Search in sources :

Example 6 with EntityTemplate

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

the class EntityTemplateTest method shouldUseDefaultParametersIfParameterMissingFromCustomParameters.

@Test
public void shouldUseDefaultParametersIfParameterMissingFromCustomParameters() {
    ParametersWrapper weaponBulletParameters = new ParametersWrapper();
    // damage and position parameters are missing, but they are on default parameters
    EntityTemplate bulletTemplate = new BulletEntityTemplate();
    EntityFactory entityFactory = new EntityFactoryImpl(new World());
    Entity bullet = entityFactory.instantiate(bulletTemplate, weaponBulletParameters);
    DamageComponent damageComponent = bullet.getComponent(DamageComponent.class);
    assertThat(damageComponent.getDamage(), IsEqual.equalTo(5f));
}
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) ParametersWrapper(com.gemserk.componentsengine.utils.ParametersWrapper) Test(org.junit.Test)

Aggregations

Entity (com.artemis.Entity)6 World (com.artemis.World)6 EntityFactory (com.gemserk.commons.artemis.templates.EntityFactory)6 EntityFactoryImpl (com.gemserk.commons.artemis.templates.EntityFactoryImpl)6 EntityTemplate (com.gemserk.commons.artemis.templates.EntityTemplate)6 Test (org.junit.Test)5 SpatialComponent (com.gemserk.commons.artemis.components.SpatialComponent)3 ParametersWrapper (com.gemserk.componentsengine.utils.ParametersWrapper)3 Spatial (com.gemserk.commons.gdx.games.Spatial)2 Container (com.gemserk.componentsengine.utils.Container)2 ScriptComponent (com.gemserk.commons.artemis.components.ScriptComponent)1 Script (com.gemserk.commons.artemis.scripts.Script)1 ScriptJavaImpl (com.gemserk.commons.artemis.scripts.ScriptJavaImpl)1