diff --git a/Cargo.lock b/Cargo.lock index 14f24ec..bdb6392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,9 +70,9 @@ checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca" [[package]] name = "glam" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9" +checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94" [[package]] name = "hashbrown" @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "once_cell" @@ -175,9 +175,9 @@ checksum = "17fd96390ed3feda12e1dfe2645ed587e0bea749e319333f104a33ff62f77a0b" [[package]] name = "rl_ball_sym" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08b4849f7e2424fc472350e7feebbd0458d2d784eb7014b0b5d36a8a6a0b94bc" +checksum = "a76ae2ee7b55c2d1991d50119373d5f2627501e0d075a155ea8c2fdd472d7cd1" dependencies = [ "byteorder", "combo_vec", @@ -188,7 +188,7 @@ dependencies = [ [[package]] name = "rl_ball_sym_dll" -version = "0.1.1" +version = "0.1.2" dependencies = [ "rl_ball_sym", ] diff --git a/Cargo.toml b/Cargo.toml index 506a9a0..2cffe8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,14 @@ [package] name = "rl_ball_sym_dll" -version = "0.1.1" +version = "0.1.2" edition = "2021" [lib] name = "rl_ball_sym" crate-type = ["cdylib", "staticlib"] -[dependencies.rl_ball_sym] -version = "4.0.0" -default-features = false -features = ["compression", "standard", "hoops", "dropshot", "throwback"] +[dependencies] +rl_ball_sym = { version = "4.1.0", features = ["compression"] } [profile.release] codegen-units=1 diff --git a/src/lib.rs b/src/lib.rs index e910da3..9fc40fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,15 @@ use rl_ball_sym::{Ball, Game, Vec3A}; -use std::sync::RwLock; +use std::sync::{ + atomic::{AtomicBool, Ordering}, + RwLock, +}; const TPS: usize = 120; const DT: f32 = 1.0 / TPS as f32; static GAME: RwLock> = RwLock::new(None); static BALL: RwLock = RwLock::new(Ball::const_default()); +static HEATSEEKER: AtomicBool = AtomicBool::new(false); fn set_game_and_ball((game, ball): (Game, Ball)) { let mut game_lock = GAME.write().unwrap(); @@ -15,24 +19,34 @@ fn set_game_and_ball((game, ball): (Game, Ball)) { *ball_lock = ball; } +#[no_mangle] +pub extern "C" fn load_heatseeker() { + set_game_and_ball(rl_ball_sym::load_standard_heatseeker()); + HEATSEEKER.store(true, Ordering::Relaxed); +} + #[no_mangle] pub extern "C" fn load_standard() { set_game_and_ball(rl_ball_sym::load_standard()); + HEATSEEKER.store(false, Ordering::Relaxed); } #[no_mangle] pub extern "C" fn load_dropshot() { set_game_and_ball(rl_ball_sym::load_dropshot()); + HEATSEEKER.store(false, Ordering::Relaxed); } #[no_mangle] pub extern "C" fn load_hoops() { set_game_and_ball(rl_ball_sym::load_hoops()); + HEATSEEKER.store(false, Ordering::Relaxed); } #[no_mangle] pub extern "C" fn load_standard_throwback() { set_game_and_ball(rl_ball_sym::load_standard_throwback()); + HEATSEEKER.store(false, Ordering::Relaxed); } #[repr(C)] @@ -82,6 +96,12 @@ impl From for BallSlice { } } +#[no_mangle] +pub extern "C" fn set_heatseeker_target(blue_goal: u8) { + let mut ball = *BALL.write().unwrap(); + ball.set_heatseeker_target(blue_goal == 1); +} + #[no_mangle] pub extern "C" fn step(current_ball: BallSlice) -> BallSlice { let game_lock = GAME.read().unwrap(); @@ -98,6 +118,10 @@ pub extern "C" fn step(current_ball: BallSlice) -> BallSlice { current_ball.angular_velocity.into(), ); - ball.step(game, DT); + if HEATSEEKER.load(Ordering::Relaxed) { + ball.step_heatseeker(game, DT); + } else { + ball.step(game, DT); + } ball.into() }