Add distance moved, move stats button
This commit is contained in:
parent
b21e0834b4
commit
525b2e7e13
@ -18,35 +18,41 @@ ping_medium_color = Color(0.7963379, 0.79633814, 0, 1)
|
|||||||
ping_high = ExtResource("3_kx1on")
|
ping_high = ExtResource("3_kx1on")
|
||||||
ping_high_color = Color(0.99999994, 0.22953579, 0.17418489, 1)
|
ping_high_color = Color(0.99999994, 0.22953579, 0.17418489, 1)
|
||||||
ping_icon = NodePath("ping_icon")
|
ping_icon = NodePath("ping_icon")
|
||||||
stats_button = NodePath("button")
|
stats_button = NodePath("stats_button")
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
theme = ExtResource("4_kx1on")
|
theme = ExtResource("4_kx1on")
|
||||||
|
|
||||||
|
[node name="stats_button" type="Button" parent="." unique_id=1272088409]
|
||||||
|
custom_minimum_size = Vector2(20, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
icon = ExtResource("5_gadtc")
|
||||||
|
expand_icon = true
|
||||||
|
|
||||||
[node name="name" type="Label" parent="." unique_id=1361759955]
|
[node name="name" type="Label" parent="." unique_id=1361759955]
|
||||||
clip_contents = true
|
clip_contents = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 2
|
size_flags_horizontal = 2
|
||||||
text = "Player Name"
|
text = "Name"
|
||||||
|
|
||||||
[node name="kills" type="Label" parent="." unique_id=690390687]
|
[node name="kills" type="Label" parent="." unique_id=690390687]
|
||||||
custom_minimum_size = Vector2(50, 0)
|
custom_minimum_size = Vector2(50, 0)
|
||||||
custom_maximum_size = Vector2(50, -1)
|
custom_maximum_size = Vector2(50, -1)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "0"
|
text = "Kills"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="deaths" type="Label" parent="." unique_id=1615203485]
|
[node name="deaths" type="Label" parent="." unique_id=1615203485]
|
||||||
custom_minimum_size = Vector2(50, 0)
|
custom_minimum_size = Vector2(50, 0)
|
||||||
custom_maximum_size = Vector2(50, -1)
|
custom_maximum_size = Vector2(50, -1)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "0"
|
text = "Deaths"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
[node name="ping" type="Label" parent="." unique_id=1700548535]
|
[node name="ping" type="Label" parent="." unique_id=1700548535]
|
||||||
custom_minimum_size = Vector2(50, 0)
|
custom_minimum_size = Vector2(50, 0)
|
||||||
custom_maximum_size = Vector2(50, -1)
|
custom_maximum_size = Vector2(50, -1)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "0ms"
|
text = "Ping"
|
||||||
horizontal_alignment = 2
|
horizontal_alignment = 2
|
||||||
clip_text = true
|
clip_text = true
|
||||||
|
|
||||||
@ -55,9 +61,3 @@ layout_mode = 2
|
|||||||
texture = ExtResource("3_kx1on")
|
texture = ExtResource("3_kx1on")
|
||||||
expand_mode = 2
|
expand_mode = 2
|
||||||
stretch_mode = 4
|
stretch_mode = 4
|
||||||
|
|
||||||
[node name="button" type="Button" parent="." unique_id=1272088409]
|
|
||||||
custom_minimum_size = Vector2(20, 0)
|
|
||||||
layout_mode = 2
|
|
||||||
icon = ExtResource("5_gadtc")
|
|
||||||
expand_icon = true
|
|
||||||
|
|||||||
@ -301,6 +301,14 @@ impl INode for Game {
|
|||||||
self.last_replay_clone = 0.
|
self.last_replay_clone = 0.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for player in &mut self.players {
|
||||||
|
if let Some(character) = &player.character {
|
||||||
|
let delta = character.get_global_position() - player.last_position;
|
||||||
|
player.stats.distance_moved += delta.length();
|
||||||
|
player.last_position = character.get_global_position();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,6 +582,7 @@ impl Game {
|
|||||||
killing_spree_cd: 0.,
|
killing_spree_cd: 0.,
|
||||||
character: None,
|
character: None,
|
||||||
last_held_weapon: WeaponType::Raygun,
|
last_held_weapon: WeaponType::Raygun,
|
||||||
|
last_position: Vector3::ZERO,
|
||||||
});
|
});
|
||||||
self.run_deferred(move |s| s.signals().on_new_player().emit(id));
|
self.run_deferred(move |s| s.signals().on_new_player().emit(id));
|
||||||
|
|
||||||
@ -850,6 +859,12 @@ impl Game {
|
|||||||
map.bind_mut()
|
map.bind_mut()
|
||||||
.spawn_player(id, team, id == self.self_id.unwrap_or(0), None, true);
|
.spawn_player(id, team, id == self.self_id.unwrap_or(0), None, true);
|
||||||
|
|
||||||
|
if let Some(character) = &character
|
||||||
|
&& let Some(player) = self.find_player_mut(id)
|
||||||
|
{
|
||||||
|
player.last_position = character.get_global_position()
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(character) = &mut character {
|
if let Some(character) = &mut character {
|
||||||
character.dyn_bind_mut().new_buff(Buff {
|
character.dyn_bind_mut().new_buff(Buff {
|
||||||
time_remaining: self.opts.get_float(GameOption::SpawnProtection),
|
time_remaining: self.opts.get_float(GameOption::SpawnProtection),
|
||||||
@ -940,6 +955,11 @@ impl Game {
|
|||||||
Some(transform),
|
Some(transform),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(character) = &character {
|
||||||
|
player.last_position = character.get_global_position()
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(character) = &mut character {
|
if let Some(character) = &mut character {
|
||||||
character.dyn_bind_mut().new_buff(Buff {
|
character.dyn_bind_mut().new_buff(Buff {
|
||||||
time_remaining: self.opts.get_float(GameOption::SpawnProtection),
|
time_remaining: self.opts.get_float(GameOption::SpawnProtection),
|
||||||
@ -1386,6 +1406,7 @@ pub struct Player {
|
|||||||
pub killing_spree: u16,
|
pub killing_spree: u16,
|
||||||
pub killing_spree_cd: f64,
|
pub killing_spree_cd: f64,
|
||||||
pub last_held_weapon: WeaponType,
|
pub last_held_weapon: WeaponType,
|
||||||
|
pub last_position: Vector3,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
@ -1531,6 +1552,7 @@ pub struct PlayerStats {
|
|||||||
pub own_goals: u16,
|
pub own_goals: u16,
|
||||||
pub friendly_kills: u16,
|
pub friendly_kills: u16,
|
||||||
pub friendly_deaths: u16,
|
pub friendly_deaths: u16,
|
||||||
|
pub distance_moved: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
@ -1552,6 +1574,7 @@ impl From<NetPlayer> for Player {
|
|||||||
killing_spree: 0,
|
killing_spree: 0,
|
||||||
killing_spree_cd: 0.,
|
killing_spree_cd: 0.,
|
||||||
last_held_weapon: WeaponType::Raygun,
|
last_held_weapon: WeaponType::Raygun,
|
||||||
|
last_position: Vector3::ZERO,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ impl PlayerStatsPanel {
|
|||||||
("Own Goals", stats.own_goals.to_string()),
|
("Own Goals", stats.own_goals.to_string()),
|
||||||
("Friendly Kills", stats.friendly_kills.to_string()),
|
("Friendly Kills", stats.friendly_kills.to_string()),
|
||||||
("Friendly Deaths", stats.friendly_deaths.to_string()),
|
("Friendly Deaths", stats.friendly_deaths.to_string()),
|
||||||
|
("Distance Moved", format!("{:.0}m", stats.distance_moved)),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (stat_name, stat) in stats {
|
for (stat_name, stat) in stats {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user