Cell class

Cell is the rect (quad) of game space, connected with it's neighbors at left, right, top and bottom. This class stores cell information and automates new cells creation,makes easier querying cell's components for collision detection system.

Usually you do not need to use any of it's methods. But you absolutely should to ensure that component's HasGridSupport.currentCell is not null.

Constructors

Cell({required SpatialGrid spatialGrid, required Rect rect, bool suspended = false})

Properties

beingSuspendedTimeMicroseconds double
A time in microseconds from the moment when cell's state was changed into CellState.suspended. See updateComponentsState too.
getter/setter pair
bottom Cell
Existing or new bottom cell
no setter
bottomChecked Cell?
Existing bottom cell if not scheduled for removal, otherwise null
no setter
center ↔ Vector2
Cell's central point.
latefinal
components HashSet<HasGridSupport>
Collection of component currently places inside this cell. Should not be modified manually!
final
fullyInsideMap bool
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasOutOfBoundsComponents bool
no setter
isCellBuildFinished bool
getter/setter pair
isRemoving bool
no setter
left Cell
Existing or new left cell
no setter
leftChecked Cell?
Existing left cell if not scheduled for removal, otherwise null
no setter
lockInState CellState?
Locks cell in specified state, preventing unloading when not used. Feature is disabled, when null.
getter/setter pair
neighbours List<Cell?>
Get cell's left, right, top and bottom neighbours, if exists. Also includes left-top, right-top, right-bottom and left-bottom neighbours. Useful for collision detection system.
no setter
neighboursAndMe List<Cell?>
no setter
outOfBoundsCounter int
getter/setter pair
rawBottom Cell?
Bottom cell from current, or null
getter/setter pair
rawLeft Cell?
Left cell from current, or null
getter/setter pair
rawRight Cell?
Right cell from current, or null
getter/setter pair
rawTop Cell?
Top cell from current, or null
getter/setter pair
rect Rect
final
Existing or new right cell
no setter
rightChecked Cell?
Existing right cell if not scheduled for removal, otherwise null
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
spatialGrid SpatialGrid
final
state CellState
Most important cell's parameter, controls cell's lifecycle and lifecycle of components inside the cell. See CellState for detailed description of states meaning. See updateComponentsState to understand a part of internal mechanics.
getter/setter pair
tileBuilderContextProvider TileBuilderContextProvider?
getter/setter pair
tmpState CellState
getter/setter pair
top Cell
Existing or new top cell
no setter
topChecked Cell?
Existing top cell if not scheduled for removal, otherwise null
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove() → void
The cell should to remove itself from all neighbours and spatialGrid, remove all cell's components from game tree and dispose state's listeners.
setStateInternal(CellState value) → void
toString() String
A string representation of this object.
inherited
updateComponentsState([CellState? oldState]) → void

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

setCollisionTypeForHitbox(ShapeHitbox hitbox, [CollisionType? collisionType]) → void