GridService2D

GridService2D

Contract: Provides grid metadata (tile size + origin) and deterministic conversion between world space () and grid space () for a uniform 2D grid. Coordinate / rounding rules:

  • defines the world-space origin of grid cell (0,0) (the grid “anchor”).
  • uses floor(local / tileSize) per-axis (not rounding).
  • returns the world-space center of a cell. Edge cases:
  • If a tile size component is 0, that axis maps to 0 in .
  • No bounds checking is performed; negative coordinates are valid.

Project: GridPlacement v6.0
Layer: Core
Source: Core/Services/Grid/GridService2D.cs
Namespace: GridBuilding.Core.Services.Grid
Kind: class

Parsing Method: AST-based (Roslyn) - NOT regex

⚠️ IMPORTANT: This documentation was generated using AST parsing, not regex.

Properties

State

TileSize

Origin

Methods

SetTileSize

Sets the tile size used by conversions.

Returns: void

Parameters:

  • CoreVector2 tileSize

GetTileSize

Returns: CoreVector2

SetOrigin

Sets the grid origin used by conversions.

Returns: void

Parameters:

  • CoreVector2 origin

GetOrigin

Returns: CoreVector2

SetTargetMap

Returns: void

Parameters:

  • IGridMap2D? map

GetTargetMap

Returns: IGridMap2D?

SetMaps

Returns: void

Parameters:

  • IReadOnlyList<IGridMap2D> maps

GetMaps

Returns: IReadOnlyList<IGridMap2D>

WorldToGrid

Converts a world position to a grid cell coordinate.

Returns: CoreVector2I

Parameters:

  • CoreVector2 worldPosition

GridToWorld

Converts a grid cell coordinate to a world position.

Returns: CoreVector2

Parameters:

  • CoreVector2I gridPosition

IsValidGridPosition

Returns: bool

Parameters:

  • CoreVector2I gridPosition

SnapToTileCenter

Snaps an arbitrary world position to the center of the tile it falls within.

Returns: CoreVector2

Parameters:

  • CoreVector2 worldPosition