warscript 0.0.1-dev.3b2adda → 0.0.1-dev.3bc4ba4
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 +5 -0
- package/engine/behaviour/unit.lua +29 -4
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +10 -0
- package/engine/internal/item.d.ts +2 -1
- package/engine/internal/item.lua +53 -24
- 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 +6 -3
- package/engine/object-field.lua +85 -73
- package/engine/text-tag.d.ts +12 -1
- package/engine/text-tag.lua +44 -10
- package/package.json +1 -1
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
|
@@ -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"))
|
|
@@ -29,10 +29,15 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
29
29
|
onDamageReceived(source: Unit | undefined, event: DamageEvent): void;
|
|
30
30
|
onAbilityGained(ability: Ability): void;
|
|
31
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;
|
|
32
36
|
onItemDropped(item: Item): void;
|
|
33
37
|
onItemPickedUp(item: Item): void;
|
|
34
38
|
onItemUsed(item: Item): void;
|
|
35
39
|
onItemStacked(item: Item): void;
|
|
40
|
+
onItemChargesChanged(item: Item): void;
|
|
36
41
|
onKill(target: Unit): void;
|
|
37
42
|
onDeath(source: Unit | undefined): void;
|
|
38
43
|
}
|
|
@@ -100,6 +100,14 @@ function UnitBehavior.prototype.onAbilityGained(self, ability)
|
|
|
100
100
|
end
|
|
101
101
|
function UnitBehavior.prototype.onAbilityLost(self, ability)
|
|
102
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
|
|
103
111
|
function UnitBehavior.prototype.onItemDropped(self, item)
|
|
104
112
|
end
|
|
105
113
|
function UnitBehavior.prototype.onItemPickedUp(self, item)
|
|
@@ -108,6 +116,8 @@ function UnitBehavior.prototype.onItemUsed(self, item)
|
|
|
108
116
|
end
|
|
109
117
|
function UnitBehavior.prototype.onItemStacked(self, item)
|
|
110
118
|
end
|
|
119
|
+
function UnitBehavior.prototype.onItemChargesChanged(self, item)
|
|
120
|
+
end
|
|
111
121
|
function UnitBehavior.prototype.onKill(self, target)
|
|
112
122
|
end
|
|
113
123
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
@@ -156,11 +166,23 @@ __TS__SetDescriptor(
|
|
|
156
166
|
end
|
|
157
167
|
____exports.UnitBehavior:forAll(target, "onDamageReceived", source, event)
|
|
158
168
|
end)
|
|
159
|
-
Unit.abilityGainedEvent:addListener(function(source,
|
|
160
|
-
____exports.UnitBehavior:forAll(source, "onAbilityGained",
|
|
169
|
+
Unit.abilityGainedEvent:addListener(function(source, ability)
|
|
170
|
+
____exports.UnitBehavior:forAll(source, "onAbilityGained", ability)
|
|
161
171
|
end)
|
|
162
|
-
Unit.abilityLostEvent:addListener(function(source,
|
|
163
|
-
____exports.UnitBehavior:forAll(source, "onAbilityLost",
|
|
172
|
+
Unit.abilityLostEvent:addListener(function(source, ability)
|
|
173
|
+
____exports.UnitBehavior:forAll(source, "onAbilityLost", ability)
|
|
174
|
+
end)
|
|
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)
|
|
164
186
|
end)
|
|
165
187
|
Unit.deathEvent:addListener(function(target, source)
|
|
166
188
|
if source ~= nil then
|
|
@@ -180,6 +202,9 @@ __TS__SetDescriptor(
|
|
|
180
202
|
Unit.itemStackedEvent:addListener(function(unit, item)
|
|
181
203
|
____exports.UnitBehavior:forAll(unit, "onItemStacked", item)
|
|
182
204
|
end)
|
|
205
|
+
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
206
|
+
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
207
|
+
end)
|
|
183
208
|
end)(UnitBehavior)
|
|
184
209
|
Unit.destroyEvent:addListener(function(unit)
|
|
185
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",
|
|
@@ -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
|
|
@@ -75,6 +74,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
75
74
|
set charges(v: number);
|
|
76
75
|
get charges(): number;
|
|
77
76
|
consumeCharge(): boolean;
|
|
77
|
+
consumeCharges(count: number): boolean;
|
|
78
78
|
addAbility(abilityTypeId: AbilityTypeId): ItemAbility | undefined;
|
|
79
79
|
removeAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
80
80
|
hasAbility(abilityTypeId: AbilityTypeId): boolean;
|
|
@@ -84,5 +84,6 @@ export declare class Item extends Handle<jitem> {
|
|
|
84
84
|
static getInRect(rect: ReadonlyRect): Item[];
|
|
85
85
|
static get onCreate(): Event<[Item]>;
|
|
86
86
|
static get destroyEvent(): Event<[Item]>;
|
|
87
|
+
static readonly chargesChangedEvent: Event<[Item]>;
|
|
87
88
|
}
|
|
88
89
|
export {};
|
package/engine/internal/item.lua
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
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")
|
|
@@ -23,6 +27,7 @@ local ____add_2Ditem_2Dto_2Dslot = require("engine.internal.unit.add-item-to-slo
|
|
|
23
27
|
local SLOT_FILLER_ITEM_TYPE_ID = ____add_2Ditem_2Dto_2Dslot.SLOT_FILLER_ITEM_TYPE_ID
|
|
24
28
|
local ____vec2 = require("math.vec2")
|
|
25
29
|
local distance = ____vec2.distance
|
|
30
|
+
local itemChargesChangeEvent = __TS__New(Event)
|
|
26
31
|
local itemAddAbility = BlzItemAddAbility
|
|
27
32
|
local itemRemoveAbility = BlzItemRemoveAbility
|
|
28
33
|
local getItemAbility = BlzGetItemAbility
|
|
@@ -40,10 +45,24 @@ local getItemX = GetItemX
|
|
|
40
45
|
local getItemY = GetItemY
|
|
41
46
|
local getItemCharges = GetItemCharges
|
|
42
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
|
|
43
59
|
local getItemIntegerField = BlzGetItemIntegerField
|
|
44
60
|
local setItemBooleanField = BlzSetItemBooleanField
|
|
45
61
|
local getItemBooleanField = BlzGetItemBooleanField
|
|
62
|
+
invoke = Event.invoke
|
|
46
63
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
64
|
+
---
|
|
65
|
+
-- @internal For use by internal systems only.
|
|
47
66
|
____exports.addAndGetAbility = function(handle, abilityTypeId)
|
|
48
67
|
if itemAddAbility(handle, abilityTypeId) then
|
|
49
68
|
return getItemAbility(handle, abilityTypeId)
|
|
@@ -69,6 +88,23 @@ local function getItemAbilities(handle, item)
|
|
|
69
88
|
end
|
|
70
89
|
return abilities
|
|
71
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
|
|
72
108
|
local targetCollection
|
|
73
109
|
local targetCollectionNextIndex
|
|
74
110
|
local centerX
|
|
@@ -121,40 +157,31 @@ function Item.create(self, id, x, y, skinId)
|
|
|
121
157
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
122
158
|
end
|
|
123
159
|
function Item.prototype.consumeCharge(self)
|
|
160
|
+
return self:consumeCharges(1)
|
|
161
|
+
end
|
|
162
|
+
function Item.prototype.consumeCharges(self, count)
|
|
124
163
|
local handle = self.handle
|
|
125
164
|
local charges = getItemCharges(handle)
|
|
126
|
-
if charges
|
|
127
|
-
setItemCharges(handle, charges -
|
|
165
|
+
if charges > count then
|
|
166
|
+
setItemCharges(handle, charges - count)
|
|
167
|
+
invoke(itemChargesChangeEvent, self)
|
|
128
168
|
return true
|
|
129
169
|
end
|
|
130
|
-
if charges ==
|
|
170
|
+
if charges == count then
|
|
131
171
|
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
132
172
|
self:destroy()
|
|
133
173
|
return true
|
|
134
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)
|
|
135
181
|
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
136
182
|
local ____opt_0 = self.owner
|
|
137
|
-
____doAbilityActionForceDummy_2(
|
|
138
|
-
|
|
139
|
-
____opt_0 and ____opt_0.handle,
|
|
140
|
-
function()
|
|
141
|
-
do
|
|
142
|
-
local i = 0
|
|
143
|
-
local ability = getItemAbilityByIndex(handle, i)
|
|
144
|
-
while ability ~= nil do
|
|
145
|
-
UnitRemoveAbility(
|
|
146
|
-
itemAbilityDummy,
|
|
147
|
-
getAbilityId(ability)
|
|
148
|
-
)
|
|
149
|
-
do
|
|
150
|
-
i = i + 1
|
|
151
|
-
ability = getItemAbilityByIndex(handle, i)
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
UnitUseItem(itemAbilityDummy, handle)
|
|
156
|
-
end
|
|
157
|
-
)
|
|
183
|
+
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
184
|
+
invoke(itemChargesChangeEvent, self)
|
|
158
185
|
return true
|
|
159
186
|
end
|
|
160
187
|
return false
|
|
@@ -604,6 +631,7 @@ __TS__SetDescriptor(
|
|
|
604
631
|
end,
|
|
605
632
|
set = function(self, v)
|
|
606
633
|
setItemCharges(self.handle, v)
|
|
634
|
+
invoke(itemChargesChangeEvent, self)
|
|
607
635
|
end
|
|
608
636
|
},
|
|
609
637
|
true
|
|
@@ -630,6 +658,7 @@ __TS__ObjectDefineProperty(
|
|
|
630
658
|
return self.onDestroyEvent
|
|
631
659
|
end}
|
|
632
660
|
)
|
|
661
|
+
Item.chargesChangedEvent = itemChargesChangeEvent
|
|
633
662
|
local getManipulatedItem = GetManipulatedItem
|
|
634
663
|
local trigger = CreateTrigger()
|
|
635
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<[
|
|
@@ -79,6 +80,8 @@ export declare abstract class ObjectArrayField<ObjectDataEntryType extends Objec
|
|
|
79
80
|
setValue(entry: ObjectDataEntryType | InstanceType, value: ValueType[]): boolean;
|
|
80
81
|
}
|
|
81
82
|
export declare abstract class ObjectLevelField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType[], NativeFieldType> {
|
|
83
|
+
private originalValueByLevelByInstance?;
|
|
84
|
+
private modifiersByInstance?;
|
|
82
85
|
protected abstract readonly defaultValue: ValueType;
|
|
83
86
|
protected abstract getNativeFieldValue(instance: InstanceType, level: number): ValueType;
|
|
84
87
|
protected abstract setNativeFieldValue(instance: InstanceType, level: number, value: ValueType): boolean;
|
package/engine/object-field.lua
CHANGED
|
@@ -23,8 +23,11 @@ local ObjectDataEntryIdGenerator = ____object_2Ddata_2Dentry_2Did_2Dgenerator.Ob
|
|
|
23
23
|
local ____linked_2Dset = require("utility.linked-set")
|
|
24
24
|
local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
|
|
25
25
|
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
26
|
+
local emptyLuaMap = ____lua_2Dmaps.emptyLuaMap
|
|
26
27
|
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
27
28
|
local mutableWeakLuaMap = ____lua_2Dmaps.mutableWeakLuaMap
|
|
29
|
+
local ____arrays = require("utility.arrays")
|
|
30
|
+
local emptyArray = ____arrays.emptyArray
|
|
28
31
|
local compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId = {}
|
|
29
32
|
local defaultValueByObjectDataEntryIdByObjectFieldId = postcompile(function() return compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId end)
|
|
30
33
|
local objectFieldById = {}
|
|
@@ -34,7 +37,11 @@ local idGenerator = __TS__New(
|
|
|
34
37
|
)
|
|
35
38
|
local ObjectFieldBase = __TS__Class()
|
|
36
39
|
ObjectFieldBase.name = "ObjectFieldBase"
|
|
37
|
-
function ObjectFieldBase.prototype.____constructor(self, id)
|
|
40
|
+
function ObjectFieldBase.prototype.____constructor(self, id, isGlobal)
|
|
41
|
+
if isGlobal == nil then
|
|
42
|
+
isGlobal = false
|
|
43
|
+
end
|
|
44
|
+
self.isGlobal = isGlobal
|
|
38
45
|
self.valueByInstance = setmetatable({}, {__mode = "k"})
|
|
39
46
|
if objectFieldById[id] ~= nil then
|
|
40
47
|
error(
|
|
@@ -53,12 +60,13 @@ function ObjectFieldBase.prototype.supports(self, instance)
|
|
|
53
60
|
end
|
|
54
61
|
function ObjectFieldBase.prototype.hasValue(self, instance)
|
|
55
62
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
56
|
-
return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
63
|
+
return self.isGlobal or defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
57
64
|
end
|
|
58
|
-
function ObjectFieldBase.create(self, id)
|
|
65
|
+
function ObjectFieldBase.create(self, id, isGlobal)
|
|
59
66
|
return __TS__New(
|
|
60
67
|
self,
|
|
61
|
-
id or idGenerator:next()
|
|
68
|
+
id or idGenerator:next(),
|
|
69
|
+
isGlobal
|
|
62
70
|
)
|
|
63
71
|
end
|
|
64
72
|
function ObjectFieldBase.of(self, id)
|
|
@@ -185,36 +193,40 @@ function ObjectField.prototype.trySetValue(self, entry, value)
|
|
|
185
193
|
end
|
|
186
194
|
function ObjectField.prototype.getActualValue(self, instance)
|
|
187
195
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
188
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
189
|
-
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
190
|
-
if defaultValue ~= nil then
|
|
196
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
197
|
+
local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
|
|
198
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
191
199
|
local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
|
|
192
200
|
if ____self_valueByInstance_instance_0 == nil then
|
|
193
201
|
____self_valueByInstance_instance_0 = defaultValue
|
|
194
202
|
end
|
|
195
|
-
|
|
203
|
+
local ____self_valueByInstance_instance_0_1 = ____self_valueByInstance_instance_0
|
|
204
|
+
if ____self_valueByInstance_instance_0_1 == nil then
|
|
205
|
+
____self_valueByInstance_instance_0_1 = self.defaultValue
|
|
206
|
+
end
|
|
207
|
+
return ____self_valueByInstance_instance_0_1
|
|
196
208
|
end
|
|
197
209
|
end
|
|
198
|
-
local
|
|
199
|
-
if
|
|
200
|
-
|
|
210
|
+
local ____temp_2 = self:getNativeFieldValue(instance)
|
|
211
|
+
if ____temp_2 == nil then
|
|
212
|
+
____temp_2 = self.defaultValue
|
|
201
213
|
end
|
|
202
|
-
return
|
|
214
|
+
return ____temp_2
|
|
203
215
|
end
|
|
204
216
|
function ObjectField.prototype.setActualValue(self, instance, value)
|
|
205
217
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
206
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
207
|
-
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
208
|
-
if defaultValue ~= nil then
|
|
209
|
-
local
|
|
210
|
-
if
|
|
211
|
-
|
|
218
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
219
|
+
local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
|
|
220
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
221
|
+
local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
|
|
222
|
+
if ____self_valueByInstance_instance_3 == nil then
|
|
223
|
+
____self_valueByInstance_instance_3 = defaultValue
|
|
212
224
|
end
|
|
213
|
-
local
|
|
214
|
-
if
|
|
215
|
-
|
|
225
|
+
local ____self_valueByInstance_instance_3_4 = ____self_valueByInstance_instance_3
|
|
226
|
+
if ____self_valueByInstance_instance_3_4 == nil then
|
|
227
|
+
____self_valueByInstance_instance_3_4 = self.defaultValue
|
|
216
228
|
end
|
|
217
|
-
local previousValue =
|
|
229
|
+
local previousValue = ____self_valueByInstance_instance_3_4
|
|
218
230
|
if value ~= previousValue then
|
|
219
231
|
self.valueByInstance[instance] = value
|
|
220
232
|
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
@@ -235,10 +247,10 @@ function ObjectField.prototype.setActualValue(self, instance, value)
|
|
|
235
247
|
return true
|
|
236
248
|
end
|
|
237
249
|
function ObjectField.prototype.calculateActualValue(self, instance)
|
|
238
|
-
local
|
|
239
|
-
local originalValue =
|
|
240
|
-
local
|
|
241
|
-
local modifiers =
|
|
250
|
+
local ____opt_5 = self.originalValueByInstance
|
|
251
|
+
local originalValue = ____opt_5 and ____opt_5[instance]
|
|
252
|
+
local ____opt_7 = self.modifiersByInstance
|
|
253
|
+
local modifiers = ____opt_7 and ____opt_7[instance]
|
|
242
254
|
if originalValue ~= nil then
|
|
243
255
|
local value = originalValue
|
|
244
256
|
if modifiers ~= nil then
|
|
@@ -303,37 +315,37 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
303
315
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
304
316
|
local value = defaultValueByObjectDataEntryId[entry.id]
|
|
305
317
|
if value ~= nil then
|
|
306
|
-
local
|
|
318
|
+
local ____temp_10
|
|
307
319
|
if index == nil then
|
|
308
|
-
|
|
320
|
+
____temp_10 = value
|
|
309
321
|
else
|
|
310
|
-
local
|
|
311
|
-
if
|
|
312
|
-
|
|
322
|
+
local ____value_index_9 = value[index + 1]
|
|
323
|
+
if ____value_index_9 == nil then
|
|
324
|
+
____value_index_9 = self.defaultValue
|
|
313
325
|
end
|
|
314
|
-
|
|
326
|
+
____temp_10 = ____value_index_9
|
|
315
327
|
end
|
|
316
|
-
return
|
|
328
|
+
return ____temp_10
|
|
317
329
|
end
|
|
318
330
|
end
|
|
319
331
|
return index == nil and ({}) or self.defaultValue
|
|
320
332
|
end
|
|
321
333
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
322
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
323
|
-
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
324
|
-
if defaultValue ~= nil then
|
|
325
|
-
local value = self.valueByInstance[entry] or defaultValue
|
|
326
|
-
local
|
|
334
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
335
|
+
local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
|
|
336
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
337
|
+
local value = self.valueByInstance[entry] or defaultValue or emptyArray()
|
|
338
|
+
local ____temp_12
|
|
327
339
|
if index == nil then
|
|
328
|
-
|
|
340
|
+
____temp_12 = value
|
|
329
341
|
else
|
|
330
|
-
local
|
|
331
|
-
if
|
|
332
|
-
|
|
342
|
+
local ____value_index_11 = value[index + 1]
|
|
343
|
+
if ____value_index_11 == nil then
|
|
344
|
+
____value_index_11 = self.defaultValue
|
|
333
345
|
end
|
|
334
|
-
|
|
346
|
+
____temp_12 = ____value_index_11
|
|
335
347
|
end
|
|
336
|
-
return
|
|
348
|
+
return ____temp_12
|
|
337
349
|
end
|
|
338
350
|
end
|
|
339
351
|
if index ~= nil then
|
|
@@ -378,36 +390,36 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
378
390
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
379
391
|
local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
|
|
380
392
|
if valueByLevel ~= nil then
|
|
381
|
-
local
|
|
382
|
-
if
|
|
383
|
-
|
|
393
|
+
local ____valueByLevel_index_13 = valueByLevel[level + 1]
|
|
394
|
+
if ____valueByLevel_index_13 == nil then
|
|
395
|
+
____valueByLevel_index_13 = self.defaultValue
|
|
384
396
|
end
|
|
385
|
-
return
|
|
397
|
+
return ____valueByLevel_index_13
|
|
386
398
|
end
|
|
387
399
|
end
|
|
388
400
|
return self.defaultValue
|
|
389
401
|
end
|
|
390
402
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
391
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
392
|
-
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
393
|
-
if defaultValueByLevel ~= nil then
|
|
394
|
-
local
|
|
395
|
-
local
|
|
396
|
-
if
|
|
397
|
-
|
|
403
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
404
|
+
local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
|
|
405
|
+
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
406
|
+
local ____opt_14 = self.valueByInstance[entry]
|
|
407
|
+
local ____temp_16 = ____opt_14 and ____opt_14[level + 1]
|
|
408
|
+
if ____temp_16 == nil then
|
|
409
|
+
____temp_16 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
398
410
|
end
|
|
399
|
-
local
|
|
400
|
-
if
|
|
401
|
-
|
|
411
|
+
local ____temp_16_17 = ____temp_16
|
|
412
|
+
if ____temp_16_17 == nil then
|
|
413
|
+
____temp_16_17 = self.defaultValue
|
|
402
414
|
end
|
|
403
|
-
return
|
|
415
|
+
return ____temp_16_17
|
|
404
416
|
end
|
|
405
417
|
end
|
|
406
|
-
local
|
|
407
|
-
if
|
|
408
|
-
|
|
418
|
+
local ____temp_18 = self:getNativeFieldValue(entry, level)
|
|
419
|
+
if ____temp_18 == nil then
|
|
420
|
+
____temp_18 = self.defaultValue
|
|
409
421
|
end
|
|
410
|
-
return
|
|
422
|
+
return ____temp_18
|
|
411
423
|
end
|
|
412
424
|
function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
413
425
|
if value == nil then
|
|
@@ -448,23 +460,23 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
|
448
460
|
return true
|
|
449
461
|
end
|
|
450
462
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
451
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
452
|
-
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
453
|
-
if defaultValueByLevel ~= nil then
|
|
463
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
464
|
+
local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
|
|
465
|
+
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
454
466
|
local valueByLevel = self.valueByInstance[entry]
|
|
455
467
|
if valueByLevel == nil then
|
|
456
468
|
valueByLevel = {}
|
|
457
469
|
self.valueByInstance[entry] = valueByLevel
|
|
458
470
|
end
|
|
459
|
-
local
|
|
460
|
-
if
|
|
461
|
-
|
|
471
|
+
local ____valueByLevel_index_19 = valueByLevel[level + 1]
|
|
472
|
+
if ____valueByLevel_index_19 == nil then
|
|
473
|
+
____valueByLevel_index_19 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
462
474
|
end
|
|
463
|
-
local
|
|
464
|
-
if
|
|
465
|
-
|
|
475
|
+
local ____valueByLevel_index_19_20 = ____valueByLevel_index_19
|
|
476
|
+
if ____valueByLevel_index_19_20 == nil then
|
|
477
|
+
____valueByLevel_index_19_20 = self.defaultValue
|
|
466
478
|
end
|
|
467
|
-
local previousValue =
|
|
479
|
+
local previousValue = ____valueByLevel_index_19_20
|
|
468
480
|
if value ~= previousValue then
|
|
469
481
|
valueByLevel[level + 1] = value
|
|
470
482
|
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
package/utility/lua-maps.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Flatten, TupleOf } from "./types";
|
|
3
|
+
export declare const emptyLuaMap: <K extends AnyNotNil, V>() => ReadonlyLuaMap<K, V>;
|
|
3
4
|
export declare const mutableLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
|
|
4
5
|
export declare const mutableWeakLuaMap: <K extends AnyNotNil, V>() => LuaMap<K, V>;
|
|
5
6
|
export declare const luaMapOf: <K extends AnyNotNil, V>(...pairs: Flatten<TupleOf<[K, V], 0 | 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>>) => LuaMap<K, V>;
|
package/utility/lua-maps.lua
CHANGED
|
@@ -2,6 +2,10 @@ local ____exports = {}
|
|
|
2
2
|
local select = _G.select
|
|
3
3
|
local setmetatable = _G.setmetatable
|
|
4
4
|
local weakKeysMetatable = {__mode = "k"}
|
|
5
|
+
local EMPTY_LUA_MAP = {}
|
|
6
|
+
____exports.emptyLuaMap = function()
|
|
7
|
+
return EMPTY_LUA_MAP
|
|
8
|
+
end
|
|
5
9
|
____exports.mutableLuaMap = function()
|
|
6
10
|
return {}
|
|
7
11
|
end
|