warscript 0.0.1-dev.dd8349d → 0.0.1-dev.e0e46c4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/types/timer.d.ts +1 -1
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +9 -2
- package/engine/behaviour/ability.lua +8 -17
- package/engine/behaviour/unit/stun-immunity.d.ts +5 -3
- package/engine/behaviour/unit/stun-immunity.lua +43 -27
- package/engine/behaviour/unit.d.ts +13 -1
- package/engine/behaviour/unit.lua +55 -3
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.d.ts +2 -0
- package/engine/internal/ability.lua +10 -0
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/item.d.ts +1 -0
- package/engine/internal/item.lua +7 -3
- package/engine/internal/unit/ability.d.ts +35 -0
- package/engine/internal/unit/ability.lua +62 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit.d.ts +2 -1
- package/engine/internal/unit.lua +70 -57
- package/engine/object-field/unit.d.ts +4 -0
- package/engine/object-field/unit.lua +13 -0
- package/engine/object-field.d.ts +6 -3
- package/engine/object-field.lua +85 -73
- package/engine/standard/fields/unit.d.ts +3 -0
- package/engine/standard/fields/unit.lua +5 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +175 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +1 -1
- package/utility/functions.d.ts +3 -0
- package/utility/functions.lua +3 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/core/types/order.d.ts +0 -26
- package/core/types/order.lua +0 -65
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,39 @@ export type TextTagPreset = {
|
|
|
10
12
|
velocityY: number;
|
|
11
13
|
color: Color;
|
|
12
14
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
declare const enum TextTagPropertyKey {
|
|
16
|
+
UNIT = 100,
|
|
17
|
+
HANDLE = 101,
|
|
18
|
+
CONFIGURATION = 102,
|
|
19
|
+
TEXT = 103,
|
|
20
|
+
FONT_SIZE = 104,
|
|
21
|
+
COLOR = 105,
|
|
22
|
+
X = 106,
|
|
23
|
+
Y = 107
|
|
24
|
+
}
|
|
25
|
+
export declare class TextTag extends AbstractDestroyable {
|
|
26
|
+
private readonly [TextTagPropertyKey.HANDLE];
|
|
27
|
+
private [TextTagPropertyKey.CONFIGURATION]?;
|
|
28
|
+
private [TextTagPropertyKey.TEXT]?;
|
|
29
|
+
private [TextTagPropertyKey.FONT_SIZE]?;
|
|
30
|
+
private [TextTagPropertyKey.COLOR]?;
|
|
31
|
+
private [TextTagPropertyKey.UNIT]?;
|
|
32
|
+
private [TextTagPropertyKey.X]?;
|
|
33
|
+
private [TextTagPropertyKey.Y]?;
|
|
15
34
|
private constructor();
|
|
35
|
+
protected onDestroy(): Destructor;
|
|
36
|
+
get text(): string;
|
|
37
|
+
set text(text: string);
|
|
38
|
+
get fontSize(): number;
|
|
39
|
+
set fontSize(fontSize: number);
|
|
40
|
+
get color(): Color;
|
|
41
|
+
set color(color: Color);
|
|
42
|
+
get unit(): Unit | undefined;
|
|
43
|
+
set unit(unit: Unit | undefined);
|
|
44
|
+
get x(): number;
|
|
45
|
+
set x(x: number);
|
|
46
|
+
get y(): number;
|
|
47
|
+
set y(y: number);
|
|
16
48
|
static BASE: Readonly<TextTagPreset>;
|
|
17
49
|
static BASH: Readonly<TextTagPreset>;
|
|
18
50
|
static CRITICAL_STRIKE: Readonly<TextTagPreset>;
|
|
@@ -22,4 +54,6 @@ export declare class TextTag {
|
|
|
22
54
|
static MISS: Readonly<TextTagPreset>;
|
|
23
55
|
static SHADOW_STRIKE: Readonly<TextTagPreset>;
|
|
24
56
|
static flash(configuration: Readonly<TextTagPreset>, text: string, x: number, y: number, z?: number): void;
|
|
57
|
+
static create(configuration: Readonly<TextTagPreset>, text: string, unit: Unit): TextTag;
|
|
25
58
|
}
|
|
59
|
+
export {};
|
package/engine/text-tag.lua
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
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
|
|
5
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
3
6
|
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
|
|
4
7
|
local ____exports = {}
|
|
5
8
|
local ____color = require("core.types.color")
|
|
6
9
|
local Color = ____color.Color
|
|
10
|
+
local ____timer = require("core.types.timer")
|
|
11
|
+
local Timer = ____timer.Timer
|
|
12
|
+
local ____destroyable = require("destroyable")
|
|
13
|
+
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
7
14
|
local createTextTag = CreateTextTag
|
|
8
15
|
local destroyTextTag = DestroyTextTag
|
|
9
16
|
local setTextTagText = SetTextTagText
|
|
@@ -18,16 +25,7 @@ local setTextTagAge = SetTextTagAge
|
|
|
18
25
|
local setTextTagLifespan = SetTextTagLifespan
|
|
19
26
|
local setTextTagFadepoint = SetTextTagFadepoint
|
|
20
27
|
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)
|
|
28
|
+
local function applyConfiguration(textTag, configuration)
|
|
31
29
|
setTextTagFadepoint(textTag, configuration.fadepoint)
|
|
32
30
|
setTextTagLifespan(textTag, configuration.lifespan)
|
|
33
31
|
local color = configuration.color
|
|
@@ -42,6 +40,168 @@ function TextTag.flash(self, configuration, text, x, y, z)
|
|
|
42
40
|
setTextTagPermanent(textTag, false)
|
|
43
41
|
setTextTagVisibility(textTag, true)
|
|
44
42
|
end
|
|
43
|
+
local unitTextTags = setmetatable({}, {__mode = "k"})
|
|
44
|
+
____exports.TextTag = __TS__Class()
|
|
45
|
+
local TextTag = ____exports.TextTag
|
|
46
|
+
TextTag.name = "TextTag"
|
|
47
|
+
__TS__ClassExtends(TextTag, AbstractDestroyable)
|
|
48
|
+
function TextTag.prototype.____constructor(self, handle)
|
|
49
|
+
AbstractDestroyable.prototype.____constructor(self)
|
|
50
|
+
self[101] = handle
|
|
51
|
+
end
|
|
52
|
+
function TextTag.prototype.onDestroy(self)
|
|
53
|
+
destroyTextTag(self[101])
|
|
54
|
+
unitTextTags[self] = nil
|
|
55
|
+
return AbstractDestroyable.prototype.onDestroy(self)
|
|
56
|
+
end
|
|
57
|
+
function TextTag.flash(self, configuration, text, x, y, z)
|
|
58
|
+
local textTag = createTextTag()
|
|
59
|
+
setTextTagText(textTag, text, DEFAULT_FONT_SIZE)
|
|
60
|
+
setTextTagPos(textTag, x + configuration.offsetX, y + configuration.offsetY, (z or 0) + configuration.offsetZ)
|
|
61
|
+
applyConfiguration(textTag, configuration)
|
|
62
|
+
end
|
|
63
|
+
function TextTag.create(self, configuration, text, unit)
|
|
64
|
+
local handle = createTextTag()
|
|
65
|
+
setTextTagText(handle, text, DEFAULT_FONT_SIZE)
|
|
66
|
+
setTextTagPosUnit(handle, unit.handle, configuration.offsetZ)
|
|
67
|
+
applyConfiguration(handle, configuration)
|
|
68
|
+
setTextTagPermanent(handle, true)
|
|
69
|
+
local textTag = __TS__New(____exports.TextTag, handle)
|
|
70
|
+
textTag[100] = unit
|
|
71
|
+
textTag[102] = configuration
|
|
72
|
+
unitTextTags[textTag] = true
|
|
73
|
+
return textTag
|
|
74
|
+
end
|
|
75
|
+
__TS__SetDescriptor(
|
|
76
|
+
TextTag.prototype,
|
|
77
|
+
"text",
|
|
78
|
+
{
|
|
79
|
+
get = function(self)
|
|
80
|
+
return self[103] or ""
|
|
81
|
+
end,
|
|
82
|
+
set = function(self, text)
|
|
83
|
+
setTextTagText(self[101], text, self[104] or DEFAULT_FONT_SIZE)
|
|
84
|
+
self[103] = text
|
|
85
|
+
end
|
|
86
|
+
},
|
|
87
|
+
true
|
|
88
|
+
)
|
|
89
|
+
__TS__SetDescriptor(
|
|
90
|
+
TextTag.prototype,
|
|
91
|
+
"fontSize",
|
|
92
|
+
{
|
|
93
|
+
get = function(self)
|
|
94
|
+
return self[104] or DEFAULT_FONT_SIZE
|
|
95
|
+
end,
|
|
96
|
+
set = function(self, fontSize)
|
|
97
|
+
setTextTagText(self[101], self[103] or "", DEFAULT_FONT_SIZE)
|
|
98
|
+
self[104] = fontSize
|
|
99
|
+
end
|
|
100
|
+
},
|
|
101
|
+
true
|
|
102
|
+
)
|
|
103
|
+
__TS__SetDescriptor(
|
|
104
|
+
TextTag.prototype,
|
|
105
|
+
"color",
|
|
106
|
+
{
|
|
107
|
+
get = function(self)
|
|
108
|
+
return self[105] or Color.white
|
|
109
|
+
end,
|
|
110
|
+
set = function(self, color)
|
|
111
|
+
setTextTagColor(
|
|
112
|
+
self[101],
|
|
113
|
+
color.r,
|
|
114
|
+
color.g,
|
|
115
|
+
color.b,
|
|
116
|
+
color.a
|
|
117
|
+
)
|
|
118
|
+
self[105] = color
|
|
119
|
+
end
|
|
120
|
+
},
|
|
121
|
+
true
|
|
122
|
+
)
|
|
123
|
+
__TS__SetDescriptor(
|
|
124
|
+
TextTag.prototype,
|
|
125
|
+
"unit",
|
|
126
|
+
{
|
|
127
|
+
get = function(self)
|
|
128
|
+
return self[100]
|
|
129
|
+
end,
|
|
130
|
+
set = function(self, unit)
|
|
131
|
+
if unit ~= nil then
|
|
132
|
+
setTextTagPosUnit(self[101], unit.handle, 0)
|
|
133
|
+
self[106] = nil
|
|
134
|
+
self[107] = nil
|
|
135
|
+
unitTextTags[self] = true
|
|
136
|
+
elseif self[100] ~= nil then
|
|
137
|
+
local unit = self[100]
|
|
138
|
+
local x = unit.x
|
|
139
|
+
local y = unit.y
|
|
140
|
+
setTextTagPos(self[101], x, y, 0)
|
|
141
|
+
self[106] = x
|
|
142
|
+
self[107] = y
|
|
143
|
+
unitTextTags[self] = nil
|
|
144
|
+
end
|
|
145
|
+
self[100] = unit
|
|
146
|
+
end
|
|
147
|
+
},
|
|
148
|
+
true
|
|
149
|
+
)
|
|
150
|
+
__TS__SetDescriptor(
|
|
151
|
+
TextTag.prototype,
|
|
152
|
+
"x",
|
|
153
|
+
{
|
|
154
|
+
get = function(self)
|
|
155
|
+
local ____self__106_2 = self[106]
|
|
156
|
+
if ____self__106_2 == nil then
|
|
157
|
+
local ____opt_0 = self[100]
|
|
158
|
+
____self__106_2 = ____opt_0 and ____opt_0.x
|
|
159
|
+
end
|
|
160
|
+
return ____self__106_2 or 0
|
|
161
|
+
end,
|
|
162
|
+
set = function(self, x)
|
|
163
|
+
local ____self__101_6 = self[101]
|
|
164
|
+
local ____x_7 = x
|
|
165
|
+
local ____self__107_5 = self[107]
|
|
166
|
+
if ____self__107_5 == nil then
|
|
167
|
+
local ____opt_3 = self[100]
|
|
168
|
+
____self__107_5 = ____opt_3 and ____opt_3.y
|
|
169
|
+
end
|
|
170
|
+
setTextTagPos(____self__101_6, ____x_7, ____self__107_5 or 0, 0)
|
|
171
|
+
self[106] = x
|
|
172
|
+
self[100] = nil
|
|
173
|
+
unitTextTags[self] = nil
|
|
174
|
+
end
|
|
175
|
+
},
|
|
176
|
+
true
|
|
177
|
+
)
|
|
178
|
+
__TS__SetDescriptor(
|
|
179
|
+
TextTag.prototype,
|
|
180
|
+
"y",
|
|
181
|
+
{
|
|
182
|
+
get = function(self)
|
|
183
|
+
local ____self__107_10 = self[107]
|
|
184
|
+
if ____self__107_10 == nil then
|
|
185
|
+
local ____opt_8 = self[100]
|
|
186
|
+
____self__107_10 = ____opt_8 and ____opt_8.y
|
|
187
|
+
end
|
|
188
|
+
return ____self__107_10 or 0
|
|
189
|
+
end,
|
|
190
|
+
set = function(self, y)
|
|
191
|
+
local ____self__101_14 = self[101]
|
|
192
|
+
local ____self__106_13 = self[106]
|
|
193
|
+
if ____self__106_13 == nil then
|
|
194
|
+
local ____opt_11 = self[100]
|
|
195
|
+
____self__106_13 = ____opt_11 and ____opt_11.x
|
|
196
|
+
end
|
|
197
|
+
setTextTagPos(____self__101_14, ____self__106_13 or 0, y, 0)
|
|
198
|
+
self[107] = y
|
|
199
|
+
self[100] = nil
|
|
200
|
+
unitTextTags[self] = nil
|
|
201
|
+
end
|
|
202
|
+
},
|
|
203
|
+
true
|
|
204
|
+
)
|
|
45
205
|
TextTag.BASE = {
|
|
46
206
|
fadepoint = 2,
|
|
47
207
|
lifespan = 3,
|
|
@@ -106,4 +266,9 @@ TextTag.SHADOW_STRIKE = __TS__ObjectAssign(
|
|
|
106
266
|
lifespan = 5
|
|
107
267
|
}
|
|
108
268
|
)
|
|
269
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
270
|
+
for textTag in pairs(unitTextTags) do
|
|
271
|
+
setTextTagPosUnit(textTag[101], textTag[100].handle, textTag[102].offsetZ)
|
|
272
|
+
end
|
|
273
|
+
end)
|
|
109
274
|
return ____exports
|
package/engine/unit.d.ts
CHANGED
package/engine/unit.lua
CHANGED
package/package.json
CHANGED
package/utility/functions.d.ts
CHANGED
|
@@ -4,3 +4,6 @@ export declare const apply: {
|
|
|
4
4
|
<T, ConsumerParameters extends any[], K extends KeysOfType<T, (...parameters: ConsumerParameters) => void>>(object: T, key: K, ...parameters: ConsumerParameters): T;
|
|
5
5
|
};
|
|
6
6
|
export declare const identity: <T>(value: T) => T;
|
|
7
|
+
export declare const firstArgument: <T>(value: T) => T;
|
|
8
|
+
export declare const secondArgument: <T>(_: unknown, value: T) => T;
|
|
9
|
+
export declare const thirdArgument: <T>(_first: unknown, _second: unknown, value: T) => T;
|
package/utility/functions.lua
CHANGED
|
@@ -88,4 +88,7 @@ ____exports.apply = function(object, transform, ...)
|
|
|
88
88
|
return object
|
|
89
89
|
end
|
|
90
90
|
____exports.identity = function(value) return value end
|
|
91
|
+
____exports.firstArgument = ____exports.identity
|
|
92
|
+
____exports.secondArgument = function(_, value) return value end
|
|
93
|
+
____exports.thirdArgument = function(_first, _second, value) return value end
|
|
91
94
|
return ____exports
|
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
|
package/core/types/order.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** @noSelfInFile */
|
|
2
|
-
import { Unit } from "./unit";
|
|
3
|
-
import { Item } from "./item";
|
|
4
|
-
import { Destructable } from "./destructable";
|
|
5
|
-
export type Order = {
|
|
6
|
-
id: number;
|
|
7
|
-
startX: number;
|
|
8
|
-
startY: number;
|
|
9
|
-
issueTime: number;
|
|
10
|
-
} & ({
|
|
11
|
-
type: "immediate";
|
|
12
|
-
} | {
|
|
13
|
-
type: "point";
|
|
14
|
-
targetX: number;
|
|
15
|
-
targetY: number;
|
|
16
|
-
} | {
|
|
17
|
-
type: "target";
|
|
18
|
-
target: Unit | Item | Destructable;
|
|
19
|
-
});
|
|
20
|
-
declare module "../../engine/internal/unit" {
|
|
21
|
-
interface Unit {
|
|
22
|
-
readonly currentOrder: Order;
|
|
23
|
-
readonly lastOrder: Order;
|
|
24
|
-
issueOrder(order: Order): void;
|
|
25
|
-
}
|
|
26
|
-
}
|