ImmunityComponent ​
Inherits: RefCounted
Manages ImmunityDefinition-based immunities (damage types, status effects, schools, etc.)
Variables ​
Dictionary | active_immunities | {} # Key: immunity_id, Value: ImmunityInstance |
Methods ​
bool | activate_immunity( chrono_manager: ChronoManager, immunity_id: int, duration: float = -1.0, permanent: bool = false ) |
bool | deactivate_immunity( immunity_id: int ) |
Dictionary | is_immune_to_damage_type( damage_type: int ) |
Dictionary | is_immune_to_school_type( school_id: int ) |
Dictionary | is_immune_to_status_effect( status_effect_id: int ) |
Dictionary | check_damage_immunity( damage_amount: float, damage_type: int, damage_source: Variant = null, effect: EffectInstance = null ) |
Dictionary | check_school_immunity( school_id: int, source_entity: Variant = null, effect: EffectInstance = null ) |
Dictionary | check_status_effect_immunity( status_effect_id: int, source_entity: Variant = null, effect: EffectInstance = null ) |
float | get_immunity_time_remaining( immunity_id: int ) |
bool | has_any_immunity() |
Array[int] | get_active_immunities() |
Array[int] | get_immunities_by_type( immunity_type: ImmunityDefinition.ImmunityType ) |
Array[int] | get_protected_targets_for_immunity( immunity_id: int ) |
void | cleanup() |
int | get_active_immunity_count() |
Signals ​
immunity_activated( immunity_id: int, duration: float, immunity_type: ImmunityDefinition.ImmunityType, protected_targets: Array[int] ) ​
========== SIGNALS ========== Immunity events
immunity_deactivated( immunity_id: int, immunity_type: ImmunityDefinition.ImmunityType, protected_targets: Array[int] ) ​
Emitted when a temporary immunity ends.
damage_blocked_by_immunity( damage_id: int, immunity_id: int, blocked_amount: float, damage_source: Variant, effect: EffectInstance ) ​
Enhanced blocking events with context
school_effect_blocked_by_immunity( school_id: int, immunity_id: int, source_entity: Variant, effect: EffectInstance ) ​
Emitted when an immunity stops an effect of a school: the school, the immunity, the source and the effect.
status_effect_blocked_by_immunity( status_effect_id: int, immunity_id: int, source_entity: Variant, effect: EffectInstance ) ​
Emitted when an immunity stops a status effect: the status, the immunity, the source and the effect.
Variable descriptions ​
Dictionary active_immunities = # Key: immunity_id, Value: ImmunityInstance ​
========== CORE PROPERTIES ========== Active immunity instances - now self-managing via ImmunityInstance timers
Method descriptions ​
bool activate_immunity( chrono_manager: ChronoManager, immunity_id: int, duration: float = -1.0, permanent: bool = false ) ​
Switches an immunity (ImmunityDefinition id) on for duration seconds (10 when it is 0 or less; permanent has no timer and never ends). An immunity that is already on is replaced. Emits immunity_activated. False when the definition does not exist
bool deactivate_immunity( immunity_id: int ) ​
Switches an immunity off, ahead of its time or when it ran out. Emits immunity_deactivated. False when it was not active
Dictionary is_immune_to_damage_type( damage_type: int ) ​
Does an active damage immunity cover this damage type? A dictionary with is_immune, immunity_id and immunity_type
Dictionary is_immune_to_school_type( school_id: int ) ​
Does an active school immunity cover this ability school? A dictionary with is_immune, immunity_id and immunity_type
Dictionary is_immune_to_status_effect( status_effect_id: int ) ​
Does an active status effect immunity cover this status effect? A dictionary with is_immune, immunity_id, immunity_type and reason
Dictionary check_damage_immunity( damage_amount: float, damage_type: int, damage_source: Variant = null, effect: EffectInstance = null ) ​
Asks the question for a hit and announces the answer: a dictionary with is_blocked, blocked_amount, immunity_id and can_proceed. Emits damage_blocked_by_immunity when blocked
Dictionary check_school_immunity( school_id: int, source_entity: Variant = null, effect: EffectInstance = null ) ​
The same for an effect of a school: is_blocked, immunity_id, can_proceed. Emits school_effect_blocked_by_immunity when blocked
Dictionary check_status_effect_immunity( status_effect_id: int, source_entity: Variant = null, effect: EffectInstance = null ) ​
The same for a status effect: is_blocked, immunity_id, can_proceed. Emits status_effect_blocked_by_immunity when blocked
float get_immunity_time_remaining( immunity_id: int ) ​
Seconds an immunity has left (0 when it is not active, -1 when it is permanent)
bool has_any_immunity() ​
True while any immunity is active
Array[int] get_active_immunities() ​
The ids of the active immunities
Array[int] get_immunities_by_type( immunity_type: ImmunityDefinition.ImmunityType ) ​
The ids of the active immunities of one type (damage type, status effect or school)
Array[int] get_protected_targets_for_immunity( immunity_id: int ) ​
A copy of what an active immunity protects against
void cleanup() ​
Ends every immunity without announcing it
int get_active_immunity_count() ​
How many immunities are active