perf: harden runtime for weaker hardware
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user