Skip to main content

BoostPadState

Struct BoostPadState 

Source
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: f32

Seconds of cooldown left (0 = active).

Implementations§

Source§

impl BoostPadState

Source

pub const DEFAULT: Self

Active-pad placeholder (cooldown == 0).

Source

pub const fn is_active(&self) -> bool

Returns true when the pad can be picked up (cooldown <= 0).

Examples found in repository?
examples/snapshot_raycast.rs (line 45)
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}

Trait Implementations§

Source§

impl Clone for BoostPadState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BoostPadState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BoostPadState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.