warscript 0.0.1-dev.7c9c5d2 → 0.0.1-dev.7d7d4b4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/types/timer.d.ts +1 -1
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +11 -3
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +26 -0
- package/engine/behaviour/unit.lua +163 -4
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +18 -2
- package/engine/internal/item/ability.lua +63 -11
- package/engine/internal/item.d.ts +3 -1
- package/engine/internal/item.lua +75 -3
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +62 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +8 -2
- package/engine/internal/unit.lua +136 -58
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +6 -3
- package/engine/object-field.lua +85 -73
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +1 -1
- package/utility/functions.d.ts +5 -0
- package/utility/functions.lua +5 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/core/types/timer.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class Timer extends AbstractDestroyable {
|
|
|
22
22
|
pause(): void;
|
|
23
23
|
resume(): void;
|
|
24
24
|
static create(): Timer;
|
|
25
|
-
static run<Args extends any[]>(callback: (...args: Args) => void, ...args: Args): void;
|
|
25
|
+
static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): void;
|
|
26
26
|
static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
|
|
27
27
|
static periodic<Args extends any[]>(period: number, callback: (this: void, timer: Timer, ...args: Args) => void, ...args: Args): Timer;
|
|
28
28
|
static counted(period: number, count: number, callback: (this: void, timer: Timer) => void): Timer;
|
package/engine/behavior.d.ts
CHANGED
|
@@ -24,5 +24,7 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
|
|
|
24
24
|
static forFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, count: number, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
|
|
25
25
|
static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => unknown, ...parameters: ConsumerParameters): number;
|
|
26
26
|
static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
|
|
27
|
+
static reduce<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[], Accumulator, R>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, operation: (accumulator: Accumulator, value: R) => Accumulator, initial: Accumulator, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => R, ...parameters: ConsumerParameters): Accumulator;
|
|
28
|
+
static reduce<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], Accumulator, R, K extends KeysOfType<T, (this: T, ...args: any) => R>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, operation: (accumulator: Accumulator, value: R) => Accumulator, initial: Accumulator, key: K, ...parameters: T[K] extends (this: T, ...args: any) => R ? Parameters<T[K]> : never): Accumulator;
|
|
27
29
|
}
|
|
28
30
|
export {};
|
package/engine/behavior.lua
CHANGED
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
-
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
5
|
local ____exports = {}
|
|
6
6
|
local ____destroyable = require("destroyable")
|
|
7
7
|
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
8
8
|
local ____timer = require("core.types.timer")
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
|
+
local ____functions = require("utility.functions")
|
|
11
|
+
local increment = ____functions.increment
|
|
10
12
|
local safeCall = warpack.safeCall
|
|
11
13
|
local firstBehaviorByObject = {}
|
|
12
14
|
local lastBehaviorByObject = {}
|
|
13
15
|
local function invokeBehaviorOnPeriod(behavior, ...)
|
|
14
16
|
behavior.onPeriod(behavior, ...)
|
|
15
17
|
end
|
|
18
|
+
local function reduceBehaviors(behaviorConstructor, object, operation, initial, consumerOrKey, ...)
|
|
19
|
+
local result = initial
|
|
20
|
+
local behavior = firstBehaviorByObject[object]
|
|
21
|
+
if behavior ~= nil then
|
|
22
|
+
if type(consumerOrKey) == "function" then
|
|
23
|
+
repeat
|
|
24
|
+
do
|
|
25
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
26
|
+
result = operation(
|
|
27
|
+
result,
|
|
28
|
+
safeCall(consumerOrKey, behavior, ...)
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
behavior = behavior[1]
|
|
32
|
+
end
|
|
33
|
+
until not (behavior ~= nil)
|
|
34
|
+
else
|
|
35
|
+
repeat
|
|
36
|
+
do
|
|
37
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
38
|
+
result = operation(
|
|
39
|
+
result,
|
|
40
|
+
safeCall(behavior[consumerOrKey], behavior, ...)
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
behavior = behavior[1]
|
|
44
|
+
end
|
|
45
|
+
until not (behavior ~= nil)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
return result
|
|
49
|
+
end
|
|
16
50
|
____exports.Behavior = __TS__Class()
|
|
17
51
|
local Behavior = ____exports.Behavior
|
|
18
52
|
Behavior.name = "Behavior"
|
|
@@ -151,31 +185,23 @@ function Behavior.forFirst(self, object, count, consumerOrKey, ...)
|
|
|
151
185
|
return behaviorsCount
|
|
152
186
|
end
|
|
153
187
|
function Behavior.forAll(self, object, consumerOrKey, ...)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
behaviorsCount = behaviorsCount + 1
|
|
173
|
-
end
|
|
174
|
-
behavior = behavior[1]
|
|
175
|
-
end
|
|
176
|
-
until not (behavior ~= nil)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
return behaviorsCount
|
|
188
|
+
return reduceBehaviors(
|
|
189
|
+
self,
|
|
190
|
+
object,
|
|
191
|
+
increment,
|
|
192
|
+
0,
|
|
193
|
+
consumerOrKey,
|
|
194
|
+
...
|
|
195
|
+
)
|
|
196
|
+
end
|
|
197
|
+
function Behavior.reduce(self, object, operation, initial, consumerOrKey, ...)
|
|
198
|
+
return reduceBehaviors(
|
|
199
|
+
self,
|
|
200
|
+
object,
|
|
201
|
+
operation,
|
|
202
|
+
initial,
|
|
203
|
+
consumerOrKey,
|
|
204
|
+
...
|
|
205
|
+
)
|
|
180
206
|
end
|
|
181
207
|
return ____exports
|
|
@@ -148,7 +148,7 @@ function ApplyBuffChannelingTargetAbilityBehavior.prototype.onStop(self)
|
|
|
148
148
|
self.buff = nil
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
|
-
Buff.
|
|
151
|
+
Buff.beingDestroyedEvent:addListener(function(buff)
|
|
152
152
|
local behavior = behaviorByBuff[buff]
|
|
153
153
|
if behavior ~= nil then
|
|
154
154
|
behaviorByBuff[buff] = nil
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { AbilityBehavior } from "../ability";
|
|
3
3
|
import { Unit } from "../../internal/unit";
|
|
4
4
|
export declare abstract class EmulateImpactAbilityBehavior extends AbilityBehavior {
|
|
5
|
-
protected emulateImpact(caster: Unit):
|
|
5
|
+
protected emulateImpact(caster: Unit): boolean;
|
|
6
6
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
4
5
|
local ____exports = {}
|
|
5
6
|
local ____ability = require("engine.behaviour.ability")
|
|
6
7
|
local AbilityBehavior = ____ability.AbilityBehavior
|
|
8
|
+
local ____unit = require("engine.internal.unit")
|
|
9
|
+
local Unit = ____unit.Unit
|
|
7
10
|
local ____ability = require("engine.standard.fields.ability")
|
|
8
11
|
local COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD = ____ability.COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD
|
|
9
12
|
local MANA_COST_ABILITY_INTEGER_LEVEL_FIELD = ____ability.MANA_COST_ABILITY_INTEGER_LEVEL_FIELD
|
|
@@ -13,6 +16,10 @@ local MINIMUM_POSITIVE_NORMALIZED_FLOAT = ____math.MINIMUM_POSITIVE_NORMALIZED_F
|
|
|
13
16
|
local ____sound = require("core.types.sound")
|
|
14
17
|
local Sound3D = ____sound.Sound3D
|
|
15
18
|
local SoundSettings = ____sound.SoundSettings
|
|
19
|
+
local ____ability = require("engine.internal.ability")
|
|
20
|
+
local UnitAbility = ____ability.UnitAbility
|
|
21
|
+
local ____event = require("event")
|
|
22
|
+
local Event = ____event.Event
|
|
16
23
|
____exports.EmulateImpactAbilityBehavior = __TS__Class()
|
|
17
24
|
local EmulateImpactAbilityBehavior = ____exports.EmulateImpactAbilityBehavior
|
|
18
25
|
EmulateImpactAbilityBehavior.name = "EmulateImpactAbilityBehavior"
|
|
@@ -20,8 +27,8 @@ __TS__ClassExtends(EmulateImpactAbilityBehavior, AbilityBehavior)
|
|
|
20
27
|
function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
21
28
|
local manaCost = self:resolveCurrentAbilityDependentValue(MANA_COST_ABILITY_INTEGER_LEVEL_FIELD)
|
|
22
29
|
local cooldown = self:resolveCurrentAbilityDependentValue(COOLDOWN_ABILITY_FLOAT_LEVEL_FIELD)
|
|
23
|
-
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost then
|
|
24
|
-
return
|
|
30
|
+
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost or __TS__InstanceOf(self.ability, UnitAbility) and self.ability.isDisabled then
|
|
31
|
+
return false
|
|
25
32
|
end
|
|
26
33
|
caster.mana = caster.mana - manaCost
|
|
27
34
|
self.ability.cooldownRemaining = max(cooldown, MINIMUM_POSITIVE_NORMALIZED_FLOAT)
|
|
@@ -30,6 +37,7 @@ function EmulateImpactAbilityBehavior.prototype.emulateImpact(self, caster)
|
|
|
30
37
|
if soundPresetId ~= "" then
|
|
31
38
|
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
32
39
|
end
|
|
33
|
-
|
|
40
|
+
Event.invoke(Unit.abilityImpactEvent, caster, self.ability)
|
|
41
|
+
return true
|
|
34
42
|
end
|
|
35
43
|
return ____exports
|
|
@@ -5,7 +5,6 @@ local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
|
5
5
|
local __TS__New = ____lualib.__TS__New
|
|
6
6
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
7
7
|
local ____exports = {}
|
|
8
|
-
local createUnitEventListener
|
|
9
8
|
local ____behavior = require("engine.behavior")
|
|
10
9
|
local Behavior = ____behavior.Behavior
|
|
11
10
|
local ____unit = require("engine.unit")
|
|
@@ -30,17 +29,9 @@ local ____ability = require("engine.object-field.ability")
|
|
|
30
29
|
local AbilityField = ____ability.AbilityField
|
|
31
30
|
local AbilityLevelField = ____ability.AbilityLevelField
|
|
32
31
|
local resolveCurrentAbilityDependentValue = ____ability.resolveCurrentAbilityDependentValue
|
|
33
|
-
local ____timer = require("core.types.timer")
|
|
34
|
-
local Timer = ____timer.Timer
|
|
35
32
|
local createBehaviorFunctionsByAbilityTypeId = {}
|
|
36
33
|
local exclusiveOnImpactHandlerAbilityBehaviorByAbility = setmetatable({}, {__mode = "k"})
|
|
37
|
-
local function
|
|
38
|
-
local unitEventListener = createUnitEventListener(key)
|
|
39
|
-
return function(unit, ability, ...)
|
|
40
|
-
Timer:run(unitEventListener, unit, ability, ...)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
createUnitEventListener = function(key)
|
|
34
|
+
local function createUnitEventListener(key)
|
|
44
35
|
return function(unit, ability, ...)
|
|
45
36
|
____exports.AbilityBehavior:forAll(ability, key, unit, ...)
|
|
46
37
|
end
|
|
@@ -274,13 +265,13 @@ __TS__SetDescriptor(
|
|
|
274
265
|
Unit.abilityDestructibleTargetChannelingStartEvent:addListener(createUnitEventListener("onDestructibleTargetChannelingStart"))
|
|
275
266
|
Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
|
|
276
267
|
Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
|
|
277
|
-
Unit.
|
|
278
|
-
Unit.
|
|
279
|
-
Unit.
|
|
280
|
-
Unit.
|
|
281
|
-
Unit.
|
|
282
|
-
Unit.
|
|
283
|
-
Unit.
|
|
268
|
+
Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
|
|
269
|
+
Unit.abilityWidgetTargetImpactEvent:addListener(createUnitEventListener("onWidgetTargetImpact"))
|
|
270
|
+
Unit.abilityUnitTargetImpactEvent:addListener(createUnitEventListener("onUnitTargetImpact"))
|
|
271
|
+
Unit.abilityItemTargetImpactEvent:addListener(createUnitEventListener("onItemTargetImpact"))
|
|
272
|
+
Unit.abilityDestructibleTargetImpactEvent:addListener(createUnitEventListener("onDestructibleTargetImpact"))
|
|
273
|
+
Unit.abilityPointTargetImpactEvent:addListener(createUnitEventListener("onPointTargetImpact"))
|
|
274
|
+
Unit.abilityNoTargetImpactEvent:addListener(createUnitEventListener("onNoTargetImpact"))
|
|
284
275
|
Unit.abilityChannelingFinishEvent:addListener(createUnitEventListener("onChannelingFinish"))
|
|
285
276
|
Unit.abilityStopEvent:addListener(createUnitEventListener("onStop"))
|
|
286
277
|
end)(AbilityBehavior)
|
|
@@ -10,9 +10,11 @@ export type StunImmunityUnitBehaviourParameters = {
|
|
|
10
10
|
textTagText?: string;
|
|
11
11
|
};
|
|
12
12
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
13
|
-
|
|
13
|
+
readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
|
|
14
14
|
static defaultParameters: StunImmunityUnitBehaviourParameters;
|
|
15
|
-
constructor(unit: Unit, parameters?: StunImmunityUnitBehaviourParameters);
|
|
15
|
+
constructor(unit: Unit, parameters?: Readonly<StunImmunityUnitBehaviourParameters>);
|
|
16
16
|
protected onDestroy(): Destructor;
|
|
17
|
-
|
|
17
|
+
onDamageReceived(): void;
|
|
18
|
+
onTargetingAbilityChannelingStart(): void;
|
|
19
|
+
onTargetingAbilityImpact(): void;
|
|
18
20
|
}
|
|
@@ -12,31 +12,46 @@ local flatMapToLuaSet = ____arrays.flatMapToLuaSet
|
|
|
12
12
|
local map = ____arrays.map
|
|
13
13
|
local ____text_2Dtag = require("engine.text-tag")
|
|
14
14
|
local TextTag = ____text_2Dtag.TextTag
|
|
15
|
+
local ____timer = require("core.types.timer")
|
|
16
|
+
local Timer = ____timer.Timer
|
|
15
17
|
local DEFAULT_BUFF_TYPE_IDS = postcompile(function()
|
|
16
18
|
return flatMapToLuaSet(
|
|
17
19
|
AbilityType:getAllByBaseIds(map({
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
20
|
+
"AHtb",
|
|
21
|
+
"AHbh",
|
|
22
|
+
"AOws",
|
|
23
|
+
"AOw2",
|
|
24
|
+
"AUim",
|
|
25
|
+
"Acyc",
|
|
26
|
+
"ANfb",
|
|
27
|
+
"ANsb",
|
|
28
|
+
"ANcs",
|
|
29
|
+
"ANc1",
|
|
30
|
+
"ANc2",
|
|
31
|
+
"ANc3",
|
|
32
|
+
"ACbh",
|
|
33
|
+
"ANbh",
|
|
34
|
+
"SCc1",
|
|
35
|
+
"ACcy",
|
|
36
|
+
"ANb2",
|
|
37
|
+
"Awrs",
|
|
38
|
+
"Awrh",
|
|
39
|
+
"Awrg",
|
|
40
|
+
"ACtb",
|
|
41
|
+
"ACcb"
|
|
36
42
|
}, fourCC)),
|
|
37
43
|
function(abilityType) return __TS__ArrayFlat(abilityType.buffTypeIds) end
|
|
38
44
|
)
|
|
39
45
|
end)
|
|
46
|
+
local function process(behavior)
|
|
47
|
+
local hasRemovedBuffs = false
|
|
48
|
+
for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
|
+
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
|
+
end
|
|
51
|
+
if hasRemovedBuffs and behavior.parameters.textTagText ~= nil then
|
|
52
|
+
TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
40
55
|
____exports.StunImmunityUnitBehavior = __TS__Class()
|
|
41
56
|
local StunImmunityUnitBehavior = ____exports.StunImmunityUnitBehavior
|
|
42
57
|
StunImmunityUnitBehavior.name = "StunImmunityUnitBehavior"
|
|
@@ -48,20 +63,21 @@ function StunImmunityUnitBehavior.prototype.____constructor(self, unit, paramete
|
|
|
48
63
|
UnitBehavior.prototype.____constructor(self, unit)
|
|
49
64
|
self.parameters = parameters
|
|
50
65
|
unit:decrementStunCounter()
|
|
51
|
-
self
|
|
66
|
+
process(self)
|
|
52
67
|
end
|
|
53
68
|
function StunImmunityUnitBehavior.prototype.onDestroy(self)
|
|
54
69
|
self.unit:incrementStunCounter()
|
|
55
70
|
return UnitBehavior.prototype.onDestroy(self)
|
|
56
71
|
end
|
|
57
|
-
function StunImmunityUnitBehavior.prototype.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
function StunImmunityUnitBehavior.prototype.onDamageReceived(self)
|
|
73
|
+
process(self)
|
|
74
|
+
Timer:run(process, self)
|
|
75
|
+
end
|
|
76
|
+
function StunImmunityUnitBehavior.prototype.onTargetingAbilityChannelingStart(self)
|
|
77
|
+
process(self)
|
|
78
|
+
end
|
|
79
|
+
function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
|
|
80
|
+
process(self)
|
|
65
81
|
end
|
|
66
82
|
StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
|
|
67
83
|
return ____exports
|
|
@@ -6,23 +6,49 @@ import "../internal/unit+ability";
|
|
|
6
6
|
import "../internal/unit-missile-launch";
|
|
7
7
|
import { Item } from "../internal/item";
|
|
8
8
|
import type { AbilityBehavior } from "./ability";
|
|
9
|
+
import { Event } from "../../event";
|
|
10
|
+
import { Destructor } from "../../destroyable";
|
|
11
|
+
import type { Widget } from "../../core/types/widget";
|
|
12
|
+
import { Destructable } from "../../core/types/destructable";
|
|
13
|
+
import type { Buff } from "../buff";
|
|
9
14
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
10
15
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
11
16
|
constructor(unit: Unit);
|
|
17
|
+
protected onDestroy(): Destructor;
|
|
12
18
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
13
19
|
get unit(): Unit;
|
|
20
|
+
registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractUnit: (...args: Args) => Unit | undefined, range: number, listener: T): void;
|
|
21
|
+
onImmediateOrder(orderId: number): void;
|
|
22
|
+
onTargetOrder(orderId: number, target: Widget): void;
|
|
23
|
+
onPointOrder(orderId: number, x: number, y: number): void;
|
|
14
24
|
onAutoAttackStart(target: Unit): void;
|
|
15
25
|
onAutoAttackFinish(target: Unit): void;
|
|
26
|
+
onTargetingAutoAttackStart(source: Unit): void;
|
|
27
|
+
onTargetingAutoAttackFinish(source: Unit): void;
|
|
16
28
|
onDamageDealing(target: Unit, event: DamagingEvent): void;
|
|
17
29
|
onDamageDealt(target: Unit, event: DamageEvent): void;
|
|
18
30
|
onDamageReceiving(source: Unit | undefined, event: DamagingEvent): void;
|
|
19
31
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
20
32
|
onAbilityGained(ability: Ability): void;
|
|
21
33
|
onAbilityLost(ability: Ability): void;
|
|
34
|
+
onAbilityChannelingStart(ability: Ability): void;
|
|
35
|
+
onAbilityImpact(ability: Ability): void;
|
|
36
|
+
onAbilityWidgetTargetImpact(ability: Ability, target: Widget): void;
|
|
37
|
+
onAbilityUnitTargetImpact(ability: Ability, target: Unit): void;
|
|
38
|
+
onAbilityItemTargetImpact(ability: Ability, target: Item): void;
|
|
39
|
+
onAbilityDestructibleTargetImpact(ability: Ability, target: Destructable): void;
|
|
40
|
+
onAbilityPointTargetImpact(ability: Ability, x: number, y: number): void;
|
|
41
|
+
onAbilityNoTargetImpact(ability: Ability): void;
|
|
42
|
+
onAbilityChannelingFinish(ability: Ability): void;
|
|
43
|
+
onAbilityStop(ability: Ability): void;
|
|
44
|
+
onTargetingAbilityChannelingStart(ability: Ability, source: Unit): void;
|
|
45
|
+
onTargetingAbilityImpact(ability: Ability, source: Unit): void;
|
|
46
|
+
onBuffGained(buff: Buff): void;
|
|
22
47
|
onItemDropped(item: Item): void;
|
|
23
48
|
onItemPickedUp(item: Item): void;
|
|
24
49
|
onItemUsed(item: Item): void;
|
|
25
50
|
onItemStacked(item: Item): void;
|
|
51
|
+
onItemChargesChanged(item: Item): void;
|
|
26
52
|
onKill(target: Unit): void;
|
|
27
53
|
onDeath(source: Unit | undefined): void;
|
|
28
54
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____behavior = require("engine.behavior")
|
|
@@ -9,6 +10,17 @@ local ____unit = require("engine.internal.unit")
|
|
|
9
10
|
local Unit = ____unit.Unit
|
|
10
11
|
require("engine.internal.unit+ability")
|
|
11
12
|
require("engine.internal.unit-missile-launch")
|
|
13
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
14
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
15
|
+
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
16
|
+
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
17
|
+
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
|
+
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
20
|
+
local behaviorsByEvent = {}
|
|
21
|
+
local rangeByBehaviorByEvent = {}
|
|
22
|
+
local listenerByBehaviorByEvent = {}
|
|
23
|
+
local eventsByBehavior = {}
|
|
12
24
|
____exports.UnitBehavior = __TS__Class()
|
|
13
25
|
local UnitBehavior = ____exports.UnitBehavior
|
|
14
26
|
UnitBehavior.name = "UnitBehavior"
|
|
@@ -16,10 +28,69 @@ __TS__ClassExtends(UnitBehavior, Behavior)
|
|
|
16
28
|
function UnitBehavior.prototype.____constructor(self, unit)
|
|
17
29
|
Behavior.prototype.____constructor(self, unit)
|
|
18
30
|
end
|
|
31
|
+
function UnitBehavior.prototype.onDestroy(self)
|
|
32
|
+
local events = eventsByBehavior[self]
|
|
33
|
+
if events ~= nil then
|
|
34
|
+
for event in pairs(events) do
|
|
35
|
+
local ____opt_0 = behaviorsByEvent[event]
|
|
36
|
+
if ____opt_0 ~= nil then
|
|
37
|
+
____opt_0:remove(self)
|
|
38
|
+
end
|
|
39
|
+
local ____opt_2 = rangeByBehaviorByEvent[event]
|
|
40
|
+
if ____opt_2 ~= nil then
|
|
41
|
+
____opt_2[self] = nil
|
|
42
|
+
end
|
|
43
|
+
local ____opt_4 = listenerByBehaviorByEvent[event]
|
|
44
|
+
if ____opt_4 ~= nil then
|
|
45
|
+
____opt_4[self] = nil
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
eventsByBehavior[self] = nil
|
|
49
|
+
end
|
|
50
|
+
return Behavior.prototype.onDestroy(self)
|
|
51
|
+
end
|
|
52
|
+
function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, extractUnit, range, listener)
|
|
53
|
+
local rangeByBehavior = getOrPut(rangeByBehaviorByEvent, event, mutableLuaMap)
|
|
54
|
+
rangeByBehavior[self] = range
|
|
55
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
56
|
+
listenerByBehavior[self] = listener
|
|
57
|
+
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
58
|
+
local behaviors = behaviorsByEvent[event]
|
|
59
|
+
if behaviors == nil then
|
|
60
|
+
event:addListener(function(...)
|
|
61
|
+
local behaviors = behaviorsByEvent[event]
|
|
62
|
+
if behaviors ~= nil then
|
|
63
|
+
local unit = extractUnit(...)
|
|
64
|
+
if unit ~= nil then
|
|
65
|
+
for behavior in pairs(behaviors) do
|
|
66
|
+
local range = rangeByBehavior[behavior]
|
|
67
|
+
if range ~= nil and unit:getCollisionDistanceTo(behavior.unit) <= range then
|
|
68
|
+
local ____self_6 = behavior
|
|
69
|
+
____self_6[listenerByBehavior[behavior]](____self_6, ...)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end)
|
|
75
|
+
behaviors = __TS__New(LinkedSet)
|
|
76
|
+
behaviorsByEvent[event] = behaviors
|
|
77
|
+
end
|
|
78
|
+
behaviors:add(self)
|
|
79
|
+
end
|
|
80
|
+
function UnitBehavior.prototype.onImmediateOrder(self, orderId)
|
|
81
|
+
end
|
|
82
|
+
function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
|
|
83
|
+
end
|
|
84
|
+
function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
|
|
85
|
+
end
|
|
19
86
|
function UnitBehavior.prototype.onAutoAttackStart(self, target)
|
|
20
87
|
end
|
|
21
88
|
function UnitBehavior.prototype.onAutoAttackFinish(self, target)
|
|
22
89
|
end
|
|
90
|
+
function UnitBehavior.prototype.onTargetingAutoAttackStart(self, source)
|
|
91
|
+
end
|
|
92
|
+
function UnitBehavior.prototype.onTargetingAutoAttackFinish(self, source)
|
|
93
|
+
end
|
|
23
94
|
function UnitBehavior.prototype.onDamageDealing(self, target, event)
|
|
24
95
|
end
|
|
25
96
|
function UnitBehavior.prototype.onDamageDealt(self, target, event)
|
|
@@ -32,6 +103,32 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
|
|
|
32
103
|
end
|
|
33
104
|
function UnitBehavior.prototype.onAbilityLost(self, ability)
|
|
34
105
|
end
|
|
106
|
+
function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
|
|
107
|
+
end
|
|
108
|
+
function UnitBehavior.prototype.onAbilityImpact(self, ability)
|
|
109
|
+
end
|
|
110
|
+
function UnitBehavior.prototype.onAbilityWidgetTargetImpact(self, ability, target)
|
|
111
|
+
end
|
|
112
|
+
function UnitBehavior.prototype.onAbilityUnitTargetImpact(self, ability, target)
|
|
113
|
+
end
|
|
114
|
+
function UnitBehavior.prototype.onAbilityItemTargetImpact(self, ability, target)
|
|
115
|
+
end
|
|
116
|
+
function UnitBehavior.prototype.onAbilityDestructibleTargetImpact(self, ability, target)
|
|
117
|
+
end
|
|
118
|
+
function UnitBehavior.prototype.onAbilityPointTargetImpact(self, ability, x, y)
|
|
119
|
+
end
|
|
120
|
+
function UnitBehavior.prototype.onAbilityNoTargetImpact(self, ability)
|
|
121
|
+
end
|
|
122
|
+
function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
|
|
123
|
+
end
|
|
124
|
+
function UnitBehavior.prototype.onAbilityStop(self, ability)
|
|
125
|
+
end
|
|
126
|
+
function UnitBehavior.prototype.onTargetingAbilityChannelingStart(self, ability, source)
|
|
127
|
+
end
|
|
128
|
+
function UnitBehavior.prototype.onTargetingAbilityImpact(self, ability, source)
|
|
129
|
+
end
|
|
130
|
+
function UnitBehavior.prototype.onBuffGained(self, buff)
|
|
131
|
+
end
|
|
35
132
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
36
133
|
end
|
|
37
134
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -40,6 +137,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
|
|
|
40
137
|
end
|
|
41
138
|
function UnitBehavior.prototype.onItemStacked(self, item)
|
|
42
139
|
end
|
|
140
|
+
function UnitBehavior.prototype.onItemChargesChanged(self, item)
|
|
141
|
+
end
|
|
43
142
|
function UnitBehavior.prototype.onKill(self, target)
|
|
44
143
|
end
|
|
45
144
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
@@ -53,11 +152,28 @@ __TS__SetDescriptor(
|
|
|
53
152
|
true
|
|
54
153
|
);
|
|
55
154
|
(function(self)
|
|
155
|
+
Unit.onImmediateOrder:addListener(function(source, orderId)
|
|
156
|
+
____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
|
|
157
|
+
end)
|
|
158
|
+
Unit.onTargetOrder:addListener(function(source, orderId, target)
|
|
159
|
+
____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
|
|
160
|
+
end)
|
|
161
|
+
Unit.onPointOrder:addListener(function(source, orderId, x, y)
|
|
162
|
+
____exports.UnitBehavior:forAll(
|
|
163
|
+
source,
|
|
164
|
+
"onPointOrder",
|
|
165
|
+
orderId,
|
|
166
|
+
x,
|
|
167
|
+
y
|
|
168
|
+
)
|
|
169
|
+
end)
|
|
56
170
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
57
171
|
____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
|
|
172
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
|
|
58
173
|
end)
|
|
59
174
|
Unit.autoAttackFinishEvent:addListener(function(source, target)
|
|
60
175
|
____exports.UnitBehavior:forAll(source, "onAutoAttackFinish", target)
|
|
176
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackFinish", source)
|
|
61
177
|
end)
|
|
62
178
|
Unit.onDamaging:addListener(function(source, target, event)
|
|
63
179
|
if source ~= nil then
|
|
@@ -71,11 +187,51 @@ __TS__SetDescriptor(
|
|
|
71
187
|
end
|
|
72
188
|
____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
|
|
73
189
|
end)
|
|
74
|
-
Unit.abilityGainedEvent:addListener(function(source,
|
|
75
|
-
____exports.UnitBehavior:forAll(source, "onAbilityGained",
|
|
190
|
+
Unit.abilityGainedEvent:addListener(function(source, ability)
|
|
191
|
+
____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
|
|
192
|
+
end)
|
|
193
|
+
Unit.abilityLostEvent:addListener(function(source, ability)
|
|
194
|
+
____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
|
|
195
|
+
end)
|
|
196
|
+
Unit.abilityChannelingStartEvent:addListener(function(source, ability)
|
|
197
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
|
|
198
|
+
end)
|
|
199
|
+
Unit.abilityUnitTargetChannelingStartEvent:addListener(function(source, ability, target)
|
|
200
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAbilityChannelingStart", ability, source)
|
|
76
201
|
end)
|
|
77
|
-
Unit.
|
|
78
|
-
____exports.UnitBehavior:forAll(source, "
|
|
202
|
+
Unit.abilityImpactEvent:addListener(function(source, ability)
|
|
203
|
+
____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
|
|
204
|
+
end)
|
|
205
|
+
Unit.abilityWidgetTargetImpactEvent:addListener(function(source, ability, target)
|
|
206
|
+
____exports.UnitBehavior:forAll(source, "onAbilityWidgetTargetImpact", ability, target)
|
|
207
|
+
end)
|
|
208
|
+
Unit.abilityUnitTargetImpactEvent:addListener(function(source, ability, target)
|
|
209
|
+
____exports.UnitBehavior:forAll(source, "onAbilityUnitTargetImpact", ability, target)
|
|
210
|
+
____exports.UnitBehavior:forAll(target, "onTargetingAbilityImpact", ability, source)
|
|
211
|
+
end)
|
|
212
|
+
Unit.abilityItemTargetImpactEvent:addListener(function(source, ability, target)
|
|
213
|
+
____exports.UnitBehavior:forAll(source, "onAbilityItemTargetImpact", ability, target)
|
|
214
|
+
end)
|
|
215
|
+
Unit.abilityDestructibleTargetImpactEvent:addListener(function(source, ability, target)
|
|
216
|
+
____exports.UnitBehavior:forAll(source, "onAbilityDestructibleTargetImpact", ability, target)
|
|
217
|
+
end)
|
|
218
|
+
Unit.abilityPointTargetImpactEvent:addListener(function(source, ability, x, y)
|
|
219
|
+
____exports.UnitBehavior:forAll(
|
|
220
|
+
source,
|
|
221
|
+
"onAbilityPointTargetImpact",
|
|
222
|
+
ability,
|
|
223
|
+
x,
|
|
224
|
+
y
|
|
225
|
+
)
|
|
226
|
+
end)
|
|
227
|
+
Unit.abilityNoTargetImpactEvent:addListener(function(source, ability)
|
|
228
|
+
____exports.UnitBehavior:forAll(source, "onAbilityNoTargetImpact", ability)
|
|
229
|
+
end)
|
|
230
|
+
Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
|
|
231
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
|
|
232
|
+
end)
|
|
233
|
+
Unit.abilityStopEvent:addListener(function(source, ability)
|
|
234
|
+
____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
|
|
79
235
|
end)
|
|
80
236
|
Unit.deathEvent:addListener(function(target, source)
|
|
81
237
|
if source ~= nil then
|
|
@@ -95,6 +251,9 @@ __TS__SetDescriptor(
|
|
|
95
251
|
Unit.itemStackedEvent:addListener(function(unit, item)
|
|
96
252
|
____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
|
|
97
253
|
end)
|
|
254
|
+
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
255
|
+
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
256
|
+
end)
|
|
98
257
|
end)(UnitBehavior)
|
|
99
258
|
Unit.destroyEvent:addListener(function(unit)
|
|
100
259
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
package/engine/buff.d.ts
CHANGED
|
@@ -278,6 +278,7 @@ export declare class Buff<AdditionalParameters extends Prohibit<Record<string, a
|
|
|
278
278
|
onDeath(source: Unit | undefined): void;
|
|
279
279
|
onDamageDealt(target: Unit, event: DamageEvent): void;
|
|
280
280
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
281
|
-
static readonly
|
|
281
|
+
static readonly createdEvent: Event<[Buff<object>]>;
|
|
282
|
+
static readonly beingDestroyedEvent: Event<[Buff<object>]>;
|
|
282
283
|
}
|
|
283
284
|
export {};
|