use crate::ecs::tilemap::components::Tilemap;
use crate::ecs::world::{Entity, World};
use nalgebra_glm::Vec2;
pub fn spawn_tilemap(
world: &mut World,
position: Vec2,
tile_size: Vec2,
grid_width: u32,
grid_height: u32,
) -> Entity {
let entities = world.spawn_entities(crate::ecs::TILEMAP | crate::ecs::VISIBILITY, 1);
let entity = entities[0];
let tilemap = Tilemap::new(position, tile_size, grid_width, grid_height);
if let Some(existing) = world.get_tilemap_mut(entity) {
*existing = tilemap;
}
if let Some(visibility) = world.get_visibility_mut(entity) {
visibility.visible = true;
}
entity
}