warscript 0.0.1-dev.e72b4b0 → 0.0.1-dev.ea102a7
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/core/types/frame.lua +24 -21
- package/core/types/player.lua +3 -1
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/tileCell.d.ts +9 -0
- package/core/types/tileCell.lua +92 -0
- package/core/types/timer.d.ts +2 -1
- package/core/types/timer.lua +21 -2
- package/decl/native.d.ts +6 -4
- package/engine/behavior.d.ts +5 -0
- package/engine/behavior.lua +106 -27
- package/engine/behaviour/ability/apply-buff.lua +1 -1
- package/engine/behaviour/ability/emulate-impact.d.ts +1 -1
- package/engine/behaviour/ability/emulate-impact.lua +2 -1
- package/engine/behaviour/ability/restore-mana.d.ts +1 -1
- package/engine/behaviour/ability/restore-mana.lua +6 -6
- package/engine/behaviour/ability.lua +7 -16
- package/engine/behaviour/unit/stun-immunity.d.ts +7 -3
- package/engine/behaviour/unit/stun-immunity.lua +52 -27
- package/engine/behaviour/unit.d.ts +12 -2
- package/engine/behaviour/unit.lua +47 -7
- package/engine/buff.d.ts +2 -4
- package/engine/buff.lua +68 -83
- package/engine/internal/ability.d.ts +3 -1
- package/engine/internal/ability.lua +34 -11
- package/engine/internal/item/ability.lua +51 -1
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +13 -15
- package/engine/internal/item.lua +63 -49
- package/engine/internal/misc/frame-coordinates.d.ts +2 -0
- package/engine/internal/misc/frame-coordinates.lua +21 -0
- package/engine/internal/misc/get-terrain-z.d.ts +2 -0
- package/engine/internal/misc/get-terrain-z.lua +11 -0
- package/engine/internal/misc/player-local-handle.d.ts +2 -0
- package/engine/internal/misc/player-local-handle.lua +5 -0
- package/engine/internal/unit/ability.lua +13 -5
- package/engine/internal/unit+ability.lua +10 -1
- package/engine/internal/unit-missile-launch.lua +18 -5
- package/engine/internal/unit.d.ts +5 -6
- package/engine/internal/unit.lua +73 -73
- package/engine/object-data/auxiliary/armor-type.d.ts +11 -0
- package/engine/object-data/auxiliary/armor-type.lua +46 -0
- package/engine/object-data/entry/ability-type.lua +5 -4
- package/engine/object-data/entry/unit-type.d.ts +11 -2
- package/engine/object-data/entry/unit-type.lua +59 -1
- package/engine/object-field/ability.d.ts +3 -3
- package/engine/object-field/ability.lua +7 -6
- package/engine/object-field/unit.d.ts +7 -0
- package/engine/object-field/unit.lua +21 -0
- package/engine/object-field.d.ts +2 -2
- package/engine/object-field.lua +8 -6
- package/engine/random.d.ts +9 -0
- package/engine/random.lua +13 -0
- package/engine/standard/fields/unit.d.ts +2 -1
- package/engine/standard/fields/unit.lua +2 -0
- package/engine/text-tag.d.ts +1 -1
- package/engine/text-tag.lua +91 -17
- package/objutil/buff.lua +1 -1
- package/package.json +2 -2
- package/patch-lualib.lua +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +13 -0
- package/utility/callback-array.lua +46 -0
- package/utility/functions.d.ts +7 -0
- package/utility/functions.lua +12 -0
- package/utility/lua-maps.d.ts +11 -2
- package/utility/lua-maps.lua +33 -2
- package/utility/lua-sets.d.ts +1 -0
- package/utility/lua-sets.lua +4 -0
package/core/types/frame.lua
CHANGED
|
@@ -15,13 +15,20 @@ local Event = ____event.Event
|
|
|
15
15
|
local TriggerEvent = ____event.TriggerEvent
|
|
16
16
|
local ____timer = require("core.types.timer")
|
|
17
17
|
local Timer = ____timer.Timer
|
|
18
|
+
local ____frame_2Dcoordinates = require("engine.internal.misc.frame-coordinates")
|
|
19
|
+
local FRAME_MAX_Y = ____frame_2Dcoordinates.FRAME_MAX_Y
|
|
20
|
+
local FRAME_MIN_Y = ____frame_2Dcoordinates.FRAME_MIN_Y
|
|
21
|
+
local getFrameMinXMaxX = ____frame_2Dcoordinates.getFrameMinXMaxX
|
|
22
|
+
local ____playerCamera = require("core.types.playerCamera")
|
|
23
|
+
local frameCoordinatesToWorld = ____playerCamera.frameCoordinatesToWorld
|
|
24
|
+
local worldCoordinatesToFrame = ____playerCamera.worldCoordinatesToFrame
|
|
25
|
+
local ____get_2Dterrain_2Dz = require("engine.internal.misc.get-terrain-z")
|
|
26
|
+
local getTerrainZ = ____get_2Dterrain_2Dz.getTerrainZ
|
|
18
27
|
local frameClick = BlzFrameClick
|
|
19
28
|
local frameGetEnable = BlzFrameGetEnable
|
|
20
29
|
local frameIsVisible = BlzFrameIsVisible
|
|
21
30
|
local frameSetEnable = BlzFrameSetEnable
|
|
22
31
|
local frameSetScale = BlzFrameSetScale
|
|
23
|
-
local getCameraTargetPositionX = GetCameraTargetPositionX
|
|
24
|
-
local getCameraTargetPositionY = GetCameraTargetPositionY
|
|
25
32
|
local ____rawget = _G.rawget
|
|
26
33
|
local rawset = _G.rawset
|
|
27
34
|
local invoke = Event.invoke
|
|
@@ -344,27 +351,21 @@ __TS__ObjectDefineProperty(
|
|
|
344
351
|
Frame,
|
|
345
352
|
"minX",
|
|
346
353
|
{get = function(self)
|
|
347
|
-
local
|
|
348
|
-
|
|
349
|
-
local width4by3 = (w - h / 600 * 800) / 2
|
|
350
|
-
local pxtodpi = 0.6 / h
|
|
351
|
-
return -width4by3 * pxtodpi
|
|
354
|
+
local minX = getFrameMinXMaxX()
|
|
355
|
+
return minX
|
|
352
356
|
end}
|
|
353
357
|
)
|
|
354
358
|
__TS__ObjectDefineProperty(
|
|
355
359
|
Frame,
|
|
356
360
|
"maxX",
|
|
357
361
|
{get = function(self)
|
|
358
|
-
local
|
|
359
|
-
|
|
360
|
-
local width4by3 = (w - h / 600 * 800) / 2
|
|
361
|
-
local pxtodpi = 0.6 / h
|
|
362
|
-
return (-width4by3 + w) * pxtodpi
|
|
362
|
+
local ____, maxX = getFrameMinXMaxX()
|
|
363
|
+
return maxX
|
|
363
364
|
end}
|
|
364
365
|
)
|
|
365
366
|
Frame.centerX = 0.4
|
|
366
|
-
Frame.minY =
|
|
367
|
-
Frame.maxY =
|
|
367
|
+
Frame.minY = FRAME_MIN_Y
|
|
368
|
+
Frame.maxY = FRAME_MAX_Y
|
|
368
369
|
Frame.centerY = 0.3
|
|
369
370
|
__TS__SetDescriptor(
|
|
370
371
|
Frame.prototype,
|
|
@@ -938,16 +939,19 @@ __TS__ObjectDefineProperty(
|
|
|
938
939
|
local event = __TS__New(Event)
|
|
939
940
|
local syncX = 0
|
|
940
941
|
local syncY = 0
|
|
941
|
-
local
|
|
942
|
-
local
|
|
942
|
+
local syncFrameX = 0
|
|
943
|
+
local syncFrameY = 0
|
|
943
944
|
local lastX = syncX
|
|
944
945
|
local lastY = syncY
|
|
945
946
|
self.onMouseMove:addListener(function(player, x, y)
|
|
946
947
|
if player.isLocal then
|
|
947
948
|
syncX = x
|
|
948
949
|
syncY = y
|
|
949
|
-
|
|
950
|
-
|
|
950
|
+
syncFrameX, syncFrameY = worldCoordinatesToFrame(
|
|
951
|
+
x,
|
|
952
|
+
y,
|
|
953
|
+
getTerrainZ(x, y)
|
|
954
|
+
)
|
|
951
955
|
lastX = x
|
|
952
956
|
lastY = y
|
|
953
957
|
invoke(event, x, y)
|
|
@@ -957,9 +961,8 @@ __TS__ObjectDefineProperty(
|
|
|
957
961
|
if syncX == 0 and syncY == 0 then
|
|
958
962
|
return
|
|
959
963
|
end
|
|
960
|
-
local x
|
|
961
|
-
|
|
962
|
-
if x ~= lastX or y ~= lastY then
|
|
964
|
+
local x, y, ____, isDefinite = frameCoordinatesToWorld(syncFrameX, syncFrameY)
|
|
965
|
+
if isDefinite and (x ~= lastX or y ~= lastY) then
|
|
963
966
|
lastX = x
|
|
964
967
|
lastY = y
|
|
965
968
|
invoke(event, x, y)
|
package/core/types/player.lua
CHANGED
|
@@ -21,6 +21,8 @@ local ____exception = require("exception")
|
|
|
21
21
|
local IllegalStateException = ____exception.IllegalStateException
|
|
22
22
|
local ____math = require("math")
|
|
23
23
|
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
24
|
+
local ____player_2Dlocal_2Dhandle = require("engine.internal.misc.player-local-handle")
|
|
25
|
+
local PLAYER_LOCAL_HANDLE = ____player_2Dlocal_2Dhandle.PLAYER_LOCAL_HANDLE
|
|
24
26
|
local getPlayerColor = GetPlayerColor
|
|
25
27
|
local getPlayerName = GetPlayerName
|
|
26
28
|
local getPlayerTechCount = GetPlayerTechCount
|
|
@@ -249,7 +251,7 @@ Player.all = (function()
|
|
|
249
251
|
end
|
|
250
252
|
return all
|
|
251
253
|
end)()
|
|
252
|
-
Player["local"] = ____exports.Player:of(
|
|
254
|
+
Player["local"] = ____exports.Player:of(PLAYER_LOCAL_HANDLE)
|
|
253
255
|
Player.neutralPassive = ____exports.Player.all[PLAYER_NEUTRAL_PASSIVE + 1]
|
|
254
256
|
Player.neutralAggressive = ____exports.Player.all[PLAYER_NEUTRAL_AGGRESSIVE + 1]
|
|
255
257
|
Player.neutralVictim = ____exports.Player.all[bj_PLAYER_NEUTRAL_VICTIM + 1]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
|
+
import type { Unit } from "../../engine/internal/unit";
|
|
2
3
|
export declare class PlayerCamera {
|
|
3
4
|
private readonly player;
|
|
4
5
|
private readonly isLocal;
|
|
@@ -28,5 +29,6 @@ export declare class PlayerCamera {
|
|
|
28
29
|
get roll(): number;
|
|
29
30
|
set roll(v: number);
|
|
30
31
|
reset(): void;
|
|
32
|
+
static isUnitInView(unit: Unit): boolean;
|
|
31
33
|
static of(player: jplayer): PlayerCamera;
|
|
32
34
|
}
|
|
@@ -3,33 +3,52 @@ local __TS__Class = ____lualib.__TS__Class
|
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
4
|
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
5
5
|
local ____exports = {}
|
|
6
|
+
local ____timer = require("core.types.timer")
|
|
7
|
+
local Timer = ____timer.Timer
|
|
8
|
+
local ____player_2Dlocal_2Dhandle = require("engine.internal.misc.player-local-handle")
|
|
9
|
+
local PLAYER_LOCAL_HANDLE = ____player_2Dlocal_2Dhandle.PLAYER_LOCAL_HANDLE
|
|
10
|
+
local ____preconditions = require("utility.preconditions")
|
|
11
|
+
local check = ____preconditions.check
|
|
12
|
+
local ____frame_2Dcoordinates = require("engine.internal.misc.frame-coordinates")
|
|
13
|
+
local FRAME_MAX_Y = ____frame_2Dcoordinates.FRAME_MAX_Y
|
|
14
|
+
local FRAME_MIN_Y = ____frame_2Dcoordinates.FRAME_MIN_Y
|
|
15
|
+
local getFrameMinXMaxX = ____frame_2Dcoordinates.getFrameMinXMaxX
|
|
16
|
+
local ____get_2Dterrain_2Dz = require("engine.internal.misc.get-terrain-z")
|
|
17
|
+
local getTerrainZ = ____get_2Dterrain_2Dz.getTerrainZ
|
|
6
18
|
local getHandleId = GetHandleId
|
|
7
19
|
local setCameraField = SetCameraField
|
|
8
20
|
local getCameraField = GetCameraField
|
|
9
21
|
local setCameraPosition = SetCameraPosition
|
|
22
|
+
local getCameraEyePositionX = GetCameraEyePositionX
|
|
23
|
+
local getCameraEyePositionY = GetCameraEyePositionY
|
|
24
|
+
local getCameraEyePositionZ = GetCameraEyePositionZ
|
|
10
25
|
local getCameraTargetPositionX = GetCameraTargetPositionX
|
|
11
26
|
local getCameraTargetPositionY = GetCameraTargetPositionY
|
|
12
27
|
local resetToGameCamera = ResetToGameCamera
|
|
28
|
+
local cos = math.cos
|
|
13
29
|
local deg = math.deg
|
|
14
|
-
local
|
|
30
|
+
local sin = math.sin
|
|
31
|
+
local sqrt = math.sqrt
|
|
15
32
|
local memoized = {}
|
|
16
33
|
____exports.PlayerCamera = __TS__Class()
|
|
17
34
|
local PlayerCamera = ____exports.PlayerCamera
|
|
18
35
|
PlayerCamera.name = "PlayerCamera"
|
|
19
36
|
function PlayerCamera.prototype.____constructor(self, player)
|
|
20
37
|
local id = getHandleId(player)
|
|
21
|
-
|
|
22
|
-
error("Double-constructor run player camera!")
|
|
23
|
-
end
|
|
38
|
+
check(memoized[id] == nil)
|
|
24
39
|
memoized[id] = self
|
|
25
40
|
self.player = player
|
|
26
|
-
self.isLocal = player ==
|
|
41
|
+
self.isLocal = player == PLAYER_LOCAL_HANDLE
|
|
27
42
|
end
|
|
28
43
|
function PlayerCamera.prototype.reset(self)
|
|
29
44
|
if self.isLocal then
|
|
30
45
|
resetToGameCamera(0)
|
|
31
46
|
end
|
|
32
47
|
end
|
|
48
|
+
function PlayerCamera.isUnitInView(self, unit)
|
|
49
|
+
local ____, ____, isInView = ____exports.worldCoordinatesToFrame(unit.x, unit.y, unit.z)
|
|
50
|
+
return isInView
|
|
51
|
+
end
|
|
33
52
|
function PlayerCamera.of(self, player)
|
|
34
53
|
return memoized[getHandleId(player)] or __TS__New(____exports.PlayerCamera, player)
|
|
35
54
|
end
|
|
@@ -159,4 +178,103 @@ __TS__SetDescriptor(
|
|
|
159
178
|
},
|
|
160
179
|
true
|
|
161
180
|
)
|
|
181
|
+
local cameraEyeX = 0
|
|
182
|
+
local cameraEyeY = 0
|
|
183
|
+
local cameraEyeZ = 0
|
|
184
|
+
local cameraAngleOfAttack = 0
|
|
185
|
+
local cameraAngleOfAttackCos = 0
|
|
186
|
+
local cameraAngleOfAttackSin = 0
|
|
187
|
+
local cameraRotation = 0
|
|
188
|
+
local cameraRotationCos = 0
|
|
189
|
+
local cameraRotationSin = 0
|
|
190
|
+
local cameraAngleOfAttackCosRotationCos = 0
|
|
191
|
+
local cameraAngleOfAttackCosRotationSin = 0
|
|
192
|
+
local cameraAngleOfAttackSinRotationCos = 0
|
|
193
|
+
local cameraAngleOfAttackSinRotationSin = 0
|
|
194
|
+
local yCenterScreenShift = 0
|
|
195
|
+
local scaleFactor = 0
|
|
196
|
+
local frameMinX = 0
|
|
197
|
+
local frameMaxX = 0
|
|
198
|
+
local isCameraViewPrecalculated = false
|
|
199
|
+
local function precalculateCameraView()
|
|
200
|
+
cameraEyeX = getCameraEyePositionX()
|
|
201
|
+
cameraEyeY = getCameraEyePositionY()
|
|
202
|
+
cameraEyeZ = getCameraEyePositionZ()
|
|
203
|
+
cameraAngleOfAttack = getCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)
|
|
204
|
+
cameraAngleOfAttackCos = cos(cameraAngleOfAttack)
|
|
205
|
+
cameraAngleOfAttackSin = sin(cameraAngleOfAttack)
|
|
206
|
+
cameraRotation = getCameraField(CAMERA_FIELD_ROTATION)
|
|
207
|
+
cameraRotationCos = cos(cameraRotation)
|
|
208
|
+
cameraRotationSin = sin(cameraRotation)
|
|
209
|
+
cameraAngleOfAttackCosRotationCos = cameraAngleOfAttackCos * cameraRotationCos
|
|
210
|
+
cameraAngleOfAttackCosRotationSin = cameraAngleOfAttackCos * cameraRotationSin
|
|
211
|
+
cameraAngleOfAttackSinRotationCos = cameraAngleOfAttackSin * cameraRotationCos
|
|
212
|
+
cameraAngleOfAttackSinRotationSin = cameraAngleOfAttackSin * cameraRotationSin
|
|
213
|
+
yCenterScreenShift = 0.1284 * cameraAngleOfAttackCos
|
|
214
|
+
local cameraFieldOfView = getCameraField(CAMERA_FIELD_FIELD_OF_VIEW)
|
|
215
|
+
scaleFactor = 0.0524 * cameraFieldOfView ^ 3 - 0.0283 * cameraFieldOfView ^ 2 + 1.061 * cameraFieldOfView
|
|
216
|
+
frameMinX, frameMaxX = getFrameMinXMaxX()
|
|
217
|
+
isCameraViewPrecalculated = true
|
|
218
|
+
end
|
|
219
|
+
Timer.onPeriod[1 / 64]:addListener(
|
|
220
|
+
4,
|
|
221
|
+
function()
|
|
222
|
+
isCameraViewPrecalculated = false
|
|
223
|
+
end
|
|
224
|
+
)
|
|
225
|
+
---
|
|
226
|
+
-- @internal For use by internal systems only.
|
|
227
|
+
____exports.worldCoordinatesToFrame = function(x, y, z)
|
|
228
|
+
if not isCameraViewPrecalculated then
|
|
229
|
+
precalculateCameraView()
|
|
230
|
+
end
|
|
231
|
+
local dx = x - cameraEyeX
|
|
232
|
+
local dy = y - cameraEyeY
|
|
233
|
+
local dz = z - cameraEyeZ
|
|
234
|
+
local xPrime = scaleFactor * (-cameraAngleOfAttackCosRotationCos * dx - cameraAngleOfAttackCosRotationSin * dy - cameraAngleOfAttackSin * dz)
|
|
235
|
+
local frameX = 0.4 + (cameraRotationCos * dy - cameraRotationSin * dx) / xPrime
|
|
236
|
+
local frameY = 0.42625 - yCenterScreenShift + (cameraAngleOfAttackSinRotationCos * dx + cameraAngleOfAttackSinRotationSin * dy - cameraAngleOfAttackCos * dz) / xPrime
|
|
237
|
+
return frameX, frameY, xPrime < 0 and frameX >= frameMinX and frameX <= frameMaxX and frameY >= FRAME_MIN_Y and frameY <= FRAME_MAX_Y
|
|
238
|
+
end
|
|
239
|
+
---
|
|
240
|
+
-- @internal For use by internal systems only.
|
|
241
|
+
____exports.frameCoordinatesToWorld = function(x, y)
|
|
242
|
+
if not isCameraViewPrecalculated then
|
|
243
|
+
precalculateCameraView()
|
|
244
|
+
end
|
|
245
|
+
local a = (x - 0.4) * scaleFactor
|
|
246
|
+
local b = (0.42625 - yCenterScreenShift - y) * scaleFactor
|
|
247
|
+
local nx = 1 / sqrt(1 + a * a + b * b)
|
|
248
|
+
local ny = sqrt(1 - (1 + b * b) * nx * nx)
|
|
249
|
+
local nz = sqrt(1 - nx * nx - ny * ny)
|
|
250
|
+
if a > 0 then
|
|
251
|
+
ny = -ny
|
|
252
|
+
end
|
|
253
|
+
if b < 0 then
|
|
254
|
+
nz = -nz
|
|
255
|
+
end
|
|
256
|
+
local nxPrime = cameraAngleOfAttackCosRotationCos * nx - cameraRotationSin * ny + cameraAngleOfAttackSinRotationCos * nz
|
|
257
|
+
local nyPrime = cameraAngleOfAttackCosRotationSin * nx + cameraRotationCos * ny + cameraAngleOfAttackSinRotationSin * nz
|
|
258
|
+
local nzPrime = -cameraAngleOfAttackSin * nx + cameraAngleOfAttackCos * nz
|
|
259
|
+
local zGuess = getTerrainZ(cameraEyeX, cameraEyeY)
|
|
260
|
+
local xGuess = cameraEyeX + nxPrime * (cameraEyeZ - zGuess) / nzPrime
|
|
261
|
+
local yGuess = cameraEyeY + nyPrime * (cameraEyeZ - zGuess) / nzPrime
|
|
262
|
+
local zWorld = getTerrainZ(xGuess, yGuess)
|
|
263
|
+
local deltaZ = zWorld - zGuess
|
|
264
|
+
zGuess = zWorld
|
|
265
|
+
local zWorldOld = zWorld
|
|
266
|
+
local deltaZOld = deltaZ
|
|
267
|
+
local i = 0
|
|
268
|
+
while (deltaZ > 1 or deltaZ < -1) and i < 50 do
|
|
269
|
+
xGuess = cameraEyeX + nxPrime * (cameraEyeZ - zGuess) / nzPrime
|
|
270
|
+
yGuess = cameraEyeY + nyPrime * (cameraEyeZ - zGuess) / nzPrime
|
|
271
|
+
zWorld = getTerrainZ(xGuess, yGuess)
|
|
272
|
+
deltaZ = zWorld - zGuess
|
|
273
|
+
zGuess = (deltaZOld * zWorld - deltaZ * zWorldOld) / (deltaZOld - deltaZ)
|
|
274
|
+
zWorldOld = zWorld
|
|
275
|
+
deltaZOld = deltaZ
|
|
276
|
+
i = i + 1
|
|
277
|
+
end
|
|
278
|
+
return xGuess, yGuess, zWorld, i < 50
|
|
279
|
+
end
|
|
162
280
|
return ____exports
|
package/core/types/tileCell.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export declare class TileCell implements Readonly<Vec2> {
|
|
|
5
5
|
readonly y: number;
|
|
6
6
|
readonly z: undefined;
|
|
7
7
|
protected constructor(id: number, x: number, y: number, z: undefined);
|
|
8
|
+
get up(): TileCell;
|
|
9
|
+
get down(): TileCell;
|
|
10
|
+
get left(): TileCell;
|
|
11
|
+
get right(): TileCell;
|
|
12
|
+
get terrainTypeId(): number;
|
|
13
|
+
set terrainTypeId(terrainTypeId: number);
|
|
14
|
+
get terrainVariance(): number;
|
|
15
|
+
set terrainVariance(terrainVariance: number);
|
|
16
|
+
randomizeTerrainVariance(): void;
|
|
8
17
|
isInRangeOf(x: number, y: number, range: number): boolean;
|
|
9
18
|
isInRangeOf(tileCell: TileCell, range: number): boolean;
|
|
10
19
|
static getInRect(minX: number, minY: number, maxX: number, maxY: number): TileCell[];
|
package/core/types/tileCell.lua
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
3
|
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
|
|
4
5
|
local ____exports = {}
|
|
6
|
+
local getTerrainType = GetTerrainType
|
|
7
|
+
local setTerrainType = SetTerrainType
|
|
8
|
+
local getTerrainVariance = GetTerrainVariance
|
|
5
9
|
local abs = math.abs
|
|
6
10
|
local ____type = math.type
|
|
7
11
|
local ult = math.ult
|
|
@@ -16,6 +20,18 @@ function TileCell.prototype.____constructor(self, id, x, y, z)
|
|
|
16
20
|
self.z = z
|
|
17
21
|
tileCellById[id] = self
|
|
18
22
|
end
|
|
23
|
+
function TileCell.prototype.randomizeTerrainVariance(self)
|
|
24
|
+
local x = self.x
|
|
25
|
+
local y = self.y
|
|
26
|
+
setTerrainType(
|
|
27
|
+
x,
|
|
28
|
+
y,
|
|
29
|
+
getTerrainType(x, y),
|
|
30
|
+
-1,
|
|
31
|
+
1,
|
|
32
|
+
1
|
|
33
|
+
)
|
|
34
|
+
end
|
|
19
35
|
function TileCell.prototype.isInRangeOf(self, x, y, range)
|
|
20
36
|
if range == nil then
|
|
21
37
|
range = y
|
|
@@ -97,4 +113,80 @@ function TileCell.of(x, y)
|
|
|
97
113
|
nil
|
|
98
114
|
)
|
|
99
115
|
end
|
|
116
|
+
__TS__SetDescriptor(
|
|
117
|
+
TileCell.prototype,
|
|
118
|
+
"up",
|
|
119
|
+
{get = function(self)
|
|
120
|
+
return ____exports.TileCell.of(self.x, self.y + 128)
|
|
121
|
+
end},
|
|
122
|
+
true
|
|
123
|
+
)
|
|
124
|
+
__TS__SetDescriptor(
|
|
125
|
+
TileCell.prototype,
|
|
126
|
+
"down",
|
|
127
|
+
{get = function(self)
|
|
128
|
+
return ____exports.TileCell.of(self.x, self.y - 128)
|
|
129
|
+
end},
|
|
130
|
+
true
|
|
131
|
+
)
|
|
132
|
+
__TS__SetDescriptor(
|
|
133
|
+
TileCell.prototype,
|
|
134
|
+
"left",
|
|
135
|
+
{get = function(self)
|
|
136
|
+
return ____exports.TileCell.of(self.x - 128, self.y)
|
|
137
|
+
end},
|
|
138
|
+
true
|
|
139
|
+
)
|
|
140
|
+
__TS__SetDescriptor(
|
|
141
|
+
TileCell.prototype,
|
|
142
|
+
"right",
|
|
143
|
+
{get = function(self)
|
|
144
|
+
return ____exports.TileCell.of(self.x + 128, self.y)
|
|
145
|
+
end},
|
|
146
|
+
true
|
|
147
|
+
)
|
|
148
|
+
__TS__SetDescriptor(
|
|
149
|
+
TileCell.prototype,
|
|
150
|
+
"terrainTypeId",
|
|
151
|
+
{
|
|
152
|
+
get = function(self)
|
|
153
|
+
return getTerrainType(self.x, self.y)
|
|
154
|
+
end,
|
|
155
|
+
set = function(self, terrainTypeId)
|
|
156
|
+
local x = self.x
|
|
157
|
+
local y = self.y
|
|
158
|
+
setTerrainType(
|
|
159
|
+
x,
|
|
160
|
+
y,
|
|
161
|
+
terrainTypeId,
|
|
162
|
+
getTerrainVariance(x, y),
|
|
163
|
+
1,
|
|
164
|
+
1
|
|
165
|
+
)
|
|
166
|
+
end
|
|
167
|
+
},
|
|
168
|
+
true
|
|
169
|
+
)
|
|
170
|
+
__TS__SetDescriptor(
|
|
171
|
+
TileCell.prototype,
|
|
172
|
+
"terrainVariance",
|
|
173
|
+
{
|
|
174
|
+
get = function(self)
|
|
175
|
+
return getTerrainVariance(self.x, self.y)
|
|
176
|
+
end,
|
|
177
|
+
set = function(self, terrainVariance)
|
|
178
|
+
local x = self.x
|
|
179
|
+
local y = self.y
|
|
180
|
+
setTerrainType(
|
|
181
|
+
x,
|
|
182
|
+
y,
|
|
183
|
+
getTerrainType(x, y),
|
|
184
|
+
terrainVariance,
|
|
185
|
+
1,
|
|
186
|
+
1
|
|
187
|
+
)
|
|
188
|
+
end
|
|
189
|
+
},
|
|
190
|
+
true
|
|
191
|
+
)
|
|
100
192
|
return ____exports
|
package/core/types/timer.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ export declare class Timer extends AbstractDestroyable {
|
|
|
22
22
|
pause(): void;
|
|
23
23
|
resume(): void;
|
|
24
24
|
static create(): Timer;
|
|
25
|
-
static run<
|
|
25
|
+
static run<T, K extends KeysOfType<T, (this: T, ...args: any) => any>>(object: T, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): void;
|
|
26
|
+
static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): void;
|
|
26
27
|
static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
|
|
27
28
|
static periodic<Args extends any[]>(period: number, callback: (this: void, timer: Timer, ...args: Args) => void, ...args: Args): Timer;
|
|
28
29
|
static counted(period: number, count: number, callback: (this: void, timer: Timer) => void): Timer;
|
package/core/types/timer.lua
CHANGED
|
@@ -12,6 +12,10 @@ local ____objectPool = require("util.objectPool")
|
|
|
12
12
|
local ObjectPool = ____objectPool.ObjectPool
|
|
13
13
|
local ____destroyable = require("destroyable")
|
|
14
14
|
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
15
|
+
local ____callback_2Darray = require("utility.callback-array")
|
|
16
|
+
local addCallback = ____callback_2Darray.addCallback
|
|
17
|
+
local callbackArray = ____callback_2Darray.callbackArray
|
|
18
|
+
local consumeCallbacks = ____callback_2Darray.consumeCallbacks
|
|
15
19
|
local createTimer = CreateTimer
|
|
16
20
|
local timerStart = TimerStart
|
|
17
21
|
local pauseTimer = PauseTimer
|
|
@@ -24,6 +28,7 @@ local getHandleId = GetHandleId
|
|
|
24
28
|
local ____pcall = _G.pcall
|
|
25
29
|
local ____print = _G.print
|
|
26
30
|
local select = _G.select
|
|
31
|
+
local ____type = _G.type
|
|
27
32
|
local safeCall = warpack.safeCall
|
|
28
33
|
local corunning = coroutine.running
|
|
29
34
|
local coresume = coroutine.resume
|
|
@@ -48,6 +53,12 @@ local function timerSafeCall()
|
|
|
48
53
|
end
|
|
49
54
|
end
|
|
50
55
|
end
|
|
56
|
+
local zeroTimerScheduled = false
|
|
57
|
+
local zeroTimerCallbacks = callbackArray()
|
|
58
|
+
local function invokeZeroTimerCallbacks()
|
|
59
|
+
zeroTimerScheduled = false
|
|
60
|
+
consumeCallbacks(zeroTimerCallbacks)
|
|
61
|
+
end
|
|
51
62
|
____exports.Timer = __TS__Class()
|
|
52
63
|
local Timer = ____exports.Timer
|
|
53
64
|
Timer.name = "Timer"
|
|
@@ -81,8 +92,16 @@ end
|
|
|
81
92
|
function Timer.create(self)
|
|
82
93
|
return __TS__New(____exports.Timer)
|
|
83
94
|
end
|
|
84
|
-
function Timer.run(self,
|
|
85
|
-
|
|
95
|
+
function Timer.run(self, objectOrCallback, keyOrFirstArg, ...)
|
|
96
|
+
if not zeroTimerScheduled then
|
|
97
|
+
zeroTimerScheduled = true
|
|
98
|
+
____exports.Timer:simple(0, invokeZeroTimerCallbacks)
|
|
99
|
+
end
|
|
100
|
+
if ____type(objectOrCallback) == "function" then
|
|
101
|
+
addCallback(zeroTimerCallbacks, objectOrCallback, keyOrFirstArg, ...)
|
|
102
|
+
else
|
|
103
|
+
addCallback(zeroTimerCallbacks, objectOrCallback[keyOrFirstArg], objectOrCallback, ...)
|
|
104
|
+
end
|
|
86
105
|
end
|
|
87
106
|
function Timer.simple(self, timeout, callback, ...)
|
|
88
107
|
local timer = __TS__New(____exports.Timer)
|
package/decl/native.d.ts
CHANGED
|
@@ -388,13 +388,15 @@ declare interface jmovetype extends jhandle {
|
|
|
388
388
|
declare interface jtargetflag extends jhandle {
|
|
389
389
|
__jtargetflag: never
|
|
390
390
|
}
|
|
391
|
-
declare
|
|
391
|
+
declare type jarmortype = symbol &
|
|
392
|
+
jhandle & {
|
|
392
393
|
__jarmortype: never
|
|
393
394
|
}
|
|
394
395
|
declare interface jheroattribute extends jhandle {
|
|
395
396
|
__jheroattribute: never
|
|
396
397
|
}
|
|
397
|
-
declare
|
|
398
|
+
declare type jdefensetype = symbol &
|
|
399
|
+
jhandle & {
|
|
398
400
|
__jdefensetype: never
|
|
399
401
|
}
|
|
400
402
|
declare interface jregentype extends jhandle {
|
|
@@ -5257,8 +5259,8 @@ declare function BlzRemoveAbilityStringLevelArrayField(
|
|
|
5257
5259
|
level: number,
|
|
5258
5260
|
value: string,
|
|
5259
5261
|
): boolean
|
|
5260
|
-
declare function BlzGetItemAbilityByIndex(whichItem: jitem, index: number): jability |
|
|
5261
|
-
declare function BlzGetItemAbility(whichItem: jitem, abilCode: number): jability |
|
|
5262
|
+
declare function BlzGetItemAbilityByIndex(whichItem: jitem, index: number): jability | undefined
|
|
5263
|
+
declare function BlzGetItemAbility(whichItem: jitem, abilCode: number): jability | undefined
|
|
5262
5264
|
declare function BlzItemAddAbility(whichItem: jitem, abilCode: number): boolean
|
|
5263
5265
|
declare function BlzGetItemBooleanField(whichItem: jitem, whichField: jitembooleanfield): boolean
|
|
5264
5266
|
declare function BlzGetItemIntegerField(whichItem: jitem, whichField: jitemintegerfield): number
|
package/engine/behavior.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
3
|
+
import { Event } from "../event";
|
|
3
4
|
export type BehaviorConstructor<T extends Behavior<AnyNotNil>, Parameters extends any[] = any[]> = OmitConstructor<typeof Behavior<any>> & (abstract new (...parameters: Parameters) => T);
|
|
4
5
|
declare const enum BehaviorPropertyKey {
|
|
5
6
|
PREVIOUS_BEHAVIOR = 0,
|
|
@@ -13,6 +14,8 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
|
|
|
13
14
|
private [BehaviorPropertyKey.TIMER]?;
|
|
14
15
|
protected constructor(object: T);
|
|
15
16
|
protected onDestroy(): Destructor;
|
|
17
|
+
protected registerEvent<K extends string, Args extends any[]>(this: Behavior<any, PeriodicActionParameters> & Record<K, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, listener: K): void;
|
|
18
|
+
protected deregisterEvent(event: Event<any>): boolean;
|
|
16
19
|
protected onPeriod(...parameters: PeriodicActionParameters): void;
|
|
17
20
|
protected startPeriodicAction(interval: number, ...parameters: PeriodicActionParameters): void;
|
|
18
21
|
protected stopPeriodicAction(): void;
|
|
@@ -24,5 +27,7 @@ export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParame
|
|
|
24
27
|
static forFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, count: number, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
|
|
25
28
|
static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => unknown, ...parameters: ConsumerParameters): number;
|
|
26
29
|
static forAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], K extends KeysOfType<T, (this: T, ...args: any) => any>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, key: K, ...parameters: T[K] extends (this: T, ...args: any) => any ? Parameters<T[K]> : never): number;
|
|
30
|
+
static reduce<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[], Accumulator, R>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, operation: (this: void, accumulator: Accumulator, value: R) => Accumulator, initial: Accumulator, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => R, ...parameters: ConsumerParameters): Accumulator;
|
|
31
|
+
static reduce<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], Accumulator, R, K extends KeysOfType<T, (this: T, ...args: any) => R>>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, operation: (this: void, accumulator: Accumulator, value: R) => Accumulator, initial: Accumulator, key: K, ...parameters: T[K] extends (this: T, ...args: any) => R ? Parameters<T[K]> : never): Accumulator;
|
|
27
32
|
}
|
|
28
33
|
export {};
|