public bool TryGetTileInfo(TerrainTile r, out TerrainTileInfo info) { if (!Templates.TryGetValue(r.Type, out var tpl) || !tpl.Contains(r.Index)) { info = null; return(false); } info = tpl[r.Index]; return(info != null); }
static TerrainTileInfo LoadTileInfo(TileSet tileSet, MiniYaml my) { var tile = new TerrainTileInfo(); FieldLoader.Load(tile, my); // Terrain type must be converted from a string to an index tile.GetType().GetField("TerrainType").SetValue(tile, tileSet.GetTerrainIndex(my.Value)); // Fall back to the terrain-type color if necessary var overrideColor = tileSet.TerrainInfo[tile.TerrainType].Color; if (tile.LeftColor == default(Color)) { tile.GetType().GetField("LeftColor").SetValue(tile, overrideColor); } if (tile.RightColor == default(Color)) { tile.GetType().GetField("RightColor").SetValue(tile, overrideColor); } return(tile); }
static TerrainTileInfo LoadTileInfo(TileSet tileSet, MiniYaml my) { var tile = new TerrainTileInfo(); FieldLoader.Load(tile, my); // Terrain type must be converted from a string to an index tile.GetType().GetField("TerrainType").SetValue(tile, tileSet.GetTerrainIndex(my.Value)); // Fall back to the terrain-type color if necessary var overrideColor = tileSet.TerrainInfo[tile.TerrainType].Color; if (tile.LeftColor == default(Color)) tile.GetType().GetField("LeftColor").SetValue(tile, overrideColor); if (tile.RightColor == default(Color)) tile.GetType().GetField("RightColor").SetValue(tile, overrideColor); return tile; }