-
Notifications
You must be signed in to change notification settings - Fork 27
/
coreelementunitsequence.lua
48 lines (35 loc) · 1.26 KB
/
coreelementunitsequence.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
core:module("CoreElementUnitSequence")
core:import("CoreMissionScriptElement")
core:import("CoreCode")
core:import("CoreUnit")
ElementUnitSequence = ElementUnitSequence or class(CoreMissionScriptElement.MissionScriptElement)
function ElementUnitSequence:init(...)
ElementUnitSequence.super.init(self, ...)
self._unit = CoreUnit.safe_spawn_unit("core/units/run_sequence_dummy/run_sequence_dummy", self._values.position)
managers.worlddefinition:add_trigger_sequence(self._unit, self._values.trigger_list)
end
function ElementUnitSequence:on_script_activated()
self._mission_script:add_save_state_cb(self._id)
end
function ElementUnitSequence:client_on_executed(...)
self:on_executed(...)
end
function ElementUnitSequence:on_executed(instigator)
if not self._values.enabled then
return
end
local run_sequence = true
if self._values.only_for_local_player then
run_sequence = not managers.player:player_unit() or instigator == managers.player:player_unit()
end
if run_sequence then
self._unit:damage():run_sequence_simple("run_sequence")
end
ElementUnitSequence.super.on_executed(self, instigator)
end
function ElementUnitSequence:save(data)
data.enabled = self._values.enabled
end
function ElementUnitSequence:load(data)
self:set_enabled(data.enabled)
end