Skip to content

ToggleUseStrategyDefinition ​

Inherits: UseStrategyDefinition < Resource

Definition for abilities that can be turned on and off (stance abilities, auras, etc.). Handles activation/deactivation logic, resource draining, and toggle group management.

Properties ​

TogglePaymentcost_timingTogglePayment.ON_ACTIVATE
TogglePaymentcooldown_timingTogglePayment.ON_DEACTIVATE
boolhas_resource_drainfalse
PoolTypedrain_pool_typePoolType.RESOURCE_POOL
intdrain_pool_id0
floatdrain_per_second5.0
boolauto_deactivate_on_emptytrue
floatdeactivate_threshold_percent0.0
Stringtoggle_group""
booldeactivate_group_memberstrue
floatmin_active_duration0.0
floatmax_active_duration-1.0
CompressedTexture2Dactive_icon

Methods ​

boolcharges_at( timing: TogglePayment, switching_on: bool )
voidexecute_strategy( strategy_instance: UseStrategyInstance, user: Entity, target: Variant )
voidattempt_activate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant )
boolis_min_duration_running( strategy_instance: UseStrategyInstance )
voidattempt_deactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant )
voidactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant )
voiddeactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant )
EffectInstanceapply_effect_and_get_instance( effect: Effect, target: Variant, strategy_instance: UseStrategyInstance )
voidsetup_toggle_timers( strategy_instance: UseStrategyInstance )
voidstop_toggle_timers( strategy_instance: UseStrategyInstance )
voidupdate_toggle_appearance( strategy_instance: UseStrategyInstance )
boolcan_activate_in_group( user: Entity )
voiddeactivate_group_members_func( user: Entity )
PoolInstanceget_drain_pool( user: Entity )
Variantget_property_value( strategy_instance: UseStrategyInstance, property_name: String )
voidcleanup_timing_resources( strategy_instance: UseStrategyInstance, user: Entity )

Enumerations ​

enum PoolType ​

The options of pool type: health pool, resource pool.

  • HEALTH_POOL = 0
  • RESOURCE_POOL = 1

enum TogglePayment ​

When a toggle charges its cost or starts its cooldown

  • ON_ACTIVATE = 0 - when it is switched on
  • ON_DEACTIVATE = 1 - when it is switched off
  • BOTH = 2 - on every switch

Property descriptions ​

TogglePayment cost_timing = TogglePayment.ON_ACTIVATE ​

When the ability's resource cost is paid (the cooldown and cost of an ability apply to a toggle through these two settings)

TogglePayment cooldown_timing = TogglePayment.ON_DEACTIVATE ​

When the ability's cooldown starts. A toggle can always be switched off during a cooldown; it cannot be switched on again until it ends

bool has_resource_drain = false ​

Whether this toggle drains resources while active

PoolType drain_pool_type = PoolType.RESOURCE_POOL ​

Type of pool to drain from (health_pool or resource_pool)

int drain_pool_id = 0 ​

Specific name of the pool to drain from (mana, stamina, etc.)

float drain_per_second = 5.0 ​

Amount of resources consumed per second while active

bool auto_deactivate_on_empty = true ​

Whether to automatically deactivate when resources are exhausted

float deactivate_threshold_percent = 0.0 ​

Percentage threshold below which to auto-deactivate (0-100)

String toggle_group = "" ​

Group name for mutually exclusive toggles (abilities in same group deactivate each other)

bool deactivate_group_members = true ​

Whether activating this toggle should deactivate other members of the same group

float min_active_duration = 0.0 ​

Minimum time this toggle must stay active before it can be deactivated

float max_active_duration = -1.0 ​

Maximum time this toggle can stay active (-1 for unlimited)

CompressedTexture2D active_icon ​

Icon to display when the toggle is active (overrides base ability icon)

Method descriptions ​

bool charges_at( timing: TogglePayment, switching_on: bool ) ​

Does a payment set to timing happen on this switch?

void execute_strategy( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) ​

Execute toggle strategy - activate/deactivate based on current state

void attempt_activate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) ​

Attempt to activate the toggle (checks group restrictions)

bool is_min_duration_running( strategy_instance: UseStrategyInstance ) ​

Is the toggle still inside its minimum active duration (it cannot be switched off yet)?

void attempt_deactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) ​

Attempt to deactivate the toggle (checks minimum duration)

void activate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) ​

Internal toggle activation logic

void deactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) ​

Internal toggle deactivation logic

EffectInstance apply_effect_and_get_instance( effect: Effect, target: Variant, strategy_instance: UseStrategyInstance ) ​

Apply effect and return instance for tracking

void setup_toggle_timers( strategy_instance: UseStrategyInstance ) ​

Setup toggle-specific timers

void stop_toggle_timers( strategy_instance: UseStrategyInstance ) ​

Stop toggle timers

void update_toggle_appearance( strategy_instance: UseStrategyInstance ) ​

Update toggle appearance based on current state

bool can_activate_in_group( user: Entity ) ​

Check if this toggle can activate in its group

void deactivate_group_members_func( user: Entity ) ​

Deactivate other members of the same toggle group

PoolInstance get_drain_pool( user: Entity ) ​

Get drain pool for resource consumption

Variant get_property_value( strategy_instance: UseStrategyInstance, property_name: String ) ​

Get property value with runtime override support

void cleanup_timing_resources( strategy_instance: UseStrategyInstance, user: Entity ) ​

Clean up toggle-specific resources