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 TypeMethodDescriptionactions()All registered actions of this entity.voidaddController(IEntityController controller) Adds a controller to the entity.voidaddEntityRenderListener(EntityRenderListener listener) Adds the specifiedEntityRenderListenerto receive events and callbacks about the rendering process of entities.voidaddListener(EntityListener listener) Adds aEntityListenerto this entity that fires whenever the entity is added to or removed from the environment.voidAdds a tag to the entity.voidaddTransformListener(EntityTransformListener listener) Adds aEntityTransformListenerto receive transform events for this entity.Gets the entities animation controller.voidAttaches all controllers to this entity.behavior()Gets the behavior controller of the entity.voidDetaches all controllers from this entity.doublegetAngle()Gets the bounding box of the entity.Gets the center point of the entity.<T extends IEntityController>
TgetController(Class<T> clss) Gets a specific controller of the entity.Gets the environment the entity was loaded to or null if it is not loaded.doubleGets the height of the entity.Gets the location of the entity.intgetMapId()Gets the map ID of the entity.getName()Gets the name of this entity.Gets the custom properties of the entity.Gets the render type of the entity.getTags()Gets the list of tags associated with the entity.doublegetWidth()Gets the width of the entity.doublegetX()Gets the X coordinate of the entity.doublegetY()Gets the Y coordinate of the entity.booleanChecks if the entity has the specified tag.booleanisLoaded()Indicates whether this entity is loaded on the currently active environment.booleanChecks if the entity is visible.voidloaded(Environment environment) This method provides the possibility to implement behavior whenever this entity was added to the environment.voidonMessage(EntityMessageListener listener) Adds aEntityMessageListenerto receive messages sent to this entity.voidonMessage(String message, EntityMessageListener listener) Adds aEntityMessageListenerto receive messages with a specific content sent to this entity.voidonRendered(EntityRenderedListener listener) Adds the specifiedEntityRenderedListenerto receive events when entities were rendered.voidPerforms anEntityActionthat was previously registered for this entity.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) Removes aEntityListenerfrom this entity.voidremoveListener(EntityMessageListener listener) Removes aEntityMessageListenerfrom this entity.voidremoveListener(EntityRenderedListener listener) Removes the specifiedEntityRenderedListener.voidremoveListener(EntityRenderListener listener) Removes the specifiedEntityRenderListener.voidremoveListener(EntityTransformListener listener) Removes aEntityTransformListenerfrom this entity.voidRemoves a tag from the entity.booleanDetermines whether this entity is being rendered with the layer it's originating from.sendMessage(Object sender, String message) Sends a message from the specified sender to this entity.voidsetAngle(double angle) Sets the angle (in degrees) in which the entity is directed.<T extends IEntityController>
voidsetController(Class<T> clss, T controller) Sets a specific controller for the entity.voidsetHeight(double height) Sets the height of the entity.voidsetLocation(double x, double y) Sets the location of the entity.voidsetLocation(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.voidSets the name of the entity.voidsetRenderType(RenderType renderType) Sets the render type of the entity.voidsetRenderWithLayer(boolean renderWithLayer) Sets whether the entity should be rendered with its layer.voidsetSize(double width, double height) Sets the size of the entity.voidsetVisible(boolean visible) Sets the visibility of the entity.voidsetWidth(double width) Sets the width of the entity.voidsetX(double x) Sets the X coordinate of the entity.voidsetY(double y) Sets the Y coordinate of the entity.
-
Method Details
-
onMessage
Adds aEntityMessageListenerto receive messages sent to this entity.- Parameters:
listener- TheEntityMessageListenerto add.
-
onMessage
Adds aEntityMessageListenerto receive messages with a specific content sent to this entity.- Parameters:
message- The message content to listen for.listener- TheEntityMessageListenerto add.
-
addTransformListener
Adds aEntityTransformListenerto receive transform events for this entity.- Parameters:
listener- TheEntityTransformListenerto add.
-
addListener
Adds aEntityListenerto this entity that fires whenever the entity is added to or removed from the environment.- Parameters:
listener- TheEntityListenerto add.
-
removeListener
Removes aEntityMessageListenerfrom this entity.- Parameters:
listener- TheEntityMessageListenerto remove.
-
removeListener
Removes aEntityTransformListenerfrom this entity.- Parameters:
listener- TheEntityTransformListenerto remove.
-
removeListener
Removes aEntityListenerfrom this entity.- Parameters:
listener- TheEntityListenerto remove.
-
onRendered
Adds the specifiedEntityRenderedListenerto receive events when entities were rendered.- Parameters:
listener- TheEntityRenderedListenerto add.
-
removeListener
Removes the specifiedEntityRenderedListener.- Parameters:
listener- TheEntityRenderedListenerto remove.
-
addEntityRenderListener
Adds the specifiedEntityRenderListenerto receive events and callbacks about the rendering process of entities.- Parameters:
listener- TheEntityRenderListenerto add.
-
removeListener
Removes the specifiedEntityRenderListener.- Parameters:
listener- TheEntityRenderListenerto 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:
-
isVisible
boolean isVisible()Checks if the entity is visible.- Returns:
- True if the entity is visible; otherwise false.
-
setVisible
void setVisible(boolean visible) Sets the visibility of the entity.- Parameters:
visible- True to make the entity visible; false to make it invisible.
-
behavior
IBehaviorController behavior()Gets the behavior controller of the entity.- Returns:
- The behavior controller of the entity.
-
addController
Adds a controller to the entity.- Parameters:
controller- The controller to add.
-
setController
Sets a specific controller for the entity.- Type Parameters:
T- The type of the controller.- Parameters:
clss- The class of the controller.controller- The controller to set.
-
getController
Gets a specific controller of the entity.- Type Parameters:
T- The type of the controller.- Parameters:
clss- The class of the controller.- Returns:
- The controller of the specified type.
-
actions
EntityActionMap actions()All registered actions of this entity.- Returns:
- The EntityActionMap that holds all registered EntityActions for this instance.
- See Also:
-
perform
Performs anEntityActionthat 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:
-
register
Registers anEntityActionwith 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:
-
detachControllers
void detachControllers()Detaches all controllers from this entity. -
attachControllers
void attachControllers()Attaches all controllers to this entity. -
getBoundingBox
Rectangle2D getBoundingBox()Gets the bounding box of the entity.- Returns:
- The bounding box of the entity.
-
getCenter
-
getHeight
double getHeight()Gets the height of the entity.- Returns:
- The height of the entity.
-
getLocation
-
getMapId
int getMapId()Gets the map ID of the entity.- Returns:
- The map ID of the entity.
-
getName
-
getRenderType
RenderType getRenderType()Gets the render type of the entity.- Returns:
- The render type of the entity.
-
renderWithLayer
boolean renderWithLayer()Determines 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 its layer.This can only be used, of course, if the entity is related to a
MapObject.
This defaults tofalseif 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:
-
getWidth
double getWidth()Gets the width of the entity.- Returns:
- The width of the entity.
-
getX
double getX()Gets the X coordinate of the entity.- Returns:
- The X coordinate of the entity.
-
getY
double getY()Gets the Y coordinate of the entity.- Returns:
- The Y coordinate of the entity.
-
sendMessage
-
setHeight
void setHeight(double height) Sets the height of the entity.- Parameters:
height- The new height of the entity.
-
setLocation
void setLocation(double x, double y) Sets the location of the entity.- Parameters:
x- The X coordinate of the new location.y- The Y coordinate of the new location.
-
hasTag
Checks if the entity has the specified tag.- Parameters:
tag- The tag to check for.- Returns:
- True if the entity has the tag; otherwise false.
-
getTags
-
addTag
-
removeTag
-
setLocation
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
Sets the name of the entity.- Parameters:
name- The new name of the entity.
-
setRenderType
Sets the render type of the entity.- Parameters:
renderType- The new render type of the entity.
-
setRenderWithLayer
void setRenderWithLayer(boolean renderWithLayer) Sets whether the entity should be rendered with its layer.- Parameters:
renderWithLayer- True to render with the layer; otherwise false.
-
setSize
void setSize(double width, double height) Sets the size of the entity.- Parameters:
width- The new width of the entity.height- The new height of the entity.
-
setWidth
void setWidth(double width) Sets the width of the entity.- Parameters:
width- The new width of the entity.
-
setX
void setX(double x) Sets the X coordinate of the entity.- Parameters:
x- The new X coordinate of the entity.
-
setY
void setY(double y) Sets the Y coordinate of the entity.- Parameters:
y- The new Y coordinate of the entity.
-
getProperties
ICustomPropertyProvider getProperties()Gets the custom properties of the entity.- Returns:
- The custom property provider of the entity.
-
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:
-
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:
-
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:
-