warscript 0.0.1-dev.f48f7bb → 0.0.1-dev.f9166a3
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/attributes.d.ts +5 -0
- package/attributes.lua +8 -1
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +1 -3
- package/core/types/effect.lua +26 -29
- package/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/timer.d.ts +6 -7
- package/core/types/timer.lua +18 -21
- package/core/util.lua +6 -1
- package/decl/native.d.ts +840 -786
- package/engine/behaviour/ability/apply-buff.d.ts +5 -0
- package/engine/behaviour/ability/apply-buff.lua +32 -0
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +9 -3
- package/engine/behaviour/ability/damage.lua +26 -38
- package/engine/behaviour/ability/emulate-impact.lua +16 -2
- package/engine/behaviour/ability.d.ts +7 -2
- package/engine/behaviour/ability.lua +35 -8
- package/engine/behaviour/unit.d.ts +17 -0
- package/engine/behaviour/unit.lua +114 -4
- package/engine/buff.d.ts +56 -41
- package/engine/buff.lua +295 -228
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -2
- package/engine/internal/item/ability.lua +15 -13
- package/engine/internal/item.d.ts +7 -4
- package/engine/internal/item.lua +131 -28
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- package/engine/internal/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/bonus.d.ts +2 -0
- package/engine/internal/unit/bonus.lua +17 -0
- package/engine/internal/unit/item.lua +3 -48
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +27 -4
- package/engine/internal/unit.lua +178 -37
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- package/engine/object-data/auxiliary/attachment-preset.d.ts +7 -2
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -17
- package/engine/object-data/entry/ability-type.lua +81 -21
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type.d.ts +6 -12
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.d.ts +1 -1
- package/engine/object-data/entry/item-type.lua +4 -4
- package/engine/object-data/entry/lightning-type.d.ts +1 -1
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +10 -3
- package/engine/object-data/entry/unit-type.lua +155 -92
- package/engine/object-data/entry/upgrade.d.ts +1 -1
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +16 -14
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-field/ability.d.ts +1 -1
- package/engine/object-field/unit.d.ts +46 -3
- package/engine/object-field/unit.lua +173 -7
- package/engine/object-field.d.ts +12 -3
- package/engine/object-field.lua +164 -78
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/unit.d.ts +1 -0
- package/engine/unit.lua +1 -0
- package/objutil/buff.lua +1 -2
- package/objutil/unit.lua +8 -0
- package/package.json +2 -2
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +3 -0
- package/utility/functions.d.ts +1 -0
- package/utility/functions.lua +1 -0
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +3 -0
- package/utility/lua-maps.d.ts +3 -0
- package/utility/lua-maps.lua +16 -0
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +3 -0
- package/utility/reflection.lua +11 -7
|
@@ -7,10 +7,11 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
|
7
7
|
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
8
8
|
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
|
|
9
9
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
10
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
10
11
|
local __TS__StringSplit = ____lualib.__TS__StringSplit
|
|
11
12
|
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
12
13
|
local ____exports = {}
|
|
13
|
-
local booleanToData, dataToBoolean, numberToData, dataToNumber, stringToData, dataToString, objectDataEntryIdToData, dataToObjectDataEntryId, booleansToData, dataToBooleans, numbersToData, dataToNumbers, stringsToData, dataToStrings,
|
|
14
|
+
local booleanToData, dataToBoolean, numberToData, dataToNumber, stringToData, dataToString, objectDataEntryNumericIdToData, dataToObjectDataEntryNumericId, objectDataEntryIdToData, dataToObjectDataEntryId, booleansToData, dataToBooleans, numbersToData, dataToNumbers, stringsToData, dataToStrings, objectDataEntryNumericIdsToData, dataToObjectDataEntryNumericIds, isDataNotBlank
|
|
14
15
|
local ____attachment_2Dpreset = require("engine.object-data.auxiliary.attachment-preset")
|
|
15
16
|
local extractAttachmentPresetInputModelPath = ____attachment_2Dpreset.extractAttachmentPresetInputModelPath
|
|
16
17
|
local extractAttachmentPresetInputNodeFQN = ____attachment_2Dpreset.extractAttachmentPresetInputNodeFQN
|
|
@@ -124,7 +125,7 @@ function ObjectDataEntry.getAllByBaseIds(self, baseIds)
|
|
|
124
125
|
local constructor = self
|
|
125
126
|
for id, object in pairs(constructor:getObjectData(currentMap).all) do
|
|
126
127
|
if dataBaseIds[object.parentId or id] ~= nil then
|
|
127
|
-
local objectDataEntry = self:of(dataToObjectDataEntryId(id))
|
|
128
|
+
local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.idType))
|
|
128
129
|
if objectDataEntry ~= nil and not objectDataEntry.isInternal then
|
|
129
130
|
result[#result + 1] = objectDataEntry
|
|
130
131
|
end
|
|
@@ -139,7 +140,7 @@ function ObjectDataEntry.getAll(self)
|
|
|
139
140
|
local constructor = self
|
|
140
141
|
local result = {}
|
|
141
142
|
for id in pairs(constructor:getObjectData(currentMap).all) do
|
|
142
|
-
local objectDataEntry = self:of(dataToObjectDataEntryId(id))
|
|
143
|
+
local objectDataEntry = self:of(dataToObjectDataEntryId(id, self.idType))
|
|
143
144
|
if objectDataEntry ~= nil and not objectDataEntry.isInternal then
|
|
144
145
|
result[#result + 1] = objectDataEntry
|
|
145
146
|
end
|
|
@@ -156,9 +157,9 @@ function ObjectDataEntry.of(self, id)
|
|
|
156
157
|
if object == nil then
|
|
157
158
|
return nil
|
|
158
159
|
end
|
|
159
|
-
local objectDataEntry = objectDataEntryByObjectDataEntryId[dataToObjectDataEntryId(object.id)]
|
|
160
|
+
local objectDataEntry = objectDataEntryByObjectDataEntryId[dataToObjectDataEntryId(object.id, self.idType)]
|
|
160
161
|
if objectDataEntry == nil then
|
|
161
|
-
if not constructor.IS_SYNTHETIC and (self.BASE_ID == 0 or dataToObjectDataEntryId(object.parentId) == self.BASE_ID) then
|
|
162
|
+
if not constructor.IS_SYNTHETIC and (self.BASE_ID == 0 or dataToObjectDataEntryId(object.parentId, self.idType) == self.BASE_ID) then
|
|
162
163
|
local AbstractObjectDataEntryView = __TS__Class()
|
|
163
164
|
AbstractObjectDataEntryView.name = "AbstractObjectDataEntryView"
|
|
164
165
|
__TS__ClassExtends(AbstractObjectDataEntryView, constructor)
|
|
@@ -231,13 +232,13 @@ function ObjectDataEntry.prototype.setStringField(self, field, value)
|
|
|
231
232
|
stringToData(value)
|
|
232
233
|
)
|
|
233
234
|
end
|
|
234
|
-
function ObjectDataEntry.prototype.
|
|
235
|
-
return
|
|
235
|
+
function ObjectDataEntry.prototype.getObjectDataEntryNumericIdField(self, field)
|
|
236
|
+
return dataToObjectDataEntryNumericId(self.object:getField(field))
|
|
236
237
|
end
|
|
237
|
-
function ObjectDataEntry.prototype.
|
|
238
|
+
function ObjectDataEntry.prototype.setObjectDataEntryNumericIdField(self, field, value)
|
|
238
239
|
self.object:setField(
|
|
239
240
|
field,
|
|
240
|
-
|
|
241
|
+
objectDataEntryNumericIdToData(value)
|
|
241
242
|
)
|
|
242
243
|
end
|
|
243
244
|
function ObjectDataEntry.prototype.getAttachmentPresetField(self, modelPathField, nodeFQNField)
|
|
@@ -285,13 +286,13 @@ function ObjectDataEntry.prototype.setStringsField(self, field, values)
|
|
|
285
286
|
stringsToData(values)
|
|
286
287
|
)
|
|
287
288
|
end
|
|
288
|
-
function ObjectDataEntry.prototype.
|
|
289
|
-
return
|
|
289
|
+
function ObjectDataEntry.prototype.getObjectDataEntryNumericIdsField(self, field)
|
|
290
|
+
return dataToObjectDataEntryNumericIds(self.object:getField(field))
|
|
290
291
|
end
|
|
291
|
-
function ObjectDataEntry.prototype.
|
|
292
|
+
function ObjectDataEntry.prototype.setObjectDataEntryNumericIdsField(self, field, values)
|
|
292
293
|
self.object:setField(
|
|
293
294
|
field,
|
|
294
|
-
|
|
295
|
+
objectDataEntryNumericIdsToData(values)
|
|
295
296
|
)
|
|
296
297
|
end
|
|
297
298
|
function ObjectDataEntry.prototype.getAttachmentPresetListField(self, modelPathListField, nodeFQNFields)
|
|
@@ -369,16 +370,16 @@ function ObjectDataEntry.prototype.setStringLevelField(self, field, values)
|
|
|
369
370
|
stringToData
|
|
370
371
|
)
|
|
371
372
|
end
|
|
372
|
-
function ObjectDataEntry.prototype.
|
|
373
|
-
return self:getLevelField(field,
|
|
373
|
+
function ObjectDataEntry.prototype.getObjectDataEntryNumericIdLevelField(self, field)
|
|
374
|
+
return self:getLevelField(field, dataToObjectDataEntryNumericId)
|
|
374
375
|
end
|
|
375
|
-
function ObjectDataEntry.prototype.
|
|
376
|
+
function ObjectDataEntry.prototype.setObjectDataEntryNumericIdLevelField(self, field, values)
|
|
376
377
|
self:setLevelField(
|
|
377
378
|
field,
|
|
378
379
|
values,
|
|
379
380
|
____exports.extractObjectDataEntryLevelFieldValue,
|
|
380
|
-
|
|
381
|
-
|
|
381
|
+
dataToObjectDataEntryNumericId,
|
|
382
|
+
objectDataEntryNumericIdToData
|
|
382
383
|
)
|
|
383
384
|
end
|
|
384
385
|
function ObjectDataEntry.prototype.getBooleansLevelField(self, field)
|
|
@@ -417,23 +418,26 @@ function ObjectDataEntry.prototype.setStringsLevelField(self, field, values)
|
|
|
417
418
|
stringsToData
|
|
418
419
|
)
|
|
419
420
|
end
|
|
420
|
-
function ObjectDataEntry.prototype.
|
|
421
|
-
return self:getLevelField(field,
|
|
421
|
+
function ObjectDataEntry.prototype.getObjectDataEntryNumericIdsLevelField(self, field)
|
|
422
|
+
return self:getLevelField(field, dataToObjectDataEntryNumericIds)
|
|
422
423
|
end
|
|
423
|
-
function ObjectDataEntry.prototype.
|
|
424
|
+
function ObjectDataEntry.prototype.setObjectDataEntryNumericIdsLevelField(self, field, values)
|
|
424
425
|
self:setLevelField(
|
|
425
426
|
field,
|
|
426
427
|
values,
|
|
427
428
|
____exports.extractObjectDataEntryLevelArrayFieldValue,
|
|
428
|
-
|
|
429
|
-
|
|
429
|
+
dataToObjectDataEntryNumericIds,
|
|
430
|
+
objectDataEntryNumericIdsToData
|
|
430
431
|
)
|
|
431
432
|
end
|
|
432
433
|
function ObjectDataEntry.prototype.getLevelField(self, field, dataToValue)
|
|
433
434
|
local values = {}
|
|
434
435
|
local object = self.object
|
|
435
436
|
for level = 1, tonumber(object:getField("levels")) or 1 do
|
|
436
|
-
values[level] = dataToValue(
|
|
437
|
+
values[level] = dataToValue(
|
|
438
|
+
object:getField((field .. "+") .. tostring(level)),
|
|
439
|
+
"number"
|
|
440
|
+
)
|
|
437
441
|
end
|
|
438
442
|
return values
|
|
439
443
|
end
|
|
@@ -473,6 +477,14 @@ function ObjectDataEntry.prototype.setLevelField(self, field, supplier, extracto
|
|
|
473
477
|
end
|
|
474
478
|
ObjectDataEntry.BASE_ID = 0
|
|
475
479
|
ObjectDataEntry.IS_SYNTHETIC = false
|
|
480
|
+
__TS__SetDescriptor(
|
|
481
|
+
ObjectDataEntry.prototype,
|
|
482
|
+
"type",
|
|
483
|
+
{get = function(self)
|
|
484
|
+
return self.constructor
|
|
485
|
+
end},
|
|
486
|
+
true
|
|
487
|
+
)
|
|
476
488
|
__TS__SetDescriptor(
|
|
477
489
|
ObjectDataEntry.prototype,
|
|
478
490
|
"isInternal",
|
|
@@ -491,11 +503,18 @@ __TS__SetDescriptor(
|
|
|
491
503
|
},
|
|
492
504
|
true
|
|
493
505
|
)
|
|
506
|
+
__TS__ObjectDefineProperty(
|
|
507
|
+
ObjectDataEntry,
|
|
508
|
+
"idType",
|
|
509
|
+
{get = function(self)
|
|
510
|
+
return type(self.BASE_ID) == "number" and "number" or "string"
|
|
511
|
+
end}
|
|
512
|
+
)
|
|
494
513
|
__TS__SetDescriptor(
|
|
495
514
|
ObjectDataEntry.prototype,
|
|
496
515
|
"id",
|
|
497
516
|
{get = function(self)
|
|
498
|
-
return dataToObjectDataEntryId(self.object.id)
|
|
517
|
+
return dataToObjectDataEntryId(self.object.id, self.type.idType)
|
|
499
518
|
end},
|
|
500
519
|
true
|
|
501
520
|
)
|
|
@@ -503,7 +522,7 @@ __TS__SetDescriptor(
|
|
|
503
522
|
ObjectDataEntry.prototype,
|
|
504
523
|
"baseId",
|
|
505
524
|
{get = function(self)
|
|
506
|
-
return dataToObjectDataEntryId(self.object.parentId or self.object.id)
|
|
525
|
+
return dataToObjectDataEntryId(self.object.parentId or self.object.id, self.type.idType)
|
|
507
526
|
end},
|
|
508
527
|
true
|
|
509
528
|
)
|
|
@@ -533,10 +552,10 @@ end
|
|
|
533
552
|
dataToString = function(data)
|
|
534
553
|
return tostring(data or "")
|
|
535
554
|
end
|
|
536
|
-
|
|
555
|
+
objectDataEntryNumericIdToData = function(value)
|
|
537
556
|
return value == 0 and "" or string.pack(">I4", value)
|
|
538
557
|
end
|
|
539
|
-
|
|
558
|
+
dataToObjectDataEntryNumericId = function(data)
|
|
540
559
|
local dataString = dataToString(data)
|
|
541
560
|
if isDataNotBlank(nil, dataString) then
|
|
542
561
|
return (string.unpack(">I4", dataString))
|
|
@@ -544,6 +563,15 @@ dataToObjectDataEntryId = function(data)
|
|
|
544
563
|
return 0
|
|
545
564
|
end
|
|
546
565
|
end
|
|
566
|
+
objectDataEntryIdToData = function(value)
|
|
567
|
+
return type(value) == "number" and objectDataEntryNumericIdToData(value) or value
|
|
568
|
+
end
|
|
569
|
+
dataToObjectDataEntryId = function(data, ____type)
|
|
570
|
+
if ____type == "number" then
|
|
571
|
+
return dataToObjectDataEntryNumericId(data)
|
|
572
|
+
end
|
|
573
|
+
return dataToString(data)
|
|
574
|
+
end
|
|
547
575
|
booleansToData = function(value)
|
|
548
576
|
return table.concat(
|
|
549
577
|
__TS__ArrayMap(
|
|
@@ -607,16 +635,16 @@ dataToStrings = function(data)
|
|
|
607
635
|
function(____, data) return dataToString(data) end
|
|
608
636
|
)
|
|
609
637
|
end
|
|
610
|
-
|
|
638
|
+
objectDataEntryNumericIdsToData = function(value)
|
|
611
639
|
return table.concat(
|
|
612
640
|
__TS__ArrayMap(
|
|
613
641
|
value,
|
|
614
|
-
function(____, objectDataEntryId) return
|
|
642
|
+
function(____, objectDataEntryId) return objectDataEntryNumericIdToData(objectDataEntryId) end
|
|
615
643
|
),
|
|
616
644
|
","
|
|
617
645
|
)
|
|
618
646
|
end
|
|
619
|
-
|
|
647
|
+
dataToObjectDataEntryNumericIds = function(data)
|
|
620
648
|
return __TS__ArrayMap(
|
|
621
649
|
__TS__ArrayFilter(
|
|
622
650
|
__TS__StringSplit(
|
|
@@ -625,7 +653,7 @@ dataToObjectDataEntryIds = function(data)
|
|
|
625
653
|
),
|
|
626
654
|
isDataNotBlank
|
|
627
655
|
),
|
|
628
|
-
function(____, data) return
|
|
656
|
+
function(____, data) return dataToObjectDataEntryNumericId(data) end
|
|
629
657
|
)
|
|
630
658
|
end
|
|
631
659
|
isDataNotBlank = function(self, data)
|
|
@@ -117,7 +117,7 @@ export declare abstract class AbilityEnumLevelField<T extends number> extends Ab
|
|
|
117
117
|
protected getNativeFieldById(id: number): jabilityintegerlevelfield;
|
|
118
118
|
protected getNativeFieldValue(instance: Ability, level: number): T;
|
|
119
119
|
protected setNativeFieldValue(instance: Ability, level: number, value: T): boolean;
|
|
120
|
-
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<
|
|
120
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<AbilityEnumLevelField<number>>;
|
|
121
121
|
}
|
|
122
122
|
export declare class AbilityBuffPolarityLevelField extends AbilityEnumLevelField<BuffPolarity> {
|
|
123
123
|
protected values: ReadonlyNonEmptyLinkedSet<BuffPolarity>;
|
|
@@ -1,16 +1,59 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Unit } from "../internal/unit";
|
|
3
|
-
import { ObjectField } from "../object-field";
|
|
3
|
+
import { ObjectField, ObjectLevelField, ObjectLevelFieldValueChangeEvent, ReadonlyObjectLevelFieldType } from "../object-field";
|
|
4
4
|
import { UnitType, UnitTypeId } from "../object-data/entry/unit-type";
|
|
5
|
+
import { ReadonlyNonEmptyLinkedSet } from "../../utility/linked-set";
|
|
6
|
+
import { AttackType } from "../object-data/auxiliary/attack-type";
|
|
5
7
|
export declare abstract class UnitField<ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = any> extends ObjectField<UnitType, Unit, ValueType, NativeFieldType> {
|
|
6
8
|
protected get instanceClass(): typeof Unit;
|
|
7
9
|
protected getObjectDataEntryId(instance: Unit): UnitTypeId;
|
|
10
|
+
protected hasNativeFieldValue(): boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class UnitBooleanField extends UnitField<boolean, junitbooleanfield> {
|
|
13
|
+
protected get defaultValue(): boolean;
|
|
14
|
+
protected getNativeFieldById(id: number): junitbooleanfield;
|
|
15
|
+
protected getNativeFieldValue(instance: Unit): boolean;
|
|
16
|
+
protected setNativeFieldValue(instance: Unit, value: boolean): boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class UnitFloatField extends UnitField<number, junitrealfield> {
|
|
19
|
+
protected get defaultValue(): number;
|
|
20
|
+
protected getNativeFieldById(id: number): junitrealfield;
|
|
21
|
+
protected getNativeFieldValue(instance: Unit): number;
|
|
22
|
+
protected setNativeFieldValue(instance: Unit, value: number): boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare class UnitIntegerField extends UnitField<number, junitintegerfield> {
|
|
25
|
+
protected get defaultValue(): number;
|
|
26
|
+
protected getNativeFieldById(id: number): junitintegerfield;
|
|
27
|
+
protected getNativeFieldValue(instance: Unit): number;
|
|
28
|
+
protected setNativeFieldValue(instance: Unit, value: number): boolean;
|
|
8
29
|
}
|
|
9
30
|
export declare class UnitStringField extends UnitField<string, junitstringfield> {
|
|
10
31
|
protected get defaultValue(): string;
|
|
11
32
|
protected getNativeFieldById(id: number): junitstringfield;
|
|
12
|
-
protected hasNativeFieldValue(): boolean;
|
|
13
33
|
protected getNativeFieldValue(instance: Unit): string;
|
|
14
|
-
protected getObjectDataEntryId(instance: Unit): UnitTypeId;
|
|
15
34
|
protected setNativeFieldValue(instance: Unit, value: string): boolean;
|
|
16
35
|
}
|
|
36
|
+
type junitweaponfield = junitweaponbooleanfield | junitweaponintegerfield | junitweaponrealfield | junitweaponstringfield;
|
|
37
|
+
export declare abstract class UnitWeaponField<ValueType extends number | string | boolean = number | string | boolean, InputValueType extends ValueType = never, NativeFieldType extends junitweaponfield = junitweaponfield> extends ObjectLevelField<UnitType, Unit, ValueType, InputValueType, NativeFieldType> {
|
|
38
|
+
protected get instanceClass(): typeof Unit;
|
|
39
|
+
protected getLevelCount(): number;
|
|
40
|
+
protected getObjectDataEntryId(instance: Unit): UnitTypeId;
|
|
41
|
+
protected hasNativeFieldValue(): boolean;
|
|
42
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<ReadonlyObjectLevelFieldType<UnitWeaponField>>;
|
|
43
|
+
}
|
|
44
|
+
export declare abstract class UnitNumberWeaponField<NativeFieldType extends junitweaponintegerfield | junitweaponrealfield = junitweaponintegerfield | junitweaponrealfield> extends UnitWeaponField<number, number, NativeFieldType> {
|
|
45
|
+
protected get defaultValue(): number;
|
|
46
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<UnitNumberWeaponField>;
|
|
47
|
+
}
|
|
48
|
+
export declare abstract class UnitEnumWeaponField<T extends number> extends UnitWeaponField<T, T, junitweaponintegerfield> {
|
|
49
|
+
protected abstract values: ReadonlyNonEmptyLinkedSet<T>;
|
|
50
|
+
protected get defaultValue(): T;
|
|
51
|
+
protected getNativeFieldById(id: number): junitweaponintegerfield;
|
|
52
|
+
protected getNativeFieldValue(instance: Unit, index: number): T;
|
|
53
|
+
protected setNativeFieldValue(instance: Unit, index: number, value: T): boolean;
|
|
54
|
+
static get valueChangeEvent(): ObjectLevelFieldValueChangeEvent<UnitEnumWeaponField<number>>;
|
|
55
|
+
}
|
|
56
|
+
export declare class UnitAttackTypeWeaponField extends UnitEnumWeaponField<AttackType> {
|
|
57
|
+
protected values: ReadonlyNonEmptyLinkedSet<AttackType>;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -2,11 +2,22 @@ local ____lualib = require("lualib_bundle")
|
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
4
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
|
+
local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____unit = require("engine.internal.unit")
|
|
7
8
|
local Unit = ____unit.Unit
|
|
8
9
|
local ____object_2Dfield = require("engine.object-field")
|
|
9
10
|
local ObjectField = ____object_2Dfield.ObjectField
|
|
11
|
+
local ObjectLevelField = ____object_2Dfield.ObjectLevelField
|
|
12
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
13
|
+
local nonEmptyLinkedSetOf = ____linked_2Dset.nonEmptyLinkedSetOf
|
|
14
|
+
local convertUnitBooleanField = ConvertUnitBooleanField
|
|
15
|
+
local convertUnitIntegerField = ConvertUnitIntegerField
|
|
16
|
+
local convertUnitRealField = ConvertUnitRealField
|
|
17
|
+
local convertUnitStringField = ConvertUnitStringField
|
|
18
|
+
local convertUnitWeaponIntegerField = ConvertUnitWeaponIntegerField
|
|
19
|
+
local getUnitWeaponIntegerField = BlzGetUnitWeaponIntegerField
|
|
20
|
+
local setUnitWeaponIntegerField = BlzSetUnitWeaponIntegerField
|
|
10
21
|
____exports.UnitField = __TS__Class()
|
|
11
22
|
local UnitField = ____exports.UnitField
|
|
12
23
|
UnitField.name = "UnitField"
|
|
@@ -14,6 +25,9 @@ __TS__ClassExtends(UnitField, ObjectField)
|
|
|
14
25
|
function UnitField.prototype.getObjectDataEntryId(self, instance)
|
|
15
26
|
return instance.typeId
|
|
16
27
|
end
|
|
28
|
+
function UnitField.prototype.hasNativeFieldValue(self)
|
|
29
|
+
return true
|
|
30
|
+
end
|
|
17
31
|
__TS__SetDescriptor(
|
|
18
32
|
UnitField.prototype,
|
|
19
33
|
"instanceClass",
|
|
@@ -22,22 +36,79 @@ __TS__SetDescriptor(
|
|
|
22
36
|
end},
|
|
23
37
|
true
|
|
24
38
|
)
|
|
39
|
+
____exports.UnitBooleanField = __TS__Class()
|
|
40
|
+
local UnitBooleanField = ____exports.UnitBooleanField
|
|
41
|
+
UnitBooleanField.name = "UnitBooleanField"
|
|
42
|
+
__TS__ClassExtends(UnitBooleanField, ____exports.UnitField)
|
|
43
|
+
function UnitBooleanField.prototype.getNativeFieldById(self, id)
|
|
44
|
+
return convertUnitBooleanField(id)
|
|
45
|
+
end
|
|
46
|
+
function UnitBooleanField.prototype.getNativeFieldValue(self, instance)
|
|
47
|
+
return instance:getField(self.nativeField)
|
|
48
|
+
end
|
|
49
|
+
function UnitBooleanField.prototype.setNativeFieldValue(self, instance, value)
|
|
50
|
+
return instance:setField(self.nativeField, value)
|
|
51
|
+
end
|
|
52
|
+
__TS__SetDescriptor(
|
|
53
|
+
UnitBooleanField.prototype,
|
|
54
|
+
"defaultValue",
|
|
55
|
+
{get = function(self)
|
|
56
|
+
return false
|
|
57
|
+
end},
|
|
58
|
+
true
|
|
59
|
+
)
|
|
60
|
+
____exports.UnitFloatField = __TS__Class()
|
|
61
|
+
local UnitFloatField = ____exports.UnitFloatField
|
|
62
|
+
UnitFloatField.name = "UnitFloatField"
|
|
63
|
+
__TS__ClassExtends(UnitFloatField, ____exports.UnitField)
|
|
64
|
+
function UnitFloatField.prototype.getNativeFieldById(self, id)
|
|
65
|
+
return convertUnitRealField(id)
|
|
66
|
+
end
|
|
67
|
+
function UnitFloatField.prototype.getNativeFieldValue(self, instance)
|
|
68
|
+
return instance:getField(self.nativeField)
|
|
69
|
+
end
|
|
70
|
+
function UnitFloatField.prototype.setNativeFieldValue(self, instance, value)
|
|
71
|
+
return instance:setField(self.nativeField, value)
|
|
72
|
+
end
|
|
73
|
+
__TS__SetDescriptor(
|
|
74
|
+
UnitFloatField.prototype,
|
|
75
|
+
"defaultValue",
|
|
76
|
+
{get = function(self)
|
|
77
|
+
return 0
|
|
78
|
+
end},
|
|
79
|
+
true
|
|
80
|
+
)
|
|
81
|
+
____exports.UnitIntegerField = __TS__Class()
|
|
82
|
+
local UnitIntegerField = ____exports.UnitIntegerField
|
|
83
|
+
UnitIntegerField.name = "UnitIntegerField"
|
|
84
|
+
__TS__ClassExtends(UnitIntegerField, ____exports.UnitField)
|
|
85
|
+
function UnitIntegerField.prototype.getNativeFieldById(self, id)
|
|
86
|
+
return convertUnitIntegerField(id)
|
|
87
|
+
end
|
|
88
|
+
function UnitIntegerField.prototype.getNativeFieldValue(self, instance)
|
|
89
|
+
return instance:getField(self.nativeField)
|
|
90
|
+
end
|
|
91
|
+
function UnitIntegerField.prototype.setNativeFieldValue(self, instance, value)
|
|
92
|
+
return instance:setField(self.nativeField, value)
|
|
93
|
+
end
|
|
94
|
+
__TS__SetDescriptor(
|
|
95
|
+
UnitIntegerField.prototype,
|
|
96
|
+
"defaultValue",
|
|
97
|
+
{get = function(self)
|
|
98
|
+
return 0
|
|
99
|
+
end},
|
|
100
|
+
true
|
|
101
|
+
)
|
|
25
102
|
____exports.UnitStringField = __TS__Class()
|
|
26
103
|
local UnitStringField = ____exports.UnitStringField
|
|
27
104
|
UnitStringField.name = "UnitStringField"
|
|
28
105
|
__TS__ClassExtends(UnitStringField, ____exports.UnitField)
|
|
29
106
|
function UnitStringField.prototype.getNativeFieldById(self, id)
|
|
30
|
-
return
|
|
31
|
-
end
|
|
32
|
-
function UnitStringField.prototype.hasNativeFieldValue(self)
|
|
33
|
-
return true
|
|
107
|
+
return convertUnitStringField(id)
|
|
34
108
|
end
|
|
35
109
|
function UnitStringField.prototype.getNativeFieldValue(self, instance)
|
|
36
110
|
return instance:getField(self.nativeField)
|
|
37
111
|
end
|
|
38
|
-
function UnitStringField.prototype.getObjectDataEntryId(self, instance)
|
|
39
|
-
return instance.typeId
|
|
40
|
-
end
|
|
41
112
|
function UnitStringField.prototype.setNativeFieldValue(self, instance, value)
|
|
42
113
|
return instance:setField(self.nativeField, value)
|
|
43
114
|
end
|
|
@@ -49,4 +120,99 @@ __TS__SetDescriptor(
|
|
|
49
120
|
end},
|
|
50
121
|
true
|
|
51
122
|
)
|
|
123
|
+
____exports.UnitWeaponField = __TS__Class()
|
|
124
|
+
local UnitWeaponField = ____exports.UnitWeaponField
|
|
125
|
+
UnitWeaponField.name = "UnitWeaponField"
|
|
126
|
+
__TS__ClassExtends(UnitWeaponField, ObjectLevelField)
|
|
127
|
+
function UnitWeaponField.prototype.getLevelCount(self)
|
|
128
|
+
return 2
|
|
129
|
+
end
|
|
130
|
+
function UnitWeaponField.prototype.getObjectDataEntryId(self, instance)
|
|
131
|
+
return instance.typeId
|
|
132
|
+
end
|
|
133
|
+
function UnitWeaponField.prototype.hasNativeFieldValue(self)
|
|
134
|
+
return true
|
|
135
|
+
end
|
|
136
|
+
__TS__SetDescriptor(
|
|
137
|
+
UnitWeaponField.prototype,
|
|
138
|
+
"instanceClass",
|
|
139
|
+
{get = function(self)
|
|
140
|
+
return Unit
|
|
141
|
+
end},
|
|
142
|
+
true
|
|
143
|
+
)
|
|
144
|
+
__TS__ObjectDefineProperty(
|
|
145
|
+
UnitWeaponField,
|
|
146
|
+
"valueChangeEvent",
|
|
147
|
+
{get = function(self)
|
|
148
|
+
return self:getOrCreateValueChangeEvent()
|
|
149
|
+
end}
|
|
150
|
+
)
|
|
151
|
+
____exports.UnitNumberWeaponField = __TS__Class()
|
|
152
|
+
local UnitNumberWeaponField = ____exports.UnitNumberWeaponField
|
|
153
|
+
UnitNumberWeaponField.name = "UnitNumberWeaponField"
|
|
154
|
+
__TS__ClassExtends(UnitNumberWeaponField, ____exports.UnitWeaponField)
|
|
155
|
+
__TS__SetDescriptor(
|
|
156
|
+
UnitNumberWeaponField.prototype,
|
|
157
|
+
"defaultValue",
|
|
158
|
+
{get = function(self)
|
|
159
|
+
return 0
|
|
160
|
+
end},
|
|
161
|
+
true
|
|
162
|
+
)
|
|
163
|
+
__TS__ObjectDefineProperty(
|
|
164
|
+
UnitNumberWeaponField,
|
|
165
|
+
"valueChangeEvent",
|
|
166
|
+
{get = function(self)
|
|
167
|
+
return self:getOrCreateValueChangeEvent()
|
|
168
|
+
end}
|
|
169
|
+
)
|
|
170
|
+
____exports.UnitEnumWeaponField = __TS__Class()
|
|
171
|
+
local UnitEnumWeaponField = ____exports.UnitEnumWeaponField
|
|
172
|
+
UnitEnumWeaponField.name = "UnitEnumWeaponField"
|
|
173
|
+
__TS__ClassExtends(UnitEnumWeaponField, ____exports.UnitWeaponField)
|
|
174
|
+
function UnitEnumWeaponField.prototype.getNativeFieldById(self, id)
|
|
175
|
+
return convertUnitWeaponIntegerField(id)
|
|
176
|
+
end
|
|
177
|
+
function UnitEnumWeaponField.prototype.getNativeFieldValue(self, instance, index)
|
|
178
|
+
local value = getUnitWeaponIntegerField(instance.handle, self.nativeField, index)
|
|
179
|
+
if self.values:contains(value) then
|
|
180
|
+
return value
|
|
181
|
+
end
|
|
182
|
+
return self.values:first()
|
|
183
|
+
end
|
|
184
|
+
function UnitEnumWeaponField.prototype.setNativeFieldValue(self, instance, index, value)
|
|
185
|
+
return setUnitWeaponIntegerField(instance.handle, self.nativeField, index, value)
|
|
186
|
+
end
|
|
187
|
+
__TS__SetDescriptor(
|
|
188
|
+
UnitEnumWeaponField.prototype,
|
|
189
|
+
"defaultValue",
|
|
190
|
+
{get = function(self)
|
|
191
|
+
return self.values:first()
|
|
192
|
+
end},
|
|
193
|
+
true
|
|
194
|
+
)
|
|
195
|
+
__TS__ObjectDefineProperty(
|
|
196
|
+
UnitEnumWeaponField,
|
|
197
|
+
"valueChangeEvent",
|
|
198
|
+
{get = function(self)
|
|
199
|
+
return self:getOrCreateValueChangeEvent()
|
|
200
|
+
end}
|
|
201
|
+
)
|
|
202
|
+
____exports.UnitAttackTypeWeaponField = __TS__Class()
|
|
203
|
+
local UnitAttackTypeWeaponField = ____exports.UnitAttackTypeWeaponField
|
|
204
|
+
UnitAttackTypeWeaponField.name = "UnitAttackTypeWeaponField"
|
|
205
|
+
__TS__ClassExtends(UnitAttackTypeWeaponField, ____exports.UnitEnumWeaponField)
|
|
206
|
+
function UnitAttackTypeWeaponField.prototype.____constructor(self, ...)
|
|
207
|
+
UnitAttackTypeWeaponField.____super.prototype.____constructor(self, ...)
|
|
208
|
+
self.values = nonEmptyLinkedSetOf(
|
|
209
|
+
1,
|
|
210
|
+
2,
|
|
211
|
+
3,
|
|
212
|
+
0,
|
|
213
|
+
5,
|
|
214
|
+
4,
|
|
215
|
+
6
|
|
216
|
+
)
|
|
217
|
+
end
|
|
52
218
|
return ____exports
|
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,7 +19,7 @@ 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
|
+
constructor(id: number, isGlobal?: boolean);
|
|
22
23
|
static create<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldConstructor<T>, id?: number): T & symbol;
|
|
23
24
|
static of<T extends ObjectFieldBase<any, any, any, any>>(this: ObjectFieldAbstractConstructor<T>, id: number): T | undefined;
|
|
24
25
|
}
|
|
@@ -35,14 +36,22 @@ export type ObjectFieldValueChangeEvent<T extends ObjectField<any, any, any, any
|
|
|
35
36
|
]> : never;
|
|
36
37
|
export type ReadonlyObjectFieldType<T extends ObjectField<any, any, any, any>> = Omit<T, "setValue" | "removeValue" | "trySetValue">;
|
|
37
38
|
type ReadonlyObjectFieldConstructor<T extends ObjectField> = OmitConstructor<typeof ObjectField> & (abstract new (...args: any[]) => ReadonlyObjectFieldType<T>);
|
|
39
|
+
type ObjectFieldModifier<InstanceType extends AnyNotNil, ValueType extends number | string | boolean> = (instance: InstanceType, currentValue: ValueType, originalValue: ValueType) => ValueType;
|
|
38
40
|
export declare abstract class ObjectField<ObjectDataEntryType extends ObjectDataEntry = ObjectDataEntry, InstanceType extends AnyNotNil = AnyNotNil, ValueType extends number | string | boolean = number | string | boolean, NativeFieldType = unknown> extends ObjectFieldBase<ObjectDataEntryType, InstanceType, ValueType, NativeFieldType> {
|
|
39
41
|
protected abstract readonly defaultValue: ValueType;
|
|
40
42
|
protected abstract getNativeFieldValue(instance: InstanceType): ValueType;
|
|
41
43
|
protected abstract setNativeFieldValue(instance: InstanceType, value: ValueType): boolean;
|
|
42
|
-
|
|
44
|
+
private originalValueByInstance?;
|
|
45
|
+
private modifiersByInstance?;
|
|
46
|
+
getValue(entry: ObjectDataEntryType | InstanceType, includeModifiers?: boolean): ValueType;
|
|
43
47
|
setValue(entry: ObjectDataEntryType | InstanceType, value: ValueType): boolean;
|
|
48
|
+
applyModifier(instance: InstanceType, modifier: ObjectFieldModifier<InstanceType, ValueType>): void;
|
|
49
|
+
removeModifier(instance: InstanceType, modifier: ObjectFieldModifier<InstanceType, ValueType>): boolean;
|
|
44
50
|
removeValue(entry: ObjectDataEntryType): boolean;
|
|
45
51
|
trySetValue(entry: ObjectDataEntryType | InstanceType, value: unknown): boolean;
|
|
52
|
+
private getActualValue;
|
|
53
|
+
private setActualValue;
|
|
54
|
+
private calculateActualValue;
|
|
46
55
|
private invokeValueChangeEvent;
|
|
47
56
|
private invokeValueChangeEventRecursive;
|
|
48
57
|
protected static getOrCreateValueChangeEvent<T extends ObjectField, R extends ReadonlyObjectFieldType<T>>(this: ReadonlyObjectFieldConstructor<T>): ObjectFieldValueChangeEvent<R>;
|