warscript 0.0.1-dev.6d8bd54 → 0.0.1-dev.6f7008d
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 +1 -0
- package/attributes.lua +9 -0
- package/core/types/timer.d.ts +3 -2
- package/core/types/timer.lua +8 -2
- package/engine/behaviour/unit/stun-immunity.d.ts +2 -0
- package/engine/behaviour/unit/stun-immunity.lua +11 -2
- package/engine/behaviour/unit.d.ts +2 -0
- package/engine/behaviour/unit.lua +5 -0
- package/engine/internal/item.d.ts +12 -12
- package/engine/internal/item.lua +41 -26
- package/engine/internal/unit/ability.d.ts +14 -14
- package/engine/internal/unit/ability.lua +72 -45
- package/engine/internal/unit/main-selected.lua +12 -27
- package/engine/internal/unit-missile-launch.lua +42 -21
- package/engine/internal/unit.d.ts +2 -0
- package/engine/internal/unit.lua +20 -10
- package/engine/object-data/entry/ability-type.lua +4 -1
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.lua +1 -1
- package/net/socket.lua +1 -1
- package/objutil/buff.lua +1 -1
- package/package.json +1 -1
- package/utility/arrays.d.ts +1 -0
- package/utility/arrays.lua +8 -0
- package/utility/callback-array.d.ts +5 -1
- package/utility/callback-array.lua +16 -1
- package/utility/linked-set.d.ts +1 -0
- package/utility/linked-set.lua +19 -1
- package/utility/lua-maps.d.ts +1 -1
- package/utility/types.d.ts +3 -0
package/attributes.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export declare namespace Attribute {
|
|
|
13
13
|
export declare class AttributesHolder {
|
|
14
14
|
readonly get: (<T>(attribute: Attribute<T>) => T | undefined) & LuaExtension<"TableGetMethod">;
|
|
15
15
|
readonly set: (<T>(attribute: Attribute<T>, value: T | undefined) => void) & LuaExtension<"TableSetMethod">;
|
|
16
|
+
getOrPut<T>(attribute: Attribute<T>, defaultValue: () => T): T;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
package/attributes.lua
CHANGED
|
@@ -20,4 +20,13 @@ local AttributesHolder = ____exports.AttributesHolder
|
|
|
20
20
|
AttributesHolder.name = "AttributesHolder"
|
|
21
21
|
function AttributesHolder.prototype.____constructor(self)
|
|
22
22
|
end
|
|
23
|
+
function AttributesHolder.prototype.getOrPut(self, attribute, defaultValue)
|
|
24
|
+
local value = self[attribute]
|
|
25
|
+
if value ~= nil then
|
|
26
|
+
return value
|
|
27
|
+
end
|
|
28
|
+
value = defaultValue()
|
|
29
|
+
self[attribute] = value
|
|
30
|
+
return value
|
|
31
|
+
end
|
|
23
32
|
return ____exports
|
package/core/types/timer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { Event } from "../../event";
|
|
3
3
|
import { AbstractDestroyable, Destructor } from "../../destroyable";
|
|
4
|
+
import { CallbackId } from "../../utility/callback-array";
|
|
4
5
|
declare const enum TimerPropertyKey {
|
|
5
6
|
HANDLE = 0,
|
|
6
7
|
DESTROY_ON_EXPIRATION = 1,
|
|
@@ -22,8 +23,8 @@ export declare class Timer extends AbstractDestroyable {
|
|
|
22
23
|
pause(): void;
|
|
23
24
|
resume(): void;
|
|
24
25
|
static create(): Timer;
|
|
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):
|
|
26
|
-
static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args):
|
|
26
|
+
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): CallbackId;
|
|
27
|
+
static run<Args extends any[]>(callback: (this: void, ...args: Args) => void, ...args: Args): CallbackId;
|
|
27
28
|
static simple<Args extends any[]>(timeout: number, callback: (...args: Args) => void, ...args: Args): Timer;
|
|
28
29
|
static periodic<Args extends any[]>(period: number, callback: (this: void, timer: Timer, ...args: Args) => void, ...args: Args): Timer;
|
|
29
30
|
static counted(period: number, count: number, callback: (this: void, timer: Timer) => void): Timer;
|
package/core/types/timer.lua
CHANGED
|
@@ -15,6 +15,7 @@ local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
|
15
15
|
local ____callback_2Darray = require("utility.callback-array")
|
|
16
16
|
local addCallback = ____callback_2Darray.addCallback
|
|
17
17
|
local callbackArray = ____callback_2Darray.callbackArray
|
|
18
|
+
local consumeCallback = ____callback_2Darray.consumeCallback
|
|
18
19
|
local consumeCallbacks = ____callback_2Darray.consumeCallbacks
|
|
19
20
|
local createTimer = CreateTimer
|
|
20
21
|
local timerStart = TimerStart
|
|
@@ -55,6 +56,11 @@ local function timerSafeCall()
|
|
|
55
56
|
end
|
|
56
57
|
local zeroTimerScheduled = false
|
|
57
58
|
local zeroTimerCallbacks = callbackArray()
|
|
59
|
+
---
|
|
60
|
+
-- @internal For use by internal systems only.
|
|
61
|
+
____exports.consumeZeroTimerCallback = function(id)
|
|
62
|
+
consumeCallback(zeroTimerCallbacks, id)
|
|
63
|
+
end
|
|
58
64
|
local function invokeZeroTimerCallbacks()
|
|
59
65
|
zeroTimerScheduled = false
|
|
60
66
|
consumeCallbacks(zeroTimerCallbacks)
|
|
@@ -98,9 +104,9 @@ function Timer.run(self, objectOrCallback, keyOrFirstArg, ...)
|
|
|
98
104
|
____exports.Timer:simple(0, invokeZeroTimerCallbacks)
|
|
99
105
|
end
|
|
100
106
|
if ____type(objectOrCallback) == "function" then
|
|
101
|
-
addCallback(zeroTimerCallbacks, objectOrCallback, keyOrFirstArg, ...)
|
|
107
|
+
return addCallback(zeroTimerCallbacks, objectOrCallback, keyOrFirstArg, ...)
|
|
102
108
|
else
|
|
103
|
-
addCallback(zeroTimerCallbacks, objectOrCallback[keyOrFirstArg], objectOrCallback, ...)
|
|
109
|
+
return addCallback(zeroTimerCallbacks, objectOrCallback[keyOrFirstArg], objectOrCallback, ...)
|
|
104
110
|
end
|
|
105
111
|
end
|
|
106
112
|
function Timer.simple(self, timeout, callback, ...)
|
|
@@ -8,6 +8,7 @@ export type StunImmunityUnitBehaviourParameters = {
|
|
|
8
8
|
buffTypeIds?: LuaSet<BuffTypeId>;
|
|
9
9
|
textTagPreset?: TextTagPreset;
|
|
10
10
|
textTagText?: string;
|
|
11
|
+
additionalAction?: (this: void, unit: Unit) => void;
|
|
11
12
|
};
|
|
12
13
|
export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
13
14
|
readonly parameters: Readonly<StunImmunityUnitBehaviourParameters>;
|
|
@@ -17,4 +18,5 @@ export declare class StunImmunityUnitBehavior extends UnitBehavior {
|
|
|
17
18
|
onDamageReceived(): void;
|
|
18
19
|
onTargetingAbilityChannelingStart(): void;
|
|
19
20
|
onTargetingAbilityImpact(): void;
|
|
21
|
+
protected onEffect(): void;
|
|
20
22
|
}
|
|
@@ -48,8 +48,15 @@ local function process(behavior)
|
|
|
48
48
|
for buffTypeId in pairs(behavior.parameters.buffTypeIds or DEFAULT_BUFF_TYPE_IDS) do
|
|
49
49
|
hasRemovedBuffs = hasRemovedBuffs or behavior.unit:removeBuff(buffTypeId)
|
|
50
50
|
end
|
|
51
|
-
if hasRemovedBuffs
|
|
52
|
-
|
|
51
|
+
if hasRemovedBuffs then
|
|
52
|
+
behavior.onEffect(behavior)
|
|
53
|
+
if behavior.parameters.textTagText ~= nil then
|
|
54
|
+
TextTag:flash(TextTag.MISS, behavior.parameters.textTagText, behavior.unit.x, behavior.unit.y)
|
|
55
|
+
end
|
|
56
|
+
local ____opt_0 = behavior.parameters.additionalAction
|
|
57
|
+
if ____opt_0 ~= nil then
|
|
58
|
+
____opt_0(behavior.unit)
|
|
59
|
+
end
|
|
53
60
|
end
|
|
54
61
|
end
|
|
55
62
|
____exports.StunImmunityUnitBehavior = __TS__Class()
|
|
@@ -79,5 +86,7 @@ end
|
|
|
79
86
|
function StunImmunityUnitBehavior.prototype.onTargetingAbilityImpact(self)
|
|
80
87
|
process(self)
|
|
81
88
|
end
|
|
89
|
+
function StunImmunityUnitBehavior.prototype.onEffect(self)
|
|
90
|
+
end
|
|
82
91
|
StunImmunityUnitBehavior.defaultParameters = {buffTypeIds = DEFAULT_BUFF_TYPE_IDS, textTagPreset = TextTag.MISS, textTagText = nil}
|
|
83
92
|
return ____exports
|
|
@@ -12,6 +12,7 @@ import type { Widget } from "../../core/types/widget";
|
|
|
12
12
|
import { Destructable } from "../../core/types/destructable";
|
|
13
13
|
import type { Buff } from "../buff";
|
|
14
14
|
import { UnitBonusType } from "../internal/unit/bonus";
|
|
15
|
+
import { Player } from "../../core/types/player";
|
|
15
16
|
export type UnitBehaviorConstructor<Args extends any[]> = new (unit: Unit, ...args: Args) => UnitBehavior;
|
|
16
17
|
export declare abstract class UnitBehavior<PeriodicActionParameters extends any[] = any[]> extends Behavior<Unit, PeriodicActionParameters> {
|
|
17
18
|
readonly sourceAbilityBehavior?: AbilityBehavior;
|
|
@@ -55,4 +56,5 @@ export declare abstract class UnitBehavior<PeriodicActionParameters extends any[
|
|
|
55
56
|
onItemChargesChanged(item: Item): void;
|
|
56
57
|
onKill(target: Unit): void;
|
|
57
58
|
onDeath(source: Unit | undefined): void;
|
|
59
|
+
onOwnerChange(previousOwner: Player): void;
|
|
58
60
|
}
|
|
@@ -165,6 +165,8 @@ function UnitBehavior.prototype.onKill(self, target)
|
|
|
165
165
|
end
|
|
166
166
|
function UnitBehavior.prototype.onDeath(self, source)
|
|
167
167
|
end
|
|
168
|
+
function UnitBehavior.prototype.onOwnerChange(self, previousOwner)
|
|
169
|
+
end
|
|
168
170
|
__TS__SetDescriptor(
|
|
169
171
|
UnitBehavior.prototype,
|
|
170
172
|
"unit",
|
|
@@ -276,6 +278,9 @@ __TS__SetDescriptor(
|
|
|
276
278
|
Unit.itemChargesChangedEvent:addListener(function(unit, item)
|
|
277
279
|
____exports.UnitBehavior:forAll(unit, "onItemChargesChanged", item)
|
|
278
280
|
end)
|
|
281
|
+
Unit.onOwnerChange:addListener(function(unit, previousOwner)
|
|
282
|
+
____exports.UnitBehavior:forAll(unit, "onOwnerChange", previousOwner)
|
|
283
|
+
end)
|
|
279
284
|
end)(UnitBehavior)
|
|
280
285
|
Unit.destroyEvent:addListener(function(unit)
|
|
281
286
|
____exports.UnitBehavior:forAll(unit, "destroy")
|
|
@@ -28,22 +28,22 @@ export declare class Item extends Handle<jitem> {
|
|
|
28
28
|
get extendedTooltip(): string;
|
|
29
29
|
set iconPath(v: string);
|
|
30
30
|
get iconPath(): string;
|
|
31
|
-
set
|
|
32
|
-
get
|
|
33
|
-
set
|
|
34
|
-
get
|
|
35
|
-
set
|
|
36
|
-
get
|
|
37
|
-
set
|
|
38
|
-
get
|
|
39
|
-
set
|
|
40
|
-
get
|
|
31
|
+
set dropsOnDeath(dropsOnDeath: boolean);
|
|
32
|
+
get dropsOnDeath(): boolean;
|
|
33
|
+
set canBeDropped(canBeDropped: boolean);
|
|
34
|
+
get canBeDropped(): boolean;
|
|
35
|
+
set canBeSold(canBeSold: boolean);
|
|
36
|
+
get canBeSold(): boolean;
|
|
37
|
+
set perishes(perishes: boolean);
|
|
38
|
+
get perishes(): boolean;
|
|
39
|
+
set isPowerUp(isPowerUp: boolean);
|
|
40
|
+
get isPowerUp(): boolean;
|
|
41
41
|
get isAlive(): boolean;
|
|
42
42
|
get isDead(): boolean;
|
|
43
43
|
set isInvulnerable(isInvulnerable: boolean);
|
|
44
44
|
get isInvulnerable(): boolean;
|
|
45
|
-
set
|
|
46
|
-
get
|
|
45
|
+
set isActivelyUsed(isActivelyUsed: boolean);
|
|
46
|
+
get isActivelyUsed(): boolean;
|
|
47
47
|
set visible(v: boolean);
|
|
48
48
|
get visible(): boolean;
|
|
49
49
|
set level(v: number);
|
package/engine/internal/item.lua
CHANGED
|
@@ -50,6 +50,13 @@ local unitRemoveItem = UnitRemoveItem
|
|
|
50
50
|
local unitUseItem = UnitUseItem
|
|
51
51
|
local unitUseItemPoint = UnitUseItemPoint
|
|
52
52
|
local unitUseItemTarget = UnitUseItemTarget
|
|
53
|
+
local setItemDropOnDeath = SetItemDropOnDeath
|
|
54
|
+
local setItemDroppable = SetItemDroppable
|
|
55
|
+
local setItemPawnable = SetItemPawnable
|
|
56
|
+
local isItemPawnable = IsItemPawnable
|
|
57
|
+
local getItemIntegerField = BlzGetItemIntegerField
|
|
58
|
+
local setItemBooleanField = BlzSetItemBooleanField
|
|
59
|
+
local getItemBooleanField = BlzGetItemBooleanField
|
|
53
60
|
local tableRemove = table.remove
|
|
54
61
|
_G.SetItemCharges = function(whichItem, charges)
|
|
55
62
|
setItemCharges(whichItem, charges)
|
|
@@ -58,9 +65,6 @@ _G.SetItemCharges = function(whichItem, charges)
|
|
|
58
65
|
____exports.Item:of(whichItem)
|
|
59
66
|
)
|
|
60
67
|
end
|
|
61
|
-
local getItemIntegerField = BlzGetItemIntegerField
|
|
62
|
-
local setItemBooleanField = BlzSetItemBooleanField
|
|
63
|
-
local getItemBooleanField = BlzGetItemBooleanField
|
|
64
68
|
invoke = Event.invoke
|
|
65
69
|
local enumRect = Rect:create(0, 0, 0, 0).handle
|
|
66
70
|
---
|
|
@@ -328,65 +332,68 @@ __TS__SetDescriptor(
|
|
|
328
332
|
)
|
|
329
333
|
__TS__SetDescriptor(
|
|
330
334
|
Item.prototype,
|
|
331
|
-
"
|
|
335
|
+
"dropsOnDeath",
|
|
332
336
|
{
|
|
333
337
|
get = function(self)
|
|
334
|
-
return
|
|
338
|
+
return getItemBooleanField(self.handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
335
339
|
end,
|
|
336
|
-
set = function(self,
|
|
337
|
-
|
|
340
|
+
set = function(self, dropsOnDeath)
|
|
341
|
+
setItemDropOnDeath(self.handle, dropsOnDeath)
|
|
338
342
|
end
|
|
339
343
|
},
|
|
340
344
|
true
|
|
341
345
|
)
|
|
342
346
|
__TS__SetDescriptor(
|
|
343
347
|
Item.prototype,
|
|
344
|
-
"
|
|
348
|
+
"canBeDropped",
|
|
345
349
|
{
|
|
346
350
|
get = function(self)
|
|
347
|
-
return
|
|
351
|
+
return getItemBooleanField(self.handle, ITEM_BF_CAN_BE_DROPPED)
|
|
348
352
|
end,
|
|
349
|
-
set = function(self,
|
|
350
|
-
|
|
353
|
+
set = function(self, canBeDropped)
|
|
354
|
+
setItemDroppable(self.handle, canBeDropped)
|
|
351
355
|
end
|
|
352
356
|
},
|
|
353
357
|
true
|
|
354
358
|
)
|
|
355
359
|
__TS__SetDescriptor(
|
|
356
360
|
Item.prototype,
|
|
357
|
-
"
|
|
361
|
+
"canBeSold",
|
|
358
362
|
{
|
|
359
363
|
get = function(self)
|
|
360
|
-
return
|
|
364
|
+
return isItemPawnable(self.handle)
|
|
361
365
|
end,
|
|
362
|
-
set = function(self,
|
|
363
|
-
|
|
366
|
+
set = function(self, canBeSold)
|
|
367
|
+
setItemPawnable(self.handle, canBeSold)
|
|
364
368
|
end
|
|
365
369
|
},
|
|
366
370
|
true
|
|
367
371
|
)
|
|
368
372
|
__TS__SetDescriptor(
|
|
369
373
|
Item.prototype,
|
|
370
|
-
"
|
|
374
|
+
"perishes",
|
|
371
375
|
{
|
|
372
376
|
get = function(self)
|
|
373
377
|
return getItemBooleanField(self.handle, ITEM_BF_PERISHABLE)
|
|
374
378
|
end,
|
|
375
|
-
set = function(self,
|
|
376
|
-
|
|
379
|
+
set = function(self, perishes)
|
|
380
|
+
local handle = self.handle
|
|
381
|
+
local powerUp = isItemPowerup(handle)
|
|
382
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
383
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
377
384
|
end
|
|
378
385
|
},
|
|
379
386
|
true
|
|
380
387
|
)
|
|
381
388
|
__TS__SetDescriptor(
|
|
382
389
|
Item.prototype,
|
|
383
|
-
"
|
|
390
|
+
"isPowerUp",
|
|
384
391
|
{
|
|
385
392
|
get = function(self)
|
|
386
393
|
return isItemPowerup(self.handle)
|
|
387
394
|
end,
|
|
388
|
-
set = function(self,
|
|
389
|
-
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED,
|
|
395
|
+
set = function(self, isPowerUp)
|
|
396
|
+
setItemBooleanField(self.handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, isPowerUp)
|
|
390
397
|
end
|
|
391
398
|
},
|
|
392
399
|
true
|
|
@@ -422,16 +429,24 @@ __TS__SetDescriptor(
|
|
|
422
429
|
)
|
|
423
430
|
__TS__SetDescriptor(
|
|
424
431
|
Item.prototype,
|
|
425
|
-
"
|
|
432
|
+
"isActivelyUsed",
|
|
426
433
|
{
|
|
427
434
|
get = function(self)
|
|
428
435
|
return getItemBooleanField(self.handle, ITEM_BF_ACTIVELY_USED)
|
|
429
436
|
end,
|
|
430
|
-
set = function(self,
|
|
437
|
+
set = function(self, isActivelyUsed)
|
|
431
438
|
local handle = self.handle
|
|
432
|
-
local
|
|
433
|
-
|
|
434
|
-
|
|
439
|
+
local powerUp = isItemPowerup(handle)
|
|
440
|
+
local perishes = getItemBooleanField(handle, ITEM_BF_PERISHABLE)
|
|
441
|
+
local dropsOnDeath = getItemBooleanField(handle, ITEM_BF_DROPPED_WHEN_CARRIER_DIES)
|
|
442
|
+
local canBeDropped = getItemBooleanField(handle, ITEM_BF_CAN_BE_DROPPED)
|
|
443
|
+
local canBeSold = isItemPawnable(handle)
|
|
444
|
+
setItemBooleanField(handle, ITEM_BF_ACTIVELY_USED, isActivelyUsed)
|
|
445
|
+
setItemPawnable(handle, canBeSold)
|
|
446
|
+
setItemDroppable(handle, canBeDropped)
|
|
447
|
+
setItemDropOnDeath(handle, dropsOnDeath)
|
|
448
|
+
setItemBooleanField(handle, ITEM_BF_PERISHABLE, perishes)
|
|
449
|
+
setItemBooleanField(handle, ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED, powerUp)
|
|
435
450
|
end
|
|
436
451
|
},
|
|
437
452
|
true
|
|
@@ -133,55 +133,55 @@ declare module "../unit" {
|
|
|
133
133
|
}
|
|
134
134
|
declare module "../unit" {
|
|
135
135
|
namespace Unit {
|
|
136
|
-
const
|
|
136
|
+
const abilityChannelingFinishEvent: DispatchingEvent<[Unit, Ability]>;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
declare module "../unit" {
|
|
140
140
|
namespace Unit {
|
|
141
|
-
const
|
|
141
|
+
const abilityStopEvent: DispatchingEvent<[Unit, Ability]>;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
declare module "../unit" {
|
|
145
145
|
namespace Unit {
|
|
146
|
-
const
|
|
146
|
+
const abilityCommandEvent: {
|
|
147
|
+
readonly [abilityTypeId: number]: {
|
|
148
|
+
readonly [orderTypeStringId: string]: Event<[Unit, Ability, string]>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
153
|
declare module "../unit" {
|
|
150
154
|
namespace Unit {
|
|
151
|
-
const
|
|
155
|
+
const abilityImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
declare module "../unit" {
|
|
155
159
|
namespace Unit {
|
|
156
|
-
const
|
|
160
|
+
const abilityWidgetTargetImpactEvent: DispatchingEvent<[Unit, Ability, Widget]>;
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
declare module "../unit" {
|
|
160
164
|
namespace Unit {
|
|
161
|
-
const
|
|
165
|
+
const abilityUnitTargetImpactEvent: DispatchingEvent<[Unit, Ability, Unit]>;
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
declare module "../unit" {
|
|
165
169
|
namespace Unit {
|
|
166
|
-
const
|
|
170
|
+
const abilityItemTargetImpactEvent: DispatchingEvent<[Unit, Ability, Item]>;
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
declare module "../unit" {
|
|
170
174
|
namespace Unit {
|
|
171
|
-
const
|
|
175
|
+
const abilityDestructibleTargetImpactEvent: DispatchingEvent<[Unit, Ability, Destructable]>;
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
declare module "../unit" {
|
|
175
179
|
namespace Unit {
|
|
176
|
-
const
|
|
180
|
+
const abilityPointTargetImpactEvent: DispatchingEvent<[Unit, Ability, number, number]>;
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
declare module "../unit" {
|
|
180
184
|
namespace Unit {
|
|
181
|
-
const
|
|
182
|
-
readonly [abilityTypeId: number]: {
|
|
183
|
-
readonly [orderTypeStringId: string]: Event<[Unit, Ability, string]>;
|
|
184
|
-
};
|
|
185
|
-
};
|
|
185
|
+
const abilityNoTargetImpactEvent: DispatchingEvent<[Unit, Ability]>;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -22,7 +22,12 @@ local checkNotNull = ____preconditions.checkNotNull
|
|
|
22
22
|
local ____lazy = require("utility.lazy")
|
|
23
23
|
local lazyRecord = ____lazy.lazyRecord
|
|
24
24
|
local ____timer = require("core.types.timer")
|
|
25
|
+
local consumeZeroTimerCallback = ____timer.consumeZeroTimerCallback
|
|
25
26
|
local Timer = ____timer.Timer
|
|
27
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
28
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
29
|
+
local ____attributes = require("attributes")
|
|
30
|
+
local attribute = ____attributes.attribute
|
|
26
31
|
local eventInvoke = Event.invoke
|
|
27
32
|
local condition = Condition
|
|
28
33
|
local createTrigger = CreateTrigger
|
|
@@ -347,10 +352,65 @@ rawset(
|
|
|
347
352
|
extractAbilityTypeId
|
|
348
353
|
)
|
|
349
354
|
)
|
|
355
|
+
local internalAbilityChannelingFinishEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_FINISH, collectUnitAbilityEventParameters)
|
|
356
|
+
rawset(
|
|
357
|
+
Unit,
|
|
358
|
+
"abilityChannelingFinishEvent",
|
|
359
|
+
createDispatchingEvent(internalAbilityChannelingFinishEvent, extractAbilityTypeId)
|
|
360
|
+
)
|
|
361
|
+
local internalAbilityStopEvent = __TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters)
|
|
362
|
+
rawset(
|
|
363
|
+
Unit,
|
|
364
|
+
"abilityStopEvent",
|
|
365
|
+
createDispatchingEvent(internalAbilityStopEvent, extractAbilityTypeId)
|
|
366
|
+
)
|
|
367
|
+
rawset(
|
|
368
|
+
Unit,
|
|
369
|
+
"abilityCommandEvent",
|
|
370
|
+
lazyRecord(function(abilityTypeId)
|
|
371
|
+
return lazyRecord(function(orderTypeStringId)
|
|
372
|
+
return __TS__New(
|
|
373
|
+
InitializingEvent,
|
|
374
|
+
function(event)
|
|
375
|
+
local trigger = createTrigger()
|
|
376
|
+
triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
|
|
377
|
+
triggerAddCondition(
|
|
378
|
+
trigger,
|
|
379
|
+
condition(function()
|
|
380
|
+
local unit = Unit:of(getTriggerUnit())
|
|
381
|
+
if unit ~= nil then
|
|
382
|
+
local ability = unit:getAbility(abilityTypeId)
|
|
383
|
+
if ability ~= nil then
|
|
384
|
+
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
end)
|
|
388
|
+
)
|
|
389
|
+
end
|
|
390
|
+
)
|
|
391
|
+
end)
|
|
392
|
+
end)
|
|
393
|
+
)
|
|
350
394
|
local internalAbilityImpactEvent = __TS__New(Event)
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
395
|
+
local impactCallbackIdAttribute = attribute()
|
|
396
|
+
local function invokeImpactEvent(unit, ability, ...)
|
|
397
|
+
ability[impactCallbackIdAttribute] = nil
|
|
398
|
+
eventInvoke(internalAbilityImpactEvent, unit, ability, ...)
|
|
399
|
+
end
|
|
400
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
401
|
+
999999,
|
|
402
|
+
function(unit, ability, ...)
|
|
403
|
+
ability[impactCallbackIdAttribute] = Timer:run(invokeImpactEvent, unit, ability, ...)
|
|
404
|
+
end
|
|
405
|
+
)
|
|
406
|
+
local function consumeImpactCallback(_, ability)
|
|
407
|
+
local impactCallbackId = ability[impactCallbackIdAttribute]
|
|
408
|
+
if impactCallbackId ~= nil then
|
|
409
|
+
consumeZeroTimerCallback(impactCallbackId)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
internalAbilityChannelingFinishEvent:addListener(999999, consumeImpactCallback)
|
|
413
|
+
internalAbilityStopEvent:addListener(999999, consumeImpactCallback)
|
|
354
414
|
rawset(
|
|
355
415
|
Unit,
|
|
356
416
|
"abilityImpactEvent",
|
|
@@ -407,47 +467,14 @@ rawset(
|
|
|
407
467
|
extractAbilityTypeId
|
|
408
468
|
)
|
|
409
469
|
)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
Unit,
|
|
420
|
-
"abilityStopEvent",
|
|
421
|
-
createDispatchingEvent(
|
|
422
|
-
__TS__New(UnitTriggerEvent, EVENT_PLAYER_UNIT_SPELL_ENDCAST, collectUnitAbilityEventParameters),
|
|
423
|
-
extractAbilityTypeId
|
|
424
|
-
)
|
|
425
|
-
)
|
|
426
|
-
rawset(
|
|
427
|
-
Unit,
|
|
428
|
-
"abilityCommandEvent",
|
|
429
|
-
lazyRecord(function(abilityTypeId)
|
|
430
|
-
return lazyRecord(function(orderTypeStringId)
|
|
431
|
-
return __TS__New(
|
|
432
|
-
InitializingEvent,
|
|
433
|
-
function(event)
|
|
434
|
-
local trigger = createTrigger()
|
|
435
|
-
triggerRegisterCommandEvent(trigger, abilityTypeId, orderTypeStringId)
|
|
436
|
-
triggerAddCondition(
|
|
437
|
-
trigger,
|
|
438
|
-
condition(function()
|
|
439
|
-
local unit = Unit:of(getTriggerUnit())
|
|
440
|
-
if unit ~= nil then
|
|
441
|
-
local ability = unit:getAbility(abilityTypeId)
|
|
442
|
-
if ability ~= nil then
|
|
443
|
-
eventInvoke(event, unit, ability, orderTypeStringId)
|
|
444
|
-
end
|
|
445
|
-
end
|
|
446
|
-
end)
|
|
447
|
-
)
|
|
448
|
-
end
|
|
449
|
-
)
|
|
450
|
-
end)
|
|
451
|
-
end)
|
|
470
|
+
local spellEffectOnlyAbilityTypeIds = luaSetOf(fourCC("AAns"))
|
|
471
|
+
internalAbilityChannelingStartEvent:addListener(
|
|
472
|
+
-999999,
|
|
473
|
+
function(unit, ability)
|
|
474
|
+
if spellEffectOnlyAbilityTypeIds[ability.parentTypeId] ~= nil then
|
|
475
|
+
eventInvoke(internalAbilityChannelingFinishEvent, unit, ability)
|
|
476
|
+
eventInvoke(internalAbilityStopEvent, unit, ability)
|
|
477
|
+
end
|
|
478
|
+
end
|
|
452
479
|
)
|
|
453
480
|
return ____exports
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__New = ____lualib.__TS__New
|
|
3
3
|
local ____exports = {}
|
|
4
|
-
local ____player = require("core.types.player")
|
|
5
|
-
local Player = ____player.Player
|
|
6
|
-
local ____math = require("math")
|
|
7
|
-
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
8
|
-
local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
|
|
9
4
|
local ____local_2Dclient = require("engine.local-client")
|
|
10
5
|
local LocalClient = ____local_2Dclient.LocalClient
|
|
11
6
|
local ____unit = require("engine.internal.unit")
|
|
12
7
|
local Unit = ____unit.Unit
|
|
13
8
|
local ____event = require("event")
|
|
14
9
|
local Event = ____event.Event
|
|
10
|
+
local ____synchronization = require("engine.synchronization")
|
|
11
|
+
local ObjectBus = ____synchronization.ObjectBus
|
|
15
12
|
local mainSelectedUnitChangeEvent = __TS__New(Event)
|
|
16
13
|
rawset(Unit, "mainSelectedUnitChangeEvent", mainSelectedUnitChangeEvent)
|
|
17
14
|
local mainSelectedUnitByPlayer = {}
|
|
18
|
-
local
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"",
|
|
23
|
-
0
|
|
15
|
+
local unitBus = __TS__New(
|
|
16
|
+
ObjectBus,
|
|
17
|
+
function(unit) return unit.syncId end,
|
|
18
|
+
function(syncId) return Unit:getBySyncId(syncId) end
|
|
24
19
|
)
|
|
25
|
-
BlzFrameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
26
20
|
LocalClient.mainSelectedUnitChangeEvent:addListener(function()
|
|
27
|
-
|
|
28
|
-
local syncId = ____opt_0 and ____opt_0.syncId
|
|
29
|
-
BlzFrameSetValue(syncSlider, syncId or 0)
|
|
21
|
+
unitBus:send(LocalClient.mainSelectedUnit)
|
|
30
22
|
end)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function()
|
|
36
|
-
local player = Player:of(GetTriggerPlayer())
|
|
37
|
-
local mainSelectedUnit = Unit:getBySyncId(BlzGetTriggerFrameValue())
|
|
38
|
-
if mainSelectedUnit ~= mainSelectedUnitByPlayer[player] then
|
|
39
|
-
mainSelectedUnitByPlayer[player] = mainSelectedUnit
|
|
40
|
-
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
41
|
-
end
|
|
23
|
+
unitBus.event:addListener(function(player, unit)
|
|
24
|
+
if unit ~= mainSelectedUnitByPlayer[player] then
|
|
25
|
+
mainSelectedUnitByPlayer[player] = unit
|
|
26
|
+
Event.invoke(mainSelectedUnitChangeEvent, player)
|
|
42
27
|
end
|
|
43
|
-
)
|
|
28
|
+
end)
|
|
44
29
|
rawset(
|
|
45
30
|
Unit,
|
|
46
31
|
"getMainSelectedOf",
|
|
@@ -9,11 +9,16 @@ local ____timer = require("core.types.timer")
|
|
|
9
9
|
local Timer = ____timer.Timer
|
|
10
10
|
local ____lua_2Dsets = require("utility.lua-sets")
|
|
11
11
|
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
12
|
-
local
|
|
13
|
-
local
|
|
12
|
+
local ____attributes = require("attributes")
|
|
13
|
+
local attribute = ____attributes.attribute
|
|
14
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
15
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
14
16
|
local autoAttackFinishEvent = __TS__New(Event)
|
|
15
17
|
rawset(Unit, "autoAttackFinishEvent", autoAttackFinishEvent)
|
|
16
|
-
local
|
|
18
|
+
local units = __TS__New(LinkedSet)
|
|
19
|
+
local targetAttribute = attribute()
|
|
20
|
+
local impactDelayAttribute = attribute()
|
|
21
|
+
local passedTimeAttribute = attribute()
|
|
17
22
|
local instantOrderIds = luaSetOf(
|
|
18
23
|
orderId("avatar"),
|
|
19
24
|
orderId("berserk"),
|
|
@@ -30,29 +35,45 @@ local instantOrderIds = luaSetOf(
|
|
|
30
35
|
orderId("unimmolation")
|
|
31
36
|
)
|
|
32
37
|
local function reset(source, orderId)
|
|
33
|
-
if not (instantOrderIds[orderId] ~= nil) then
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
eventTimerByUnit[source] = nil
|
|
38
|
-
end
|
|
38
|
+
if not (instantOrderIds[orderId] ~= nil) and units:remove(source) then
|
|
39
|
+
source[targetAttribute] = nil
|
|
40
|
+
source[impactDelayAttribute] = nil
|
|
41
|
+
source[passedTimeAttribute] = nil
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
44
|
Unit.onImmediateOrder:addListener(reset)
|
|
42
45
|
Unit.onPointOrder:addListener(reset)
|
|
43
46
|
Unit.onTargetOrder:addListener(reset)
|
|
44
|
-
local
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
local timerPeriod = 1 / 64
|
|
48
|
+
local function invokeEvent(unit)
|
|
49
|
+
units:remove(unit)
|
|
50
|
+
local target = unit[targetAttribute]
|
|
51
|
+
unit[targetAttribute] = nil
|
|
52
|
+
unit[impactDelayAttribute] = nil
|
|
53
|
+
unit[passedTimeAttribute] = nil
|
|
54
|
+
Event.invoke(autoAttackFinishEvent, unit, target)
|
|
55
|
+
end
|
|
56
|
+
local function checkUnit(unit)
|
|
57
|
+
local passedTime = unit[passedTimeAttribute] + timerPeriod
|
|
58
|
+
if passedTime >= unit[impactDelayAttribute] then
|
|
59
|
+
invokeEvent(unit)
|
|
60
|
+
else
|
|
61
|
+
unit[passedTimeAttribute] = passedTime
|
|
62
|
+
end
|
|
47
63
|
end
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
local timer = Timer:simple(
|
|
51
|
-
attackPoint + min(0.001, attackPoint / 2),
|
|
52
|
-
timerCallback,
|
|
53
|
-
source,
|
|
54
|
-
target
|
|
55
|
-
)
|
|
56
|
-
eventTimerByUnit[source] = timer
|
|
64
|
+
Timer.onPeriod[timerPeriod]:addListener(function()
|
|
65
|
+
units:forEach(checkUnit)
|
|
57
66
|
end)
|
|
67
|
+
Unit.autoAttackStartEvent:addListener(
|
|
68
|
+
999999,
|
|
69
|
+
function(source, target)
|
|
70
|
+
if source[targetAttribute] ~= nil then
|
|
71
|
+
invokeEvent(source)
|
|
72
|
+
end
|
|
73
|
+
source[targetAttribute] = target
|
|
74
|
+
source[impactDelayAttribute] = (source:chooseWeapon(target) or source.firstWeapon).impactDelay
|
|
75
|
+
source[passedTimeAttribute] = -timerPeriod
|
|
76
|
+
units:add(source)
|
|
77
|
+
end
|
|
78
|
+
)
|
|
58
79
|
return ____exports
|
|
@@ -80,6 +80,8 @@ export declare class UnitWeapon {
|
|
|
80
80
|
readonly unit: Unit;
|
|
81
81
|
readonly index: 0 | 1;
|
|
82
82
|
constructor(unit: Unit, index: 0 | 1);
|
|
83
|
+
get isEnabled(): boolean;
|
|
84
|
+
set isEnabled(isEnabled: boolean);
|
|
83
85
|
get cooldown(): number;
|
|
84
86
|
set cooldown(cooldown: number);
|
|
85
87
|
get damage(): [minimumDamage: number, maximumDamage: number];
|
package/engine/internal/unit.lua
CHANGED
|
@@ -410,6 +410,19 @@ function UnitWeapon.prototype.____constructor(self, unit, index)
|
|
|
410
410
|
self.unit = unit
|
|
411
411
|
self.index = index
|
|
412
412
|
end
|
|
413
|
+
__TS__SetDescriptor(
|
|
414
|
+
UnitWeapon.prototype,
|
|
415
|
+
"isEnabled",
|
|
416
|
+
{
|
|
417
|
+
get = function(self)
|
|
418
|
+
return BlzGetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index)
|
|
419
|
+
end,
|
|
420
|
+
set = function(self, isEnabled)
|
|
421
|
+
BlzSetUnitWeaponBooleanField(self.unit.handle, UNIT_WEAPON_BF_ATTACKS_ENABLED, self.index, isEnabled)
|
|
422
|
+
end
|
|
423
|
+
},
|
|
424
|
+
true
|
|
425
|
+
)
|
|
413
426
|
__TS__SetDescriptor(
|
|
414
427
|
UnitWeapon.prototype,
|
|
415
428
|
"cooldown",
|
|
@@ -836,11 +849,13 @@ function Unit.prototype.queueAnimation(self, animation)
|
|
|
836
849
|
QueueUnitAnimation(self.handle, animation)
|
|
837
850
|
end
|
|
838
851
|
function Unit.prototype.chooseWeapon(self, target)
|
|
839
|
-
|
|
840
|
-
|
|
852
|
+
local firstWeapon = self.firstWeapon
|
|
853
|
+
if firstWeapon.isEnabled and target:isAllowedTarget(self, firstWeapon.allowedTargetCombatClassifications) then
|
|
854
|
+
return firstWeapon
|
|
841
855
|
end
|
|
842
|
-
|
|
843
|
-
|
|
856
|
+
local secondWeapon = self.secondWeapon
|
|
857
|
+
if secondWeapon.isEnabled and target:isAllowedTarget(target, secondWeapon.allowedTargetCombatClassifications) then
|
|
858
|
+
return secondWeapon
|
|
844
859
|
end
|
|
845
860
|
return nil
|
|
846
861
|
end
|
|
@@ -2468,12 +2483,7 @@ Unit.onDamaging = (function()
|
|
|
2468
2483
|
preventRetaliation = damagingEventPreventRetaliation
|
|
2469
2484
|
}
|
|
2470
2485
|
if data.isAttack and source then
|
|
2471
|
-
|
|
2472
|
-
if weapon == -1 then
|
|
2473
|
-
local targetsAllowed = BlzGetUnitWeaponIntegerField(source.handle, UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED, 0)
|
|
2474
|
-
weapon = 0
|
|
2475
|
-
end
|
|
2476
|
-
data.weapon = assert(source.weapons[weapon + 1])
|
|
2486
|
+
data.weapon = source:chooseWeapon(target)
|
|
2477
2487
|
end
|
|
2478
2488
|
if not data.isAttack or not source or not source._attackHandlers then
|
|
2479
2489
|
invoke(
|
|
@@ -38,6 +38,8 @@ local ____sound = require("core.types.sound")
|
|
|
38
38
|
local isSoundLabelCustom = ____sound.isSoundLabelCustom
|
|
39
39
|
local Sound3D = ____sound.Sound3D
|
|
40
40
|
local SoundSettings = ____sound.SoundSettings
|
|
41
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
42
|
+
local luaSetOf = ____lua_2Dsets.luaSetOf
|
|
41
43
|
local castAnimationFQNByAbilityTypeId = {}
|
|
42
44
|
local isButtonVisibleFalseAbilityTypes = {}
|
|
43
45
|
local casterCastingEffectPresetsByAbilityTypeId = {}
|
|
@@ -1004,9 +1006,10 @@ for abilityTypeId, soundPresetId in pairs(postcompile(function() return targetEf
|
|
|
1004
1006
|
)
|
|
1005
1007
|
end
|
|
1006
1008
|
end
|
|
1009
|
+
local unsupportedEffectSoundAbilityTypeIds = luaSetOf(fourCC("AAns"))
|
|
1007
1010
|
Unit.abilityChannelingStartEvent:addListener(function(caster, ability)
|
|
1008
1011
|
local soundPresetId = ability:getField(ABILITY_SF_EFFECT_SOUND)
|
|
1009
|
-
if isSoundLabelCustom(soundPresetId) then
|
|
1012
|
+
if isSoundLabelCustom(soundPresetId) or soundPresetId ~= "" and unsupportedEffectSoundAbilityTypeIds[ability.parentTypeId] ~= nil then
|
|
1010
1013
|
Sound3D:playFromLabel(soundPresetId, SoundSettings.Ability, caster)
|
|
1011
1014
|
end
|
|
1012
1015
|
end)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { Player } from "../core/types/player";
|
|
3
|
+
import { Event } from "../event";
|
|
4
|
+
export declare const synchronizer: <T, K extends number>(getSyncId: (object: T) => K, getObject: (syncId: K) => T | undefined) => ((player: Player, object: T | undefined) => Promise<T | undefined>);
|
|
5
|
+
export declare class ObjectBus<T, K extends number> {
|
|
6
|
+
private readonly getSyncId;
|
|
7
|
+
readonly event: Event<[Player, T | undefined]>;
|
|
8
|
+
private readonly syncSlider;
|
|
9
|
+
constructor(getSyncId: (object: T) => K, getObject: (syncId: K) => T | undefined);
|
|
10
|
+
send(object: T | undefined): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__New = ____lualib.__TS__New
|
|
3
|
+
local __TS__Promise = ____lualib.__TS__Promise
|
|
4
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____player = require("core.types.player")
|
|
7
|
+
local Player = ____player.Player
|
|
8
|
+
local ____math = require("math")
|
|
9
|
+
local MAXIMUM_INTEGER = ____math.MAXIMUM_INTEGER
|
|
10
|
+
local MINIMUM_INTEGER = ____math.MINIMUM_INTEGER
|
|
11
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
12
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
13
|
+
local ____event = require("event")
|
|
14
|
+
local Event = ____event.Event
|
|
15
|
+
local eventInvoke = Event.invoke
|
|
16
|
+
local createFrameByType = BlzCreateFrameByType
|
|
17
|
+
local createTrigger = CreateTrigger
|
|
18
|
+
local getOriginFrame = BlzGetOriginFrame
|
|
19
|
+
local getTriggerFrameValue = BlzGetTriggerFrameValue
|
|
20
|
+
local getTriggerPlayer = GetTriggerPlayer
|
|
21
|
+
local frameSetMinMaxValue = BlzFrameSetMinMaxValue
|
|
22
|
+
local frameSetValue = BlzFrameSetValue
|
|
23
|
+
local triggerAddAction = TriggerAddAction
|
|
24
|
+
local triggerRegisterFrameEvent = BlzTriggerRegisterFrameEvent
|
|
25
|
+
____exports.synchronizer = function(getSyncId, getObject)
|
|
26
|
+
local queue = __TS__New(LinkedSet)
|
|
27
|
+
local socket = __TS__New(____exports.ObjectBus, getSyncId, getObject)
|
|
28
|
+
socket.event:addListener(function(_, object)
|
|
29
|
+
local ____opt_0 = queue:pop()
|
|
30
|
+
if ____opt_0 ~= nil then
|
|
31
|
+
____opt_0(object)
|
|
32
|
+
end
|
|
33
|
+
end)
|
|
34
|
+
local function executor(____, resolve)
|
|
35
|
+
queue:add(resolve)
|
|
36
|
+
end
|
|
37
|
+
return function(player, object)
|
|
38
|
+
if player.isLocal then
|
|
39
|
+
socket:send(object)
|
|
40
|
+
end
|
|
41
|
+
return __TS__New(__TS__Promise, executor)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
____exports.ObjectBus = __TS__Class()
|
|
45
|
+
local ObjectBus = ____exports.ObjectBus
|
|
46
|
+
ObjectBus.name = "ObjectBus"
|
|
47
|
+
function ObjectBus.prototype.____constructor(self, getSyncId, getObject)
|
|
48
|
+
self.getSyncId = getSyncId
|
|
49
|
+
local syncSlider = createFrameByType(
|
|
50
|
+
"SLIDER",
|
|
51
|
+
"Synchronizer",
|
|
52
|
+
getOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0),
|
|
53
|
+
"",
|
|
54
|
+
0
|
|
55
|
+
)
|
|
56
|
+
frameSetMinMaxValue(syncSlider, MINIMUM_INTEGER, MAXIMUM_INTEGER)
|
|
57
|
+
self.syncSlider = syncSlider
|
|
58
|
+
local event = __TS__New(Event)
|
|
59
|
+
local trigger = createTrigger()
|
|
60
|
+
triggerRegisterFrameEvent(trigger, syncSlider, FRAMEEVENT_SLIDER_VALUE_CHANGED)
|
|
61
|
+
triggerAddAction(
|
|
62
|
+
trigger,
|
|
63
|
+
function()
|
|
64
|
+
eventInvoke(
|
|
65
|
+
event,
|
|
66
|
+
Player:of(getTriggerPlayer()),
|
|
67
|
+
getObject(getTriggerFrameValue())
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
)
|
|
71
|
+
self.event = event
|
|
72
|
+
end
|
|
73
|
+
function ObjectBus.prototype.send(self, object)
|
|
74
|
+
local syncId = object ~= nil and self.getSyncId(object) or 0
|
|
75
|
+
frameSetValue(self.syncSlider, syncId)
|
|
76
|
+
end
|
|
77
|
+
return ____exports
|
package/engine/text-tag.lua
CHANGED
package/net/socket.lua
CHANGED
|
@@ -28,13 +28,13 @@ function Socket.prototype.____constructor(self)
|
|
|
28
28
|
onReceive[self[0]]:addListener(function(sender, data)
|
|
29
29
|
local chunks = chunksByPlayer[sender]
|
|
30
30
|
if chunks ~= nil then
|
|
31
|
+
chunksByPlayer[sender] = nil
|
|
31
32
|
chunks[#chunks + 1] = data
|
|
32
33
|
Event.invoke(
|
|
33
34
|
self.onMessage,
|
|
34
35
|
sender,
|
|
35
36
|
tableConcat(chunks)
|
|
36
37
|
)
|
|
37
|
-
chunksByPlayer[sender] = nil
|
|
38
38
|
else
|
|
39
39
|
Event.invoke(self.onMessage, sender, data)
|
|
40
40
|
end
|
package/objutil/buff.lua
CHANGED
|
@@ -762,7 +762,7 @@ Unit.onDamaging:addListener(function(source, target, event)
|
|
|
762
762
|
end
|
|
763
763
|
end)
|
|
764
764
|
Unit.itemPickedUpEvent:addListener(function(unit, item)
|
|
765
|
-
if item.
|
|
765
|
+
if item.isPowerUp and item:hasAbility(fourCC("APdi")) then
|
|
766
766
|
end
|
|
767
767
|
end)
|
|
768
768
|
return ____exports
|
package/package.json
CHANGED
package/utility/arrays.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const joinToString: <T>(array: readonly T[], separator: string, t
|
|
|
5
5
|
export declare const arrayOfNotNull: <T>(...elements: readonly (T | undefined | null)[]) => T[];
|
|
6
6
|
export declare const array: <T, N extends number>(length: N, initialize: (index: number) => T) => TupleOf<T, N>;
|
|
7
7
|
export declare const toLuaSet: <T extends AnyNotNil>(array: readonly T[]) => LuaSet<T>;
|
|
8
|
+
export declare const contains: <T>(array: readonly T[], element: T) => boolean;
|
|
8
9
|
export declare const forEach: <T, Args extends any[]>(array: readonly T[], consumerOrKey: ((value: T, ...args: Args) => void) | KeysOfType<T, (this: T, ...args: Args) => void>, ...args: Args) => void;
|
|
9
10
|
export declare const all: {
|
|
10
11
|
<T>(array: readonly T[], transform: (value: T) => boolean): boolean;
|
package/utility/arrays.lua
CHANGED
|
@@ -49,6 +49,14 @@ ____exports.toLuaSet = function(array)
|
|
|
49
49
|
end
|
|
50
50
|
return result
|
|
51
51
|
end
|
|
52
|
+
____exports.contains = function(array, element)
|
|
53
|
+
for i = 1, #array do
|
|
54
|
+
if array[i] == element then
|
|
55
|
+
return true
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
return false
|
|
59
|
+
end
|
|
52
60
|
____exports.forEach = function(array, consumerOrKey, ...)
|
|
53
61
|
if type(consumerOrKey) == "function" then
|
|
54
62
|
for i = 1, #array do
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
type Callback = {
|
|
3
3
|
readonly __callback: unique symbol;
|
|
4
4
|
};
|
|
5
|
+
export type CallbackId = number & {
|
|
6
|
+
readonly __callbackId: unique symbol;
|
|
7
|
+
};
|
|
5
8
|
export type CallbackArray = {
|
|
6
9
|
readonly __callbackArray: unique symbol;
|
|
7
10
|
} & Callback[];
|
|
8
11
|
export declare const callbackArray: () => CallbackArray;
|
|
9
|
-
export declare function addCallback<Args extends any[]>(this: void, array: CallbackArray, callback: (...args: Args) => unknown, ...args: Args):
|
|
12
|
+
export declare function addCallback<Args extends any[]>(this: void, array: CallbackArray, callback: (...args: Args) => unknown, ...args: Args): CallbackId;
|
|
10
13
|
export declare function clearCallbacks(this: void, array: CallbackArray): void;
|
|
14
|
+
export declare function consumeCallback(this: void, array: CallbackArray, id: CallbackId): void;
|
|
11
15
|
export declare function consumeCallbacks(this: void, array: CallbackArray): void;
|
|
12
16
|
export declare function invokeCallbacks(this: void, array: CallbackArray): void;
|
|
13
17
|
export {};
|
|
@@ -20,8 +20,11 @@ local select = _G.select
|
|
|
20
20
|
local tableMove = table.move
|
|
21
21
|
tableUnpack = table.unpack
|
|
22
22
|
____exports.callbackArray = function() return {} end
|
|
23
|
+
local function doNothing()
|
|
24
|
+
end
|
|
23
25
|
function ____exports.addCallback(array, callback, ...)
|
|
24
|
-
local
|
|
26
|
+
local id = array[1] or 2
|
|
27
|
+
local i = id
|
|
25
28
|
array[i] = callback
|
|
26
29
|
local argsCount = select("#", ...)
|
|
27
30
|
i = i + 1
|
|
@@ -31,11 +34,23 @@ function ____exports.addCallback(array, callback, ...)
|
|
|
31
34
|
array[i] = (select(j, ...))
|
|
32
35
|
end
|
|
33
36
|
array[1] = i + 1
|
|
37
|
+
return id
|
|
34
38
|
end
|
|
35
39
|
function ____exports.clearCallbacks(array)
|
|
36
40
|
local length = array[1] or 2
|
|
37
41
|
tableMove(array, length, length + length - 2, 1)
|
|
38
42
|
end
|
|
43
|
+
function ____exports.consumeCallback(array, id)
|
|
44
|
+
local callback = array[id]
|
|
45
|
+
array[id] = doNothing
|
|
46
|
+
id = id + 1
|
|
47
|
+
local argsCount = array[id]
|
|
48
|
+
id = id + 1
|
|
49
|
+
safeCall(
|
|
50
|
+
callback,
|
|
51
|
+
tableUnpack(array, id, id + argsCount - 1)
|
|
52
|
+
)
|
|
53
|
+
end
|
|
39
54
|
function ____exports.consumeCallbacks(array)
|
|
40
55
|
local length = array[1] or 2
|
|
41
56
|
____exports.invokeCallbacks(array)
|
package/utility/linked-set.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class LinkedSet<T extends AnyNotNil> implements ReadonlyLinkedSet
|
|
|
36
36
|
copyOf(): LinkedSet<T>;
|
|
37
37
|
first(): T | undefined;
|
|
38
38
|
last(): T | undefined;
|
|
39
|
+
pop(): T | undefined;
|
|
39
40
|
next(key: T): T | undefined;
|
|
40
41
|
previous(key: T): T | undefined;
|
|
41
42
|
add(key: T): boolean;
|
package/utility/linked-set.lua
CHANGED
|
@@ -42,6 +42,23 @@ end
|
|
|
42
42
|
function LinkedSet.prototype.last(self)
|
|
43
43
|
return self.l
|
|
44
44
|
end
|
|
45
|
+
function LinkedSet.prototype.pop(self)
|
|
46
|
+
local f = self.f
|
|
47
|
+
if f == nil then
|
|
48
|
+
return nil
|
|
49
|
+
end
|
|
50
|
+
local n = self.n
|
|
51
|
+
local next = n[f]
|
|
52
|
+
n[f] = nil
|
|
53
|
+
self.f = next
|
|
54
|
+
if next ~= nil then
|
|
55
|
+
self.p[next] = nil
|
|
56
|
+
else
|
|
57
|
+
self.l = nil
|
|
58
|
+
end
|
|
59
|
+
self.s = self.s - 1
|
|
60
|
+
return f
|
|
61
|
+
end
|
|
45
62
|
function LinkedSet.prototype.next(self, key)
|
|
46
63
|
return self.n[key]
|
|
47
64
|
end
|
|
@@ -107,8 +124,9 @@ function LinkedSet.prototype.forEach(self, action, ...)
|
|
|
107
124
|
local n = self.n
|
|
108
125
|
local c = self.f
|
|
109
126
|
while c ~= nil do
|
|
127
|
+
local next = n[c]
|
|
110
128
|
action(c, ...)
|
|
111
|
-
c =
|
|
129
|
+
c = next
|
|
112
130
|
end
|
|
113
131
|
end
|
|
114
132
|
function LinkedSet.prototype.toArray(self)
|
package/utility/lua-maps.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const mutableWeakLuaMap: <K extends AnyNotNil, V>() => LuaMap<K,
|
|
|
6
6
|
export declare const luaMapOf: <K extends AnyNotNil, V>(...pairs: Flatten<TupleOf<[K, V], 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40>>) => LuaMap<K, V>;
|
|
7
7
|
export declare const luaMapInvert: <K extends AnyNotNil, V extends AnyNotNil>(luaMap: ReadonlyLuaMap<K, V | undefined | null>) => LuaMap<V, K>;
|
|
8
8
|
export declare const toLuaMap: <K extends PropertyKey, V>(record: Record<K, V>) => LuaMap<K, V>;
|
|
9
|
-
export declare const flattenKeys: <K extends AnyNotNil, V>(luaMap: ReadonlyLuaMap<readonly K[], V>) => LuaMap<K, V>;
|
|
9
|
+
export declare const flattenKeys: <K extends AnyNotNil, V>(luaMap: ReadonlyLuaMap<readonly K[], V> | ReadonlyLuaMap<K[], V>) => LuaMap<K, V>;
|
|
10
10
|
export declare const mapKeys: {
|
|
11
11
|
<K1 extends AnyNotNil, K2 extends AnyNotNil, V>(luaMap: ReadonlyLuaMap<K1, V>, transform: (value: K1) => K2): LuaMap<K2, V>;
|
|
12
12
|
<K1 extends AnyNotNil, K2 extends keyof K1, V>(luaMap: ReadonlyLuaMap<K1, V>, key: K2): K1[K2] extends AnyNotNil ? LuaMap<K1[K2], V> : never;
|
package/utility/types.d.ts
CHANGED
|
@@ -37,4 +37,7 @@ export type Flatten<T extends readonly any[], A extends readonly any[] = []> = T
|
|
|
37
37
|
export type Prohibit<T, K extends keyof any> = T & {
|
|
38
38
|
[P in K]?: never;
|
|
39
39
|
};
|
|
40
|
+
type TupleSplit<T, N extends number, O extends readonly any[] = readonly []> = O["length"] extends N ? [O, T] : T extends readonly [infer F, ...infer R] ? TupleSplit<readonly [...R], N, readonly [...O, F]> : [O, T];
|
|
41
|
+
export type TakeFirst<T extends readonly any[], N extends number> = TupleSplit<T, N>[0];
|
|
42
|
+
export type SkipFirst<T extends readonly any[], N extends number> = TupleSplit<T, N>[1];
|
|
40
43
|
export {};
|