Table of Contents

Class TilemapLayer

Namespace
PopcorningGuineaPig.Engine.Gameplay
Assembly
PopcorningGuineaPig.Engine.dll

Represents a single layer within a tilemap. Contains tile data and layer-specific properties.

public class TilemapLayer
Inheritance
TilemapLayer
Inherited Members

Constructors

TilemapLayer(string, int, int)

Creates a new tilemap layer with specified dimensions.

public TilemapLayer(string name, int width, int height)

Parameters

name string

Layer name

width int

Width in tiles

height int

Height in tiles

Properties

Height

public int Height { get; set; }

Property Value

int

Name

public string Name { get; set; }

Property Value

string

Opacity

public float Opacity { get; set; }

Property Value

float

Properties

public Dictionary<string, string> Properties { get; set; }

Property Value

Dictionary<string, string>

Visible

public bool Visible { get; set; }

Property Value

bool

Width

public int Width { get; set; }

Property Value

int

Methods

Clear()

Clears all tiles in the layer (sets all to 0).

public void Clear()

GetTileCount()

Gets the number of non-empty tiles in the layer.

public int GetTileCount()

Returns

int

Count of tiles

GetTileId(int, int)

Gets the tile ID at the specified coordinates.

public int GetTileId(int x, int y)

Parameters

x int

X coordinate

y int

Y coordinate

Returns

int

Tile ID, or 0 if empty or out of bounds

HasTiles()

Checks if the layer contains any non-empty tiles.

public bool HasTiles()

Returns

bool

True if the layer has any tiles

LoadFromArray(int[])

Loads tile data from a flat array (as typically found in TMX files).

public void LoadFromArray(int[] data)

Parameters

data int[]

Flat array of tile IDs

SetTileId(int, int, int)

Sets the tile ID at the specified coordinates.

public void SetTileId(int x, int y, int tileId)

Parameters

x int

X coordinate

y int

Y coordinate

tileId int

Tile ID to set

ToArray()

Exports tile data to a flat array.

public int[] ToArray()

Returns

int[]

Flat array of tile IDs

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.