Search in sources :

Example 16 with Entity

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

the class EntityTemplateTest method weaponInstantiateBullet.

@Deprecated
public void weaponInstantiateBullet() {
    EntityTemplate bulletTemplate = new BulletEntityTemplate();
    // modifies the template forever, if we are using the same template in different weapons or something similar, then they will be modified as well.
    // bulletTemplate.getDefaultParameters().put("damage", new Float(200f));
    EntityFactory entityFactory = new EntityFactoryImpl(new World());
    Entity bullet = entityFactory.instantiate(bulletTemplate);
    DamageComponent damageComponent = bullet.getComponent(DamageComponent.class);
    assertThat(damageComponent.getDamage(), IsEqual.equalTo(200f));
}
Also used : Entity(com.artemis.Entity) EntityFactoryImpl(com.gemserk.commons.artemis.templates.EntityFactoryImpl) EntityTemplate(com.gemserk.commons.artemis.templates.EntityTemplate) World(com.artemis.World) EntityFactory(com.gemserk.commons.artemis.templates.EntityFactory)

Example 17 with Entity

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

the class MultipleImplementationsSameComponentTest method shouldHandleSpecificComponentImplementation.

@Test
public void shouldHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new FirstImplementationSystem());
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new FirstImplementationComponent());
    e1.refresh();
    worldWrapper.update(100);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) World(com.artemis.World) Test(org.junit.Test)

Example 18 with Entity

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

the class MultipleImplementationsSameComponentWorkaroundTest method shouldHandleSpecificComponentImplementation.

@Test
public void shouldHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new SpatialSystem());
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new SpatialComponent(new SpatialFirstImpl()));
    e1.refresh();
    worldWrapper.update(100);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) World(com.artemis.World) Test(org.junit.Test)

Example 19 with Entity

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

the class MultipleImplementationsSameComponentWorkaroundTest method shouldNotHandleSpecificComponentImplementation.

@Test
public void shouldNotHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new SpatialSystem());
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new SpatialComponent(new SpatialSecondImpl()));
    e1.refresh();
    worldWrapper.update(100);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) World(com.artemis.World) Test(org.junit.Test)

Example 20 with Entity

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

the class OrderedByLayerEntitiesTest method shouldReturnEntityFirstIfGreaterLayerInverted.

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

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