Allow passing seed to new_world
This commit is contained in:
parent
a58e7a2c2d
commit
030f590d79
3 changed files with 4 additions and 4 deletions
|
@ -160,8 +160,8 @@ impl WorldManager {
|
||||||
self.get_world().unwrap()
|
self.get_world().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_world(&mut self) -> Result<&World, WorldGenError> {
|
pub fn new_world(&mut self, seed: Option<u32>) -> Result<&World, WorldGenError> {
|
||||||
let seed = random();
|
let seed = seed.unwrap_or_else(random);
|
||||||
let mut new_world = World::new(400, 200, seed);
|
let mut new_world = World::new(400, 200, seed);
|
||||||
new_world.generate()?;
|
new_world.generate()?;
|
||||||
self.world = Some(new_world);
|
self.world = Some(new_world);
|
||||||
|
|
|
@ -34,7 +34,7 @@ impl ToolbarButton {
|
||||||
world.resource_scope(|world, mut world_manager: Mut<'_, WorldManager>| {
|
world.resource_scope(|world, mut world_manager: Mut<'_, WorldManager>| {
|
||||||
match self {
|
match self {
|
||||||
ToolbarButton::GenerateWorld => {
|
ToolbarButton::GenerateWorld => {
|
||||||
if let Err(err) = world_manager.new_world() {
|
if let Err(err) = world_manager.new_world(None) {
|
||||||
eprintln!("Failed to generate world: {}", err);
|
eprintln!("Failed to generate world: {}", err);
|
||||||
} else {
|
} else {
|
||||||
world.resource_mut::<ShouldRedraw>().0 = true;
|
world.resource_mut::<ShouldRedraw>().0 = true;
|
||||||
|
|
|
@ -252,7 +252,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut manager = WorldManager::new();
|
let mut manager = WorldManager::new();
|
||||||
#[cfg(feature = "render")]
|
#[cfg(feature = "render")]
|
||||||
{
|
{
|
||||||
let world = manager.new_world()?;
|
let world = manager.new_world(None)?;
|
||||||
_ = app
|
_ = app
|
||||||
.insert_resource(WinitSettings::game())
|
.insert_resource(WinitSettings::game())
|
||||||
// Use nearest-neighbor rendering for cripsier pixels
|
// Use nearest-neighbor rendering for cripsier pixels
|
||||||
|
|
Loading…
Reference in a new issue