Search in sources :

Example 96 with EntityRef

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()));
}
Also used : EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 97 with EntityRef

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();
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 98 with EntityRef

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);
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 99 with EntityRef

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()));
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 100 with EntityRef

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());
    }
}
Also used : StringComponent(org.terasology.unittest.stubs.StringComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)298 Test (org.junit.jupiter.api.Test)88 ClientComponent (org.terasology.engine.network.ClientComponent)55 Vector3f (org.joml.Vector3f)51 LocationComponent (org.terasology.engine.logic.location.LocationComponent)44 Vector3i (org.joml.Vector3i)36 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)34 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)29 StringComponent (org.terasology.unittest.stubs.StringComponent)26 NetworkComponent (org.terasology.engine.network.NetworkComponent)23 EntityData (org.terasology.protobuf.EntityData)23 Quaternionf (org.joml.Quaternionf)19 DisplayNameComponent (org.terasology.engine.logic.common.DisplayNameComponent)19 Component (org.terasology.gestalt.entitysystem.component.Component)19 CharacterComponent (org.terasology.engine.logic.characters.CharacterComponent)15 Map (java.util.Map)14 EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)13 BlockComponent (org.terasology.engine.world.block.BlockComponent)13 Block (org.terasology.engine.world.block.Block)11 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)10