Update player health from state in replays

This commit is contained in:
Sofia 2026-07-27 20:23:19 +03:00
parent def6539bbc
commit 1a0a11cccc
2 changed files with 8 additions and 0 deletions

View File

@ -326,6 +326,11 @@ impl RemotePlayer {
double_health_bar.set_value(double_value);
}
}
pub fn set_hp(&mut self, health: i32) {
self.health = health;
self.update_health_bar();
}
}
#[godot_dyn]

View File

@ -308,6 +308,7 @@ impl INode for ReplayPlayback {
character
.bind_mut()
.set_movement_dir(state.movement_dir.into());
character.bind_mut().set_hp(state.health);
let weapon = character.bind().get_weapon().clone();
if let Some(weapon) = weapon
&& weapon.dyn_bind().get_type() != state.current_weapon
@ -593,6 +594,7 @@ pub struct ReplayPlayerState {
pub is_dead: bool,
pub kills: u16,
pub deaths: u16,
pub health: i32,
}
impl Player {
@ -610,6 +612,7 @@ impl Player {
is_dead: character.dyn_bind().is_dead(),
kills: player.data.kills,
deaths: player.data.deaths,
health: character.dyn_bind().get_health(),
})
} else {
None