warscript 0.0.1-dev.2bde093 → 0.0.1-dev.2cd2e68
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/core/types/order.d.ts +1 -0
- package/core/types/order.lua +11 -1
- package/engine/behaviour/ability/damage.d.ts +2 -1
- package/engine/behaviour/ability/damage.lua +21 -36
- package/engine/behaviour/ability/emulate-impact.lua +9 -2
- package/engine/behaviour/ability.lua +1 -1
- package/engine/behaviour/unit.d.ts +15 -0
- package/engine/behaviour/unit.lua +114 -4
- package/engine/internal/ability.d.ts +4 -0
- package/engine/internal/ability.lua +17 -0
- package/engine/internal/item/ability.lua +12 -10
- package/engine/internal/item.d.ts +3 -1
- package/engine/internal/item.lua +75 -3
- package/engine/internal/unit/ability.d.ts +5 -0
- package/engine/internal/unit/ability.lua +14 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit-missile-launch.lua +1 -1
- package/engine/internal/unit.d.ts +10 -2
- package/engine/internal/unit.lua +91 -8
- 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-field.d.ts +4 -3
- package/engine/object-field.lua +72 -61
- package/package.json +1 -1
package/engine/object-field.lua
CHANGED
|
@@ -25,6 +25,8 @@ local mutableLinkedSet = ____linked_2Dset.mutableLinkedSet
|
|
|
25
25
|
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
26
26
|
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
27
27
|
local mutableWeakLuaMap = ____lua_2Dmaps.mutableWeakLuaMap
|
|
28
|
+
local ____arrays = require("utility.arrays")
|
|
29
|
+
local emptyArray = ____arrays.emptyArray
|
|
28
30
|
local compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId = {}
|
|
29
31
|
local defaultValueByObjectDataEntryIdByObjectFieldId = postcompile(function() return compiletimeDefaultValueByObjectDataEntryIdByObjectFieldId end)
|
|
30
32
|
local objectFieldById = {}
|
|
@@ -34,7 +36,11 @@ local idGenerator = __TS__New(
|
|
|
34
36
|
)
|
|
35
37
|
local ObjectFieldBase = __TS__Class()
|
|
36
38
|
ObjectFieldBase.name = "ObjectFieldBase"
|
|
37
|
-
function ObjectFieldBase.prototype.____constructor(self, id)
|
|
39
|
+
function ObjectFieldBase.prototype.____constructor(self, id, isGlobal)
|
|
40
|
+
if isGlobal == nil then
|
|
41
|
+
isGlobal = true
|
|
42
|
+
end
|
|
43
|
+
self.isGlobal = isGlobal
|
|
38
44
|
self.valueByInstance = setmetatable({}, {__mode = "k"})
|
|
39
45
|
if objectFieldById[id] ~= nil then
|
|
40
46
|
error(
|
|
@@ -53,12 +59,13 @@ function ObjectFieldBase.prototype.supports(self, instance)
|
|
|
53
59
|
end
|
|
54
60
|
function ObjectFieldBase.prototype.hasValue(self, instance)
|
|
55
61
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
56
|
-
return defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
62
|
+
return self.isGlobal or defaultValueByObjectDataEntryId ~= nil and defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)] ~= nil or self:hasNativeFieldValue(instance)
|
|
57
63
|
end
|
|
58
|
-
function ObjectFieldBase.create(self, id)
|
|
64
|
+
function ObjectFieldBase.create(self, id, isGlobal)
|
|
59
65
|
return __TS__New(
|
|
60
66
|
self,
|
|
61
|
-
id or idGenerator:next()
|
|
67
|
+
id or idGenerator:next(),
|
|
68
|
+
isGlobal
|
|
62
69
|
)
|
|
63
70
|
end
|
|
64
71
|
function ObjectFieldBase.of(self, id)
|
|
@@ -187,34 +194,38 @@ function ObjectField.prototype.getActualValue(self, instance)
|
|
|
187
194
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
188
195
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
189
196
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
190
|
-
if defaultValue ~= nil then
|
|
197
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
191
198
|
local ____self_valueByInstance_instance_0 = self.valueByInstance[instance]
|
|
192
199
|
if ____self_valueByInstance_instance_0 == nil then
|
|
193
200
|
____self_valueByInstance_instance_0 = defaultValue
|
|
194
201
|
end
|
|
195
|
-
|
|
202
|
+
local ____self_valueByInstance_instance_0_1 = ____self_valueByInstance_instance_0
|
|
203
|
+
if ____self_valueByInstance_instance_0_1 == nil then
|
|
204
|
+
____self_valueByInstance_instance_0_1 = self.defaultValue
|
|
205
|
+
end
|
|
206
|
+
return ____self_valueByInstance_instance_0_1
|
|
196
207
|
end
|
|
197
208
|
end
|
|
198
|
-
local
|
|
199
|
-
if
|
|
200
|
-
|
|
209
|
+
local ____temp_2 = self:getNativeFieldValue(instance)
|
|
210
|
+
if ____temp_2 == nil then
|
|
211
|
+
____temp_2 = self.defaultValue
|
|
201
212
|
end
|
|
202
|
-
return
|
|
213
|
+
return ____temp_2
|
|
203
214
|
end
|
|
204
215
|
function ObjectField.prototype.setActualValue(self, instance, value)
|
|
205
216
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
206
217
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
207
218
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(instance)]
|
|
208
|
-
if defaultValue ~= nil then
|
|
209
|
-
local
|
|
210
|
-
if
|
|
211
|
-
|
|
219
|
+
if defaultValue ~= nil or self.isGlobal then
|
|
220
|
+
local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
|
|
221
|
+
if ____self_valueByInstance_instance_3 == nil then
|
|
222
|
+
____self_valueByInstance_instance_3 = defaultValue
|
|
212
223
|
end
|
|
213
|
-
local
|
|
214
|
-
if
|
|
215
|
-
|
|
224
|
+
local ____self_valueByInstance_instance_3_4 = ____self_valueByInstance_instance_3
|
|
225
|
+
if ____self_valueByInstance_instance_3_4 == nil then
|
|
226
|
+
____self_valueByInstance_instance_3_4 = self.defaultValue
|
|
216
227
|
end
|
|
217
|
-
local previousValue =
|
|
228
|
+
local previousValue = ____self_valueByInstance_instance_3_4
|
|
218
229
|
if value ~= previousValue then
|
|
219
230
|
self.valueByInstance[instance] = value
|
|
220
231
|
self:invokeValueChangeEvent(instance, self, previousValue, value)
|
|
@@ -235,10 +246,10 @@ function ObjectField.prototype.setActualValue(self, instance, value)
|
|
|
235
246
|
return true
|
|
236
247
|
end
|
|
237
248
|
function ObjectField.prototype.calculateActualValue(self, instance)
|
|
238
|
-
local
|
|
239
|
-
local originalValue =
|
|
240
|
-
local
|
|
241
|
-
local modifiers =
|
|
249
|
+
local ____opt_5 = self.originalValueByInstance
|
|
250
|
+
local originalValue = ____opt_5 and ____opt_5[instance]
|
|
251
|
+
local ____opt_7 = self.modifiersByInstance
|
|
252
|
+
local modifiers = ____opt_7 and ____opt_7[instance]
|
|
242
253
|
if originalValue ~= nil then
|
|
243
254
|
local value = originalValue
|
|
244
255
|
if modifiers ~= nil then
|
|
@@ -303,17 +314,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
303
314
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
304
315
|
local value = defaultValueByObjectDataEntryId[entry.id]
|
|
305
316
|
if value ~= nil then
|
|
306
|
-
local
|
|
317
|
+
local ____temp_10
|
|
307
318
|
if index == nil then
|
|
308
|
-
|
|
319
|
+
____temp_10 = value
|
|
309
320
|
else
|
|
310
|
-
local
|
|
311
|
-
if
|
|
312
|
-
|
|
321
|
+
local ____value_index_9 = value[index + 1]
|
|
322
|
+
if ____value_index_9 == nil then
|
|
323
|
+
____value_index_9 = self.defaultValue
|
|
313
324
|
end
|
|
314
|
-
|
|
325
|
+
____temp_10 = ____value_index_9
|
|
315
326
|
end
|
|
316
|
-
return
|
|
327
|
+
return ____temp_10
|
|
317
328
|
end
|
|
318
329
|
end
|
|
319
330
|
return index == nil and ({}) or self.defaultValue
|
|
@@ -323,17 +334,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
|
|
|
323
334
|
local defaultValue = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
324
335
|
if defaultValue ~= nil then
|
|
325
336
|
local value = self.valueByInstance[entry] or defaultValue
|
|
326
|
-
local
|
|
337
|
+
local ____temp_12
|
|
327
338
|
if index == nil then
|
|
328
|
-
|
|
339
|
+
____temp_12 = value
|
|
329
340
|
else
|
|
330
|
-
local
|
|
331
|
-
if
|
|
332
|
-
|
|
341
|
+
local ____value_index_11 = value[index + 1]
|
|
342
|
+
if ____value_index_11 == nil then
|
|
343
|
+
____value_index_11 = self.defaultValue
|
|
333
344
|
end
|
|
334
|
-
|
|
345
|
+
____temp_12 = ____value_index_11
|
|
335
346
|
end
|
|
336
|
-
return
|
|
347
|
+
return ____temp_12
|
|
337
348
|
end
|
|
338
349
|
end
|
|
339
350
|
if index ~= nil then
|
|
@@ -378,11 +389,11 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
378
389
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
379
390
|
local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
|
|
380
391
|
if valueByLevel ~= nil then
|
|
381
|
-
local
|
|
382
|
-
if
|
|
383
|
-
|
|
392
|
+
local ____valueByLevel_index_13 = valueByLevel[level + 1]
|
|
393
|
+
if ____valueByLevel_index_13 == nil then
|
|
394
|
+
____valueByLevel_index_13 = self.defaultValue
|
|
384
395
|
end
|
|
385
|
-
return
|
|
396
|
+
return ____valueByLevel_index_13
|
|
386
397
|
end
|
|
387
398
|
end
|
|
388
399
|
return self.defaultValue
|
|
@@ -390,24 +401,24 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
|
|
|
390
401
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
391
402
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
392
403
|
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
393
|
-
if defaultValueByLevel ~= nil then
|
|
394
|
-
local
|
|
395
|
-
local
|
|
396
|
-
if
|
|
397
|
-
|
|
404
|
+
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
405
|
+
local ____opt_14 = self.valueByInstance[entry]
|
|
406
|
+
local ____temp_16 = ____opt_14 and ____opt_14[level + 1]
|
|
407
|
+
if ____temp_16 == nil then
|
|
408
|
+
____temp_16 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
398
409
|
end
|
|
399
|
-
local
|
|
400
|
-
if
|
|
401
|
-
|
|
410
|
+
local ____temp_16_17 = ____temp_16
|
|
411
|
+
if ____temp_16_17 == nil then
|
|
412
|
+
____temp_16_17 = self.defaultValue
|
|
402
413
|
end
|
|
403
|
-
return
|
|
414
|
+
return ____temp_16_17
|
|
404
415
|
end
|
|
405
416
|
end
|
|
406
|
-
local
|
|
407
|
-
if
|
|
408
|
-
|
|
417
|
+
local ____temp_18 = self:getNativeFieldValue(entry, level)
|
|
418
|
+
if ____temp_18 == nil then
|
|
419
|
+
____temp_18 = self.defaultValue
|
|
409
420
|
end
|
|
410
|
-
return
|
|
421
|
+
return ____temp_18
|
|
411
422
|
end
|
|
412
423
|
function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
413
424
|
if value == nil then
|
|
@@ -450,21 +461,21 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
|
|
|
450
461
|
local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
|
|
451
462
|
if defaultValueByObjectDataEntryId ~= nil then
|
|
452
463
|
local defaultValueByLevel = defaultValueByObjectDataEntryId[self:getObjectDataEntryId(entry)]
|
|
453
|
-
if defaultValueByLevel ~= nil then
|
|
464
|
+
if defaultValueByLevel ~= nil or self.isGlobal then
|
|
454
465
|
local valueByLevel = self.valueByInstance[entry]
|
|
455
466
|
if valueByLevel == nil then
|
|
456
467
|
valueByLevel = {}
|
|
457
468
|
self.valueByInstance[entry] = valueByLevel
|
|
458
469
|
end
|
|
459
|
-
local
|
|
460
|
-
if
|
|
461
|
-
|
|
470
|
+
local ____valueByLevel_index_19 = valueByLevel[level + 1]
|
|
471
|
+
if ____valueByLevel_index_19 == nil then
|
|
472
|
+
____valueByLevel_index_19 = (defaultValueByLevel or emptyArray())[level + 1]
|
|
462
473
|
end
|
|
463
|
-
local
|
|
464
|
-
if
|
|
465
|
-
|
|
474
|
+
local ____valueByLevel_index_19_20 = ____valueByLevel_index_19
|
|
475
|
+
if ____valueByLevel_index_19_20 == nil then
|
|
476
|
+
____valueByLevel_index_19_20 = self.defaultValue
|
|
466
477
|
end
|
|
467
|
-
local previousValue =
|
|
478
|
+
local previousValue = ____valueByLevel_index_19_20
|
|
468
479
|
if value ~= previousValue then
|
|
469
480
|
valueByLevel[level + 1] = value
|
|
470
481
|
self:invokeValueChangeEvent(
|
package/package.json
CHANGED