Package com.badlogic.gdx.utils

Examples of com.badlogic.gdx.utils.Bits


   */
  public Entity(){
    components = new Bag<Component>();
    componentsArray = new Array<Component>();
    immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
    componentBits = new Bits();
    familyBits = new Bits();
    flags = 0;
   
    index = nextIndex++;
   
    componentAdded = new Signal<Entity>();
View Full Code Here


   */
  public Entity(){
    components = new Bag<Component>();
    componentsArray = new Array<Component>(false, 16);
    immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
    componentBits = new Bits();
    familyBits = new Bits();
    flags = 0;
   
    index = nextIndex++;
   
    componentAdded = new Signal<Entity>();
View Full Code Here

 
  /**
   * @return Whether the entity matches the family requirements or not
   */
  public boolean matches(Entity entity){
    Bits entityComponentBits = entity.getComponentBits();
   
    if(entityComponentBits.isEmpty())
      return false;
   
    for (int i = all.nextSetBit(0); i >= 0; i = all.nextSetBit(i+1)){
      if(!entityComponentBits.get(i))
        return false;
    }
   
    if (!one.isEmpty() && !one.intersects(entityComponentBits)) {
      return false;
View Full Code Here

   
    entity.add(new ComponentA());
   
    assertEquals(1, entity.getComponents().size());
   
    Bits componentBits = entity.getComponentBits();
    int componentAIndex = ComponentType.getIndexFor(ComponentA.class);
   
    for (int i = 0; i < componentBits.length(); ++i) {
      assertEquals(i == componentAIndex, componentBits.get(i));
    }
   
    assertNotNull(am.get(entity));
    assertNull(bm.get(entity));
    assertTrue(am.has(entity));
    assertFalse(bm.has(entity));
   
    entity.remove(ComponentA.class);
   
    assertEquals(0, entity.getComponents().size());
   
    for (int i = 0; i < componentBits.length(); ++i) {
      assertFalse(componentBits.get(i));
    }
   
    assertNull(am.get(entity));
    assertNull(bm.get(entity));
    assertFalse(am.has(entity));
View Full Code Here

   */
  public Entity(){
    components = new Bag<Component>();
    componentsArray = new Array<Component>(false, 16);
    immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
    componentBits = new Bits();
    familyBits = new Bits();
    flags = 0;
   
    componentAdded = new Signal<Entity>();
    componentRemoved = new Signal<Entity>();
  }
View Full Code Here

    entity.add(new ComponentA());
    entity.add(new ComponentB());
   
    assertEquals(2, entity.getComponents().size());
   
    Bits componentBits = entity.getComponentBits();
    int componentAIndex = ComponentType.getIndexFor(ComponentA.class);
    int componentBIndex = ComponentType.getIndexFor(ComponentB.class);
   
    for (int i = 0; i < componentBits.length(); ++i) {
      assertEquals(i == componentAIndex || i == componentBIndex, componentBits.get(i));
    }
   
    assertNotNull(am.get(entity));
    assertNotNull(bm.get(entity));
    assertTrue(am.has(entity));
    assertTrue(bm.has(entity));
   
    entity.removeAll();
   
    assertEquals(0, entity.getComponents().size());
   
    for (int i = 0; i < componentBits.length(); ++i) {
      assertFalse(componentBits.get(i));
    }
   
    assertNull(am.get(entity));
    assertNull(bm.get(entity));
    assertFalse(am.has(entity));
View Full Code Here

 
  /**
   * @return Whether the entity matches the family requirements or not
   */
  public boolean matches(Entity entity){
    Bits entityComponentBits = entity.getComponentBits();
   
    if(entityComponentBits.isEmpty())
      return false;
   
    for (int i = all.nextSetBit(0); i >= 0; i = all.nextSetBit(i+1)){
      if(!entityComponentBits.get(i))
        return false;
    }
   
    if (!one.isEmpty() && !one.intersects(entityComponentBits)) {
      return false;
View Full Code Here

   * @return The family matching the specified {@link Component} classes as a descriptor. Each set of component types will
   * always return the same Family instance.
   */
  @SafeVarargs
  public static Family getFor(Class<? extends Component> ...componentTypes){
    return getFor(ComponentType.getBitsFor(componentTypes), new Bits(), new Bits());
  }
View Full Code Here

    /**
   * @param componentTypes list of {@link Component} classes
   * @return Bits representing the collection of components for quick comparison and matching. See {@link Family#getFor(Bits, Bits, Bits)}.
   */
  public static Bits getBitsFor(Class<? extends Component> ...componentTypes) {
    Bits bits = new Bits();

        int typesLength = componentTypes.length;
        for(int i = 0; i < typesLength; i++){
            bits.set(ComponentType.getIndexFor(componentTypes[i]));
        }
       
        return bits;
  }
View Full Code Here

   */
  public Entity(){
    components = new Bag<Component>();
    componentsArray = new Array<Component>(false, 16);
    immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
    componentBits = new Bits();
    familyBits = new Bits();
    flags = 0;
   
    uuid = new Long(nextId++);
   
    componentAdded = new Signal<Entity>();
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.utils.Bits

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.