use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class PojoEntityPoolTest method testContains.
@Test
public void testContains() {
assertFalse(pool.contains(PojoEntityManager.NULL_ID));
assertFalse(pool.contains(1000000));
EntityRef ref = entityManager.create();
entityManager.moveToPool(ref.getId(), pool);
assertTrue(pool.contains(ref.getId()));
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testChangeComponentsDuringIterator.
@Test
public void testChangeComponentsDuringIterator() {
EntityRef entity1 = entityManager.create();
entity1.addComponent(new StringComponent());
EntityRef entity2 = entityManager.create();
entity2.addComponent(new StringComponent());
Iterator<Map.Entry<EntityRef, StringComponent>> iterator = entityManager.listComponents(StringComponent.class).iterator();
iterator.next();
entity2.removeComponent(StringComponent.class);
iterator.next();
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testPrefabCopiedCorrectly.
@Test
public void testPrefabCopiedCorrectly() {
EntityRef entity1 = entityManager.create(prefab);
StringComponent comp = entity1.getComponent(StringComponent.class);
assertEquals("Test", comp.value);
comp.value = "One";
entity1.saveComponent(comp);
assertEquals("Test", prefab.getComponent(StringComponent.class).value);
EntityRef entity2 = entityManager.create(prefab);
assertEquals("Test", prefab.getComponent(StringComponent.class).value);
assertEquals("One", entity1.getComponent(StringComponent.class).value);
assertEquals("Test", entity2.getComponent(StringComponent.class).value);
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testCreateEntityWithComponent.
@Test
public void testCreateEntityWithComponent() {
StringComponent comp = new StringComponent("Test");
EntityRef entity = entityManager.create(comp);
assertNotNull(entity);
assertNotNull(entity.getComponent(StringComponent.class));
assertEquals(comp, entity.getComponent(StringComponent.class));
assertEquals(CHUNK, entity.getScope());
assertTrue(entityManager.getGlobalPool().contains(entity.getId()));
assertFalse(entityManager.getSectorManager().contains(entity.getId()));
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testIterateComponents.
@Test
public void testIterateComponents() {
EntityRef entity = entityManager.create();
StringComponent comp = new StringComponent();
entity.addComponent(comp);
for (Map.Entry<EntityRef, StringComponent> item : entityManager.listComponents(StringComponent.class)) {
assertEquals(entity, item.getKey());
assertEquals(comp, item.getValue());
}
}
Aggregations