WarheadInfo loading
This commit is contained in:
@@ -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<KeyValuePair<string, string>>
|
||||
{
|
||||
string name;
|
||||
public string Name { get; private set; }
|
||||
Dictionary<string, string> values = new Dictionary<string, string>();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
48
OpenRa.Game/GameRules/WarheadInfo.cs
Normal file
48
OpenRa.Game/GameRules/WarheadInfo.cs
Normal file
@@ -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<string, WarheadInfo> warheadInfos = new Dictionary<string, WarheadInfo>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@
|
||||
<Compile Include="GameRules\Footprint.cs" />
|
||||
<Compile Include="GameRules\Rules.cs" />
|
||||
<Compile Include="GameRules\UnitInfo.cs" />
|
||||
<Compile Include="GameRules\WarheadInfo.cs" />
|
||||
<Compile Include="GameRules\WeaponInfo.cs" />
|
||||
<Compile Include="Graphics\Animation.cs" />
|
||||
<Compile Include="Game.cs" />
|
||||
|
||||
Reference in New Issue
Block a user