import Signal from "@rbxts/sleitnick-signal"; import { t } from "@rbxts/t"; import { Timer } from "@rbxts/timer"; import type { Character, DamageContainer } from "./character"; import { Flags } from "./flags"; import type { AnyStatus } from "./statusEffect"; import { type Constructor, type DeepReadonly } from "./utility"; export interface SkillState { IsActive: boolean; Debounce: boolean; MaxHoldTime?: number; StarterParams: unknown[]; } export declare enum SkillType { Default = "Default", Holdable = "Holdable" } /** @hidden */ export interface _internal_SkillState extends SkillState { _timerEndTimestamp?: number; } type ReadonlyState = DeepReadonly; export interface SkillData { state: _internal_SkillState; constructorArguments: unknown[]; metadata: unknown; } export type AnySkill = SkillBase; export type UnknownSkill = SkillBase; export type SkillConstructor = new (...args: [Character, ...constructorArgs: any[]]) => UnknownSkill; type ValidatorArray = T extends [ infer First, ...infer Rest ] ? readonly [t.check, ...ValidatorArray] : readonly t.check[]; /** @hidden */ export declare abstract class SkillBase { /** * A Janitor object. Cleans up everything after skill ends. */ protected readonly Janitor: import("@rbxts/janitor").Janitor; /** * A Timer object. Starts, when ApplyCooldown() gets invoked on server. Does not sync to client. */ protected readonly CooldownTimer: Timer; /** * A Character object this skill is tied with. */ readonly Character: Character; /** Fires whenever skill starts. Works on client and server. */ readonly Started: Signal<[]>; /** Fires whenever skill ends. Works on client and server. */ readonly Ended: Signal<[]>; /** Fires whenever current skill state changes. */ readonly StateChanged: Signal<[NewState: SkillState, OldState: SkillState]>; /** Fires whenever skill gets destroyed (removed from the character). */ readonly Destroyed: Signal<[]>; /** Fires whenever skill metadata changes. */ readonly MetadataChanged: Signal<[NewMeta: Metadata | undefined, PreviousMeta: Metadata | undefined]>; /** * Checks whenever other skills should be non active for :Start() to proceed. */ protected CheckOthersActive: boolean; /** * Determines if other skills should check if the skill is active to proceed. */ protected CheckedByOthers: boolean; /** * An array of Status Effect constructors. * If any of them is applied to Character object whenever Start() is called, it will not proceed further and skill will not be started. */ protected MutualExclusives: Constructor[]; /** * An array of Status Effect constructors. * Checks Character for the following effects to be applied before starting the skill. */ protected Requirements: Constructor[]; /** Checks whenever the start function should check if the skill is active/on cooldown on client side before firing a remote. */ protected CheckClientState: boolean; protected readonly ParamValidators?: ValidatorArray; /** * A Player object the skill is associated with. Retrieved internally by Players:GetPlayerFromCharacter(self.Character.Instance). */ readonly Player?: Player; private _internal_state; private _internal_destroyed; private _internal_metadata?; protected readonly Name: string; /** * A table of arguments provided after the Character in .new(). */ protected readonly ConstructorArguments: ConstructorArguments; constructor(Character: Character, ...Args: ConstructorArguments); /** * Server: Starts the skill * Client: Sends a request to server that will call :Start() on server */ Start(...params: StarterParams): void; /** Returns true if the skill is destroyed / removed from the Character. */ IsDestroyed(): boolean; /** * Force end the skill. This is automatically called after OnStartServer() is completed */ End(): void; /** Alias for End() */ Stop(): void; /** Retrieves the skill type */ GetSkillType(): SkillType; /** * Destroys the skill and removes it from the character */ Destroy(): void; /** @hidden */ Destroy(flag: (typeof Flags)["CanDestroyLocallyClient"]): void; GetDebounceEndTimestamp(): number | undefined; /** Retrieves the current skill state. */ GetState(): ReadonlyState; /** Retrieves the skill name. */ GetName(): string; /** * Clears the current Metadata. Only works on server. */ protected ClearMetadata(): void; /** * Sets the current Metadata. */ protected SetMetadata(NewMeta: Metadata): void; /** * Retrieves the current Metadata. * */ GetMetadata(): Metadata | undefined; /** * Creates a damage container, with the current skill specified in Source. */ protected CreateDamageContainer(Damage: number): DamageContainer; /** * Applies a cooldown to the skill. Works only on server. */ ApplyCooldown(Duration: number): void; CancelCooldown(): void; ExtendCooldown(Duration: number): void; /** * Determines if the skill should start, when Start() is called. */ protected ShouldStart(...params: StarterParams): boolean; private _internal_startReplication; private _internal_packData; protected OnConstruct(...Args: ConstructorArguments): void; protected OnConstructClient(...Args: ConstructorArguments): void; protected OnConstructServer(...Args: ConstructorArguments): void; /** Called whenever skill starts on the server. Accepts an argument passed to Start(). */ protected OnStartServer(...Params: StarterParams): void; /** Called whenever skill starts on the client. Accepts an argument passed to Start(). */ protected OnStartClient(...Params: StarterParams): void; /** Called whenever server when a message from client was received. */ protected OnEndClient(): void; /** Called whenever skill ends on client. */ protected OnEndServer(): void; protected AssumeStart(...Params: StarterParams): void; } /** A skill class. */ export declare abstract class Skill extends SkillBase { constructor(Character: Character, ...Args: ConstructorArguments); } /** * A decorator function that registers a skill. */ export declare function SkillDecorator(Constructor: T): void; /** * Retrieves the constructor function of a registered skill by name. */ export declare function GetRegisteredSkillConstructor(Name: string): SkillConstructor | undefined; export {};