Exemplo n.º 1
0
  public <T extends Component> T create(Class<T> componentKlazz) {
    ComponentManager componentManager = world.getComponentManager();
    T component = componentManager.create(entity, componentKlazz);

    ComponentTypeFactory tf = world.getComponentManager().typeFactory;
    ComponentType componentType = tf.getTypeFor(componentKlazz);
    componentBits.set(componentType.getIndex());

    return component;
  }
Exemplo n.º 2
0
 /**
  * Add a component to this entity.
  *
  * @param component the component to add to this entity
  * @return this EntityEdit for chaining
  * @see {@link #createComponent(Class)}
  */
 public EntityEdit add(Component component) {
   ComponentTypeFactory tf = world.getComponentManager().typeFactory;
   return add(component, tf.getTypeFor(component.getClass()));
 }
Exemplo n.º 3
0
 /**
  * Remove component by its type.
  *
  * @param type the class type of component to remove from this entity
  * @return this EntityEdit for chaining
  */
 public EntityEdit remove(Class<? extends Component> type) {
   ComponentTypeFactory tf = world.getComponentManager().typeFactory;
   return remove(tf.getTypeFor(type));
 }
Exemplo n.º 4
0
 private static void associate(
     ComponentTypeFactory tf, Bag<Class<? extends Component>> types, BitSet componentBits) {
   for (Class<? extends Component> t : types) {
     componentBits.set(tf.getIndexFor(t));
   }
 }