warscript 0.0.1-dev.ee2345e → 0.0.1-dev.ee6e396
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 +6 -1
- package/attributes.lua +17 -1
- package/binaryreader.d.ts +1 -0
- package/binaryreader.lua +3 -0
- package/config.d.ts +5 -0
- package/config.lua +10 -0
- package/core/types/effect.d.ts +14 -6
- package/core/types/effect.lua +131 -35
- package/core/types/frame.d.ts +8 -1
- package/core/types/frame.lua +117 -22
- package/core/types/group.d.ts +0 -1
- package/core/types/image.d.ts +0 -1
- package/core/types/missile.d.ts +2 -2
- package/core/types/missile.lua +8 -2
- package/core/types/player.d.ts +16 -0
- package/core/types/player.lua +60 -15
- package/core/types/playerCamera.d.ts +2 -0
- package/core/types/playerCamera.lua +123 -5
- package/core/types/sound.d.ts +17 -24
- package/core/types/sound.lua +99 -24
- package/core/types/tileCell.d.ts +11 -1
- package/core/types/tileCell.lua +97 -0
- package/core/types/timer.d.ts +9 -8
- package/core/types/timer.lua +45 -23
- package/core/types/unit.lua +8 -0
- package/core/util.d.ts +1 -1
- package/core/util.lua +18 -1
- package/decl/index.d.ts +1 -0
- package/decl/native.d.ts +846 -790
- package/destroyable.d.ts +1 -0
- package/destroyable.lua +9 -0
- package/engine/ability.d.ts +1 -1
- package/engine/behavior.d.ts +24 -11
- package/engine/behavior.lua +233 -73
- package/engine/behaviour/ability/always-enabled.d.ts +7 -0
- package/engine/behaviour/ability/always-enabled.lua +31 -0
- package/engine/behaviour/ability/apply-buff.d.ts +8 -5
- package/engine/behaviour/ability/apply-buff.lua +36 -4
- package/engine/behaviour/ability/apply-unit-behavior.d.ts +6 -1
- package/engine/behaviour/ability/apply-unit-behavior.lua +1 -0
- package/engine/behaviour/ability/damage.d.ts +39 -11
- package/engine/behaviour/ability/damage.lua +83 -37
- package/engine/behaviour/ability/emulate-impact.d.ts +6 -0
- package/engine/behaviour/ability/emulate-impact.lua +43 -0
- package/engine/behaviour/ability/heal.d.ts +33 -6
- package/engine/behaviour/ability/heal.lua +89 -10
- package/engine/behaviour/ability/instant-impact.d.ts +2 -2
- package/engine/behaviour/ability/instant-impact.lua +4 -15
- package/engine/behaviour/ability/on-command-impact.d.ts +8 -0
- package/engine/behaviour/ability/on-command-impact.lua +25 -0
- package/engine/behaviour/ability/remove-buffs.d.ts +25 -0
- package/engine/behaviour/ability/remove-buffs.lua +49 -0
- package/engine/behaviour/ability/restore-mana.d.ts +15 -0
- package/engine/behaviour/ability/restore-mana.lua +29 -0
- package/engine/behaviour/ability.d.ts +33 -5
- package/engine/behaviour/ability.lua +183 -27
- package/engine/behaviour/unit/stun-immunity.d.ts +12 -7
- package/engine/behaviour/unit/stun-immunity.lua +57 -31
- package/engine/behaviour/unit.d.ts +48 -4
- package/engine/behaviour/unit.lua +292 -2
- package/engine/buff.d.ts +121 -46
- package/engine/buff.lua +567 -248
- package/engine/game-map.d.ts +7 -0
- package/engine/game-map.lua +32 -0
- package/engine/internal/ability.d.ts +23 -14
- package/engine/internal/ability.lua +129 -85
- package/engine/internal/item/ability.lua +162 -4
- package/engine/internal/item+owner.lua +12 -6
- package/engine/internal/item.d.ts +20 -19
- package/engine/internal/item.lua +191 -74
- package/engine/internal/mechanics/ability-duration.lua +1 -1
- package/engine/internal/mechanics/cast-ability.lua +6 -3
- package/engine/internal/misc/ability-disable-counter.d.ts +2 -0
- package/engine/internal/misc/ability-disable-counter.lua +13 -0
- package/engine/internal/misc/damage-metadata-by-target.d.ts +2 -0
- package/engine/internal/misc/damage-metadata-by-target.lua +5 -0
- 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/object-data/auto-attack-speed-increase.d.ts +1 -1
- package/engine/internal/object-data/auto-attack-speed-increase.lua +2 -0
- package/engine/internal/object-data/evasion-probability.d.ts +2 -0
- package/engine/internal/object-data/evasion-probability.lua +16 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.d.ts +2 -0
- package/engine/internal/object-data/mana-regeneration-rate-increase-factor.lua +16 -0
- package/engine/internal/unit/ability.d.ts +45 -1
- package/engine/internal/unit/ability.lua +128 -17
- package/engine/internal/unit/add-item-to-slot-init.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot-init.lua +23 -0
- package/engine/internal/unit/add-item-to-slot.d.ts +2 -0
- package/engine/internal/unit/add-item-to-slot.lua +52 -0
- package/engine/internal/unit/allowed-targets.d.ts +1 -1
- package/engine/internal/unit/allowed-targets.lua +9 -1
- package/engine/internal/unit/attributes.d.ts +17 -0
- package/engine/internal/unit/attributes.lua +46 -0
- package/engine/internal/unit/bonus.d.ts +13 -8
- package/engine/internal/unit/bonus.lua +33 -1
- package/engine/internal/unit/fly-height.d.ts +7 -0
- package/engine/internal/unit/fly-height.lua +20 -0
- package/engine/internal/unit/ignore-events-items.d.ts +2 -0
- package/engine/internal/unit/ignore-events-items.lua +5 -0
- package/engine/internal/unit/interrupts.d.ts +12 -0
- package/engine/internal/unit/interrupts.lua +28 -0
- package/engine/internal/unit/item.d.ts +24 -0
- package/engine/internal/unit/item.lua +78 -0
- package/engine/internal/unit/main-selected.d.ts +13 -0
- package/engine/internal/unit/main-selected.lua +36 -0
- package/engine/internal/unit/order.d.ts +20 -0
- package/engine/internal/unit/order.lua +136 -0
- package/engine/internal/unit/range-event.d.ts +12 -0
- package/engine/internal/unit/range-event.lua +90 -0
- package/engine/internal/unit/scale.d.ts +7 -0
- package/engine/internal/unit/scale.lua +20 -0
- package/engine/internal/unit+ability.lua +12 -3
- package/engine/internal/unit+damage.d.ts +2 -11
- package/engine/internal/unit+damage.lua +10 -14
- package/engine/internal/unit+spellSteal.lua +1 -2
- package/engine/internal/unit+transport.lua +4 -10
- package/engine/internal/unit-missile-launch.lua +70 -13
- package/engine/internal/unit.d.ts +97 -36
- package/engine/internal/unit.lua +701 -336
- package/engine/internal/utility.lua +12 -0
- package/engine/lightning.d.ts +12 -5
- package/engine/lightning.lua +48 -14
- package/engine/local-client.d.ts +9 -2
- package/engine/local-client.lua +112 -0
- package/engine/object-data/auxiliary/animation-name.d.ts +1 -0
- package/engine/object-data/auxiliary/animation-name.lua +16 -0
- 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/auxiliary/attachment-preset.d.ts +7 -3
- package/engine/object-data/auxiliary/attachment-preset.lua +4 -3
- package/engine/object-data/auxiliary/attack-type.d.ts +7 -8
- package/engine/object-data/auxiliary/attack-type.lua +42 -0
- package/engine/object-data/auxiliary/combat-classification.d.ts +0 -2
- package/engine/object-data/auxiliary/health-regeneration-type.d.ts +8 -0
- package/engine/object-data/auxiliary/health-regeneration-type.lua +2 -0
- package/engine/object-data/auxiliary/movement-type.d.ts +7 -7
- package/engine/object-data/auxiliary/movement-type.lua +22 -0
- package/engine/object-data/auxiliary/sound-eax.d.ts +10 -0
- package/engine/object-data/auxiliary/sound-eax.lua +2 -0
- package/engine/object-data/auxiliary/sound-preset-name.d.ts +5 -1
- package/engine/object-data/auxiliary/tech-tree-dependency.d.ts +1 -1
- package/engine/object-data/auxiliary/unit-attribute.d.ts +6 -0
- package/engine/object-data/auxiliary/unit-attribute.lua +9 -0
- package/engine/object-data/entry/ability-type/berserk.d.ts +2 -0
- package/engine/object-data/entry/ability-type/berserk.lua +13 -0
- package/engine/object-data/entry/ability-type/blank-configurable.d.ts +0 -1
- package/engine/object-data/entry/ability-type/blank-configurable.lua +12 -1
- package/engine/object-data/entry/ability-type/blank-passive.d.ts +0 -1
- package/engine/object-data/entry/ability-type/carrion-swarm.d.ts +14 -0
- package/engine/object-data/entry/ability-type/carrion-swarm.lua +65 -0
- package/engine/object-data/entry/ability-type/channel.d.ts +0 -1
- package/engine/object-data/entry/ability-type/disease-cloud.lua +2 -2
- package/engine/object-data/entry/ability-type/engineering-upgrade.lua +2 -2
- package/engine/object-data/entry/ability-type/ensnare.d.ts +12 -0
- package/engine/object-data/entry/ability-type/ensnare.lua +52 -0
- package/engine/object-data/entry/ability-type/feral-spirit.lua +2 -2
- package/engine/object-data/entry/ability-type/mana-regeneration.d.ts +8 -0
- package/engine/object-data/entry/ability-type/mana-regeneration.lua +26 -0
- package/engine/object-data/entry/ability-type/mine.d.ts +10 -0
- package/engine/object-data/entry/ability-type/mine.lua +39 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.d.ts +8 -0
- package/engine/object-data/entry/ability-type/permanent-invisibility.lua +26 -0
- package/engine/object-data/entry/ability-type/phase-shift.d.ts +10 -0
- package/engine/object-data/entry/ability-type/phase-shift.lua +39 -0
- package/engine/object-data/entry/ability-type/phoenix-morph.lua +4 -4
- package/engine/object-data/entry/ability-type/raise-dead.d.ts +17 -0
- package/engine/object-data/entry/ability-type/raise-dead.lua +78 -0
- package/engine/object-data/entry/ability-type/shock-wave.d.ts +4 -0
- package/engine/object-data/entry/ability-type/shock-wave.lua +26 -0
- package/engine/object-data/entry/ability-type/slow-poison.d.ts +10 -0
- package/engine/object-data/entry/ability-type/slow-poison.lua +58 -0
- package/engine/object-data/entry/ability-type/spirit-touch.d.ts +2 -2
- package/engine/object-data/entry/ability-type/spirit-touch.lua +6 -6
- package/engine/object-data/entry/ability-type/summon-quilbeast.lua +2 -2
- package/engine/object-data/entry/ability-type/summon-water-elemental.lua +2 -2
- package/engine/object-data/entry/ability-type/web.d.ts +12 -0
- package/engine/object-data/entry/ability-type/web.lua +52 -0
- package/engine/object-data/entry/ability-type.d.ts +19 -18
- package/engine/object-data/entry/ability-type.lua +93 -36
- package/engine/object-data/entry/buff-type/applicable.d.ts +0 -1
- package/engine/object-data/entry/buff-type/applicable.lua +18 -37
- package/engine/object-data/entry/buff-type/blank.d.ts +0 -1
- package/engine/object-data/entry/buff-type.d.ts +6 -13
- package/engine/object-data/entry/buff-type.lua +13 -29
- package/engine/object-data/entry/destructible-type.d.ts +28 -3
- package/engine/object-data/entry/destructible-type.lua +155 -0
- package/engine/object-data/entry/item-type/blank.d.ts +0 -1
- package/engine/object-data/entry/item-type.d.ts +15 -2
- package/engine/object-data/entry/item-type.lua +93 -2
- package/engine/object-data/entry/lightning-type.d.ts +1 -2
- package/engine/object-data/entry/sound-preset.d.ts +33 -0
- package/engine/object-data/entry/sound-preset.lua +140 -0
- package/engine/object-data/entry/unit-type.d.ts +62 -7
- package/engine/object-data/entry/unit-type.lua +524 -75
- package/engine/object-data/entry/upgrade/blank.d.ts +0 -1
- package/engine/object-data/entry/upgrade.d.ts +1 -2
- package/engine/object-data/entry/upgrade.lua +4 -4
- package/engine/object-data/entry.d.ts +18 -17
- package/engine/object-data/entry.lua +60 -32
- package/engine/object-data/utility/object-data-entry-id-generator.lua +7 -0
- package/engine/object-field/ability.d.ts +28 -5
- package/engine/object-field/ability.lua +59 -5
- package/engine/object-field/unit.d.ts +72 -3
- package/engine/object-field/unit.lua +268 -7
- package/engine/object-field.d.ts +25 -7
- package/engine/object-field.lua +359 -116
- package/engine/random.d.ts +10 -0
- package/engine/random.lua +22 -0
- package/engine/standard/entries/buff-type.d.ts +3 -0
- package/engine/standard/entries/buff-type.lua +3 -0
- package/engine/standard/entries/sound-preset.d.ts +10 -0
- package/engine/standard/entries/sound-preset.lua +10 -0
- package/engine/standard/entries/unit-type.d.ts +39 -1
- package/engine/standard/entries/unit-type.lua +39 -1
- package/engine/standard/fields/ability.d.ts +5 -3
- package/engine/standard/fields/ability.lua +5 -3
- package/engine/standard/fields/unit.d.ts +12 -0
- package/engine/standard/fields/unit.lua +20 -0
- package/engine/synchronization.d.ts +11 -0
- package/engine/synchronization.lua +77 -0
- package/engine/text-tag.d.ts +36 -2
- package/engine/text-tag.lua +250 -10
- package/engine/unit.d.ts +9 -0
- package/engine/unit.lua +18 -2
- package/event.d.ts +2 -3
- package/event.lua +9 -5
- package/index.d.ts +1 -0
- package/index.lua +1 -0
- package/lualib_bundle.lua +146 -42
- package/math/vec2.d.ts +2 -9
- package/math.d.ts +0 -2
- package/net/socket.d.ts +7 -1
- package/net/socket.lua +45 -4
- package/network.d.ts +1 -0
- package/network.lua +3 -2
- package/objutil/ability.d.ts +0 -1
- package/objutil/buff.d.ts +0 -1
- package/objutil/buff.lua +12 -11
- package/objutil/object.d.ts +0 -1
- package/objutil/unit.d.ts +0 -1
- package/objutil/unit.lua +8 -0
- package/package.json +13 -14
- package/patch-lua.d.ts +0 -0
- package/patch-lua.lua +25 -0
- package/patch-lualib.lua +1 -1
- package/property.d.ts +55 -0
- package/property.lua +374 -0
- package/string.d.ts +30 -0
- package/string.lua +14 -0
- package/util/stream.d.ts +0 -1
- package/utility/arrays.d.ts +13 -5
- package/utility/arrays.lua +45 -3
- package/utility/bit-set.d.ts +0 -2
- package/utility/callback-array.d.ts +17 -0
- package/utility/callback-array.lua +61 -0
- package/utility/functions.d.ts +8 -0
- package/utility/functions.lua +13 -0
- package/utility/lazy.d.ts +2 -0
- package/utility/lazy.lua +14 -0
- package/utility/linked-map.d.ts +34 -0
- package/utility/linked-map.lua +101 -0
- package/utility/linked-set.d.ts +15 -4
- package/utility/linked-set.lua +48 -3
- package/utility/lua-maps.d.ts +16 -4
- package/utility/lua-maps.lua +53 -2
- package/utility/lua-sets.d.ts +3 -2
- package/utility/lua-sets.lua +7 -0
- package/utility/records.lua +20 -1
- package/utility/reflection.lua +11 -7
- package/utility/types.d.ts +4 -0
- package/core/mapbounds.d.ts +0 -8
- package/core/mapbounds.lua +0 -12
- package/core/types/order.d.ts +0 -25
- package/core/types/order.lua +0 -55
package/destroyable.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface Destroyable {
|
|
|
10
10
|
destroy(): void;
|
|
11
11
|
}
|
|
12
12
|
export declare abstract class AbstractDestroyable implements Destroyable {
|
|
13
|
+
get isDestroyed(): boolean;
|
|
13
14
|
/**
|
|
14
15
|
* An overriding function should always call the super one at the end of it,
|
|
15
16
|
* in the following manner: `return super.onDestroy()`.
|
package/destroyable.lua
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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 = {}
|
|
5
6
|
local ____exception = require("exception")
|
|
6
7
|
local IllegalStateException = ____exception.IllegalStateException
|
|
@@ -28,4 +29,12 @@ function AbstractDestroyable.prototype.destroy(self)
|
|
|
28
29
|
end
|
|
29
30
|
return true
|
|
30
31
|
end
|
|
32
|
+
__TS__SetDescriptor(
|
|
33
|
+
AbstractDestroyable.prototype,
|
|
34
|
+
"isDestroyed",
|
|
35
|
+
{get = function(self)
|
|
36
|
+
return stateByDestroyable[self] ~= nil
|
|
37
|
+
end},
|
|
38
|
+
true
|
|
39
|
+
)
|
|
31
40
|
return ____exports
|
package/engine/ability.d.ts
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { AbilityTypeId } from "./object-data/entry/ability-type";
|
|
3
3
|
import { UnitAbility } from "./internal/ability";
|
|
4
4
|
import { Player } from "../core/types/player";
|
|
5
|
-
export declare const castAbility: (owner: Player, abilityTypeId: AbilityTypeId, ...args: [
|
|
5
|
+
export declare const castAbility: (owner: Player, abilityTypeId: AbilityTypeId, ...args: [...levelOrAbilityConsumer: [number] | [(ability: UnitAbility) => void] | [], x: number, y: number]) => void;
|
package/engine/behavior.d.ts
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { AbstractDestroyable, Destructor } from "../destroyable";
|
|
3
|
-
|
|
3
|
+
import { Event } from "../event";
|
|
4
|
+
export declare const enum BehaviorPriority {
|
|
5
|
+
HIGH = 0,
|
|
6
|
+
MEDIUM = 1,
|
|
7
|
+
LOW = 2
|
|
8
|
+
}
|
|
9
|
+
export type BehaviorConstructor<T extends Behavior<AnyNotNil>, Parameters extends any[] = any[]> = OmitConstructor<typeof Behavior<any>> & (abstract new (...parameters: Parameters) => T);
|
|
4
10
|
declare const enum BehaviorPropertyKey {
|
|
5
11
|
PREVIOUS_BEHAVIOR = 0,
|
|
6
12
|
NEXT_BEHAVIOR = 1,
|
|
7
13
|
TIMER = 2
|
|
8
14
|
}
|
|
9
|
-
export declare abstract class Behavior<T, PeriodicActionParameters extends any[] = any[]> extends AbstractDestroyable {
|
|
15
|
+
export declare abstract class Behavior<T extends AnyNotNil, PeriodicActionParameters extends any[] = any[]> extends AbstractDestroyable {
|
|
10
16
|
protected readonly object: T;
|
|
17
|
+
readonly priority: BehaviorPriority;
|
|
11
18
|
private [BehaviorPropertyKey.PREVIOUS_BEHAVIOR]?;
|
|
12
19
|
private [BehaviorPropertyKey.NEXT_BEHAVIOR]?;
|
|
13
20
|
private [BehaviorPropertyKey.TIMER]?;
|
|
14
|
-
|
|
21
|
+
constructor(object: T, priority?: BehaviorPriority);
|
|
15
22
|
protected onDestroy(): Destructor;
|
|
23
|
+
protected registerGlobalEvent<K extends string, Args extends any[]>(this: Behavior<any, PeriodicActionParameters> & Record<K, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, listener: K): void;
|
|
24
|
+
protected deregisterGlobalEvent(event: Event<any>): boolean;
|
|
25
|
+
protected registerEvent<K extends string, Args extends any[]>(this: Behavior<any, PeriodicActionParameters> & Record<K, (this: this, ...args: Args) => unknown>, event: Event<[...Args]>, extractObject: (...args: Args) => T | undefined, listener: K): void;
|
|
26
|
+
protected deregisterEvent(event: Event<any>): boolean;
|
|
16
27
|
protected onPeriod(...parameters: PeriodicActionParameters): void;
|
|
17
28
|
protected startPeriodicAction(interval: number, ...parameters: PeriodicActionParameters): void;
|
|
18
29
|
protected stopPeriodicAction(): void;
|
|
19
|
-
static count<T extends Behavior<
|
|
20
|
-
static getFirst<T extends Behavior<
|
|
21
|
-
static getLast<T extends Behavior<
|
|
22
|
-
static getAll<T extends Behavior<
|
|
23
|
-
static forFirst<T extends Behavior<
|
|
24
|
-
static forFirst<T extends Behavior<
|
|
25
|
-
static forAll<T extends Behavior<
|
|
26
|
-
static forAll<T extends Behavior<
|
|
30
|
+
static count<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, limit?: number): number;
|
|
31
|
+
static getFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], CountOrPredicate extends [number] | [] | [(behavior: T, ...args: PredicateArgs) => boolean, ...PredicateArgs], PredicateArgs extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, ...[countOrPredicate]: CountOrPredicate): CountOrPredicate extends [number] ? T[] : T | undefined;
|
|
32
|
+
static getLast<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never): T | undefined;
|
|
33
|
+
static getAll<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], PredicateArgs extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, predicate?: (this: void, behavior: T, ...args: PredicateArgs) => boolean, ...predicateArgs: PredicateArgs): T[];
|
|
34
|
+
static forFirst<T extends Behavior<AnyNotNil>, ConstructorParameters extends any[], ConsumerParameters extends any[]>(this: BehaviorConstructor<T, ConstructorParameters>, object: T extends Behavior<infer Object> ? Object : never, count: number, consumer: (this: void, behavior: T, ...parameters: ConsumerParameters) => any, ...parameters: ConsumerParameters): number;
|
|
35
|
+
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;
|
|
36
|
+
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;
|
|
37
|
+
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;
|
|
38
|
+
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;
|
|
39
|
+
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
40
|
}
|
|
28
41
|
export {};
|
package/engine/behavior.lua
CHANGED
|
@@ -1,28 +1,88 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
2
3
|
local __TS__Class = ____lualib.__TS__Class
|
|
3
4
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
-
local
|
|
5
|
+
local __TS__New = ____lualib.__TS__New
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____destroyable = require("destroyable")
|
|
7
8
|
local AbstractDestroyable = ____destroyable.AbstractDestroyable
|
|
8
9
|
local ____timer = require("core.types.timer")
|
|
9
10
|
local Timer = ____timer.Timer
|
|
11
|
+
local ____functions = require("utility.functions")
|
|
12
|
+
local increment = ____functions.increment
|
|
13
|
+
local ____linked_2Dset = require("utility.linked-set")
|
|
14
|
+
local LinkedSet = ____linked_2Dset.LinkedSet
|
|
15
|
+
local ____lua_2Dmaps = require("utility.lua-maps")
|
|
16
|
+
local getOrPut = ____lua_2Dmaps.getOrPut
|
|
17
|
+
local mutableLuaMap = ____lua_2Dmaps.mutableLuaMap
|
|
18
|
+
local ____lua_2Dsets = require("utility.lua-sets")
|
|
19
|
+
local mutableLuaSet = ____lua_2Dsets.mutableLuaSet
|
|
10
20
|
local safeCall = warpack.safeCall
|
|
11
|
-
local
|
|
12
|
-
local
|
|
21
|
+
local firstBehaviorByObjectByPriority = {[0] = {}, [2] = {}, [1] = {}}
|
|
22
|
+
local lastBehaviorByObjectByPriority = {[0] = {}, [2] = {}, [1] = {}}
|
|
13
23
|
local function invokeBehaviorOnPeriod(behavior, ...)
|
|
14
24
|
behavior.onPeriod(behavior, ...)
|
|
15
25
|
end
|
|
26
|
+
local function reduceBehaviors(behaviorConstructor, object, operation, initial, consumerOrKey, ...)
|
|
27
|
+
local accumulator = initial
|
|
28
|
+
for priority = 0, 2 do
|
|
29
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
30
|
+
if behavior ~= nil then
|
|
31
|
+
if type(consumerOrKey) == "function" then
|
|
32
|
+
repeat
|
|
33
|
+
do
|
|
34
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
35
|
+
local isSuccessful, result = safeCall(consumerOrKey, behavior, ...)
|
|
36
|
+
if isSuccessful then
|
|
37
|
+
accumulator = operation(accumulator, result)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
behavior = behavior[1]
|
|
41
|
+
end
|
|
42
|
+
until not (behavior ~= nil)
|
|
43
|
+
else
|
|
44
|
+
repeat
|
|
45
|
+
do
|
|
46
|
+
if __TS__InstanceOf(behavior, behaviorConstructor) then
|
|
47
|
+
local isSuccessful, result = safeCall(behavior[consumerOrKey], behavior, ...)
|
|
48
|
+
if isSuccessful then
|
|
49
|
+
accumulator = operation(accumulator, result)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
behavior = behavior[1]
|
|
53
|
+
end
|
|
54
|
+
until not (behavior ~= nil)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
return accumulator
|
|
59
|
+
end
|
|
60
|
+
local behaviorsByGlobalEvent = {}
|
|
61
|
+
local listenerByBehaviorByGlobalEvent = {}
|
|
62
|
+
local globalEventsByBehavior = {}
|
|
63
|
+
local behaviorsByEvent = {}
|
|
64
|
+
local listenerByBehaviorByEvent = {}
|
|
65
|
+
local eventsByBehavior = {}
|
|
66
|
+
local function safeCallBehaviorListener(behavior, behaviors, listenerByBehavior, ...)
|
|
67
|
+
if behaviors[behavior] ~= nil then
|
|
68
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
16
71
|
____exports.Behavior = __TS__Class()
|
|
17
72
|
local Behavior = ____exports.Behavior
|
|
18
73
|
Behavior.name = "Behavior"
|
|
19
74
|
__TS__ClassExtends(Behavior, AbstractDestroyable)
|
|
20
|
-
function Behavior.prototype.____constructor(self, object)
|
|
75
|
+
function Behavior.prototype.____constructor(self, object, priority)
|
|
76
|
+
if priority == nil then
|
|
77
|
+
priority = 1
|
|
78
|
+
end
|
|
21
79
|
AbstractDestroyable.prototype.____constructor(self)
|
|
22
80
|
self.object = object
|
|
81
|
+
self.priority = priority
|
|
82
|
+
local lastBehaviorByObject = lastBehaviorByObjectByPriority[priority]
|
|
23
83
|
local lastBehavior = lastBehaviorByObject[object]
|
|
24
84
|
if lastBehavior == nil then
|
|
25
|
-
|
|
85
|
+
firstBehaviorByObjectByPriority[priority][object] = self
|
|
26
86
|
lastBehaviorByObject[object] = self
|
|
27
87
|
else
|
|
28
88
|
self[0] = lastBehavior
|
|
@@ -35,20 +95,112 @@ function Behavior.prototype.onDestroy(self)
|
|
|
35
95
|
if ____opt_0 ~= nil then
|
|
36
96
|
____opt_0:destroy()
|
|
37
97
|
end
|
|
98
|
+
local globalEvents = globalEventsByBehavior[self]
|
|
99
|
+
if globalEvents ~= nil then
|
|
100
|
+
for event in pairs(globalEvents) do
|
|
101
|
+
local ____opt_2 = behaviorsByGlobalEvent[event]
|
|
102
|
+
if ____opt_2 ~= nil then
|
|
103
|
+
____opt_2:remove(self)
|
|
104
|
+
end
|
|
105
|
+
local ____opt_4 = listenerByBehaviorByGlobalEvent[event]
|
|
106
|
+
if ____opt_4 ~= nil then
|
|
107
|
+
____opt_4[self] = nil
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
globalEventsByBehavior[self] = nil
|
|
111
|
+
end
|
|
112
|
+
local events = eventsByBehavior[self]
|
|
113
|
+
if events ~= nil then
|
|
114
|
+
for event in pairs(events) do
|
|
115
|
+
local ____opt_6 = behaviorsByEvent[event]
|
|
116
|
+
if ____opt_6 ~= nil then
|
|
117
|
+
____opt_6[self] = nil
|
|
118
|
+
end
|
|
119
|
+
local ____opt_8 = listenerByBehaviorByEvent[event]
|
|
120
|
+
if ____opt_8 ~= nil then
|
|
121
|
+
____opt_8[self] = nil
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
eventsByBehavior[self] = nil
|
|
125
|
+
end
|
|
38
126
|
local previousBehavior = self[0]
|
|
39
127
|
local nextBehavior = self[1]
|
|
40
128
|
if previousBehavior ~= nil then
|
|
41
129
|
previousBehavior[1] = nextBehavior
|
|
42
130
|
else
|
|
43
|
-
|
|
131
|
+
firstBehaviorByObjectByPriority[self.priority][self.object] = nextBehavior
|
|
44
132
|
end
|
|
45
133
|
if nextBehavior ~= nil then
|
|
46
134
|
nextBehavior[0] = previousBehavior
|
|
47
135
|
else
|
|
48
|
-
|
|
136
|
+
lastBehaviorByObjectByPriority[self.priority][self.object] = previousBehavior
|
|
49
137
|
end
|
|
50
138
|
return AbstractDestroyable.prototype.onDestroy(self)
|
|
51
139
|
end
|
|
140
|
+
function Behavior.prototype.registerGlobalEvent(self, event, listener)
|
|
141
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByGlobalEvent, event, mutableLuaMap)
|
|
142
|
+
listenerByBehavior[self] = listener
|
|
143
|
+
getOrPut(globalEventsByBehavior, self, mutableLuaSet)[event] = true
|
|
144
|
+
local behaviors = behaviorsByGlobalEvent[event]
|
|
145
|
+
if behaviors == nil then
|
|
146
|
+
event:addListener(function(...)
|
|
147
|
+
local behaviors = behaviorsByGlobalEvent[event]
|
|
148
|
+
if behaviors ~= nil then
|
|
149
|
+
for behavior in pairs(behaviors) do
|
|
150
|
+
safeCall(behavior[listenerByBehavior[behavior]], behavior, ...)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end)
|
|
154
|
+
behaviors = __TS__New(LinkedSet)
|
|
155
|
+
behaviorsByGlobalEvent[event] = behaviors
|
|
156
|
+
end
|
|
157
|
+
behaviors:add(self)
|
|
158
|
+
end
|
|
159
|
+
function Behavior.prototype.deregisterGlobalEvent(self, event)
|
|
160
|
+
local behaviors = behaviorsByGlobalEvent[event]
|
|
161
|
+
if behaviors ~= nil and behaviors:remove(self) then
|
|
162
|
+
globalEventsByBehavior[self][event] = nil
|
|
163
|
+
listenerByBehaviorByGlobalEvent[event][self] = nil
|
|
164
|
+
return true
|
|
165
|
+
end
|
|
166
|
+
return false
|
|
167
|
+
end
|
|
168
|
+
function Behavior.prototype.registerEvent(self, event, extractObject, listener)
|
|
169
|
+
local listenerByBehavior = getOrPut(listenerByBehaviorByEvent, event, mutableLuaMap)
|
|
170
|
+
listenerByBehavior[self] = listener
|
|
171
|
+
getOrPut(eventsByBehavior, self, mutableLuaSet)[event] = true
|
|
172
|
+
local behaviors = behaviorsByEvent[event]
|
|
173
|
+
if behaviors == nil then
|
|
174
|
+
event:addListener(function(...)
|
|
175
|
+
local behaviors = behaviorsByEvent[event]
|
|
176
|
+
if behaviors ~= nil then
|
|
177
|
+
local object = extractObject(...)
|
|
178
|
+
if object ~= nil then
|
|
179
|
+
____exports.Behavior:forAll(
|
|
180
|
+
object,
|
|
181
|
+
safeCallBehaviorListener,
|
|
182
|
+
behaviors,
|
|
183
|
+
listenerByBehavior,
|
|
184
|
+
...
|
|
185
|
+
)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end)
|
|
189
|
+
behaviors = {}
|
|
190
|
+
behaviorsByEvent[event] = behaviors
|
|
191
|
+
end
|
|
192
|
+
behaviors[self] = true
|
|
193
|
+
end
|
|
194
|
+
function Behavior.prototype.deregisterEvent(self, event)
|
|
195
|
+
local behaviors = behaviorsByEvent[event]
|
|
196
|
+
if behaviors ~= nil and behaviors[self] ~= nil then
|
|
197
|
+
behaviors[self] = nil
|
|
198
|
+
eventsByBehavior[self][event] = nil
|
|
199
|
+
listenerByBehaviorByEvent[event][self] = nil
|
|
200
|
+
return true
|
|
201
|
+
end
|
|
202
|
+
return false
|
|
203
|
+
end
|
|
52
204
|
function Behavior.prototype.onPeriod(self, ...)
|
|
53
205
|
end
|
|
54
206
|
function Behavior.prototype.startPeriodicAction(self, interval, ...)
|
|
@@ -74,108 +226,116 @@ function Behavior.prototype.stopPeriodicAction(self)
|
|
|
74
226
|
end
|
|
75
227
|
function Behavior.count(self, object, limit)
|
|
76
228
|
local behaviorsCount = 0
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
229
|
+
for priority = 0, 2 do
|
|
230
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
231
|
+
while behavior ~= nil and (limit == nil or behaviorsCount < limit) do
|
|
232
|
+
if __TS__InstanceOf(behavior, self) then
|
|
233
|
+
behaviorsCount = behaviorsCount + 1
|
|
234
|
+
end
|
|
235
|
+
behavior = behavior[1]
|
|
81
236
|
end
|
|
82
|
-
behavior = behavior[1]
|
|
83
237
|
end
|
|
84
238
|
return behaviorsCount
|
|
85
239
|
end
|
|
86
|
-
function Behavior.getFirst(self, object,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
240
|
+
function Behavior.getFirst(self, object, countOrPredicate, ...)
|
|
241
|
+
if type(countOrPredicate) ~= "number" then
|
|
242
|
+
for priority = 0, 2 do
|
|
243
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
244
|
+
while behavior ~= nil do
|
|
245
|
+
if __TS__InstanceOf(behavior, self) and (countOrPredicate == nil or countOrPredicate(behavior, ...)) then
|
|
246
|
+
return behavior
|
|
247
|
+
end
|
|
248
|
+
behavior = behavior[1]
|
|
92
249
|
end
|
|
93
|
-
behavior = behavior[1]
|
|
94
250
|
end
|
|
95
251
|
return nil
|
|
96
252
|
end
|
|
97
253
|
local behaviors = {}
|
|
98
254
|
local behaviorsCount = 0
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
255
|
+
for priority = 0, 2 do
|
|
256
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
257
|
+
while behavior ~= nil and behaviorsCount < countOrPredicate do
|
|
258
|
+
if __TS__InstanceOf(behavior, self) then
|
|
259
|
+
behaviorsCount = behaviorsCount + 1
|
|
260
|
+
behaviors[behaviorsCount] = behavior
|
|
261
|
+
end
|
|
262
|
+
behavior = behavior[1]
|
|
103
263
|
end
|
|
104
|
-
behavior = behavior[1]
|
|
105
264
|
end
|
|
106
265
|
return behaviors
|
|
107
266
|
end
|
|
108
267
|
function Behavior.getLast(self, object)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
268
|
+
for priority = 2, 0, -1 do
|
|
269
|
+
local behavior = lastBehaviorByObjectByPriority[priority][object]
|
|
270
|
+
while behavior ~= nil do
|
|
271
|
+
if __TS__InstanceOf(behavior, self) then
|
|
272
|
+
return behavior
|
|
273
|
+
end
|
|
274
|
+
behavior = behavior[0]
|
|
113
275
|
end
|
|
114
|
-
behavior = behavior[0]
|
|
115
276
|
end
|
|
116
277
|
return nil
|
|
117
278
|
end
|
|
118
|
-
function Behavior.getAll(self, object)
|
|
279
|
+
function Behavior.getAll(self, object, predicate, ...)
|
|
119
280
|
local behaviors = {}
|
|
120
281
|
local behaviorsCount = 0
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
282
|
+
for priority = 0, 2 do
|
|
283
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
284
|
+
while behavior ~= nil do
|
|
285
|
+
if __TS__InstanceOf(behavior, self) and (predicate == nil or predicate(behavior, ...)) then
|
|
286
|
+
behaviorsCount = behaviorsCount + 1
|
|
287
|
+
behaviors[behaviorsCount] = behavior
|
|
288
|
+
end
|
|
289
|
+
behavior = behavior[1]
|
|
126
290
|
end
|
|
127
|
-
behavior = behavior[1]
|
|
128
291
|
end
|
|
129
292
|
return behaviors
|
|
130
293
|
end
|
|
131
294
|
function Behavior.forFirst(self, object, count, consumerOrKey, ...)
|
|
132
295
|
local behaviorsCount = 0
|
|
133
|
-
local behavior = firstBehaviorByObject[object]
|
|
134
296
|
if type(consumerOrKey) == "function" then
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
297
|
+
for priority = 0, 2 do
|
|
298
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
299
|
+
while behavior ~= nil and behaviorsCount < count do
|
|
300
|
+
if __TS__InstanceOf(behavior, self) then
|
|
301
|
+
safeCall(consumerOrKey, behavior, ...)
|
|
302
|
+
behaviorsCount = behaviorsCount + 1
|
|
303
|
+
end
|
|
304
|
+
behavior = behavior[1]
|
|
139
305
|
end
|
|
140
|
-
behavior = behavior[1]
|
|
141
306
|
end
|
|
142
307
|
else
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
308
|
+
for priority = 0, 2 do
|
|
309
|
+
local behavior = firstBehaviorByObjectByPriority[priority][object]
|
|
310
|
+
while behavior ~= nil and behaviorsCount < count do
|
|
311
|
+
if __TS__InstanceOf(behavior, self) then
|
|
312
|
+
safeCall(behavior[consumerOrKey], behavior, ...)
|
|
313
|
+
behaviorsCount = behaviorsCount + 1
|
|
314
|
+
end
|
|
315
|
+
behavior = behavior[1]
|
|
147
316
|
end
|
|
148
|
-
behavior = behavior[1]
|
|
149
317
|
end
|
|
150
318
|
end
|
|
151
319
|
return behaviorsCount
|
|
152
320
|
end
|
|
153
321
|
function Behavior.forAll(self, object, consumerOrKey, ...)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
behaviorsCount = behaviorsCount + 1
|
|
173
|
-
end
|
|
174
|
-
behavior = behavior[1]
|
|
175
|
-
end
|
|
176
|
-
until not (behavior ~= nil)
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
return behaviorsCount
|
|
322
|
+
return reduceBehaviors(
|
|
323
|
+
self,
|
|
324
|
+
object,
|
|
325
|
+
increment,
|
|
326
|
+
0,
|
|
327
|
+
consumerOrKey,
|
|
328
|
+
...
|
|
329
|
+
)
|
|
330
|
+
end
|
|
331
|
+
function Behavior.reduce(self, object, operation, initial, consumerOrKey, ...)
|
|
332
|
+
return reduceBehaviors(
|
|
333
|
+
self,
|
|
334
|
+
object,
|
|
335
|
+
operation,
|
|
336
|
+
initial,
|
|
337
|
+
consumerOrKey,
|
|
338
|
+
...
|
|
339
|
+
)
|
|
180
340
|
end
|
|
181
341
|
return ____exports
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** @noSelfInFile */
|
|
2
|
+
import { AbilityBehavior } from "../ability";
|
|
3
|
+
import { Destructor } from "../../../destroyable";
|
|
4
|
+
export declare class AlwaysEnabledAbilityBehavior extends AbilityBehavior {
|
|
5
|
+
protected onCreate(): void;
|
|
6
|
+
protected onDestroy(): Destructor;
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local __TS__Class = ____lualib.__TS__Class
|
|
3
|
+
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
4
|
+
local __TS__InstanceOf = ____lualib.__TS__InstanceOf
|
|
5
|
+
local ____exports = {}
|
|
6
|
+
local ____ability = require("engine.behaviour.ability")
|
|
7
|
+
local AbilityBehavior = ____ability.AbilityBehavior
|
|
8
|
+
local ____ability = require("engine.internal.ability")
|
|
9
|
+
local UnitAbility = ____ability.UnitAbility
|
|
10
|
+
local ____ability_2Ddisable_2Dcounter = require("engine.internal.misc.ability-disable-counter")
|
|
11
|
+
local increaseAbilityDisableCounter = ____ability_2Ddisable_2Dcounter.increaseAbilityDisableCounter
|
|
12
|
+
____exports.AlwaysEnabledAbilityBehavior = __TS__Class()
|
|
13
|
+
local AlwaysEnabledAbilityBehavior = ____exports.AlwaysEnabledAbilityBehavior
|
|
14
|
+
AlwaysEnabledAbilityBehavior.name = "AlwaysEnabledAbilityBehavior"
|
|
15
|
+
__TS__ClassExtends(AlwaysEnabledAbilityBehavior, AbilityBehavior)
|
|
16
|
+
function AlwaysEnabledAbilityBehavior.prototype.onCreate(self)
|
|
17
|
+
local ability = self.ability
|
|
18
|
+
if not __TS__InstanceOf(ability, UnitAbility) then
|
|
19
|
+
return
|
|
20
|
+
end
|
|
21
|
+
increaseAbilityDisableCounter(ability.owner.handle, ability.typeId, -10)
|
|
22
|
+
end
|
|
23
|
+
function AlwaysEnabledAbilityBehavior.prototype.onDestroy(self)
|
|
24
|
+
local ability = self.ability
|
|
25
|
+
if not __TS__InstanceOf(ability, UnitAbility) then
|
|
26
|
+
return AbilityBehavior.prototype.onDestroy(self)
|
|
27
|
+
end
|
|
28
|
+
increaseAbilityDisableCounter(ability.owner.handle, ability.typeId, 10)
|
|
29
|
+
return AbilityBehavior.prototype.onDestroy(self)
|
|
30
|
+
end
|
|
31
|
+
return ____exports
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
import { AbilityBehavior } from "../ability";
|
|
3
3
|
import { Ability } from "../../internal/ability";
|
|
4
|
-
import { Buff, BuffConstructor, BuffParameters, BuffTypeIdSelectionPolicy } from "../../buff";
|
|
4
|
+
import { Buff, BuffConstructor, BuffParameters, BuffPolarityParameterType, BuffResistanceTypeParameterType, BuffTypeIdSelectionPolicy } from "../../buff";
|
|
5
5
|
import { Unit } from "../../internal/unit";
|
|
6
6
|
import { ApplicableBuffTypeId } from "../../object-data/entry/buff-type/applicable";
|
|
7
|
-
import { BuffResistanceType } from "../../object-data/auxiliary/buff-resistance-type";
|
|
8
|
-
import { BuffPolarity } from "../../object-data/auxiliary/buff-polarity";
|
|
9
7
|
import { Widget } from "../../../core/types/widget";
|
|
10
8
|
type BuffParametersType<T extends BuffConstructor> = BuffParameters & Omit<BuffAdditionalParametersType<T>, keyof BuffParameters>;
|
|
11
9
|
type BuffAdditionalParametersType<T extends BuffConstructor> = T extends BuffConstructor<Buff<infer AdditionalParameters>> ? AdditionalParameters : never;
|
|
@@ -17,8 +15,8 @@ export declare abstract class ApplyBuffAbilityBehavior<T extends BuffConstructor
|
|
|
17
15
|
typeIds: [ApplicableBuffTypeId, ...ApplicableBuffTypeId[]],
|
|
18
16
|
typeIdSelectionPolicy: BuffTypeIdSelectionPolicy
|
|
19
17
|
],
|
|
20
|
-
polarity:
|
|
21
|
-
resistanceType:
|
|
18
|
+
polarity: BuffPolarityParameterType,
|
|
19
|
+
resistanceType: BuffResistanceTypeParameterType,
|
|
22
20
|
parameters?: BuffParametersType<T>
|
|
23
21
|
]);
|
|
24
22
|
}
|
|
@@ -35,4 +33,9 @@ export declare class ApplyBuffTargetAreaAbilityBehavior<T extends BuffConstructo
|
|
|
35
33
|
onPointTargetImpact(caster: Unit, x: number, y: number): void;
|
|
36
34
|
onWidgetTargetImpact(caster: Unit, target: Widget): void;
|
|
37
35
|
}
|
|
36
|
+
export declare class ApplyBuffChannelingTargetAbilityBehavior<T extends BuffConstructor = typeof Buff> extends ApplyBuffAbilityBehavior<T> {
|
|
37
|
+
private buff?;
|
|
38
|
+
onUnitTargetChannelingStart(caster: Unit, target: Unit): void;
|
|
39
|
+
onStop(): void;
|
|
40
|
+
}
|
|
38
41
|
export {};
|
|
@@ -27,7 +27,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
27
27
|
constructorOrTypeIdOrTypeIds,
|
|
28
28
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
29
29
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
30
|
-
|
|
30
|
+
self,
|
|
31
31
|
resistanceTypeOrPolarityOrParameters
|
|
32
32
|
)
|
|
33
33
|
end
|
|
@@ -39,7 +39,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
39
39
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
40
40
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
41
41
|
resistanceTypeOrPolarityOrParameters,
|
|
42
|
-
|
|
42
|
+
self,
|
|
43
43
|
parametersOrResistanceType
|
|
44
44
|
)
|
|
45
45
|
end
|
|
@@ -50,7 +50,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
50
50
|
typeIdOrTypeIdsOrPolarityOrTypeIdSelectionPolicy,
|
|
51
51
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
52
52
|
resistanceTypeOrPolarityOrParameters,
|
|
53
|
-
|
|
53
|
+
self,
|
|
54
54
|
parametersOrResistanceType
|
|
55
55
|
)
|
|
56
56
|
end
|
|
@@ -62,7 +62,7 @@ function ApplyBuffAbilityBehavior.prototype.____constructor(self, ability, const
|
|
|
62
62
|
polarityOrTypeIdSelectionPolicyOrResistanceType,
|
|
63
63
|
resistanceTypeOrPolarityOrParameters,
|
|
64
64
|
parametersOrResistanceType,
|
|
65
|
-
|
|
65
|
+
self,
|
|
66
66
|
parameters
|
|
67
67
|
)
|
|
68
68
|
end
|
|
@@ -123,4 +123,36 @@ function ApplyBuffTargetAreaAbilityBehavior.prototype.onWidgetTargetImpact(self,
|
|
|
123
123
|
self.applyBuff(unit)
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
|
+
local behaviorByBuff = {}
|
|
127
|
+
____exports.ApplyBuffChannelingTargetAbilityBehavior = __TS__Class()
|
|
128
|
+
local ApplyBuffChannelingTargetAbilityBehavior = ____exports.ApplyBuffChannelingTargetAbilityBehavior
|
|
129
|
+
ApplyBuffChannelingTargetAbilityBehavior.name = "ApplyBuffChannelingTargetAbilityBehavior"
|
|
130
|
+
__TS__ClassExtends(ApplyBuffChannelingTargetAbilityBehavior, ____exports.ApplyBuffAbilityBehavior)
|
|
131
|
+
function ApplyBuffChannelingTargetAbilityBehavior.prototype.onUnitTargetChannelingStart(self, caster, target)
|
|
132
|
+
local previousBuff = self.buff
|
|
133
|
+
if previousBuff ~= nil then
|
|
134
|
+
behaviorByBuff[previousBuff] = nil
|
|
135
|
+
previousBuff:destroy()
|
|
136
|
+
end
|
|
137
|
+
local buff = self.applyBuff(target)
|
|
138
|
+
if buff ~= nil then
|
|
139
|
+
behaviorByBuff[buff] = self
|
|
140
|
+
end
|
|
141
|
+
self.buff = buff
|
|
142
|
+
end
|
|
143
|
+
function ApplyBuffChannelingTargetAbilityBehavior.prototype.onStop(self)
|
|
144
|
+
local buff = self.buff
|
|
145
|
+
if buff ~= nil then
|
|
146
|
+
behaviorByBuff[buff] = nil
|
|
147
|
+
buff:destroy()
|
|
148
|
+
self.buff = nil
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
Buff.beingDestroyedEvent:addListener(function(buff)
|
|
152
|
+
local behavior = behaviorByBuff[buff]
|
|
153
|
+
if behavior ~= nil then
|
|
154
|
+
behaviorByBuff[buff] = nil
|
|
155
|
+
behavior.ability:interruptCast()
|
|
156
|
+
end
|
|
157
|
+
end)
|
|
126
158
|
return ____exports
|
|
@@ -3,14 +3,19 @@ import { AbilityBehavior } from "../ability";
|
|
|
3
3
|
import { Ability } from "../../internal/ability";
|
|
4
4
|
import { UnitBehavior } from "../unit";
|
|
5
5
|
import { Unit } from "../../internal/unit";
|
|
6
|
+
import { MutableKeys } from "../../../utility/types";
|
|
6
7
|
import { AbilityDependentValue } from "../../object-field/ability";
|
|
8
|
+
type UnitBehaviorParameters<T extends UnitBehavior> = Partial<{
|
|
9
|
+
[K in MutableKeys<T> & KeysOfType<T, boolean | number | string>]: T[K] extends boolean | number | string ? AbilityDependentValue<T[K]> : never;
|
|
10
|
+
}>;
|
|
7
11
|
export declare class ApplyUnitBehaviorAbilityBehavior<T extends UnitBehavior> extends AbilityBehavior {
|
|
8
12
|
private readonly unitBehaviorConstructor;
|
|
9
13
|
private readonly parameters?;
|
|
10
14
|
private readonly keys?;
|
|
11
15
|
private unitBehavior?;
|
|
12
|
-
constructor(ability: Ability, unitBehaviorConstructor: new (unit: Unit) => T, parameters?:
|
|
16
|
+
constructor(ability: Ability, unitBehaviorConstructor: new (unit: Unit) => T, parameters?: UnitBehaviorParameters<T> | undefined);
|
|
13
17
|
update(): void;
|
|
14
18
|
onUnitGainAbility(unit: Unit): void;
|
|
15
19
|
onUnitLoseAbility(): void;
|
|
16
20
|
}
|
|
21
|
+
export {};
|