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 IEntityMethod 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()voiddetachControllers()doublegetAngle()java.awt.geom.Rectangle2DgetBoundingBox()java.awt.geom.Point2DgetCenter()<T extends IEntityController>
TgetController(java.lang.Class<T> clss)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()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)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)voidsetVisible(boolean visible)voidsetWidth(double width)voidsetX(double x)voidsetY(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 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:
actions(),register(String, Runnable)
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:
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 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.- 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)
