/** Let framework take care of internal business. */
  public void loopStart() {
    if (!refreshed.isEmpty()) {
      for (int i = 0; refreshed.size() > i; i++) {
        entityManager.refresh(refreshed.get(i));
      }
      refreshed.clear();
    }

    if (!deleted.isEmpty()) {
      for (int i = 0; deleted.size() > i; i++) {
        Entity e = deleted.get(i);
        groupManager.remove(e);
        entityManager.remove(e);
      }
      deleted.clear();
    }
  }
예제 #2
0
  public ArchetypeMapper(World world, IntBag toSave) {
    int[] ids = toSave.getData();
    Bag<Component> components = new Bag<Component>();
    Bag<Class<? extends Component>> types = new Bag<Class<? extends Component>>();

    for (int i = 0, s = toSave.size(); s > i; i++) {
      int compositionId = world.getEntity(ids[i]).getCompositionId();
      if (!compositionIdMapper.containsKey(compositionId)) {
        components.clear();
        types.clear();

        world.getComponentManager().getComponentsFor(ids[i], components);
        compositionIdMapper.put(compositionId, new TransmuterEntry(toClasses(components, types)));
      }
    }
  }