From 84eb560e433bfe5b7a143c89af5804de2defa099 Mon Sep 17 00:00:00 2001 From: Michael Bradley Date: Sun, 18 May 2025 22:09:09 -0400 Subject: [PATCH] Give Seed an Into<[u8; 8]> --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 78bfd8f..dd9331b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,6 +46,12 @@ impl From for Seed { } } +impl From for [u8; 8] { + fn from(value: Seed) -> Self { + value.0.to_le_bytes() + } +} + #[derive(Resource)] struct PlayableArea(f32, f32); @@ -55,6 +61,8 @@ struct PlayerSize(f32); fn run_app(settings: AppSettings) -> AppExit { let seed = Seed::from(settings.seed); App::new() + .insert_resource(Gravity(Vector::ZERO)) + .insert_resource(seed.clone()) .add_plugins(( DefaultPlugins.set(WindowPlugin { primary_window: Window { @@ -66,7 +74,7 @@ fn run_app(settings: AppSettings) -> AppExit { ..default() }), PhysicsPlugins::default().with_length_unit(50.0), - EntropyPlugin::::with_seed(seed.0.to_le_bytes()), // TODO: Tried to make an Into<[u8; 8]> for this but it wants to consume the value + EntropyPlugin::::with_seed(seed.into()), )) .add_systems( Startup, @@ -81,8 +89,6 @@ fn run_app(settings: AppSettings) -> AppExit { (move_player, quit.run_if(input_pressed(KeyCode::KeyQ))), ) .add_systems(PostUpdate, move_camera) - .insert_resource(Gravity(Vector::ZERO)) - .insert_resource(seed) .run() }