T
- The subclass of CellGame that uses this SpaceStatepublic class SpaceState<T extends CellGame> extends CellGameState<T,SpaceState<T>,SpaceThinker<T>,SpaceThinkerState<T>>
A SpaceState is a CellGameState that handles gameplay in a continuous two-dimensional space. Space in a SpaceState is divided into rectangular cells of equal and positive widths and heights, both of which are specified externally. A SpaceState automatically creates more cells as SpaceObjects enter where they would be if they existed.
SpaceObjects may be assigned to one SpaceState each in much the same way that Thinkers are assigned to CellGameStates. Similarly to Thinkers, the actual addition or removal of a SpaceObject to or from a SpaceState is delayed until any and all current iterations through its SpaceThinkers, SpaceObjects, or ThinkerObjects, such as the periods during which ThinkerObjects move or SpaceThinkers perform their various types of actions, have been completed. Multiple delayed instructions may be successfully given to SpaceStates regarding the same SpaceObject without having to wait until all iterations have finished.
SpaceStates use cells to organize SpaceObjects by location, improving the efficiency of processes like ThinkerObject movement that are concerned only with SpaceObjects in a small region of space. For maximum efficiency, cells should be set to be large enough that SpaceObjects do not change which cells they are in too frequently, but small enough that not too many SpaceObjects are in each cell at any one time.
Every frame, between the periods in which its SpaceThinkers perform their frameActions() and afterMovementActions(), a SpaceState moves each of its ThinkerObjects by the sum of its velocity and step multiplied by its time factor, then resets its step to (0, 0). This, along with manual calls to the ThinkerObject's doMovement() method, is when the ThinkerObject interacts with the solid surfaces of SpaceObjects in its path if it has Cell2D's standard collision mechanics enabled.
SpaceLayers may be assigned to one SpaceState each with an integer ID in the context of that SpaceState. Only one SpaceLayer may be assigned to a given SpaceState with a given ID at once. SpaceLayers with higher IDs are rendered in front of those with lower ones. SpaceLayers with positive IDs are rendered in front of the SpaceState's SpaceObjects, and SpaceLayers with negative IDs are rendered behind its SpaceObjects. SpaceLayers may not be added with an ID of 0.
HUDs may be assigned to one SpaceState each. Only one HUD may be assigned to a given SpaceState at once. A SpaceState's HUD uses the entire screen as its rendering region.
Viewports may be assigned to one SpaceState each with an integer ID in the context of that SpaceState. Only one Viewport may be assigned to a given SpaceState with a given ID at once.
Constructor and Description |
---|
SpaceState(T game,
int id,
long cellWidth,
long cellHeight,
DrawMode drawMode)
Creates a new SpaceState of the specified CellGame with the specified ID.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addObject(SpaceObject<T> object)
Adds the specified SpaceObject to this SpaceState if it is not already
assigned to a levelState.
|
<O extends SpaceObject<T>> |
boundingBoxesMeet(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns all of this SpaceState's SpaceObjects of the specified class
whose overlap Hitboxes' rectangular bounding boxes touch or intersect the
specified Hitbox's rectangular bounding box.
|
void |
clearEmptyCells()
Removes any cells that no longer have SpaceObjects in them, freeing up
the memory that they occupied.
|
void |
clearLayers()
Removes from this SpaceState all SpaceLayers that are currently assigned
to it.
|
void |
clearViewports()
Removes from this SpaceState all Viewports that are currently assigned to
it.
|
void |
frameActions(T game)
Actions for this CellGameState to take once every frame, after all of its
Thinkers have taken their frameActions().
|
long |
getCellHeight()
Returns the height of each of this SpaceState's cells.
|
long |
getCellWidth()
Returns the width of each of this SpaceState's cells.
|
DrawMode |
getDrawMode()
Returns this SpaceState's DrawMode.
|
HUD<T> |
getHUD()
Returns the HUD that is currently assigned to this SpaceState, or null if
there is none.
|
SpaceLayer<T> |
getLayer(int id)
Returns the SpaceLayer that is assigned to this SpaceState with the
specified ID.
|
int |
getNumLayers()
Returns the number of SpaceLayers that are currently assigned to this
SpaceState.
|
int |
getNumObjects()
Returns the number of SpaceObjects that are currently assigned to this
SpaceState.
|
int |
getNumThinkerObjects()
Returns the number of ThinkerObjects that are currently assigned to this
SpaceState.
|
int |
getNumViewports()
Returns the number of Viewports that are currently assigned to this
SpaceState.
|
SpaceState<T> |
getThis()
A method which returns this CellGameState as a U, rather than as a
CellGameState<T,U,V,W>.
|
Viewport<T> |
getViewport(int id)
Returns the Viewport that is assigned to this SpaceState with the
specified ID.
|
<O extends SpaceObject<T>> |
intersectingSolidObject(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns one of this SpaceState's SpaceObjects of the specified class
whose solid Hitbox overlaps the specified Hitbox, or null if there is
none.
|
<O extends SpaceObject<T>> |
intersectingSolidObjects(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns all of this SpaceState's SpaceObjects of the specified class
whose solid Hitboxes overlap the specified Hitbox.
|
<O extends SpaceObject<T>> |
isIntersectingSolidObject(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns whether this SpaceState has any SpaceObjects of the specified
class whose solid Hitboxes overlap the specified Hitbox.
|
<O extends SpaceObject<T>> |
isOverlappingObject(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns whether this SpaceState has any SpaceObjects of the specified
class that overlap the specified Hitbox.
|
boolean |
iteratingThroughObjects()
Returns whether any Iterators over this SpaceState's list of SpaceObjects
are currently in progress.
|
boolean |
iteratingThroughThinkerObjects()
Returns whether any Iterators over this SpaceState's list of
ThinkerObjects are currently in progress.
|
void |
loadArea(CellVector origin,
Area<T> area)
Loads the specified Area about the specified origin point.
|
void |
loadArea(long originX,
long originY,
Area<T> area)
Loads the specified Area about the specified origin point.
|
<O extends SpaceObject<T>> |
nearestIntersectingSolidObject(CellVector point,
Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class whose solid
Hitbox overlaps the specified Hitbox whose center is nearest to the
specified point, or null if there is none.
|
<O extends SpaceObject<T>> |
nearestIntersectingSolidObject(long pointX,
long pointY,
Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class whose solid
Hitbox overlaps the specified Hitbox whose center is nearest to the
specified point, or null if there is none.
|
<O extends SpaceObject<T>> |
nearestObject(CellVector point,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class whose center
is nearest to the specified point, or null if this SpaceState has no
SpaceObjects of that class.
|
<O extends SpaceObject<T>> |
nearestObject(long pointX,
long pointY,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class whose center
is nearest to the specified point, or null if this SpaceState has no
SpaceObjects of that class.
|
<O extends SpaceObject<T>> |
nearestObjectWithinCircle(CellVector point,
CellVector center,
long radius,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class within the
specified circular region whose center is nearest to the specified point,
or null if there is none.
|
<O extends SpaceObject<T>> |
nearestObjectWithinCircle(long pointX,
long pointY,
long centerX,
long centerY,
long radius,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class within the
specified circular region whose center is nearest to the specified point,
or null if there is none.
|
<O extends SpaceObject<T>> |
nearestObjectWithinRectangle(CellVector point,
long x1,
long y1,
long x2,
long y2,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class within the
specified rectangular region whose center is nearest to the specified
point, or null if there is none.
|
<O extends SpaceObject<T>> |
nearestObjectWithinRectangle(long pointX,
long pointY,
long x1,
long y1,
long x2,
long y2,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class within the
specified rectangular region whose center is nearest to the specified
point, or null if there is none.
|
<O extends SpaceObject<T>> |
nearestOverlappingObject(CellVector point,
Hitbox hitbox,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class that
overlaps the specified Hitbox whose center is nearest to the specified
point, or null if there is none.
|
<O extends SpaceObject<T>> |
nearestOverlappingObject(long pointX,
long pointY,
Hitbox hitbox,
java.lang.Class<O> cls)
Returns this SpaceState's SpaceObject of the specified class that
overlaps the specified Hitbox whose center is nearest to the specified
point, or null if there is none.
|
<O extends SpaceObject<T>> |
objectIsWithinCircle(CellVector center,
long radius,
java.lang.Class<O> cls)
Returns whether this SpaceState has any SpaceObjects of the specified
class with their centers within the specified circular region.
|
<O extends SpaceObject<T>> |
objectIsWithinCircle(long centerX,
long centerY,
long radius,
java.lang.Class<O> cls)
Returns whether this SpaceState has any SpaceObjects of the specified
class with their centers within the specified circular region.
|
<O extends SpaceObject<T>> |
objectIsWithinRectangle(long x1,
long y1,
long x2,
long y2,
java.lang.Class<O> cls)
Returns whether this SpaceState has any SpaceObjects of the specified
class with their centers within the specified rectangular region.
|
SafeIterator<SpaceObject<T>> |
objectIterator()
Returns a new Iterator over this SpaceState's list of SpaceObjects.
|
<O extends SpaceObject<T>> |
objectsWithinCircle(CellVector center,
long radius,
java.lang.Class<O> cls)
Returns all of this SpaceState's SpaceObjects of the specified class with
their centers within the specified circular region.
|
<O extends SpaceObject<T>> |
objectsWithinCircle(long centerX,
long centerY,
long radius,
java.lang.Class<O> cls)
Returns all of this SpaceState's SpaceObjects of the specified class with
their centers within the specified circular region.
|
<O extends SpaceObject<T>> |
objectsWithinRectangle(long x1,
long y1,
long x2,
long y2,
java.lang.Class<O> cls)
Returns all of this SpaceState's SpaceObjects of the specified class with
their centers within the specified rectangular region.
|
<O extends SpaceObject<T>> |
objectWithinCircle(CellVector center,
long radius,
java.lang.Class<O> cls)
Returns one of this SpaceState's SpaceObjects of the specified class with
its center within the specified circular region, or null if there is
none.
|
<O extends SpaceObject<T>> |
objectWithinCircle(long centerX,
long centerY,
long radius,
java.lang.Class<O> cls)
Returns one of this SpaceState's SpaceObjects of the specified class with
its center within the specified circular region, or null if there is
none.
|
<O extends SpaceObject<T>> |
objectWithinRectangle(long x1,
long y1,
long x2,
long y2,
java.lang.Class<O> cls)
Returns one of this SpaceState's SpaceObjects of the specified class with
its center within the specified rectangular region, or null if there is
none.
|
<O extends SpaceObject<T>> |
overlappingObject(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns one of this SpaceState's SpaceObjects of the specified class that
overlaps the specified Hitbox, or null if there is none.
|
<O extends SpaceObject<T>> |
overlappingObjects(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns all of this SpaceState's SpaceObjects of the specified class that
overlap the specified Hitbox.
|
boolean |
rectangleIsVisible(long x1,
long y1,
long x2,
long y2)
Returns whether any part of the specified rectangular region is visible
through any of this SpaceState's Viewports.
|
void |
removeAboveLine(long y)
Removes from this SpaceState all of its SpaceObjects that exist entirely
above the specified horizontal line.
|
void |
removeAllObjects()
Removes from this SpaceState all of the SpaceObjects that are currently
assigned to it.
|
void |
removeBelowLine(long y)
Removes from this SpaceState all of its SpaceObjects that exist entirely
below the specified horizontal line.
|
void |
removeLeftOfLine(long x)
Removes from this SpaceState all of its SpaceObjects that exist entirely
to the left of the specified vertical line.
|
boolean |
removeObject(SpaceObject<T> object)
Removes the specified SpaceObject from this SpaceState if it is currently
assigned to it.
|
void |
removeOutsideRectangle(long x1,
long y1,
long x2,
long y2)
Removes from this SpaceState all of its SpaceObjects that exist entirely
outside the specified rectangular region.
|
void |
removeRectangle(long x1,
long y1,
long x2,
long y2)
Removes from this SpaceState all of its SpaceObjects that exist entirely
inside the specified rectangular region.
|
void |
removeRightOfLine(long x)
Removes from this SpaceState all of its SpaceObjects that exist entirely
to the right of the specified vertical line.
|
void |
renderActions(T game,
org.newdawn.slick.Graphics g,
int x1,
int y1,
int x2,
int y2)
Actions for this CellGameState to take each frame to render its visuals.
|
void |
setCellDimensions(long cellWidth,
long cellHeight)
Sets the dimensions of each of this SpaceState's cells to the specified
values.
|
void |
setDrawMode(DrawMode drawMode)
Sets this SpaceState's DrawMode.
|
boolean |
setHUD(HUD<T> hud)
Sets the HUD that is assigned to this SpaceState to the specified HUD, if
it is not already assigned to a SpaceState.
|
boolean |
setLayer(int id,
SpaceLayer<T> layer)
Sets the SpaceLayer that is assigned to this SpaceState with the
specified ID to the specified SpaceLayer, if it is not already assigned
to a SpaceState.
|
boolean |
setViewport(int id,
Viewport<T> viewport)
Sets the Viewport that is assigned to this SpaceState with the specified
ID to the specified Viewport, if it is not already assigned to a
SpaceState.
|
<O extends SpaceObject<T>> |
solidBoundingBoxesMeet(Hitbox<T> hitbox,
java.lang.Class<O> cls)
Returns all of this SpaceState's solid SpaceObjects of the specified
class whose solid Hitboxes' rectangular bounding boxes touch or intersect
the specified Hitbox's rectangular bounding box.
|
SafeIterator<ThinkerObject<T>> |
thinkerObjectIterator()
Returns a new Iterator over this SpaceState's list of ThinkerObjects.
|
void |
updateThinkerListActions(T game)
Actions for this CellGameState to take immediately after updating its
list of Thinkers.
|
addAnimInstance, addAnimInstance, addThinker, addThinkerActions, charDeletedActions, charTypedActions, clearAnimInstances, enteredActions, getAnimation, getAnimInstance, getGame, getID, getNumAnimInstances, getNumThinkers, getTimeFactor, isActive, iteratingThroughThinkers, leftActions, removeAnimInstance, removeThinker, removeThinkerActions, setAnimation, setAnimInstance, setTimeFactor, stringBeganActions, stringCanceledActions, stringDeletedActions, stringFinishedActions, thinkerIterator
public SpaceState(T game, int id, long cellWidth, long cellHeight, DrawMode drawMode)
game
- The CellGame to which this SpaceState belongsid
- This SpaceState's IDcellWidth
- The width of each of this SpaceState's cellscellHeight
- The height of each of this SpaceState's cellsdrawMode
- This SpaceState's DrawModepublic final SpaceState<T> getThis()
CellGameState
getThis
in class CellGameState<T extends CellGame,SpaceState<T extends CellGame>,SpaceThinker<T extends CellGame>,SpaceThinkerState<T extends CellGame>>
public final long getCellWidth()
public final long getCellHeight()
public final void setCellDimensions(long cellWidth, long cellHeight)
cellWidth
- The new width of each of this SpaceState's cellscellHeight
- The new height of each of this SpaceState's cellspublic final void clearEmptyCells()
public final DrawMode getDrawMode()
public final void setDrawMode(DrawMode drawMode)
drawMode
- The new DrawModepublic final void loadArea(CellVector origin, Area<T> area)
origin
- The origin point about which to load the Areaarea
- The Area to loadpublic final void loadArea(long originX, long originY, Area<T> area)
originX
- The x-coordinate of the origin point about which to load
the AreaoriginY
- The y-coordinate of the origin point about which to load
the Areaarea
- The Area to loadpublic final void updateThinkerListActions(T game)
CellGameState
updateThinkerListActions
in class CellGameState<T extends CellGame,SpaceState<T extends CellGame>,SpaceThinker<T extends CellGame>,SpaceThinkerState<T extends CellGame>>
game
- This CellGameState's CellGamepublic final int getNumObjects()
public final boolean iteratingThroughObjects()
public final SafeIterator<SpaceObject<T>> objectIterator()
public final boolean addObject(SpaceObject<T> object)
object
- The SpaceObject to be addedpublic final boolean removeObject(SpaceObject<T> object)
object
- The SpaceObject to be removedpublic final void removeAllObjects()
public final void removeRectangle(long x1, long y1, long x2, long y2)
x1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgepublic final void removeOutsideRectangle(long x1, long y1, long x2, long y2)
x1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgepublic final void removeLeftOfLine(long x)
x
- The line's x-coordinatepublic final void removeRightOfLine(long x)
x
- The line's x-coordinatepublic final void removeAboveLine(long y)
y
- The line's y-coordinatepublic final void removeBelowLine(long y)
y
- The line's y-coordinatepublic final int getNumThinkerObjects()
public final boolean iteratingThroughThinkerObjects()
public final SafeIterator<ThinkerObject<T>> thinkerObjectIterator()
public final <O extends SpaceObject<T>> O nearestObject(CellVector point, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpoint
- The point to check distance tocls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObject(long pointX, long pointY, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpointX
- The x-coordinate of the point to check the distance topointY
- The y-coordinate of the point to check the distance tocls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean objectIsWithinRectangle(long x1, long y1, long x2, long y2, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forx1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgecls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O objectWithinRectangle(long x1, long y1, long x2, long y2, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forx1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgecls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> objectsWithinRectangle(long x1, long y1, long x2, long y2, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forx1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgecls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinRectangle(CellVector point, long x1, long y1, long x2, long y2, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpoint
- The point to check the distance tox1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgecls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinRectangle(long pointX, long pointY, long x1, long y1, long x2, long y2, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpointX
- The x-coordinate of the point to check the distance topointY
- The y-coordinate of the point to check the distance tox1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgecls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean objectIsWithinCircle(CellVector center, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenter
- The region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean objectIsWithinCircle(long centerX, long centerY, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenterX
- The x-coordinate of the region's centercenterY
- The y-coordinate of the region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O objectWithinCircle(CellVector center, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenter
- The region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O objectWithinCircle(long centerX, long centerY, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenterX
- The x-coordinate of the region's centercenterY
- The y-coordinate of the region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> objectsWithinCircle(CellVector center, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenter
- The region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> objectsWithinCircle(long centerX, long centerY, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forcenterX
- The x-coordinate of the region's centercenterY
- The y-coordinate of the region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinCircle(CellVector point, CellVector center, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpoint
- The point to check the distance tocenter
- The region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestObjectWithinCircle(long pointX, long pointY, long centerX, long centerY, long radius, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpointX
- The x-coordinate of the point to check the distance topointY
- The y-coordinate of the point to check the distance tocenterX
- The x-coordinate of the region's centercenterY
- The y-coordinate of the region's centerradius
- The region's radiuscls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean isOverlappingObject(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O overlappingObject(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> overlappingObjects(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestOverlappingObject(CellVector point, Hitbox hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpoint
- The point to check the distance tohitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestOverlappingObject(long pointX, long pointY, Hitbox hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpointX
- The x-coordinate of the point to check the distance topointY
- The y-coordinate of the point to check the distance tohitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> boundingBoxesMeet(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox whose bounding box to checkcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> boolean isIntersectingSolidObject(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O intersectingSolidObject(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> intersectingSolidObjects(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestIntersectingSolidObject(CellVector point, Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpoint
- The point to check the distance tohitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> O nearestIntersectingSolidObject(long pointX, long pointY, Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forpointX
- The x-coordinate of the point to check the distance topointY
- The y-coordinate of the point to check the distance tohitbox
- The Hitbox to check for overlappingcls
- The Class object that represents the SpaceObject subclasspublic final <O extends SpaceObject<T>> java.util.List<O> solidBoundingBoxesMeet(Hitbox<T> hitbox, java.lang.Class<O> cls)
O
- The subclass of SpaceObject to search forhitbox
- The Hitbox whose bounding box to checkcls
- The Class object that represents the SpaceObject subclasspublic final int getNumLayers()
public final SpaceLayer<T> getLayer(int id)
id
- The ID of the SpaceLayer to be returnedpublic final boolean setLayer(int id, SpaceLayer<T> layer)
id
- The ID with which to assign the specified SpaceLayerlayer
- The SpaceLayer to add with the specified IDpublic final void clearLayers()
public final HUD<T> getHUD()
public final boolean setHUD(HUD<T> hud)
hud
- The HUD to addpublic final int getNumViewports()
public final Viewport<T> getViewport(int id)
id
- The ID of the Viewport to be returnedpublic final boolean setViewport(int id, Viewport<T> viewport)
id
- The ID with which to assign the specified Viewportviewport
- The Viewport to add with the specified IDpublic final void clearViewports()
public final boolean rectangleIsVisible(long x1, long y1, long x2, long y2)
x1
- The x-coordinate of the region's left edgey1
- The y-coordinate of the region's top edgex2
- The x-coordinate of the region's right edgey2
- The y-coordinate of the region's bottom edgepublic final void frameActions(T game)
CellGameState
frameActions
in class CellGameState<T extends CellGame,SpaceState<T extends CellGame>,SpaceThinker<T extends CellGame>,SpaceThinkerState<T extends CellGame>>
game
- This CellGameState's CellGamepublic void renderActions(T game, org.newdawn.slick.Graphics g, int x1, int y1, int x2, int y2)
CellGameState
renderActions
in class CellGameState<T extends CellGame,SpaceState<T extends CellGame>,SpaceThinker<T extends CellGame>,SpaceThinkerState<T extends CellGame>>
game
- This CellGameState's CellGameg
- The Graphics context to which this CellGameState is rendering
its visuals this framex1
- The x-coordinate in pixels of the screen's left edge on the
Graphics contexty1
- The y-coordinate in pixels of the screen's top edge on the
Graphics contextx2
- The x-coordinate in pixels of the screen's right edge on the
screen on the Graphics contexty2
- The y-coordinate in pixels of the screen's bottom edge on the
Graphics context