Class TilemapLayer
Represents a single layer within a tilemap. Contains tile data and layer-specific properties.
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Gameplay
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class TilemapLayer
Constructors
| Edit this page View SourceTilemapLayer(string, int, int)
Creates a new tilemap layer with specified dimensions.
Declaration
public TilemapLayer(string name, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Layer name |
| int | width | Width in tiles |
| int | height | Height in tiles |
Properties
| Edit this page View SourceHeight
Declaration
public int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Name
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Opacity
Declaration
public float Opacity { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Properties
Declaration
public Dictionary<string, string> Properties { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, string> |
Visible
Declaration
public bool Visible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Width
Declaration
public int Width { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceClear()
Clears all tiles in the layer (sets all to 0).
Declaration
public void Clear()
GetTileCount()
Gets the number of non-empty tiles in the layer.
Declaration
public int GetTileCount()
Returns
| Type | Description |
|---|---|
| int | Count of tiles |
GetTileId(int, int)
Gets the tile ID at the specified coordinates.
Declaration
public int GetTileId(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | X coordinate |
| int | y | Y coordinate |
Returns
| Type | Description |
|---|---|
| int | Tile ID, or 0 if empty or out of bounds |
HasTiles()
Checks if the layer contains any non-empty tiles.
Declaration
public bool HasTiles()
Returns
| Type | Description |
|---|---|
| bool | True if the layer has any tiles |
LoadFromArray(int[])
Loads tile data from a flat array (as typically found in TMX files).
Declaration
public void LoadFromArray(int[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | data | Flat array of tile IDs |
SetTileId(int, int, int)
Sets the tile ID at the specified coordinates.
Declaration
public void SetTileId(int x, int y, int tileId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | X coordinate |
| int | y | Y coordinate |
| int | tileId | Tile ID to set |
ToArray()
Exports tile data to a flat array.
Declaration
public int[] ToArray()
Returns
| Type | Description |
|---|---|
| int[] | Flat array of tile IDs |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents the current object. |