From 5e8e4dd9d5bd82e99ed67d38500317df26850ca1 Mon Sep 17 00:00:00 2001 From: geckosoft Date: Mon, 15 Nov 2010 02:17:55 +0100 Subject: [PATCH] Changed: Made it possible for maps to define custom & override existing weapons --- OpenRA.Game/GameRules/Rules.cs | 2 +- OpenRA.Game/Map.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/GameRules/Rules.cs b/OpenRA.Game/GameRules/Rules.cs index 43d898bb45..738478f0a2 100755 --- a/OpenRA.Game/GameRules/Rules.cs +++ b/OpenRA.Game/GameRules/Rules.cs @@ -29,7 +29,7 @@ namespace OpenRA { // Added support to extend the list of rules (add it to m.LocalRules) Info = LoadYamlRules(m.Rules, map.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y)); - Weapons = LoadYamlRules(m.Weapons, new List(), (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value)); + Weapons = LoadYamlRules(m.Weapons, map.Weapons, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value)); Voices = LoadYamlRules(m.Voices, new List(), (k, _) => new VoiceInfo(k.Value)); Music = LoadYamlRules(m.Music, new List(), (k, _) => new MusicInfo(k.Key, k.Value)); Movies = LoadYamlRules(m.Movies, new List(), (k, v) => k.Value.Value); diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 516f237302..a075d447e8 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -34,6 +34,8 @@ namespace OpenRA // Sequences overrides public List Sequences = new List(); + // Weapon overrides + public List Weapons = new List(); // Binary map data public byte TileFormat = 1; [FieldLoader.Load] public int2 MapSize; @@ -184,6 +186,9 @@ namespace OpenRA // Sequences Sequences = (yaml.NodesDict.ContainsKey("Sequences")) ? yaml.NodesDict["Sequences"].Nodes : new List(); + // Weapons + Weapons = (yaml.NodesDict.ContainsKey("Weapons")) ? yaml.NodesDict["Weapons"].Nodes : new List(); + CustomTerrain = new string[MapSize.X, MapSize.Y]; LoadBinaryData(); } @@ -216,6 +221,7 @@ namespace OpenRA root.Add( new MiniYamlNode( "Smudges", MiniYaml.FromList( Smudges ) ) ); root.Add(new MiniYamlNode("Rules", null, Rules)); root.Add(new MiniYamlNode("Sequences", null, Sequences)); + root.Add(new MiniYamlNode("Weapons", null, Weapons)); SaveBinaryData(Path.Combine(filepath, "map.bin")); root.WriteToFile(Path.Combine(filepath, "map.yaml"));