本文整理了Java中com.artemis.utils.Bag.set()
方法的一些代码示例,展示了Bag.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bag.set()
方法的具体详情如下:
包路径:com.artemis.utils.Bag
类名称:Bag
方法名:set
[英]Set element at specified index in the bag.
[中]将元素设置为袋中指定的索引。
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-core
/** 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;
}
}
代码示例来源:origin: DaanVanYperen/artemis-odb-contrib
/** 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;
}
}
代码示例来源:origin: junkdog/artemis-odb
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;
}
代码示例来源:origin: junkdog/artemis-odb
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);
}
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
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;
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
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);
}
}
代码示例来源:origin: junkdog/artemis-odb
@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);
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
@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);
}
代码示例来源:origin: junkdog/artemis-odb
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;
}
}
代码示例来源:origin: DaanVanYperen/libgdx-artemis-quickstart
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;
}
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* 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;
}
代码示例来源:origin: junkdog/artemis-odb
/**
* 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;
}
代码示例来源:origin: junkdog/artemis-odb
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);
}
代码示例来源:origin: junkdog/artemis-odb
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);
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
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);
}
代码示例来源:origin: junkdog/artemis-odb
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);
}
}
};
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb-serializer
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);
}
}
};
代码示例来源:origin: junkdog/artemis-odb
@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;
}
代码示例来源:origin: junkdog/artemis-odb
@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;
}
代码示例来源:origin: junkdog/artemis-odb
@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;
}
内容来源于网络,如有侵权,请联系作者删除!