Interface IEntity

  • Method Details

    • onMessage

      void onMessage(EntityMessageListener listener)
      Adds a EntityMessageListener to receive messages sent to this entity.
      Parameters:
      listener - The EntityMessageListener to add.
    • onMessage

      void onMessage(String message, EntityMessageListener listener)
      Adds a EntityMessageListener to receive messages with a specific content sent to this entity.
      Parameters:
      message - The message content to listen for.
      listener - The EntityMessageListener to add.
    • addTransformListener

      void addTransformListener(EntityTransformListener listener)
      Adds a EntityTransformListener to receive transform events for this entity.
      Parameters:
      listener - The EntityTransformListener to add.
    • addListener

      void addListener(EntityListener listener)
      Adds a EntityListener to this entity that fires whenever the entity is added to or removed from the environment.
      Parameters:
      listener - The EntityListener to add.
    • removeListener

      void removeListener(EntityMessageListener listener)
      Removes a EntityMessageListener from this entity.
      Parameters:
      listener - The EntityMessageListener to remove.
    • removeListener

      void removeListener(EntityTransformListener listener)
      Removes a EntityTransformListener from this entity.
      Parameters:
      listener - The EntityTransformListener to remove.
    • removeListener

      void removeListener(EntityListener listener)
      Removes a EntityListener from this entity.
      Parameters:
      listener - The EntityListener to remove.
    • onRendered

      void onRendered(EntityRenderedListener listener)
      Adds the specified EntityRenderedListener to receive events when entities were rendered.
      Parameters:
      listener - The EntityRenderedListener to add.
    • removeListener

      void removeListener(EntityRenderedListener listener)
      Removes the specified EntityRenderedListener.
      Parameters:
      listener - The EntityRenderedListener to remove.
    • addEntityRenderListener

      void addEntityRenderListener(EntityRenderListener listener)
      Adds the specified EntityRenderListener to receive events and callbacks about the rendering process of entities.
      Parameters:
      listener - The EntityRenderListener to add.
    • removeListener

      void removeListener(EntityRenderListener listener)
      Removes the specified EntityRenderListener.
      Parameters:
      listener - The EntityRenderListener 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

      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

      Gets the behavior controller of the entity.
      Returns:
      The behavior controller of the entity.
    • addController

      void addController(IEntityController controller)
      Adds a controller to the entity.
      Parameters:
      controller - The controller to add.
    • setController

      <T extends IEntityController> void setController(Class<T> clss, T controller)
      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

      <T extends IEntityController> T getController(Class<T> clss)
      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

      void perform(String actionName)
      Performs an EntityAction 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:
    • register

      EntityAction register(String name, Runnable action)
      Registers an EntityAction with the specified name. It's later possible to execute these actions on the entity by using the Entity.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

      Point2D getCenter()
      Gets the center point of the entity.
      Returns:
      The center point of the entity.
    • getHeight

      double getHeight()
      Gets the height of the entity.
      Returns:
      The height of the entity.
    • getLocation

      Point2D getLocation()
      Gets the location of the entity.
      Returns:
      The location of the entity.
    • getMapId

      int getMapId()
      Gets the map ID of the entity.
      Returns:
      The map ID of the entity.
    • getName

      String getName()
      Gets the name of this entity.
      Returns:
      The name of this entity.
    • 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 specified RenderType and 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 to false if not explicitly set on the MapObject.

      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

      String sendMessage(Object sender, String message)
      Sends a message from the specified sender to this entity.
      Parameters:
      sender - The sender of the message.
      message - The message to send.
      Returns:
      The response to the message.
    • 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

      boolean hasTag(String tag)
      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

      List<String> getTags()
      Gets the list of tags associated with the entity.
      Returns:
      A list of tags associated with the entity.
    • addTag

      void addTag(String tag)
      Adds a tag to the entity.
      Parameters:
      tag - The tag to add.
    • removeTag

      void removeTag(String tag)
      Removes a tag from the entity.
      Parameters:
      tag - The tag to remove.
    • setLocation

      void setLocation(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 this IEntity
    • setName

      void setName(String name)
      Sets the name of the entity.
      Parameters:
      name - The new name of the entity.
    • setRenderType

      void setRenderType(RenderType renderType)
      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

      void loaded(Environment environment)
      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

      void removed(Environment environment)
      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: