T
- The subclass of CellGame that uses the SpaceStates that can use
this CompositeHitboxpublic class CompositeHitbox<T extends CellGame> extends Hitbox<T>
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)
Creates a new CompositeHitbox with the specified relative position.
|
CompositeHitbox(long relX,
long relY)
Creates a new 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<T> |
getComponent(int id)
Returns the component Hitbox that is assigned to this CompositeHitbox
with the specified ID.
|
java.util.Map<java.lang.Integer,Hitbox<T>> |
getComponents()
Returns all of this CompositeHitbox's components as values in a Map with
their respective IDs as keys.
|
Hitbox<T> |
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<T> 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, getObject, getRelAngle, getRelAngleX, getRelAngleY, getRelPosition, getRelX, getRelXFlip, getRelXSign, getRelY, getRelYFlip, getRelYSign, 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 Hitbox<T> getCopy()
Hitbox
public final java.util.Map<java.lang.Integer,Hitbox<T>> getComponents()
public final Hitbox<T> getComponent(int id)
id
- The ID of the component Hitbox to be returnedpublic final boolean setComponent(int id, Hitbox<T> 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<T extends CellGame>
public final long getRightEdge()
Hitbox
getRightEdge
in class Hitbox<T extends CellGame>
public final long getTopEdge()
Hitbox
getTopEdge
in class Hitbox<T extends CellGame>
public final long getBottomEdge()
Hitbox
getBottomEdge
in class Hitbox<T extends CellGame>