use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.
the class ContextTest method entityIndexTest.
@Test
public void entityIndexTest() {
entity.addComponent(TestComponentIds.Position, new Position());
Group group = context.getGroup(TestMatcher.Position());
PrimaryEntityIndex<Entity, String> index = new PrimaryEntityIndex("", (e, c) -> "positionEntities", group);
context.addEntityIndex("positions", index);
index = (PrimaryEntityIndex<Entity, String>) context.getEntityIndex("positions");
assertNotNull(index);
assertNotNull(index.getEntity("positionEntities"));
}
use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.
the class ContextTest method updateGroupsComponentReplacedTest.
@Test
public void updateGroupsComponentReplacedTest() {
Position position = new Position();
Position position2 = new Position();
Group<TestEntity> groupE = context.getGroup(TestMatcher.Position());
groupE.OnEntityUpdated((IGroup<TestEntity> group, final TestEntity entity, int index, IComponent previousComponent, IComponent nc) -> {
System.out.println("Removed...........");
assertEquals(position2, nc);
});
entity.addComponent(TestComponentIds.Position, position);
context.updateGroupsComponentReplaced(entity, TestComponentIds.Position, position, position2, context._groupsForIndex);
}
use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.
the class EntityTest method replaceComponentTest.
@Test
public void replaceComponentTest() {
entity.replaceComponent(TestComponentIds.Position, new Position(50F, 50F));
assertEquals(50F, ((Position) entity.getComponent(TestComponentIds.Position)).x, 0.1F);
}
use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.
the class EntityTest method recoverNullComponent.
@Test
public void recoverNullComponent() throws InstantiationException, IllegalAccessException {
Position component = (Position) entity.recoverComponent(TestComponentIds.Position);
assertNull(component);
}
use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.
the class ContextTest method getGroupEntitiesTest.
@Test
public void getGroupEntitiesTest() {
entity.addComponent(TestComponentIds.Position, new Position());
Group group = context.getGroup(TestMatcher.Position());
assertEquals(1, group.getEntities().length);
}
Aggregations