Table of Contents

Interface IGridOccupancy

Namespace
MoonBark.GridPlacement.Core.Interfaces.Placement
Assembly
MoonBark.GridPlacement.Core.dll

Interface for accessing grid occupancy data. Provides information about which grid positions are occupied.

public interface IGridOccupancy

Methods

GetGridSize()

Gets the size of the grid.

CoreVector2I GetGridSize()

Returns

CoreVector2I

Grid size in tiles

GetOccupant(CoreVector2I)

Gets the occupant at a grid position.

IOccupantData? GetOccupant(CoreVector2I position)

Parameters

position CoreVector2I

Grid position to check

Returns

IOccupantData

Occupant data or null if unoccupied

GetOccupiedPositions()

Gets all occupied positions in the grid.

ISet<CoreVector2I> GetOccupiedPositions()

Returns

ISet<CoreVector2I>

Set of occupied grid positions

HasOccupancy(IEnumerable<CoreVector2I>)

Checks if any position in a collection is occupied.

bool HasOccupancy(IEnumerable<CoreVector2I> positions)

Parameters

positions IEnumerable<CoreVector2I>

Collection of positions to check

Returns

bool

True if any position is occupied

IsInBounds(CoreVector2I)

Checks if a position is within grid bounds.

bool IsInBounds(CoreVector2I position)

Parameters

position CoreVector2I

Position to check

Returns

bool

True if position is within bounds

IsOccupied(CoreVector2I)

Checks if a grid position is occupied.

bool IsOccupied(CoreVector2I position)

Parameters

position CoreVector2I

Grid position to check

Returns

bool

True if the position is occupied

SeedOccupancy(IEnumerable<(CoreVector2I Cell, string PlaceableId)>)

One-time bootstrap: seeds the occupancy map from an external source (e.g., TileMapLayer). Creates ECS entities and marks them dirty so the occupancy map is populated on the next UpdateInternal() call.

After seeding, the normal placement/removal flow resumes as usual.

void SeedOccupancy(IEnumerable<(CoreVector2I Cell, string PlaceableId)> cells)

Parameters

cells IEnumerable<(CoreVector2I Cell, string PlaceableId)>

Pairs of (grid position, placeableId) to seed. Only cells with known placeableIds should be passed.

TryGetTileSource(CoreVector2I, out TileSourceData)

Gets the tile source data at a grid position. Used by TileMap synchronization to determine which atlas coordinates to set.

bool TryGetTileSource(CoreVector2I position, out TileSourceData tileSourceData)

Parameters

position CoreVector2I

Grid position to check.

tileSourceData TileSourceData

When successful, contains the tile source data.

Returns

bool

True if the position has tile source data, false otherwise.