T
- The type of CellGame that uses this SpaceStateU
- The type of SpaceState that this SpaceState is for SpaceThinker
interaction purposesV
- The type of SpaceThinker that this SpaceState usespublic abstract class SpaceState<T extends CellGame,U extends SpaceState<T,U,V>,V extends SpaceThinker<T,U,V>> extends GameState<T,U,V>
A SpaceState is a type of GameState that handles gameplay in a continuous two-dimensional space. Space in a SpaceState is divided into rectangular cells of equal width and equal height. 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 SubThinkers are assigned to Thinkers. Similarly to SubThinkers, the actual addition or removal of a SpaceObject to or from a SpaceState is delayed until any and all current iterations over its SpaceThinkers, SpaceObjects, or MobileObjects, such as the periods during which MobileObjects move or SpaceThinkers take their time-dependent 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 MobileObject 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.
Like the SpaceThinkers that it uses, a SpaceState has an EventGroup of before-movement Events that it performs once each frame. A SpaceState performs these Events at the beginning of its frameActions(). Immediately afterward, the SpaceState moves each of its MobileObjects 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 MobileObject's doMovement() method, is when the MobileObject interacts with the solid surfaces of SpaceObjects in its path if it has Cell2D's standard collision mechanics enabled.
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.
HUDs may be assigned to a SpaceState to render visuals in front of the SpaceState's own. Only one HUD may be assigned to a given SpaceState in this capacity at once. A SpaceState's HUD uses the entire screen as its rendering region.
SpaceLayers may be assigned to a SpaceState 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 assigned with an ID of 0.
SpaceThinker
,
SpaceObject
,
Viewport
,
HUD
,
SpaceLayer
Modifier and Type | Class and Description |
---|---|
static class |
SpaceState.DrawMode
A DrawMode is a procedure by which a SpaceState determines the order
in which to draw SpaceObjects with the same draw priority over one
another.
|
Constructor and Description |
---|
SpaceState(java.lang.Class<T> gameClass,
java.lang.Class<U> stateClass,
java.lang.Class<V> subThinkerClass,
T game,
int id,
long cellWidth,
long cellHeight,
SpaceState.DrawMode drawMode)
Constructs a SpaceState of the specified CellGame with the specified ID.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addObject(SpaceObject object)
Adds the specified SpaceObject to this SpaceState if it is not already
assigned to a SpaceState.
|
void |
addSubThinkerActions(T game,
U state,
V subThinker)
Actions for this Thinker to take immediately after adding a SubThinker to
itself, before the added SubThinker takes its addedActions().
|
<O extends SpaceObject> |
boundingBoxesMeet(Hitbox 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 |
clearObjects()
Removes from this SpaceState all of the SpaceObjects that are currently
assigned to it.
|
void |
clearViewports()
Removes from this SpaceState all Viewports that are currently assigned to
it.
|
void |
frameActions(T game,
U state)
Actions for this Thinker to take once each frame.
|
EventGroup<T,U> |
getBeforeMovementEvents()
Returns the EventGroup of this SpaceState's before-movement Events.
|
long |
getCellHeight()
Returns the height of each of this SpaceState's cells.
|
long |
getCellWidth()
Returns the width of each of this SpaceState's cells.
|
SpaceState.DrawMode |
getDrawMode()
Returns this SpaceState's DrawMode.
|
HUD |
getHUD()
Returns the HUD that is assigned to this SpaceState, or null if there is
none.
|
SpaceLayer |
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 assigned to this SpaceState.
|
int |
getNumMobileObjects()
Returns the number of MobileObjects that are assigned to this SpaceState.
|
int |
getNumObjects()
Returns the number of SpaceObjects that are assigned to this SpaceState.
|
int |
getNumViewports()
Returns the number of Viewports that are assigned to this SpaceState.
|
CellVector |
getSpacePoint(int x,
int y)
Returns the point in this SpaceState, as seen through one of its
Viewports, that corresponds to the specified point in pixels on the
screen.
|
Viewport<T,U> |
getViewport(int id)
Returns the Viewport that is assigned to this SpaceState with the
specified ID.
|
<O extends SpaceObject> |
intersectingSolidObject(Hitbox 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> |
intersectingSolidObjects(Hitbox 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> |
isIntersectingSolidObject(Hitbox 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> |
isOverlappingObject(Hitbox hitbox,
java.lang.Class<O> cls)
Returns whether this SpaceState has any SpaceObjects of the specified
class that overlap the specified Hitbox.
|
boolean |
iteratingThroughMobileObjects()
Returns whether any Iterators over this SpaceState's list of
MobileObjects are in progress.
|
boolean |
iteratingThroughObjects()
Returns whether any Iterators over this SpaceState's list of SpaceObjects
are in progress.
|
void |
loadArea(CellVector origin,
Area<T,U> area)
Loads the specified Area about the specified origin point.
|
void |
loadArea(long originX,
long originY,
Area<T,U> area)
Loads the specified Area about the specified origin point.
|
SafeIterator<MobileObject> |
mobileObjectIterator()
Returns a new SafeIterator over this SpaceState's list of MobileObjects.
|
<O extends SpaceObject> |
nearestIntersectingSolidObject(CellVector point,
Hitbox 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> |
nearestIntersectingSolidObject(long pointX,
long pointY,
Hitbox 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> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
objectIterator()
Returns a new SafeIterator over this SpaceState's list of SpaceObjects.
|
<O extends SpaceObject> |
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> |
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> |
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> |
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> |
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> |
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> |
overlappingObject(Hitbox 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> |
overlappingObjects(Hitbox 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 of this
SpaceState's space is visible through any of its Viewports.
|
void |
removeAboveLine(long y)
Removes from this SpaceState all of its SpaceObjects that lie entirely
above the specified horizontal line.
|
void |
removeBelowLine(long y)
Removes from this SpaceState all of its SpaceObjects that lie entirely
below the specified horizontal line.
|
void |
removeLeftOfLine(long x)
Removes from this SpaceState all of its SpaceObjects that lie entirely
to the left of the specified vertical line.
|
boolean |
removeObject(SpaceObject 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 lie 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 lie entirely
inside the specified rectangular region.
|
void |
removeRightOfLine(long x)
Removes from this SpaceState all of its SpaceObjects that lie entirely
to the right of the specified vertical line.
|
void |
removeSubThinkerActions(T game,
U state,
V subThinker)
Actions for this Thinker to take immediately before removing a SubThinker
from itself, after the soon-to-be-removed SubThinker takes its
removedActions().
|
void |
renderActions(T game,
Graphics g,
int x1,
int y1,
int x2,
int y2)
Actions for this GameState 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(SpaceState.DrawMode drawMode)
Sets this SpaceState's DrawMode.
|
void |
setHUD(HUD hud)
Sets the HUD that is assigned to this SpaceState to the specified one.
|
void |
setLayer(int id,
SpaceLayer layer)
Sets the SpaceLayer that is assigned to this SpaceState with the
specified ID to the specified SpaceLayer.
|
boolean |
setViewport(int id,
Viewport<T,U> 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> |
solidBoundingBoxesMeet(Hitbox 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.
|
addAnimInstance, addAnimInstance, bindFinishedActions, charDeletedActions, charTypedActions, clearAnimInstances, enteredActions, getAnimation, getAnimInstance, getEffectiveTimeFactor, getGame, getGameState, getID, getNumAnimInstances, getThis, isActive, leftActions, removeAnimInstance, setAnimation, setAnimInstance, stringBeganActions, stringCanceledActions, stringDeletedActions, stringFinishedActions
addSubThinker, clearLineages, clearSubThinkers, getFrameEvents, getGameClass, getNumSubThinkers, getStateClass, getSubThinkerClass, getTimeFactor, getTimerValue, iteratingThroughSubThinkers, removeLineage, removeSubThinker, setTimeFactor, setTimerValue, subThinkerIterator
public SpaceState(java.lang.Class<T> gameClass, java.lang.Class<U> stateClass, java.lang.Class<V> subThinkerClass, T game, int id, long cellWidth, long cellHeight, SpaceState.DrawMode drawMode)
gameClass
- The Class object representing the type of CellGame that
uses this SpaceStatestateClass
- The Class object representing the type of SpaceState
that this SpaceState is for SpaceThinker interaction purposessubThinkerClass
- The Class object representing the type of
SpaceThinker that this SpaceState usesgame
- 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 void addSubThinkerActions(T game, U state, V subThinker)
Thinker
addSubThinkerActions
in class Thinker<T extends CellGame,U extends SpaceState<T,U,V>,V extends SpaceThinker<T,U,V>>
game
- This Thinker's GameState's CellGame, or null if it has no
GameStatestate
- This Thinker's GameState, or null if it has nonesubThinker
- The SubThinker that was addedpublic void removeSubThinkerActions(T game, U state, V subThinker)
Thinker
removeSubThinkerActions
in class Thinker<T extends CellGame,U extends SpaceState<T,U,V>,V extends SpaceThinker<T,U,V>>
game
- This Thinker's GameState's CellGame, or null if it has no
GameStatestate
- This Thinker's GameState, or null if it has nonesubThinker
- The SubThinker that is about to be removedpublic final EventGroup<T,U> getBeforeMovementEvents()
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 SpaceState.DrawMode getDrawMode()
public final void setDrawMode(SpaceState.DrawMode drawMode)
drawMode
- The new DrawModepublic final void loadArea(CellVector origin, Area<T,U> area)
origin
- The origin point about which to load the Areaarea
- The Area to loadpublic final void loadArea(long originX, long originY, Area<T,U> 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 int getNumObjects()
public final boolean iteratingThroughObjects()
public final SafeIterator<SpaceObject> objectIterator()
public final boolean addObject(SpaceObject object)
object
- The SpaceObject to be addedpublic final boolean removeObject(SpaceObject object)
object
- The SpaceObject to be removedpublic final void clearObjects()
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 getNumMobileObjects()
public final boolean iteratingThroughMobileObjects()
public final SafeIterator<MobileObject> mobileObjectIterator()
public final <O extends SpaceObject> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> 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> boolean isOverlappingObject(Hitbox 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> O overlappingObject(Hitbox 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> java.util.List<O> overlappingObjects(Hitbox 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> 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> 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> java.util.List<O> boundingBoxesMeet(Hitbox 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> boolean isIntersectingSolidObject(Hitbox 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> O intersectingSolidObject(Hitbox 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> java.util.List<O> intersectingSolidObjects(Hitbox 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> O nearestIntersectingSolidObject(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> O nearestIntersectingSolidObject(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> java.util.List<O> solidBoundingBoxesMeet(Hitbox 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 getNumViewports()
public final Viewport<T,U> getViewport(int id)
id
- The ID of the Viewport to be returnedpublic final boolean setViewport(int id, Viewport<T,U> viewport)
id
- The ID with which to assign the specified Viewportviewport
- The Viewport to add with the specified IDpublic final void clearViewports()
public final CellVector getSpacePoint(int x, int y)
x
- The x-coordinate of the screen pointy
- The y-coordinate of the screen pointpublic 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 HUD getHUD()
public final void setHUD(HUD hud)
hud
- The HUD to addpublic final int getNumLayers()
public final SpaceLayer getLayer(int id)
id
- The ID of the SpaceLayer to be returnedpublic final void setLayer(int id, SpaceLayer layer)
id
- The ID with which to assign the specified SpaceLayerlayer
- The SpaceLayer to add with the specified IDpublic final void clearLayers()
public void frameActions(T game, U state)
Thinker
frameActions
in class Thinker<T extends CellGame,U extends SpaceState<T,U,V>,V extends SpaceThinker<T,U,V>>
game
- This Thinker's GameState's CellGamestate
- This Thinker's GameStatepublic void renderActions(T game, Graphics g, int x1, int y1, int x2, int y2)
GameState
renderActions
in class GameState<T extends CellGame,U extends SpaceState<T,U,V>,V extends SpaceThinker<T,U,V>>
game
- This GameState's CellGameg
- The Graphics context to which this GameState 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