use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntitySerializerTest method testDeltaAddNewComponent.
@Test
public void testDeltaAddNewComponent() throws Exception {
EntityRef entity = entityManager.create(prefab);
entity.addComponent(new IntegerComponent(1));
EntityData.Entity entityData = entitySerializer.serialize(entity);
assertEquals(entity.getId(), entityData.getId());
assertEquals(prefab.getName(), entityData.getParentPrefab());
assertEquals(1, entityData.getComponentCount());
assertEquals(0, entityData.getRemovedComponentCount());
EntityData.Component componentData = entityData.getComponent(0);
assertEquals("test:integer", componentData.getType());
assertEquals(1, componentData.getFieldCount());
EntityData.NameValue field = componentData.getField(0);
assertEquals("value", field.getName());
assertEquals(1, field.getValue().getInteger(0));
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class ByteCodeReflectFactoryTest method testAccessIntegerField.
@Test
public void testAccessIntegerField() throws Exception {
ReflectFactory reflectFactory = new ByteCodeReflectFactory();
FieldAccessor fieldAccessor = reflectFactory.createFieldAccessor(IntegerComponent.class, IntegerComponent.class.getDeclaredField("value"));
IntegerComponent comp = new IntegerComponent();
fieldAccessor.setValue(comp, 1);
assertEquals(1, fieldAccessor.getValue(comp));
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentUntouchedIfRetainRequested.
@Test
public void testComponentUntouchedIfRetainRequested() {
worldProvider.setBlock(Vector3i.zero(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(Vector3i.zero());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockRetainComponent(Vector3i.zero(), blockWithString, IntegerComponent.class);
assertNotNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsAlteredIfBlockInSameFamilyWhenForced.
@Test
public void testComponentsAlteredIfBlockInSameFamilyWhenForced() {
worldProvider.setBlock(Vector3i.zero(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(Vector3i.zero());
entity.addComponent(new IntegerComponent());
worldProvider.setBlockForceUpdateEntity(Vector3i.zero(), blockInFamilyTwo);
assertNull(entity.getComponent(IntegerComponent.class));
}
use of org.terasology.entitySystem.stubs.IntegerComponent in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method testComponentsNotAlteredIfBlockInSameFamily.
@Test
public void testComponentsNotAlteredIfBlockInSameFamily() {
worldProvider.setBlock(Vector3i.zero(), blockInFamilyOne);
EntityRef entity = worldProvider.getBlockEntityAt(Vector3i.zero());
entity.addComponent(new IntegerComponent());
worldProvider.setBlock(Vector3i.zero(), blockInFamilyTwo);
assertNotNull(entity.getComponent(IntegerComponent.class));
}
Aggregations