warscript 0.0.1-dev.5ca835c → 0.0.1-dev.5e33506

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.
@@ -124,6 +124,7 @@ function ObjectField.prototype.setValue(self, entry, value)
124
124
  defaultValueByObjectDataEntryId[entry.id] = value
125
125
  return true
126
126
  end
127
+ local previousOriginalValue
127
128
  local modifiersByInstance = self.modifiersByInstance
128
129
  if modifiersByInstance ~= nil then
129
130
  local modifiers = modifiersByInstance[entry]
@@ -133,11 +134,34 @@ function ObjectField.prototype.setValue(self, entry, value)
133
134
  originalValueByInstance = mutableWeakLuaMap()
134
135
  self.originalValueByInstance = originalValueByInstance
135
136
  end
137
+ previousOriginalValue = originalValueByInstance[entry]
138
+ if value == previousOriginalValue then
139
+ return true
140
+ end
136
141
  originalValueByInstance[entry] = value
137
142
  value = self:calculateActualValue(entry)
138
143
  end
139
144
  end
140
- return self:setActualValue(entry, value)
145
+ local previousValue = self:setActualValue(entry, value)
146
+ if previousValue == nil then
147
+ return false
148
+ end
149
+ if previousOriginalValue ~= nil or value ~= previousValue then
150
+ local ____self_invokeValueChangeEvent_2 = self.invokeValueChangeEvent
151
+ local ____entry_1 = entry
152
+ local ____previousOriginalValue_0 = previousOriginalValue
153
+ if ____previousOriginalValue_0 == nil then
154
+ ____previousOriginalValue_0 = previousValue
155
+ end
156
+ ____self_invokeValueChangeEvent_2(
157
+ self,
158
+ ____entry_1,
159
+ self,
160
+ ____previousOriginalValue_0,
161
+ value
162
+ )
163
+ end
164
+ return true
141
165
  end
142
166
  function ObjectField.prototype.applyModifier(self, instance, modifier)
143
167
  local modifiersByInstance = self.modifiersByInstance
@@ -151,13 +175,13 @@ function ObjectField.prototype.applyModifier(self, instance, modifier)
151
175
  originalValueByInstance = mutableWeakLuaMap()
152
176
  self.originalValueByInstance = originalValueByInstance
153
177
  end
154
- local ____originalValueByInstance_1 = originalValueByInstance
155
- local ____instance_2 = instance
156
- local ____originalValueByInstance_instance_0 = originalValueByInstance[instance]
157
- if ____originalValueByInstance_instance_0 == nil then
158
- ____originalValueByInstance_instance_0 = self:getActualValue(instance)
178
+ local ____originalValueByInstance_4 = originalValueByInstance
179
+ local ____instance_5 = instance
180
+ local ____originalValueByInstance_instance_3 = originalValueByInstance[instance]
181
+ if ____originalValueByInstance_instance_3 == nil then
182
+ ____originalValueByInstance_instance_3 = self:getActualValue(instance)
159
183
  end
160
- ____originalValueByInstance_1[____instance_2] = ____originalValueByInstance_instance_0
184
+ ____originalValueByInstance_4[____instance_5] = ____originalValueByInstance_instance_3
161
185
  self:setActualValue(
162
186
  instance,
163
187
  self:calculateActualValue(instance)
@@ -203,22 +227,22 @@ function ObjectField.prototype.getActualValue(self, instance)
203
227
  if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
204
228
  local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
205
229
  if defaultValue ~= nil or self.isGlobal then
206
- local ____self_valueByInstance_instance_3 = self.valueByInstance[instance]
207
- if ____self_valueByInstance_instance_3 == nil then
208
- ____self_valueByInstance_instance_3 = defaultValue
230
+ local ____self_valueByInstance_instance_6 = self.valueByInstance[instance]
231
+ if ____self_valueByInstance_instance_6 == nil then
232
+ ____self_valueByInstance_instance_6 = defaultValue
209
233
  end
210
- local ____self_valueByInstance_instance_3_4 = ____self_valueByInstance_instance_3
211
- if ____self_valueByInstance_instance_3_4 == nil then
212
- ____self_valueByInstance_instance_3_4 = self.defaultValue
234
+ local ____self_valueByInstance_instance_6_7 = ____self_valueByInstance_instance_6
235
+ if ____self_valueByInstance_instance_6_7 == nil then
236
+ ____self_valueByInstance_instance_6_7 = self.defaultValue
213
237
  end
214
- return ____self_valueByInstance_instance_3_4
238
+ return ____self_valueByInstance_instance_6_7
215
239
  end
216
240
  end
217
- local ____temp_5 = self:getNativeFieldValue(instance)
218
- if ____temp_5 == nil then
219
- ____temp_5 = self.defaultValue
241
+ local ____temp_8 = self:getNativeFieldValue(instance)
242
+ if ____temp_8 == nil then
243
+ ____temp_8 = self.defaultValue
220
244
  end
221
- return ____temp_5
245
+ return ____temp_8
222
246
  end
223
247
  function ObjectField.prototype.setActualValue(self, instance, value)
224
248
  local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
@@ -226,35 +250,33 @@ function ObjectField.prototype.setActualValue(self, instance, value)
226
250
  if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
227
251
  local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[objectDataEntryId]
228
252
  if defaultValue ~= nil or self.isGlobal then
229
- local ____self_valueByInstance_instance_6 = self.valueByInstance[instance]
230
- if ____self_valueByInstance_instance_6 == nil then
231
- ____self_valueByInstance_instance_6 = defaultValue
253
+ local ____self_valueByInstance_instance_9 = self.valueByInstance[instance]
254
+ if ____self_valueByInstance_instance_9 == nil then
255
+ ____self_valueByInstance_instance_9 = defaultValue
232
256
  end
233
- local ____self_valueByInstance_instance_6_7 = ____self_valueByInstance_instance_6
234
- if ____self_valueByInstance_instance_6_7 == nil then
235
- ____self_valueByInstance_instance_6_7 = self.defaultValue
257
+ local ____self_valueByInstance_instance_9_10 = ____self_valueByInstance_instance_9
258
+ if ____self_valueByInstance_instance_9_10 == nil then
259
+ ____self_valueByInstance_instance_9_10 = self.defaultValue
236
260
  end
237
- local previousValue = ____self_valueByInstance_instance_6_7
261
+ local previousValue = ____self_valueByInstance_instance_9_10
238
262
  self.valueByInstance[instance] = value
239
- self:invokeValueChangeEvent(instance, self, previousValue, value)
240
- return true
263
+ return previousValue
241
264
  end
242
265
  end
243
266
  if not self:hasNativeFieldValue(objectDataEntryId) then
244
- return false
267
+ return nil
245
268
  end
246
269
  local previousValue = self:getNativeFieldValue(instance)
247
270
  if value ~= previousValue and not self:setNativeFieldValue(instance, value) then
248
- return false
271
+ return nil
249
272
  end
250
- self:invokeValueChangeEvent(instance, self, previousValue, value)
251
- return true
273
+ return previousValue
252
274
  end
253
275
  function ObjectField.prototype.calculateActualValue(self, instance)
254
- local ____opt_8 = self.originalValueByInstance
255
- local originalValue = ____opt_8 and ____opt_8[instance]
256
- local ____opt_10 = self.modifiersByInstance
257
- local modifiers = ____opt_10 and ____opt_10[instance]
276
+ local ____opt_11 = self.originalValueByInstance
277
+ local originalValue = ____opt_11 and ____opt_11[instance]
278
+ local ____opt_13 = self.modifiersByInstance
279
+ local modifiers = ____opt_13 and ____opt_13[instance]
258
280
  if originalValue ~= nil then
259
281
  local value = originalValue
260
282
  if modifiers ~= nil then
@@ -319,17 +341,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
319
341
  if defaultValueByObjectDataEntryId ~= nil then
320
342
  local value = defaultValueByObjectDataEntryId[entry.id]
321
343
  if value ~= nil then
322
- local ____temp_13
344
+ local ____temp_16
323
345
  if index == nil then
324
- ____temp_13 = value
346
+ ____temp_16 = value
325
347
  else
326
- local ____value_index_12 = value[index + 1]
327
- if ____value_index_12 == nil then
328
- ____value_index_12 = self.defaultValue
348
+ local ____value_index_15 = value[index + 1]
349
+ if ____value_index_15 == nil then
350
+ ____value_index_15 = self.defaultValue
329
351
  end
330
- ____temp_13 = ____value_index_12
352
+ ____temp_16 = ____value_index_15
331
353
  end
332
- return ____temp_13
354
+ return ____temp_16
333
355
  end
334
356
  end
335
357
  return index == nil and ({}) or self.defaultValue
@@ -339,17 +361,17 @@ function ObjectArrayField.prototype.getValue(self, entry, index)
339
361
  local defaultValue = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(entry)]
340
362
  if defaultValue ~= nil or self.isGlobal then
341
363
  local value = self.valueByInstance[entry] or defaultValue or emptyArray()
342
- local ____temp_15
364
+ local ____temp_18
343
365
  if index == nil then
344
- ____temp_15 = value
366
+ ____temp_18 = value
345
367
  else
346
- local ____value_index_14 = value[index + 1]
347
- if ____value_index_14 == nil then
348
- ____value_index_14 = self.defaultValue
368
+ local ____value_index_17 = value[index + 1]
369
+ if ____value_index_17 == nil then
370
+ ____value_index_17 = self.defaultValue
349
371
  end
350
- ____temp_15 = ____value_index_14
372
+ ____temp_18 = ____value_index_17
351
373
  end
352
- return ____temp_15
374
+ return ____temp_18
353
375
  end
354
376
  end
355
377
  if index ~= nil then
@@ -394,18 +416,18 @@ function ObjectLevelField.prototype.getValue(self, entry, level)
394
416
  if defaultValueByObjectDataEntryId ~= nil then
395
417
  local valueByLevel = defaultValueByObjectDataEntryId[entry.id]
396
418
  if valueByLevel ~= nil then
397
- local ____valueByLevel_index_16 = valueByLevel[level + 1]
398
- if ____valueByLevel_index_16 == nil then
399
- ____valueByLevel_index_16 = self.defaultValue
419
+ local ____valueByLevel_index_19 = valueByLevel[level + 1]
420
+ if ____valueByLevel_index_19 == nil then
421
+ ____valueByLevel_index_19 = self.defaultValue
400
422
  end
401
- return ____valueByLevel_index_16
423
+ return ____valueByLevel_index_19
402
424
  end
403
425
  end
404
426
  return self.defaultValue
405
427
  end
406
- local ____opt_19 = self.originalValueByLevelByInstance
407
- local ____opt_17 = ____opt_19 and ____opt_19[entry]
408
- local originalValue = ____opt_17 and ____opt_17[level]
428
+ local ____opt_22 = self.originalValueByLevelByInstance
429
+ local ____opt_20 = ____opt_22 and ____opt_22[entry]
430
+ local originalValue = ____opt_20 and ____opt_20[level]
409
431
  if originalValue ~= nil then
410
432
  return originalValue
411
433
  end
@@ -449,6 +471,7 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
449
471
  valueByLevel[level + 1] = value
450
472
  return true
451
473
  end
474
+ local previousOriginalValue
452
475
  local modifiersByInstance = self.modifiersByInstance
453
476
  if modifiersByInstance ~= nil then
454
477
  local modifiers = modifiersByInstance[entry]
@@ -458,11 +481,36 @@ function ObjectLevelField.prototype.setValue(self, entry, levelOrValue, value)
458
481
  originalValueByLevelByInstance = mutableWeakLuaMap()
459
482
  self.originalValueByLevelByInstance = originalValueByLevelByInstance
460
483
  end
461
- getOrPut(originalValueByLevelByInstance, entry, mutableLuaMap)[level] = value
484
+ local originalValueByLevel = getOrPut(originalValueByLevelByInstance, entry, mutableLuaMap)
485
+ previousOriginalValue = originalValueByLevel[level]
486
+ if value == previousOriginalValue then
487
+ return true
488
+ end
489
+ originalValueByLevel[level] = value
462
490
  value = self:calculateActualValue(entry, level)
463
491
  end
464
492
  end
465
- return self:setActualValue(entry, level, value)
493
+ local previousValue = self:setActualValue(entry, level, value)
494
+ if previousValue == nil then
495
+ return false
496
+ end
497
+ if previousOriginalValue ~= nil or value ~= previousValue then
498
+ local ____self_invokeValueChangeEvent_26 = self.invokeValueChangeEvent
499
+ local ____entry_25 = entry
500
+ local ____previousOriginalValue_24 = previousOriginalValue
501
+ if ____previousOriginalValue_24 == nil then
502
+ ____previousOriginalValue_24 = previousValue
503
+ end
504
+ ____self_invokeValueChangeEvent_26(
505
+ self,
506
+ ____entry_25,
507
+ self,
508
+ level,
509
+ ____previousOriginalValue_24,
510
+ value
511
+ )
512
+ end
513
+ return true
466
514
  end
467
515
  function ObjectLevelField.prototype.applyModifier(self, instance, modifier)
468
516
  local modifiersByInstance = self.modifiersByInstance
@@ -479,11 +527,11 @@ function ObjectLevelField.prototype.applyModifier(self, instance, modifier)
479
527
  local originalValueByLevel = getOrPut(originalValueByLevelByInstance, instance, mutableLuaMap)
480
528
  local levelCount = self:getLevelCount(instance)
481
529
  for level = 0, levelCount - 1 do
482
- local ____originalValueByLevel_level_21 = originalValueByLevel[level]
483
- if ____originalValueByLevel_level_21 == nil then
484
- ____originalValueByLevel_level_21 = self:getActualValue(instance, level)
530
+ local ____originalValueByLevel_level_27 = originalValueByLevel[level]
531
+ if ____originalValueByLevel_level_27 == nil then
532
+ ____originalValueByLevel_level_27 = self:getActualValue(instance, level)
485
533
  end
486
- originalValueByLevel[level] = ____originalValueByLevel_level_21
534
+ originalValueByLevel[level] = ____originalValueByLevel_level_27
487
535
  self:setActualValue(
488
536
  instance,
489
537
  level,
@@ -530,23 +578,23 @@ function ObjectLevelField.prototype.getActualValue(self, instance, level)
530
578
  if defaultValueByObjectDataEntryId ~= nil or self.isGlobal then
531
579
  local defaultValueByLevel = (defaultValueByObjectDataEntryId or emptyLuaMap())[self:getObjectDataEntryId(instance)]
532
580
  if defaultValueByLevel ~= nil or self.isGlobal then
533
- local ____opt_22 = self.valueByInstance[instance]
534
- local ____temp_24 = ____opt_22 and ____opt_22[level + 1]
535
- if ____temp_24 == nil then
536
- ____temp_24 = (defaultValueByLevel or emptyArray())[level + 1]
581
+ local ____opt_28 = self.valueByInstance[instance]
582
+ local ____temp_30 = ____opt_28 and ____opt_28[level + 1]
583
+ if ____temp_30 == nil then
584
+ ____temp_30 = (defaultValueByLevel or emptyArray())[level + 1]
537
585
  end
538
- local ____temp_24_25 = ____temp_24
539
- if ____temp_24_25 == nil then
540
- ____temp_24_25 = self.defaultValue
586
+ local ____temp_30_31 = ____temp_30
587
+ if ____temp_30_31 == nil then
588
+ ____temp_30_31 = self.defaultValue
541
589
  end
542
- return ____temp_24_25
590
+ return ____temp_30_31
543
591
  end
544
592
  end
545
- local ____temp_26 = self:getNativeFieldValue(instance, level)
546
- if ____temp_26 == nil then
547
- ____temp_26 = self.defaultValue
593
+ local ____temp_32 = self:getNativeFieldValue(instance, level)
594
+ if ____temp_32 == nil then
595
+ ____temp_32 = self.defaultValue
548
596
  end
549
- return ____temp_26
597
+ return ____temp_32
550
598
  end
551
599
  function ObjectLevelField.prototype.setActualValue(self, instance, level, value)
552
600
  local defaultValueByObjectDataEntryId = defaultValueByObjectDataEntryIdByObjectFieldId[self.id]
@@ -559,48 +607,34 @@ function ObjectLevelField.prototype.setActualValue(self, instance, level, value)
559
607
  valueByLevel = {}
560
608
  self.valueByInstance[instance] = valueByLevel
561
609
  end
562
- local ____valueByLevel_index_27 = valueByLevel[level + 1]
563
- if ____valueByLevel_index_27 == nil then
564
- ____valueByLevel_index_27 = (defaultValueByLevel or emptyArray())[level + 1]
610
+ local ____valueByLevel_index_33 = valueByLevel[level + 1]
611
+ if ____valueByLevel_index_33 == nil then
612
+ ____valueByLevel_index_33 = (defaultValueByLevel or emptyArray())[level + 1]
565
613
  end
566
- local ____valueByLevel_index_27_28 = ____valueByLevel_index_27
567
- if ____valueByLevel_index_27_28 == nil then
568
- ____valueByLevel_index_27_28 = self.defaultValue
614
+ local ____valueByLevel_index_33_34 = ____valueByLevel_index_33
615
+ if ____valueByLevel_index_33_34 == nil then
616
+ ____valueByLevel_index_33_34 = self.defaultValue
569
617
  end
570
- local previousValue = ____valueByLevel_index_27_28
618
+ local previousValue = ____valueByLevel_index_33_34
571
619
  valueByLevel[level + 1] = value
572
- self:invokeValueChangeEvent(
573
- instance,
574
- self,
575
- level,
576
- previousValue,
577
- value
578
- )
579
- return true
620
+ return previousValue
580
621
  end
581
622
  end
582
623
  if not self:hasNativeFieldValue(objectDataEntryId) then
583
- return false
624
+ return nil
584
625
  end
585
626
  local previousValue = self:getNativeFieldValue(instance, level)
586
627
  if value ~= previousValue and not self:setNativeFieldValue(instance, level, value) then
587
- return false
628
+ return nil
588
629
  end
589
- self:invokeValueChangeEvent(
590
- instance,
591
- self,
592
- level,
593
- previousValue,
594
- value
595
- )
596
- return true
630
+ return previousValue
597
631
  end
598
632
  function ObjectLevelField.prototype.calculateActualValue(self, instance, level)
599
- local ____opt_31 = self.originalValueByLevelByInstance
600
- local ____opt_29 = ____opt_31 and ____opt_31[instance]
601
- local originalValue = ____opt_29 and ____opt_29[level]
602
- local ____opt_33 = self.modifiersByInstance
603
- local modifiers = ____opt_33 and ____opt_33[instance]
633
+ local ____opt_37 = self.originalValueByLevelByInstance
634
+ local ____opt_35 = ____opt_37 and ____opt_37[instance]
635
+ local originalValue = ____opt_35 and ____opt_35[level]
636
+ local ____opt_39 = self.modifiersByInstance
637
+ local modifiers = ____opt_39 and ____opt_39[instance]
604
638
  if originalValue ~= nil then
605
639
  local value = originalValue
606
640
  if modifiers ~= nil then
@@ -376,8 +376,8 @@ export declare const INVISIBILITY_TRANSITION_TIME_ABILITY_FLOAT_LEVEL_FIELD: Abi
376
376
  export declare const ACTIVATION_RADIUS_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
377
377
  export declare const AMOUNT_REGENERATED_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
378
378
  export declare const DAMAGE_PER_SECOND_POI1_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
379
- export declare const ATTACK_SPEED_FACTOR_POI2_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
380
- export declare const MOVEMENT_SPEED_FACTOR_POI3_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
379
+ export declare const MOVEMENT_SPEED_FACTOR_POI2_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
380
+ export declare const ATTACK_SPEED_FACTOR_POI3_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
381
381
  export declare const EXTRA_DAMAGE_POA1_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
382
382
  export declare const DAMAGE_PER_SECOND_POA2_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
383
383
  export declare const ATTACK_SPEED_FACTOR_POA3_ABILITY_FLOAT_LEVEL_FIELD: AbilityFloatLevelField & symbol;
@@ -387,8 +387,8 @@ ____exports.INVISIBILITY_TRANSITION_TIME_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloa
387
387
  ____exports.ACTIVATION_RADIUS_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Neu1"))
388
388
  ____exports.AMOUNT_REGENERATED_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Arm1"))
389
389
  ____exports.DAMAGE_PER_SECOND_POI1_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poi1"))
390
- ____exports.ATTACK_SPEED_FACTOR_POI2_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poi2"))
391
- ____exports.MOVEMENT_SPEED_FACTOR_POI3_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poi3"))
390
+ ____exports.MOVEMENT_SPEED_FACTOR_POI2_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poi2"))
391
+ ____exports.ATTACK_SPEED_FACTOR_POI3_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poi3"))
392
392
  ____exports.EXTRA_DAMAGE_POA1_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poa1"))
393
393
  ____exports.DAMAGE_PER_SECOND_POA2_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poa2"))
394
394
  ____exports.ATTACK_SPEED_FACTOR_POA3_ABILITY_FLOAT_LEVEL_FIELD = AbilityFloatLevelField:create(fourCC("Poa3"))
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.5ca835c",
4
+ "version": "0.0.1-dev.5e33506",
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.251db08"
27
+ "warpack": "0.0.1-dev.efd0770"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@typescript-eslint/eslint-plugin": "^8.13.0",