本文整理了Java中com.artemis.Entity.getId()
方法的一些代码示例,展示了Entity.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getId()
方法的具体详情如下:
包路径:com.artemis.Entity
类名称:Entity
方法名:getId
[英]The internal id for this entity within the framework. Id is zero or greater.
No other entity will have the same ID, but ID's are however reused so another entity may acquire this ID if the previous entity was deleted.
[中]框架内此实体的内部id。Id为零或更大。
没有其他实体具有相同的ID,但是ID被重用,因此如果删除了以前的实体,其他实体可能会获取此ID。
代码示例来源:origin: junkdog/artemis-odb
@Override
public int read(Component c, Field f) {
Entity e = ((UniEntityLink) c).field;
return (e != null) ? e.getId() : -1;
}
代码示例来源:origin: junkdog/artemis-odb
private boolean updateReferenced(Entity e, BitVector referencedIds) {
return (e != null)
? updateReferenced(e.getId(), referencedIds)
: false;
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Create or remove a component from an entity.
*
* Does nothing if already removed or created respectively.
*
* @param entity Entity to change.
* @param value {@code true} to create component (if missing), {@code false} to remove (if exists).
* @return the instance of the component, or {@code null} if removed.
*/
public A set(Entity entity, boolean value) {
return set(entity.getId(), value);
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Fast and safe retrieval of a component for this entity.
* If the entity does not have this component then fallback is returned.
*
* @param entity Entity that should possess the component
* @param fallback fallback component to return, or {@code null} to return null.
* @return the instance of the component
*/
public A getSafe(Entity entity, A fallback) {
return getSafe(entity.getId(), fallback);
}
代码示例来源: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: junkdog/artemis-odb
@Override
public int read(Component c, Field f) {
try {
Entity e = (Entity) f.get(c);
return (e != null) ? e.getId() : -1;
} catch (ReflectionException exc) {
throw new RuntimeException(exc);
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Create component for this entity.
* Will avoid creation if component preexists.
*
* @param entity the entity that should possess the component
* @return the instance of the component.
*/
public A create(Entity entity) {
return create(entity.getId());
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Remove component from entity.
* Does nothing if already removed.
*
* @param entity entity to remove.
*/
public void remove(Entity entity) {
remove(entity.getId());
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* Fast and safe retrieval of a component for this entity.
* If the entity does not have this component then fallback is returned.
*
* @param entity Entity that should possess the component
* @param fallback fallback component to return, or {@code null} to return null.
* @return the instance of the component
*/
public A getSafe(Entity entity, A fallback) {
return getSafe(entity.getId(), fallback);
}
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-core
/**
* Create or remove a component from an entity.
*
* Does nothing if already removed or created respectively.
*
* @param entity Entity to change.
* @param value {@code true} to create component (if missing), {@code false} to remove (if exists).
* @return the instance of the component, or {@code null} if removed.
*/
public A set(Entity entity, boolean value) {
return mapper.set(entity.getId(), value);
}
代码示例来源: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: junkdog/artemis-odb
public UUID getUuid(Entity e) {
UUID uuid = entityToUuid.safeGet(e.getId());
if (uuid == null) {
uuid = UUID.randomUUID();
setUuid(e, uuid);
}
return uuid;
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Create and return a new or reused entity instance. Entity is
* automatically added to the world.
*
* @return entity
* @see #create() recommended alternative.
*/
public Entity createEntity() {
Entity e = em.createEntityInstance();
batchProcessor.changed.unsafeSet(e.getId());
return e;
}
代码示例来源:origin: junkdog/artemis-odb
void translate(Component c, Field field, Bag<Entity> translatedIds) {
try {
int oldId = ((Integer)field.get(c)).intValue();
if (oldId != -1)
field.set(c, translatedIds.get(oldId).getId());
} catch (ReflectionException e) {
throw new RuntimeException(e);
}
}
},
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* Create and return a new or reused entity instance. Entity is
* automatically added to the world.
*
* @return entity
* @see #create() recommended alternative.
*/
public Entity createEntity() {
Entity e = em.createEntityInstance();
batchProcessor.changed.unsafeSet(e.getId());
return e;
}
代码示例来源:origin: junkdog/artemis-odb
void translate(Component c, Field field, Bag<Entity> translatedIds) {
try {
Entity e = (Entity) field.get(c);
if (e != null) {
int oldId = e.getId();
field.set(c, translatedIds.get(oldId));
}
} catch (ReflectionException e) {
throw new RuntimeException(e);
}
}
},
代码示例来源:origin: junkdog/artemis-odb
@Override
public void validate(int sourceId, Bag<Entity> entities, LinkListener listener) {
for (int i = 0; entities.size() > i; i++) {
Entity e = entities.get(i);
if (!all.getActiveEntityIds().unsafeGet(e.getId())) {
entities.remove(i--);
if (listener != null)
listener.onTargetDead(sourceId, e.getId());
}
}
}
代码示例来源:origin: junkdog/artemis-odb
@Override
public void validate(int sourceId, Bag<Entity> entities, LinkListener listener) {
for (int i = 0; entities.size() > i; i++) {
Entity e = entities.get(i);
if (!all.getActiveEntityIds().unsafeGet(e.getId())) {
entities.remove(i--);
if (listener != null)
listener.onTargetDead(sourceId, e.getId());
}
}
}
代码示例来源:origin: junkdog/artemis-odb
void translate(Component c, Field field, Bag<Entity> translatedIds) {
try {
IntBag bag = (IntBag) field.get(c);
for (int i = 0, s = bag.size(); s > i; i++) {
int oldId = bag.get(i);
bag.set(i, translatedIds.get(oldId).getId());
}
} catch (ReflectionException e) {
throw new RuntimeException(e);
}
}
},
内容来源于网络,如有侵权,请联系作者删除!