示例#1
0
  /**
   * Delete the entity from the world.
   *
   * @param e Entity to remove
   */
  public void deleteEntity(Entity e) {
    if (!deleted.contains(e)) {
      deleted.add(e);
    }

    if (added.contains(e)) {
      added.remove(e);
    }
  }
示例#2
0
 /**
  * Performs an action on each entity.
  *
  * @param entities
  * @param performer
  */
 protected void check(ObjectSet<Entity> entities, Performer performer) {
   if (entities.size > 0) {
     for (Entity e : entities) {
       notifyManagers(performer, e);
       notifySystems(performer, e);
     }
     entities.clear();
   }
 }
示例#3
0
 public void remove() {
   if (currentIndex < 0) throw new IllegalStateException("next must be called before remove.");
   if (currentIndex >= set.capacity) {
     set.removeStashIndex(currentIndex);
   } else {
     set.keyTable[currentIndex] = null;
   }
   currentIndex = -1;
   set.size--;
 }
示例#4
0
  @Override
  public void dispose() {
    em.dispose();
    cm.dispose();

    added.clear();
    changed.clear();
    deleted.clear();
    enable.clear();
    disable.clear();

    for (Manager manager : managers) {
      manager.dispose();
    }

    managers.clear();
    systems.clear();

    if (eventSystem != null) {
      eventSystem.dispose();
      eventSystem = null;
    }
  }
示例#5
0
 private static void cleanRemovableBodies() {
   ///// WORLD Step////////CleanStuff//
   if (removableBodies.size > 0) {
     boolean clearRemovable = false;
     for (Body body : removableBodies) {
       body.setActive(
           false); // Body wont be active while it waits deletion; This must happen outside the
                   // Step process;
       if (!WORLD.isLocked()) {
         WORLD.destroyBody(body);
         clearRemovable = true;
       }
     }
     if (clearRemovable) {
       removableBodies.clear();
       // collisionPairsDictionary.clear();
     }
   }
   ///// WORLD Step////////CleanStuff//
 }
示例#6
0
 public void clear() {
   items.clear();
   super.clear();
 }
示例#7
0
 public void clear(int maximumCapacity) {
   items.clear();
   super.clear(maximumCapacity);
 }
示例#8
0
 // Destroy bodies from Poolable or Non-Poolable objects
 public static void destroyBody(Body body) {
   // body.setActive(false); //Body wont be active while it waits deletion;  //Da problema!!
   removableBodies.add(body);
 }
示例#9
0
 /**
  * Disable the entity from being processed. Won't delete it, it will continue to exist but won't
  * get processed.
  *
  * @param e entity to disable
  */
 public void disable(Entity e) {
   disable.add(e);
 }
示例#10
0
 /**
  * (Re)enable the entity in the world, after it having being disabled. Won't do anything unless it
  * was already disabled.
  *
  * @param e entity to enable
  */
 public void enable(Entity e) {
   enable.add(e);
 }
示例#11
0
 /**
  * Ensure all systems are notified of changes to this entity. If you're adding a component to an
  * entity after it's been added to the world, then you need to invoke this method.
  *
  * @param e entity
  */
 public void changedEntity(Entity e) {
   changed.add(e);
 }
示例#12
0
 /**
  * Adds a entity to this world.
  *
  * @param e entity
  */
 public void addEntity(Entity e) {
   added.add(e);
 }