Search in sources :

Example 11 with ParametersWrapper

use of com.gemserk.componentsengine.utils.ParametersWrapper 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)

Example 12 with ParametersWrapper

use of com.gemserk.componentsengine.utils.ParametersWrapper in project commons-gdx by gemserk.

the class ParametersDelegateImplTest method shouldReturnParameterFromItself.

@Test
public void shouldReturnParameterFromItself() {
    ParametersWrapper parameters = new ParametersWrapper();
    ParametersDelegateImpl parametersDelegate = new ParametersDelegateImpl();
    parametersDelegate.setDelegate(parameters);
    parametersDelegate.put("a", "b");
    assertEquals("b", parametersDelegate.get("a"));
    assertNull(parameters.get("a"));
}
Also used : ParametersWrapper(com.gemserk.componentsengine.utils.ParametersWrapper) Test(org.junit.Test)

Example 13 with ParametersWrapper

use of com.gemserk.componentsengine.utils.ParametersWrapper in project commons-gdx by gemserk.

the class ParametersDelegateImplTest method shouldReturnParameterFromItself2.

@Test
public void shouldReturnParameterFromItself2() {
    ParametersWrapper parameters = new ParametersWrapper();
    ParametersDelegateImpl parametersDelegate = new ParametersDelegateImpl();
    parametersDelegate.setDelegate(parameters);
    parametersDelegate.put("a", "b");
    assertEquals("b", parametersDelegate.get("a", "c"));
    assertNull(parameters.get("a"));
}
Also used : ParametersWrapper(com.gemserk.componentsengine.utils.ParametersWrapper) Test(org.junit.Test)

Example 14 with ParametersWrapper

use of com.gemserk.componentsengine.utils.ParametersWrapper in project commons-gdx by gemserk.

the class ParametersDelegateImplTest method shouldReturnParameterFromDelegate.

@Test
public void shouldReturnParameterFromDelegate() {
    ParametersWrapper parameters = new ParametersWrapper();
    parameters.put("a", "b");
    ParametersDelegateImpl parametersDelegate = new ParametersDelegateImpl();
    parametersDelegate.setDelegate(parameters);
    assertEquals("b", parametersDelegate.get("a"));
}
Also used : ParametersWrapper(com.gemserk.componentsengine.utils.ParametersWrapper) Test(org.junit.Test)

Example 15 with ParametersWrapper

use of com.gemserk.componentsengine.utils.ParametersWrapper in project commons-gdx by gemserk.

the class ParametersDelegateImplTest method shouldReturnDefaultValue.

@Test
public void shouldReturnDefaultValue() {
    ParametersWrapper parameters = new ParametersWrapper();
    ParametersDelegateImpl parametersDelegate = new ParametersDelegateImpl();
    parametersDelegate.setDelegate(parameters);
    assertEquals("c", parametersDelegate.get("a", "c"));
}
Also used : ParametersWrapper(com.gemserk.componentsengine.utils.ParametersWrapper) Test(org.junit.Test)

Aggregations

ParametersWrapper (com.gemserk.componentsengine.utils.ParametersWrapper)15 Test (org.junit.Test)15 Parameters (com.gemserk.componentsengine.utils.Parameters)5 Entity (com.artemis.Entity)3 World (com.artemis.World)3 EntityFactory (com.gemserk.commons.artemis.templates.EntityFactory)3 EntityFactoryImpl (com.gemserk.commons.artemis.templates.EntityFactoryImpl)3 EntityTemplate (com.gemserk.commons.artemis.templates.EntityTemplate)3 ScriptComponent (com.gemserk.commons.artemis.components.ScriptComponent)1 SpatialComponent (com.gemserk.commons.artemis.components.SpatialComponent)1 Script (com.gemserk.commons.artemis.scripts.Script)1 ScriptJavaImpl (com.gemserk.commons.artemis.scripts.ScriptJavaImpl)1 HashMap (java.util.HashMap)1