Skip to content

Commit 5e9e4aa

Browse files
Added posibility for working with proxy and some improvements
1 parent f7dada8 commit 5e9e4aa

19 files changed

+1009
-358
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ log.txt
1414
/_build
1515
/_bundle
1616

17-
/.defold
17+
/.defold
18+
/.editor_settings

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@
222222
"mlerp",
223223
"photogram",
224224
"substep",
225-
"unmark"
225+
"unmark",
226+
"dirtylarry"
226227
],
227228

228229
}

atlas_loader/atlas_data.script

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1+
local atlas_loader = require "atlas_loader.atlas_loader"
2+
13
go.property("atlas", resource.atlas())
4+
go.property("atlas_name", hash("NAME"))
5+
6+
---@class atlas_data
7+
---@field atlas_name hash
8+
---@field atlas hash
29

10+
---Initilaize object
11+
---@param self atlas_data
312
function init(self)
13+
atlas_loader.atlas_loaded(self.atlas_name, self.atlas)
14+
end
15+
16+
---Final object
17+
---@param self atlas_data
18+
function final(self)
19+
atlas_loader.atlas_unloaded(self.atlas_name)
420
end

atlas_loader/atlas_factory.script

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
local atlas_loader = require("atlas_loader.atlas_loader")
22

3-
local ATLAS = hash("atlas")
4-
local SCRIPT_NAME = "atlas_data"
5-
63
go.property("atlas_name", hash("NAME"))
74
go.property("atlas_factory", msg.url("#factory"))
85

@@ -11,16 +8,15 @@ go.property("atlas_factory", msg.url("#factory"))
118
---@field atlas_name hash
129
---@field atlas_factory url
1310

11+
local LOAD_ATLAS = hash("LOAD_ATLAS")
12+
local UNLOAD_ATLAS = hash("UNLOAD_ATLAS")
13+
1414
---Load new atlas
1515
---@param self atlas_factory
1616
local function load_atlas(self)
1717
factory.load(self.atlas_factory, function(_, url, result)
1818
if result then
1919
self.current_object = factory.create(url)
20-
local script_path = msg.url(self.current_object)
21-
script_path.fragment = SCRIPT_NAME
22-
local atlas = go.get(script_path, ATLAS)
23-
atlas_loader.atlas_loaded(self.atlas_name, atlas)
2420
else
2521
error("Atlas not loaded: " .. tostring(self.atlas_factory), 2)
2622
end
@@ -35,7 +31,6 @@ local function unload_atlas(self)
3531
self.current_object = nil
3632
timer.delay(0, false, function()
3733
factory.unload(self.atlas_factory)
38-
atlas_loader.atlas_unloaded(self.atlas_name)
3934
end)
4035
end
4136
end
@@ -52,9 +47,15 @@ end
5247
---@param message table
5348
---@param sender url
5449
function on_message(self, message_id, message, sender)
55-
if message_id == atlas_loader.LOAD_ATLAS then
50+
if message_id == LOAD_ATLAS then
5651
load_atlas(self)
57-
elseif message_id == atlas_loader.UNLOAD_ATLAS then
52+
elseif message_id == UNLOAD_ATLAS then
5853
unload_atlas(self)
5954
end
6055
end
56+
57+
---Mark atlas as unloaded
58+
---@param self atlas_factory
59+
function final(self)
60+
atlas_loader.unregister_factory(self.atlas_name)
61+
end

0 commit comments

Comments
 (0)