warscript 0.0.1-dev.dd8349d → 0.0.1-dev.e196516
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 +1 -0
- package/engine/behaviour/unit.lua +5 -0
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +10 -0
- package/engine/internal/item.d.ts +1 -0
- package/engine/internal/item.lua +7 -3
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/object-field.d.ts +6 -3
- package/engine/object-field.lua +81 -69
- 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"))
|
|
@@ -30,6 +30,7 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
30
30
|
onAbilityGained(ability: Ability): void;
|
|
31
31
|
onAbilityLost(ability: Ability): void;
|
|
32
32
|
onAbilityChannelingStart(ability: Ability): void;
|
|
33
|
+
onAbilityImpact(ability: Ability): void;
|
|
33
34
|
onAbilityChannelingFinish(ability: Ability): void;
|
|
34
35
|
onAbilityStop(ability: Ability): void;
|
|
35
36
|
onItemDropped(item: Item): void;
|
|
@@ -102,6 +102,8 @@ function UnitBehavior.prototype.onAbilityLost(self, ability)
|
|
|
102
102
|
end
|
|
103
103
|
function UnitBehavior.prototype.onAbilityChannelingStart(self, ability)
|
|
104
104
|
end
|
|
105
|
+
function UnitBehavior.prototype.onAbilityImpact(self, ability)
|
|
106
|
+
end
|
|
105
107
|
function UnitBehavior.prototype.onAbilityChannelingFinish(self, ability)
|
|
106
108
|
end
|
|
107
109
|
function UnitBehavior.prototype.onAbilityStop(self, ability)
|
|
@@ -173,6 +175,9 @@ __TS__SetDescriptor(
|
|
|
173
175
|
Unit.abilityChannelingStartEvent:addListener(function(source, ability)
|
|
174
176
|
____exports.UnitBehavior:forAll(source, "onAbilityChannelingStart", ability)
|
|
175
177
|
end)
|
|
178
|
+
Unit.abilityImpactEvent:addListener(function(source, ability)
|
|
179
|
+
____exports.UnitBehavior:forAll(source, "onAbilityImpact", ability)
|
|
180
|
+
end)
|
|
176
181
|
Unit.abilityChannelingFinishEvent:addListener(function(source, ability)
|
|
177
182
|
____exports.UnitBehavior:forAll(source, "onAbilityChannelingFinish", ability)
|
|
178
183
|
end)
|
|
@@ -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",
|
|
@@ -74,6 +74,7 @@ export declare class Item extends Handle<jitem> {
|
|
|
74
74
|
set charges(v: number);
|
|
75
75
|
get charges(): number;
|
|
76
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;
|
package/engine/internal/item.lua
CHANGED
|
@@ -157,14 +157,17 @@ function Item.create(self, id, x, y, skinId)
|
|
|
157
157
|
return self:of(BlzCreateItemWithSkin(id, x, y, skinId or id))
|
|
158
158
|
end
|
|
159
159
|
function Item.prototype.consumeCharge(self)
|
|
160
|
+
return self:consumeCharges(1)
|
|
161
|
+
end
|
|
162
|
+
function Item.prototype.consumeCharges(self, count)
|
|
160
163
|
local handle = self.handle
|
|
161
164
|
local charges = getItemCharges(handle)
|
|
162
|
-
if charges
|
|
163
|
-
setItemCharges(handle, charges -
|
|
165
|
+
if charges > count then
|
|
166
|
+
setItemCharges(handle, charges - count)
|
|
164
167
|
invoke(itemChargesChangeEvent, self)
|
|
165
168
|
return true
|
|
166
169
|
end
|
|
167
|
-
if charges ==
|
|
170
|
+
if charges == count then
|
|
168
171
|
if getItemBooleanField(handle, ITEM_BF_PERISHABLE) then
|
|
169
172
|
self:destroy()
|
|
170
173
|
return true
|
|
@@ -174,6 +177,7 @@ function Item.prototype.consumeCharge(self)
|
|
|
174
177
|
invoke(itemChargesChangeEvent, self)
|
|
175
178
|
return true
|
|
176
179
|
end
|
|
180
|
+
setItemCharges(handle, 1)
|
|
177
181
|
local ____doAbilityActionForceDummy_2 = doAbilityActionForceDummy
|
|
178
182
|
local ____opt_0 = self.owner
|
|
179
183
|
____doAbilityActionForceDummy_2(handle, ____opt_0 and ____opt_0.handle, consumeCharge)
|
|
@@ -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",
|
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 = true
|
|
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,17 +315,17 @@ 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
|
|
@@ -323,17 +335,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
323
335
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
324
336
|
if defaultValue ~= nil then
|
|
325
337
|
local value = self.valueByInstance[entry] or defaultValue
|
|
326
|
-
local
|
|
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
|