public final class Environment extends java.lang.Object implements IRenderable
Constructor and Description |
---|
Environment(IMap map)
Instantiates a new
Environment for the specified map. |
Environment(java.lang.String mapPath)
Instantiates a new
Environment for the specified map. |
Modifier and Type | Method and Description |
---|---|
void |
add(IEntity entity)
Adds the specified entity to the environment container.
|
void |
add(IRenderable renderable,
RenderType renderType)
Adds the specified instance to be rendered with the defined
RenderType whenever the environment's render pipeline is executed. |
void |
addAll(IEntity... entities)
Adds all the specified entities to the environment container.
|
<T extends IEntity> |
addAll(java.lang.Iterable<T> entities)
Adds all the specified entities to the environment container.
|
void |
addEntityListener(EnvironmentEntityListener listener)
Adds the specified environment entity listener to receive events about entities on this environment.
|
void |
addListener(EnvironmentListener listener)
Adds the specified environment listener to receive events about the basic environment life-cycle.
|
java.util.Collection<IEntity> |
build(Blueprint blueprint,
double x,
double y)
Adds entities by the specified blueprint to this environment at the defined location.
|
java.util.Collection<IEntity> |
build(Blueprint blueprint,
java.awt.geom.Point2D location)
Adds entities by the specified blueprint to this environment at the defined location.
|
void |
clear()
Clears all loaded entities and renderable instances from this environment.
|
boolean |
contains(IEntity entity)
Determines whether the environment contains the specified entity.
|
boolean |
contains(int mapId)
Determines whether the environment contains any entity with the specified map ID.
|
java.util.Collection<ICombatEntity> |
findCombatEntities(java.awt.Shape shape)
Attempts to find all combat entities whose hitBox intersects with the specified shape.
|
java.util.Collection<ICombatEntity> |
findCombatEntities(java.awt.Shape shape,
java.util.function.Predicate<ICombatEntity> condition)
Attempts to find all combat entities whose hitBox intersects with the specified shape.
|
java.util.Collection<IEntity> |
findEntities(java.awt.Shape shape)
Attempts to find all entities whose bounding box intersects with the specified shape.
|
<T extends IEntity> |
get(java.lang.Class<T> clss,
int mapId)
Gets the strongly typed entity with the specified map ID from this environment.
|
<T extends IEntity> |
get(java.lang.Class<T> clss,
java.lang.String name)
Gets the strongly typed entity with the specified name from this environment.
|
java.util.List<IEntity> |
get(int... mapIds)
Gets all entities with the specified map IDs from this environment.
|
IEntity |
get(int mapId)
Gets the entity with the specified map ID from this environment.
|
IEntity |
get(java.lang.String name)
Gets the entity with the specified name from this environment.
|
java.util.Collection<java.lang.Integer> |
getAllMapIDs()
Gets an immutable collection with all assigned map IDs on this environment.
|
AmbientLight |
getAmbientLight()
Gets the ambient light instance of this environment.
|
MapArea |
getArea(int mapId)
Gets the
MapArea with the specified map ID from this environment. |
MapArea |
getArea(java.lang.String name)
Gets the
MapArea with the specified name from this environment. |
java.util.Collection<MapArea> |
getAreas()
Gets an immutable collection containing all
MapArea entities on this environment. |
<T extends IEntity> |
getByTag(java.lang.Class<? extends T> clss,
java.lang.String... tags)
Gets a distinct and strongly named collection of all entities with any of the specified tags.
|
java.util.Collection<IEntity> |
getByTag(java.lang.String... tags)
Gets a distinct collection of all entities with any of the specified tags.
|
java.awt.geom.Point2D |
getCenter()
Gets the center location of the boundaries defined by the map of this environment.
|
CollisionBox |
getCollisionBox(int mapId)
Gets the
CollisionBox with the specified map ID from this environment. |
CollisionBox |
getCollisionBox(java.lang.String name)
Gets the
CollisionBox with the specified name from this environment. |
java.util.Collection<CollisionBox> |
getCollisionBoxes()
Gets an immutable collection containing all
CollisionBox entities on this environment. |
java.util.Collection<ICombatEntity> |
getCombatEntities()
Gets an immutable collection containing all
ICombatEntity entities on this environment. |
ICombatEntity |
getCombatEntity(int mapId)
Gets the
ICombatEntity with the specified map ID from this environment. |
ICombatEntity |
getCombatEntity(java.lang.String name)
Gets the
ICombatEntity with the specified name from this environment. |
Creature |
getCreature(int mapId)
Gets the
Creature with the specified map ID from this environment. |
Creature |
getCreature(java.lang.String name)
Gets the
Creature with the specified name from this environment. |
java.util.Collection<Creature> |
getCreatures()
Gets an immutable collection containing all
Creature entities on this environment. |
Emitter |
getEmitter(int mapId)
Gets the
Emitter with the specified map ID from this environment. |
Emitter |
getEmitter(java.lang.String name)
Gets the
Emitter with the specified name from this environment. |
java.util.Collection<Emitter> |
getEmitters()
Gets an immutable collection containing all
Emitter entities on this environment. |
java.util.Collection<IEntity> |
getEntities()
Gets an immutable collection containing all entities on this environment.
|
<T> java.util.Collection<T> |
getEntities(java.lang.Class<? extends T> cls)
Gets all entities of the specified type on this environment.
|
<T> java.util.Collection<T> |
getEntities(java.lang.Class<? extends T> cls,
java.util.function.Predicate<T> pred)
Gets all entities of the specified type on this environment.
|
java.util.Collection<IEntity> |
getEntities(IMapObjectLayer layer)
Gets the entities that are bound to the specified layer.
|
java.util.Collection<IEntity> |
getEntities(RenderType renderType)
Gets the entities with the specified render type that are not bound to layers.
|
java.util.Collection<IEntity> |
getEntitiesByLayer(int layerId)
Gets the entities that are bound to layer with the specified layer ID.
|
java.util.Collection<IEntity> |
getEntitiesByLayer(java.lang.String name)
Gets the entities that are bound to layer with the specified name.
|
java.util.Map<java.lang.String,java.util.Collection<IEntity>> |
getEntitiesByTag()
DON'T USE THIS! THIS IS FOR ENGINE INTERNAL PURPOSES ONLY!.
|
int |
getGravity()
Gets the gravity defined for this environment.
|
LightSource |
getLightSource(int mapId)
Gets the
LightSource with the specified map ID from this environment. |
LightSource |
getLightSource(java.lang.String name)
Gets the
LightSource with the specified name from this environment. |
java.util.Collection<LightSource> |
getLightSources()
Gets an immutable collection containing all
LightSource entities on this environment. |
static int |
getLocalMapId()
Gets the next unique local map id.
|
IMap |
getMap()
Gets the map on which this environment is based upon.
|
java.util.Collection<IMobileEntity> |
getMobileEntities()
Gets an immutable collection containing all
IMobileEntity instances on this environment. |
IMobileEntity |
getMobileEntity(int mapId)
Gets the
IMobileEntity with the specified map ID from this environment. |
IMobileEntity |
getMobileEntity(java.lang.String name)
Gets the
IMobileEntity with the specified name from this environment. |
int |
getNextMapId()
Gets the next unique global map id.
|
Prop |
getProp(int mapId)
Gets the
Prop with the specified map ID from this environment. |
Prop |
getProp(java.lang.String name)
Gets the
Prop with the specified name from this environment. |
java.util.Collection<Prop> |
getProps()
Gets an immutable collection containing all
Prop entities on this environment. |
java.util.Collection<IRenderable> |
getRenderables(RenderType renderType)
Gets an immutable collection containing all
IRenderable instances for the specified render type on this environment. |
Spawnpoint |
getSpawnpoint(int mapId)
Gets the
Spawnpoint with the specified map ID from this environment. |
Spawnpoint |
getSpawnpoint(java.lang.String name)
Gets the
Spawnpoint with the specified name from this environment. |
java.util.Collection<Spawnpoint> |
getSpawnPoints()
Gets an immutable collection containing all
Spawnpoint entities on this environment. |
StaticShadow |
getStaticShadow(int mapId)
Gets the
StaticShadow with the specified map ID from this environment. |
StaticShadow |
getStaticShadow(java.lang.String name)
Gets the
StaticShadow with the specified name from this environment. |
StaticShadowLayer |
getStaticShadowLayer()
Gets the static shadow lighting layer of this environment.
|
java.util.Collection<StaticShadow> |
getStaticShadows()
Gets an immutable collection containing all
StaticShadow entities on this environment. |
Trigger |
getTrigger(int mapId)
Gets the
Trigger with the specified map ID from this environment. |
Trigger |
getTrigger(java.lang.String name)
Gets the
Trigger with the specified name from this environment. |
java.util.Collection<Trigger> |
getTriggers()
Gets an immutable collection containing all
Trigger entities on this environment. |
java.util.Collection<java.lang.String> |
getUsedTags()
Gets all tags that are assigned to entities on this environment.
|
void |
init()
Initializes all entities and lighting layers of this environment.
|
Trigger |
interact(ICollisionEntity source)
Attempts to interact with triggers on this environment.
|
Trigger |
interact(ICollisionEntity source,
java.util.function.Predicate<Trigger> condition)
Attempts to interact with triggers on this environment.
|
boolean |
isLoaded()
Determines whether this environment has been loaded.
|
void |
load()
Initializes and loads this environment and all its entities.
|
java.util.Collection<IEntity> |
load(IMapObject mapObject)
Loads all entities for the specified map object.
|
boolean |
loadFromMap(int mapId)
Loads the entities from the map object with the specified map ID from the map of this environment.
|
void |
onRendered(RenderType renderType,
EnvironmentRenderedListener listener)
Adds the specified environment rendered listener to receive events when this instance renders the specified renderType.
|
static void |
registerCustomEntityType(java.lang.Class<? extends IEntity> entityType)
Registers a custom
IEntity implementation to support being loaded from an IMap instance. |
static void |
registerCustomEntityType(java.lang.String mapObjectType,
java.lang.Class<? extends IEntity> 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)
Reloads the map object with the specified map ID from the map by first removing any previously loaded entity
and then loading it freshly from its map definition.
|
void |
remove(IEntity entity)
Removes the specified entity from this environment and unloads is.
|
void |
remove(int mapId)
Removes the entity with the specified map ID from this environment and unloads is.
|
void |
remove(java.lang.String name)
Removes the entity with the specified name from this environment and unloads is.
|
void |
removeAll(IEntity... entities)
Removes all specified entities from this environment.
|
<T extends IEntity> |
removeAll(java.lang.Iterable<T> entities)
Removes all specified entities from this environment.
|
void |
removeEntityListener(EnvironmentEntityListener listener)
Removes the environment entity listener listener.
|
void |
removeListener(EnvironmentListener listener)
Removes the environment listener.
|
void |
removeRenderable(IRenderable renderable) |
void |
removeRenderListener(EnvironmentRenderedListener listener)
Removes the specified environment rendered listener.
|
void |
render(java.awt.Graphics2D g)
Renders the visual contents of this instance onto the provided graphics context.
|
void |
setGravity(int gravity)
Sets the gravity for this particular environment.
|
void |
unload()
Unloads all entities of this environment.
|
void |
updateLighting()
Forces an update on the lighting layers for the entire map.
|
void |
updateLighting(java.awt.geom.Rectangle2D section)
Forces an update on the lighting layers for the specified section on the map.
|
public Environment(IMap map)
Environment
for the specified map.map
- The map that defines this environment.public Environment(java.lang.String mapPath)
Environment
for the specified map.mapPath
- The path to the map resource that defines this environment.public static void registerMapObjectLoader(IMapObjectLoader mapObjectLoader)
mapObjectLoader
- The MapObjectLoader instance to be registered.IMapObjectLoader.getMapObjectType()
public static void registerCustomEntityType(java.lang.String mapObjectType, java.lang.Class<? extends IEntity> 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.
Custom entity types need to provide at least one constructor that matches the following criteria:
Environment, IMapObject
IMapObject, Environment
IMapObject
Environment
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 void registerCustomEntityType(java.lang.Class<? extends IEntity> 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.entityType
- The class type of the custom entity implementation.registerCustomEntityType(String, Class)
,
IMapObject.getType()
,
EntityInfo.customMapObjectType()
public void onRendered(RenderType renderType, EnvironmentRenderedListener listener)
renderType
- The type that defines to which render process this listener should be attached.listener
- The listener to add.public void removeRenderListener(EnvironmentRenderedListener listener)
listener
- The listener to remove.public void addListener(EnvironmentListener listener)
listener
- The listener to add.public void removeListener(EnvironmentListener listener)
listener
- The listener to remove.public void addEntityListener(EnvironmentEntityListener listener)
listener
- The listener to add.public void removeEntityListener(EnvironmentEntityListener listener)
listener
- The listener to remove.public void add(IEntity entity)
entity
- The entity to add to the environment.isLoaded()
,
IEntity.loaded(Environment)
,
EnvironmentEntityListener.entityAdded(IEntity)
public <T extends IEntity> void addAll(java.lang.Iterable<T> entities)
T
- The type of the entity.entities
- The entities to be added to the environment.add(IEntity)
,
addAll(IEntity...)
,
remove(IEntity)
,
removeAll(Iterable)
public void addAll(IEntity... entities)
entities
- The entities to be added to the environment.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public void updateLighting()
public void updateLighting(java.awt.geom.Rectangle2D section)
section
- The section for which to update the lighting layers.getStaticShadowLayer()
,
getAmbientLight()
,
ColorLayer.updateSection(Rectangle2D)
public void add(IRenderable renderable, RenderType renderType)
RenderType
whenever the environment's render pipeline is executed.
This method can be used for any custom rendering that is not related to an entity, a GUI component or the map.
Note that you don't need to explicitly add an Entity
if it implements IRenderable
. The render engine will inherently
call an entity's render method.
renderable
- The instance that should be rendered.renderType
- The render type that determines how the instance is processed by the environment's render pipeline.render(Graphics2D)
,
RenderEngine.renderEntity(Graphics2D, IEntity)
public java.util.Collection<IEntity> build(Blueprint blueprint, double x, double y)
blueprint
- The blueprint, defining the map object to load the entities from.x
- The x-coordinate of the location at which to spawn the entities.y
- The y-coordinate of the location at which to spawn the entities.public java.util.Collection<IEntity> build(Blueprint blueprint, java.awt.geom.Point2D location)
blueprint
- The blueprint, defining the map object to load the entities from.location
- The location at which to spawn the entities.public void clear()
public boolean contains(IEntity entity)
entity
- The entity to check for.public boolean contains(int mapId)
mapId
- The map ID of the entity to check for.public java.util.Collection<ICombatEntity> findCombatEntities(java.awt.Shape shape)
shape
- The shape to check intersection for.Shape
.public java.util.Collection<ICombatEntity> findCombatEntities(java.awt.Shape shape, java.util.function.Predicate<ICombatEntity> condition)
shape
- 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.Collection<IEntity> findEntities(java.awt.Shape shape)
shape
- The shape to check intersection for.Shape
.public IEntity get(int mapId)
mapId
- The map ID of the entity.public java.util.List<IEntity> get(int... mapIds)
mapIds
- The map IDs to search for.List
of entities found, in the order given by the parameters.public <T extends IEntity> T get(java.lang.Class<T> clss, int mapId)
T
- The type of the entity.clss
- The class instance defining the type of the entity.mapId
- The map ID of the entity.public IEntity get(java.lang.String name)
name
- The name of the entity.public <T extends IEntity> T get(java.lang.Class<T> clss, java.lang.String name)
T
- The type of the entity.clss
- The class instance defining the type of the entity.name
- The name of the entity.public java.util.Collection<IEntity> getByTag(java.lang.String... tags)
tags
- The tags to search for.public <T extends IEntity> java.util.Collection<T> getByTag(java.lang.Class<? extends T> clss, java.lang.String... tags)
T
- The type of the entity.clss
- The class instance defining the type of the entity.tags
- The tags to search for.public AmbientLight getAmbientLight()
getStaticShadowLayer()
public StaticShadowLayer getStaticShadowLayer()
getAmbientLight()
public java.util.Collection<java.lang.Integer> getAllMapIDs()
public java.util.Collection<MapArea> getAreas()
MapArea
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
MapArea
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public MapArea getArea(int mapId)
MapArea
with the specified map ID from this environment.mapId
- The map ID of the entity.MapArea
with the specified map ID or null if no entity is found.getArea(String)
,
getAreas()
public MapArea getArea(java.lang.String name)
MapArea
with the specified name from this environment.name
- The name of the entity.MapArea
with the specified name or null if no entity is found.getArea(int)
,
getAreas()
public java.util.Collection<Emitter> getEmitters()
Emitter
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
Emitter
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public Emitter getEmitter(int mapId)
Emitter
with the specified map ID from this environment.mapId
- The map ID of the entity.Emitter
with the specified map ID or null if no entity is found.getEmitter(String)
,
getEmitters()
public Emitter getEmitter(java.lang.String name)
Emitter
with the specified name from this environment.name
- The name of the entity.Emitter
with the specified name or null if no entity is found.getEmitter(int)
,
getEmitters()
public java.util.Collection<CollisionBox> getCollisionBoxes()
CollisionBox
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
CollisionBox
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public CollisionBox getCollisionBox(int mapId)
CollisionBox
with the specified map ID from this environment.mapId
- The map ID of the entity.CollisionBox
with the specified map ID or null if no entity is found.getCollisionBox(String)
,
getCollisionBoxes()
public CollisionBox getCollisionBox(java.lang.String name)
CollisionBox
with the specified name from this environment.name
- The name of the entity.CollisionBox
with the specified name or null if no entity is found.getCollisionBox(int)
,
getCollisionBoxes()
public java.util.Collection<ICombatEntity> getCombatEntities()
ICombatEntity
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
ICombatEntity
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public ICombatEntity getCombatEntity(int mapId)
ICombatEntity
with the specified map ID from this environment.mapId
- The map ID of the entity.ICombatEntity
with the specified map ID or null if no entity is found.getCombatEntity(String)
,
getCombatEntities()
public ICombatEntity getCombatEntity(java.lang.String name)
ICombatEntity
with the specified name from this environment.name
- The name of the entity.ICombatEntity
with the specified name or null if no entity is found.getCombatEntity(int)
,
getCombatEntities()
public java.util.Collection<IEntity> getEntities()
To add or remove entities, use the corresponding methods on this environment.
add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public <T> java.util.Collection<T> getEntities(java.lang.Class<? extends T> cls)
T
- The type of the entity.cls
- The class instance defining the type of the entity.public <T> java.util.Collection<T> getEntities(java.lang.Class<? extends T> cls, java.util.function.Predicate<T> pred)
T
- The type of the entity.cls
- The class instance defining the type of the entity.pred
- A predicate that decides whether the defined entity should be included in the result.public java.util.Collection<IEntity> getEntities(RenderType renderType)
Entities are unbound from there originating MapObjectLayer
if their RenderType
differs
from the layer's RenderType
.
renderType
- The render typeIEntity.getRenderType()
,
ILayer.getRenderType()
public java.util.Collection<IEntity> getEntities(IMapObjectLayer layer)
Entities are bound to a layer if their RenderType
matches the layer's RenderType
layer
- The layer that the entities are bound to.IEntity.getRenderType()
,
ILayer.getRenderType()
public java.util.Collection<IEntity> getEntitiesByLayer(java.lang.String name)
Entities are bound to a layer if their RenderType
matches the layer's RenderType
name
- The name of the layerIEntity.getRenderType()
,
ILayer.getRenderType()
,
ILayer.getName()
public java.util.Collection<IEntity> getEntitiesByLayer(int layerId)
Entities are bound to a layer if their RenderType
matches the layer's RenderType
layerId
- The id of the layerIEntity.getRenderType()
,
ILayer.getRenderType()
,
ILayer.getId()
public java.util.Map<java.lang.String,java.util.Collection<IEntity>> getEntitiesByTag()
public java.util.Collection<LightSource> getLightSources()
LightSource
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
LightSource
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public LightSource getLightSource(int mapId)
LightSource
with the specified map ID from this environment.mapId
- The map ID of the entity.LightSource
with the specified map ID or null if no entity is found.getLightSource(String)
,
getLightSources()
public LightSource getLightSource(java.lang.String name)
LightSource
with the specified name from this environment.name
- The name of the entity.LightSource
with the specified name or null if no entity is found.getLightSource(int)
,
getLightSources()
public static int getLocalMapId()
public IMap getMap()
public java.util.Collection<IMobileEntity> getMobileEntities()
IMobileEntity
instances on this environment.
To add or remove entities, use the corresponding methods on this environment.
IMobileEntity
instances.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public IMobileEntity getMobileEntity(int mapId)
IMobileEntity
with the specified map ID from this environment.mapId
- The map ID of the entity.IMobileEntity
with the specified map ID or null if no entity is found.getMobileEntity(String)
,
getMobileEntities()
public IMobileEntity getMobileEntity(java.lang.String name)
IMobileEntity
with the specified name from this environment.name
- The name of the entity.IMobileEntity
with the specified name or null if no entity is found.getMobileEntity(int)
,
getMobileEntities()
public int getNextMapId()
public java.util.Collection<IRenderable> getRenderables(RenderType renderType)
IRenderable
instances for the specified render type on this environment.
To add or remove instances, use the corresponding methods on this environment.
renderType
- The render type of the renderable instances.IRenderable
instances.add(IRenderable, RenderType)
,
removeRenderable(IRenderable)
public java.util.Collection<Prop> getProps()
Prop
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
Prop
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public Prop getProp(int mapId)
Prop
with the specified map ID from this environment.mapId
- The map ID of the entity.Prop
with the specified map ID or null if no entity is found.getProp(String)
,
getProps()
public Prop getProp(java.lang.String name)
Prop
with the specified name from this environment.name
- The name of the entity.Prop
with the specified name or null if no entity is found.getProp(int)
,
getProps()
public java.util.Collection<Creature> getCreatures()
Creature
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
Creature
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public Creature getCreature(int mapId)
Creature
with the specified map ID from this environment.mapId
- The map ID of the entity.Creature
with the specified map ID or null if no entity is found.getCreature(String)
,
getCreatures()
public Creature getCreature(java.lang.String name)
Creature
with the specified name from this environment.name
- The name of the entity.Creature
with the specified name or null if no entity is found.getCreature(int)
,
getCreatures()
public java.util.Collection<Spawnpoint> getSpawnPoints()
Spawnpoint
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
Spawnpoint
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public Spawnpoint getSpawnpoint(int mapId)
Spawnpoint
with the specified map ID from this environment.mapId
- The map ID of the entity.Spawnpoint
with the specified map ID or null if no entity is found.getSpawnpoint(String)
,
getSpawnPoints()
public Spawnpoint getSpawnpoint(java.lang.String name)
Spawnpoint
with the specified name from this environment.name
- The name of the entity.Spawnpoint
with the specified name or null if no entity is found.getSpawnpoint(int)
,
getSpawnPoints()
public java.util.Collection<StaticShadow> getStaticShadows()
StaticShadow
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
StaticShadow
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public StaticShadow getStaticShadow(int mapId)
StaticShadow
with the specified map ID from this environment.mapId
- The map ID of the entity.StaticShadow
with the specified map ID or null if no entity is found.getStaticShadow(String)
,
getStaticShadows()
public StaticShadow getStaticShadow(java.lang.String name)
StaticShadow
with the specified name from this environment.name
- The name of the entity.StaticShadow
with the specified name or null if no entity is found.getStaticShadow(int)
,
getStaticShadows()
public java.util.Collection<Trigger> getTriggers()
Trigger
entities on this environment.
To add or remove entities, use the corresponding methods on this environment.
Trigger
entities.add(IEntity)
,
addAll(Iterable)
,
remove(IEntity)
,
removeAll(Iterable)
public Trigger getTrigger(int mapId)
Trigger
with the specified map ID from this environment.mapId
- The map ID of the entity.Trigger
with the specified map ID or null if no entity is found.getTrigger(String)
,
getTriggers()
public Trigger getTrigger(java.lang.String name)
Trigger
with the specified name from this environment.name
- The name of the entity.Trigger
with the specified name or null if no entity is found.getTrigger(int)
,
getTriggers()
public java.util.Collection<java.lang.String> getUsedTags()
public java.awt.geom.Point2D getCenter()
getMap()
public final void init()
public boolean isLoaded()
public void load()
init()
,
EnvironmentListener.loaded(Environment)
,
isLoaded()
public boolean loadFromMap(int mapId)
mapId
- The map ID of the map object.public void reloadFromMap(int mapId)
mapId
- The map ID of the map object.remove(int)
,
loadFromMap(int)
public java.util.Collection<IEntity> load(IMapObject mapObject)
mapObject
- The mapObject to load the entities from.IMapObjectLoader.load(Environment, IMapObject)
public Trigger interact(ICollisionEntity source)
source
- The entity that attempts to interacts with triggers.public Trigger interact(ICollisionEntity source, java.util.function.Predicate<Trigger> condition)
source
- The entity that attempts to interacts with triggers.condition
- The condition that determines whether a trigger can be interacted with.Trigger.canTrigger(ICollisionEntity)
public void remove(IEntity entity)
entity
- The entity to be removed.remove(int)
,
remove(String)
,
removeAll(Iterable)
,
unload(IEntity)
,
EnvironmentEntityListener.entityRemoved(IEntity)
,
IEntity.removed(Environment)
,
EntityListener.removed(IEntity, Environment)
public void remove(int mapId)
mapId
- The map ID of the entity to be removed.remove(int)
,
remove(String)
,
removeAll(Iterable)
,
unload(IEntity)
,
EnvironmentEntityListener.entityRemoved(IEntity)
,
IEntity.removed(Environment)
,
EntityListener.removed(IEntity, Environment)
public void remove(java.lang.String name)
name
- The name of the entity to be removed.remove(int)
,
remove(String)
,
removeAll(Iterable)
,
unload(IEntity)
,
EnvironmentEntityListener.entityRemoved(IEntity)
,
IEntity.removed(Environment)
,
EntityListener.removed(IEntity, Environment)
public <T extends IEntity> void removeAll(java.lang.Iterable<T> entities)
T
- The type of the specified entitiesentities
- The entities to be removed.remove(int)
,
remove(String)
public void removeAll(IEntity... entities)
entities
- The entities to be removed.remove(int)
,
remove(String)
public void removeRenderable(IRenderable renderable)
public void render(java.awt.Graphics2D g)
IRenderable
If an Entity
implements this interface, this method will be called right after the entity was rendered from the environment.
Allowing for a custom rendering mechanism.
This interface can be implemented in general by anything that should be rendered to the game's screen.
render
in interface IRenderable
g
- The current graphics object onto which this instance will render its visual contents.RenderEngine.renderEntity(Graphics2D, de.gurkenlabs.litiengine.entities.IEntity)
public int getGravity()
GameWorld.gravity()
,
GameWorld.setGravity(int)
,
setGravity(int)
public void setGravity(int gravity)
This typically only needs to be called explicitly, when the gravity is different than for other environments.
gravity
- The new gravity for this environment. If 0, no gravity will be applied.GameWorld.gravity()
,
GameWorld.setGravity(int)
,
getGravity()
public void unload()