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()
-10
View File
@@ -8,7 +8,6 @@ const HOSTILE_SCENE := preload("res://world/combat/HostileCombatant.tscn")
@export var wolf_spawn_positions: PackedVector3Array = PackedVector3Array()
var hostiles: Dictionary = {}
var _initialized := false
var _wolves_spawned := false
@@ -20,7 +19,6 @@ func _ready() -> void:
simulation_manager.combatant_spawned.connect(_on_combatant_spawned)
simulation_manager.combatant_died.connect(_on_combatant_died)
simulation_manager.state_restored.connect(_on_state_restored)
_initialized = true
call_deferred("_spawn_wolves")
_refresh_from_state()
@@ -34,14 +32,6 @@ func _spawn_wolves() -> void:
simulation_manager.spawn_wolf(position)
func _process(_delta: float) -> void:
if not _initialized:
return
for combatant_id in _hostile_ids():
if not hostiles.has(combatant_id):
_spawn_visual(combatant_id)
func _hostile_ids() -> Array:
var ids: Array[StringName] = []
var living: Array = simulation_manager.get_living_hostile_combatants()