Constructor
new AbilityExecutor(optionsopt)
| Name | Type | Attributes | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | Object | <optional> | Properties
|
Classes
Members
_cooldowns
Cooldowns map: Map<string, Map<string, number>> (casterId -> abilityId -> remainingSeconds)
_instances
Active execution instances: Map<number, Object>
_listeners
Event listeners: Map<string, Set
Methods
_advanceSequence()
Advance a pending sequence until completion or until paused by an active delay.
_cancelInstance(instance, reason)
Internal helper to cancel an instance cleanly.
| Name | Type | Description |
|---|---|---|
instance | Object | |
reason | string |
_consumeOperation(instance)
Consume an operation from the execution budget.
| Name | Type | Description |
|---|---|---|
instance | Object |
_emit(event, payload)
Emit an event to local listeners and optional external event bus.
| Name | Type | Description |
|---|---|---|
event | string | |
payload | Object |
_executeAreaEffectNode()
Execute 'area_effect' node: finds targets within radius and triggers onHit on them.
_executeConditionNode()
Execute 'condition' node: branches to onTrue or onFalse based on check result.
_executeDamageNode()
Execute 'damage' node: applies damage to target Combatant / Stats.
_executeFilterNode()
Execute 'filter' node: filters current targets by faction, type, and maxTargets.
_executeHealNode()
Execute 'heal' node: applies healing to target Combatant / Stats.
_executeKnockbackNode()
Execute 'knockback' node: applies knockback to targets.
_executeNode(instance, nodeId)
Execute a single node in the ability graph.
| Name | Type | Description |
|---|---|---|
instance | Object | |
nodeId | string |
_executePresentationNode()
Execute 'presentation' node: emits presentation cues via event bus.
_executeProjectileNode()
Execute 'projectile' node: launches a simulated projectile traveling toward cursor/target.
_executeSequenceNode()
Execute 'sequence' node: steps through child nodes sequentially, pausing on delays.
_executeStatusNode()
Execute 'status' node: applies status effect to targets.
_executeTargetNode()
Execute 'target' node: resolves target actors (caster, enemies, allies, cursor, cone, radius).
_executeTimedActionNode()
Execute 'timed_action' node: registers a delay and pauses execution flow.
_getCandidateActors(instance) → {Array}
Collect candidate actors for targeting from context and executor defaults.
| Name | Type | Description |
|---|---|---|
instance | Object |
- Type:
- Array
_isInstanceFinished(instance) → {boolean}
Helper to determine whether an execution instance has completed all active work.
| Name | Type | Description |
|---|---|---|
instance | Object |
- Type:
- boolean
cancelAll(reasonopt) → {number}
Cancel all running executions across all casters.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
reason | string | <optional> | "cancelled" |
Number of instances cancelled
- Type:
- number
cancelByCaster(casterId, reasonopt) → {number}
Cancel all running executions for a specific caster.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
casterId | string | |||
reason | string | <optional> | "cancelled" |
Number of instances cancelled
- Type:
- number
cast(abilityDef, contextopt) → {Object}
Alias for execute().
| Name | Type | Attributes | Description |
|---|---|---|---|
abilityDef | Object | ||
context | Object | <optional> |
- Type:
- Object
execute(abilityDef, contextopt) → {Object}
Execute an ability graph definition against an execution context. Validates the graph, enforces cooldowns and caster survival, and steps execution.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
abilityDef | Object | Validated or validatable ability definition graph | ||
context | Object | <optional> | {} | Execution context (caster, target, targets, cursor, world, actors) |
Execution result { success, instance, status, reason }
- Type:
- Object
getActiveInstances(casterIdopt) → {Array}
Get all active execution instances, optionally filtered by caster ID.
| Name | Type | Attributes | Description |
|---|---|---|---|
casterId | string | <optional> |
- Type:
- Array
getCooldown(casterId, abilityId) → {number}
Get the remaining cooldown time for an ability and caster in seconds.
| Name | Type | Description |
|---|---|---|
casterId | string | |
abilityId | string |
Remaining cooldown in seconds, or 0
- Type:
- number
isOnCooldown(casterId, abilityId) → {boolean}
Check if an ability is currently on cooldown for a given caster.
| Name | Type | Description |
|---|---|---|
casterId | string | |
abilityId | string |
- Type:
- boolean
off(event, listener) → {boolean}
Remove an event listener.
| Name | Type | Description |
|---|---|---|
event | string | |
listener | function |
- Type:
- boolean
on(event, listener) → {function}
Subscribe to executor events.
| Name | Type | Description |
|---|---|---|
event | string | |
listener | function |
Unsubscribe function
- Type:
- function
resetAllCooldowns()
Reset all tracked cooldowns across all casters.
resetCooldown(casterId, abilityId)
Reset cooldown for a specific caster and ability.
| Name | Type | Description |
|---|---|---|
casterId | string | |
abilityId | string |
setCooldown(casterId, abilityId, duration)
Set a cooldown duration for a caster and ability.
| Name | Type | Description |
|---|---|---|
casterId | string | |
abilityId | string | |
duration | number | Cooldown in seconds |
update(deltaTime)
Advance simulation time for all active executions and cooldowns. Enforces caster death cancellation and operation budgets.
| Name | Type | Default | Description |
|---|---|---|---|
deltaTime | number | 0 | Time step in seconds |