Search in sources :

Example 1 with Position

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"));
}
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 Position

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);
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) Position(ilargia.entitas.components.Position) IComponent(ilargia.entitas.api.IComponent) IGroup(ilargia.entitas.api.IGroup) Test(org.junit.Test)

Example 3 with Position

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);
}
Also used : Position(ilargia.entitas.components.Position) Test(org.junit.Test)

Example 4 with Position

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);
}
Also used : Position(ilargia.entitas.components.Position) Test(org.junit.Test)

Example 5 with Position

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);
}
Also used : IGroup(ilargia.entitas.api.IGroup) Group(ilargia.entitas.group.Group) Position(ilargia.entitas.components.Position) Test(org.junit.Test)

Aggregations

Position (ilargia.entitas.components.Position)17 Test (org.junit.Test)15 TestEntity (ilargia.entitas.utils.TestEntity)6 IGroup (ilargia.entitas.api.IGroup)5 Group (ilargia.entitas.group.Group)5 IComponent (ilargia.entitas.api.IComponent)4 IEntity (ilargia.entitas.api.entitas.IEntity)3 ContextInfo (ilargia.entitas.api.ContextInfo)2 View (ilargia.entitas.components.View)2 PrimaryEntityIndex (ilargia.entitas.index.PrimaryEntityIndex)2 Before (org.junit.Before)2 EntitasCache (ilargia.entitas.caching.EntitasCache)1