Class Tileset
Represents a tileset containing tiles from a texture atlas. Manages texture coordinates and tile properties.
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Gameplay
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class Tileset
Constructors
| Edit this page View SourceTileset(string, int, int, int, int, int)
Creates a new tileset with the specified properties.
Declaration
public Tileset(string name, int firstGid, int tileWidth, int tileHeight, int tileCount, int columns)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Tileset name |
| int | firstGid | First global ID |
| int | tileWidth | Width of each tile |
| int | tileHeight | Height of each tile |
| int | tileCount | Total number of tiles |
| int | columns | Number of columns in the texture |
Properties
| Edit this page View SourceColumns
Declaration
public int Columns { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
FirstGid
Declaration
public int FirstGid { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
ImagePath
Declaration
public string ImagePath { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
IsTextureLoaded
Declaration
public bool IsTextureLoaded { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Name
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Properties
Declaration
public Dictionary<string, string> Properties { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, string> |
Texture
Declaration
public Texture2D Texture { get; set; }
Property Value
| Type | Description |
|---|---|
| Texture2D |
TileCount
Declaration
public int TileCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TileHeight
Declaration
public int TileHeight { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TileProperties
Declaration
public Dictionary<int, TileProperties> TileProperties { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<int, TileProperties> |
TileWidth
Declaration
public int TileWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceContainsTile(int)
Checks if a global tile ID belongs to this tileset.
Declaration
public bool ContainsTile(int globalTileId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | globalTileId | Global tile ID |
Returns
| Type | Description |
|---|---|
| bool | True if the tile belongs to this tileset |
GetTileProperties(int)
Gets the tile properties for a specific local tile ID.
Declaration
public TileProperties? GetTileProperties(int localTileId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | localTileId | Local tile ID within this tileset |
Returns
| Type | Description |
|---|---|
| TileProperties | Tile properties, or null if none defined |
GetTileSourceRect(int)
Gets the source rectangle for a specific tile in the tileset texture.
Declaration
public Rectangle GetTileSourceRect(int localTileId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | localTileId | Local tile ID within this tileset (0-based) |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public int GlobalToLocal(int globalTileId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | globalTileId | Global tile ID |
Returns
| Type | Description |
|---|---|
| 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.
Declaration
public void LoadTexture(string imagePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | imagePath | Path to the texture file |
LocalToGlobal(int)
Converts a local tile ID to a global tile ID.
Declaration
public int LocalToGlobal(int localTileId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | localTileId | Local tile ID |
Returns
| Type | Description |
|---|---|
| int | Global tile ID |
SetTileProperties(int, TileProperties)
Sets properties for a specific tile.
Declaration
public void SetTileProperties(int localTileId, TileProperties properties)
Parameters
| Type | Name | Description |
|---|---|---|
| int | localTileId | Local tile ID within this tileset |
| TileProperties | properties | Properties to set |
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. |
Overrides
| Edit this page View SourceUnloadTexture()
Unloads the tileset texture from memory.
Declaration
public void UnloadTexture()