Skip to content

Commit

Permalink
Removed obsolete GetSourceVector method and added missing xml comment…
Browse files Browse the repository at this point in the history
…s in models
  • Loading branch information
TheBoneJarmer committed Aug 8, 2022
1 parent 9c4ea0f commit eb4064d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 35 deletions.
34 changes: 0 additions & 34 deletions src/TiledMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -688,40 +688,6 @@ public TiledTile GetTiledTile(TiledMapTileset mapTileset, TiledTileset tileset,
return null;
}

/// <summary>
/// This method can be used to figure out the x and y position on a Tileset image for rendering tiles.
/// </summary>
/// <param name="mapTileset">An element of the Tilesets array</param>
/// <param name="tileset">An instance of the TiledTileset class</param>
/// <param name="gid">An element within a TiledLayer.data array</param>
/// <returns>An int array of length 2 containing the x and y position of the source rect of the tileset image. Multiply the values by the tile width and height in pixels to get the actual x and y position. Returns null if the gid was not found</returns>
/// <remarks>This method currently doesn't take margin into account</remarks>
[Obsolete("Please use GetSourceRect instead because with future versions of Tiled this method may no longer be sufficient")]
public int[] GetSourceVector(TiledMapTileset mapTileset, TiledTileset tileset, int gid)
{
var tileHor = 0;
var tileVert = 0;

for (var i = 0; i < tileset.TileCount; i++)
{
if (i == gid - mapTileset.firstgid)
{
return new[] { tileHor, tileVert };
}

// Update x and y position
tileHor++;

if (tileHor == tileset.Image.width / tileset.TileWidth)
{
tileHor = 0;
tileVert++;
}
}

return null;
}

/// <summary>
/// This method can be used to figure out the source rect on a Tileset image for rendering tiles.
/// </summary>
Expand Down
23 changes: 23 additions & 0 deletions src/TiledModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,34 @@ public class TiledGroup
/// </summary>
public class TiledChunk
{
/// <summary>
/// The chunk's x position
/// </summary>
public int x;

/// <summary>
/// The chunk's y position
/// </summary>
public int y;

/// <summary>
/// The chunk's width
/// </summary>
public int width;

/// <summary>
/// The chunk's height
/// </summary>
public int height;

/// <summary>
/// The chunk's data is similar to the data array in the TiledLayer class
/// </summary>
public int[] data;

/// <summary>
/// The chunk's data rotation flags are similar to the data rotation flags array in the TiledLayer class
/// </summary>
public byte[] dataRotationFlags;
}

Expand Down
5 changes: 4 additions & 1 deletion src/TiledTileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class TiledTileset
/// </summary>
public TiledProperty[] Properties { get; set; }

/// <summary>
/// The tile offset in pixels
/// </summary>
public TiledOffset Offset { get; set; }

/// <summary>
Expand Down Expand Up @@ -192,7 +195,7 @@ private TiledProperty[] ParseProperties(XmlNodeList nodeList)
property.type = node.Attributes["type"]?.Value;
property.value = node.Attributes["value"]?.Value;

if (property.value == null && node.InnerText != null)
if (property.value == null)
{
property.value = node.InnerText;
}
Expand Down

0 comments on commit eb4064d

Please sign in to comment.