perf: harden runtime for weaker hardware

This commit is contained in:
Rijad Zuzo
2026-08-12 10:02:45 +02:00
parent cd29da95e0
commit 34428d836a
47 changed files with 2164 additions and 243 deletions
+9 -7
View File
@@ -5,6 +5,7 @@ var combatant: CombatantStateRecord
var simulation_manager: Node
var _flash_tween: Tween
var _spawn_tween: Tween
var _last_health := 0.0
func _ready() -> void:
@@ -24,22 +25,21 @@ func bind(combatant_id_value: StringName, manager: Node) -> void:
global_position = combatant.get_position()
sim_position = combatant.get_position()
_build_from_definition()
_last_health = combatant.get_health()
combatant.changed.connect(_on_combatant_changed)
func _process(_delta: float) -> void:
func _on_combatant_changed(_state: CombatantStateRecord) -> void:
if is_dead_visual or combatant == null or not is_instance_valid(combatant):
return
if not combatant.is_alive():
play_death()
return
set_sim_position(combatant.get_position())
func _on_combatant_changed(_state: CombatantStateRecord) -> void:
if combatant == null or combatant.get_health() >= combatant.get_max_health():
return
_flash_hit()
var current_health := combatant.get_health()
if current_health < _last_health:
_flash_hit()
_last_health = current_health
func _flash_hit() -> void:
@@ -51,6 +51,8 @@ func _flash_hit() -> void:
func play_death() -> void:
if is_dead_visual:
return
is_dead_visual = true
super.play_death()