class_name SimBoss extends RefCounted ## A boss instance. All fight-specific behaviour lives in its [BossDef]; this ## class only advances the phase timeline. var id: int = 0 var def: BossDef var pos := Vector2.ZERO var hp: int = 1 var alive: bool = true var phase_index: int = 0 ## Ticks since entering the current phase. var phase_tick: int = 0 ## The arena this boss may occupy, in world space. A boss never leaves it, so a ## player can always disengage by walking out -- which is the trade for the ## boss room having no door that locks. var room := Rect2() ## WAYPOINTS movement: which point it is walking to, and how long it still ## stands at the one it reached. var waypoint_index: int = 0 var waypoint_wait: int = 0 ## Poison doses ticking on the boss. Lazy for the same reason enemies' are. var poison: PoisonTrack = null func poison_track() -> PoisonTrack: if poison == null: poison = PoisonTrack.new() return poison func hp_fraction() -> float: if def == null or def.max_hp <= 0: return 0.0 return float(hp) / float(def.max_hp) func current_phase() -> BossPhase: if def == null or def.phases.is_empty(): return null return def.phases[clampi(phase_index, 0, def.phases.size() - 1)]