use of com.b3dgs.lionengine.game.Feature in project lionengine by b3dgs.
the class Features method add.
/**
* Add a feature. Stores its interface, and all sub interfaces which describe also a {@link Feature} annotated by
* {@link FeatureInterface}.
*
* @param feature The feature to add.
* @param overwrite <code>true</code> to overwrite existing feature, <code>false</code> else.
* @throws LionEngineException If feature is not annotated by {@link FeatureInterface} or already referenced.
*/
public void add(Feature feature, boolean overwrite) {
if (!isAnnotated(feature)) {
throw new LionEngineException(ERROR_FEATURE_NOT_ANNOTATED + feature.getClass());
}
final Feature old;
// CHECKSTYLE IGNORE LINE: InnerAssignment
if ((old = typeToFeature.put(feature.getClass(), feature)) != null) {
throw new LionEngineException(ERROR_FEATURE_EXISTS + feature.getClass() + WITH + old.getClass());
}
checkTypeDepth(feature, feature.getClass(), overwrite);
features.add(feature);
}
use of com.b3dgs.lionengine.game.Feature in project lionengine by b3dgs.
the class HandlablesImpl method add.
/**
* Add a featurable.
*
* @param featurable The featurable to add.
*/
public void add(Featurable featurable) {
featurables.put(featurable.getFeature(Identifiable.class).getId(), featurable);
for (final Class<?> type : featurable.getClass().getInterfaces()) {
addType(type, featurable);
}
for (final Class<? extends Feature> feature : featurable.getFeaturesType()) {
final Feature object = featurable.getFeature(feature);
addType(feature, object);
for (final Class<?> other : UtilReflection.getInterfaces(feature, Feature.class)) {
addType(other, object);
}
}
addType(featurable.getClass(), featurable);
addSuperClass(featurable, featurable.getClass());
}
use of com.b3dgs.lionengine.game.Feature in project lionengine by b3dgs.
the class Factory method addFeatures.
/**
* Add all features declared in configuration.
*
* @param featurable The featurable to handle.
* @param services The services reference.
* @param setup The setup reference.
*/
private void addFeatures(Featurable featurable, Services services, Setup setup) {
final List<Feature> rawFeatures = FeaturableConfig.getFeatures(classLoader, services, setup);
final int length = rawFeatures.size();
for (int i = 0; i < length; i++) {
final Feature feature = rawFeatures.get(i);
featurable.addFeature(feature);
}
featurable.addAfter(services, setup);
}
use of com.b3dgs.lionengine.game.Feature in project lionengine by b3dgs.
the class Routines method prepare.
/*
* Feature
*/
@Override
public void prepare(FeatureProvider provider) {
super.prepare(provider);
for (final Feature feature : provider.getFeatures()) {
if (feature instanceof Routine) {
routines.add((Routine) feature);
}
}
routinesCount = routines.size();
}
Aggregations