Search in sources :

Example 11 with Position

use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.

the class ContextTest method clearComponentPoolsTest.

@Test
public void clearComponentPoolsTest() {
    Stack[] cpool = context.getComponentPools();
    cpool[0] = new Stack<IComponent>();
    cpool[0].push(new Position());
    assertEquals(1, cpool[0].size());
    context.clearComponentPools();
    assertTrue(cpool[0].empty());
}
Also used : Position(ilargia.entitas.components.Position) IComponent(ilargia.entitas.api.IComponent) Test(org.junit.Test)

Example 12 with Position

use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.

the class ContextTest method clearComponentPoolTest.

@Test
public void clearComponentPoolTest() {
    Stack[] cpool = context.getComponentPools();
    cpool[0] = new Stack<IComponent>();
    cpool[0].push(new Position());
    assertEquals(1, cpool[0].size());
    context.clearComponentPool(0);
    assertTrue(cpool[0].empty());
}
Also used : Position(ilargia.entitas.components.Position) IComponent(ilargia.entitas.api.IComponent) Test(org.junit.Test)

Example 13 with Position

use of ilargia.entitas.components.Position 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)

Example 14 with Position

use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.

the class ContextTest method updateGroupsComponentAddedOrRemovedTest.

@Test
public void updateGroupsComponentAddedOrRemovedTest() {
    Position position = new Position();
    Group<TestEntity> group = context.getGroup(TestMatcher.Position());
    group.OnEntityAdded((g, e, idx, pc) -> assertEquals(TestComponentIds.Position, idx));
    entity.addComponent(TestComponentIds.Position, position);
    context.updateGroupsComponentAddedOrRemoved(entity, TestComponentIds.Position, position, context._groupsForIndex);
    context.updateGroupsComponentAddedOrRemoved(entity, TestComponentIds.Position, position, context._groupsForIndex);
//context.OnGroupCleared = (context, group)->  assertNull(context.OnEntityCreated);
}
Also used : TestEntity(ilargia.entitas.utils.TestEntity) Position(ilargia.entitas.components.Position) Test(org.junit.Test)

Example 15 with Position

use of ilargia.entitas.components.Position in project Entitas-Java by Rubentxu.

the class ContextTest method getGroupTest.

@Test
public void getGroupTest() {
    entity.addComponent(TestComponentIds.Position, new Position());
    Group group = context.getGroup(TestMatcher.Position());
    assertEquals(1, group.getCount());
    group = context.getGroup(TestMatcher.Position());
    assertEquals(1, group.getCount());
}
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