warscript 0.0.1-dev.effa673 → 0.0.1-dev.f26a113

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.
Files changed (62) hide show
  1. package/attributes.d.ts +5 -0
  2. package/attributes.lua +8 -1
  3. package/core/types/order.d.ts +1 -0
  4. package/core/types/order.lua +11 -1
  5. package/core/types/sound.lua +5 -0
  6. package/core/types/timer.d.ts +6 -7
  7. package/core/types/timer.lua +18 -21
  8. package/decl/native.d.ts +840 -786
  9. package/engine/behaviour/ability/damage.d.ts +6 -3
  10. package/engine/behaviour/ability/damage.lua +24 -36
  11. package/engine/behaviour/ability/emulate-impact.lua +7 -0
  12. package/engine/behaviour/unit.d.ts +6 -0
  13. package/engine/behaviour/unit.lua +64 -0
  14. package/engine/internal/ability.d.ts +2 -0
  15. package/engine/internal/ability.lua +7 -0
  16. package/engine/internal/item.d.ts +2 -1
  17. package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
  18. package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
  19. package/engine/internal/unit+damage.d.ts +2 -11
  20. package/engine/internal/unit+damage.lua +10 -14
  21. package/engine/internal/unit+spellSteal.lua +1 -2
  22. package/engine/internal/unit.d.ts +16 -3
  23. package/engine/internal/unit.lua +126 -37
  24. package/engine/object-data/auxiliary/attachment-preset.d.ts +1 -1
  25. package/engine/object-data/auxiliary/attachment-preset.lua +3 -2
  26. package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
  27. package/engine/object-data/auxiliary/attack-type.lua +42 -0
  28. package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
  29. package/engine/object-data/auxiliary/movement-type.lua +22 -0
  30. package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
  31. package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
  32. package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
  33. package/engine/object-data/entry/ability-type/berserk.lua +13 -0
  34. package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
  35. package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
  36. package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
  37. package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
  38. package/engine/object-data/entry/ability-type.lua +7 -0
  39. package/engine/object-data/entry/buff-type/applicable.lua +5 -0
  40. package/engine/object-data/entry/buff-type.d.ts +5 -11
  41. package/engine/object-data/entry/buff-type.lua +11 -27
  42. package/engine/object-data/entry/unit-type.d.ts +2 -2
  43. package/engine/object-data/entry/unit-type.lua +94 -84
  44. package/engine/object-field/ability.d.ts +1 -1
  45. package/engine/object-field/unit.d.ts +46 -3
  46. package/engine/object-field/unit.lua +173 -7
  47. package/engine/object-field.d.ts +9 -1
  48. package/engine/object-field.lua +158 -76
  49. package/engine/standard/entries/buff-type.d.ts +3 -0
  50. package/engine/standard/entries/buff-type.lua +3 -0
  51. package/objutil/buff.lua +1 -2
  52. package/package.json +2 -2
  53. package/utility/arrays.d.ts +1 -0
  54. package/utility/arrays.lua +3 -0
  55. package/utility/functions.d.ts +1 -0
  56. package/utility/functions.lua +1 -0
  57. package/utility/linked-set.d.ts +1 -0
  58. package/utility/linked-set.lua +3 -0
  59. package/utility/lua-maps.d.ts +3 -0
  60. package/utility/lua-maps.lua +16 -0
  61. package/utility/lua-sets.d.ts +1 -0
  62. package/utility/lua-sets.lua +3 -0
package/attributes.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  /** @noSelfInFile */
2
+ declare const marker: {};
2
3
  export type Attribute<T> = {
3
4
  readonly __attribute: unique symbol;
4
5
  readonly __type: T;
6
+ readonly __marker: typeof marker;
5
7
  } & symbol;
8
+ export declare const attribute: <T>() => Attribute<T>;
9
+ export declare const isAttribute: (value: unknown) => value is Attribute<unknown>;
6
10
  export declare namespace Attribute {
7
11
  const create: <T>() => Attribute<T>;
8
12
  }
@@ -10,3 +14,4 @@ export declare class AttributesHolder {
10
14
  readonly get: (<T>(attribute: Attribute<T>) => T | undefined) & LuaExtension<"TableGetMethod">;
11
15
  readonly set: (<T>(attribute: Attribute<T>, value: T | undefined) => void) & LuaExtension<"TableSetMethod">;
12
16
  }
17
+ export {};
package/attributes.lua CHANGED
@@ -1,11 +1,18 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__Class = ____lualib.__TS__Class
3
3
  local ____exports = {}
4
+ local marker = {}
5
+ ____exports.attribute = function()
6
+ return {__marker = marker}
7
+ end
8
+ ____exports.isAttribute = function(value)
9
+ return type(value) == "table" and rawget(value, "__marker") == marker
10
+ end
4
11
  ____exports.Attribute = {}
5
12
  local Attribute = ____exports.Attribute
6
13
  do
7
14
  Attribute.create = function()
8
- return {}
15
+ return {__marker = marker}
9
16
  end
10
17
  end
11
18
  ____exports.AttributesHolder = __TS__Class()
@@ -6,6 +6,7 @@ export type Order = {
6
6
  id: number;
7
7
  startX: number;
8
8
  startY: number;
9
+ issueTime: number;
9
10
  } & ({
10
11
  type: "immediate";
11
12
  } | {
@@ -3,16 +3,25 @@ local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
3
  local ____exports = {}
4
4
  local ____unit = require("core.types.unit")
5
5
  local Unit = ____unit.Unit
6
+ local ____game = require("core.game")
7
+ local elapsedTime = ____game.elapsedTime
6
8
  local getUnitCurrentOrder = GetUnitCurrentOrder
7
9
  local orders = setmetatable({}, {__mode = "k"})
8
10
  Unit.onImmediateOrder:addListener(function(unit, orderId)
9
- orders[unit] = {id = orderId, startX = unit.x, startY = unit.y, type = "immediate"}
11
+ orders[unit] = {
12
+ id = orderId,
13
+ startX = unit.x,
14
+ startY = unit.y,
15
+ issueTime = elapsedTime(),
16
+ type = "immediate"
17
+ }
10
18
  end)
11
19
  Unit.onPointOrder:addListener(function(unit, orderId, x, y)
12
20
  orders[unit] = {
13
21
  id = orderId,
14
22
  startX = unit.x,
15
23
  startY = unit.y,
24
+ issueTime = elapsedTime(),
16
25
  type = "point",
17
26
  targetX = x,
18
27
  targetY = y
@@ -23,6 +32,7 @@ Unit.onTargetOrder:addListener(function(unit, orderId, target)
23
32
  id = orderId,
24
33
  startX = unit.x,
25
34
  startY = unit.y,
35
+ issueTime = elapsedTime(),
26
36
  type = "target",
27
37
  target = target
28
38
  }
@@ -121,6 +121,11 @@ local customSoundPresetDataByLabel = postcompile(function()
121
121
  end
122
122
  return customSoundPresetDataByLabel
123
123
  end)
124
+ ---
125
+ -- @internal For use by internal systems only.
126
+ ____exports.isSoundLabelCustom = function(label)
127
+ return customSoundPresetDataByLabel[label] ~= nil
128
+ end
124
129
  local function createPresetSound(fileName, preset)
125
130
  local ____fileName_1 = fileName
126
131
  local ____preset_looping_0 = preset.looping
@@ -1,27 +1,26 @@
1
1
  /** @noSelfInFile */
2
2
  import { Event } from "../../event";
3
+ import { AbstractDestroyable, Destructor } from "../../destroyable";
3
4
  declare const enum TimerPropertyKey {
4
5
  HANDLE = 0,
5
- DESTROYED = 1,
6
- DESTROY_ON_EXPIRATION = 2,
7
- CALLBACK = 3,
8
- ARGS_LENGTH = 4
6
+ DESTROY_ON_EXPIRATION = 1,
7
+ CALLBACK = 2,
8
+ ARGS_LENGTH = 3
9
9
  }
10
- export declare class Timer implements Destroyable {
10
+ export declare class Timer extends AbstractDestroyable {
11
11
  private readonly [TimerPropertyKey.HANDLE];
12
- private [TimerPropertyKey.DESTROYED]?;
13
12
  private [TimerPropertyKey.DESTROY_ON_EXPIRATION]?;
14
13
  private [TimerPropertyKey.CALLBACK]?;
15
14
  private [TimerPropertyKey.ARGS_LENGTH]?;
16
15
  private constructor();
17
16
  get handle(): jtimer;
18
17
  start<Args extends any[]>(timeout: number, periodic: boolean, callback: (...args: Args) => void, ...args: Args): void;
18
+ onDestroy(): Destructor;
19
19
  get elapsed(): number;
20
20
  get remaining(): number;
21
21
  get timeout(): number;
22
22
  pause(): void;
23
23
  resume(): void;
24
- destroy(): void;
25
24
  static create(): Timer;
26
25
  static run<Args extends any[]>(callback: (...args: Args) => void, ...args: Args): void;
27
26
  static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
@@ -1,6 +1,7 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local __TS__New = ____lualib.__TS__New
3
3
  local __TS__Class = ____lualib.__TS__Class
4
+ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
5
  local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
6
  local __TS__Promise = ____lualib.__TS__Promise
6
7
  local ____exports = {}
@@ -9,8 +10,8 @@ local Event = ____event.Event
9
10
  local InitializingEvent = ____event.InitializingEvent
10
11
  local ____objectPool = require("util.objectPool")
11
12
  local ObjectPool = ____objectPool.ObjectPool
12
- local ____exception = require("exception")
13
- local IllegalStateException = ____exception.IllegalStateException
13
+ local ____destroyable = require("destroyable")
14
+ local AbstractDestroyable = ____destroyable.AbstractDestroyable
14
15
  local createTimer = CreateTimer
15
16
  local timerStart = TimerStart
16
17
  local pauseTimer = PauseTimer
@@ -35,14 +36,14 @@ local timerByHandleId = {}
35
36
  local function timerSafeCall()
36
37
  local timer = timerByHandleId[getHandleId(getExpiredTimer())]
37
38
  if timer ~= nil then
38
- if timer[2] then
39
+ if timer[1] then
39
40
  timer:destroy()
40
41
  end
41
- local callback = timer[3]
42
+ local callback = timer[2]
42
43
  if callback ~= nil then
43
44
  safeCall(
44
45
  callback,
45
- ____unpack(timer, 4 + 1, 4 + (timer[4] or 0))
46
+ ____unpack(timer, 3 + 1, 3 + (timer[3] or 0))
46
47
  )
47
48
  end
48
49
  end
@@ -50,37 +51,33 @@ end
50
51
  ____exports.Timer = __TS__Class()
51
52
  local Timer = ____exports.Timer
52
53
  Timer.name = "Timer"
54
+ __TS__ClassExtends(Timer, AbstractDestroyable)
53
55
  function Timer.prototype.____constructor(self)
56
+ AbstractDestroyable.prototype.____constructor(self)
54
57
  self[0] = get()
55
58
  timerByHandleId[getHandleId(self[0])] = self
56
59
  end
57
60
  function Timer.prototype.start(self, timeout, periodic, callback, ...)
58
- self[3] = callback
61
+ self[2] = callback
59
62
  local argsLength = select("#", ...)
60
- self[4] = argsLength
63
+ self[3] = argsLength
61
64
  for i = 1, argsLength do
62
- self[4 + i] = (select(i, ...))
65
+ self[3 + i] = (select(i, ...))
63
66
  end
64
67
  timerStart(self.handle, timeout, periodic, timerSafeCall)
65
68
  end
69
+ function Timer.prototype.onDestroy(self)
70
+ local handle = self[0]
71
+ timerByHandleId[getHandleId(handle)] = nil
72
+ release(handle)
73
+ return AbstractDestroyable.prototype.onDestroy(self)
74
+ end
66
75
  function Timer.prototype.pause(self)
67
76
  pauseTimer(self[0])
68
77
  end
69
78
  function Timer.prototype.resume(self)
70
79
  resumeTimer(self[0])
71
80
  end
72
- function Timer.prototype.destroy(self)
73
- if self[1] then
74
- error(
75
- __TS__New(IllegalStateException, "Double-destroy run for timer"),
76
- 0
77
- )
78
- end
79
- local handle = self[0]
80
- timerByHandleId[getHandleId(handle)] = nil
81
- release(handle)
82
- self[1] = true
83
- end
84
81
  function Timer.create(self)
85
82
  return __TS__New(____exports.Timer)
86
83
  end
@@ -89,7 +86,7 @@ function Timer.run(self, callback, ...)
89
86
  end
90
87
  function Timer.simple(self, timeout, callback, ...)
91
88
  local timer = __TS__New(____exports.Timer)
92
- timer[2] = true
89
+ timer[1] = true
93
90
  timer:start(timeout, false, callback, ...)
94
91
  return timer
95
92
  end