Example #1
0
  /**
   * Create a new entity.
   *
   * @return a new entity
   */
  protected Entity createEntityInstance() {
    Entity e = recyclingEntityFactory.obtain();
    entityToIdentity.set(e.getId(), 0);

    // growing backing array just in case
    entities.set(e.getId(), e);
    newlyCreatedEntityIds.set(e.id);
    return e;
  }
Example #2
0
  /**
   * Removes the entity from the manager, freeing it's id for new entities.
   *
   * @param entityId the entity to remove
   */
  @Override
  public void deleted(int entityId) {
    Entity entity = entities.get(entityId);
    if (entity == null) return;

    entities.set(entityId, null);

    // usually never happens but:
    // this happens when an entity is deleted before
    // it is added to the world, ie; created and deleted
    // before World#process has been called
    newlyCreatedEntityIds.set(entityId, false);

    recyclingEntityFactory.free(entity);

    disabled.clear(entityId);
  }
Example #3
0
 protected void clean() {
   recyclingEntityFactory.recycle();
 }