From b31a35d34b8bf094f808bc6283b243c8d231e4e2 Mon Sep 17 00:00:00 2001 From: geckosoft Date: Mon, 15 Nov 2010 02:08:27 +0100 Subject: [PATCH] Changed: Made it possible for maps to contain custom sequences (allowing 100% custom map-specific units to be 'build') --- OpenRA.Game/Graphics/SequenceProvider.cs | 6 ++---- OpenRA.Game/Map.cs | 13 ++++++++++--- OpenRA.Game/ModData.cs | 5 ++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Graphics/SequenceProvider.cs b/OpenRA.Game/Graphics/SequenceProvider.cs index 5599851106..acdedf814c 100644 --- a/OpenRA.Game/Graphics/SequenceProvider.cs +++ b/OpenRA.Game/Graphics/SequenceProvider.cs @@ -21,15 +21,13 @@ namespace OpenRA.Graphics { static Dictionary> units; - public static void Initialize(string[] sequenceFiles) + public static void Initialize(string[] sequenceFiles, List sequenceNodes) { units = new Dictionary>(); if (sequenceFiles.Length == 0) return; - var sequences = sequenceFiles - .Select(s => MiniYaml.FromFile(s)) - .Aggregate(MiniYaml.Merge); + var sequences = sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(sequenceNodes, MiniYaml.Merge); foreach (var s in sequences) LoadSequencesForUnit(s.Key, s.Value); diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index ee04e41f0d..516f237302 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -27,10 +27,13 @@ namespace OpenRA public Dictionary Players = new Dictionary(); public Dictionary Actors = new Dictionary(); public List Smudges = new List(); - - // Rules overrides + + // Rules overrides public List Rules = new List(); + // Sequences overrides + public List Sequences = new List(); + // Binary map data public byte TileFormat = 1; [FieldLoader.Load] public int2 MapSize; @@ -178,6 +181,9 @@ namespace OpenRA // Rules Rules = yaml.NodesDict["Rules"].Nodes; + // Sequences + Sequences = (yaml.NodesDict.ContainsKey("Sequences")) ? yaml.NodesDict["Sequences"].Nodes : new List(); + CustomTerrain = new string[MapSize.X, MapSize.Y]; LoadBinaryData(); } @@ -208,7 +214,8 @@ namespace OpenRA root.Add( new MiniYamlNode( "Waypoints", MiniYaml.FromDictionary( Waypoints ) ) ); root.Add( new MiniYamlNode( "Smudges", MiniYaml.FromList( 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")); root.WriteToFile(Path.Combine(filepath, "map.yaml")); diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index d1441dba07..785200e2d3 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -53,6 +53,7 @@ namespace OpenRA } string cachedTheatre = null; + public Map PrepareMap(string uid) { LoadScreen.Display(); @@ -63,13 +64,15 @@ namespace OpenRA var map = new Map(AvailableMaps[uid]); Rules.LoadRules(Manifest, map); + if (map.Theater != cachedTheatre) { SpriteSheetBuilder.Initialize( Rules.TileSets[map.Tileset] ); - SequenceProvider.Initialize(Manifest.Sequences); CursorProvider.Initialize(Manifest.Cursors); + SequenceProvider.Initialize(Manifest.Sequences, map.Sequences); cachedTheatre = map.Theater; } + return map; } }