Show kills and deaths correctly in after-replay view
This commit is contained in:
parent
9cd6a40ac5
commit
bc1bad8ab5
@ -82,6 +82,7 @@ offset_bottom = 133.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
|
|
||||||
[node name="save_dialog" type="FileDialog" parent="." unique_id=1637714468]
|
[node name="save_dialog" type="FileDialog" parent="." unique_id=1637714468]
|
||||||
|
access = 2
|
||||||
filters = PackedStringArray("*.replay")
|
filters = PackedStringArray("*.replay")
|
||||||
|
|
||||||
[connection signal="pressed" from="save_replay" to="." method="open_file_dialog"]
|
[connection signal="pressed" from="save_replay" to="." method="open_file_dialog"]
|
||||||
|
|||||||
@ -254,6 +254,7 @@ text = "Ok"
|
|||||||
[node name="open_replay_dialog" type="FileDialog" parent="." unique_id=925465558]
|
[node name="open_replay_dialog" type="FileDialog" parent="." unique_id=925465558]
|
||||||
title = "Open a File"
|
title = "Open a File"
|
||||||
file_mode = 0
|
file_mode = 0
|
||||||
|
access = 2
|
||||||
filters = PackedStringArray("*.replay")
|
filters = PackedStringArray("*.replay")
|
||||||
|
|
||||||
[connection signal="pressed" from="main_panel/v_box_container/host" to="." method="go_to_host_game"]
|
[connection signal="pressed" from="main_panel/v_box_container/host" to="." method="go_to_host_game"]
|
||||||
|
|||||||
@ -108,6 +108,7 @@ impl StandaloneReplayManager {
|
|||||||
#[class(base=Node, init)]
|
#[class(base=Node, init)]
|
||||||
pub struct ReplayPlayback {
|
pub struct ReplayPlayback {
|
||||||
pub replay: Replay,
|
pub replay: Replay,
|
||||||
|
pub player_data: HashMap<u16, ReplayPlayerState>,
|
||||||
pub current_map: Option<Gd<Map>>,
|
pub current_map: Option<Gd<Map>>,
|
||||||
current_frame_idx: usize,
|
current_frame_idx: usize,
|
||||||
player_characters: HashMap<u16, Gd<RemotePlayer>>,
|
player_characters: HashMap<u16, Gd<RemotePlayer>>,
|
||||||
@ -152,6 +153,8 @@ impl INode for ReplayPlayback {
|
|||||||
while let Some(frame) = self.replay.frames.get(self.current_frame_idx)
|
while let Some(frame) = self.replay.frames.get(self.current_frame_idx)
|
||||||
&& frame.time <= self.current_time
|
&& frame.time <= self.current_time
|
||||||
{
|
{
|
||||||
|
self.player_data = frame.player_data.clone();
|
||||||
|
|
||||||
if let ReplayBall::World(ball_state) = &frame.ball_data {
|
if let ReplayBall::World(ball_state) = &frame.ball_data {
|
||||||
if let Some(ball) = &mut self.ball {
|
if let Some(ball) = &mut self.ball {
|
||||||
ball.bind_mut().apply_sync(BallSync {
|
ball.bind_mut().apply_sync(BallSync {
|
||||||
@ -319,6 +322,8 @@ impl INode for ReplayRecorder {
|
|||||||
name: player.data.name.clone(),
|
name: player.data.name.clone(),
|
||||||
color: team.bind().color.into(),
|
color: team.bind().color.into(),
|
||||||
team: player.data.team,
|
team: player.data.team,
|
||||||
|
kills: 0,
|
||||||
|
deaths: 0,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -381,6 +386,10 @@ impl ReplayRecorder {
|
|||||||
if let Some(state) = player.get_state() {
|
if let Some(state) = player.get_state() {
|
||||||
player_data.insert(player.id(), state);
|
player_data.insert(player.id(), state);
|
||||||
}
|
}
|
||||||
|
if let Some(replay_player) = self.replay.players.get_mut(&player.id()) {
|
||||||
|
replay_player.kills = player.data.kills;
|
||||||
|
replay_player.deaths = player.data.deaths;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ball_data = if let Some(ball) = &game.bind().world_ball {
|
ball_data = if let Some(ball) = &game.bind().world_ball {
|
||||||
ReplayBall::World(ReplayBallData {
|
ReplayBall::World(ReplayBallData {
|
||||||
@ -439,6 +448,8 @@ pub struct ReplayPlayer {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub color: ReplayColor,
|
pub color: ReplayColor,
|
||||||
pub team: u8,
|
pub team: u8,
|
||||||
|
pub kills: u16,
|
||||||
|
pub deaths: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
@ -504,11 +515,18 @@ pub struct ReplayPlayerState {
|
|||||||
pub look_up: f32,
|
pub look_up: f32,
|
||||||
pub current_weapon: WeaponType,
|
pub current_weapon: WeaponType,
|
||||||
pub is_dead: bool,
|
pub is_dead: bool,
|
||||||
|
pub kills: u16,
|
||||||
|
pub deaths: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
pub fn get_state(&self) -> Option<ReplayPlayerState> {
|
pub fn get_state(&self) -> Option<ReplayPlayerState> {
|
||||||
if let Some(character) = &self.character {
|
if let Some(character) = &self.character
|
||||||
|
&& let Some(game) = Game::singleton()
|
||||||
|
&& let Some(player) = game
|
||||||
|
.bind()
|
||||||
|
.find_player(character.dyn_bind().get_player_id().unwrap_or(0))
|
||||||
|
{
|
||||||
Some(ReplayPlayerState {
|
Some(ReplayPlayerState {
|
||||||
transform: character.dyn_bind().get_transform(),
|
transform: character.dyn_bind().get_transform(),
|
||||||
movement_dir: character.dyn_bind().get_movement_dir().into(),
|
movement_dir: character.dyn_bind().get_movement_dir().into(),
|
||||||
@ -519,6 +537,8 @@ impl Player {
|
|||||||
.map(|w| w.dyn_bind().get_type())
|
.map(|w| w.dyn_bind().get_type())
|
||||||
.unwrap_or(WeaponType::Raygun),
|
.unwrap_or(WeaponType::Raygun),
|
||||||
is_dead: character.dyn_bind().is_dead(),
|
is_dead: character.dyn_bind().is_dead(),
|
||||||
|
kills: player.data.kills,
|
||||||
|
deaths: player.data.deaths,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
@ -98,6 +98,12 @@ impl PlayerListing {
|
|||||||
if let Some(name_label) = &mut self.name_label {
|
if let Some(name_label) = &mut self.name_label {
|
||||||
name_label.set_text(&player.name);
|
name_label.set_text(&player.name);
|
||||||
}
|
}
|
||||||
|
if let Some(kills_label) = &mut self.kills_label {
|
||||||
|
kills_label.set_text(&player.kills.to_string());
|
||||||
|
}
|
||||||
|
if let Some(deaths_label) = &mut self.deaths_label {
|
||||||
|
deaths_label.set_text(&player.deaths.to_string());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(name_label) = &mut self.name_label {
|
if let Some(name_label) = &mut self.name_label {
|
||||||
name_label.set_text("Name");
|
name_label.set_text("Name");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user