GridService2D
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
This page documents the supported public API surface only. Private, internal, benchmark, test, and implementation-detail types are intentionally omitted.
Declaration
Summary
Contract: Provides grid metadata (tile size + origin) and deterministic conversion between world space (CoreVector2) and grid space (CoreVector2I) for a uniform 2D grid.
Coordinate / rounding rules:
Origindefines the world-space origin of grid cell (0,0) (the grid “anchor”).WorldToGridusesfloor(local / tileSize)per-axis (not rounding).GridToWorldreturns the world-space center of a cell.
Edge cases:
- If a tile size component is 0, that axis maps to 0 in
WorldToGrid. - No bounds checking is performed; negative coordinates are valid.
Metadata
Namespace: GridPlacement.Core.Services.Grid
Source File: cs/Core/Services/Grid/GridService2D.cs
Assembly: GridPlacement.Core
Type: class
Constructors
GridService2D
Creates a grid conversion service.
Parameters
| Name | Description |
|---|---|
state | Grid state containing tile size and origin. |
GridService2D
Creates a grid conversion service with optional tile size and origin.
Parameters
| Name | Description |
|---|---|
tileSize | Optional tile size. Defaults to (64, 64). |
origin | Optional origin. Defaults to (0, 0). |
Properties
TileSize
Gets or sets the dimensions of a single grid tile in world units.
Origin
Gets or sets the world-space origin of the grid cell at (0, 0).
TargetMap
Gets or sets the current active target map for grid operations.
Maps
Gets or sets the collection of maps available to this service.
Methods
GetSnapshot
WorldToGrid
Converts a world position to a grid cell coordinate.
Remarks
Behavior contract:
- Computes
local = worldPosition - Origin - Computes
grid = floor(local / TileSize)per-axis. - If
TileSize.X == 0,Xis returned as 0 (same forY). - Negative positions are supported and will produce negative grid coordinates.
GridToWorld
Converts a grid cell coordinate to a world position.
Remarks
Behavior contract:
- Returns the world-space center of the given cell.
- The returned position is
Origin + (grid * TileSize) + (TileSize * 0.5)per-axis. - No validation is performed.
IsValidGridPosition
SnapToTileCenter
Snaps an arbitrary world position to the center of the tile it falls within.
Remarks
Equivalent to GridToWorld(WorldToGrid(worldPosition)).
Events
TargetMapChanged
Raised when the active target map has changed.
MapsChanged
Raised when the list of available maps has changed.