use of com.b3dgs.lionengine.Animation in project lionengine by b3dgs.
the class StateHandler method create.
/**
* Create state from its type.
*
* @param state The state to create (must not be <code>null</code>).
* @return The created state.
* @throws LionEngineException If unable to create state.
*/
@SuppressWarnings("unchecked")
private State create(Class<? extends State> state) {
Check.notNull(state);
try {
if (setup.hasNode(AnimationConfig.NODE_ANIMATIONS)) {
final AnimationConfig configAnimations = AnimationConfig.imports(setup);
final String name = converter.apply(state);
final Animation animation = configAnimations.getAnimation(name);
final Class<? extends Feature> feature;
feature = (Class<? extends Feature>) UtilReflection.getCompatibleConstructor(state, FeatureProvider.class, Animation.class).getParameters()[PARAM_FEATURE_INDEX].getType();
return UtilReflection.create(state, UtilReflection.getParamTypes(feature, animation), getFeature(feature), animation);
}
return UtilReflection.createReduce(state);
} catch (final LionEngineException exception) {
throw new LionEngineException(exception, setup.getMedia());
} catch (final NoSuchMethodException exception) {
throw new LionEngineException(exception);
}
}
Aggregations