Give Seed an Into<[u8; 8]>
This commit is contained in:
parent
763acd0ad8
commit
84eb560e43
1 changed files with 9 additions and 3 deletions
12
src/main.rs
12
src/main.rs
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue