warscript 0.0.1-dev.86b4b59 → 0.0.1-dev.87bdb89
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/engine/behaviour/ability/emulate-impact.lua +9 -2
- package/engine/behaviour/ability.lua +1 -1
- package/engine/behaviour/unit.d.ts +9 -0
- package/engine/behaviour/unit.lua +50 -4
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +10 -0
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +3 -1
- package/engine/internal/item.lua +75 -3
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit.d.ts +1 -0
- package/engine/internal/unit.lua +15 -0
- package/engine/object-field.d.ts +4 -3
- package/engine/object-field.lua +72 -61
- package/engine/text-tag.d.ts +12 -1
- package/engine/text-tag.lua +44 -10
- package/package.json +1 -1
|
@@ -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,7 +27,7 @@ __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
|
|
30
|
+
if self.ability.cooldownRemaining ~= 0 or caster.mana < manaCost or __TS__InstanceOf(self.ability, UnitAbility) and self.ability.isDisabled then
|
|
24
31
|
return
|
|
25
32
|
end
|
|
26
33
|
caster.mana = caster.mana - manaCost
|
|
@@ -30,6 +37,6 @@ 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)
|
|
34
41
|
end
|
|
35
42
|
return ____exports
|
|
@@ -274,7 +274,7 @@ __TS__SetDescriptor(
|
|
|
274
274
|
Unit.abilityDestructibleTargetChannelingStartEvent:addListener(createUnitEventListener("onDestructibleTargetChannelingStart"))
|
|
275
275
|
Unit.abilityPointTargetChannelingStartEvent:addListener(createUnitEventListener("onPointTargetChannelingStart"))
|
|
276
276
|
Unit.abilityNoTargetChannelingStartEvent:addListener(createUnitEventListener("onNoTargetChannelingStart"))
|
|
277
|
-
Unit.
|
|
277
|
+
Unit.abilityImpactEvent:addListener(createUnitEventListener("onImpact"))
|
|
278
278
|
Unit.abilityWidgetTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onWidgetTargetImpact"))
|
|
279
279
|
Unit.abilityUnitTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onUnitTargetImpact"))
|
|
280
280
|
Unit.abilityItemTargetChannelingStartEvent:addListener(createZeroTimerUnitEventListener("onItemTargetImpact"))
|
|
@@ -8,6 +8,7 @@ import { Item } from "../internal/item";
|
|
|
8
8
|
import type { AbilityBehavior } from "./ability";
|
|
9
9
|
import { Event } from "../../event";
|
|
10
10
|
import { Destructor } from "../../destroyable";
|
|
11
|
+
import type { Widget } from "../../core/types/widget";
|
|
11
12
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
12
13
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
13
14
|
constructor(unit: Unit);
|
|
@@ -15,6 +16,9 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
15
16
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
16
17
|
get unit(): Unit;
|
|
17
18
|
registerInRangeUnitEvent<T extends string, Args extends any[]>(this: UnitBehavior<PeriodicActionParameters> & Record<T, (this: this, unit: Unit, ...args: Args) => unknown>, event: Event<[Unit, ...Args]>, range: number, listener: T): void;
|
|
19
|
+
onImmediateOrder(orderId: number): void;
|
|
20
|
+
onTargetOrder(orderId: number, target: Widget): void;
|
|
21
|
+
onPointOrder(orderId: number, x: number, y: number): void;
|
|
18
22
|
onAutoAttackStart(target: Unit): void;
|
|
19
23
|
onAutoAttackFinish(target: Unit): void;
|
|
20
24
|
onTargetingAutoAttackStart(source: Unit): void;
|
|
@@ -25,10 +29,15 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
25
29
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
26
30
|
onAbilityGained(ability: Ability): void;
|
|
27
31
|
onAbilityLost(ability: Ability): void;
|
|
32
|
+
onAbilityChannelingStart(ability: Ability): void;
|
|
33
|
+
onAbilityImpact(ability: Ability): void;
|
|
34
|
+
onAbilityChannelingFinish(ability: Ability): void;
|
|
35
|
+
onAbilityStop(ability: Ability): void;
|
|
28
36
|
onItemDropped(item: Item): void;
|
|
29
37
|
onItemPickedUp(item: Item): void;
|
|
30
38
|
onItemUsed(item: Item): void;
|
|
31
39
|
onItemStacked(item: Item): void;
|
|
40
|
+
onItemChargesChanged(item: Item): void;
|
|
32
41
|
onKill(target: Unit): void;
|
|
33
42
|
onDeath(source: Unit | undefined): void;
|
|
34
43
|
}
|
|
@@ -74,6 +74,12 @@ function UnitBehavior.prototype.registerInRangeUnitEvent(self, event, range, lis
|
|
|
74
74
|
end
|
|
75
75
|
behaviors:add(self)
|
|
76
76
|
end
|
|
77
|
+
function UnitBehavior.prototype.onImmediateOrder(self, orderId)
|
|
78
|
+
end
|
|
79
|
+
function UnitBehavior.prototype.onTargetOrder(self, orderId, target)
|
|
80
|
+
end
|
|
81
|
+
function UnitBehavior.prototype.onPointOrder(self, orderId, x, y)
|
|
82
|
+
end
|
|
77
83
|
function UnitBehavior.prototype.onAutoAttackStart(self, target)
|
|
78
84
|
end
|
|
79
85
|
function UnitBehavior.prototype.onAutoAttackFinish(self, target)
|
|
@@ -94,6 +100,14 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
|
|
|
94
100
|
end
|
|
95
101
|
function UnitBehavior.prototype.onAbilityLost(self, ability)
|
|
96
102
|
end
|
|
103
|
+
function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
|
|
104
|
+
end
|
|
105
|
+
function UnitBehavior.prototype.onAbilityImpact(self, ability)
|
|
106
|
+
end
|
|
107
|
+
function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
|
|
108
|
+
end
|
|
109
|
+
function UnitBehavior.prototype.onAbilityStop(self, ability)
|
|
110
|
+
end
|
|
97
111
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
98
112
|
end
|
|
99
113
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -102,6 +116,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
|
|
|
102
116
|
end
|
|
103
117
|
function UnitBehavior.prototype.onItemStacked(self, item)
|
|
104
118
|
end
|
|
119
|
+
function UnitBehavior.prototype.onItemChargesChanged(self, item)
|
|
120
|
+
end
|
|
105
121
|
function UnitBehavior.prototype.onKill(self, target)
|
|
106
122
|
end
|
|
107
123
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
@@ -115,6 +131,21 @@ __TS__SetDescriptor(
|
|
|
115
131
|
true
|
|
116
132
|
);
|
|
117
133
|
(function(self)
|
|
134
|
+
Unit.onImmediateOrder:addListener(function(source, orderId)
|
|
135
|
+
____exports.UnitBehavior:forAll(source, "onImmediateOrder", orderId)
|
|
136
|
+
end)
|
|
137
|
+
Unit.onTargetOrder:addListener(function(source, orderId, target)
|
|
138
|
+
____exports.UnitBehavior:forAll(source, "onTargetOrder", orderId, target)
|
|
139
|
+
end)
|
|
140
|
+
Unit.onPointOrder:addListener(function(source, orderId, x, y)
|
|
141
|
+
____exports.UnitBehavior:forAll(
|
|
142
|
+
source,
|
|
143
|
+
"onPointOrder",
|
|
144
|
+
orderId,
|
|
145
|
+
x,
|
|
146
|
+
y
|
|
147
|
+
)
|
|
148
|
+
end)
|
|
118
149
|
Unit.autoAttackStartEvent:addListener(function(source, target)
|
|
119
150
|
____exports.UnitBehavior:forAll(source, "onAutoAttackStart", target)
|
|
120
151
|
____exports.UnitBehavior:forAll(target, "onTargetingAutoAttackStart", source)
|
|
@@ -135,11 +166,23 @@ __TS__SetDescriptor(
|
|
|
135
166
|
end
|
|
136
167
|
____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
|
|
137
168
|
end)
|
|
138
|
-
Unit.abilityGainedEvent:addListener(function(source,
|
|
139
|
-
____exports.UnitBehavior:forAll(source, "onAbilityGained",
|
|
169
|
+
Unit.abilityGainedEvent:addListener(function(source, ability)
|
|
170
|
+
____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
|
|
171
|
+
end)
|
|
172
|
+
Unit.abilityLostEvent:addListener(function(source, ability)
|
|
173
|
+
____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
|
|
140
174
|
end)
|
|
141
|
-
Unit.
|
|
142
|
-
____exports.UnitBehavior:forAll(source, "
|
|
175
|
+
Unit.abilityChannelingStartEvent:addListener(function(source, ability)
|
|
176
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
|
|
177
|
+
end)
|
|
178
|
+
Unit.abilityImpactEvent:addListener(function(source, ability)
|
|
179
|
+
____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
|
|
180
|
+
end)
|
|
181
|
+
Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
|
|
182
|
+
____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
|
|
183
|
+
end)
|
|
184
|
+
Unit.abilityStopEvent:addListener(function(source, ability)
|
|
185
|
+
____exports.UnitBehavior:forAll(source, "onAbilityStop", ability)
|
|
143
186
|
end)
|
|
144
187
|
Unit.deathEvent:addListener(function(target, source)
|
|
145
188
|
if source ~= nil then
|
|
@@ -159,6 +202,9 @@ __TS__SetDescriptor(
|
|
|
159
202
|
Unit.itemStackedEvent:addListener(function(unit, item)
|
|
160
203
|
____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
|
|
161
204
|
end)
|
|
205
|
+
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
206
|
+
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
207
|
+
end)
|
|
162
208
|
end)(UnitBehavior)
|
|
163
209
|
Unit.destroyEvent:addListener(function(unit)
|
|
164
210
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
|
@@ -55,11 +55,13 @@ export declare class UnrecognizedAbility extends Ability {
|
|
|
55
55
|
export declare class UnitAbility extends Ability {
|
|
56
56
|
readonly owner: Unit;
|
|
57
57
|
private readonly u;
|
|
58
|
+
private d?;
|
|
58
59
|
constructor(handle: jability, typeId: number, owner: Unit);
|
|
59
60
|
incrementHideCounter(): void;
|
|
60
61
|
decrementHideCounter(): void;
|
|
61
62
|
incrementDisableCounter(): void;
|
|
62
63
|
decrementDisableCounter(): void;
|
|
64
|
+
get isDisabled(): boolean;
|
|
63
65
|
get level(): number;
|
|
64
66
|
set level(v: number);
|
|
65
67
|
get cooldownRemaining(): number;
|
|
@@ -405,13 +405,23 @@ function UnitAbility.prototype.decrementHideCounter(self)
|
|
|
405
405
|
end
|
|
406
406
|
function UnitAbility.prototype.incrementDisableCounter(self)
|
|
407
407
|
unitDisableAbility(self.u, self.typeId, true, false)
|
|
408
|
+
self.d = (self.d or 0) + 1
|
|
408
409
|
end
|
|
409
410
|
function UnitAbility.prototype.decrementDisableCounter(self)
|
|
410
411
|
unitDisableAbility(self.u, self.typeId, false, false)
|
|
412
|
+
self.d = (self.d or 0) - 1
|
|
411
413
|
end
|
|
412
414
|
function UnitAbility.prototype.interruptCast(self)
|
|
413
415
|
self.owner:interruptCast(self.typeId)
|
|
414
416
|
end
|
|
417
|
+
__TS__SetDescriptor(
|
|
418
|
+
UnitAbility.prototype,
|
|
419
|
+
"isDisabled",
|
|
420
|
+
{get = function(self)
|
|
421
|
+
return self.d ~= nil and self.d > 0
|
|
422
|
+
end},
|
|
423
|
+
true
|
|
424
|
+
)
|
|
415
425
|
__TS__SetDescriptor(
|
|
416
426
|
UnitAbility.prototype,
|
|
417
427
|
"level",
|
|
@@ -55,22 +55,24 @@ local COOLDOWN_STARTER_ITEM_TYPE_ID = compiletime(function()
|
|
|
55
55
|
itemType.activelyUsed = true
|
|
56
56
|
return itemType.id
|
|
57
57
|
end)
|
|
58
|
-
|
|
58
|
+
---
|
|
59
|
+
-- @internal For use by internal systems only.
|
|
60
|
+
____exports.itemAbilityDummy = assert(CreateUnit(
|
|
59
61
|
Player.neutralVictim.handle,
|
|
60
62
|
dummyUnitId,
|
|
61
63
|
0,
|
|
62
64
|
0,
|
|
63
65
|
270
|
|
64
66
|
))
|
|
65
|
-
local cooldownStarterItem = UnitAddItemById(
|
|
67
|
+
local cooldownStarterItem = UnitAddItemById(____exports.itemAbilityDummy, COOLDOWN_STARTER_ITEM_TYPE_ID)
|
|
66
68
|
local cooldownStarterAbility = BlzGetItemAbility(cooldownStarterItem, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
67
|
-
ShowUnit(
|
|
69
|
+
ShowUnit(____exports.itemAbilityDummy, false)
|
|
68
70
|
local function startItemCooldownInternal(handle, cooldown)
|
|
69
71
|
local cooldownGroup = getItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP)
|
|
70
72
|
setItemIntegerField(handle, ITEM_IF_COOLDOWN_GROUP, COOLDOWN_STARTER_ABILITY_TYPE_ID)
|
|
71
73
|
setAbilityRealLevelField(cooldownStarterAbility, ABILITY_RLF_COOLDOWN, 0, cooldown)
|
|
72
|
-
unitResetCooldown(
|
|
73
|
-
unitUseItem(
|
|
74
|
+
unitResetCooldown(____exports.itemAbilityDummy)
|
|
75
|
+
unitUseItem(____exports.itemAbilityDummy, cooldownStarterItem)
|
|
74
76
|
Timer:run(restoreCooldownGroup, handle, cooldownGroup)
|
|
75
77
|
end
|
|
76
78
|
restoreCooldownGroup = function(handle, cooldownGroup)
|
|
@@ -85,7 +87,7 @@ ____exports.startItemCooldown = function(handle, owner, cooldown)
|
|
|
85
87
|
end
|
|
86
88
|
---
|
|
87
89
|
-- @internal For use by internal systems only.
|
|
88
|
-
____exports.abilityActionDummy =
|
|
90
|
+
____exports.abilityActionDummy = ____exports.itemAbilityDummy
|
|
89
91
|
---
|
|
90
92
|
-- @internal For use by internal systems only.
|
|
91
93
|
____exports.doAbilityAction = function(handle, action, ...)
|
|
@@ -104,11 +106,11 @@ ____exports.doAbilityAction = function(handle, action, ...)
|
|
|
104
106
|
end
|
|
105
107
|
x = getItemX(handle)
|
|
106
108
|
y = getItemY(handle)
|
|
107
|
-
unitAddItem(
|
|
109
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
108
110
|
end
|
|
109
111
|
local result = action(handle, ...)
|
|
110
112
|
if not isOwned then
|
|
111
|
-
unitRemoveItem(
|
|
113
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
112
114
|
setItemPosition(handle, x, y)
|
|
113
115
|
if isPowerup then
|
|
114
116
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -139,9 +141,9 @@ ____exports.doAbilityActionForceDummy = function(handle, owner, action, ...)
|
|
|
139
141
|
isPowerup = true
|
|
140
142
|
end
|
|
141
143
|
unitRemoveItem(owner, handle)
|
|
142
|
-
unitAddItem(
|
|
144
|
+
unitAddItem(____exports.itemAbilityDummy, handle)
|
|
143
145
|
local result = action(handle, ...)
|
|
144
|
-
unitRemoveItem(
|
|
146
|
+
unitRemoveItem(____exports.itemAbilityDummy, handle)
|
|
145
147
|
unitAddItemToSlot(owner, handle, slot)
|
|
146
148
|
if isPowerup then
|
|
147
149
|
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, true)
|
|
@@ -7,7 +7,6 @@ import { ItemAbility } from "./ability";
|
|
|
7
7
|
import { AbilityTypeId } from "../object-data/entry/ability-type";
|
|
8
8
|
import type { ItemTypeId } from "../object-data/entry/item-type";
|
|
9
9
|
type DefenseType = 0 | 1 | 2 | 3 | 4 | 5;
|
|
10
|
-
export declare const addAndGetAbility: (handle: jitem, abilityTypeId: AbilityTypeId) => jability | null;
|
|
11
10
|
declare const enum ItemPropertyKey {
|
|
12
11
|
ABILITIES = 100,
|
|
13
12
|
LUA_INDEX_BY_ABILITY_TYPE_ID = 101
|
|
@@ -74,6 +73,8 @@ export declare class Item extends Handle<jitem> {
|
|
|
74
73
|
set position(v: Vec2);
|
|
75
74
|
set charges(v: number);
|
|
76
75
|
get charges(): number;
|
|
76
|
+
consumeCharge(): boolean;
|
|
77
|
+
consumeCharges(count: number): boolean;
|
|
77
78
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
78
79
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
79
80
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -83,5 +84,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
83
84
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
84
85
|
static get onCreate(): Event<[Item]>;
|
|
85
86
|
static get destroyEvent(): Event<[Item]>;
|
|
87
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
86
88
|
}
|
|
87
89
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
5
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
6
|
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
6
7
|
local __TS__Delete = ____lualib.__TS__Delete
|
|
7
8
|
local ____exports = {}
|
|
9
|
+
local invoke
|
|
8
10
|
local ____handle = require("core.types.handle")
|
|
9
11
|
local Handle = ____handle.Handle
|
|
10
12
|
local ____color = require("core.types.color")
|
|
11
13
|
local Color = ____color.Color
|
|
14
|
+
local ____event = require("event")
|
|
15
|
+
local Event = ____event.Event
|
|
12
16
|
local ____rect = require("core.types.rect")
|
|
13
17
|
local Rect = ____rect.Rect
|
|
14
18
|
local ____ability = require("engine.internal.ability")
|
|
15
19
|
local ItemAbility = ____ability.ItemAbility
|
|
16
20
|
local ____ability = require("engine.internal.item.ability")
|
|
17
21
|
local doAbilityAction = ____ability.doAbilityAction
|
|
22
|
+
local doAbilityActionForceDummy = ____ability.doAbilityActionForceDummy
|
|
23
|
+
local itemAbilityDummy = ____ability.itemAbilityDummy
|
|
18
24
|
local ____dummy_2Ditem = require("engine.internal.object-data.dummy-item")
|
|
19
25
|
local DUMMY_ITEM_ID = ____dummy_2Ditem.DUMMY_ITEM_ID
|
|
20
26
|
local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slot")
|
|
21
27
|
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
22
28
|
local ____vec2 = require("math.vec2")
|
|
23
29
|
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
24
31
|
local itemAddAbility = BlzItemAddAbility
|
|
25
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
26
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -36,10 +43,26 @@ local getEnumItem = GetEnumItem
|
|
|
36
43
|
local getItemTypeId = GetItemTypeId
|
|
37
44
|
local getItemX = GetItemX
|
|
38
45
|
local getItemY = GetItemY
|
|
46
|
+
local getItemCharges = GetItemCharges
|
|
47
|
+
local setItemCharges = SetItemCharges
|
|
48
|
+
local unitRemoveAbility = UnitRemoveAbility
|
|
49
|
+
local unitUseItem = UnitUseItem
|
|
50
|
+
local unitUseItemPoint = UnitUseItemPoint
|
|
51
|
+
local unitUseItemTarget = UnitUseItemTarget
|
|
52
|
+
_G.SetItemCharges = function(whichItem, charges)
|
|
53
|
+
setItemCharges(whichItem, charges)
|
|
54
|
+
invoke(
|
|
55
|
+
itemChargesChangeEvent,
|
|
56
|
+
____exports.Item:of(whichItem)
|
|
57
|
+
)
|
|
58
|
+
end
|
|
39
59
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
40
60
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
41
61
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
62
|
+
invoke = Event.invoke
|
|
42
63
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
64
|
+
---
|
|
65
|
+
-- @internal For use by internal systems only.
|
|
43
66
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
44
67
|
if itemAddAbility(handle, abilityTypeId) then
|
|
45
68
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -65,6 +88,23 @@ local function getItemAbilities(handle, item)
|
|
|
65
88
|
end
|
|
66
89
|
return abilities
|
|
67
90
|
end
|
|
91
|
+
local function consumeCharge(handle)
|
|
92
|
+
do
|
|
93
|
+
local i = 0
|
|
94
|
+
local ability = getItemAbilityByIndex(handle, i)
|
|
95
|
+
while ability ~= nil do
|
|
96
|
+
unitRemoveAbility(
|
|
97
|
+
itemAbilityDummy,
|
|
98
|
+
getAbilityId(ability)
|
|
99
|
+
)
|
|
100
|
+
do
|
|
101
|
+
i = i + 1
|
|
102
|
+
ability = getItemAbilityByIndex(handle, i)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
return unitUseItem(itemAbilityDummy, handle) or unitUseItemPoint(itemAbilityDummy, handle, 0, 0) or unitUseItemTarget(itemAbilityDummy, handle, itemAbilityDummy)
|
|
107
|
+
end
|
|
68
108
|
local targetCollection
|
|
69
109
|
local targetCollectionNextIndex
|
|
70
110
|
local centerX
|
|
@@ -116,6 +156,36 @@ end
|
|
|
116
156
|
function Item.create(self, id, x, y, skinId)
|
|
117
157
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
118
158
|
end
|
|
159
|
+
function Item.prototype.consumeCharge(self)
|
|
160
|
+
return self:consumeCharges(1)
|
|
161
|
+
end
|
|
162
|
+
function Item.prototype.consumeCharges(self, count)
|
|
163
|
+
local handle = self.handle
|
|
164
|
+
local charges = getItemCharges(handle)
|
|
165
|
+
if charges > count then
|
|
166
|
+
setItemCharges(handle, charges - count)
|
|
167
|
+
invoke(itemChargesChangeEvent, self)
|
|
168
|
+
return true
|
|
169
|
+
end
|
|
170
|
+
if charges == count then
|
|
171
|
+
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
172
|
+
self:destroy()
|
|
173
|
+
return true
|
|
174
|
+
end
|
|
175
|
+
if not getItemBooleanField(handle, ITEM_BF_ACTIVELY_USED) then
|
|
176
|
+
setItemCharges(handle, 0)
|
|
177
|
+
invoke(itemChargesChangeEvent, self)
|
|
178
|
+
return true
|
|
179
|
+
end
|
|
180
|
+
setItemCharges(handle, 1)
|
|
181
|
+
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
182
|
+
local ____opt_0 = self.owner
|
|
183
|
+
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
184
|
+
invoke(itemChargesChangeEvent, self)
|
|
185
|
+
return true
|
|
186
|
+
end
|
|
187
|
+
return false
|
|
188
|
+
end
|
|
119
189
|
function Item.prototype.addAbility(self, abilityTypeId)
|
|
120
190
|
local nativeAbility = doAbilityAction(self.handle, ____exports.addAndGetAbility, abilityTypeId)
|
|
121
191
|
if nativeAbility ~= nil then
|
|
@@ -301,7 +371,7 @@ __TS__SetDescriptor(
|
|
|
301
371
|
"perishable",
|
|
302
372
|
{
|
|
303
373
|
get = function(self)
|
|
304
|
-
return
|
|
374
|
+
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
305
375
|
end,
|
|
306
376
|
set = function(self, v)
|
|
307
377
|
BlzSetItemBooleanField(self.handle, ITEM_BF_PERISHABLE, v)
|
|
@@ -557,10 +627,11 @@ __TS__SetDescriptor(
|
|
|
557
627
|
"charges",
|
|
558
628
|
{
|
|
559
629
|
get = function(self)
|
|
560
|
-
return
|
|
630
|
+
return getItemCharges(self.handle)
|
|
561
631
|
end,
|
|
562
632
|
set = function(self, v)
|
|
563
|
-
|
|
633
|
+
setItemCharges(self.handle, v)
|
|
634
|
+
invoke(itemChargesChangeEvent, self)
|
|
564
635
|
end
|
|
565
636
|
},
|
|
566
637
|
true
|
|
@@ -587,6 +658,7 @@ __TS__ObjectDefineProperty(
|
|
|
587
658
|
return self.onDestroyEvent
|
|
588
659
|
end}
|
|
589
660
|
)
|
|
661
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
590
662
|
local getManipulatedItem = GetManipulatedItem
|
|
591
663
|
local trigger = CreateTrigger()
|
|
592
664
|
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_PICKUP_ITEM)
|
|
@@ -131,6 +131,11 @@ declare module "../unit" {
|
|
|
131
131
|
const abilityNoTargetChannelingStartEvent: DispatchingEvent<[Unit, Ability]>;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
declare module "../unit" {
|
|
135
|
+
namespace Unit {
|
|
136
|
+
const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
134
139
|
declare module "../unit" {
|
|
135
140
|
namespace Unit {
|
|
136
141
|
const abilityChannelingFinishEvent: DispatchingEvent<[Unit, Ability]>;
|
|
@@ -21,6 +21,8 @@ local ____preconditions = require("utility.preconditions")
|
|
|
21
21
|
local checkNotNull = ____preconditions.checkNotNull
|
|
22
22
|
local ____lazy = require("utility.lazy")
|
|
23
23
|
local lazyRecord = ____lazy.lazyRecord
|
|
24
|
+
local ____timer = require("core.types.timer")
|
|
25
|
+
local Timer = ____timer.Timer
|
|
24
26
|
local eventInvoke = Event.invoke
|
|
25
27
|
local condition = Condition
|
|
26
28
|
local createTrigger = CreateTrigger
|
|
@@ -345,6 +347,18 @@ rawset(
|
|
|
345
347
|
extractAbilityTypeId
|
|
346
348
|
)
|
|
347
349
|
)
|
|
350
|
+
local internalAbilityImpactEvent = __TS__New(Event)
|
|
351
|
+
internalAbilityChannelingStartEvent:addListener(function(...)
|
|
352
|
+
Timer:run(eventInvoke, internalAbilityImpactEvent, ...)
|
|
353
|
+
end)
|
|
354
|
+
rawset(
|
|
355
|
+
Unit,
|
|
356
|
+
"abilityImpactEvent",
|
|
357
|
+
createDispatchingEvent(
|
|
358
|
+
createCommonEvent(internalAbilityImpactEvent),
|
|
359
|
+
extractAbilityTypeId
|
|
360
|
+
)
|
|
361
|
+
)
|
|
348
362
|
rawset(
|
|
349
363
|
Unit,
|
|
350
364
|
"abilityChannelingFinishEvent",
|
|
@@ -354,6 +354,7 @@ export declare class Unit extends Handle<junit> {
|
|
|
354
354
|
static itemPickedUpEvent: UnitTriggerEvent<[Item]>;
|
|
355
355
|
static itemUsedEvent: UnitTriggerEvent<[Item]>;
|
|
356
356
|
static itemStackedEvent: UnitTriggerEvent<[Item]>;
|
|
357
|
+
static get itemChargesChangedEvent(): Event<[unit: Unit, item: Item]>;
|
|
357
358
|
static get itemUseOrderEvent(): Event<[unit: Unit, item: Item]>;
|
|
358
359
|
static get itemMoveOrderEvent(): Event<[
|
|
359
360
|
unit: Unit,
|
package/engine/internal/unit.lua
CHANGED
|
@@ -2682,6 +2682,21 @@ Unit.itemStackedEvent = __TS__New(
|
|
|
2682
2682
|
EVENT_PLAYER_UNIT_STACK_ITEM,
|
|
2683
2683
|
function() return ____exports.Unit:of(getTriggerUnit()), Item:of(getManipulatedItem()) end
|
|
2684
2684
|
)
|
|
2685
|
+
__TS__ObjectDefineProperty(
|
|
2686
|
+
Unit,
|
|
2687
|
+
"itemChargesChangedEvent",
|
|
2688
|
+
{get = function(self)
|
|
2689
|
+
local event = __TS__New(Event)
|
|
2690
|
+
Item.chargesChangedEvent:addListener(function(item)
|
|
2691
|
+
local unit = item.owner
|
|
2692
|
+
if unit ~= nil then
|
|
2693
|
+
invoke(event, unit, item)
|
|
2694
|
+
end
|
|
2695
|
+
end)
|
|
2696
|
+
rawset(self, "itemChargesChangedEvent", event)
|
|
2697
|
+
return event
|
|
2698
|
+
end}
|
|
2699
|
+
)
|
|
2685
2700
|
__TS__ObjectDefineProperty(
|
|
2686
2701
|
Unit,
|
|
2687
2702
|
"itemUseOrderEvent",
|
package/engine/object-field.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ import { ObjectDataEntry, ObjectDataEntryIdType, ObjectDataEntryLevelFieldValueS
|
|
|
5
5
|
export type ObjectFieldId = number & {
|
|
6
6
|
readonly __objectDataEntryFieldId: unique symbol;
|
|
7
7
|
};
|
|
8
|
-
export type ObjectFieldConstructor<T extends ObjectFieldBase<any, any, any, any>> = OmitConstructor<typeof ObjectFieldBase> & (new (id: number) => T);
|
|
8
|
+
export type ObjectFieldConstructor<T extends ObjectFieldBase<any, any, any, any>> = OmitConstructor<typeof ObjectFieldBase> & (new (id: number, isGlobal?: boolean) => T);
|
|
9
9
|
export type ObjectFieldAbstractConstructor<T extends ObjectFieldBase<any, any, any, any>> = OmitConstructor<typeof ObjectFieldBase> & (abstract new (id: number) => T);
|
|
10
10
|
declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEntry, InstanceType extends AnyNotNil, ValueType, NativeFieldType> {
|
|
11
|
+
readonly isGlobal: boolean;
|
|
11
12
|
protected abstract readonly instanceClass: AbstractConstructor<InstanceType> | Function;
|
|
12
13
|
supports(instance: AnyNotNil): instance is InstanceType & {
|
|
13
14
|
readonly __oneSidedTypeGuard: unique symbol;
|
|
@@ -18,8 +19,8 @@ declare abstract class ObjectFieldBase<ObjectDataEntryType extends ObjectDataEnt
|
|
|
18
19
|
protected abstract getObjectDataEntryId(instance: InstanceType): ObjectDataEntryIdType<ObjectDataEntryType>;
|
|
19
20
|
protected abstract hasNativeFieldValue(instance: InstanceType): boolean;
|
|
20
21
|
hasValue(instance: InstanceType): boolean;
|
|
21
|
-
constructor(id: number);
|
|
22
|
-
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
|
|
22
|
+
constructor(id: number, isGlobal?: boolean);
|
|
23
|
+
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number, isGlobal?: boolean): T & symbol;
|
|
23
24
|
static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
|
|
24
25
|
}
|
|
25
26
|
export type ObjectFieldValueChangeEvent<T extends ObjectField<any, any, any, any> | ReadonlyObjectFieldType<ObjectField<any, any, any, any>>> = T extends ObjectField<any, infer InstanceType, infer ValueType, any> ? DispatchingEvent<[
|
package/engine/object-field.lua
CHANGED
|
@@ -25,6 +25,8 @@ local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
|
|
|
25
25
|
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
26
26
|
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
27
27
|
local mutableWeakLuaMap = ____lua_2Dmaps.mutableWeakLuaMap
|
|
28
|
+
local ____arrays = require("utility.arrays")
|
|
29
|
+
local emptyArray = ____arrays.emptyArray
|
|
28
30
|
local compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId = {}
|
|
29
31
|
local defaultValueByObjectDataEntryIdByObjectFieldId = postcompile(function() return compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId end)
|
|
30
32
|
local objectFieldById = {}
|
|
@@ -34,7 +36,11 @@ local idGenerator = __TS__New(
|
|
|
34
36
|
)
|
|
35
37
|
local ObjectFieldBase = __TS__Class()
|
|
36
38
|
ObjectFieldBase.name = "ObjectFieldBase"
|
|
37
|
-
function ObjectFieldBase.prototype.____constructor(self, id)
|
|
39
|
+
function ObjectFieldBase.prototype.____constructor(self, id, isGlobal)
|
|
40
|
+
if isGlobal == nil then
|
|
41
|
+
isGlobal = true
|
|
42
|
+
end
|
|
43
|
+
self.isGlobal = isGlobal
|
|
38
44
|
self.valueByInstance = setmetatable({}, {__mode = "k"})
|
|
39
45
|
if objectFieldById[id] ~= nil then
|
|
40
46
|
error(
|
|
@@ -53,12 +59,13 @@ function ObjectFieldBase.prototype.supports(self, instance)
|
|
|
53
59
|
end
|
|
54
60
|
function ObjectFieldBase.prototype.hasValue(self, instance)
|
|
55
61
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
56
|
-
return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
62
|
+
return self.isGlobal or defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
57
63
|
end
|
|
58
|
-
function ObjectFieldBase.create(self, id)
|
|
64
|
+
function ObjectFieldBase.create(self, id, isGlobal)
|
|
59
65
|
return __TS__New(
|
|
60
66
|
self,
|
|
61
|
-
id or idGenerator:next()
|
|
67
|
+
id or idGenerator:next(),
|
|
68
|
+
isGlobal
|
|
62
69
|
)
|
|
63
70
|
end
|
|
64
71
|
function ObjectFieldBase.of(self, id)
|
|
@@ -187,34 +194,38 @@ function ObjectField.prototype.getActualValue(self, instance)
|
|
|
187
194
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
188
195
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
189
196
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
190
|
-
if defaultValue ~= nil then
|
|
197
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
191
198
|
local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
|
|
192
199
|
if ____self_valueByInstance_instance_0 == nil then
|
|
193
200
|
____self_valueByInstance_instance_0 = defaultValue
|
|
194
201
|
end
|
|
195
|
-
|
|
202
|
+
local ____self_valueByInstance_instance_0_1 = ____self_valueByInstance_instance_0
|
|
203
|
+
if ____self_valueByInstance_instance_0_1 == nil then
|
|
204
|
+
____self_valueByInstance_instance_0_1 = self.defaultValue
|
|
205
|
+
end
|
|
206
|
+
return ____self_valueByInstance_instance_0_1
|
|
196
207
|
end
|
|
197
208
|
end
|
|
198
|
-
local
|
|
199
|
-
if
|
|
200
|
-
|
|
209
|
+
local ____temp_2 = self:getNativeFieldValue(instance)
|
|
210
|
+
if ____temp_2 == nil then
|
|
211
|
+
____temp_2 = self.defaultValue
|
|
201
212
|
end
|
|
202
|
-
return
|
|
213
|
+
return ____temp_2
|
|
203
214
|
end
|
|
204
215
|
function ObjectField.prototype.setActualValue(self, instance, value)
|
|
205
216
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
206
217
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
207
218
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
208
|
-
if defaultValue ~= nil then
|
|
209
|
-
local
|
|
210
|
-
if
|
|
211
|
-
|
|
219
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
220
|
+
local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
|
|
221
|
+
if ____self_valueByInstance_instance_3 == nil then
|
|
222
|
+
____self_valueByInstance_instance_3 = defaultValue
|
|
212
223
|
end
|
|
213
|
-
local
|
|
214
|
-
if
|
|
215
|
-
|
|
224
|
+
local ____self_valueByInstance_instance_3_4 = ____self_valueByInstance_instance_3
|
|
225
|
+
if ____self_valueByInstance_instance_3_4 == nil then
|
|
226
|
+
____self_valueByInstance_instance_3_4 = self.defaultValue
|
|
216
227
|
end
|
|
217
|
-
local previousValue =
|
|
228
|
+
local previousValue = ____self_valueByInstance_instance_3_4
|
|
218
229
|
if value ~= previousValue then
|
|
219
230
|
self.valueByInstance[instance] = value
|
|
220
231
|
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
@@ -235,10 +246,10 @@ function ObjectField.prototype.setActualValue(self, instance, value)
|
|
|
235
246
|
return true
|
|
236
247
|
end
|
|
237
248
|
function ObjectField.prototype.calculateActualValue(self, instance)
|
|
238
|
-
local
|
|
239
|
-
local originalValue =
|
|
240
|
-
local
|
|
241
|
-
local modifiers =
|
|
249
|
+
local ____opt_5 = self.originalValueByInstance
|
|
250
|
+
local originalValue = ____opt_5 and ____opt_5[instance]
|
|
251
|
+
local ____opt_7 = self.modifiersByInstance
|
|
252
|
+
local modifiers = ____opt_7 and ____opt_7[instance]
|
|
242
253
|
if originalValue ~= nil then
|
|
243
254
|
local value = originalValue
|
|
244
255
|
if modifiers ~= nil then
|
|
@@ -303,17 +314,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
303
314
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
304
315
|
local value = defaultValueByObjectDataEntryId[entry.id]
|
|
305
316
|
if value ~= nil then
|
|
306
|
-
local
|
|
317
|
+
local ____temp_10
|
|
307
318
|
if index == nil then
|
|
308
|
-
|
|
319
|
+
____temp_10 = value
|
|
309
320
|
else
|
|
310
|
-
local
|
|
311
|
-
if
|
|
312
|
-
|
|
321
|
+
local ____value_index_9 = value[index + 1]
|
|
322
|
+
if ____value_index_9 == nil then
|
|
323
|
+
____value_index_9 = self.defaultValue
|
|
313
324
|
end
|
|
314
|
-
|
|
325
|
+
____temp_10 = ____value_index_9
|
|
315
326
|
end
|
|
316
|
-
return
|
|
327
|
+
return ____temp_10
|
|
317
328
|
end
|
|
318
329
|
end
|
|
319
330
|
return index == nil and ({}) or self.defaultValue
|
|
@@ -323,17 +334,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
323
334
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
324
335
|
if defaultValue ~= nil then
|
|
325
336
|
local value = self.valueByInstance[entry] or defaultValue
|
|
326
|
-
local
|
|
337
|
+
local ____temp_12
|
|
327
338
|
if index == nil then
|
|
328
|
-
|
|
339
|
+
____temp_12 = value
|
|
329
340
|
else
|
|
330
|
-
local
|
|
331
|
-
if
|
|
332
|
-
|
|
341
|
+
local ____value_index_11 = value[index + 1]
|
|
342
|
+
if ____value_index_11 == nil then
|
|
343
|
+
____value_index_11 = self.defaultValue
|
|
333
344
|
end
|
|
334
|
-
|
|
345
|
+
____temp_12 = ____value_index_11
|
|
335
346
|
end
|
|
336
|
-
return
|
|
347
|
+
return ____temp_12
|
|
337
348
|
end
|
|
338
349
|
end
|
|
339
350
|
if index ~= nil then
|
|
@@ -378,11 +389,11 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
378
389
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
379
390
|
local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
|
|
380
391
|
if valueByLevel ~= nil then
|
|
381
|
-
local
|
|
382
|
-
if
|
|
383
|
-
|
|
392
|
+
local ____valueByLevel_index_13 = valueByLevel[level + 1]
|
|
393
|
+
if ____valueByLevel_index_13 == nil then
|
|
394
|
+
____valueByLevel_index_13 = self.defaultValue
|
|
384
395
|
end
|
|
385
|
-
return
|
|
396
|
+
return ____valueByLevel_index_13
|
|
386
397
|
end
|
|
387
398
|
end
|
|
388
399
|
return self.defaultValue
|
|
@@ -390,24 +401,24 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
390
401
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
391
402
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
392
403
|
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
393
|
-
if defaultValueByLevel ~= nil then
|
|
394
|
-
local
|
|
395
|
-
local
|
|
396
|
-
if
|
|
397
|
-
|
|
404
|
+
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
405
|
+
local ____opt_14 = self.valueByInstance[entry]
|
|
406
|
+
local ____temp_16 = ____opt_14 and ____opt_14[level + 1]
|
|
407
|
+
if ____temp_16 == nil then
|
|
408
|
+
____temp_16 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
398
409
|
end
|
|
399
|
-
local
|
|
400
|
-
if
|
|
401
|
-
|
|
410
|
+
local ____temp_16_17 = ____temp_16
|
|
411
|
+
if ____temp_16_17 == nil then
|
|
412
|
+
____temp_16_17 = self.defaultValue
|
|
402
413
|
end
|
|
403
|
-
return
|
|
414
|
+
return ____temp_16_17
|
|
404
415
|
end
|
|
405
416
|
end
|
|
406
|
-
local
|
|
407
|
-
if
|
|
408
|
-
|
|
417
|
+
local ____temp_18 = self:getNativeFieldValue(entry, level)
|
|
418
|
+
if ____temp_18 == nil then
|
|
419
|
+
____temp_18 = self.defaultValue
|
|
409
420
|
end
|
|
410
|
-
return
|
|
421
|
+
return ____temp_18
|
|
411
422
|
end
|
|
412
423
|
function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
413
424
|
if value == nil then
|
|
@@ -450,21 +461,21 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
|
450
461
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
451
462
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
452
463
|
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
453
|
-
if defaultValueByLevel ~= nil then
|
|
464
|
+
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
454
465
|
local valueByLevel = self.valueByInstance[entry]
|
|
455
466
|
if valueByLevel == nil then
|
|
456
467
|
valueByLevel = {}
|
|
457
468
|
self.valueByInstance[entry] = valueByLevel
|
|
458
469
|
end
|
|
459
|
-
local
|
|
460
|
-
if
|
|
461
|
-
|
|
470
|
+
local ____valueByLevel_index_19 = valueByLevel[level + 1]
|
|
471
|
+
if ____valueByLevel_index_19 == nil then
|
|
472
|
+
____valueByLevel_index_19 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
462
473
|
end
|
|
463
|
-
local
|
|
464
|
-
if
|
|
465
|
-
|
|
474
|
+
local ____valueByLevel_index_19_20 = ____valueByLevel_index_19
|
|
475
|
+
if ____valueByLevel_index_19_20 == nil then
|
|
476
|
+
____valueByLevel_index_19_20 = self.defaultValue
|
|
466
477
|
end
|
|
467
|
-
local previousValue =
|
|
478
|
+
local previousValue = ____valueByLevel_index_19_20
|
|
468
479
|
if value ~= previousValue then
|
|
469
480
|
valueByLevel[level + 1] = value
|
|
470
481
|
self:invokeValueChangeEvent(
|
package/engine/text-tag.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Color } from "../core/types/color";
|
|
3
|
+
import { Unit } from "./internal/unit";
|
|
4
|
+
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
3
5
|
export type TextTagPreset = {
|
|
4
6
|
fadepoint: number;
|
|
5
7
|
lifespan: number;
|
|
@@ -10,9 +12,16 @@ export type TextTagPreset = {
|
|
|
10
12
|
velocityY: number;
|
|
11
13
|
color: Color;
|
|
12
14
|
};
|
|
13
|
-
|
|
15
|
+
declare const enum TextTagPropertyKey {
|
|
16
|
+
UNIT = 100,
|
|
17
|
+
CONFIGURATION = 101
|
|
18
|
+
}
|
|
19
|
+
export declare class TextTag extends AbstractDestroyable {
|
|
14
20
|
private readonly handle;
|
|
21
|
+
private [TextTagPropertyKey.UNIT]?;
|
|
22
|
+
private [TextTagPropertyKey.CONFIGURATION]?;
|
|
15
23
|
private constructor();
|
|
24
|
+
protected onDestroy(): Destructor;
|
|
16
25
|
static BASE: Readonly<TextTagPreset>;
|
|
17
26
|
static BASH: Readonly<TextTagPreset>;
|
|
18
27
|
static CRITICAL_STRIKE: Readonly<TextTagPreset>;
|
|
@@ -22,4 +31,6 @@ export declare class TextTag {
|
|
|
22
31
|
static MISS: Readonly<TextTagPreset>;
|
|
23
32
|
static SHADOW_STRIKE: Readonly<TextTagPreset>;
|
|
24
33
|
static flash(configuration: Readonly<TextTagPreset>, text: string, x: number, y: number, z?: number): void;
|
|
34
|
+
static create(configuration: Readonly<TextTagPreset>, text: string, unit: Unit): TextTag;
|
|
25
35
|
}
|
|
36
|
+
export {};
|
package/engine/text-tag.lua
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
5
|
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
|
|
4
6
|
local ____exports = {}
|
|
5
7
|
local ____color = require("core.types.color")
|
|
6
8
|
local Color = ____color.Color
|
|
9
|
+
local ____timer = require("core.types.timer")
|
|
10
|
+
local Timer = ____timer.Timer
|
|
11
|
+
local ____destroyable = require("destroyable")
|
|
12
|
+
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
7
13
|
local createTextTag = CreateTextTag
|
|
8
14
|
local destroyTextTag = DestroyTextTag
|
|
9
15
|
local setTextTagText = SetTextTagText
|
|
@@ -18,16 +24,7 @@ local setTextTagAge = SetTextTagAge
|
|
|
18
24
|
local setTextTagLifespan = SetTextTagLifespan
|
|
19
25
|
local setTextTagFadepoint = SetTextTagFadepoint
|
|
20
26
|
local DEFAULT_FONT_SIZE = 0.024
|
|
21
|
-
|
|
22
|
-
local TextTag = ____exports.TextTag
|
|
23
|
-
TextTag.name = "TextTag"
|
|
24
|
-
function TextTag.prototype.____constructor(self, handle)
|
|
25
|
-
self.handle = handle
|
|
26
|
-
end
|
|
27
|
-
function TextTag.flash(self, configuration, text, x, y, z)
|
|
28
|
-
local textTag = createTextTag()
|
|
29
|
-
setTextTagText(textTag, text, DEFAULT_FONT_SIZE)
|
|
30
|
-
setTextTagPos(textTag, x + configuration.offsetX, y + configuration.offsetY, (z or 0) + configuration.offsetZ)
|
|
27
|
+
local function applyConfiguration(textTag, configuration)
|
|
31
28
|
setTextTagFadepoint(textTag, configuration.fadepoint)
|
|
32
29
|
setTextTagLifespan(textTag, configuration.lifespan)
|
|
33
30
|
local color = configuration.color
|
|
@@ -42,6 +39,38 @@ function TextTag.flash(self, configuration, text, x, y, z)
|
|
|
42
39
|
setTextTagPermanent(textTag, false)
|
|
43
40
|
setTextTagVisibility(textTag, true)
|
|
44
41
|
end
|
|
42
|
+
local unitTextTags = setmetatable({}, {__mode = "k"})
|
|
43
|
+
____exports.TextTag = __TS__Class()
|
|
44
|
+
local TextTag = ____exports.TextTag
|
|
45
|
+
TextTag.name = "TextTag"
|
|
46
|
+
__TS__ClassExtends(TextTag, AbstractDestroyable)
|
|
47
|
+
function TextTag.prototype.____constructor(self, handle)
|
|
48
|
+
AbstractDestroyable.prototype.____constructor(self)
|
|
49
|
+
self.handle = handle
|
|
50
|
+
end
|
|
51
|
+
function TextTag.prototype.onDestroy(self)
|
|
52
|
+
destroyTextTag(self.handle)
|
|
53
|
+
unitTextTags[self] = nil
|
|
54
|
+
return AbstractDestroyable.prototype.onDestroy(self)
|
|
55
|
+
end
|
|
56
|
+
function TextTag.flash(self, configuration, text, x, y, z)
|
|
57
|
+
local textTag = createTextTag()
|
|
58
|
+
setTextTagText(textTag, text, DEFAULT_FONT_SIZE)
|
|
59
|
+
setTextTagPos(textTag, x + configuration.offsetX, y + configuration.offsetY, (z or 0) + configuration.offsetZ)
|
|
60
|
+
applyConfiguration(textTag, configuration)
|
|
61
|
+
end
|
|
62
|
+
function TextTag.create(self, configuration, text, unit)
|
|
63
|
+
local handle = createTextTag()
|
|
64
|
+
setTextTagText(handle, text, DEFAULT_FONT_SIZE)
|
|
65
|
+
setTextTagPosUnit(handle, unit.handle, configuration.offsetZ)
|
|
66
|
+
applyConfiguration(handle, configuration)
|
|
67
|
+
setTextTagPermanent(handle, true)
|
|
68
|
+
local textTag = __TS__New(____exports.TextTag, handle)
|
|
69
|
+
textTag[100] = unit.handle
|
|
70
|
+
textTag[101] = configuration
|
|
71
|
+
unitTextTags[textTag] = true
|
|
72
|
+
return textTag
|
|
73
|
+
end
|
|
45
74
|
TextTag.BASE = {
|
|
46
75
|
fadepoint = 2,
|
|
47
76
|
lifespan = 3,
|
|
@@ -106,4 +135,9 @@ TextTag.SHADOW_STRIKE = __TS__ObjectAssign(
|
|
|
106
135
|
lifespan = 5
|
|
107
136
|
}
|
|
108
137
|
)
|
|
138
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
139
|
+
for textTag in pairs(unitTextTags) do
|
|
140
|
+
setTextTagPosUnit(textTag.handle, textTag[100], textTag[101].offsetZ)
|
|
141
|
+
end
|
|
142
|
+
end)
|
|
109
143
|
return ____exports
|
package/package.json
CHANGED