use of org.terasology.engine.entitySystem.entity.EntityRef in project Anatomy by Terasology.
the class AnatomyScreenWindow method onOpened.
@Override
public void onOpened() {
EntityRef characterEntity = CoreRegistry.get(LocalPlayer.class).getCharacterEntity();
CharacterComponent characterComponent = characterEntity.getComponent(CharacterComponent.class);
// In case the player has been created yet, exit out early to prevent an error.
if (characterComponent == null) {
return;
}
// erroneously marked as existent.
if (!player.exists() || (player.exists() && (player == EntityRef.NULL || player.getId() == 0 || player == null))) {
reInit();
}
// As long as there's an interaction target, open this window.
if (getInteractionTarget() != EntityRef.NULL) {
initializeWithInteractionTarget(getInteractionTarget());
super.onOpened();
}
// Every time the character screen window is opened, update the Anatomy part statuses.
updateStatuses();
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntitySerializerTest method testScopePersisted.
@Test
public void testScopePersisted() {
EntityRef entity = entityManager.create(prefab);
for (EntityScope scope : EntityScope.values()) {
entity.setScope(scope);
entity = serializeDeserializeEntity(entity);
assertEquals(scope, entity.getScope());
}
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaLoadNoChange.
@Test
public void testDeltaLoadNoChange() throws Exception {
EntityRef entity = entityManager.create("test:Test");
EntityData.Entity entityData = entitySerializer.serialize(entity);
long nextId = entityManager.getNextId();
entityManager.clear();
entityManager.setNextId(nextId);
EntityRef loadedEntity = entitySerializer.deserialize(entityData);
assertTrue(loadedEntity.exists());
assertTrue(loadedEntity.hasComponent(StringComponent.class));
assertEquals("Value", loadedEntity.getComponent(StringComponent.class).value);
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaLoadChangedComponent.
@Test
public void testDeltaLoadChangedComponent() throws Exception {
EntityRef entity = entityManager.create("test:Test");
StringComponent comp = entity.getComponent(StringComponent.class);
comp.value = "Delta";
entity.saveComponent(comp);
EntityData.Entity entityData = entitySerializer.serialize(entity);
long nextId = entityManager.getNextId();
entityManager.clear();
entityManager.setNextId(nextId);
EntityRef loadedEntity = entitySerializer.deserialize(entityData);
assertTrue(loadedEntity.exists());
assertTrue(loadedEntity.hasComponent(StringComponent.class));
assertEquals("Delta", loadedEntity.getComponent(StringComponent.class).value);
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaNoUnchangedComponents.
@Test
public void testDeltaNoUnchangedComponents() throws Exception {
EntityRef entity = entityManager.create(prefab);
EntityData.Entity entityData = entitySerializer.serialize(entity);
assertEquals(entity.getId(), entityData.getId());
assertEquals(prefab.getName(), entityData.getParentPrefab());
assertEquals(0, entityData.getComponentCount());
assertEquals(0, entityData.getRemovedComponentCount());
}
Aggregations