pub trait DungeonFloorGeneration {
type EntityGenerator: DungeonEntityGeneration;
type LayoutGenerator: ?Sized;
// Required methods
fn generate_floor(
&mut self,
width: usize,
height: usize,
properties: &floor_properties
) -> &mut Self;
fn generate_layout(
&mut self,
layout: &mut Self::LayoutGenerator,
properties: &floor_properties
) -> &mut Self;
fn entities<F: FnOnce(&mut Self::EntityGenerator)>(
&mut self,
cb: F
) -> &mut Self;
fn generate(self, global_dungeon: &mut GlobalDungeonData<'_>);
}
Expand description
High-level trait for generating new dungeons and replacing the current global dungeon.
Required Associated Types§
type EntityGenerator: DungeonEntityGeneration
type LayoutGenerator: ?Sized
Required Methods§
sourcefn generate_floor(
&mut self,
width: usize,
height: usize,
properties: &floor_properties
) -> &mut Self
fn generate_floor( &mut self, width: usize, height: usize, properties: &floor_properties ) -> &mut Self
Generates a floor using the specified floor properties. This will create a fully working layout, including entities.
Whether a fixed floor or a floor using a layout is generated is taken from the properties.
sourcefn generate_layout(
&mut self,
layout: &mut Self::LayoutGenerator,
properties: &floor_properties
) -> &mut Self
fn generate_layout( &mut self, layout: &mut Self::LayoutGenerator, properties: &floor_properties ) -> &mut Self
Generates a floor using the specified layout. This will create a fully working layout.
Entities are not spawned.
sourcefn entities<F: FnOnce(&mut Self::EntityGenerator)>(
&mut self,
cb: F
) -> &mut Self
fn entities<F: FnOnce(&mut Self::EntityGenerator)>( &mut self, cb: F ) -> &mut Self
Generate entities, the callback will receive Self::EntityGenerator
to generate them.
Implementors
Implementations must call cb
.
sourcefn generate(self, global_dungeon: &mut GlobalDungeonData<'_>)
fn generate(self, global_dungeon: &mut GlobalDungeonData<'_>)
Write the finished generated dungeon to the global dungeon struct.
Important: For the builtin generator, see the note at
game_builtin::GlobalDungeonStructureGenerator::generate
.
Implementors§
source§impl<'a> DungeonFloorGeneration for GlobalDungeonStructureGenerator<'a>
impl<'a> DungeonFloorGeneration for GlobalDungeonStructureGenerator<'a>
The game’s builtin dungeon generator.