Class CollisionEntity

java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
All Implemented Interfaces:
EntityRenderedListener, EntityRenderListener, ICollisionEntity, IEntity, Tweenable, EventListener
Direct Known Subclasses:
CollisionBox, CombatEntity, Trigger

public abstract class CollisionEntity extends Entity implements ICollisionEntity
  • Constructor Details

    • CollisionEntity

      protected CollisionEntity()
  • Method Details

    • getCollisionBox

      public static Rectangle2D getCollisionBox(Point2D location, double entityWidth, double entityHeight, double collisionBoxWidth, double collisionBoxHeight, Align align, Valign valign)
    • canCollideWith

      public boolean canCollideWith(ICollisionEntity otherEntity)
      Description copied from interface: ICollisionEntity
      Determines if this entity can collide with another specified ICollisionEntity. This method should be implemented to define custom collision logic between entities.
      Specified by:
      canCollideWith in interface ICollisionEntity
      Parameters:
      otherEntity - The other ICollisionEntity to check collision capability with.
      Returns:
      true if this entity can collide with the specified entity; false otherwise.
    • getCollisionBoxAlign

      public Align getCollisionBoxAlign()
      Description copied from interface: ICollisionEntity
      Retrieves the horizontal alignment of the entity's collision box. This alignment determines the horizontal positioning of the collision box relative to the entity's location.
      Specified by:
      getCollisionBoxAlign in interface ICollisionEntity
      Returns:
      The Align representing the horizontal alignment of the collision box.
    • getCollisionBox

      public Rectangle2D getCollisionBox()
      Gets the collision box.
      Specified by:
      getCollisionBox in interface ICollisionEntity
      Returns:
      the collision box
    • getCollisionBox

      public Rectangle2D getCollisionBox(Point2D location)
      Gets the collision box.
      Specified by:
      getCollisionBox in interface ICollisionEntity
      Parameters:
      location - the location
      Returns:
      the collision box
    • getCollisionBoxHeight

      public double getCollisionBoxHeight()
      Description copied from interface: ICollisionEntity
      Retrieves the height of the entity's collision box. This height is used in collision detection to determine the vertical bounds of the entity.
      Specified by:
      getCollisionBoxHeight in interface ICollisionEntity
      Returns:
      The height of the collision box in pixels.
    • getCollisionBoxWidth

      public double getCollisionBoxWidth()
      Description copied from interface: ICollisionEntity
      Retrieves the width of the entity's collision box. This width is used in collision detection to determine the horizontal bounds of the entity.
      Specified by:
      getCollisionBoxWidth in interface ICollisionEntity
      Returns:
      The width of the collision box in pixels.
    • getCollisionBoxCenter

      public Point2D getCollisionBoxCenter()
      Description copied from interface: ICollisionEntity
      Gets the center Point2D of the entities collision box.
      Specified by:
      getCollisionBoxCenter in interface ICollisionEntity
      Returns:
      The center Point2D of the entities collision box
    • getCollisionBoxValign

      public Valign getCollisionBoxValign()
      Description copied from interface: ICollisionEntity
      Retrieves the vertical alignment of the entity's collision box. This alignment determines the vertical positioning of the collision box relative to the entity's location.
      Specified by:
      getCollisionBoxValign in interface ICollisionEntity
      Returns:
      The Valign representing the vertical alignment of the collision box.
    • getCollisionType

      public Collision getCollisionType()
      Description copied from interface: ICollisionEntity
      Retrieves the collision type of this entity. The collision type defines how this entity interacts with other entities in terms of physical collisions.
      Specified by:
      getCollisionType in interface ICollisionEntity
      Returns:
      The Collision type of this entity, indicating how it should be treated in collision detection and handling.
    • getTweenValues

      public float[] getTweenValues(TweenType tweenType)
      Description copied from interface: Tweenable
      Gets one or many values from the target object associated to the given tween type. It is used by the Tween Engine to determine starting values.
      Specified by:
      getTweenValues in interface Tweenable
      Overrides:
      getTweenValues in class Entity
      Parameters:
      tweenType - The tween type of this interpolation, determining which values are modified.
      Returns:
      The array of current tween values.
    • setTweenValues

      public void setTweenValues(TweenType tweenType, float[] newValues)
      Description copied from interface: Tweenable
      This method is called in a Tween's update() method to set the new interpolated values.
      Specified by:
      setTweenValues in interface Tweenable
      Overrides:
      setTweenValues in class Entity
      Parameters:
      tweenType - The tween type of this interpolation, determining which values are modified.
      newValues - The new values determined by the tween equation.
    • hasCollision

      public boolean hasCollision()
      Checks for collision.
      Specified by:
      hasCollision in interface ICollisionEntity
      Returns:
      true, if successful
    • setCollision

      public void setCollision(boolean collision)
      Sets the collision.
      Specified by:
      setCollision in interface ICollisionEntity
      Parameters:
      collision - the new collision
    • setCollisionBoxAlign

      public void setCollisionBoxAlign(Align align)
      Description copied from interface: ICollisionEntity
      Sets the horizontal alignment of the entity's collision box.
      Specified by:
      setCollisionBoxAlign in interface ICollisionEntity
      Parameters:
      align - The Align representing the horizontal alignment of the collision box.
    • setCollisionBoxHeight

      public void setCollisionBoxHeight(double collisionBoxHeight)
      Description copied from interface: ICollisionEntity
      Sets the height of the entity's collision box.
      Specified by:
      setCollisionBoxHeight in interface ICollisionEntity
      Parameters:
      collisionBoxHeight - The height of the collision box in pixels.
    • setCollisionBoxValign

      public void setCollisionBoxValign(Valign valign)
      Description copied from interface: ICollisionEntity
      Sets the vertical alignment of the entity's collision box.
      Specified by:
      setCollisionBoxValign in interface ICollisionEntity
      Parameters:
      valign - The Valign representing the vertical alignment of the collision box.
    • setCollisionBoxWidth

      public void setCollisionBoxWidth(double collisionBoxWidth)
      Description copied from interface: ICollisionEntity
      Sets the width of the entity's collision box.
      Specified by:
      setCollisionBoxWidth in interface ICollisionEntity
      Parameters:
      collisionBoxWidth - The width of the collision box in pixels.
    • setLocation

      public void setLocation(Point2D location)
      Description copied from class: Entity
      Sets the map location.
      Specified by:
      setLocation in interface IEntity
      Overrides:
      setLocation in class Entity
      Parameters:
      location - the new map location
    • setSize

      public void setSize(double width, double height)
      Description copied from interface: IEntity
      Sets the size of the entity.
      Specified by:
      setSize in interface IEntity
      Overrides:
      setSize in class Entity
      Parameters:
      width - The new width of the entity.
      height - The new height of the entity.
    • setHeight

      public void setHeight(double height)
      Description copied from interface: IEntity
      Sets the height of the entity.
      Specified by:
      setHeight in interface IEntity
      Overrides:
      setHeight in class Entity
      Parameters:
      height - The new height of the entity.
    • setWidth

      public void setWidth(double width)
      Description copied from interface: IEntity
      Sets the width of the entity.
      Specified by:
      setWidth in interface IEntity
      Overrides:
      setWidth in class Entity
      Parameters:
      width - The new width of the entity.
    • setCollisionType

      public void setCollisionType(Collision type)
      Description copied from interface: ICollisionEntity
      Sets the collision type of this entity.
      Specified by:
      setCollisionType in interface ICollisionEntity
      Parameters:
      type - The Collision type indicating how this entity should be treated in collision detection and handling.
    • onCollision

      public void onCollision(CollisionListener listener)
      Description copied from interface: ICollisionEntity
      Registers a CollisionListener to this entity. The listener will be notified whenever this entity collides with another ICollisionEntity.
      Specified by:
      onCollision in interface ICollisionEntity
      Parameters:
      listener - The CollisionListener to be added to this entity. It should not be null.
    • removeCollisionListener

      public void removeCollisionListener(CollisionListener listener)
      Description copied from interface: ICollisionEntity
      Removes a previously registered CollisionListener from this entity. After removal, the listener will no longer receive collision events involving this entity.
      Specified by:
      removeCollisionListener in interface ICollisionEntity
      Parameters:
      listener - The CollisionListener to be removed. It should match a listener that was previously added with ICollisionEntity.onCollision(CollisionListener).
    • fireCollisionEvent

      public void fireCollisionEvent(CollisionEvent event)
      Description copied from interface: ICollisionEntity
      Triggers a collision event for this entity. This method is used to manually fire a collision event, which can be useful for custom collision handling or for simulating collisions in specific scenarios.
      Specified by:
      fireCollisionEvent in interface ICollisionEntity
      Parameters:
      event - The CollisionEvent that encapsulates the details of the collision. This includes information such as the entities involved in the collision and the collision's impact point.
    • refreshCollisionBox

      protected void refreshCollisionBox()