Search in sources :

Example 56 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class OrderedByLayerEntitiesTest method testSubEntitiesAfterAnotherEntityIfParentIsAfter.

@Test
public void testSubEntitiesAfterAnotherEntityIfParentIsAfter() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    Entity e3 = world.createEntity();
    e1.addComponent(new RenderableComponent(6, 0));
    e2.addComponent(new RenderableComponent(5));
    e3.addComponent(new RenderableComponent(6, 1, true));
    e3.addComponent(new OwnerComponent(e1));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    orderedByLayerEntities.add(e3);
    assertSame(orderedByLayerEntities.get(0), e2);
    assertSame(orderedByLayerEntities.get(1), e1);
    assertSame(orderedByLayerEntities.get(2), e3);
}
Also used : Entity(com.artemis.Entity) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) RenderableComponent(com.gemserk.commons.artemis.components.RenderableComponent) World(com.artemis.World) Test(org.junit.Test)

Example 57 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class OrderedByLayerEntitiesTest method testTwoSubEntitiesOrder.

@Test
public void testTwoSubEntitiesOrder() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    Entity e3 = world.createEntity();
    Entity e4 = world.createEntity();
    e1.addComponent(new RenderableComponent(5));
    e2.addComponent(new RenderableComponent(6));
    e3.addComponent(new RenderableComponent(5, -1, true));
    e4.addComponent(new RenderableComponent(5, -1, true));
    e3.addComponent(new OwnerComponent(e1));
    e4.addComponent(new OwnerComponent(e2));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    orderedByLayerEntities.add(e3);
    orderedByLayerEntities.add(e4);
    assertSame(orderedByLayerEntities.get(0), e3);
    assertSame(orderedByLayerEntities.get(1), e1);
    assertSame(orderedByLayerEntities.get(2), e4);
    assertSame(orderedByLayerEntities.get(3), e2);
}
Also used : Entity(com.artemis.Entity) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) RenderableComponent(com.gemserk.commons.artemis.components.RenderableComponent) World(com.artemis.World) Test(org.junit.Test)

Example 58 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class OrderedByLayerEntitiesTest method shouldReturnEntityFirstIfLesserLayer.

@Test
public void shouldReturnEntityFirstIfLesserLayer() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    e1.addComponent(new RenderableComponent(0));
    e2.addComponent(new RenderableComponent(1));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    assertSame(orderedByLayerEntities.get(0), e1);
    assertSame(orderedByLayerEntities.get(1), e2);
}
Also used : Entity(com.artemis.Entity) RenderableComponent(com.gemserk.commons.artemis.components.RenderableComponent) World(com.artemis.World) Test(org.junit.Test)

Example 59 with Entity

use of com.artemis.Entity in project commons-gdx by gemserk.

the class TagManagerTest method shouldGetComponent.

public void shouldGetComponent() {
    String tag = "SuperUniqueEntity";
    World world = new World();
    Entity e = world.createEntity();
    e.setTag(tag);
    e.refresh();
    world.setDelta(10);
    world.loopStart();
    Entity e1 = world.getTagManager().getEntity(tag);
    assertThat(e1, IsNull.notNullValue());
    assertThat(e1, IsSame.sameInstance(e));
    world.deleteEntity(e);
    world.setDelta(10);
    world.loopStart();
    Entity e2 = world.getTagManager().getEntity(tag);
    assertThat(e2, IsNull.nullValue());
}
Also used : Entity(com.artemis.Entity) World(com.artemis.World)

Aggregations

Entity (com.artemis.Entity)59 World (com.artemis.World)38 Test (org.junit.Test)31 RenderableComponent (com.gemserk.commons.artemis.components.RenderableComponent)16 OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)15 WorldWrapper (com.gemserk.commons.artemis.WorldWrapper)8 EntityFactory (com.gemserk.commons.artemis.templates.EntityFactory)6 EntityFactoryImpl (com.gemserk.commons.artemis.templates.EntityFactoryImpl)6 EntityTemplate (com.gemserk.commons.artemis.templates.EntityTemplate)6 Spatial (com.gemserk.commons.gdx.games.Spatial)6 SpatialComponent (com.gemserk.commons.artemis.components.SpatialComponent)5 Body (com.badlogic.gdx.physics.box2d.Body)4 ContainerComponent (com.gemserk.commons.artemis.components.ContainerComponent)4 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)4 ParametersWrapper (com.gemserk.componentsengine.utils.ParametersWrapper)3 ComponentType (com.artemis.ComponentType)2 PreviousStateSpatialComponent (com.gemserk.commons.artemis.components.PreviousStateSpatialComponent)2 SpriteComponent (com.gemserk.commons.artemis.components.SpriteComponent)2 Script (com.gemserk.commons.artemis.scripts.Script)2 Container (com.gemserk.componentsengine.utils.Container)2