@Override
 public void updatedEntitySystem(int systemIndex, int entitiesCount, int maxEntitiesCount) {
   for (int i = 0, n = _listeners.size(); i < n; ++i) {
     EntityTrackerCommunicator communicator = _listeners.get(i);
     communicator.updatedEntitySystem(systemIndex, entitiesCount, maxEntitiesCount);
   }
   _entitySystemsEntitiesCount.set(systemIndex, entitiesCount);
   _entitySystemsMaxEntitiesCount.set(systemIndex, maxEntitiesCount);
 }
 @Override
 public void addedSystem(
     int index, String name, BitSet allTypes, BitSet oneTypes, BitSet notTypes) {
   for (int i = 0, n = _listeners.size(); i < n; ++i) {
     EntityTrackerCommunicator communicator = _listeners.get(i);
     communicator.addedSystem(index, name, allTypes, oneTypes, notTypes);
   }
   _systems.add(Tuple3.create(index, name, new AspectInfo(allTypes, oneTypes, notTypes)));
   _entitySystemsEntitiesCount.set(index, 0);
   _entitySystemsMaxEntitiesCount.set(index, 0);
 }
 @Override
 public void addedComponentType(int index, ComponentTypeInfo info) {
   for (int i = 0, n = _listeners.size(); i < n; ++i) {
     EntityTrackerCommunicator communicator = _listeners.get(i);
     communicator.addedComponentType(index, info);
   }
   _componentTypes.set(index, info);
 }
示例#4
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;
  }
  /**
   * Gets the component type for the given component class.
   *
   * <p>If no component type exists yet, a new one will be created and stored for later retrieval.
   *
   * @param c the component's class to get the type for
   * @return the component's {@link ComponentType}
   */
  public ComponentType getTypeFor(Class<? extends Component> c) {
    ComponentType type = componentTypes.get(c);

    if (type == null) {
      int index = componentTypeCount++;
      type = new ComponentType(c, index);
      componentTypes.put(c, type);
      types.set(index, type);
    }

    return type;
  }
示例#6
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);
  }