Search in sources :

Example 36 with StringComponent

use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testRemoveComponent.

@Test
public void testRemoveComponent() {
    EntityRef entity = entityManager.create();
    StringComponent comp = new StringComponent();
    entity.addComponent(comp);
    entity.removeComponent(StringComponent.class);
    assertNull(entity.getComponent(StringComponent.class));
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Example 37 with StringComponent

use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEntityManagerTest method testAddAndRetrieveComponent.

@Test
public void testAddAndRetrieveComponent() {
    EntityRef entity = entityManager.create();
    assertNotNull(entity);
    StringComponent comp = new StringComponent();
    entity.addComponent(comp);
    assertEquals(comp, entity.getComponent(StringComponent.class));
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) Test(org.junit.Test)

Example 38 with StringComponent

use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEventSystemTests method testPriorityAndCancel.

@Test
public void testPriorityAndCancel() {
    StringComponent stringComponent = entity.addComponent(new StringComponent());
    TestEventHandler handlerNormal = new TestEventHandler();
    TestHighPriorityEventHandler handlerHigh = new TestHighPriorityEventHandler();
    handlerHigh.cancel = true;
    eventSystem.registerEventHandler(handlerNormal);
    eventSystem.registerEventHandler(handlerHigh);
    TestEvent event = new TestEvent();
    eventSystem.send(entity, event);
    assertEquals(1, handlerHigh.receivedList.size());
    assertEquals(0, handlerNormal.receivedList.size());
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) Test(org.junit.Test)

Example 39 with StringComponent

use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEventSystemTests method testNoReceiveEventWhenMissingComponents.

@Test
public void testNoReceiveEventWhenMissingComponents() {
    StringComponent component = entity.addComponent(new StringComponent());
    TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
    eventSystem.registerEventHandler(handler);
    TestEvent event = new TestEvent();
    eventSystem.send(entity, event);
    assertEquals(0, handler.receivedList.size());
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) Test(org.junit.Test)

Example 40 with StringComponent

use of org.terasology.entitySystem.stubs.StringComponent in project Terasology by MovingBlocks.

the class PojoEventSystemTests method testReceiveEventRequiringMultipleComponents.

@Test
public void testReceiveEventRequiringMultipleComponents() {
    StringComponent stringComponent = entity.addComponent(new StringComponent());
    IntegerComponent intComponent = entity.addComponent(new IntegerComponent());
    TestCompoundComponentEventHandler handler = new TestCompoundComponentEventHandler();
    eventSystem.registerEventHandler(handler);
    TestEvent event = new TestEvent();
    eventSystem.send(entity, event);
    assertEquals(1, handler.receivedList.size());
    assertEquals(event, handler.receivedList.get(0).event);
    assertEquals(entity, handler.receivedList.get(0).entity);
}
Also used : IntegerComponent(org.terasology.entitySystem.stubs.IntegerComponent) StringComponent(org.terasology.entitySystem.stubs.StringComponent) Test(org.junit.Test)

Aggregations

StringComponent (org.terasology.entitySystem.stubs.StringComponent)41 Test (org.junit.Test)38 EntityRef (org.terasology.entitySystem.entity.EntityRef)22 IntegerComponent (org.terasology.entitySystem.stubs.IntegerComponent)8 EntityData (org.terasology.protobuf.EntityData)8 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)5 ResourceUrn (org.terasology.assets.ResourceUrn)4 PrefabData (org.terasology.entitySystem.prefab.PrefabData)4 Prefab (org.terasology.entitySystem.prefab.Prefab)3 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)3 Before (org.junit.Before)2 SimpleUri (org.terasology.engine.SimpleUri)2 Component (org.terasology.entitySystem.Component)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 GetterSetterComponent (org.terasology.entitySystem.stubs.GetterSetterComponent)2 Vector3i (org.terasology.math.geom.Vector3i)2 NetworkSystem (org.terasology.network.NetworkSystem)2 Map (java.util.Map)1 EntityRefComponent (org.terasology.entitySystem.stubs.EntityRefComponent)1 StorageManager (org.terasology.persistence.StorageManager)1