diff --git a/OpenRa.FileFormats/IniFile.cs b/OpenRa.FileFormats/IniFile.cs index 97ec1a957f..6a9592ec88 100644 --- a/OpenRa.FileFormats/IniFile.cs +++ b/OpenRa.FileFormats/IniFile.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.IO; using System.Text.RegularExpressions; +using System.Collections; namespace OpenRa.FileFormats { @@ -75,18 +76,17 @@ namespace OpenRa.FileFormats public class IniSection : IEnumerable> { - string name; + public string Name { get; private set; } Dictionary values = new Dictionary(); public IniSection( string name ) { - this.name = name; + Name = name; } public void Add( string key, string value ) { values[key] = value; - //values.Add( key, value ); } public string GetValue( string key, string defaultValue ) @@ -100,7 +100,7 @@ namespace OpenRa.FileFormats return values.GetEnumerator(); } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index e7c04dc5aa..230e3780eb 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -10,6 +10,7 @@ namespace OpenRa.Game { public static UnitInfoLoader UnitInfo; public static WeaponInfoLoader WeaponInfo; + public static WarheadInfoLoader WarheadInfo; public static Footprint Footprint; // TODO: load rules from the map, where appropriate. @@ -18,6 +19,7 @@ namespace OpenRa.Game var rulesIni = new IniFile( FileSystem.Open( "rules.ini" ) ); UnitInfo = new UnitInfoLoader( rulesIni ); WeaponInfo = new WeaponInfoLoader( rulesIni ); + WarheadInfo = new WarheadInfoLoader(rulesIni); Footprint = new Footprint(FileSystem.Open("footprint.txt")); } } diff --git a/OpenRa.Game/GameRules/WarheadInfo.cs b/OpenRa.Game/GameRules/WarheadInfo.cs new file mode 100644 index 0000000000..65441d7e2d --- /dev/null +++ b/OpenRa.Game/GameRules/WarheadInfo.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.FileFormats; +using OpenRa.Game.Graphics; + +namespace OpenRa.Game.GameRules +{ + class WarheadInfoLoader + { + readonly Dictionary warheadInfos = new Dictionary(); + + public WarheadInfoLoader(IniFile rules) + { + foreach (var s in Util.ReadAllLines(FileSystem.Open("warheads.txt"))) + { + var unitName = s.Split(',')[0]; + warheadInfos.Add(unitName.ToLowerInvariant(), + new WarheadInfo(rules.GetSection(unitName))); + } + } + + public WarheadInfo this[string unitName] + { + get + { + return warheadInfos[unitName.ToLowerInvariant()]; + } + } + } + + class WarheadInfo + { + public readonly int Spread = 1; + public readonly string Verses = "100%,100%,100%,100%,100%"; + public readonly bool Wall = false; + public readonly bool Wood = false; + public readonly bool Ore = false; + public readonly int Explosion = 0; + public readonly int InfDeath = 0; + + public WarheadInfo(IniSection ini) + { + FieldLoader.Load(this, ini); + } + } +} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 07c8bbd518..f6306613cb 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -80,6 +80,7 @@ +