Skip to content

Commit

Permalink
Fix boost meter with TrackCar
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed May 29, 2024
1 parent fdb5116 commit 57f196b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
version = "0.7.9"
version = "0.7.10"
name = "rlviser"
edition = "2021"
publish = false
Expand Down
19 changes: 17 additions & 2 deletions src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ fn update_camera(
} else {
ids[index]
}
},
}
PrimaryCamera::Director(id) => {
if *id == 0 || timer.0.finished() {
// get the car closest to the ball
Expand Down Expand Up @@ -1127,7 +1127,22 @@ fn update_boost_meter(
mut was_last_director: Local<bool>,
) {
let id = match camera.single() {
PrimaryCamera::Director(id) | PrimaryCamera::TrackCar(id) => *id,
PrimaryCamera::TrackCar(id) => {
if states.current.cars.is_empty() {
return;
}

let mut ids = states.current.cars.iter().map(|car_info| car_info.id).collect::<Vec<_>>();
radsort::sort(&mut ids);

let index = *id as usize - 1;
if index >= ids.len() {
0
} else {
ids[index]
}
}
PrimaryCamera::Director(id) => *id,
PrimaryCamera::Spectator => 0,
};

Expand Down

0 comments on commit 57f196b

Please sign in to comment.