1
1
local atlas_loader = require("atlas_loader.atlas_loader")
2
2
3
- local ATLAS = hash("atlas")
4
- local SCRIPT_NAME = "atlas_data"
5
-
6
3
go.property("atlas_name", hash("NAME"))
7
4
go.property("atlas_factory", msg.url("#factory"))
8
5
@@ -11,16 +8,15 @@ go.property("atlas_factory", msg.url("#factory"))
11
8
---@field atlas_name hash
12
9
---@field atlas_factory url
13
10
11
+ local LOAD_ATLAS = hash("LOAD_ATLAS")
12
+ local UNLOAD_ATLAS = hash("UNLOAD_ATLAS")
13
+
14
14
---Load new atlas
15
15
---@param self atlas_factory
16
16
local function load_atlas(self)
17
17
factory.load(self.atlas_factory, function(_, url, result)
18
18
if result then
19
19
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)
24
20
else
25
21
error("Atlas not loaded: " .. tostring(self.atlas_factory), 2)
26
22
end
@@ -35,7 +31,6 @@ local function unload_atlas(self)
35
31
self.current_object = nil
36
32
timer.delay(0, false, function()
37
33
factory.unload(self.atlas_factory)
38
- atlas_loader.atlas_unloaded(self.atlas_name)
39
34
end)
40
35
end
41
36
end
52
47
---@param message table
53
48
---@param sender url
54
49
function on_message(self, message_id, message, sender)
55
- if message_id == atlas_loader. LOAD_ATLAS then
50
+ if message_id == LOAD_ATLAS then
56
51
load_atlas(self)
57
- elseif message_id == atlas_loader. UNLOAD_ATLAS then
52
+ elseif message_id == UNLOAD_ATLAS then
58
53
unload_atlas(self)
59
54
end
60
55
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