use of ilargia.entitas.group.Group in project Entitas-Java by Rubentxu.
the class Collector method activate.
@Override
public void activate() {
for (int i = 0; i < _groups.length; i++) {
Group group = (Group) _groups[i];
GroupEvent groupEvent = _groupEvents[i];
switch(groupEvent) {
case Added:
group.OnEntityAdded(_addEntityCache);
break;
case Removed:
group.OnEntityRemoved(_addEntityCache);
break;
case AddedOrRemoved:
group.OnEntityAdded(_addEntityCache);
group.OnEntityRemoved(_addEntityCache);
break;
}
}
}
use of ilargia.entitas.group.Group in project Entitas-Java by Rubentxu.
the class Collector method deactivate.
@Override
public void deactivate() {
for (int i = 0; i < _groups.length; i++) {
Group group = (Group) _groups[i];
group.OnEntityAdded.remove(_addEntityCache);
group.OnEntityRemoved.remove(_addEntityCache);
}
clearCollectedEntities();
}
use of ilargia.entitas.group.Group 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.group.Group 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);
}
use of ilargia.entitas.group.Group in project Entitas-Java by Rubentxu.
the class ContextTest method duplicateEntityIndexTest.
@Test(expected = ContextEntityIndexDoesAlreadyExistException.class)
public void duplicateEntityIndexTest() {
entity.addComponent(TestComponentIds.Position, new Position());
Group group = context.getGroup(TestMatcher.Position());
PrimaryEntityIndex<Entity, String> index = new PrimaryEntityIndex("", group, (e, c) -> new String[] { "positionEntities" });
context.addEntityIndex("duplicate", index);
context.addEntityIndex("duplicate", index);
}
Aggregations