public abstract class Entity extends java.lang.Object implements IEntity
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANY_MESSAGE |
Modifier | Constructor and Description |
---|---|
protected |
Entity()
Instantiates a new entity.
|
protected |
Entity(boolean renderWithLayer) |
protected |
Entity(int mapId) |
protected |
Entity(int mapId,
java.lang.String name) |
protected |
Entity(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
EntityActionMap |
actions()
All registered actions of this entity.
|
void |
addController(IEntityController controller) |
void |
addListener(EntityListener listener) |
void |
addMessageListener(MessageListener listener) |
void |
addMessageListener(java.lang.String message,
MessageListener listener) |
void |
addTag(java.lang.String tag) |
void |
addTransformListener(EntityTransformListener listener) |
void |
attachControllers() |
void |
detachControllers() |
double |
getAngle() |
IEntityAnimationController |
getAnimationController() |
IBehaviorController |
getBehaviorController() |
java.awt.geom.Rectangle2D |
getBoundingBox() |
java.awt.geom.Point2D |
getCenter() |
<T extends IEntityController> |
getController(java.lang.Class<T> clss) |
protected EntityControllers |
getControllers() |
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.
|
void |
loaded(Environment environment)
This method provides the possibility to implement behavior whenever this entity was added to the environment.
|
void |
perform(java.lang.String actionName)
Performs an
EntityAction that was previously registered for this entity. |
EntityAction |
register(java.lang.String name,
java.lang.Runnable action)
Registers an
EntityAction 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 |
removeMessageListener(MessageListener listener) |
void |
removeTag(java.lang.String tag) |
void |
removeTransformListener(EntityTransformListener listener) |
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> |
setController(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 |
setWidth(double width) |
void |
setX(double x) |
void |
setY(double y) |
java.lang.String |
toString() |
public static final java.lang.String ANY_MESSAGE
protected Entity()
protected Entity(boolean renderWithLayer)
protected Entity(int mapId)
protected Entity(java.lang.String name)
protected Entity(int mapId, java.lang.String name)
public void addTransformListener(EntityTransformListener listener)
addTransformListener
in interface IEntity
public void attachControllers()
attachControllers
in interface IEntity
public void detachControllers()
detachControllers
in interface IEntity
public void removeTransformListener(EntityTransformListener listener)
removeTransformListener
in interface IEntity
public void addListener(EntityListener listener)
addListener
in interface IEntity
public void removeListener(EntityListener listener)
removeListener
in interface IEntity
public void addMessageListener(MessageListener listener)
addMessageListener
in interface IEntity
public void addMessageListener(java.lang.String message, MessageListener listener)
addMessageListener
in interface IEntity
public void removeMessageListener(MessageListener listener)
removeMessageListener
in interface IEntity
public ICustomPropertyProvider getProperties()
getProperties
in interface IEntity
public IEntityAnimationController getAnimationController()
getAnimationController
in interface IEntity
public IBehaviorController getBehaviorController()
getBehaviorController
in interface IEntity
public void addController(IEntityController controller)
addController
in interface IEntity
public <T extends IEntityController> void setController(java.lang.Class<T> clss, T controller)
setController
in interface IEntity
public <T extends IEntityController> T getController(java.lang.Class<T> clss)
getController
in interface IEntity
public java.awt.geom.Rectangle2D getBoundingBox()
getBoundingBox
in interface IEntity
public java.awt.geom.Point2D getLocation()
getLocation
in interface IEntity
public java.lang.String getName()
IEntity
public RenderType getRenderType()
getRenderType
in interface IEntity
public EntityActionMap actions()
IEntity
actions
in interface IEntity
EntityActionMap
,
IEntity.register(String, Runnable)
public void perform(java.lang.String actionName)
IEntity
EntityAction
that was previously registered for this entity.
Does nothing in case no action has been registered for the specified actionName
.
perform
in interface IEntity
actionName
- The name of the action to be performed.IEntity.actions()
,
IEntity.register(String, Runnable)
public EntityAction register(java.lang.String name, java.lang.Runnable action)
IEntity
EntityAction
with the specified name.
It's later possible to execute these actions on the entity by using the Entity.perform(String actionName)
method.register
in interface IEntity
name
- The name of the action to be registered.action
- The action to be performed by the entity.IEntity.perform(String)
,
IEntity.actions()
public java.lang.String sendMessage(java.lang.Object sender, java.lang.String message)
sendMessage
in interface IEntity
public void setLocation(double x, double y)
setLocation
in interface IEntity
public void setLocation(java.awt.geom.Point2D location)
setLocation
in interface IEntity
location
- the new map locationpublic void setMapId(int mapId)
public void setRenderType(RenderType renderType)
setRenderType
in interface IEntity
public java.util.List<java.lang.String> getTags()
public void setAngle(double angle)
IEntity
public java.lang.String toString()
toString
in class java.lang.Object
public Environment getEnvironment()
IEntity
getEnvironment
in interface IEntity
public void loaded(Environment environment)
IEntity
loaded
in interface IEntity
environment
- The environment that the entity was added toIEntity.addListener(EntityListener)
public void removed(Environment environment)
IEntity
removed
in interface IEntity
environment
- The environment that the entity was removed fromIEntity.addListener(EntityListener)
public boolean isLoaded()
IEntity
isLoaded
in interface IEntity
GameWorld.environment()
,
IEntity.loaded(Environment)
,
IEntity.removed(Environment)
public boolean renderWithLayer()
IEntity
RenderType
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 to false
if not explicitly set on the MapObject
.
renderWithLayer
in interface IEntity
ILayer.isVisible()
,
IMapObjectLayer.getMapObjects()
,
Environment.getEntitiesByLayer(int)
,
Environment.getEntitiesByLayer(String)
public void setRenderWithLayer(boolean renderWithLayer)
setRenderWithLayer
in interface IEntity
protected EntityControllers getControllers()