Class Environment
- All Implemented Interfaces:
IRenderable
-
Constructor Summary
ConstructorsConstructorDescriptionEnvironment(IMap map) Instantiates a newEnvironmentfor the specified map.Environment(String mapPath) Instantiates a newEnvironmentfor the specified map. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified entity to the environment container.voidadd(IRenderable renderable, RenderType renderType) Adds the specified instance to be rendered with the definedRenderTypewhenever the environment's render pipeline is executed.voidAdds all the specified entities to the environment container.<T extends IEntity>
voidAdds all the specified entities to the environment container.voidaddEntityListener(EnvironmentEntityListener listener) Adds the specified environment entity listener to receive events about entities on this environment.voidaddListener(EnvironmentListener listener) Adds the specified environment listener to receive events about the basic environment life-cycle.voidassignRenderType(IEntity entity, RenderType renderType) Adds entities by the specified blueprint to this environment at the defined location.Adds entities by the specified blueprint to this environment at the defined location.voidclear()Clears all loaded entities and renderable instances from this environment.booleancontains(int mapId) Determines whether the environment contains any entity with the specified map ID.booleanDetermines whether the environment contains the specified entity.findCombatEntities(Shape shape) Attempts to find all combat entities whose hitBox intersects with the specified shape.findCombatEntities(Shape shape, Predicate<ICombatEntity> condition) Attempts to find all combat entities whose hitBox intersects with the specified shape.findEntities(Shape shape) Attempts to find all entities whose bounding box intersects with the specified shape.get(int mapId) Gets the entity with the specified map ID from this environment.get(int... mapIds) Gets all entities with the specified map IDs from this environment.<T extends IEntity>
TGets the strongly typed entity with the specified map ID from this environment.<T extends IEntity>
TGets the strongly typed entity with the specified name from this environment.Gets the entity with the specified name from this environment.Gets an immutable collection with all assigned map IDs on this environment.Gets the ambient light instance of this environment.getArea(int mapId) Gets theMapAreawith the specified map ID from this environment.Gets theMapAreawith the specified name from this environment.getAreas()Gets an immutable collection containing allMapAreaentities on this environment.Gets an immutable collection containing allMapAreaentities with the specified tag.<T extends IEntity>
Collection<T> Gets a distinct and strongly named collection of all entities with any of the specified tags.Gets a distinct collection of all entities with any of the specified tags.Gets the center location of the boundaries defined by the map of this environment.getCollisionBox(int mapId) Gets theCollisionBoxwith the specified map ID from this environment.getCollisionBox(String name) Gets theCollisionBoxwith the specified name from this environment.Gets an immutable collection containing allCollisionBoxentities on this environment.getCollisionBoxes(String tag) Gets an immutable collection containing allCollisionBoxentities with the specified tag.Gets an immutable collection containing allICombatEntityentities on this environment.getCombatEntities(String tag) Gets an immutable collection containing allICombatEntityentities with the specified tag.getCombatEntity(int mapId) Gets theICombatEntitywith the specified map ID from this environment.getCombatEntity(String name) Gets theICombatEntitywith the specified name from this environment.getCreature(int mapId) Gets theCreaturewith the specified map ID from this environment.getCreature(String name) Gets theCreaturewith the specified name from this environment.Gets an immutable collection containing allCreatureentities on this environment.getCreatures(String tag) Gets an immutable collection containing allCreatureentities with the specified tag.getEmitter(int mapId) Gets theEmitterwith the specified map ID from this environment.getEmitter(String name) Gets theEmitterwith the specified name from this environment.Gets an immutable collection containing allEmitterentities on this environment.getEmitters(String tag) Gets an immutable collection containing allEmitterentities with the specified tag.Gets an immutable collection containing all entities on this environment.getEntities(IMapObjectLayer layer) Gets the entities that are bound to the specified layer.getEntities(RenderType renderType) Gets the entities with the specified render type that are not bound to layers.<T> Collection<T> getEntities(Class<? extends T> cls) Gets all entities of the specified type on this environment.<T> Collection<T> getEntities(Class<? extends T> cls, String tag) Gets all entities of the specified type on this environment.<T> Collection<T> getEntities(Class<? extends T> cls, Predicate<T> pred) Gets all entities of the specified type on this environment.getEntitiesByLayer(int layerId) Gets the entities that are bound to layer with the specified layer ID.getEntitiesByLayer(String name) Gets the entities that are bound to layer with the specified name.DON'T USE THIS! THIS IS FOR ENGINE INTERNAL PURPOSES ONLY!.intGets the gravity defined for this environment.getLightSource(int mapId) Gets theLightSourcewith the specified map ID from this environment.getLightSource(String name) Gets theLightSourcewith the specified name from this environment.Gets an immutable collection containing allLightSourceentities on this environment.getLightSources(String tag) Gets an immutable collection containing allLightSourceentities with the specified tag.static intGets the next unique local map id.getMap()Gets the map on which this environment is based upon.Gets an immutable collection containing allIMobileEntityinstances on this environment.getMobileEntities(String tag) Gets an immutable collection containing allIMobileEntityentities with the specified tag.getMobileEntity(int mapId) Gets theIMobileEntitywith the specified map ID from this environment.getMobileEntity(String name) Gets theIMobileEntitywith the specified name from this environment.intGets the next unique global map id.getProp(int mapId) Gets thePropwith the specified map ID from this environment.Gets thePropwith the specified name from this environment.getProps()Gets an immutable collection containing allPropentities on this environment.Gets an immutable collection containing allPropentities with the specified tag.getRenderables(RenderType renderType) Gets an immutable collection containing allIRenderableinstances for the specified render type on this environment.getSoundSource(int mapId) Gets theSoundSourcewith the specified map ID from this environment.getSoundSource(String name) Gets theSoundSourcewith the specified name from this environment.Gets an immutable collection containing allSoundSourceentities on this environment.getSoundSources(String tag) Gets an immutable collection containing allSoundSourceentities with the specified tag.getSpawnpoint(int mapId) Gets theSpawnpointwith the specified map ID from this environment.getSpawnpoint(String name) Gets theSpawnpointwith the specified name from this environment.Gets an immutable collection containing allSpawnpointentities on this environment.getSpawnpoints(String tag) Gets an immutable collection containing allSpawnpointentities with the specified tag.getStaticShadow(int mapId) Gets theStaticShadowwith the specified map ID from this environment.getStaticShadow(String name) Gets theStaticShadowwith the specified name from this environment.Gets the static shadow lighting layer of this environment.Gets an immutable collection containing allStaticShadowentities on this environment.getStaticShadows(String tag) Gets an immutable collection containing allStaticShadowentities with the specified tag.getTrigger(int mapId) Gets theTriggerwith the specified map ID from this environment.getTrigger(String name) Gets theTriggerwith the specified name from this environment.Gets an immutable collection containing allTriggerentities on this environment.getTriggers(String tag) Gets an immutable collection containing allTriggerentities with the specified tag.Gets all tags that are assigned to entities on this environment.voidinit()Initializes all entities and lighting layers of this environment.interact(ICollisionEntity source) Attempts to interact with triggers on this environment.interact(ICollisionEntity source, Predicate<Trigger> condition) Attempts to interact with triggers on this environment.booleanisLoaded()Determines whether this environment has been loaded.booleanvoidload()Initializes and loads this environment and all its entities.load(IMapObject mapObject) Loads all entities for the specified map object.booleanloadFromMap(int mapId) Loads the entities from the map object with the specified map ID from the map of this environment.voidonRendered(RenderType renderType, EnvironmentRenderedListener listener) Adds the specified environment rendered listener to receive events when this instance renders the specified renderType.static voidregisterCustomEntityType(Class<? extends IEntity> entityType) Registers a customIEntityimplementation to support being loaded from anIMapinstance.static voidregisterCustomEntityType(String mapObjectType, Class<? extends IEntity> entityType) Registers a customIEntityimplementation to support being loaded from anIMapinstance.static voidregisterMapObjectLoader(IMapObjectLoader mapObjectLoader) Registers a custom loader instance that is responsible for loading and initializing entities of the defined MapObjectType.voidreloadFromMap(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.voidremove(int mapId) Removes the entity with the specified map ID from this environment and unloads is.voidRemoves the specified entity from this environment and unloads is.voidRemoves the entity with the specified name from this environment and unloads is.voidRemoves all specified entities from this environment.<T extends IEntity>
voidRemoves all specified entities from this environment.voidRemoves the environment entity listener listener.voidremoveListener(EnvironmentListener listener) Removes the environment listener.voidremoveListener(EnvironmentRenderedListener listener) Removes the specified environment rendered listener.voidremoveRenderable(IRenderable renderable) voidrender(Graphics2D g) Renders the visual contents of this instance onto the provided graphics context.voidsetGravity(int gravity) Sets the gravity for this particular environment.voidunload()Unloads all entities of this environment.voidForces an update on the lighting layers for the entire map.voidupdateLighting(Rectangle2D section) Forces an update on the lighting layers for the specified section on the map.
-
Constructor Details
-
Environment
Instantiates a newEnvironmentfor the specified map.- Parameters:
map- The map that defines this environment.
-
Environment
Instantiates a newEnvironmentfor the specified map.- Parameters:
mapPath- The path to the map resource that defines this environment.
-
-
Method Details
-
registerMapObjectLoader
Registers a custom loader instance that is responsible for loading and initializing entities of the defined MapObjectType.
There can only be one loader for a particular type. Calling this method again for the same type will overwrite the previously registered loader.- Parameters:
mapObjectLoader- The MapObjectLoader instance to be registered.- See Also:
-
registerCustomEntityType
public static void registerCustomEntityType(String mapObjectType, Class<? extends IEntity> entityType) Registers a customIEntityimplementation to support being loaded from anIMapinstance. 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 theMapObjectTypewithout having to provide anEntityInfoannotation containing this information.Custom entity types need to provide at least one constructor that matches the following criteria:
- has 2 parameters:
Environment, IMapObject - has 2 parameters:
IMapObject, Environment - has 1 parameter:
IMapObject - has 1 parameter:
Environment - is empty constructor
- Parameters:
mapObjectType- The custom mapobjectType that is used byIMapObjectsto determine the target entity implementation.entityType- The class type of the custom entity implementation.- See Also:
- has 2 parameters:
-
registerCustomEntityType
Registers a customIEntityimplementation to support being loaded from anIMapinstance. 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.- Parameters:
entityType- The class type of the custom entity implementation.- See Also:
-
onRendered
Adds the specified environment rendered listener to receive events when this instance renders the specified renderType.- Parameters:
renderType- The type that defines to which render process this listener should be attached.listener- The listener to add.
-
removeListener
Removes the specified environment rendered listener.- Parameters:
listener- The listener to remove.
-
addListener
Adds the specified environment listener to receive events about the basic environment life-cycle.- Parameters:
listener- The listener to add.
-
removeListener
Removes the environment listener.- Parameters:
listener- The listener to remove.
-
addEntityListener
Adds the specified environment entity listener to receive events about entities on this environment.- Parameters:
listener- The listener to add.
-
removeEntityListener
Removes the environment entity listener listener.- Parameters:
listener- The listener to remove.
-
add
Adds the specified entity to the environment container. This also loads the entity (registers entity and controllers for update) if the environment has already been loaded. The entity will not be bound to a layer.- Parameters:
entity- The entity to add to the environment.- See Also:
-
addAll
Adds all the specified entities to the environment container.- Type Parameters:
T- The type of the entity.- Parameters:
entities- The entities to be added to the environment.- See Also:
-
addAll
Adds all the specified entities to the environment container.- Parameters:
entities- The entities to be added to the environment.- See Also:
-
updateLighting
public void updateLighting()Forces an update on the lighting layers for the entire map.- See Also:
-
updateLighting
Forces an update on the lighting layers for the specified section on the map.- Parameters:
section- The section for which to update the lighting layers.- See Also:
-
add
Adds the specified instance to be rendered with the definedRenderTypewhenever 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
Entityif it implementsIRenderable. The render engine will inherently call an entity's render method.- Parameters:
renderable- The instance that should be rendered.renderType- The render type that determines how the instance is processed by the environment's render pipeline.- See Also:
-
build
Adds entities by the specified blueprint to this environment at the defined location.- Parameters:
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.- Returns:
- A collection with all added entities.
-
build
Adds entities by the specified blueprint to this environment at the defined location.- Parameters:
blueprint- The blueprint, defining the map object to load the entities from.location- The location at which to spawn the entities.- Returns:
- A collection with all added entities.
-
clear
public void clear()Clears all loaded entities and renderable instances from this environment. -
contains
Determines whether the environment contains the specified entity.- Parameters:
entity- The entity to check for.- Returns:
- True if the environment contains the specified entity; otherwise false.
-
contains
public boolean contains(int mapId) Determines whether the environment contains any entity with the specified map ID.- Parameters:
mapId- The map ID of the entity to check for.- Returns:
- True if the environment contains an entity with the specified map ID; otherwise false.
-
findCombatEntities
Attempts to find all combat entities whose hitBox intersects with the specified shape.- Parameters:
shape- The shape to check intersection for.- Returns:
- A collection of all combat entities that intersect the specified
Shape.
-
findCombatEntities
public Collection<ICombatEntity> findCombatEntities(Shape shape, Predicate<ICombatEntity> condition) Attempts to find all combat entities whose hitBox intersects with the specified shape.- Parameters:
shape- The shape to check intersection for.condition- An additional condition that allows to specify a condition which determines if aICombatEntityshould be considered.- Returns:
- A collection of all combat entities that intersect the specified
Shape.
-
findEntities
Attempts to find all entities whose bounding box intersects with the specified shape.- Parameters:
shape- The shape to check intersection for.- Returns:
- A collection of all entities that intersect the specified
Shape.
-
get
Gets the entity with the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The entity with the specified map ID or null if no entity could be found.
-
get
Gets all entities with the specified map IDs from this environment.- Parameters:
mapIds- The map IDs to search for.- Returns:
- A
Listof entities found, in the order given by the parameters.
-
get
Gets the strongly typed entity with the specified map ID from this environment.- Type Parameters:
T- The type of the entity.- Parameters:
clss- The class instance defining the type of the entity.mapId- The map ID of the entity.- Returns:
- The strongly typed entity with the specified map ID or null if no entity could be found or if the defined type doesn't match.
-
get
Gets the entity with the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The entity with the specified name or null if no entity could be found or if the defined type doesn't match.
-
get
Gets the strongly typed entity with the specified name from this environment.- Type Parameters:
T- The type of the entity.- Parameters:
clss- The class instance defining the type of the entity.name- The name of the entity.- Returns:
- The strongly typed entity with the specified name or null if no entity could be found or if the defined type doesn't match.
-
getByTag
Gets a distinct collection of all entities with any of the specified tags.- Parameters:
tags- The tags to search for.- Returns:
- All entities with any of the specified tags.
-
getByTag
Gets a distinct and strongly named collection of all entities with any of the specified tags.- Type Parameters:
T- The type of the entity.- Parameters:
clss- The class instance defining the type of the entity.tags- The tags to search for.- Returns:
- All entities with any of the specified tags.
-
getAmbientLight
Gets the ambient light instance of this environment.- Returns:
- The ambient light instance of this environment.
- See Also:
-
getStaticShadowLayer
Gets the static shadow lighting layer of this environment.- Returns:
- The static shadow lighting layer of this environment.
- See Also:
-
getAllMapIDs
Gets an immutable collection with all assigned map IDs on this environment.- Returns:
- An immutable collection with all map IDs.
-
getAreas
Gets an immutable collection containing allMapAreaentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
MapAreaentities. - See Also:
-
getAreas
Gets an immutable collection containing allMapAreaentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
-
getArea
Gets theMapAreawith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
MapAreawith the specified map ID or null if no entity is found. - See Also:
-
getArea
Gets theMapAreawith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
MapAreawith the specified name or null if no entity is found. - See Also:
-
getEmitters
Gets an immutable collection containing allEmitterentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
Emitterentities. - See Also:
-
getEmitters
Gets an immutable collection containing allEmitterentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
-
getEmitter
Gets theEmitterwith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
Emitterwith the specified map ID or null if no entity is found. - See Also:
-
getEmitter
Gets theEmitterwith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
Emitterwith the specified name or null if no entity is found. - See Also:
-
getCollisionBoxes
Gets an immutable collection containing allCollisionBoxentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
CollisionBoxentities. - See Also:
-
getCollisionBoxes
Gets an immutable collection containing allCollisionBoxentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theCollisionBoxentities have to provide to be returned.- Returns:
- An immutable collection with all
CollisionBoxentities with the specified tag. - See Also:
-
getCollisionBox
Gets theCollisionBoxwith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
CollisionBoxwith the specified map ID or null if no entity is found. - See Also:
-
getCollisionBox
Gets theCollisionBoxwith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
CollisionBoxwith the specified name or null if no entity is found. - See Also:
-
getCombatEntities
Gets an immutable collection containing allICombatEntityentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
ICombatEntityentities. - See Also:
-
getCombatEntities
Gets an immutable collection containing allICombatEntityentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theICombatEntityentities have to provide to be returned.- Returns:
- An immutable collection with all
ICombatEntityentities with the specified tag. - See Also:
-
getCombatEntity
Gets theICombatEntitywith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
ICombatEntitywith the specified map ID or null if no entity is found. - See Also:
-
getCombatEntity
Gets theICombatEntitywith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
ICombatEntitywith the specified name or null if no entity is found. - See Also:
-
getEntities
Gets an immutable collection containing all entities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all entities.
- See Also:
-
getEntities
Gets all entities of the specified type on this environment.- Type Parameters:
T- The type of the entity.- Parameters:
cls- The class instance defining the type of the entity.- Returns:
- All entities of the specified type.
-
getEntities
Gets all entities of the specified type on this environment.- Type Parameters:
T- The type of the entity.- Parameters:
cls- The class instance defining the type of the entity.tag- A tag that decides whether the defined entity should be included in the result.- Returns:
- All entities of the specified type.
-
getEntities
Gets all entities of the specified type on this environment.- Type Parameters:
T- The type of the entity.- Parameters:
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.- Returns:
- All entities of the specified type.
-
getEntities
Gets the entities with the specified render type that are not bound to layers.Entities are unbound from there originating
MapObjectLayerif theirRenderTypediffers from the layer'sRenderType.- Parameters:
renderType- The render type- Returns:
- The miscellaneous entities with the specified render type
- See Also:
-
getEntities
Gets the entities that are bound to the specified layer.Entities are bound to a layer if their
RenderTypematches the layer'sRenderType- Parameters:
layer- The layer that the entities are bound to.- Returns:
- The entities that are bound to the specified layer.
- See Also:
-
getEntitiesByLayer
Gets the entities that are bound to layer with the specified name.Entities are bound to a layer if their
RenderTypematches the layer'sRenderType- Parameters:
name- The name of the layer- Returns:
- The entities that are bound to the specified layer.
- See Also:
-
getEntitiesByLayer
Gets the entities that are bound to layer with the specified layer ID.Entities are bound to a layer if their
RenderTypematches the layer'sRenderType- Parameters:
layerId- The id of the layer- Returns:
- The entities that are bound to the specified layer.
- See Also:
-
getEntitiesByTag
DON'T USE THIS! THIS IS FOR ENGINE INTERNAL PURPOSES ONLY!.- Returns:
- A map with all entities by tags.
-
getLightSources
Gets an immutable collection containing allLightSourceentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
LightSourceentities. - See Also:
-
getLightSources
Gets an immutable collection containing allLightSourceentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theLightSourceentities have to provide to be returned.- Returns:
- An immutable collection with all
LightSourceentities with the specified tag. - See Also:
-
getLightSource
Gets theLightSourcewith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
LightSourcewith the specified map ID or null if no entity is found. - See Also:
-
getLightSource
Gets theLightSourcewith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
LightSourcewith the specified name or null if no entity is found. - See Also:
-
getLocalMapId
public static int getLocalMapId()Gets the next unique local map id. (All local map ids are negative).- Returns:
- The next unique local map id.
-
getMap
Gets the map on which this environment is based upon.- Returns:
- The map of this environment.
-
getMobileEntities
Gets an immutable collection containing allIMobileEntityinstances on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
IMobileEntityinstances. - See Also:
-
getMobileEntities
Gets an immutable collection containing allIMobileEntityentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theIMobileEntityentities have to provide to be returned.- Returns:
- An immutable collection with all
IMobileEntityentities with the specified tag. - See Also:
-
getMobileEntity
Gets theIMobileEntitywith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
IMobileEntitywith the specified map ID or null if no entity is found. - See Also:
-
getMobileEntity
Gets theIMobileEntitywith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
IMobileEntitywith the specified name or null if no entity is found. - See Also:
-
getNextMapId
public int getNextMapId()Gets the next unique global map id.- Returns:
- The next unique global map id.
-
getRenderables
Gets an immutable collection containing allIRenderableinstances for the specified render type on this environment.To add or remove instances, use the corresponding methods on this environment.
- Parameters:
renderType- The render type of the renderable instances.- Returns:
- An immutable collection with all
IRenderableinstances. - See Also:
-
getProps
Gets an immutable collection containing allPropentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
Propentities. - See Also:
-
getProps
Gets an immutable collection containing allPropentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
-
getProp
Gets thePropwith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
Propwith the specified map ID or null if no entity is found. - See Also:
-
getProp
Gets thePropwith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
Propwith the specified name or null if no entity is found. - See Also:
-
getCreatures
Gets an immutable collection containing allCreatureentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
Creatureentities. - See Also:
-
getCreatures
Gets an immutable collection containing allCreatureentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
-
getCreature
Gets theCreaturewith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
Creaturewith the specified map ID or null if no entity is found. - See Also:
-
getCreature
Gets theCreaturewith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
Creaturewith the specified name or null if no entity is found. - See Also:
-
getSpawnpoints
Gets an immutable collection containing allSpawnpointentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
Spawnpointentities. - See Also:
-
getSpawnpoints
Gets an immutable collection containing allSpawnpointentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theSpawnpointentities have to provide to be returned.- Returns:
- An immutable collection with all
Spawnpointentities with the specified tag. - See Also:
-
getSpawnpoint
Gets theSpawnpointwith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
Spawnpointwith the specified map ID or null if no entity is found. - See Also:
-
getSpawnpoint
Gets theSpawnpointwith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
Spawnpointwith the specified name or null if no entity is found. - See Also:
-
getSoundSources
Gets an immutable collection containing allSoundSourceentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
SoundSourceentities. - See Also:
-
getSoundSources
Gets an immutable collection containing allSoundSourceentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theSoundSourceentities have to provide to be returned.- Returns:
- An immutable collection with all
SoundSourceentities with the specified tag. - See Also:
-
getSoundSource
Gets theSoundSourcewith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
SoundSourcewith the specified map ID or null if no entity is found. - See Also:
-
getSoundSource
Gets theSoundSourcewith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
SoundSourcewith the specified name or null if no entity is found. - See Also:
-
getStaticShadows
Gets an immutable collection containing allStaticShadowentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
StaticShadowentities. - See Also:
-
getStaticShadows
Gets an immutable collection containing allStaticShadowentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
- Parameters:
tag- The tag that theStaticShadowentities have to provide to be returned.- Returns:
- An immutable collection with all
StaticShadowentities with the specified tag. - See Also:
-
getStaticShadow
Gets theStaticShadowwith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
StaticShadowwith the specified map ID or null if no entity is found. - See Also:
-
getStaticShadow
Gets theStaticShadowwith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
StaticShadowwith the specified name or null if no entity is found. - See Also:
-
getTriggers
Gets an immutable collection containing allTriggerentities on this environment.To add or remove entities, use the corresponding methods on this environment.
- Returns:
- An immutable collection with all
Triggerentities. - See Also:
-
getTriggers
Gets an immutable collection containing allTriggerentities with the specified tag.To add or remove entities, use the corresponding methods on this environment.
-
getTrigger
Gets theTriggerwith the specified map ID from this environment.- Parameters:
mapId- The map ID of the entity.- Returns:
- The
Triggerwith the specified map ID or null if no entity is found. - See Also:
-
getTrigger
Gets theTriggerwith the specified name from this environment.- Parameters:
name- The name of the entity.- Returns:
- The
Triggerwith the specified name or null if no entity is found. - See Also:
-
getUsedTags
Gets all tags that are assigned to entities on this environment.- Returns:
- All assigned tags of this environment.
-
getCenter
Gets the center location of the boundaries defined by the map of this environment.- Returns:
- The center of this environment.
- See Also:
-
init
public void init()Initializes all entities and lighting layers of this environment.- See Also:
-
isLoaded
public boolean isLoaded()Determines whether this environment has been loaded.- Returns:
- True if this environment has been loaded; otherwise false.
- See Also:
-
load
public void load()Initializes and loads this environment and all its entities.- See Also:
-
loadFromMap
public boolean loadFromMap(int mapId) Loads the entities from the map object with the specified map ID from the map of this environment.- Parameters:
mapId- The map ID of the map object.- Returns:
- True if any entity could be loaded; otherwise false.
-
reloadFromMap
public 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.- Parameters:
mapId- The map ID of the map object.- See Also:
-
load
Loads all entities for the specified map object.- Parameters:
mapObject- The mapObject to load the entities from.- Returns:
- A collection of all loaded entities.
- See Also:
-
interact
Attempts to interact with triggers on this environment.- Parameters:
source- The entity that attempts to interacts with triggers.- Returns:
- The trigger that the source entity was able to interact with or null.
-
interact
Attempts to interact with triggers on this environment.- Parameters:
source- The entity that attempts to interacts with triggers.condition- The condition that determines whether a trigger can be interacted with.- Returns:
- The trigger that the entity was able to interact with or null.
- See Also:
-
remove
Removes the specified entity from this environment and unloads is.- Parameters:
entity- The entity to be removed.- See Also:
-
remove
public void remove(int mapId) Removes the entity with the specified map ID from this environment and unloads is.- Parameters:
mapId- The map ID of the entity to be removed.- See Also:
-
remove
Removes the entity with the specified name from this environment and unloads is.- Parameters:
name- The name of the entity to be removed.- See Also:
-
removeAll
Removes all specified entities from this environment.- Type Parameters:
T- The type of the specified entities- Parameters:
entities- The entities to be removed.- See Also:
-
removeAll
Removes all specified entities from this environment.- Parameters:
entities- The entities to be removed.- See Also:
-
removeRenderable
-
render
Description copied from interface:IRenderableRenders the visual contents of this instance onto the provided graphics context.If an
Entityimplements 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.
- Specified by:
renderin interfaceIRenderable- Parameters:
g- The current graphics object onto which this instance will render its visual contents.- See Also:
-
getGravity
public int getGravity()Gets the gravity defined for this environment.- Returns:
- The gravity of this environment.
- See Also:
-
setGravity
public void setGravity(int gravity) Sets the gravity for this particular environment.This typically only needs to be called explicitly, when the gravity is different than for other environments.
- Parameters:
gravity- The new gravity for this environment. If 0, no gravity will be applied.- See Also:
-
unload
public void unload()Unloads all entities of this environment.- See Also:
-
isRendering
public boolean isRendering() -
assignRenderType
-