Search in sources :

Example 1 with PrimaryEntityIndex

use of ilargia.entitas.index.PrimaryEntityIndex 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"));
}
Also used : IGroup(ilargia.entitas.api.IGroup) Group(ilargia.entitas.group.Group) IEntity(ilargia.entitas.api.entitas.IEntity) TestEntity(ilargia.entitas.utils.TestEntity) Position(ilargia.entitas.components.Position) PrimaryEntityIndex(ilargia.entitas.index.PrimaryEntityIndex) Test(org.junit.Test)

Example 2 with PrimaryEntityIndex

use of ilargia.entitas.index.PrimaryEntityIndex 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);
}
Also used : IGroup(ilargia.entitas.api.IGroup) Group(ilargia.entitas.group.Group) IEntity(ilargia.entitas.api.entitas.IEntity) TestEntity(ilargia.entitas.utils.TestEntity) Position(ilargia.entitas.components.Position) PrimaryEntityIndex(ilargia.entitas.index.PrimaryEntityIndex) Test(org.junit.Test)

Aggregations

IGroup (ilargia.entitas.api.IGroup)2 IEntity (ilargia.entitas.api.entitas.IEntity)2 Position (ilargia.entitas.components.Position)2 Group (ilargia.entitas.group.Group)2 PrimaryEntityIndex (ilargia.entitas.index.PrimaryEntityIndex)2 TestEntity (ilargia.entitas.utils.TestEntity)2 Test (org.junit.Test)2