Changed: Made it possible for maps to contain custom sequences (allowing 100% custom map-specific units to be 'build')
This commit is contained in:
@@ -21,15 +21,13 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
static Dictionary<string, Dictionary<string, Sequence>> units;
|
static Dictionary<string, Dictionary<string, Sequence>> units;
|
||||||
|
|
||||||
public static void Initialize(string[] sequenceFiles)
|
public static void Initialize(string[] sequenceFiles, List<MiniYamlNode> sequenceNodes)
|
||||||
{
|
{
|
||||||
units = new Dictionary<string, Dictionary<string, Sequence>>();
|
units = new Dictionary<string, Dictionary<string, Sequence>>();
|
||||||
if (sequenceFiles.Length == 0)
|
if (sequenceFiles.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var sequences = sequenceFiles
|
var sequences = sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(sequenceNodes, MiniYaml.Merge);
|
||||||
.Select(s => MiniYaml.FromFile(s))
|
|
||||||
.Aggregate(MiniYaml.Merge);
|
|
||||||
|
|
||||||
foreach (var s in sequences)
|
foreach (var s in sequences)
|
||||||
LoadSequencesForUnit(s.Key, s.Value);
|
LoadSequencesForUnit(s.Key, s.Value);
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ namespace OpenRA
|
|||||||
// Rules overrides
|
// Rules overrides
|
||||||
public List<MiniYamlNode> Rules = new List<MiniYamlNode>();
|
public List<MiniYamlNode> Rules = new List<MiniYamlNode>();
|
||||||
|
|
||||||
|
// Sequences overrides
|
||||||
|
public List<MiniYamlNode> Sequences = new List<MiniYamlNode>();
|
||||||
|
|
||||||
// Binary map data
|
// Binary map data
|
||||||
public byte TileFormat = 1;
|
public byte TileFormat = 1;
|
||||||
[FieldLoader.Load] public int2 MapSize;
|
[FieldLoader.Load] public int2 MapSize;
|
||||||
@@ -178,6 +181,9 @@ namespace OpenRA
|
|||||||
// Rules
|
// Rules
|
||||||
Rules = yaml.NodesDict["Rules"].Nodes;
|
Rules = yaml.NodesDict["Rules"].Nodes;
|
||||||
|
|
||||||
|
// Sequences
|
||||||
|
Sequences = (yaml.NodesDict.ContainsKey("Sequences")) ? yaml.NodesDict["Sequences"].Nodes : new List<MiniYamlNode>();
|
||||||
|
|
||||||
CustomTerrain = new string[MapSize.X, MapSize.Y];
|
CustomTerrain = new string[MapSize.X, MapSize.Y];
|
||||||
LoadBinaryData();
|
LoadBinaryData();
|
||||||
}
|
}
|
||||||
@@ -208,7 +214,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
root.Add( new MiniYamlNode( "Waypoints", MiniYaml.FromDictionary<string, int2>( Waypoints ) ) );
|
root.Add( new MiniYamlNode( "Waypoints", MiniYaml.FromDictionary<string, int2>( Waypoints ) ) );
|
||||||
root.Add( new MiniYamlNode( "Smudges", MiniYaml.FromList<SmudgeReference>( Smudges ) ) );
|
root.Add( new MiniYamlNode( "Smudges", MiniYaml.FromList<SmudgeReference>( Smudges ) ) );
|
||||||
root.Add( new MiniYamlNode( "Rules", null, Rules ) );
|
root.Add(new MiniYamlNode("Rules", null, Rules));
|
||||||
|
root.Add(new MiniYamlNode("Sequences", null, Sequences));
|
||||||
|
|
||||||
SaveBinaryData(Path.Combine(filepath, "map.bin"));
|
SaveBinaryData(Path.Combine(filepath, "map.bin"));
|
||||||
root.WriteToFile(Path.Combine(filepath, "map.yaml"));
|
root.WriteToFile(Path.Combine(filepath, "map.yaml"));
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
string cachedTheatre = null;
|
string cachedTheatre = null;
|
||||||
|
|
||||||
public Map PrepareMap(string uid)
|
public Map PrepareMap(string uid)
|
||||||
{
|
{
|
||||||
LoadScreen.Display();
|
LoadScreen.Display();
|
||||||
@@ -63,13 +64,15 @@ namespace OpenRA
|
|||||||
var map = new Map(AvailableMaps[uid]);
|
var map = new Map(AvailableMaps[uid]);
|
||||||
|
|
||||||
Rules.LoadRules(Manifest, map);
|
Rules.LoadRules(Manifest, map);
|
||||||
|
|
||||||
if (map.Theater != cachedTheatre)
|
if (map.Theater != cachedTheatre)
|
||||||
{
|
{
|
||||||
SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] );
|
SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] );
|
||||||
SequenceProvider.Initialize(Manifest.Sequences);
|
|
||||||
CursorProvider.Initialize(Manifest.Cursors);
|
CursorProvider.Initialize(Manifest.Cursors);
|
||||||
|
SequenceProvider.Initialize(Manifest.Sequences, map.Sequences);
|
||||||
cachedTheatre = map.Theater;
|
cachedTheatre = map.Theater;
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user