/// Adds a new component to an entity.
/// If the entity already had that component, that component is returned.
/// Otherwise, `None` is returned.
Adds a new component to an entity.
If the entity already had that component, that component is returned.
Otherwise, `None` is returned.
Adds a new component to an entity . If the entity already had that component that component is returned . Otherwise ` None ` is returned .
pub fn add_component<T: Any>(&mut self, entity: &Entity, component: T) -> Option<T> {
        if self.is_valid_entity(entity) {
            self.ent_changed.insert(entity.idx, entity.uuid);
            return self.components[entity.idx].insert(component);
        }
        None
    }
pub fn add_component < T : Any > ( & mut self , entity : & Entity , component : T ) -> Option < T > { if self . is_valid_entity ( entity ) { self . ent_changed . insert ( entity . idx , entity . uuid ) ; return self . components [ entity . idx ] . insert ( component ) ; } None }
Adds a new component to an entity.
Adds a new component to an entity .
&mut self
entity
&Entity
component
T