Record Class ColliderShapeAABB

java.lang.Object
java.lang.Record
technology.sola.engine.physics.component.collider.ColliderShapeAABB
Record Components:
width - the width of the axis-aligned bounding box
height - the height of the axis-aligned bounding box
All Implemented Interfaces:
ColliderShape<Rectangle>

@NullMarked public record ColliderShapeAABB(float width, float height) extends Record implements ColliderShape<Rectangle>
ColliderShapeAABB is a ColliderShape implementation for Axis-Aligned Bounding Boxes which utilize a Rectangle for its geometric shape representation.
  • Constructor Details

    • ColliderShapeAABB

      public ColliderShapeAABB()
      Creates an instance with height and width both set to 1.
    • ColliderShapeAABB

      public ColliderShapeAABB(float width, float height)
      Creates an instance of a ColliderShapeAABB record class.
      Parameters:
      width - the value for the width record component
      height - the value for the height record component
  • Method Details

    • type

      public ColliderType type()
      Description copied from interface: ColliderShape
      Gets the ColliderType of this collider.
      Specified by:
      type in interface ColliderShape<Rectangle>
      Returns:
      the ColliderType of this collider
    • getBoundingBox

      public Rectangle getBoundingBox(TransformComponent transformComponent, float offsetX, float offsetY)
      Description copied from interface: ColliderShape
      Returns the bounding box for this ColliderShape.
      Specified by:
      getBoundingBox in interface ColliderShape<Rectangle>
      Parameters:
      transformComponent - the TransformComponent of the entity
      offsetX - the x offset of the collider
      offsetY - the y offset of the collider
      Returns:
      the bounding box
    • getShape

      public Rectangle getShape(TransformComponent transformComponent, float offsetX, float offsetY)
      Description copied from interface: ColliderShape
      Gets the geometric Shape for this collider shape.
      Specified by:
      getShape in interface ColliderShape<Rectangle>
      Parameters:
      transformComponent - the TransformComponent for the Entity
      offsetX - the x offset off the collider
      offsetY - the y offset of the collider
      Returns:
      the geometric Shape
    • debugRender

      public void debugRender(Renderer renderer, TransformComponent transformComponent, float offsetX, float offsetY)
      Description copied from interface: ColliderShape
      Renders debug information for the collider shape.
      Specified by:
      debugRender in interface ColliderShape<Rectangle>
      Parameters:
      renderer - the Renderer
      transformComponent - the Entity's TransformComponent
      offsetX - the collider shape x-axis offset
      offsetY - the collider shape y-axis offset
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • width

      public float width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • height

      public float height()
      Returns the value of the height record component.
      Returns:
      the value of the height record component