diff --git a/Cargo.lock b/Cargo.lock index 42b4ef03..477d17bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2365,7 +2365,7 @@ dependencies = [ "egui 0.21.0", "egui-wgpu 0.21.0", "egui-winit 0.21.1", - "fastrand 1.9.0", + "fastrand 2.0.2", "gamercade_audio", "gamercade_core", "gamercade_fs", diff --git a/gamercade_console/Cargo.toml b/gamercade_console/Cargo.toml index 0a5b8f6c..88393400 100644 --- a/gamercade_console/Cargo.toml +++ b/gamercade_console/Cargo.toml @@ -42,8 +42,8 @@ bytemuck = "1.15.0" # Scripting wasmtime = "20.0.0" -# Random TODO Update This -fastrand = "1.9.0" +# Random +fastrand = "2.0.2" # Audio cpal = "0.15.3" diff --git a/gamercade_console/src/api/random_api.rs b/gamercade_console/src/api/random_api.rs index 7a8616d9..ea3d2def 100644 --- a/gamercade_console/src/api/random_api.rs +++ b/gamercade_console/src/api/random_api.rs @@ -1,10 +1,10 @@ pub trait RandomApi { - fn set_seed(&self, seed: i32); + fn set_seed(&mut self, seed: i32); - fn random_int_range(&self, min: i32, max: i32) -> i32; + fn random_int_range(&mut self, min: i32, max: i32) -> i32; - fn random_float(&self) -> f32; - fn random_float_range(&self, min: f32, max: f32) -> f32; + fn random_float(&mut self) -> f32; + fn random_float_range(&mut self, min: f32, max: f32) -> f32; } macro_rules! derive_bind_random_api { diff --git a/gamercade_console/src/console/bindings/random_binding.rs b/gamercade_console/src/console/bindings/random_binding.rs index ec332e69..b005164f 100644 --- a/gamercade_console/src/console/bindings/random_binding.rs +++ b/gamercade_console/src/console/bindings/random_binding.rs @@ -13,8 +13,8 @@ macro_rules! derive_random_api_binding { self.func_wrap( "env", stringify!($ident), - |caller: Caller<'_, Contexts>, $($name: $args,)*| { - caller.data().random_context.$ident($($name,)*) + |mut caller: Caller<'_, Contexts>, $($name: $args,)*| { + caller.data_mut().random_context.$ident($($name,)*) }).unwrap(); } )* diff --git a/gamercade_console/src/console/contexts/random_context.rs b/gamercade_console/src/console/contexts/random_context.rs index 63d38912..df61f3a2 100644 --- a/gamercade_console/src/console/contexts/random_context.rs +++ b/gamercade_console/src/console/contexts/random_context.rs @@ -16,19 +16,19 @@ impl RandomContext { } impl RandomApi for RandomContext { - fn set_seed(&self, seed: i32) { + fn set_seed(&mut self, seed: i32) { self.shared_rng.seed(seed as u64); } - fn random_int_range(&self, min: i32, max: i32) -> i32 { + fn random_int_range(&mut self, min: i32, max: i32) -> i32 { self.shared_rng.i32(min..max) } - fn random_float(&self) -> f32 { + fn random_float(&mut self) -> f32 { self.shared_rng.f32() } - fn random_float_range(&self, min: f32, max: f32) -> f32 { + fn random_float_range(&mut self, min: f32, max: f32) -> f32 { let range = max - min; let scale = self.shared_rng.f32() * max; (scale * range) + min