Skip to content

TileMapLayer

Eduard Gushchin edited this page Jul 1, 2026 · 3 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.TileMapLayer
Namespace Electron2D
Kind class
Category Rendering

Overview

Provides a single 2D tilemap layer.

Syntax

public class Electron2D.TileMapLayer : Electron2D.Node2D

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: TileMapLayer

Runtime tile map layer with cell storage, coordinate conversion, canvas submission, body RID queries and one-way tile collision shapes.

Remarks

TileMapLayer stores cell identifiers, submits visible atlas tiles to the canvas render queue and exposes tile collision polygons to the managed 2D physics query path.

Thread Safety

This type is not synchronized. Create and mutate tilemap layers on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileData
  • Electron2D.TileMapLayer.TileSet

Members

Member Kind Summary
CollisionEnabled Property Gets or sets whether tile collision polygons participate in physics.
Enabled Property Gets or sets whether this layer is active.
PhysicsQuadrantSize Property Gets or sets the physics quadrant size.
RenderingQuadrantSize Property Gets or sets the rendering quadrant size.
TileSet Property Gets or sets the tile set used by this layer.
XDrawOrderReversed Property Gets or sets whether tile draw order is reversed on the X axis.
YSortOrigin Property Gets or sets the Y-sort origin offset for submitted tiles.
Electron2D.TileMapLayer() Constructor Initializes a new instance of the Electron2D.TileMapLayer type.
Clear() Method Removes all cells from this layer.
EraseCell(Electron2D.Vector2I) Method Erases a tile cell at map coordinates.
GetCellAlternativeTile(Electron2D.Vector2I) Method Gets the alternative tile id stored in a cell.
GetCellAtlasCoords(Electron2D.Vector2I) Method Gets the atlas coordinates stored in a cell.
GetCellSourceId(Electron2D.Vector2I) Method Gets the source id stored in a cell.
GetCellTileData(Electron2D.Vector2I) Method Gets the tile data referenced by a cell.
GetCoordsForBodyRid(Electron2D.Rid) Method Gets cell coordinates for a body RID when they are unambiguous.
GetUsedCells() Method Gets all used cell coordinates.
GetUsedCellsById(System.Int32, Electron2D.Vector2I?, System.Int32) Method Gets used cell coordinates filtered by stored tile identifiers.
GetUsedRect() Method Gets the rectangle enclosing all used cells.
HasBodyRid(Electron2D.Rid) Method Checks whether a body RID belongs to this tilemap layer.
LocalToMap(Electron2D.Vector2) Method Converts a local position to map coordinates.
MapToLocal(Electron2D.Vector2I) Method Converts map coordinates to a local cell-center position.
NotifyRuntimeTileDataUpdate() Method Notifies the layer that runtime tile data has changed.
SetCell(Electron2D.Vector2I, System.Int32, Electron2D.Vector2I, System.Int32) Method Stores a tile cell at map coordinates.
UpdateInternals() Method Applies pending tilemap updates immediately.

Member Details

CollisionEnabled

Kind: Property

public System.Boolean CollisionEnabled { get; set; }

Summary

Gets or sets whether tile collision polygons participate in physics.

Remarks

Rendering is controlled separately by Electron2D.TileMapLayer.Enabled and Electron2D.CanvasItem.Visible.

Value

true when tile collision polygons should be active; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.Enabled

Enabled

Kind: Property

public System.Boolean Enabled { get; set; }

Summary

Gets or sets whether this layer is active.

Remarks

Disabling the layer leaves stored cells unchanged.

Value

true when rendering and collision are enabled for the layer; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.CollisionEnabled

PhysicsQuadrantSize

Kind: Property

public System.Int32 PhysicsQuadrantSize { get; set; }

Summary

Gets or sets the physics quadrant size.

Remarks

The preview stores this value for API state. Physics shapes are not chunk-merged yet.

Value

The positive quadrant side length in map cells.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the value is less than or equal to zero.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.RenderingQuadrantSize

RenderingQuadrantSize

Kind: Property

public System.Int32 RenderingQuadrantSize { get; set; }

Summary

Gets or sets the rendering quadrant size.

Remarks

The preview stores this value for API state. Rendering commands are not chunk-merged yet.

Value

The positive quadrant side length in map cells.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when the value is less than or equal to zero.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.PhysicsQuadrantSize

TileSet

Kind: Property

public Electron2D.TileSet TileSet { get; set; }

Summary

Gets or sets the tile set used by this layer.

Remarks

Cells remain stored when this property changes. Rendering and collision use the currently assigned tile set.

Value

The tile set resource, or null when this layer has no tile definitions.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.TileSet

XDrawOrderReversed

Kind: Property

public System.Boolean XDrawOrderReversed { get; set; }

Summary

Gets or sets whether tile draw order is reversed on the X axis.

Remarks

The flag affects stable submission order when cells have the same z-index.

Value

true to submit cells with higher X coordinates first inside each row; otherwise, false.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.GetUsedCells

YSortOrigin

Kind: Property

public System.Int32 YSortOrigin { get; set; }

Summary

Gets or sets the Y-sort origin offset for submitted tiles.

Remarks

The value is added to each cell's local Y position before it enters the canvas render queue.

Value

The local Y offset used to derive tile y-sort positions.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CanvasItem.YSortEnabled

Electron2D.TileMapLayer()

Kind: Constructor

public Electron2D.TileMapLayer()

Summary

Initializes a new instance of the Electron2D.TileMapLayer type.

Remarks

The layer starts enabled, collision-enabled and empty.

Thread Safety

This constructor is not synchronized. Call it from the thread that owns the node being created.

Since

This constructor is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.TileSet

Clear()

Kind: Method

public System.Void Clear()()

Summary

Removes all cells from this layer.

Remarks

This method does not change Electron2D.TileMapLayer.TileSet or layer settings.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.EraseCell(Electron2D.Vector2I)

EraseCell(Electron2D.Vector2I)

Kind: Method

public System.Void EraseCell(Electron2D.Vector2I)(Electron2D.Vector2I coords)

Summary

Erases a tile cell at map coordinates.

Remarks

Erasing a missing cell does nothing.

Parameters

  • coords: The map coordinates of the cell to erase.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.SetCell(Electron2D.Vector2I,System.Int32,Electron2D.Vector2I,System.Int32)

GetCellAlternativeTile(Electron2D.Vector2I)

Kind: Method

public System.Int32 GetCellAlternativeTile(Electron2D.Vector2I)(Electron2D.Vector2I coords)

Summary

Gets the alternative tile id stored in a cell.

Remarks

The 0.1.0 Preview stores the value but only default atlas alternative data is implemented by Electron2D.TileSetAtlasSource.

Parameters

  • coords: The map coordinates of the cell.

Returns

The alternative tile id, or -1 when the cell is empty.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.SetCell(Electron2D.Vector2I,System.Int32,Electron2D.Vector2I,System.Int32)

GetCellAtlasCoords(Electron2D.Vector2I)

Kind: Method

public Electron2D.Vector2I GetCellAtlasCoords(Electron2D.Vector2I)(Electron2D.Vector2I coords)

Summary

Gets the atlas coordinates stored in a cell.

Remarks

The method reads stored cell data only; it does not validate whether the source contains the atlas tile.

Parameters

  • coords: The map coordinates of the cell.

Returns

The atlas coordinates, or Vector2I(-1, -1) when the cell is empty.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.GetCellSourceId(Electron2D.Vector2I)

GetCellSourceId(Electron2D.Vector2I)

Kind: Method

public System.Int32 GetCellSourceId(Electron2D.Vector2I)(Electron2D.Vector2I coords)

Summary

Gets the source id stored in a cell.

Remarks

The method reads stored cell data only; it does not validate whether the current Electron2D.TileMapLayer.TileSet still contains the source.

Parameters

  • coords: The map coordinates of the cell.

Returns

The source id, or -1 when the cell is empty.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.SetCell(Electron2D.Vector2I,System.Int32,Electron2D.Vector2I,System.Int32)

GetCellTileData(Electron2D.Vector2I)

Kind: Method

public Electron2D.TileData GetCellTileData(Electron2D.Vector2I)(Electron2D.Vector2I coords)

Summary

Gets the tile data referenced by a cell.

Remarks

The method returns null for empty cells, missing tile sets, missing sources and non-atlas sources.

Parameters

  • coords: The map coordinates of the cell.

Returns

The tile data, or null when no tile data is available.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileData

GetCoordsForBodyRid(Electron2D.Rid)

Kind: Method

public Electron2D.Vector2I GetCoordsForBodyRid(Electron2D.Rid)(Electron2D.Rid body)

Summary

Gets cell coordinates for a body RID when they are unambiguous.

Remarks

The preview stores one internal body RID for the whole layer. The method returns cell coordinates only when exactly one cell is used.

Parameters

  • body: The body RID to query.

Returns

The single used cell coordinates, or Vector2I(-1, -1) when unavailable.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.HasBodyRid(Electron2D.Rid)

GetUsedCells()

Kind: Method

public Electron2D.Vector2I[] GetUsedCells()()

Summary

Gets all used cell coordinates.

Remarks

Coordinates are ordered by Y coordinate and then X coordinate.

Returns

A new array containing used cell coordinates in stable order.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.GetUsedCellsById(System.Int32,System.Nullable{Electron2D.Vector2I},System.Int32)

GetUsedCellsById(System.Int32, Electron2D.Vector2I?, System.Int32)

Kind: Method

public Electron2D.Vector2I[] GetUsedCellsById(System.Int32, Electron2D.Vector2I?, System.Int32)(System.Int32 sourceId, Electron2D.Vector2I? atlasCoords, System.Int32 alternativeTile)

Summary

Gets used cell coordinates filtered by stored tile identifiers.

Remarks

Filtering uses stored cell identifiers and does not require the tile set source to exist.

Parameters

  • sourceId: The source id to match, or -1 to ignore source id.
  • atlasCoords: The atlas coordinates to match, or null to ignore atlas coordinates.
  • alternativeTile: The alternative tile id to match, or -1 to ignore alternative tile id.

Returns

A new array containing matching used cell coordinates.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.GetUsedCells

GetUsedRect()

Kind: Method

public Electron2D.Rect2I GetUsedRect()()

Summary

Gets the rectangle enclosing all used cells.

Remarks

The rectangle is expressed in map coordinates.

Returns

The used cell rectangle, or an empty rectangle when no cells are used.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.GetUsedCells

HasBodyRid(Electron2D.Rid)

Kind: Method

public System.Boolean HasBodyRid(Electron2D.Rid)(Electron2D.Rid body)

Summary

Checks whether a body RID belongs to this tilemap layer.

Remarks

The RID is created only while the layer is inside a Electron2D.SceneTree.

Parameters

  • body: The body RID to check.

Returns

true when the RID is this layer's internal body RID.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.GetCoordsForBodyRid(Electron2D.Rid)

LocalToMap(Electron2D.Vector2)

Kind: Method

public Electron2D.Vector2I LocalToMap(Electron2D.Vector2)(Electron2D.Vector2 localPosition)

Summary

Converts a local position to map coordinates.

Remarks

The conversion uses floor division, so negative positions map to negative cells.

Parameters

  • localPosition: The local position in this layer.

Returns

The map coordinates containing the position.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.MapToLocal(Electron2D.Vector2I)

MapToLocal(Electron2D.Vector2I)

Kind: Method

public Electron2D.Vector2 MapToLocal(Electron2D.Vector2I)(Electron2D.Vector2I mapPosition)

Summary

Converts map coordinates to a local cell-center position.

Remarks

Rendering destination rectangles still start at the cell's top-left local position.

Parameters

  • mapPosition: The map coordinates to convert.

Returns

The local position at the center of the cell.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.LocalToMap(Electron2D.Vector2)

NotifyRuntimeTileDataUpdate()

Kind: Method

public System.Void NotifyRuntimeTileDataUpdate()()

Summary

Notifies the layer that runtime tile data has changed.

Remarks

The preview does not defer tile data caches, so this method queues a redraw and returns.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.UpdateInternals

SetCell(Electron2D.Vector2I, System.Int32, Electron2D.Vector2I, System.Int32)

Kind: Method

public System.Void SetCell(Electron2D.Vector2I, System.Int32, Electron2D.Vector2I, System.Int32)(Electron2D.Vector2I coords, System.Int32 sourceId, Electron2D.Vector2I atlasCoords, System.Int32 alternativeTile)

Summary

Stores a tile cell at map coordinates.

Remarks

Passing a negative source id or negative atlas coordinates erases the cell.

Parameters

  • coords: The map coordinates of the cell.
  • sourceId: The tile set source id, or -1 to erase the cell.
  • atlasCoords: The atlas coordinates inside the source.
  • alternativeTile: The alternative tile id.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when alternativeTile is negative for a stored cell.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.EraseCell(Electron2D.Vector2I)

UpdateInternals()

Kind: Method

public System.Void UpdateInternals()()

Summary

Applies pending tilemap updates immediately.

Remarks

The preview updates cell data immediately, so this method queues a redraw and returns.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.TileMapLayer.NotifyRuntimeTileDataUpdate

Clone this wiki locally