Class Entity
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
- All Implemented Interfaces:
EntityRenderedListener,EntityRenderListener,IEntity,Tweenable,java.util.EventListener
- Direct Known Subclasses:
CollisionEntity,Emitter,LightSource,MapArea,SoundSource,Spawnpoint
public abstract class Entity
extends java.lang.Object
implements IEntity, EntityRenderListener, TweenableField Summary
Fields Modifier and Type Field Description static java.lang.StringANY_MESSAGEConstructor Summary
Method Summary
Modifier and Type Method Description EntityActionMapactions()All registered actions of this entity.voidaddController(IEntityController controller)voidaddEntityRenderListener(EntityRenderListener listener)Adds the specified entity render listener to receive events and callbacks about the rendering process of entities.voidaddListener(EntityListener listener)voidaddTag(java.lang.String tag)voidaddTransformListener(EntityTransformListener listener)IEntityAnimationController<?>animations()Gets the entities animation controller.voidattachControllers()IBehaviorControllerbehavior()booleancanRender(IEntity entity)This method gets called before anEntityis about to be rendered.voiddetachControllers()doublegetAngle()java.awt.geom.Rectangle2DgetBoundingBox()java.awt.geom.Point2DgetCenter()<T extends IEntityController>
TgetController(java.lang.Class<T> clss)protected EntityControllersgetControllers()EnvironmentgetEnvironment()Gets the environment the entity was loaded to or null if it is not loaded.doublegetHeight()java.awt.geom.Point2DgetLocation()intgetMapId()java.lang.StringgetName()Gets the name of this entity.ICustomPropertyProvidergetProperties()RenderTypegetRenderType()java.util.List<java.lang.String>getTags()float[]getTweenValues(TweenType tweenType)Gets one or many values from the target object associated to the given tween type.doublegetWidth()doublegetX()doublegetY()booleanhasTag(java.lang.String tag)booleanisLoaded()Indicates whether this entity is loaded on the currently active environment.booleanisVisible()voidloaded(Environment environment)This method provides the possibility to implement behavior whenever this entity was added to the environment.voidonMessage(EntityMessageListener listener)voidonMessage(java.lang.String message, EntityMessageListener listener)voidonRendered(EntityRenderedListener listener)Adds the specified entity rendered listener to receive events when entities were rendered.voidperform(java.lang.String actionName)Performs anEntityActionthat was previously registered for this entity.EntityActionregister(java.lang.String name, java.lang.Runnable action)Registers anEntityActionwith the specified name.voidremoved(Environment environment)This method provides the possibility to implement behavior whenever this entity was removed from the environment.voidremoveListener(EntityListener listener)voidremoveListener(EntityMessageListener listener)voidremoveListener(EntityRenderedListener listener)Removes the specified entity rendered listener.voidremoveListener(EntityRenderListener listener)Removes the specified entity render listener.voidremoveListener(EntityTransformListener listener)voidremoveTag(java.lang.String tag)voidrendered(EntityRenderEvent event)This method gets called after an entity was rendered.voidrendering(EntityRenderEvent event)This method gets called after all rendering checks have successfully passed and right before the entity is about to be rendered.booleanrenderWithLayer()Determines whether this entity is being rendered with the layer it's originating from.java.lang.StringsendMessage(java.lang.Object sender, java.lang.String message)voidsetAngle(double angle)Sets the angle (in degrees) in which the entity is directed.<T extends IEntityController>
voidsetController(java.lang.Class<T> clss, T controller)voidsetHeight(double height)voidsetLocation(double x, double y)voidsetLocation(java.awt.geom.Point2D location)Sets the map location.voidsetMapId(int mapId)Sets an id which should only be filled when an entity gets added due to map information.voidsetName(java.lang.String name)voidsetRenderType(RenderType renderType)voidsetRenderWithLayer(boolean renderWithLayer)voidsetSize(double width, double height)voidsetTweenValues(TweenType tweenType, float[] newValues)This method is called in a Tween's update() method to set the new interpolated values.voidsetVisible(boolean visible)voidsetWidth(double width)voidsetX(double x)voidsetY(double y)java.lang.StringtoString()
Field Details
ANY_MESSAGE
public static final java.lang.String ANY_MESSAGE- See Also:
- Constant Field Values
Constructor Details
Method Details
addTransformListener
- Specified by:
addTransformListenerin interfaceIEntity
removeListener
- Specified by:
removeListenerin interfaceIEntity
addListener
- Specified by:
addListenerin interfaceIEntity
removeListener
- Specified by:
removeListenerin interfaceIEntity
onRendered
Description copied from interface:IEntityAdds the specified entity rendered listener to receive events when entities were rendered.- Specified by:
onRenderedin interfaceIEntity- Parameters:
listener- The listener to add.
removeListener
Description copied from interface:IEntityRemoves the specified entity rendered listener.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- The listener to remove.
addEntityRenderListener
Description copied from interface:IEntityAdds the specified entity render listener to receive events and callbacks about the rendering process of entities.- Specified by:
addEntityRenderListenerin interfaceIEntity- Parameters:
listener- The listener to add.
removeListener
Description copied from interface:IEntityRemoves the specified entity render listener.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- The listener to remove.
onMessage
onMessage
removeListener
- Specified by:
removeListenerin interfaceIEntity
attachControllers
public void attachControllers()- Specified by:
attachControllersin interfaceIEntity
detachControllers
public void detachControllers()- Specified by:
detachControllersin interfaceIEntity
getProperties
- Specified by:
getPropertiesin interfaceIEntity
getAngle
public double getAngle()animations
Description copied from interface:IEntityGets the entities animation controller.- Specified by:
animationsin interfaceIEntity- Returns:
- The entities animation controller or null if none was registered.
- See Also:
RenderEngine.renderEntity(java.awt.Graphics2D, IEntity)
behavior
addController
- Specified by:
addControllerin interfaceIEntity
setController
- Specified by:
setControllerin interfaceIEntity
getController
- Specified by:
getControllerin interfaceIEntity
getBoundingBox
public java.awt.geom.Rectangle2D getBoundingBox()- Specified by:
getBoundingBoxin interfaceIEntity
getCenter
public java.awt.geom.Point2D getCenter()getHeight
public double getHeight()getLocation
public java.awt.geom.Point2D getLocation()- Specified by:
getLocationin interfaceIEntity
getMapId
public int getMapId()getName
public java.lang.String getName()Description copied from interface:IEntityGets the name of this entity.getRenderType
- Specified by:
getRenderTypein interfaceIEntity
getWidth
public double getWidth()getX
public double getX()getY
public double getY()isVisible
public boolean isVisible()setVisible
public void setVisible(boolean visible)- Specified by:
setVisiblein interfaceIEntity
actions
Description copied from interface:IEntityAll registered actions of this entity.- Specified by:
actionsin interfaceIEntity- Returns:
- The EntityActionMap that holds all registered EntityActions for this instance.
- See Also:
EntityActionMap,IEntity.register(String, Runnable)
perform
public void perform(java.lang.String actionName)Description copied from interface:IEntityPerforms anEntityActionthat was previously registered for this entity.Does nothing in case no action has been registered for the specified
actionName.- Specified by:
performin interfaceIEntity- Parameters:
actionName- The name of the action to be performed.- See Also:
IEntity.actions(),IEntity.register(String, Runnable)
register
Description copied from interface:IEntityRegisters anEntityActionwith the specified name. It's later possible to execute these actions on the entity by using theEntity.perform(String actionName)method.- Specified by:
registerin interfaceIEntity- Parameters:
name- The name of the action to be registered.action- The action to be performed by the entity.- Returns:
- The created EntityAction instance; or null if the name or action parameter were invalid.
- See Also:
IEntity.perform(String),IEntity.actions()
sendMessage
public java.lang.String sendMessage(java.lang.Object sender, java.lang.String message)- Specified by:
sendMessagein interfaceIEntity
setHeight
public void setHeight(double height)setLocation
public void setLocation(double x, double y)- Specified by:
setLocationin interfaceIEntity
setLocation
public void setLocation(java.awt.geom.Point2D location)Sets the map location.- Specified by:
setLocationin interfaceIEntity- Parameters:
location- the new map location
setMapId
public void setMapId(int mapId)Sets an id which should only be filled when an entity gets added due to map information.setName
public void setName(java.lang.String name)setRenderType
- Specified by:
setRenderTypein interfaceIEntity
setSize
public void setSize(double width, double height)setWidth
public void setWidth(double width)setX
public void setX(double x)setY
public void setY(double y)getTags
public java.util.List<java.lang.String> getTags()hasTag
public boolean hasTag(java.lang.String tag)addTag
public void addTag(java.lang.String tag)removeTag
public void removeTag(java.lang.String tag)getTweenValues
Description copied from interface:TweenableGets one or many values from the target object associated to the given tween type. It is used by the Tween Engine to determine starting values.- Specified by:
getTweenValuesin interfaceTweenable- Parameters:
tweenType- The tween type of this interpolation, determining which values are modified.- Returns:
- The array of current tween values.
setTweenValues
Description copied from interface:TweenableThis method is called in a Tween's update() method to set the new interpolated values.- Specified by:
setTweenValuesin interfaceTweenable- Parameters:
tweenType- The tween type of this interpolation, determining which values are modified.newValues- The new values determined by the tween equation.
setAngle
public void setAngle(double angle)Description copied from interface:IEntitySets the angle (in degrees) in which the entity is directed.toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
getEnvironment
Description copied from interface:IEntityGets the environment the entity was loaded to or null if it is not loaded.- Specified by:
getEnvironmentin interfaceIEntity- Returns:
- The entity's environment.
loaded
Description copied from interface:IEntityThis method provides the possibility to implement behavior whenever this entity was added to the environment.- Specified by:
loadedin interfaceIEntity- Parameters:
environment- The environment that the entity was added to- See Also:
IEntity.addListener(EntityListener)
removed
Description copied from interface:IEntityThis method provides the possibility to implement behavior whenever this entity was removed from the environment.- Specified by:
removedin interfaceIEntity- Parameters:
environment- The environment that the entity was removed from- See Also:
IEntity.addListener(EntityListener)
isLoaded
public boolean isLoaded()Description copied from interface:IEntityIndicates whether this entity is loaded on the currently active environment.- Specified by:
isLoadedin interfaceIEntity- Returns:
- True if the entity is loaded on the game's currently active environment; otherwise false.
- See Also:
GameWorld.environment(),IEntity.loaded(Environment),IEntity.removed(Environment)
renderWithLayer
public boolean renderWithLayer()Description copied from interface:IEntityDetermines whether this entity is being rendered with the layer it's originating from. This ignores the specifiedRenderTypeand makes the entity dependent upon the visibility of it's layer.This can only be used, of course, if the entity is related to a
MapObject.
This defaults tofalseif not explicitly set on theMapObject.- Specified by:
renderWithLayerin interfaceIEntity- Returns:
- True if the entity should be rendered with the layer of the corresponding map object; otherwise false.
- See Also:
ILayer.isVisible(),IMapObjectLayer.getMapObjects(),Environment.getEntitiesByLayer(int),Environment.getEntitiesByLayer(String)
setRenderWithLayer
public void setRenderWithLayer(boolean renderWithLayer)- Specified by:
setRenderWithLayerin interfaceIEntity
rendering
Description copied from interface:EntityRenderListenerThis method gets called after all rendering checks have successfully passed and right before the entity is about to be rendered.- Specified by:
renderingin interfaceEntityRenderListener- Parameters:
event- The event that contains the render data.
rendered
Description copied from interface:EntityRenderedListenerThis method gets called after an entity was rendered.- Specified by:
renderedin interfaceEntityRenderedListener- Parameters:
event- The event that contains the render data.
canRender
Description copied from interface:EntityRenderListenerThis method gets called before anEntityis about to be rendered. Returning false prevents the rendering of the specified entity.- Specified by:
canRenderin interfaceEntityRenderListener- Parameters:
entity- The entity to be rendered.- Returns:
- True if the entity should be rendered; otherwise false.
getControllers
