warscript 0.0.1-dev.e196516 → 0.0.1-dev.e49ec00

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.
@@ -2,6 +2,7 @@ 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__New = ____lualib.__TS__New
5
+ local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
5
6
  local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
6
7
  local ____exports = {}
7
8
  local ____color = require("core.types.color")
@@ -46,10 +47,10 @@ TextTag.name = "TextTag"
46
47
  __TS__ClassExtends(TextTag, AbstractDestroyable)
47
48
  function TextTag.prototype.____constructor(self, handle)
48
49
  AbstractDestroyable.prototype.____constructor(self)
49
- self.handle = handle
50
+ self[101] = handle
50
51
  end
51
52
  function TextTag.prototype.onDestroy(self)
52
- destroyTextTag(self.handle)
53
+ destroyTextTag(self[101])
53
54
  unitTextTags[self] = nil
54
55
  return AbstractDestroyable.prototype.onDestroy(self)
55
56
  end
@@ -66,11 +67,141 @@ function TextTag.create(self, configuration, text, unit)
66
67
  applyConfiguration(handle, configuration)
67
68
  setTextTagPermanent(handle, true)
68
69
  local textTag = __TS__New(____exports.TextTag, handle)
69
- textTag[100] = unit.handle
70
- textTag[101] = configuration
70
+ textTag[100] = unit
71
+ textTag[102] = configuration
71
72
  unitTextTags[textTag] = true
72
73
  return textTag
73
74
  end
75
+ __TS__SetDescriptor(
76
+ TextTag.prototype,
77
+ "text",
78
+ {
79
+ get = function(self)
80
+ return self[103] or ""
81
+ end,
82
+ set = function(self, text)
83
+ setTextTagText(self[101], text, self[104] or DEFAULT_FONT_SIZE)
84
+ self[103] = text
85
+ end
86
+ },
87
+ true
88
+ )
89
+ __TS__SetDescriptor(
90
+ TextTag.prototype,
91
+ "fontSize",
92
+ {
93
+ get = function(self)
94
+ return self[104] or DEFAULT_FONT_SIZE
95
+ end,
96
+ set = function(self, fontSize)
97
+ setTextTagText(self[101], self[103] or "", DEFAULT_FONT_SIZE)
98
+ self[104] = fontSize
99
+ end
100
+ },
101
+ true
102
+ )
103
+ __TS__SetDescriptor(
104
+ TextTag.prototype,
105
+ "color",
106
+ {
107
+ get = function(self)
108
+ return self[105] or Color.white
109
+ end,
110
+ set = function(self, color)
111
+ setTextTagColor(
112
+ self[101],
113
+ color.r,
114
+ color.g,
115
+ color.b,
116
+ color.a
117
+ )
118
+ self[105] = color
119
+ end
120
+ },
121
+ true
122
+ )
123
+ __TS__SetDescriptor(
124
+ TextTag.prototype,
125
+ "unit",
126
+ {
127
+ get = function(self)
128
+ return self[100]
129
+ end,
130
+ set = function(self, unit)
131
+ if unit ~= nil then
132
+ setTextTagPosUnit(self[101], unit.handle, 0)
133
+ self[106] = nil
134
+ self[107] = nil
135
+ unitTextTags[self] = true
136
+ elseif self[100] ~= nil then
137
+ local unit = self[100]
138
+ local x = unit.x
139
+ local y = unit.y
140
+ setTextTagPos(self[101], x, y, 0)
141
+ self[106] = x
142
+ self[107] = y
143
+ unitTextTags[self] = nil
144
+ end
145
+ self[100] = unit
146
+ end
147
+ },
148
+ true
149
+ )
150
+ __TS__SetDescriptor(
151
+ TextTag.prototype,
152
+ "x",
153
+ {
154
+ get = function(self)
155
+ local ____self__106_2 = self[106]
156
+ if ____self__106_2 == nil then
157
+ local ____opt_0 = self[100]
158
+ ____self__106_2 = ____opt_0 and ____opt_0.x
159
+ end
160
+ return ____self__106_2 or 0
161
+ end,
162
+ set = function(self, x)
163
+ local ____self__101_6 = self[101]
164
+ local ____x_7 = x
165
+ local ____self__107_5 = self[107]
166
+ if ____self__107_5 == nil then
167
+ local ____opt_3 = self[100]
168
+ ____self__107_5 = ____opt_3 and ____opt_3.y
169
+ end
170
+ setTextTagPos(____self__101_6, ____x_7, ____self__107_5 or 0, 0)
171
+ self[106] = x
172
+ self[100] = nil
173
+ unitTextTags[self] = nil
174
+ end
175
+ },
176
+ true
177
+ )
178
+ __TS__SetDescriptor(
179
+ TextTag.prototype,
180
+ "y",
181
+ {
182
+ get = function(self)
183
+ local ____self__107_10 = self[107]
184
+ if ____self__107_10 == nil then
185
+ local ____opt_8 = self[100]
186
+ ____self__107_10 = ____opt_8 and ____opt_8.y
187
+ end
188
+ return ____self__107_10 or 0
189
+ end,
190
+ set = function(self, y)
191
+ local ____self__101_14 = self[101]
192
+ local ____self__106_13 = self[106]
193
+ if ____self__106_13 == nil then
194
+ local ____opt_11 = self[100]
195
+ ____self__106_13 = ____opt_11 and ____opt_11.x
196
+ end
197
+ setTextTagPos(____self__101_14, ____self__106_13 or 0, y, 0)
198
+ self[107] = y
199
+ self[100] = nil
200
+ unitTextTags[self] = nil
201
+ end
202
+ },
203
+ true
204
+ )
74
205
  TextTag.BASE = {
75
206
  fadepoint = 2,
76
207
  lifespan = 3,
@@ -137,7 +268,7 @@ TextTag.SHADOW_STRIKE = __TS__ObjectAssign(
137
268
  )
138
269
  Timer.onPeriod[1 / 64]:addListener(function()
139
270
  for textTag in pairs(unitTextTags) do
140
- setTextTagPosUnit(textTag.handle, textTag[100], textTag[101].offsetZ)
271
+ setTextTagPosUnit(textTag[101], textTag[100].handle, textTag[102].offsetZ)
141
272
  end
142
273
  end)
143
274
  return ____exports
package/engine/unit.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** @noSelfInFile */
2
2
  import "./internal/unit";
3
+ import "./internal/unit/order";
3
4
  import "./internal/unit/ability";
4
5
  import "./internal/unit/allowed-targets";
5
6
  import "./internal/unit/buff";
package/engine/unit.lua CHANGED
@@ -1,5 +1,6 @@
1
1
  local ____exports = {}
2
2
  require("engine.internal.unit")
3
+ require("engine.internal.unit.order")
3
4
  require("engine.internal.unit.ability")
4
5
  require("engine.internal.unit.allowed-targets")
5
6
  require("engine.internal.unit.buff")
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.e196516",
4
+ "version": "0.0.1-dev.e49ec00",
5
5
  "description": "A typescript library for Warcraft III using Warpack.",
6
6
  "keywords": [
7
7
  "warcraft",
@@ -4,3 +4,6 @@ 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;
@@ -88,4 +88,7 @@ ____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
91
94
  return ____exports
@@ -1,26 +0,0 @@
1
- /** @noSelfInFile */
2
- import { Unit } from "./unit";
3
- import { Item } from "./item";
4
- import { Destructable } from "./destructable";
5
- export type Order = {
6
- id: number;
7
- startX: number;
8
- startY: number;
9
- issueTime: number;
10
- } & ({
11
- type: "immediate";
12
- } | {
13
- type: "point";
14
- targetX: number;
15
- targetY: number;
16
- } | {
17
- type: "target";
18
- target: Unit | Item | Destructable;
19
- });
20
- declare module "../../engine/internal/unit" {
21
- interface Unit {
22
- readonly currentOrder: Order;
23
- readonly lastOrder: Order;
24
- issueOrder(order: Order): void;
25
- }
26
- }
@@ -1,65 +0,0 @@
1
- local ____lualib = require("lualib_bundle")
2
- local __TS__ObjectDefineProperty = ____lualib.__TS__ObjectDefineProperty
3
- local ____exports = {}
4
- local ____unit = require("core.types.unit")
5
- local Unit = ____unit.Unit
6
- local ____game = require("core.game")
7
- local elapsedTime = ____game.elapsedTime
8
- local getUnitCurrentOrder = GetUnitCurrentOrder
9
- local orders = setmetatable({}, {__mode = "k"})
10
- Unit.onImmediateOrder:addListener(function(unit, orderId)
11
- orders[unit] = {
12
- id = orderId,
13
- startX = unit.x,
14
- startY = unit.y,
15
- issueTime = elapsedTime(),
16
- type = "immediate"
17
- }
18
- end)
19
- Unit.onPointOrder:addListener(function(unit, orderId, x, y)
20
- orders[unit] = {
21
- id = orderId,
22
- startX = unit.x,
23
- startY = unit.y,
24
- issueTime = elapsedTime(),
25
- type = "point",
26
- targetX = x,
27
- targetY = y
28
- }
29
- end)
30
- Unit.onTargetOrder:addListener(function(unit, orderId, target)
31
- orders[unit] = {
32
- id = orderId,
33
- startX = unit.x,
34
- startY = unit.y,
35
- issueTime = elapsedTime(),
36
- type = "target",
37
- target = target
38
- }
39
- end)
40
- __TS__ObjectDefineProperty(
41
- Unit.prototype,
42
- "currentOrder",
43
- {get = function(self)
44
- local currentOrderId = getUnitCurrentOrder(self.handle)
45
- local lastOrder = orders[self]
46
- return lastOrder and (lastOrder.id == currentOrderId or currentOrderId == orderId("patrolAI") and lastOrder.id == orderId("patrol")) and lastOrder or ({id = 0, type = "immediate"})
47
- end}
48
- )
49
- __TS__ObjectDefineProperty(
50
- Unit.prototype,
51
- "lastOrder",
52
- {get = function(self)
53
- return orders[self] or ({id = 0, type = "immediate"})
54
- end}
55
- )
56
- Unit.prototype.issueOrder = function(self, order)
57
- if order.type == "immediate" then
58
- IssueImmediateOrderById(self.handle, order.id)
59
- elseif order.type == "point" then
60
- IssuePointOrderById(self.handle, order.id, order.targetX, order.targetY)
61
- else
62
- IssueTargetOrderById(self.handle, order.id, order.target.handle)
63
- end
64
- end
65
- return ____exports