public class Environment extends java.lang.Object implements IEnvironment
| Constructor and Description |
|---|
Environment(IMap map) |
Environment(java.lang.String mapPath) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(IEntity entity)
Adds the specified entity to the environment container.
|
void |
add(IRenderable renderable,
RenderType renderType) |
void |
addEntityListener(EnvironmentEntityListener listener) |
void |
addListener(EnvironmentListener listener) |
void |
addRenderListener(RenderType renderType,
EnvironmentRenderListener listener) |
java.util.Collection<IEntity> |
build(Blueprint blueprint,
double x,
double y) |
java.util.Collection<IEntity> |
build(Blueprint blueprint,
java.awt.geom.Point2D location) |
void |
clear() |
java.util.List<ICombatEntity> |
findCombatEntities(java.awt.Shape shape) |
java.util.List<ICombatEntity> |
findCombatEntities(java.awt.Shape shape,
java.util.function.Predicate<ICombatEntity> condition)
Searches for all combat entities whose hitBox intersect the specified
shape.
|
java.util.List<IEntity> |
findEntities(java.awt.Shape shape) |
<T extends IEntity> |
get(java.lang.Class<T> clss,
int mapId) |
<T extends IEntity> |
get(java.lang.Class<T> clss,
java.lang.String name) |
java.util.List<IEntity> |
get(int... mapIds) |
IEntity |
get(int mapId) |
IEntity |
get(java.lang.String name) |
AmbientLight |
getAmbientLight() |
MapArea |
getArea(int mapId) |
MapArea |
getArea(java.lang.String name) |
java.util.Collection<MapArea> |
getAreas() |
<T extends IEntity> |
getByTag(java.lang.Class<T> clss,
java.lang.String... tags) |
java.util.Collection<IEntity> |
getByTag(java.lang.String... tags) |
<T extends IEntity> |
getByType(java.lang.Class<T> cls) |
java.awt.geom.Point2D |
getCenter() |
CollisionBox |
getCollisionBox(int mapId) |
CollisionBox |
getCollisionBox(java.lang.String name) |
java.util.Collection<CollisionBox> |
getCollisionBoxes() |
java.util.Collection<ICombatEntity> |
getCombatEntities() |
ICombatEntity |
getCombatEntity(int mapId) |
ICombatEntity |
getCombatEntity(java.lang.String name) |
Creature |
getCreature(int mapId) |
Creature |
getCreature(java.lang.String name) |
java.util.Collection<Creature> |
getCreatures() |
Emitter |
getEmitter(int mapId) |
Emitter |
getEmitter(java.lang.String name) |
java.util.Collection<Emitter> |
getEmitters() |
java.util.Collection<IEntity> |
getEntities() |
java.util.Collection<IEntity> |
getEntities(RenderType renderType) |
java.util.Map<java.lang.String,java.util.List<IEntity>> |
getEntitiesByTag() |
LightSource |
getLightSource(int mapId) |
LightSource |
getLightSource(java.lang.String name) |
java.util.Collection<LightSource> |
getLightSources() |
int |
getLocalMapId()
Negative map ids are only used locally.
|
IMap |
getMap() |
java.util.Collection<IMobileEntity> |
getMobileEntities() |
IMobileEntity |
getMobileEntity(int mapId) |
IMobileEntity |
getMobileEntity(java.lang.String name) |
int |
getNextMapId()
Gets the next unique global map id.
|
Prop |
getProp(int mapId) |
Prop |
getProp(java.lang.String name) |
java.util.Collection<Prop> |
getProps() |
java.util.Collection<IRenderable> |
getRenderables(RenderType renderType) |
Spawnpoint |
getSpawnpoint(int mapId) |
Spawnpoint |
getSpawnpoint(java.lang.String name) |
java.util.Collection<Spawnpoint> |
getSpawnPoints() |
StaticShadow |
getStaticShadow(int mapId) |
StaticShadow |
getStaticShadow(java.lang.String name) |
StaticShadowLayer |
getStaticShadowLayer() |
java.util.Collection<StaticShadow> |
getStaticShadows() |
Trigger |
getTrigger(int mapId) |
Trigger |
getTrigger(java.lang.String name) |
java.util.Collection<Trigger> |
getTriggers() |
java.util.List<java.lang.String> |
getUsedTags() |
void |
init() |
boolean |
isLoaded() |
void |
load() |
java.util.Collection<IEntity> |
load(IMapObject mapObject) |
void |
loadFromMap(int mapId) |
static <T extends IEntity> |
registerCustomEntityType(java.lang.Class<T> entityType)
Registers a custom
IEntity implementation to support being loaded from an IMap instance. |
static <T extends IEntity> |
registerCustomEntityType(java.lang.String mapObjectType,
java.lang.Class<T> entityType)
Registers a custom
IEntity implementation to support being loaded from an IMap instance. |
static void |
registerMapObjectLoader(IMapObjectLoader mapObjectLoader)
Registers a custom loader instance that is responsible for loading and initializing entities of the defined
MapObjectType.
|
void |
reloadFromMap(int mapId) |
<T extends IEntity> |
remove(java.util.Collection<T> entities) |
void |
remove(IEntity entity) |
void |
remove(int mapId) |
void |
remove(java.lang.String name) |
void |
removeEntityListener(EnvironmentEntityListener listener) |
void |
removeListener(EnvironmentListener listener) |
void |
removeRenderable(IRenderable renderable) |
void |
removeRenderListener(EnvironmentRenderListener listener) |
void |
render(java.awt.Graphics2D g) |
void |
unload() |
public Environment(IMap map)
public Environment(java.lang.String mapPath)
public void addRenderListener(RenderType renderType, EnvironmentRenderListener listener)
addRenderListener in interface IEnvironmentpublic void removeRenderListener(EnvironmentRenderListener listener)
removeRenderListener in interface IEnvironmentpublic void addListener(EnvironmentListener listener)
addListener in interface IEnvironmentpublic void removeListener(EnvironmentListener listener)
removeListener in interface IEnvironmentpublic void addEntityListener(EnvironmentEntityListener listener)
addEntityListener in interface IEnvironmentpublic void removeEntityListener(EnvironmentEntityListener listener)
removeEntityListener in interface IEnvironmentpublic void add(IEntity entity)
IEnvironmentadd in interface IEnvironmententity - The entity to add to the environment.public void add(IRenderable renderable, RenderType renderType)
add in interface IEnvironmentpublic java.util.Collection<IEntity> build(Blueprint blueprint, double x, double y)
build in interface IEnvironmentpublic java.util.Collection<IEntity> build(Blueprint blueprint, java.awt.geom.Point2D location)
build in interface IEnvironmentpublic void clear()
clear in interface IEnvironmentpublic java.util.List<ICombatEntity> findCombatEntities(java.awt.Shape shape)
findCombatEntities in interface IEnvironmentpublic java.util.List<ICombatEntity> findCombatEntities(java.awt.Shape shape, java.util.function.Predicate<ICombatEntity> condition)
IEnvironmentfindCombatEntities in interface IEnvironmentshape - The shape to check intersection for.condition - An additional condition that allows to specify a condition which
determines if a ICombatEntity should be considered.Shape.public java.util.List<IEntity> findEntities(java.awt.Shape shape)
findEntities in interface IEnvironmentpublic IEntity get(int mapId)
get in interface IEnvironmentpublic java.util.List<IEntity> get(int... mapIds)
get in interface IEnvironmentpublic <T extends IEntity> T get(java.lang.Class<T> clss, int mapId)
get in interface IEnvironmentpublic IEntity get(java.lang.String name)
get in interface IEnvironmentpublic <T extends IEntity> T get(java.lang.Class<T> clss, java.lang.String name)
get in interface IEnvironmentpublic java.util.Collection<IEntity> getByTag(java.lang.String... tags)
getByTag in interface IEnvironmentpublic <T extends IEntity> java.util.Collection<T> getByTag(java.lang.Class<T> clss, java.lang.String... tags)
getByTag in interface IEnvironmentpublic AmbientLight getAmbientLight()
getAmbientLight in interface IEnvironmentpublic java.util.Collection<MapArea> getAreas()
getAreas in interface IEnvironmentpublic MapArea getArea(int mapId)
getArea in interface IEnvironmentpublic MapArea getArea(java.lang.String name)
getArea in interface IEnvironmentpublic java.awt.geom.Point2D getCenter()
getCenter in interface IEnvironmentpublic java.util.Collection<Emitter> getEmitters()
getEmitters in interface IEnvironmentpublic Emitter getEmitter(int mapId)
getEmitter in interface IEnvironmentpublic Emitter getEmitter(java.lang.String name)
getEmitter in interface IEnvironmentpublic java.util.Collection<CollisionBox> getCollisionBoxes()
getCollisionBoxes in interface IEnvironmentpublic CollisionBox getCollisionBox(int mapId)
getCollisionBox in interface IEnvironmentpublic CollisionBox getCollisionBox(java.lang.String name)
getCollisionBox in interface IEnvironmentpublic java.util.Collection<ICombatEntity> getCombatEntities()
getCombatEntities in interface IEnvironmentpublic ICombatEntity getCombatEntity(int mapId)
getCombatEntity in interface IEnvironmentpublic ICombatEntity getCombatEntity(java.lang.String name)
getCombatEntity in interface IEnvironmentpublic java.util.Collection<IEntity> getEntities()
getEntities in interface IEnvironmentpublic java.util.Collection<IEntity> getEntities(RenderType renderType)
getEntities in interface IEnvironmentpublic java.util.Map<java.lang.String,java.util.List<IEntity>> getEntitiesByTag()
getEntitiesByTag in interface IEnvironmentpublic <T extends IEntity> java.util.Collection<T> getByType(java.lang.Class<T> cls)
getByType in interface IEnvironmentpublic java.util.Collection<LightSource> getLightSources()
getLightSources in interface IEnvironmentpublic LightSource getLightSource(int mapId)
getLightSource in interface IEnvironmentpublic LightSource getLightSource(java.lang.String name)
getLightSource in interface IEnvironmentpublic int getLocalMapId()
getLocalMapId in interface IEnvironmentpublic IMap getMap()
getMap in interface IEnvironmentpublic java.util.Collection<IMobileEntity> getMobileEntities()
getMobileEntities in interface IEnvironmentpublic IMobileEntity getMobileEntity(int mapId)
getMobileEntity in interface IEnvironmentpublic IMobileEntity getMobileEntity(java.lang.String name)
getMobileEntity in interface IEnvironmentpublic int getNextMapId()
IEnvironmentgetNextMapId in interface IEnvironmentpublic java.util.Collection<IRenderable> getRenderables(RenderType renderType)
getRenderables in interface IEnvironmentpublic java.util.Collection<Prop> getProps()
getProps in interface IEnvironmentpublic Prop getProp(int mapId)
getProp in interface IEnvironmentpublic Prop getProp(java.lang.String name)
getProp in interface IEnvironmentpublic Creature getCreature(int mapId)
getCreature in interface IEnvironmentpublic Creature getCreature(java.lang.String name)
getCreature in interface IEnvironmentpublic java.util.Collection<Creature> getCreatures()
getCreatures in interface IEnvironmentpublic Spawnpoint getSpawnpoint(int mapId)
getSpawnpoint in interface IEnvironmentpublic Spawnpoint getSpawnpoint(java.lang.String name)
getSpawnpoint in interface IEnvironmentpublic java.util.Collection<Spawnpoint> getSpawnPoints()
getSpawnPoints in interface IEnvironmentpublic java.util.Collection<StaticShadow> getStaticShadows()
getStaticShadows in interface IEnvironmentpublic StaticShadow getStaticShadow(int mapId)
getStaticShadow in interface IEnvironmentpublic StaticShadow getStaticShadow(java.lang.String name)
getStaticShadow in interface IEnvironmentpublic StaticShadowLayer getStaticShadowLayer()
getStaticShadowLayer in interface IEnvironmentpublic Trigger getTrigger(int mapId)
getTrigger in interface IEnvironmentpublic Trigger getTrigger(java.lang.String name)
getTrigger in interface IEnvironmentpublic java.util.Collection<Trigger> getTriggers()
getTriggers in interface IEnvironmentpublic java.util.List<java.lang.String> getUsedTags()
getUsedTags in interface IEnvironmentpublic final void init()
init in interface IInitializablepublic boolean isLoaded()
isLoaded in interface IEnvironmentpublic void load()
load in interface IEnvironmentpublic void loadFromMap(int mapId)
loadFromMap in interface IEnvironmentpublic static void registerMapObjectLoader(IMapObjectLoader mapObjectLoader)
mapObjectLoader - The MapObjectLoader instance to be registered.IMapObjectLoader.getMapObjectType()public static <T extends IEntity> void registerCustomEntityType(java.lang.String mapObjectType, java.lang.Class<T> entityType)
IEntity implementation to support being loaded from an 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 is an overload of the registerCustomEntityType(Class) method that allows to explicitly specify the MapObjectType
without
having to provide an EntityInfo annotation containing this information.T - The type of the custom entity.mapObjectType - The custom mapobjectType that is used by IMapObjects to determine the target entity implementation.entityType - The class type of the custom entity implementation.IMapObject.getType(),
EntityInfo.customMapObjectType()public static <T extends IEntity> void registerCustomEntityType(java.lang.Class<T> entityType)
IEntity implementation to support being loaded from an 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 EntityInfo.customMapObjectType() to determine for which type the specified class should be
used.T - The type of the custom entity.entityType - The class type of the custom entity implementation.registerCustomEntityType(String, Class),
IMapObject.getType(),
EntityInfo.customMapObjectType()public void reloadFromMap(int mapId)
reloadFromMap in interface IEnvironmentpublic void remove(IEntity entity)
remove in interface IEnvironmentpublic void remove(int mapId)
remove in interface IEnvironmentpublic void remove(java.lang.String name)
remove in interface IEnvironmentpublic <T extends IEntity> void remove(java.util.Collection<T> entities)
remove in interface IEnvironmentpublic void removeRenderable(IRenderable renderable)
removeRenderable in interface IEnvironmentpublic void render(java.awt.Graphics2D g)
render in interface IRenderablepublic void unload()
unload in interface IEnvironmentpublic java.util.Collection<IEntity> load(IMapObject mapObject)
load in interface IEnvironment