Table of Contents

Class Tileset

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

Represents a tileset containing tiles from a texture atlas. Manages texture coordinates and tile properties.

public class Tileset
Inheritance
Tileset
Inherited Members

Constructors

Tileset(string, int, int, int, int, int)

Creates a new tileset with the specified properties.

public Tileset(string name, int firstGid, int tileWidth, int tileHeight, int tileCount, int columns)

Parameters

name string

Tileset name

firstGid int

First global ID

tileWidth int

Width of each tile

tileHeight int

Height of each tile

tileCount int

Total number of tiles

columns int

Number of columns in the texture

Properties

Columns

public int Columns { get; set; }

Property Value

int

FirstGid

public int FirstGid { get; set; }

Property Value

int

ImagePath

public string ImagePath { get; set; }

Property Value

string

IsTextureLoaded

public bool IsTextureLoaded { get; set; }

Property Value

bool

Name

public string Name { get; set; }

Property Value

string

Properties

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

Property Value

Dictionary<string, string>

Texture

public Texture2D Texture { get; set; }

Property Value

Texture2D

TileCount

public int TileCount { get; set; }

Property Value

int

TileHeight

public int TileHeight { get; set; }

Property Value

int

TileProperties

public Dictionary<int, TileProperties> TileProperties { get; set; }

Property Value

Dictionary<int, TileProperties>

TileWidth

public int TileWidth { get; set; }

Property Value

int

Methods

ContainsTile(int)

Checks if a global tile ID belongs to this tileset.

public bool ContainsTile(int globalTileId)

Parameters

globalTileId int

Global tile ID

Returns

bool

True if the tile belongs to this tileset

GetTileProperties(int)

Gets the tile properties for a specific local tile ID.

public TileProperties? GetTileProperties(int localTileId)

Parameters

localTileId int

Local tile ID within this tileset

Returns

TileProperties

Tile properties, or null if none defined

GetTileSourceRect(int)

Gets the source rectangle for a specific tile in the tileset texture.

public Rectangle GetTileSourceRect(int localTileId)

Parameters

localTileId int

Local tile ID within this tileset (0-based)

Returns

Rectangle

Rectangle defining the tile's position in the texture

GlobalToLocal(int)

Converts a global tile ID to a local tile ID for this tileset.

public int GlobalToLocal(int globalTileId)

Parameters

globalTileId int

Global tile ID

Returns

int

Local tile ID, or -1 if the tile doesn't belong to this tileset

LoadTexture(string)

Loads the tileset texture from the specified path.

public void LoadTexture(string imagePath)

Parameters

imagePath string

Path to the texture file

LocalToGlobal(int)

Converts a local tile ID to a global tile ID.

public int LocalToGlobal(int localTileId)

Parameters

localTileId int

Local tile ID

Returns

int

Global tile ID

SetTileProperties(int, TileProperties)

Sets properties for a specific tile.

public void SetTileProperties(int localTileId, TileProperties properties)

Parameters

localTileId int

Local tile ID within this tileset

properties TileProperties

Properties to set

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

UnloadTexture()

Unloads the tileset texture from memory.

public void UnloadTexture()