warscript 0.0.1-dev.1766d07 → 0.0.1-dev.193ed34
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/frame.lua +25 -12
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +79 -5
- package/core/types/timer.d.ts +2 -1
- package/core/types/timer.lua +7 -2
- package/decl/native.d.ts +4 -2
- package/engine/behavior.d.ts +2 -0
- package/engine/behavior.lua +53 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +2 -1
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +7 -16
- 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 +12 -1
- package/engine/behaviour/unit.lua +56 -7
- package/engine/buff.d.ts +2 -1
- package/engine/buff.lua +9 -3
- package/engine/internal/ability.lua +8 -2
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.d.ts +30 -0
- package/engine/internal/unit/ability.lua +48 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit-missile-launch.lua +8 -1
- package/engine/internal/unit.d.ts +3 -3
- package/engine/internal/unit.lua +70 -57
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/entry/ability-type.lua +1 -3
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/unit.d.ts +11 -0
- package/engine/object-field/unit.lua +34 -0
- package/engine/object-field.d.ts +2 -0
- package/engine/object-field.lua +73 -68
- package/engine/standard/fields/unit.d.ts +4 -0
- package/engine/standard/fields/unit.lua +7 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +248 -10
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/package.json +2 -2
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/lua-maps.d.ts +1 -0
- package/utility/lua-maps.lua +4 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.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,6 +23,7 @@ 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
|
|
28
29
|
local ____arrays = require("utility.arrays")
|
|
@@ -38,7 +39,7 @@ local ObjectFieldBase = __TS__Class()
|
|
|
38
39
|
ObjectFieldBase.name = "ObjectFieldBase"
|
|
39
40
|
function ObjectFieldBase.prototype.____constructor(self, id, isGlobal)
|
|
40
41
|
if isGlobal == nil then
|
|
41
|
-
isGlobal =
|
|
42
|
+
isGlobal = false
|
|
42
43
|
end
|
|
43
44
|
self.isGlobal = isGlobal
|
|
44
45
|
self.valueByInstance = setmetatable({}, {__mode = "k"})
|
|
@@ -192,36 +193,40 @@ function ObjectField.prototype.trySetValue(self, entry, value)
|
|
|
192
193
|
end
|
|
193
194
|
function ObjectField.prototype.getActualValue(self, instance)
|
|
194
195
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
195
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
196
|
-
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
197
|
-
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
|
|
198
199
|
local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
|
|
199
200
|
if ____self_valueByInstance_instance_0 == nil then
|
|
200
201
|
____self_valueByInstance_instance_0 = defaultValue
|
|
201
202
|
end
|
|
202
|
-
|
|
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
|
|
203
208
|
end
|
|
204
209
|
end
|
|
205
|
-
local
|
|
206
|
-
if
|
|
207
|
-
|
|
210
|
+
local ____temp_2 = self:getNativeFieldValue(instance)
|
|
211
|
+
if ____temp_2 == nil then
|
|
212
|
+
____temp_2 = self.defaultValue
|
|
208
213
|
end
|
|
209
|
-
return
|
|
214
|
+
return ____temp_2
|
|
210
215
|
end
|
|
211
216
|
function ObjectField.prototype.setActualValue(self, instance, value)
|
|
212
217
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
213
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
214
|
-
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
218
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
219
|
+
local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
|
|
215
220
|
if defaultValue ~= nil or self.isGlobal then
|
|
216
|
-
local
|
|
217
|
-
if
|
|
218
|
-
|
|
221
|
+
local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
|
|
222
|
+
if ____self_valueByInstance_instance_3 == nil then
|
|
223
|
+
____self_valueByInstance_instance_3 = defaultValue
|
|
219
224
|
end
|
|
220
|
-
local
|
|
221
|
-
if
|
|
222
|
-
|
|
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
|
|
223
228
|
end
|
|
224
|
-
local previousValue =
|
|
229
|
+
local previousValue = ____self_valueByInstance_instance_3_4
|
|
225
230
|
if value ~= previousValue then
|
|
226
231
|
self.valueByInstance[instance] = value
|
|
227
232
|
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
@@ -242,10 +247,10 @@ function ObjectField.prototype.setActualValue(self, instance, value)
|
|
|
242
247
|
return true
|
|
243
248
|
end
|
|
244
249
|
function ObjectField.prototype.calculateActualValue(self, instance)
|
|
245
|
-
local
|
|
246
|
-
local originalValue =
|
|
247
|
-
local
|
|
248
|
-
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]
|
|
249
254
|
if originalValue ~= nil then
|
|
250
255
|
local value = originalValue
|
|
251
256
|
if modifiers ~= nil then
|
|
@@ -310,37 +315,37 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
310
315
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
311
316
|
local value = defaultValueByObjectDataEntryId[entry.id]
|
|
312
317
|
if value ~= nil then
|
|
313
|
-
local
|
|
318
|
+
local ____temp_10
|
|
314
319
|
if index == nil then
|
|
315
|
-
|
|
320
|
+
____temp_10 = value
|
|
316
321
|
else
|
|
317
|
-
local
|
|
318
|
-
if
|
|
319
|
-
|
|
322
|
+
local ____value_index_9 = value[index + 1]
|
|
323
|
+
if ____value_index_9 == nil then
|
|
324
|
+
____value_index_9 = self.defaultValue
|
|
320
325
|
end
|
|
321
|
-
|
|
326
|
+
____temp_10 = ____value_index_9
|
|
322
327
|
end
|
|
323
|
-
return
|
|
328
|
+
return ____temp_10
|
|
324
329
|
end
|
|
325
330
|
end
|
|
326
331
|
return index == nil and ({}) or self.defaultValue
|
|
327
332
|
end
|
|
328
333
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
329
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
330
|
-
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
331
|
-
if defaultValue ~= nil then
|
|
332
|
-
local value = self.valueByInstance[entry] or defaultValue
|
|
333
|
-
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
|
|
334
339
|
if index == nil then
|
|
335
|
-
|
|
340
|
+
____temp_12 = value
|
|
336
341
|
else
|
|
337
|
-
local
|
|
338
|
-
if
|
|
339
|
-
|
|
342
|
+
local ____value_index_11 = value[index + 1]
|
|
343
|
+
if ____value_index_11 == nil then
|
|
344
|
+
____value_index_11 = self.defaultValue
|
|
340
345
|
end
|
|
341
|
-
|
|
346
|
+
____temp_12 = ____value_index_11
|
|
342
347
|
end
|
|
343
|
-
return
|
|
348
|
+
return ____temp_12
|
|
344
349
|
end
|
|
345
350
|
end
|
|
346
351
|
if index ~= nil then
|
|
@@ -385,36 +390,36 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
385
390
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
386
391
|
local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
|
|
387
392
|
if valueByLevel ~= nil then
|
|
388
|
-
local
|
|
389
|
-
if
|
|
390
|
-
|
|
393
|
+
local ____valueByLevel_index_13 = valueByLevel[level + 1]
|
|
394
|
+
if ____valueByLevel_index_13 == nil then
|
|
395
|
+
____valueByLevel_index_13 = self.defaultValue
|
|
391
396
|
end
|
|
392
|
-
return
|
|
397
|
+
return ____valueByLevel_index_13
|
|
393
398
|
end
|
|
394
399
|
end
|
|
395
400
|
return self.defaultValue
|
|
396
401
|
end
|
|
397
402
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
398
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
399
|
-
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
400
|
-
if defaultValueByLevel ~= nil then
|
|
401
|
-
local
|
|
402
|
-
local
|
|
403
|
-
if
|
|
404
|
-
|
|
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]
|
|
405
410
|
end
|
|
406
|
-
local
|
|
407
|
-
if
|
|
408
|
-
|
|
411
|
+
local ____temp_16_17 = ____temp_16
|
|
412
|
+
if ____temp_16_17 == nil then
|
|
413
|
+
____temp_16_17 = self.defaultValue
|
|
409
414
|
end
|
|
410
|
-
return
|
|
415
|
+
return ____temp_16_17
|
|
411
416
|
end
|
|
412
417
|
end
|
|
413
|
-
local
|
|
414
|
-
if
|
|
415
|
-
|
|
418
|
+
local ____temp_18 = self:getNativeFieldValue(entry, level)
|
|
419
|
+
if ____temp_18 == nil then
|
|
420
|
+
____temp_18 = self.defaultValue
|
|
416
421
|
end
|
|
417
|
-
return
|
|
422
|
+
return ____temp_18
|
|
418
423
|
end
|
|
419
424
|
function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
420
425
|
if value == nil then
|
|
@@ -455,23 +460,23 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
|
455
460
|
return true
|
|
456
461
|
end
|
|
457
462
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
458
|
-
if defaultValueByObjectDataEntryId ~= nil then
|
|
459
|
-
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
463
|
+
if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
|
|
464
|
+
local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
|
|
460
465
|
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
461
466
|
local valueByLevel = self.valueByInstance[entry]
|
|
462
467
|
if valueByLevel == nil then
|
|
463
468
|
valueByLevel = {}
|
|
464
469
|
self.valueByInstance[entry] = valueByLevel
|
|
465
470
|
end
|
|
466
|
-
local
|
|
467
|
-
if
|
|
468
|
-
|
|
471
|
+
local ____valueByLevel_index_19 = valueByLevel[level + 1]
|
|
472
|
+
if ____valueByLevel_index_19 == nil then
|
|
473
|
+
____valueByLevel_index_19 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
469
474
|
end
|
|
470
|
-
local
|
|
471
|
-
if
|
|
472
|
-
|
|
475
|
+
local ____valueByLevel_index_19_20 = ____valueByLevel_index_19
|
|
476
|
+
if ____valueByLevel_index_19_20 == nil then
|
|
477
|
+
____valueByLevel_index_19_20 = self.defaultValue
|
|
473
478
|
end
|
|
474
|
-
local previousValue =
|
|
479
|
+
local previousValue = ____valueByLevel_index_19_20
|
|
475
480
|
if value ~= previousValue then
|
|
476
481
|
valueByLevel[level + 1] = value
|
|
477
482
|
self:invokeValueChangeEvent(
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { UnitClassificationsField, UnitPropulsionWindowField } from "../../object-field/unit";
|
|
3
|
+
export declare const PROPULSION_WINDOW_UNIT_FLOAT_FIELD: UnitPropulsionWindowField & symbol;
|
|
4
|
+
export declare const UNIT_CLASSIFICATIONS_FIELD: UnitClassificationsField & symbol;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
local ____exports = {}
|
|
2
|
+
local ____unit = require("engine.object-field.unit")
|
|
3
|
+
local UnitClassificationsField = ____unit.UnitClassificationsField
|
|
4
|
+
local UnitPropulsionWindowField = ____unit.UnitPropulsionWindowField
|
|
5
|
+
____exports.PROPULSION_WINDOW_UNIT_FLOAT_FIELD = UnitPropulsionWindowField:create(fourCC("urpw"))
|
|
6
|
+
____exports.UNIT_CLASSIFICATIONS_FIELD = UnitClassificationsField:create(fourCC("utyp"))
|
|
7
|
+
return ____exports
|
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 [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,22 @@
|
|
|
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
|
|
14
|
+
local ____playerCamera = require("core.types.playerCamera")
|
|
15
|
+
local worldCoordinatesToFrame = ____playerCamera.worldCoordinatesToFrame
|
|
16
|
+
local ____get_2Dterrain_2Dz = require("engine.internal.misc.get-terrain-z")
|
|
17
|
+
local getTerrainZ = ____get_2Dterrain_2Dz.getTerrainZ
|
|
18
|
+
local ____player_2Dlocal_2Dhandle = require("engine.internal.misc.player-local-handle")
|
|
19
|
+
local PLAYER_LOCAL_HANDLE = ____player_2Dlocal_2Dhandle.PLAYER_LOCAL_HANDLE
|
|
7
20
|
local createTextTag = CreateTextTag
|
|
8
21
|
local destroyTextTag = DestroyTextTag
|
|
9
22
|
local setTextTagText = SetTextTagText
|
|
@@ -17,17 +30,14 @@ local setTextTagPermanent = SetTextTagPermanent
|
|
|
17
30
|
local setTextTagAge = SetTextTagAge
|
|
18
31
|
local setTextTagLifespan = SetTextTagLifespan
|
|
19
32
|
local setTextTagFadepoint = SetTextTagFadepoint
|
|
33
|
+
local isUnitHidden = IsUnitHidden
|
|
34
|
+
local isUnitLoaded = IsUnitLoaded
|
|
35
|
+
local isUnitVisible = IsUnitVisible
|
|
36
|
+
local getUnitFlyHeight = GetUnitFlyHeight
|
|
37
|
+
local getUnitX = GetUnitX
|
|
38
|
+
local getUnitY = GetUnitY
|
|
20
39
|
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)
|
|
40
|
+
local function applyConfiguration(textTag, configuration)
|
|
31
41
|
setTextTagFadepoint(textTag, configuration.fadepoint)
|
|
32
42
|
setTextTagLifespan(textTag, configuration.lifespan)
|
|
33
43
|
local color = configuration.color
|
|
@@ -42,6 +52,212 @@ function TextTag.flash(self, configuration, text, x, y, z)
|
|
|
42
52
|
setTextTagPermanent(textTag, false)
|
|
43
53
|
setTextTagVisibility(textTag, true)
|
|
44
54
|
end
|
|
55
|
+
local unitTextTags = setmetatable({}, {__mode = "k"})
|
|
56
|
+
local function ensureHandle(textTag)
|
|
57
|
+
local handle = textTag[101]
|
|
58
|
+
if handle == nil then
|
|
59
|
+
handle = createTextTag()
|
|
60
|
+
applyConfiguration(handle, textTag[102])
|
|
61
|
+
setTextTagPermanent(handle, true)
|
|
62
|
+
setTextTagText(handle, textTag[103] or "", textTag[104] or DEFAULT_FONT_SIZE)
|
|
63
|
+
local color = textTag[105]
|
|
64
|
+
if color ~= nil then
|
|
65
|
+
setTextTagColor(
|
|
66
|
+
handle,
|
|
67
|
+
color.r,
|
|
68
|
+
color.g,
|
|
69
|
+
color.b,
|
|
70
|
+
color.a
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
local unit = textTag[100]
|
|
74
|
+
if unit ~= nil then
|
|
75
|
+
setTextTagPosUnit(handle, unit.handle, textTag[102].offsetZ)
|
|
76
|
+
else
|
|
77
|
+
setTextTagPos(handle, textTag[106] or 0, textTag[107] or 0, 0)
|
|
78
|
+
end
|
|
79
|
+
textTag[101] = handle
|
|
80
|
+
end
|
|
81
|
+
return handle
|
|
82
|
+
end
|
|
83
|
+
____exports.TextTag = __TS__Class()
|
|
84
|
+
local TextTag = ____exports.TextTag
|
|
85
|
+
TextTag.name = "TextTag"
|
|
86
|
+
__TS__ClassExtends(TextTag, AbstractDestroyable)
|
|
87
|
+
function TextTag.prototype.____constructor(self, handle)
|
|
88
|
+
AbstractDestroyable.prototype.____constructor(self)
|
|
89
|
+
self[101] = handle
|
|
90
|
+
end
|
|
91
|
+
function TextTag.prototype.onDestroy(self)
|
|
92
|
+
local handle = self[101]
|
|
93
|
+
if handle ~= nil then
|
|
94
|
+
destroyTextTag(handle)
|
|
95
|
+
self[101] = nil
|
|
96
|
+
end
|
|
97
|
+
unitTextTags[self] = nil
|
|
98
|
+
return AbstractDestroyable.prototype.onDestroy(self)
|
|
99
|
+
end
|
|
100
|
+
function TextTag.flash(self, configuration, text, x, y, z)
|
|
101
|
+
local textTag = createTextTag()
|
|
102
|
+
setTextTagText(textTag, text, DEFAULT_FONT_SIZE)
|
|
103
|
+
setTextTagPos(textTag, x + configuration.offsetX, y + configuration.offsetY, (z or 0) + configuration.offsetZ)
|
|
104
|
+
applyConfiguration(textTag, configuration)
|
|
105
|
+
end
|
|
106
|
+
function TextTag.create(self, configuration, text, unit)
|
|
107
|
+
local textTag = __TS__New(____exports.TextTag)
|
|
108
|
+
textTag[100] = unit
|
|
109
|
+
textTag[102] = configuration
|
|
110
|
+
ensureHandle(textTag)
|
|
111
|
+
unitTextTags[textTag] = true
|
|
112
|
+
return textTag
|
|
113
|
+
end
|
|
114
|
+
__TS__SetDescriptor(
|
|
115
|
+
TextTag.prototype,
|
|
116
|
+
"text",
|
|
117
|
+
{
|
|
118
|
+
get = function(self)
|
|
119
|
+
return self[103] or ""
|
|
120
|
+
end,
|
|
121
|
+
set = function(self, text)
|
|
122
|
+
setTextTagText(
|
|
123
|
+
ensureHandle(self),
|
|
124
|
+
text,
|
|
125
|
+
self[104] or DEFAULT_FONT_SIZE
|
|
126
|
+
)
|
|
127
|
+
self[103] = text
|
|
128
|
+
end
|
|
129
|
+
},
|
|
130
|
+
true
|
|
131
|
+
)
|
|
132
|
+
__TS__SetDescriptor(
|
|
133
|
+
TextTag.prototype,
|
|
134
|
+
"fontSize",
|
|
135
|
+
{
|
|
136
|
+
get = function(self)
|
|
137
|
+
return self[104] or DEFAULT_FONT_SIZE
|
|
138
|
+
end,
|
|
139
|
+
set = function(self, fontSize)
|
|
140
|
+
setTextTagText(
|
|
141
|
+
ensureHandle(self),
|
|
142
|
+
self[103] or "",
|
|
143
|
+
DEFAULT_FONT_SIZE
|
|
144
|
+
)
|
|
145
|
+
self[104] = fontSize
|
|
146
|
+
end
|
|
147
|
+
},
|
|
148
|
+
true
|
|
149
|
+
)
|
|
150
|
+
__TS__SetDescriptor(
|
|
151
|
+
TextTag.prototype,
|
|
152
|
+
"color",
|
|
153
|
+
{
|
|
154
|
+
get = function(self)
|
|
155
|
+
return self[105] or Color.white
|
|
156
|
+
end,
|
|
157
|
+
set = function(self, color)
|
|
158
|
+
setTextTagColor(
|
|
159
|
+
ensureHandle(self),
|
|
160
|
+
color.r,
|
|
161
|
+
color.g,
|
|
162
|
+
color.b,
|
|
163
|
+
color.a
|
|
164
|
+
)
|
|
165
|
+
self[105] = color
|
|
166
|
+
end
|
|
167
|
+
},
|
|
168
|
+
true
|
|
169
|
+
)
|
|
170
|
+
__TS__SetDescriptor(
|
|
171
|
+
TextTag.prototype,
|
|
172
|
+
"unit",
|
|
173
|
+
{
|
|
174
|
+
get = function(self)
|
|
175
|
+
return self[100]
|
|
176
|
+
end,
|
|
177
|
+
set = function(self, unit)
|
|
178
|
+
if unit ~= nil then
|
|
179
|
+
setTextTagPosUnit(
|
|
180
|
+
ensureHandle(self),
|
|
181
|
+
unit.handle,
|
|
182
|
+
0
|
|
183
|
+
)
|
|
184
|
+
self[106] = nil
|
|
185
|
+
self[107] = nil
|
|
186
|
+
unitTextTags[self] = true
|
|
187
|
+
elseif self[100] ~= nil then
|
|
188
|
+
local unit = self[100]
|
|
189
|
+
local x = unit.x
|
|
190
|
+
local y = unit.y
|
|
191
|
+
setTextTagPos(
|
|
192
|
+
ensureHandle(self),
|
|
193
|
+
x,
|
|
194
|
+
y,
|
|
195
|
+
0
|
|
196
|
+
)
|
|
197
|
+
self[106] = x
|
|
198
|
+
self[107] = y
|
|
199
|
+
unitTextTags[self] = nil
|
|
200
|
+
end
|
|
201
|
+
self[100] = unit
|
|
202
|
+
end
|
|
203
|
+
},
|
|
204
|
+
true
|
|
205
|
+
)
|
|
206
|
+
__TS__SetDescriptor(
|
|
207
|
+
TextTag.prototype,
|
|
208
|
+
"x",
|
|
209
|
+
{
|
|
210
|
+
get = function(self)
|
|
211
|
+
local ____self__106_2 = self[106]
|
|
212
|
+
if ____self__106_2 == nil then
|
|
213
|
+
local ____opt_0 = self[100]
|
|
214
|
+
____self__106_2 = ____opt_0 and ____opt_0.x
|
|
215
|
+
end
|
|
216
|
+
return ____self__106_2 or 0
|
|
217
|
+
end,
|
|
218
|
+
set = function(self, x)
|
|
219
|
+
local ____ensureHandle_result_6 = ensureHandle(self)
|
|
220
|
+
local ____x_7 = x
|
|
221
|
+
local ____self__107_5 = self[107]
|
|
222
|
+
if ____self__107_5 == nil then
|
|
223
|
+
local ____opt_3 = self[100]
|
|
224
|
+
____self__107_5 = ____opt_3 and ____opt_3.y
|
|
225
|
+
end
|
|
226
|
+
setTextTagPos(____ensureHandle_result_6, ____x_7, ____self__107_5 or 0, 0)
|
|
227
|
+
self[106] = x
|
|
228
|
+
self[100] = nil
|
|
229
|
+
unitTextTags[self] = nil
|
|
230
|
+
end
|
|
231
|
+
},
|
|
232
|
+
true
|
|
233
|
+
)
|
|
234
|
+
__TS__SetDescriptor(
|
|
235
|
+
TextTag.prototype,
|
|
236
|
+
"y",
|
|
237
|
+
{
|
|
238
|
+
get = function(self)
|
|
239
|
+
local ____self__107_10 = self[107]
|
|
240
|
+
if ____self__107_10 == nil then
|
|
241
|
+
local ____opt_8 = self[100]
|
|
242
|
+
____self__107_10 = ____opt_8 and ____opt_8.y
|
|
243
|
+
end
|
|
244
|
+
return ____self__107_10 or 0
|
|
245
|
+
end,
|
|
246
|
+
set = function(self, y)
|
|
247
|
+
local ____ensureHandle_result_14 = ensureHandle(self)
|
|
248
|
+
local ____self__106_13 = self[106]
|
|
249
|
+
if ____self__106_13 == nil then
|
|
250
|
+
local ____opt_11 = self[100]
|
|
251
|
+
____self__106_13 = ____opt_11 and ____opt_11.x
|
|
252
|
+
end
|
|
253
|
+
setTextTagPos(____ensureHandle_result_14, ____self__106_13 or 0, y, 0)
|
|
254
|
+
self[107] = y
|
|
255
|
+
self[100] = nil
|
|
256
|
+
unitTextTags[self] = nil
|
|
257
|
+
end
|
|
258
|
+
},
|
|
259
|
+
true
|
|
260
|
+
)
|
|
45
261
|
TextTag.BASE = {
|
|
46
262
|
fadepoint = 2,
|
|
47
263
|
lifespan = 3,
|
|
@@ -106,4 +322,26 @@ TextTag.SHADOW_STRIKE = __TS__ObjectAssign(
|
|
|
106
322
|
lifespan = 5
|
|
107
323
|
}
|
|
108
324
|
)
|
|
325
|
+
Timer.onPeriod[1 / 64]:addListener(function()
|
|
326
|
+
for textTag in pairs(unitTextTags) do
|
|
327
|
+
local unit = textTag[100].handle
|
|
328
|
+
local x = getUnitX(unit)
|
|
329
|
+
local y = getUnitY(unit)
|
|
330
|
+
local ____, ____, isInView = worldCoordinatesToFrame(
|
|
331
|
+
x,
|
|
332
|
+
y,
|
|
333
|
+
getUnitFlyHeight(unit) + getTerrainZ(x, y)
|
|
334
|
+
)
|
|
335
|
+
if isInView and not isUnitHidden(unit) and not isUnitLoaded(unit) and isUnitVisible(unit, PLAYER_LOCAL_HANDLE) then
|
|
336
|
+
setTextTagPosUnit(
|
|
337
|
+
ensureHandle(textTag),
|
|
338
|
+
unit,
|
|
339
|
+
textTag[102].offsetZ
|
|
340
|
+
)
|
|
341
|
+
elseif textTag[101] ~= nil then
|
|
342
|
+
destroyTextTag(textTag[101])
|
|
343
|
+
textTag[101] = nil
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
end)
|
|
109
347
|
return ____exports
|
package/engine/unit.d.ts
CHANGED
package/engine/unit.lua
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "warscript",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.193ed34",
|
|
5
5
|
"description": "A typescript library for Warcraft III using Warpack.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"warcraft",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@warscript/language-extensions": "^0.0.1",
|
|
25
25
|
"@warscript/tstl-plugin": "^0.0.4",
|
|
26
26
|
"lua-types": "^2.13.1",
|
|
27
|
-
"warpack": "0.0.1-dev.
|
|
27
|
+
"warpack": "0.0.1-dev.78d2c64"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
package/utility/functions.d.ts
CHANGED
|
@@ -4,3 +4,10 @@ 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;
|
|
10
|
+
export declare const increment: (value: number) => number;
|
|
11
|
+
export declare const or: (lhs: boolean, rhs: boolean) => boolean;
|
|
12
|
+
export type Transform<T, R> = (<T, R>(value: T) => R) | KeysOfType<T, R>;
|
|
13
|
+
export declare const transform: <T, R>(object: T, transform: Transform<T, R>) => R;
|
package/utility/functions.lua
CHANGED
|
@@ -88,4 +88,16 @@ ____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
|
|
94
|
+
____exports.increment = function(value) return value + 1 end
|
|
95
|
+
____exports["or"] = function(lhs, rhs) return lhs or rhs end
|
|
96
|
+
____exports.transform = function(object, transform)
|
|
97
|
+
if type(transform) == "function" then
|
|
98
|
+
return transform(object)
|
|
99
|
+
else
|
|
100
|
+
return object[transform]
|
|
101
|
+
end
|
|
102
|
+
end
|
|
91
103
|
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
|