pub fn create<F>(infos: TilemapInfo, world: &mut World, mut tile_resolver: F) -> Entity
    where
        F: FnMut(&Position) -> TileInfos, {
        let self_entity = Tilemap::create_tilemap(world, infos.tileset_ref, infos.transform);

        for x in 0..infos.dimensions.width() {
            for y in 0..infos.dimensions.height() {
                for z in 0..infos.dimensions.depth() {
                    let position = Position::new(x, y, z);
                    let tile_infos = tile_resolver(&position);

                    let entity = world.push((
                        Tile { position: position.clone(), tilemap: self_entity.clone() },
                        Parent(self_entity.clone()),
                    ));

                    if let Some(tile_nb) = tile_infos.tile_nb {
                        world.entry(entity).unwrap().add_component(Sprite::new(tile_nb));
                    }

                    if let Some(animation) = tile_infos.animation {
                        world
                            .entry(entity)
                            .unwrap()
                            .add_component(Animations::single("TileAnimation", animation));
                    }
                    world
                        .entry(self_entity)
                        .unwrap()
                        .get_component_mut::<Tilemap>()
                        .unwrap()
                        .tile_entities
                        .insert(position, entity);
                }
            }
        }

        self_entity
    }
/// Convenience fn to create a tilemap and add it to the world.
/// tile_resolver is a function taking a 3D position as parameter and a `TileInfos`
/// as a return. This way, the tilemap knows exactly what to add at which coordinates.
Convenience fn to create a tilemap and add it to the world.
tile_resolver is a function taking a 3D position as parameter and a `TileInfos`
as a return. This way, the tilemap knows exactly what to add at which coordinates.
Convenience fn to create a tilemap and add it to the world . tile_resolver is a function taking a 3D position as parameter and a ` TileInfos ` as a return . This way the tilemap knows exactly what to add at which coordinates .
pub fn create<F>(infos: TilemapInfo, world: &mut World, mut tile_resolver: F) -> Entity
    where
        F: FnMut(&Position) -> TileInfos, {
        let self_entity = Tilemap::create_tilemap(world, infos.tileset_ref, infos.transform);
        for x in 0..infos.dimensions.width() {
            for y in 0..infos.dimensions.height() {
                for z in 0..infos.dimensions.depth() {
                    let position = Position::new(x, y, z);
                    let tile_infos = tile_resolver(&position);
                    let entity = world.push((
                        Tile { position: position.clone(), tilemap: self_entity.clone() },
                        Parent(self_entity.clone()),
                    ));
                    if let Some(tile_nb) = tile_infos.tile_nb {
                        world.entry(entity).unwrap().add_component(Sprite::new(tile_nb));
                    }
                    if let Some(animation) = tile_infos.animation {
                        world
                            .entry(entity)
                            .unwrap()
                            .add_component(Animations::single("TileAnimation", animation));
                    }
                    world
                        .entry(self_entity)
                        .unwrap()
                        .get_component_mut::<Tilemap>()
                        .unwrap()
                        .tile_entities
                        .insert(position, entity);
                }
            }
        }
        self_entity
    }
pub fn create < F > ( infos : TilemapInfo , world : & mut World , mut tile_resolver : F ) -> Entity where F : FnMut ( & Position ) -> TileInfos , { let self_entity = Tilemap :: create_tilemap ( world , infos . tileset_ref , infos . transform ) ; for x in 0 .. infos . dimensions . width ( ) { for y in 0 .. infos . dimensions . height ( ) { for z in 0 .. infos . dimensions . depth ( ) { let position = Position :: new ( x , y , z ) ; let tile_infos = tile_resolver ( & position ) ; let entity = world . push ( ( Tile { position : position . clone ( ) , tilemap : self_entity . clone ( ) } , Parent ( self_entity . clone ( ) ) , ) ) ; if let Some ( tile_nb ) = tile_infos . tile_nb { world . entry ( entity ) . unwrap ( ) . add_component ( Sprite :: new ( tile_nb ) ) ; } if let Some ( animation ) = tile_infos . animation { world . entry ( entity ) . unwrap ( ) . add_component ( Animations :: single ( " " , animation ) ) ; } world . entry ( self_entity ) . unwrap ( ) . get_component_mut :: < Tilemap > ( ) . unwrap ( ) . tile_entities . insert ( position , entity ) ; } } } self_entity }
Convenience fn to create a tilemap and add it to the world.
Convenience fn to create a tilemap and add it to the world .
infos
TilemapInfo
world
&mut World
tile_resolver
F
infos
TilemapInfo
world
&mut World
tile_resolver
F