Cleaner TileSet init
This commit is contained in:
@@ -61,14 +61,20 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public class TileSet
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string Id;
|
||||
public readonly string TileSuffix;
|
||||
public readonly Dictionary<string, TerrainTypeInfo> Terrain = new Dictionary<string, TerrainTypeInfo>();
|
||||
public readonly Dictionary<ushort, Terrain> Tiles = new Dictionary<ushort, Terrain>();
|
||||
public readonly Dictionary<ushort, TileTemplate> Templates = new Dictionary<ushort, TileTemplate>();
|
||||
|
||||
public TileSet( string tilesetFile, string suffix )
|
||||
public TileSet( string filepath )
|
||||
{
|
||||
var yaml = MiniYaml.FromFile(tilesetFile);
|
||||
var yaml = MiniYaml.FromFile(filepath);
|
||||
|
||||
// General info
|
||||
FieldLoader.Load(this, yaml["General"]);
|
||||
|
||||
// TerrainTypes
|
||||
foreach (var tt in yaml["Terrain"].Nodes)
|
||||
{
|
||||
@@ -84,13 +90,27 @@ namespace OpenRA.FileFormats
|
||||
Templates.Add(t.Id, t);
|
||||
|
||||
// Artwork
|
||||
using( Stream s = FileSystem.Open( t.Image + "." + suffix ) )
|
||||
using( Stream s = FileSystem.Open( t.Image + "." + TileSuffix ) )
|
||||
{
|
||||
if( !Tiles.ContainsKey( t.Id ) )
|
||||
Tiles.Add( t.Id, new Terrain( s ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadTiles()
|
||||
{
|
||||
// Templates
|
||||
foreach (var t in Templates)
|
||||
{
|
||||
// Artwork
|
||||
using( Stream s = FileSystem.Open( t.Value.Image + "." + TileSuffix ) )
|
||||
{
|
||||
if( !Tiles.ContainsKey( t.Key ) )
|
||||
Tiles.Add( t.Key, new Terrain( s ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] GetBytes(TileReference<ushort,byte> r)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.FileFormats
|
||||
public readonly string[]
|
||||
Folders, Packages, Rules,
|
||||
Sequences, Chrome, Assemblies, ChromeLayout,
|
||||
Weapons, Voices, Music, Terrain;
|
||||
Weapons, Voices, Music, TileSets;
|
||||
|
||||
public readonly string ShellmapUid;
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace OpenRA.FileFormats
|
||||
Weapons = YamlList(yaml, "Weapons");
|
||||
Voices = YamlList(yaml, "Voices");
|
||||
Music = YamlList(yaml, "Music");
|
||||
Terrain = YamlList(yaml, "Terrain");
|
||||
|
||||
TileSets = YamlList(yaml, "TileSets");
|
||||
|
||||
ShellmapUid = yaml["ShellmapUid"].Value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user