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 ​
TogglePayment | cost_timing | TogglePayment.ON_ACTIVATE |
TogglePayment | cooldown_timing | TogglePayment.ON_DEACTIVATE |
bool | has_resource_drain | false |
PoolType | drain_pool_type | PoolType.RESOURCE_POOL |
int | drain_pool_id | 0 |
float | drain_per_second | 5.0 |
bool | auto_deactivate_on_empty | true |
float | deactivate_threshold_percent | 0.0 |
String | toggle_group | "" |
bool | deactivate_group_members | true |
float | min_active_duration | 0.0 |
float | max_active_duration | -1.0 |
CompressedTexture2D | active_icon |
Methods ​
bool | charges_at( timing: TogglePayment, switching_on: bool ) |
void | execute_strategy( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) |
void | attempt_activate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) |
bool | is_min_duration_running( strategy_instance: UseStrategyInstance ) |
void | attempt_deactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) |
void | activate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) |
void | deactivate_toggle( strategy_instance: UseStrategyInstance, user: Entity, target: Variant ) |
EffectInstance | apply_effect_and_get_instance( effect: Effect, target: Variant, strategy_instance: UseStrategyInstance ) |
void | setup_toggle_timers( strategy_instance: UseStrategyInstance ) |
void | stop_toggle_timers( strategy_instance: UseStrategyInstance ) |
void | update_toggle_appearance( strategy_instance: UseStrategyInstance ) |
bool | can_activate_in_group( user: Entity ) |
void | deactivate_group_members_func( user: Entity ) |
PoolInstance | get_drain_pool( user: Entity ) |
Variant | get_property_value( strategy_instance: UseStrategyInstance, property_name: String ) |
void | cleanup_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