... and the rest.
This commit is contained in:
@@ -112,10 +112,10 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
tabSprites = groups
|
tabSprites = groups
|
||||||
.SelectMany(g => Rules.Categories[g])
|
.SelectMany(g => Rules.Categories[g])
|
||||||
.Where(u => Rules.UnitInfo[u].TechLevel != -1)
|
.Where(u => Rules.NewUnitInfo[u].Traits.Contains<BuildableInfo>())
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
u => u,
|
u => u,
|
||||||
u => SpriteSheetBuilder.LoadAllSprites(Rules.UnitInfo[u].Icon ?? (u + "icon"))[0]);
|
u => SpriteSheetBuilder.LoadAllSprites(Rules.NewUnitInfo[u].Traits.Get<BuildableInfo>().Icon ?? (u + "icon"))[0]);
|
||||||
|
|
||||||
spsprites = Rules.SupportPowerInfo
|
spsprites = Rules.SupportPowerInfo
|
||||||
.ToDictionary(
|
.ToDictionary(
|
||||||
@@ -531,8 +531,8 @@ namespace OpenRa.Game
|
|||||||
var buildableItems = Rules.TechTree.BuildableItems(Game.LocalPlayer, queueName).ToArray();
|
var buildableItems = Rules.TechTree.BuildableItems(Game.LocalPlayer, queueName).ToArray();
|
||||||
|
|
||||||
var allItems = Rules.TechTree.AllItems(Game.LocalPlayer, queueName)
|
var allItems = Rules.TechTree.AllItems(Game.LocalPlayer, queueName)
|
||||||
.Where(a => Rules.UnitInfo[a].TechLevel != -1)
|
.Where(a => Rules.NewUnitInfo[a].Traits.Contains<BuildableInfo>())
|
||||||
.OrderBy(a => Rules.UnitInfo[a].TechLevel);
|
.OrderBy(a => Rules.NewUnitInfo[a].Traits.Get<BuildableInfo>().TechLevel);
|
||||||
|
|
||||||
var queue = Game.LocalPlayer.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
var queue = Game.LocalPlayer.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||||
|
|
||||||
|
|||||||
16
OpenRa.Game/GameRules/ArmorType.cs
Executable file
16
OpenRa.Game/GameRules/ArmorType.cs
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRa.Game.GameRules
|
||||||
|
{
|
||||||
|
public enum ArmorType
|
||||||
|
{
|
||||||
|
none = 0,
|
||||||
|
wood = 1,
|
||||||
|
light = 2,
|
||||||
|
heavy = 3,
|
||||||
|
concrete = 4,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,6 @@ namespace OpenRa.Game
|
|||||||
public static IniFile AllRules;
|
public static IniFile AllRules;
|
||||||
public static Dictionary<string, List<string>> Categories = new Dictionary<string, List<string>>();
|
public static Dictionary<string, List<string>> Categories = new Dictionary<string, List<string>>();
|
||||||
public static Dictionary<string, string> UnitCategory;
|
public static Dictionary<string, string> UnitCategory;
|
||||||
[Obsolete] public static InfoLoader<LegacyUnitInfo> UnitInfo;
|
|
||||||
public static InfoLoader<WeaponInfo> WeaponInfo;
|
public static InfoLoader<WeaponInfo> WeaponInfo;
|
||||||
public static InfoLoader<WarheadInfo> WarheadInfo;
|
public static InfoLoader<WarheadInfo> WarheadInfo;
|
||||||
public static InfoLoader<ProjectileInfo> ProjectileInfo;
|
public static InfoLoader<ProjectileInfo> ProjectileInfo;
|
||||||
@@ -64,14 +63,6 @@ namespace OpenRa.Game
|
|||||||
"Plane");
|
"Plane");
|
||||||
UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair<string, string>(y, x.Key))).ToDictionary(x => x.Key, x => x.Value);
|
UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair<string, string>(y, x.Key))).ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
|
||||||
UnitInfo = new InfoLoader<LegacyUnitInfo>(
|
|
||||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Building", s => new LegacyBuildingInfo(s)),
|
|
||||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Defense", s => new LegacyBuildingInfo(s)),
|
|
||||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Infantry", s => new InfantryInfo(s)),
|
|
||||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Vehicle", s => new VehicleInfo(s)),
|
|
||||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Ship", s => new VehicleInfo(s)),
|
|
||||||
Pair.New<string, Func<string, LegacyUnitInfo>>("Plane", s => new VehicleInfo(s)));
|
|
||||||
|
|
||||||
LoadCategories(
|
LoadCategories(
|
||||||
"Weapon",
|
"Weapon",
|
||||||
"Warhead",
|
"Warhead",
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRa.Game.GameRules
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach( var p in bi.Prerequisites )
|
foreach( var p in bi.Prerequisites )
|
||||||
if (Rules.UnitInfo[p.ToLowerInvariant()].Owner.Any(x => x == player.Race))
|
if (Rules.NewUnitInfo[p.ToLowerInvariant()].Traits.Get<BuildableInfo>().Owner.Any(x => x == player.Race))
|
||||||
if( playerBuildings[ p ].Count == 0 )
|
if( playerBuildings[ p ].Count == 0 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -58,8 +58,8 @@ namespace OpenRa.Game.GameRules
|
|||||||
|
|
||||||
public IEnumerable<string> AllItems(Player player, params string[] categories)
|
public IEnumerable<string> AllItems(Player player, params string[] categories)
|
||||||
{
|
{
|
||||||
return categories.SelectMany(x => Rules.Categories[x]).Select(x => Rules.UnitInfo[x].Name)
|
return categories.SelectMany(x => Rules.Categories[x]).Select(x => Rules.NewUnitInfo[x].Name)
|
||||||
.Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */
|
.Where(x => Rules.NewUnitInfo[x].Traits.Get<BuildableInfo>().Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<NewUnitInfo> UnitBuiltAt( NewUnitInfo info )
|
public IEnumerable<NewUnitInfo> UnitBuiltAt( NewUnitInfo info )
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
namespace OpenRa.Game.GameRules
|
|
||||||
{
|
|
||||||
public enum ArmorType
|
|
||||||
{
|
|
||||||
none = 0,
|
|
||||||
wood = 1,
|
|
||||||
light = 2,
|
|
||||||
heavy = 3,
|
|
||||||
concrete = 4,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LegacyUnitInfo : ActorInfo
|
|
||||||
{
|
|
||||||
public readonly string Name;
|
|
||||||
|
|
||||||
public readonly string Description = "";
|
|
||||||
public readonly string[] Traits;
|
|
||||||
|
|
||||||
public readonly int Ammo = -1;
|
|
||||||
public readonly ArmorType Armor = ArmorType.none;
|
|
||||||
[Obsolete] public readonly bool DoubleOwned = false;
|
|
||||||
[Obsolete] public readonly bool Cloakable = false;
|
|
||||||
public readonly int Cost = 0;
|
|
||||||
public readonly bool Crewed = false;
|
|
||||||
public readonly bool Explodes = false;
|
|
||||||
public readonly int GuardRange = -1; // -1 = use weapon's range
|
|
||||||
public readonly string Image = null; // sprite-set to use when rendering
|
|
||||||
public readonly bool Invisible = false;
|
|
||||||
public readonly Race[] Owner = { Race.Allies, Race.Soviet };
|
|
||||||
public readonly int Points = 0;
|
|
||||||
public readonly string[] Prerequisite = { };
|
|
||||||
public readonly string Primary = null;
|
|
||||||
public readonly string Secondary = null;
|
|
||||||
public readonly int ROT = 255;
|
|
||||||
public readonly int Reload = 0;
|
|
||||||
public readonly bool SelfHealing = false;
|
|
||||||
[Obsolete] public readonly bool Sensors = false; // no idea what this does
|
|
||||||
public readonly int Sight = 1;
|
|
||||||
public readonly int Strength = 1;
|
|
||||||
public readonly int TechLevel = -1;
|
|
||||||
public readonly bool WaterBound = false;
|
|
||||||
public readonly string[] BuiltAt = { };
|
|
||||||
public readonly int[] PrimaryOffset = { 0, 0 };
|
|
||||||
public readonly int[] SecondaryOffset = null;
|
|
||||||
public readonly int[] RotorOffset = { 0, 0 };
|
|
||||||
public readonly int[] RotorOffset2 = null;
|
|
||||||
public readonly int Recoil = 0;
|
|
||||||
public readonly bool MuzzleFlash = false;
|
|
||||||
public readonly int SelectionPriority = 10;
|
|
||||||
public readonly int InitialFacing = 128;
|
|
||||||
public readonly bool Selectable = true;
|
|
||||||
public readonly int FireDelay = 0;
|
|
||||||
public readonly string LongDesc = null;
|
|
||||||
public readonly int OrePips = 0;
|
|
||||||
public readonly string Icon = null;
|
|
||||||
public readonly int[] SelectionSize = null;
|
|
||||||
public readonly int Passengers = 0;
|
|
||||||
public readonly int UnloadFacing = 0;
|
|
||||||
public readonly UnitMovementType[] PassengerTypes = null;
|
|
||||||
|
|
||||||
// weapon origins and firing angles within the turrets. 3 values per position.
|
|
||||||
public readonly int[] PrimaryLocalOffset = { };
|
|
||||||
public readonly int[] SecondaryLocalOffset = { };
|
|
||||||
|
|
||||||
public LegacyUnitInfo(string name) { Name = name; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LegacyMobileInfo : LegacyUnitInfo
|
|
||||||
{
|
|
||||||
public readonly int Speed = 0;
|
|
||||||
public readonly bool NoMovingFire = false;
|
|
||||||
public readonly string Voice = "GenericVoice";
|
|
||||||
|
|
||||||
public LegacyMobileInfo(string name) : base(name) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InfantryInfo : LegacyMobileInfo
|
|
||||||
{
|
|
||||||
public readonly bool C4 = false;
|
|
||||||
public readonly bool FraidyCat = false;
|
|
||||||
public readonly bool Infiltrate = false;
|
|
||||||
public readonly bool IsCanine = false;
|
|
||||||
public readonly int SquadSize = 1;
|
|
||||||
|
|
||||||
public InfantryInfo(string name) : base(name) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class VehicleInfo : LegacyMobileInfo
|
|
||||||
{
|
|
||||||
public readonly bool Tracked = false;
|
|
||||||
|
|
||||||
public VehicleInfo(string name) : base(name) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LegacyBuildingInfo : LegacyUnitInfo
|
|
||||||
{
|
|
||||||
public readonly int2 Dimensions = new int2(1, 1);
|
|
||||||
public readonly string Footprint = "x";
|
|
||||||
public readonly string[] Produces = { };
|
|
||||||
|
|
||||||
public readonly bool BaseNormal = true;
|
|
||||||
public readonly int Adjacent = 1;
|
|
||||||
public readonly bool Bib = false;
|
|
||||||
public readonly bool Capturable = false;
|
|
||||||
public readonly int Power = 0;
|
|
||||||
public readonly bool Powered = false;
|
|
||||||
public readonly bool Repairable = true;
|
|
||||||
public readonly int Storage = 0;
|
|
||||||
public readonly bool Unsellable = false;
|
|
||||||
public readonly int[] RallyPoint = { 1, 3 };
|
|
||||||
public readonly float[] SpawnOffset = null;
|
|
||||||
|
|
||||||
public LegacyBuildingInfo(string name) : base(name) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -94,6 +94,7 @@
|
|||||||
<Compile Include="Exts.cs" />
|
<Compile Include="Exts.cs" />
|
||||||
<Compile Include="GameRules\ActorInfo.cs" />
|
<Compile Include="GameRules\ActorInfo.cs" />
|
||||||
<Compile Include="GameRules\AftermathInfo.cs" />
|
<Compile Include="GameRules\AftermathInfo.cs" />
|
||||||
|
<Compile Include="GameRules\ArmorType.cs" />
|
||||||
<Compile Include="GameRules\GeneralInfo.cs" />
|
<Compile Include="GameRules\GeneralInfo.cs" />
|
||||||
<Compile Include="GameRules\NewUnitInfo.cs" />
|
<Compile Include="GameRules\NewUnitInfo.cs" />
|
||||||
<Compile Include="GameRules\SupportPowerInfo.cs" />
|
<Compile Include="GameRules\SupportPowerInfo.cs" />
|
||||||
@@ -157,7 +158,6 @@
|
|||||||
<Compile Include="GameRules\InfoLoader.cs" />
|
<Compile Include="GameRules\InfoLoader.cs" />
|
||||||
<Compile Include="GameRules\ProjectileInfo.cs" />
|
<Compile Include="GameRules\ProjectileInfo.cs" />
|
||||||
<Compile Include="GameRules\Rules.cs" />
|
<Compile Include="GameRules\Rules.cs" />
|
||||||
<Compile Include="GameRules\UnitInfo.cs" />
|
|
||||||
<Compile Include="GameRules\WarheadInfo.cs" />
|
<Compile Include="GameRules\WarheadInfo.cs" />
|
||||||
<Compile Include="GameRules\WeaponInfo.cs" />
|
<Compile Include="GameRules\WeaponInfo.cs" />
|
||||||
<Compile Include="Graphics\Animation.cs" />
|
<Compile Include="Graphics\Animation.cs" />
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRa.Game.GameRules;
|
using OpenRa.Game.GameRules;
|
||||||
using OpenRa.Game.SupportPowers;
|
using OpenRa.Game.SupportPowers;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
@@ -49,7 +50,7 @@ namespace OpenRa.Game
|
|||||||
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
var buildings = Rules.TechTree.GatherBuildings(Owner);
|
||||||
var effectivePrereq = Info.Prerequisite
|
var effectivePrereq = Info.Prerequisite
|
||||||
.Select( a => a.ToLowerInvariant() )
|
.Select( a => a.ToLowerInvariant() )
|
||||||
.Where( a => Rules.UnitInfo[a].Owner
|
.Where( a => Rules.NewUnitInfo[a].Traits.Get<BuildableInfo>().Owner
|
||||||
.Any( r => r == Owner.Race ));
|
.Any( r => r == Owner.Race ));
|
||||||
|
|
||||||
IsAvailable = Info.TechLevel > -1
|
IsAvailable = Info.TechLevel > -1
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits
|
|||||||
case "StartProduction":
|
case "StartProduction":
|
||||||
{
|
{
|
||||||
string group = Rules.UnitCategory[ order.TargetString ];
|
string group = Rules.UnitCategory[ order.TargetString ];
|
||||||
var ui = Rules.UnitInfo[ order.TargetString ];
|
var ui = Rules.NewUnitInfo[ order.TargetString ].Traits.Get<BuildableInfo>();
|
||||||
var time = ui.Cost
|
var time = ui.Cost
|
||||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||||
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
|
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||||
|
|||||||
Reference in New Issue
Block a user