Interface IEntity
- All Known Subinterfaces:
ICollisionEntity
,ICombatEntity
,IMobileEntity
- All Known Implementing Classes:
CollisionBox
,CollisionEntity
,CombatEntity
,Creature
,Emitter
,Entity
,EntityEmitter
,LightSource
,MapArea
,Prop
,SoundSource
,Spawnpoint
,StaticShadow
,Trigger
public interface IEntity
Method Summary
Modifier and Type Method Description EntityActionMap
actions()
All registered actions of this entity.void
addController(IEntityController controller)
void
addEntityRenderListener(EntityRenderListener listener)
Adds the specified entity render listener to receive events and callbacks about the rendering process of entities.void
addListener(EntityListener listener)
void
addTag(java.lang.String tag)
void
addTransformListener(EntityTransformListener listener)
IEntityAnimationController<?>
animations()
Gets the entities animation controller.void
attachControllers()
IBehaviorController
behavior()
void
detachControllers()
double
getAngle()
java.awt.geom.Rectangle2D
getBoundingBox()
java.awt.geom.Point2D
getCenter()
<T extends IEntityController>
TgetController(java.lang.Class<T> clss)
Environment
getEnvironment()
Gets the environment the entity was loaded to or null if it is not loaded.double
getHeight()
java.awt.geom.Point2D
getLocation()
int
getMapId()
java.lang.String
getName()
Gets the name of this entity.ICustomPropertyProvider
getProperties()
RenderType
getRenderType()
java.util.List<java.lang.String>
getTags()
double
getWidth()
double
getX()
double
getY()
boolean
hasTag(java.lang.String tag)
boolean
isLoaded()
Indicates whether this entity is loaded on the currently active environment.boolean
isVisible()
void
loaded(Environment environment)
This method provides the possibility to implement behavior whenever this entity was added to the environment.void
onMessage(EntityMessageListener listener)
void
onMessage(java.lang.String message, EntityMessageListener listener)
void
onRendered(EntityRenderedListener listener)
Adds the specified entity rendered listener to receive events when entities were rendered.void
perform(java.lang.String actionName)
Performs anEntityAction
that was previously registered for this entity.EntityAction
register(java.lang.String name, java.lang.Runnable action)
Registers anEntityAction
with the specified name.void
removed(Environment environment)
This method provides the possibility to implement behavior whenever this entity was removed from the environment.void
removeListener(EntityListener listener)
void
removeListener(EntityMessageListener listener)
void
removeListener(EntityRenderedListener listener)
Removes the specified entity rendered listener.void
removeListener(EntityRenderListener listener)
Removes the specified entity render listener.void
removeListener(EntityTransformListener listener)
void
removeTag(java.lang.String tag)
boolean
renderWithLayer()
Determines whether this entity is being rendered with the layer it's originating from.java.lang.String
sendMessage(java.lang.Object sender, java.lang.String message)
void
setAngle(double angle)
Sets the angle (in degrees) in which the entity is directed.<T extends IEntityController>
voidsetController(java.lang.Class<T> clss, T controller)
void
setHeight(double height)
void
setLocation(double x, double y)
void
setLocation(java.awt.geom.Point2D location)
Sets the map location.void
setMapId(int mapId)
Sets an id which should only be filled when an entity gets added due to map information.void
setName(java.lang.String name)
void
setRenderType(RenderType renderType)
void
setRenderWithLayer(boolean renderWithLayer)
void
setSize(double width, double height)
void
setVisible(boolean visible)
void
setWidth(double width)
void
setX(double x)
void
setY(double y)
Method Details
onMessage
onMessage
addTransformListener
addListener
removeListener
removeListener
removeListener
onRendered
Adds the specified entity rendered listener to receive events when entities were rendered.- Parameters:
listener
- The listener to add.
removeListener
Removes the specified entity rendered listener.- Parameters:
listener
- The listener to remove.
addEntityRenderListener
Adds the specified entity render listener to receive events and callbacks about the rendering process of entities.- Parameters:
listener
- The listener to add.
removeListener
Removes the specified entity render listener.- Parameters:
listener
- The listener to remove.
getAngle
double getAngle()setAngle
void setAngle(double angle)Sets the angle (in degrees) in which the entity is directed.- Parameters:
angle
- the new angle in degrees
animations
IEntityAnimationController<?> animations()Gets the entities animation controller.- Returns:
- The entities animation controller or null if none was registered.
- See Also:
RenderEngine.renderEntity(java.awt.Graphics2D, IEntity)
isVisible
boolean isVisible()setVisible
void setVisible(boolean visible)behavior
IBehaviorController behavior()addController
setController
getController
actions
EntityActionMap actions()All registered actions of this entity.- Returns:
- The EntityActionMap that holds all registered EntityActions for this instance.
- See Also:
EntityActionMap
,register(String, Runnable)
perform
void perform(java.lang.String actionName)Performs anEntityAction
that was previously registered for this entity.Does nothing in case no action has been registered for the specified
actionName
.- Parameters:
actionName
- The name of the action to be performed.- See Also:
actions()
,register(String, Runnable)
register
Registers anEntityAction
with the specified name. It's later possible to execute these actions on the entity by using theEntity.perform(String actionName)
method.- 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:
perform(String)
,actions()
detachControllers
void detachControllers()attachControllers
void attachControllers()getBoundingBox
java.awt.geom.Rectangle2D getBoundingBox()getCenter
java.awt.geom.Point2D getCenter()getHeight
double getHeight()getLocation
java.awt.geom.Point2D getLocation()getMapId
int getMapId()getName
java.lang.String getName()Gets the name of this entity.- Returns:
- The name of this entity.
getRenderType
RenderType getRenderType()renderWithLayer
boolean renderWithLayer()Determines whether this entity is being rendered with the layer it's originating from. This ignores the specifiedRenderType
and 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 tofalse
if not explicitly set on theMapObject
.- 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)
getWidth
double getWidth()getX
double getX()getY
double getY()sendMessage
java.lang.String sendMessage(java.lang.Object sender, java.lang.String message)setHeight
void setHeight(double height)setLocation
void setLocation(double x, double y)hasTag
boolean hasTag(java.lang.String tag)getTags
java.util.List<java.lang.String> getTags()addTag
void addTag(java.lang.String tag)removeTag
void removeTag(java.lang.String tag)setLocation
void setLocation(java.awt.geom.Point2D location)Sets the map location.- Parameters:
location
- the new map location
setMapId
void setMapId(int mapId)Sets an id which should only be filled when an entity gets added due to map information.- Parameters:
mapId
- The unique map ID for thisIEntity
setName
void setName(java.lang.String name)setRenderType
setRenderWithLayer
void setRenderWithLayer(boolean renderWithLayer)setSize
void setSize(double width, double height)setWidth
void setWidth(double width)setX
void setX(double x)setY
void setY(double y)getProperties
ICustomPropertyProvider getProperties()getEnvironment
Environment getEnvironment()Gets the environment the entity was loaded to or null if it is not loaded.- Returns:
- The entity's environment.
loaded
This method provides the possibility to implement behavior whenever this entity was added to the environment.- Parameters:
environment
- The environment that the entity was added to- See Also:
addListener(EntityListener)
removed
This method provides the possibility to implement behavior whenever this entity was removed from the environment.- Parameters:
environment
- The environment that the entity was removed from- See Also:
addListener(EntityListener)
isLoaded
boolean isLoaded()Indicates whether this entity is loaded on the currently active environment.- Returns:
- True if the entity is loaded on the game's currently active environment; otherwise false.
- See Also:
GameWorld.environment()
,loaded(Environment)
,removed(Environment)