nightshade 0.13.3

A cross-platform data-oriented game engine.
Documentation
use crate::ecs::world::{Entity, World};
use nalgebra_glm::Vec2;

pub fn spawn_sprite(world: &mut World, position: Vec2, size: Vec2) -> Entity {
    let entity = world.spawn();
    world.core.add_components(entity, crate::ecs::VISIBILITY);
    world.sprite2d.add_components(entity, crate::ecs::SPRITE);

    if let Some(sprite) = world.sprite2d.get_sprite_mut(entity) {
        sprite.position = position;
        sprite.size = size;
    }

    if let Some(visibility) = world.core.get_visibility_mut(entity) {
        visibility.visible = true;
    }

    entity
}