use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testEntityNotRemovedIfForceBlockActiveComponentAdded.
@Test
public void testEntityNotRemovedIfForceBlockActiveComponentAdded() {
EntityRef blockEntity = worldProvider.getBlockEntityAt(new Vector3i());
blockEntity.addComponent(new ForceBlockActiveComponent());
worldProvider.update(1.0f);
assertTrue(blockEntity.exists());
assertTrue(blockEntity.isActive());
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testChangedComponentsRevertedBeforeCleanUp.
@Test
public void testChangedComponentsRevertedBeforeCleanUp() {
worldStub.setBlock(new Vector3i(), blockWithString);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
StringComponent comp = entity.getComponent(StringComponent.class);
comp.value = "Moo";
entity.saveComponent(comp);
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(OnChangedComponent.newInstance(), entity)), checker.receivedEvents);
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testBlockEntityPrefabCorrectlyAddedOnChangeToBlockWithPrefab.
@Disabled("Failing due to #2625. TODO: fix to match new behaviour")
@Test
public void testBlockEntityPrefabCorrectlyAddedOnChangeToBlockWithPrefab() {
worldProvider.setBlock(new Vector3i(), plainBlock);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
worldProvider.setBlock(new Vector3i(), blockWithString);
assertEquals(blockWithString.getPrefab().get().getUrn().toString(), entity.getParentPrefab().getUrn().toString());
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentUntouchedIfRetainRequested.
@Test
public void testComponentUntouchedIfRetainRequested() {
worldProvider.setBlock(new Vector3i(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockRetainComponent(new Vector3i(), blockWithString, IntegerComponent.class);
assertNotNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.engine.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testEntityExtraComponentsRemovedBeforeCleanUp.
@Test
public void testEntityExtraComponentsRemovedBeforeCleanUp() {
EntityRef entity = worldProvider.getBlockEntityAt(new Vector3i());
entity.addComponent(new StringComponent("test"));
LifecycleEventChecker checker = new LifecycleEventChecker(entityManager.getEventSystem(), StringComponent.class);
worldProvider.update(1.0f);
assertEquals(Lists.newArrayList(new EventInfo(BeforeDeactivateComponent.newInstance(), entity), new EventInfo(BeforeRemoveComponent.newInstance(), entity)), checker.receivedEvents);
}
Aggregations