Class Environment

java.lang.Object
de.gurkenlabs.litiengine.environment.Environment
All Implemented Interfaces:
IRenderable

public final class Environment
extends java.lang.Object
implements IRenderable
  • Constructor Summary

    Constructors 
    ConstructorDescription
    Environment​(IMap map)
    Instantiates a new Environment for the specified map.
    Environment​(java.lang.String mapPath)
    Instantiates a new Environment for the specified map.
  • Method Summary

    Modifier and TypeMethodDescription
    voidadd​(IEntity entity)
    Adds the specified entity to the environment container.
    voidadd​(IRenderable renderable, RenderType renderType)
    Adds the specified instance to be rendered with the defined RenderType whenever the environment's render pipeline is executed.
    voidaddAll​(IEntity... entities)
    Adds all the specified entities to the environment container.
    <T extends IEntity>
    void
    addAll​(java.lang.Iterable<T> entities)
    Adds 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.
    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.
    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.
    booleancontains​(IEntity entity)
    Determines whether the environment contains the specified entity.
    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.
    IEntityget​(int mapId)
    Gets the entity with the specified map ID from this environment.
    java.util.List<IEntity>get​(int... mapIds)
    Gets all entities with the specified map IDs from this environment.
    <T extends IEntity>
    T
    get​(java.lang.Class<T> clss, int mapId)
    Gets the strongly typed entity with the specified map ID from this environment.
    <T extends IEntity>
    T
    get​(java.lang.Class<T> clss, java.lang.String name)
    Gets the strongly typed entity with the specified name from this environment.
    IEntityget​(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.
    AmbientLightgetAmbientLight()
    Gets the ambient light instance of this environment.
    MapAreagetArea​(int mapId)
    Gets the MapArea with the specified map ID from this environment.
    MapAreagetArea​(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.
    java.util.Collection<MapArea>getAreas​(java.lang.String tag)
    Gets an immutable collection containing all MapArea entities with the specified tag.
    <T extends IEntity>
    java.util.Collection<T>
    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.Point2DgetCenter()
    Gets the center location of the boundaries defined by the map of this environment.
    CollisionBoxgetCollisionBox​(int mapId)
    Gets the CollisionBox with the specified map ID from this environment.
    CollisionBoxgetCollisionBox​(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<CollisionBox>getCollisionBoxes​(java.lang.String tag)
    Gets an immutable collection containing all CollisionBox entities with the specified tag.
    java.util.Collection<ICombatEntity>getCombatEntities()
    Gets an immutable collection containing all ICombatEntity entities on this environment.
    java.util.Collection<ICombatEntity>getCombatEntities​(java.lang.String tag)
    Gets an immutable collection containing all ICombatEntity entities with the specified tag.
    ICombatEntitygetCombatEntity​(int mapId)
    Gets the ICombatEntity with the specified map ID from this environment.
    ICombatEntitygetCombatEntity​(java.lang.String name)
    Gets the ICombatEntity with the specified name from this environment.
    CreaturegetCreature​(int mapId)
    Gets the Creature with the specified map ID from this environment.
    CreaturegetCreature​(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.
    java.util.Collection<Creature>getCreatures​(java.lang.String tag)
    Gets an immutable collection containing all Creature entities with the specified tag.
    EmittergetEmitter​(int mapId)
    Gets the Emitter with the specified map ID from this environment.
    EmittergetEmitter​(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<Emitter>getEmitters​(java.lang.String tag)
    Gets an immutable collection containing all Emitter entities with the specified tag.
    java.util.Collection<IEntity>getEntities()
    Gets an immutable collection containing all entities 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.
    <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.lang.String tag)
    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>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!.
    intgetGravity()
    Gets the gravity defined for this environment.
    LightSourcegetLightSource​(int mapId)
    Gets the LightSource with the specified map ID from this environment.
    LightSourcegetLightSource​(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.
    java.util.Collection<LightSource>getLightSources​(java.lang.String tag)
    Gets an immutable collection containing all LightSource entities with the specified tag.
    static intgetLocalMapId()
    Gets the next unique local map id.
    IMapgetMap()
    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.
    java.util.Collection<IMobileEntity>getMobileEntities​(java.lang.String tag)
    Gets an immutable collection containing all IMobileEntity entities with the specified tag.
    IMobileEntitygetMobileEntity​(int mapId)
    Gets the IMobileEntity with the specified map ID from this environment.
    IMobileEntitygetMobileEntity​(java.lang.String name)
    Gets the IMobileEntity with the specified name from this environment.
    intgetNextMapId()
    Gets the next unique global map id.
    PropgetProp​(int mapId)
    Gets the Prop with the specified map ID from this environment.
    PropgetProp​(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<Prop>getProps​(java.lang.String tag)
    Gets an immutable collection containing all Prop entities with the specified tag.
    java.util.Collection<IRenderable>getRenderables​(RenderType renderType)
    Gets an immutable collection containing all IRenderable instances for the specified render type on this environment.
    SoundSourcegetSoundSource​(int mapId)
    Gets the SoundSource with the specified map ID from this environment.
    SoundSourcegetSoundSource​(java.lang.String name)
    Gets the SoundSource with the specified name from this environment.
    java.util.Collection<SoundSource>getSoundSources()
    Gets an immutable collection containing all SoundSource entities on this environment.
    java.util.Collection<SoundSource>getSoundSources​(java.lang.String tag)
    Gets an immutable collection containing all SoundSource entities with the specified tag.
    SpawnpointgetSpawnpoint​(int mapId)
    Gets the Spawnpoint with the specified map ID from this environment.
    SpawnpointgetSpawnpoint​(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.
    java.util.Collection<Spawnpoint>getSpawnpoints​(java.lang.String tag)
    Gets an immutable collection containing all Spawnpoint entities with the specified tag.
    StaticShadowgetStaticShadow​(int mapId)
    Gets the StaticShadow with the specified map ID from this environment.
    StaticShadowgetStaticShadow​(java.lang.String name)
    Gets the StaticShadow with the specified name from this environment.
    StaticShadowLayergetStaticShadowLayer()
    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.
    java.util.Collection<StaticShadow>getStaticShadows​(java.lang.String tag)
    Gets an immutable collection containing all StaticShadow entities with the specified tag.
    TriggergetTrigger​(int mapId)
    Gets the Trigger with the specified map ID from this environment.
    TriggergetTrigger​(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<Trigger>getTriggers​(java.lang.String tag)
    Gets an immutable collection containing all Trigger entities with the specified tag.
    java.util.Collection<java.lang.String>getUsedTags()
    Gets all tags that are assigned to entities on this environment.
    voidinit()
    Initializes all entities and lighting layers of this environment.
    Triggerinteract​(ICollisionEntity source)
    Attempts to interact with triggers on this environment.
    Triggerinteract​(ICollisionEntity source, java.util.function.Predicate<Trigger> condition)
    Attempts to interact with triggers on this environment.
    booleanisLoaded()
    Determines whether this environment has been loaded.
    booleanisRendering() 
    voidload()
    Initializes and loads this environment and all its entities.
    java.util.Collection<IEntity>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​(java.lang.Class<? extends IEntity> entityType)
    Registers a custom IEntity implementation to support being loaded from an IMap instance.
    static voidregisterCustomEntityType​(java.lang.String mapObjectType, java.lang.Class<? extends IEntity> entityType)
    Registers a custom IEntity implementation to support being loaded from an IMap instance.
    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.
    voidremove​(IEntity entity)
    Removes the specified entity from this environment and unloads is.
    voidremove​(java.lang.String name)
    Removes the entity with the specified name from this environment and unloads is.
    voidremoveAll​(IEntity... entities)
    Removes all specified entities from this environment.
    <T extends IEntity>
    void
    removeAll​(java.lang.Iterable<T> entities)
    Removes all specified entities from this environment.
    voidremoveEntityListener​(EnvironmentEntityListener listener)
    Removes 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​(java.awt.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.
    voidupdateLighting()
    Forces an update on the lighting layers for the entire map.
    voidupdateLighting​(java.awt.geom.Rectangle2D section)
    Forces an update on the lighting layers for the specified section on the map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait