added units.ini (and campaignUnits.ini), and IniFile got support for load/merging multiple files.
- Rules can now handle map-specific rules changes
- units.ini replaces {buildings,units,infantry}.txt (or will replace; sidebar still uses them)
- Added support for loading map-placed units/structures - try scg11eb.ini
- added FCOM
This commit is contained in:
@@ -12,15 +12,15 @@ namespace OpenRa.Game.GameRules
|
||||
{
|
||||
readonly Dictionary<string, T> infos = new Dictionary<string, T>();
|
||||
|
||||
public InfoLoader(IniFile rules, params Pair<string, Func<string,T>>[] srcs)
|
||||
public InfoLoader(params Pair<string, Func<string,T>>[] srcs)
|
||||
{
|
||||
foreach (var src in srcs)
|
||||
foreach (var s in Util.ReadAllLines(FileSystem.Open(src.First)))
|
||||
foreach (var s in Rules.AllRules.GetSection(src.First))
|
||||
{
|
||||
var name = s.Split(',')[0];
|
||||
var t = src.Second(name.ToLowerInvariant());
|
||||
FieldLoader.Load(t, rules.GetSection(name));
|
||||
infos[name.ToLowerInvariant()] = t;
|
||||
var name = s.Key.ToLowerInvariant();
|
||||
var t = src.Second(name);
|
||||
FieldLoader.Load(t, Rules.AllRules.GetSection(name));
|
||||
infos[name] = t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,10 @@ namespace OpenRa.Game.GameRules
|
||||
{
|
||||
get { return infos[name.ToLowerInvariant()]; }
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<string, T>> GetEnumerator()
|
||||
{
|
||||
return infos.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,29 +9,35 @@ namespace OpenRa.Game
|
||||
{
|
||||
static class Rules
|
||||
{
|
||||
public static IniFile AllRules;
|
||||
public static InfoLoader<UnitInfo> UnitInfo;
|
||||
public static InfoLoader<WeaponInfo> WeaponInfo;
|
||||
public static InfoLoader<WarheadInfo> WarheadInfo;
|
||||
public static InfoLoader<ProjectileInfo> ProjectileInfo;
|
||||
public static Footprint Footprint;
|
||||
|
||||
// TODO: load rules from the map, where appropriate.
|
||||
public static void LoadRules()
|
||||
public static void LoadRules( string mapFileName )
|
||||
{
|
||||
var rulesIni = new IniFile(FileSystem.Open("rules.ini"));
|
||||
AllRules = new IniFile(
|
||||
FileSystem.Open( mapFileName ),
|
||||
FileSystem.Open( "rules.ini" ),
|
||||
FileSystem.Open( "units.ini" ),
|
||||
FileSystem.Open( "campaignUnits.ini" ) );
|
||||
|
||||
UnitInfo = new InfoLoader<UnitInfo>(rulesIni,
|
||||
Pair.New<string,Func<string,UnitInfo>>( "buildings.txt", s => new UnitInfo.BuildingInfo(s)),
|
||||
Pair.New<string, Func<string,UnitInfo>>("infantry.txt", s => new UnitInfo.InfantryInfo(s)),
|
||||
Pair.New<string,Func<string,UnitInfo>>( "vehicles.txt", s => new UnitInfo.VehicleInfo(s)));
|
||||
UnitInfo = new InfoLoader<UnitInfo>(
|
||||
Pair.New<string,Func<string,UnitInfo>>( "BuildingTypes", s => new UnitInfo.BuildingInfo(s)),
|
||||
Pair.New<string,Func<string,UnitInfo>>( "InfantryTypes", s => new UnitInfo.InfantryInfo(s)),
|
||||
Pair.New<string,Func<string,UnitInfo>>( "VehicleTypes", s => new UnitInfo.VehicleInfo(s)),
|
||||
Pair.New<string,Func<string,UnitInfo>>( "ShipTypes", s => new UnitInfo.VehicleInfo(s)),
|
||||
Pair.New<string,Func<string,UnitInfo>>( "PlaneTypes", s => new UnitInfo.VehicleInfo(s)));
|
||||
|
||||
WeaponInfo = new InfoLoader<WeaponInfo>(rulesIni,
|
||||
Pair.New<string,Func<string,WeaponInfo>>("weapons.txt", _ => new WeaponInfo()));
|
||||
WarheadInfo = new InfoLoader<WarheadInfo>(rulesIni,
|
||||
Pair.New<string,Func<string,WarheadInfo>>("warheads.txt", _ => new WarheadInfo()));
|
||||
WeaponInfo = new InfoLoader<WeaponInfo>(
|
||||
Pair.New<string,Func<string,WeaponInfo>>("WeaponTypes", _ => new WeaponInfo()));
|
||||
WarheadInfo = new InfoLoader<WarheadInfo>(
|
||||
Pair.New<string,Func<string,WarheadInfo>>("WarheadTypes", _ => new WarheadInfo()));
|
||||
|
||||
ProjectileInfo = new InfoLoader<ProjectileInfo>(rulesIni,
|
||||
Pair.New<string, Func<string, ProjectileInfo>>("projectiles.txt", _ => new ProjectileInfo()));
|
||||
ProjectileInfo = new InfoLoader<ProjectileInfo>(
|
||||
Pair.New<string, Func<string, ProjectileInfo>>("ProjectileTypes", _ => new ProjectileInfo()));
|
||||
|
||||
Footprint = new Footprint(FileSystem.Open("footprint.txt"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user