use of de.gurkenlabs.litiengine.entities.EntityInfo in project litiengine by gurkenlabs.
the class Environment method registerCustomEntityType.
/**
* Registers a custom {@code IEntity} implementation to support being loaded from an {@code IMap} instance. Note that
* the specified class needs to be accessible in a static manner. Inner classes that aren't declared statically are not
* supported.
*
* This implementation uses the provided {@code EntityInfo.customMapObjectType()} to determine for which type the
* specified class should be used.
*
* @param entityType
* The class type of the custom entity implementation.
*
* @see Environment#registerCustomEntityType(String, Class)
* @see IMapObject#getType()
* @see EntityInfo#customMapObjectType()
*/
public static void registerCustomEntityType(Class<? extends IEntity> entityType) {
EntityInfo info = entityType.getAnnotation(EntityInfo.class);
if (info == null || info.customMapObjectType().isEmpty()) {
log.log(Level.WARNING, "Cannot register the custom entity type [{0}]: EntityInfo.customMapObjectType must be specified.\nAdd an EntityInfo annotation to the class and provide the required information or use the registerCustomEntityType overload and provide the type explicitly.", entityType.getName());
return;
}
registerCustomEntityType(info.customMapObjectType(), entityType);
}
Aggregations