pub struct BoostPadState {
pub touching_car_idxs: Vec<usize>,
pub cooldown: f32,
}Expand description
Dynamic boost-pad state: seconds of cooldown left (0 = active) and ordered car members.
This public type is no longer Copy. Existing struct literals must now provide
touching_car_idxs or use BoostPadState::DEFAULT. The added field changes
serialized snapshots. Map-based formats can default a missing field, but the
next tick rebuilds order by car index and loses saved arrival order. Sequence
formats such as postcard cannot read old layouts. Rebuild both protocol ends.
Read with Arena::get_boost_pad_state; restore with
Arena::set_boost_pad_state. A car index must occur in no more than one
pad state’s touching_car_idxs list. If restored data repeats an index
across pads, the next tick keeps it on the lowest-index pad that still
retains the car. Cooldowns tick in
crate::Arena::step_tick from MutatorConfig::boost_pad_cooldown_*.
Fields§
§touching_car_idxs: Vec<usize>Car members in retained-entry order. A car index can occur on one pad only.
cooldown: f32Seconds of cooldown left (0 = active).
Implementations§
Source§impl BoostPadState
impl BoostPadState
Sourcepub const fn is_active(&self) -> bool
pub const fn is_active(&self) -> bool
Returns true when the pad can be picked up (cooldown <= 0).
Examples found in repository?
11fn main() {
12 init_from_default(true).unwrap();
13 let mut arena = Arena::new(GameMode::Soccar);
14 let car_idx = arena.add_car(Team::Blue, CarBodyConfig::OCTANE);
15 arena.reset_to_random_kickoff(Some(7));
16
17 // 1. Snapshot everything (cars, ball, pads) for replays/debugging.
18 let snapshot = arena.get_arena_state();
19 println!(
20 "cars: {}, pads: {}",
21 snapshot.num_cars(),
22 snapshot.num_boost_pads()
23 );
24
25 // 2. Teleport the ball above the car and let it drop for a second.
26 let mut ball_state = *arena.get_ball_state();
27 let car_state = arena.get_car_state(car_idx);
28 ball_state.phys.pos = car_state.phys.pos + Vec3A::new(0.0, 0.0, 500.0);
29 ball_state.phys.vel = Vec3A::ZERO;
30 arena.set_ball_state(ball_state);
31
32 for _ in 0..120 {
33 arena.step_tick();
34 }
35 println!("ball fell to: {}", arena.get_ball_state().pos);
36
37 // 3. Boost pads: layout is RLBot/RLGym ordered (Y, then X).
38 println!("pads: {}", arena.num_boost_pads());
39 let first_config = *arena.get_boost_pad_config(0);
40 let first_state = arena.get_boost_pad_state(0);
41 println!(
42 "pad 0 at {} (big: {}), active: {}",
43 first_config.pos,
44 first_config.is_big,
45 first_state.is_active()
46 );
47
48 // 4. Raycasts are SIMD-batched in 4s — send multiples of 4 when possible.
49 // Coordinates are in Unreal units, like the rest of the API.
50 let ball_pos = arena.get_ball_state().pos + Vec3A::new(500.0, 0.0, 0.0);
51 let down = RaycastQuery {
52 from: ball_pos,
53 to: ball_pos - Vec3A::new(0.0, 0.0, 300.0),
54 include_dynamics: false,
55 };
56 let queries = [down; 4];
57 let results = arena.cast_rays(queries);
58 for (i, result) in results.iter().enumerate() {
59 match result {
60 Some(hit) => println!(
61 "ray {i}: hit at {} (t={:.3}, {:?})",
62 hit.hit_point, hit.hit_fraction, hit.user_info
63 ),
64 None => println!("ray {i}: miss"),
65 }
66 }
67
68 // 5. Overlap tests: would something fit here without stepping the sim?
69 // (cars use the hitbox only — a car at rest height clears the floor).
70 let mut high_ball = arena.get_ball_state().phys;
71 high_ball.pos = Vec3A::new(0.0, 0.0, 3000.0);
72 println!(
73 "ball at 3000uu collides: {}",
74 arena.test_collision(high_ball, None, false)
75 );
76 println!(
77 "car at 3000uu collides: {}",
78 arena.test_collision(high_ball, Some(CarBodyConfig::OCTANE), false)
79 );
80 let mut in_wall = arena.get_ball_state().phys;
81 in_wall.pos = Vec3A::new(4096.0, 0.0, 100.0);
82 println!(
83 "ball inside side wall collides: {}",
84 arena.test_collision(in_wall, None, false)
85 );
86
87 // 6. Restore: teleport back to the snapshot's ball state.
88 arena.set_ball_state(snapshot.ball);
89 println!("restored to: {}", arena.get_ball_state().pos);
90}