Search in sources :

Example 1 with ForceBlockActiveComponent

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

the class EntityAwareWorldProviderTest method testEntityBecomesTemporaryIfForceBlockActiveComponentRemoved.

@Test
public void testEntityBecomesTemporaryIfForceBlockActiveComponentRemoved() {
    EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0));
    blockEntity.addComponent(new ForceBlockActiveComponent());
    worldProvider.update(1.0f);
    blockEntity.removeComponent(ForceBlockActiveComponent.class);
    worldProvider.update(1.0f);
    assertFalse(blockEntity.exists());
    assertFalse(blockEntity.isActive());
}
Also used : Vector3i(org.terasology.math.geom.Vector3i) EntityRef(org.terasology.entitySystem.entity.EntityRef) ForceBlockActiveComponent(org.terasology.entitySystem.stubs.ForceBlockActiveComponent) Test(org.junit.Test)

Example 2 with ForceBlockActiveComponent

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

the class EntityAwareWorldProviderTest method testAllComponentsNotMarkedAsRetainedRemovedOnBlockChange.

@Test
public void testAllComponentsNotMarkedAsRetainedRemovedOnBlockChange() {
    worldStub.setBlock(Vector3i.zero(), blockWithString);
    EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0));
    entity.addComponent(new ForceBlockActiveComponent());
    entity.addComponent(new RetainedOnBlockChangeComponent(2));
    worldProvider.setBlock(Vector3i.zero(), airBlock);
    assertTrue(entity.hasComponent(RetainedOnBlockChangeComponent.class));
    assertFalse(entity.hasComponent(ForceBlockActiveComponent.class));
}
Also used : RetainedOnBlockChangeComponent(org.terasology.entitySystem.stubs.RetainedOnBlockChangeComponent) Vector3i(org.terasology.math.geom.Vector3i) EntityRef(org.terasology.entitySystem.entity.EntityRef) ForceBlockActiveComponent(org.terasology.entitySystem.stubs.ForceBlockActiveComponent) Test(org.junit.Test)

Example 3 with ForceBlockActiveComponent

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

the class EntityAwareWorldProviderTest method testEntityNotRemovedIfForceBlockActiveComponentAdded.

@Test
public void testEntityNotRemovedIfForceBlockActiveComponentAdded() {
    EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i(0, 0, 0));
    blockEntity.addComponent(new ForceBlockActiveComponent());
    worldProvider.update(1.0f);
    assertTrue(blockEntity.exists());
    assertTrue(blockEntity.isActive());
}
Also used : Vector3i(org.terasology.math.geom.Vector3i) EntityRef(org.terasology.entitySystem.entity.EntityRef) ForceBlockActiveComponent(org.terasology.entitySystem.stubs.ForceBlockActiveComponent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 EntityRef (org.terasology.entitySystem.entity.EntityRef)3 ForceBlockActiveComponent (org.terasology.entitySystem.stubs.ForceBlockActiveComponent)3 Vector3i (org.terasology.math.geom.Vector3i)3 RetainedOnBlockChangeComponent (org.terasology.entitySystem.stubs.RetainedOnBlockChangeComponent)1