Give Seed an Into<[u8; 8]>

This commit is contained in:
Michael Bradley 2025-05-18 22:09:09 -04:00
parent 763acd0ad8
commit 84eb560e43
Signed by: MichaelBradley
SSH key fingerprint: SHA256:BKO2eI2LPsCbQS3n3i5SdwZTAIV3F1lHezR07qP+Ob0

View file

@ -46,6 +46,12 @@ impl From<String> for Seed {
}
}
impl From<Seed> 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::<WyRand>::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::<WyRand>::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()
}