public class CompositeHitbox extends Hitbox
A CompositeHitbox is a Hitbox that is composed of other Hitboxes whose positions, flipped statuses, and angles of rotation are all relative to those of the CompositeHitbox itself. Each of a CompositeHitbox's component Hitboxes is assigned to it with an integer ID that is unique in the context of the CompositeHitbox. Only one Hitbox may be assigned to a given CompositeHitbox with a given ID at once. A CompositeHitbox with no component Hitboxes is a point at its absolute position that cannot overlap other Hitboxes.
Constructor and Description |
---|
CompositeHitbox(CellVector relPosition)
Constructs a CompositeHitbox with the specified relative position.
|
CompositeHitbox(long relX,
long relY)
Constructs a CompositeHitbox with the specified relative position.
|
Modifier and Type | Method and Description |
---|---|
void |
clearComponents()
Removes all of this CompositeHitbox's component Hitboxes from it.
|
long |
getBottomEdge()
Returns the y-coordinate of this Hitbox's absolute bottom boundary.
|
Hitbox |
getComponent(int id)
Returns the component Hitbox that is assigned to this CompositeHitbox
with the specified ID.
|
java.util.Map<java.lang.Integer,Hitbox> |
getComponents()
Returns an unmodifiable Map to this CompositeHitbox's components from
their respective IDs.
|
CompositeHitbox |
getCopy()
Returns a copy of this Hitbox with its relative position at the origin
that is not flipped or rotated.
|
long |
getLeftEdge()
Returns the x-coordinate of this Hitbox's absolute left boundary.
|
long |
getRightEdge()
Returns the x-coordinate of this Hitbox's absolute right boundary.
|
long |
getTopEdge()
Returns the y-coordinate of this Hitbox's absolute top boundary.
|
boolean |
setComponent(int id,
Hitbox hitbox)
Sets the component Hitbox that is assigned to this CompositeHitbox with
the specified ID to the specified Hitbox.
|
angleTo, changeRelAngle, changeRelPosition, changeRelPosition, changeRelX, changeRelY, distanceTo, getAbsAngle, getAbsAngleX, getAbsAngleY, getAbsPosition, getAbsX, getAbsXFlip, getAbsXSign, getAbsY, getAbsYFlip, getAbsYSign, getComponentOf, getGameState, getHeight, getObject, getRelAngle, getRelAngleX, getRelAngleY, getRelPosition, getRelX, getRelXFlip, getRelXSign, getRelY, getRelYFlip, getRelYSign, getWidth, isSolid, overlap, overlaps, relFlipX, relFlipY, setRelAngle, setRelPosition, setRelPosition, setRelX, setRelXFlip, setRelY, setRelYFlip, setSolid, setSurfaceSolid, surfaceIsSolid
public CompositeHitbox(CellVector relPosition)
relPosition
- This CompositeHitbox's relative positionpublic CompositeHitbox(long relX, long relY)
relX
- The x-coordinate of this CompositeHitbox's relative positionrelY
- The y-coordinate of this CompositeHitbox's relative positionpublic final CompositeHitbox getCopy()
Hitbox
public final java.util.Map<java.lang.Integer,Hitbox> getComponents()
public final Hitbox getComponent(int id)
id
- The ID of the component Hitbox to be returnedpublic final boolean setComponent(int id, Hitbox hitbox)
id
- The ID with which to assign the specified Hitboxhitbox
- The Hitbox to add as a component with the specified IDpublic final void clearComponents()
public final long getLeftEdge()
Hitbox
getLeftEdge
in class Hitbox
public final long getRightEdge()
Hitbox
getRightEdge
in class Hitbox
public final long getTopEdge()
Hitbox
getTopEdge
in class Hitbox
public final long getBottomEdge()
Hitbox
getBottomEdge
in class Hitbox