Added Seed Type.
This commit is contained in:
parent
eb4d47aa74
commit
4031c4dc13
@ -10,6 +10,7 @@ pub mod item;
|
|||||||
mod level;
|
mod level;
|
||||||
pub mod radial_chunk_iterator;
|
pub mod radial_chunk_iterator;
|
||||||
pub mod vector3;
|
pub mod vector3;
|
||||||
|
mod world_gen;
|
||||||
|
|
||||||
pub const WORLD_HEIGHT: usize = 384;
|
pub const WORLD_HEIGHT: usize = 384;
|
||||||
pub const WORLD_LOWEST_Y: i16 = -64;
|
pub const WORLD_LOWEST_Y: i16 = -64;
|
||||||
|
|||||||
1
pumpkin-world/src/world_gen/mod.rs
Normal file
1
pumpkin-world/src/world_gen/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
mod seed;
|
||||||
16
pumpkin-world/src/world_gen/seed.rs
Normal file
16
pumpkin-world/src/world_gen/seed.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct Seed(pub i64);
|
||||||
|
|
||||||
|
impl From<&str> for Seed {
|
||||||
|
fn from(value: &str) -> Self {
|
||||||
|
// TODO replace with a deterministic hasher (the same as vanilla?)
|
||||||
|
let mut hasher = DefaultHasher::new();
|
||||||
|
value.hash(&mut hasher);
|
||||||
|
|
||||||
|
// TODO use cast_signed once the feature is stabilized.
|
||||||
|
Self(hasher.finish() as i64)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user