/** Set mapper at index. */ private M setMapper(int index, Class<? extends Component> type) { M m = new M(type, world); mappers.set(index, m); return m; } }
/** Set mapper at index. */ private M setMapper(int index, Class<? extends Component> type) { M m = new M(type, world); mappers.set(index, m); return m; } }
private TransmuteOperation operation(int entityId, int compositionId) { TransmuteOperation operation = operations.safeGet(compositionId); if (operation == null) { operation = factory.createOperation(entityId); operations.set(compositionId, operation); } return operation; }
public void setUuid(Entity e, UUID newUuid) { UUID oldUuid = entityToUuid.safeGet(e.getId()); if (oldUuid != null) uuidToEntity.remove(oldUuid); uuidToEntity.put(newUuid, e); entityToUuid.set(e.getId(), newUuid); } }
private TransmuteOperation operation(int entityId, int compositionId) { TransmuteOperation operation = operations.safeGet(compositionId); if (operation == null) { operation = factory.createOperation(entityId); operations.set(compositionId, operation); } return operation; }
public void setUuid(Entity e, UUID newUuid) { UUID oldUuid = entityToUuid.safeGet(e.getId()); if (oldUuid != null) uuidToEntity.remove(oldUuid); uuidToEntity.put(newUuid, e); entityToUuid.set(e.getId(), newUuid); } }
@Override public void deleted(Entity e) { UUID uuid = entityToUuid.safeGet(e.getId()); if (uuid == null) return; Entity oldEntity = uuidToEntity.get(uuid); if (oldEntity != null && oldEntity.equals(e)) uuidToEntity.remove(uuid); entityToUuid.set(e.getId(), null); }
@Override public void deleted(Entity e) { UUID uuid = entityToUuid.safeGet(e.getId()); if (uuid == null) return; Entity oldEntity = uuidToEntity.get(uuid); if (oldEntity != null && oldEntity.equals(e)) uuidToEntity.remove(uuid); entityToUuid.set(e.getId(), null); }
E getE(int entityId) { E e = (E) es.safeGet(entityId); if ( e == null ) { e = new E().init(this,entityId); es.set(entityId, e); }; return e; } }
E getE(int entityId) { E e = (E) es.safeGet(entityId); if ( e == null ) { e = new E().init(this,entityId); es.set(entityId, e); }; return e; } }
/** * Instantiates an Entity without registering it into the world. * @param id The ID to be set on the Entity */ private Entity createEntity(int id) { Entity e = new Entity(world, id); if (e.id >= entities.getCapacity()) { growEntityStores(); } // can't use unsafe set, as we need to track highest id // for faster iteration when syncing up new subscriptions // in ComponentManager#synchronize entities.set(e.id, e); return e; }
/** * Instantiates an Entity without registering it into the world. * @param id The ID to be set on the Entity */ private Entity createEntity(int id) { Entity e = new Entity(world, id); if (e.id >= entities.getCapacity()) { growEntityStores(); } // can't use unsafe set, as we need to track highest id // for faster iteration when syncing up new subscriptions // in ComponentManager#synchronize entities.set(e.id, e); return e; }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
void registerComponentType(ComponentType ct, int capacity) { int index = ct.getIndex(); ComponentMapper mapper = new ComponentMapper(ct.getType(), world); mapper.components.ensureCapacity(capacity); mappers.set(index, mapper); }
void translate(Component c, Field field, Bag<Entity> translatedIds) { try { Bag bag = (Bag) field.get(c); for (int i = 0, s = bag.size(); s > i; i++) { Object o = bag.get(i); if (o instanceof Entity) { bag.set(i, translatedIds.get(((Entity)o).getId())); } else { return; } } } catch (ReflectionException e) { throw new RuntimeException(e); } } };
void translate(Component c, Field field, Bag<Entity> translatedIds) { try { Bag bag = (Bag) field.get(c); for (int i = 0, s = bag.size(); s > i; i++) { Object o = bag.get(i); if (o instanceof Entity) { bag.set(i, translatedIds.get(((Entity)o).getId())); } else { return; } } } catch (ReflectionException e) { throw new RuntimeException(e); } } };
@Override public IntBag read(Json json, JsonValue jsonData, Class type) { recursionLevel++; IntBag bag = new IntBag(); if (recursionLevel == 1) { JsonValue entityArray = jsonData.child; JsonValue entity = entityArray; while (entity != null) { Entity e = json.readValue(Entity.class, entity.child); translatedIds.set(Integer.parseInt(entity.name), e); bag.add(e.getId()); entity = entity.next; } } else { for (JsonValue child = jsonData.child; child != null; child = child.next) { bag.add(json.readValue(Integer.class, child)); } } recursionLevel--; return bag; }
@Override public IntBag read(Json json, JsonValue jsonData, Class type) { recursionLevel++; IntBag bag = new IntBag(); if (recursionLevel == 1) { JsonValue entityArray = jsonData.child; JsonValue entity = entityArray; while (entity != null) { Entity e = json.readValue(Entity.class, entity.child); translatedIds.set(Integer.parseInt(entity.name), e); bag.add(e.getId()); entity = entity.next; } } else { for (JsonValue child = jsonData.child; child != null; child = child.next) { bag.add(json.readValue(Integer.class, child)); } } recursionLevel--; return bag; }
@Override public IntBag read (Kryo kryo, Input input, Class<IntBag> aClass) { recursionLevel++; IntBag bag = new IntBag(); int count = input.readInt(); if (recursionLevel == 1) { for (int i = 0; i < count; i++) { int oldId = input.readInt(); Entity e = kryo.readObject(input, Entity.class); translatedIds.set(oldId, e); bag.add(e.getId()); } } else { for (int i = 0; i < count; i++) { bag.add(input.readInt()); } } recursionLevel--; return bag; }