From 12c2dbfd38c569904c9c6bb59d12d833121cfc06 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 20:52:01 +1300 Subject: [PATCH 01/83] start of converter --- OpenRa.sln | 22 +++++++ RulesConverter/Program.cs | 49 +++++++++++++++ RulesConverter/Properties/AssemblyInfo.cs | 36 +++++++++++ RulesConverter/RulesConverter.csproj | 77 +++++++++++++++++++++++ ra.yaml | 36 +++++++---- 5 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 RulesConverter/Program.cs create mode 100644 RulesConverter/Properties/AssemblyInfo.cs create mode 100644 RulesConverter/RulesConverter.csproj diff --git a/OpenRa.sln b/OpenRa.sln index 2d8e00e87b..ae77fb3c37 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SequenceEditor", "SequenceE EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Server", "OpenRA.Server\OpenRA.Server.csproj", "{76F621A1-3D8E-4A99-9F7E-B071EB657817}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesConverter", "RulesConverter\RulesConverter.csproj", "{BBE7C0D7-7529-4C34-9910-206866F204EF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug (x86)|Any CPU = Debug (x86)|Any CPU @@ -158,6 +160,26 @@ Global {76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Mixed Platforms.Build.0 = Release|Any CPU {76F621A1-3D8E-4A99-9F7E-B071EB657817}.Release|Win32.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Any CPU.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Any CPU.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Win32.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Any CPU.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Any CPU.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Mixed Platforms.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Mixed Platforms.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release (x86)|Win32.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Any CPU.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Release|Win32.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs new file mode 100644 index 0000000000..08b6050598 --- /dev/null +++ b/RulesConverter/Program.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.FileFormats; +using System.IO; +using IjwFramework.Types; +using Yaml; + +namespace RulesConverter +{ + class Program + { + static void Main(string[] args) + { + FileSystem.Mount(new Folder("./")); + + var ruleStreams = args + .Where(a => a.EndsWith(".ini")) + .Select(a => FileSystem.Open(a)).ToArray(); + + var rules = new IniFile(ruleStreams); + + var outputFile = args.Single(a => a.EndsWith(".yaml")); + + var categoryMap = new Dictionary> + { + { "VehicleTypes", Pair.New( "DefaultVehicle", "Vehicle" ) }, + { "ShipTypes", Pair.New( "DefaultShip", "Ship" ) }, + { "PlaneTypes", Pair.New( "DefaultPlane", "Plane" ) }, + { "DefenseTypes", Pair.New( "DefaultDefense", "Defense" ) }, + { "BuildingTypes", Pair.New( "DefaultBuilding", "Building" ) }, + { "InfantryTypes", Pair.New( "DefaultInfantry", "Infantry" ) }, + }; + + using (var writer = File.CreateText(outputFile)) + { + foreach (var cat in categoryMap) + foreach (var item in rules.GetSection(cat.Key).Select(a => a.Key)) + { + var iniSection = rules.GetSection(item); + var yamlSection = new MappingNode(new Yaml.String(item), new Yaml.Null()); + var doc = new Yaml.Mapping(new[] { yamlSection }); + writer.Write(doc.Write()); + } + } + } + } +} diff --git a/RulesConverter/Properties/AssemblyInfo.cs b/RulesConverter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3209d221c5 --- /dev/null +++ b/RulesConverter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("RulesConverter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("RulesConverter")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6b0eb619-b53d-4b2a-bbfd-585fcab99b22")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/RulesConverter/RulesConverter.csproj b/RulesConverter/RulesConverter.csproj new file mode 100644 index 0000000000..207bcfcfbf --- /dev/null +++ b/RulesConverter/RulesConverter.csproj @@ -0,0 +1,77 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {BBE7C0D7-7529-4C34-9910-206866F204EF} + Exe + Properties + RulesConverter + RulesConverter + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\Ijw.DirectX\Ijw.Framework\IjwFramework\bin\Release\IjwFramework.dll + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + False + ..\thirdparty\yaml\bin\Debug\Yaml.dll + + + + + + + + + {2F9E7A23-56C0-4286-9C8E-1060A9B2F073} + OpenRa.DataStructures + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRa.FileFormats + + + + + \ No newline at end of file diff --git a/ra.yaml b/ra.yaml index c6e03e0b9b..6c6153d54e 100644 --- a/ra.yaml +++ b/ra.yaml @@ -4,14 +4,28 @@ Vehicles: V2RL: - Buildable: { Description="V2 Rocket", Prerequisites=[weap,dome], TechLevel=4, Cost=700, - LongDesc="Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" } - Unit: { HP=150, Armor=light, Crewed=yes, Voice=VehicleVoice } - Mobile: { Sight=5, ROT=5, Speed=7, UMT=Track } - AttackBase: { Primary=SCUD, Ammo=1 } - RenderUnitReload: {} - AutoTarget: {} - Repairable: {} - Chronoshiftable: {} - Passenger: {} - IronCurtainable: {} \ No newline at end of file + Buildable: + Description="V2 Rocket" + Prerequisites=[weap,dome] + TechLevel=4 + Cost=700, + LongDesc="Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Unit: + HP=150 + Armor=light + Crewed=yes + Voice=VehicleVoice + Mobile: + Sight=5 + ROT=5 + Speed=7 + UMT=Track + AttackBase: + Primary=SCUD + Ammo=1 + RenderUnitReload: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: \ No newline at end of file From 8a484223850c3120df67ae68c758d8d966b1d408 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 21:51:34 +1300 Subject: [PATCH 02/83] converter sortof half works --- RulesConverter/Program.cs | 125 +++- out.rul | 1475 +++++++++++++++++++++++++++++++++++++ 2 files changed, 1595 insertions(+), 5 deletions(-) create mode 100644 out.rul diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 08b6050598..7cbb7f228d 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -5,10 +5,11 @@ using System.Text; using OpenRa.FileFormats; using System.IO; using IjwFramework.Types; -using Yaml; namespace RulesConverter { + using PL = Dictionary; + class Program { static void Main(string[] args) @@ -21,7 +22,7 @@ namespace RulesConverter var rules = new IniFile(ruleStreams); - var outputFile = args.Single(a => a.EndsWith(".yaml")); + var outputFile = args.Single(a => a.EndsWith(".rul")); var categoryMap = new Dictionary> { @@ -33,15 +34,129 @@ namespace RulesConverter { "InfantryTypes", Pair.New( "DefaultInfantry", "Infantry" ) }, }; + var traitMap = new Dictionary + { + { "Unit", new PL { + { "HP", "Strength" }, + { "Armor", "Armor" }, + { "Crewed", "Crewed" } } + }, + + { "Selectable", new PL { + { "Priority", "SelectionPriority" }, + { "Voice", "Voice" }, + { "@Bounds", "SelectionSize" } } + }, + + { "Mobile", new PL { + { "Sight", "Sight" }, + { "ROT", "ROT" }, + { "Speed", "Speed" } } + //{ "MovementType", ... }, + }, + + { "Plane", new PL { + { "ROT", "ROT" }, + { "Speed", "Speed" } } + }, + + { "Helicopter", new PL { + { "ROT", "ROT" }, + { "Speed", "Speed" } } + }, + + { "RenderBuilding", new PL { + { "Image", "Image" } } + }, + + { "RenderUnit", new PL { + { "Image", "Image" } } + }, + + { "RenderBuildingCharge", new PL { + { "Image", "Image" } } + }, + + { "RenderBuildingOre", new PL { + { "Image", "Image" } } + }, + + { "RenderBuildingTurreted", new PL { + { "Image", "Image" } } + }, + + { "RenderInfantry", new PL { + { "Image", "Image" } } + }, + + { "RenderUnitMuzzleFlash", new PL { + { "Image", "Image" } } + }, + + { "RenderUnitReload", new PL { + { "Image", "Image" } } + }, + + { "RenderUnitRotor", new PL { + { "Image", "Image" } } + }, + + { "RenderUnitSpinner", new PL { + { "Image", "Image" } } + }, + + { "RenderUnitTurreted", new PL { + { "Image", "Image" } } + }, + }; + using (var writer = File.CreateText(outputFile)) { foreach (var cat in categoryMap) foreach (var item in rules.GetSection(cat.Key).Select(a => a.Key)) { var iniSection = rules.GetSection(item); - var yamlSection = new MappingNode(new Yaml.String(item), new Yaml.Null()); - var doc = new Yaml.Mapping(new[] { yamlSection }); - writer.Write(doc.Write()); + writer.WriteLine("{0}:", item); + writer.WriteLine("\tInherits: {0}", cat.Value.First); + + var techLevel = iniSection.GetValue("TechLevel", "-1"); + if (techLevel != "-1") + { + writer.WriteLine("\tBuildable:"); + writer.WriteLine("\t\tTechLevel: {0}", techLevel); + writer.WriteLine("\t\tDescription: \"{0}\"", iniSection.GetValue("Description", "")); + writer.WriteLine("\t\tTab: \"{0}\"", cat.Value.Second); + writer.WriteLine("\t\tPrerequisites: [{0}]", iniSection.GetValue("Prerequisite", "")); + writer.WriteLine("\t\tOwner: {0}", iniSection.GetValue("Owner", "")); + writer.WriteLine("\t\tLongDesc: \"{0}\"", iniSection.GetValue("LongDesc", "")); + writer.WriteLine("\t\tCost: {0}", iniSection.GetValue("Cost", "")); + if (iniSection.Contains( "Icon" )) + writer.WriteLine("\t\tIcon: {0}", iniSection.GetValue("Icon", "")); + } + + var traits = iniSection.GetValue("Traits", "") + .Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); + + if (iniSection.GetValue("Selectable", "yes") == "yes") + traits.Add("Selectable"); + + foreach (var t in traits) + { + writer.WriteLine("\t{0}:", t); + if (traitMap.ContainsKey(t)) + foreach (var kv in traitMap[t]) + { + var v = iniSection.GetValue(kv.Value, ""); + var fmt = "\t\t{0}: {1}"; + var k = kv.Key; + if (k.StartsWith("@")) { k = k.Substring(1); fmt = "\t\t{0}: [{1}]"; } + if (k.StartsWith("$")) { k = k.Substring(1); fmt = "\t\t{0}: \"{1}\""; } + + if (!string.IsNullOrEmpty(v)) writer.WriteLine(fmt, k, v); + } + } + + writer.WriteLine(); } } } diff --git a/out.rul b/out.rul new file mode 100644 index 0000000000..a9658f9e4f --- /dev/null +++ b/out.rul @@ -0,0 +1,1475 @@ +V2RL: + Inherits: DefaultVehicle + Buildable: + TechLevel: 4 + Description: "V2 Rocket" + Tab: "Vehicle" + Prerequisites: [weap,dome] + Owner: soviet + LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Cost: 700 + Unit: + HP: 150 + Armor: light + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 7 + AttackBase: + RenderUnitReload: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +1TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 4 + Description: "Light Tank" + Tab: "Vehicle" + Prerequisites: [weap] + Owner: allies + LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" + Cost: 700 + Unit: + HP: 300 + Armor: heavy + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 9 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +2TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 6 + Description: "Medium Tank" + Tab: "Vehicle" + Prerequisites: [weap] + Owner: allies + LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Cost: 800 + Unit: + HP: 400 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 8 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +3TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 4 + Description: "Heavy Tank" + Tab: "Vehicle" + Prerequisites: [weap] + Owner: soviet + LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Cost: 950 + Unit: + HP: 400 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 7 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +4TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 10 + Description: "Mammoth Tank" + Tab: "Vehicle" + Prerequisites: [weap,stek] + Owner: soviet + LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Cost: 1700 + Unit: + HP: 600 + Armor: heavy + Crewed: yes + Mobile: + Sight: 6 + ROT: 5 + Speed: 4 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +MRJ: + Inherits: DefaultVehicle + Buildable: + TechLevel: 12 + Description: "Radar Jammer" + Tab: "Vehicle" + Prerequisites: [weap,dome] + Owner: allies + LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" + Cost: 600 + Unit: + HP: 110 + Armor: light + Crewed: yes + Mobile: + Sight: 7 + ROT: 5 + Speed: 9 + RenderUnitSpinner: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Priority: 3 + Voice: VehicleVoice + +MGG: + Inherits: DefaultVehicle + Buildable: + TechLevel: 11 + Description: "Mobile Gap Generator" + Tab: "Vehicle" + Prerequisites: [weap,atek] + Owner: allies + LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" + Cost: 600 + Unit: + HP: 110 + Armor: light + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 9 + RenderUnitSpinner: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Priority: 3 + Voice: VehicleVoice + +ARTY: + Inherits: DefaultVehicle + Buildable: + TechLevel: 8 + Description: "Artillery" + Tab: "Vehicle" + Prerequisites: [weap] + Owner: allies + LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Cost: 600 + Unit: + HP: 75 + Armor: light + Crewed: yes + Mobile: + Sight: 5 + ROT: 2 + Speed: 6 + AttackBase: + RenderUnit: + Explodes: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +HARV: + Inherits: DefaultVehicle + Buildable: + TechLevel: 1 + Description: "Ore Truck" + Tab: "Vehicle" + Prerequisites: [weap,proc] + Owner: allies,soviet + LongDesc: "Collects Ore and Gems for processing.\n Unarmed" + Cost: 1400 + Harvester: + Unit: + HP: 600 + Armor: heavy + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 6 + RenderUnit: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Priority: 7 + Voice: VehicleVoice + +MCV: + Inherits: DefaultVehicle + Buildable: + TechLevel: 11 + Description: "Mobile Construction Vehicle" + Tab: "Vehicle" + Prerequisites: [weap,fix] + Owner: allies,soviet + LongDesc: "Deploys into another Construction Yard.\n Unarmed" + Cost: 2500 + Unit: + HP: 600 + Armor: light + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 6 + McvDeploy: + RenderUnit: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Priority: 3 + Voice: VehicleVoice + +JEEP: + Inherits: DefaultVehicle + Buildable: + TechLevel: 3 + Description: "Ranger" + Tab: "Vehicle" + Prerequisites: [weap] + Owner: allies + LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" + Cost: 600 + Unit: + HP: 150 + Armor: light + Crewed: yes + Mobile: + Sight: 6 + ROT: 10 + Speed: 10 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +APC: + Inherits: DefaultVehicle + Buildable: + TechLevel: 5 + Description: "Armored Personnel Carrier" + Tab: "Vehicle" + Prerequisites: [weap,tent] + Owner: allies + LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Cost: 800 + Unit: + HP: 200 + Armor: heavy + Mobile: + Sight: 5 + ROT: 5 + Speed: 10 + AttackBase: + RenderUnitMuzzleFlash: + AutoTarget: + Repairable: + Chronoshiftable: + Cargo: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +MNLY.AP: + Inherits: DefaultVehicle + Buildable: + TechLevel: 3 + Description: "Minelayer (Anti-Personnel)" + Tab: "Vehicle" + Prerequisites: [weap,fix] + Owner: soviet + LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Cost: 800 + Icon: MNLYICON + Unit: + HP: 100 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 9 + RenderUnit: + Image: MNLY + Minelayer: + MineImmune: + Repairable: + LimitedAmmo: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +MNLY.AT: + Inherits: DefaultVehicle + Buildable: + TechLevel: 3 + Description: "Minelayer (Anti-Tank)" + Tab: "Vehicle" + Prerequisites: [weap,fix] + Owner: allies + LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Cost: 800 + Icon: MNLYICON + Unit: + HP: 100 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 9 + RenderUnit: + Image: MNLY + Minelayer: + MineImmune: + Repairable: + LimitedAmmo: + Chronoshiftable: + Passenger: + IronCurtainable: + Selectable: + Voice: VehicleVoice + +SS: + Inherits: DefaultShip + Buildable: + TechLevel: 5 + Description: "Submarine" + Tab: "Ship" + Prerequisites: [spen] + Owner: soviet + LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" + Cost: 950 + Unit: + HP: 120 + Armor: light + Mobile: + Sight: 6 + ROT: 7 + Speed: 6 + RenderUnit: + Submarine: + AttackBase: + Chronoshiftable: + IronCurtainable: + Selectable: + +DD: + Inherits: DefaultShip + Buildable: + TechLevel: 7 + Description: "Destroyer" + Tab: "Ship" + Prerequisites: [syrd] + Owner: allies + LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" + Cost: 1000 + Unit: + HP: 400 + Armor: heavy + Mobile: + Sight: 6 + ROT: 7 + Speed: 6 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Chronoshiftable: + IronCurtainable: + Selectable: + +CA: + Inherits: DefaultShip + Buildable: + TechLevel: 10 + Description: "Cruiser" + Tab: "Ship" + Prerequisites: [syrd,atek] + Owner: allies + LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" + Cost: 2000 + Unit: + HP: 700 + Armor: heavy + Mobile: + Sight: 7 + ROT: 5 + Speed: 4 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Chronoshiftable: + IronCurtainable: + Selectable: + +LST: + Inherits: DefaultShip + Buildable: + TechLevel: 3 + Description: "Transport" + Tab: "Ship" + Prerequisites: [] + Owner: allies,soviet + LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" + Cost: 700 + Unit: + HP: 350 + Armor: heavy + Mobile: + Sight: 6 + ROT: 10 + Speed: 14 + RenderUnit: + Cargo: + IronCurtainable: + Selectable: + +PT: + Inherits: DefaultShip + Buildable: + TechLevel: 5 + Description: "Gunboat" + Tab: "Ship" + Prerequisites: [syrd] + Owner: allies + LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" + Cost: 500 + Unit: + HP: 200 + Armor: heavy + Mobile: + Sight: 7 + ROT: 7 + Speed: 9 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Chronoshiftable: + IronCurtainable: + Selectable: + +MIG: + Inherits: DefaultPlane + Buildable: + TechLevel: 10 + Description: "Mig Attack Plane" + Tab: "Plane" + Prerequisites: [afld] + Owner: soviet + LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" + Cost: 1200 + Unit: + HP: 50 + Armor: light + AttackPlane: + Plane: + ROT: 5 + Speed: 20 + RenderUnit: + WithShadow: + LimitedAmmo: + IronCurtainable: + Selectable: + +YAK: + Inherits: DefaultPlane + Buildable: + TechLevel: 5 + Description: "Yak Attack Plane" + Tab: "Plane" + Prerequisites: [afld] + Owner: soviet + LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" + Cost: 800 + Unit: + HP: 60 + Armor: light + Crewed: yes + AttackPlane: + Plane: + ROT: 5 + Speed: 16 + RenderUnit: + WithShadow: + LimitedAmmo: + IronCurtainable: + Selectable: + +TRAN: + Inherits: DefaultPlane + Buildable: + TechLevel: 11 + Description: "Transport Helicopter" + Tab: "Plane" + Prerequisites: [hpad] + Owner: allies + LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" + Cost: 1200 + Unit: + HP: 90 + Armor: light + Helicopter: + ROT: 5 + Speed: 12 + RenderUnitRotor: + WithShadow: + Cargo: + IronCurtainable: + Selectable: + +HELI: + Inherits: DefaultPlane + Buildable: + TechLevel: 9 + Description: "Longbow" + Tab: "Plane" + Prerequisites: [hpad] + Owner: allies + LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" + Cost: 1200 + Unit: + HP: 225 + Armor: heavy + Crewed: yes + AttackHeli: + Helicopter: + ROT: 4 + Speed: 16 + RenderUnitRotor: + WithShadow: + LimitedAmmo: + IronCurtainable: + Selectable: + +HIND: + Inherits: DefaultPlane + Buildable: + TechLevel: 9 + Description: "Hind" + Tab: "Plane" + Prerequisites: [hpad] + Owner: allies + LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" + Cost: 1200 + Unit: + HP: 225 + Armor: heavy + Crewed: yes + AttackHeli: + Helicopter: + ROT: 4 + Speed: 12 + RenderUnitRotor: + WithShadow: + LimitedAmmo: + IronCurtainable: + Selectable: + +IRON: + Inherits: DefaultDefense + Buildable: + TechLevel: 12 + Description: "Iron Curtain" + Tab: "Defense" + Prerequisites: [stek] + Owner: soviet + LongDesc: "Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability" + Cost: 2800 + Building: + RenderBuilding: + IronCurtainable: + IronCurtain: + Selectable: + Priority: 3 + +PDOX: + Inherits: DefaultDefense + Buildable: + TechLevel: 12 + Description: "Chronosphere" + Tab: "Defense" + Prerequisites: [atek] + Owner: allies + LongDesc: "Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift" + Cost: 2800 + Building: + RenderBuilding: + Chronosphere: + IronCurtainable: + Selectable: + Priority: 3 + +PBOX: + Inherits: DefaultDefense + Buildable: + TechLevel: 2 + Description: "Pillbox" + Tab: "Defense" + Prerequisites: [tent] + Owner: allies + LongDesc: "Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Cost: 400 + Building: + Turreted: + RenderBuilding: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +HBOX: + Inherits: DefaultDefense + Buildable: + TechLevel: 3 + Description: "Camo Pillbox" + Tab: "Defense" + Prerequisites: [tent] + Owner: allies + LongDesc: "Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Cost: 600 + Building: + Turreted: + RenderBuilding: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +TSLA: + Inherits: DefaultDefense + Buildable: + TechLevel: 7 + Description: "Tesla Coil" + Tab: "Defense" + Prerequisites: [weap] + Owner: soviet + LongDesc: "Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft" + Cost: 1500 + Building: + Turreted: + RenderBuildingCharge: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +GUN: + Inherits: DefaultDefense + Buildable: + TechLevel: 4 + Description: "Turret" + Tab: "Defense" + Prerequisites: [tent] + Owner: allies + LongDesc: "Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft" + Cost: 600 + Building: + Turreted: + RenderBuildingTurreted: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +AGUN: + Inherits: DefaultDefense + Buildable: + TechLevel: 5 + Description: "AA Gun" + Tab: "Defense" + Prerequisites: [dome] + Owner: allies + LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Cost: 600 + Building: + Turreted: + RenderBuildingTurreted: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +FTUR: + Inherits: DefaultDefense + Buildable: + TechLevel: 2 + Description: "Flame Turret" + Tab: "Defense" + Prerequisites: [barr] + Owner: soviet + LongDesc: "Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft" + Cost: 600 + Turreted: + Building: + RenderBuilding: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +GAP: + Inherits: DefaultDefense + Buildable: + TechLevel: 10 + Description: "Gap Generator" + Tab: "Defense" + Prerequisites: [atek] + Owner: allies + LongDesc: "Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed" + Cost: 500 + Building: + RenderBuilding: + IronCurtainable: + Selectable: + Priority: 3 + +SAM: + Inherits: DefaultDefense + Buildable: + TechLevel: 9 + Description: "SAM Site" + Tab: "Defense" + Prerequisites: [dome] + Owner: soviet + LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Cost: 750 + Building: + Turreted: + RenderBuildingTurreted: + AttackTurreted: + AutoTarget: + IronCurtainable: + Selectable: + Priority: 3 + +MSLO: + Inherits: DefaultDefense + Buildable: + TechLevel: 13 + Description: "Missile Silo" + Tab: "Defense" + Prerequisites: [stek,atek] + Owner: soviet,allies + LongDesc: "Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile" + Cost: 2500 + Building: + RenderBuilding: + IronCurtainable: + Selectable: + Priority: 3 + +ATEK: + Inherits: DefaultBuilding + Buildable: + TechLevel: 10 + Description: "Allied Tech Center" + Tab: "Building" + Prerequisites: [weap,dome] + Owner: allies + LongDesc: "Provides Allied advanced technologies.\n Special Ability: GPS Satellite" + Cost: 1500 + Building: + RenderBuilding: + IronCurtainable: + GpsLaunchSite: + Selectable: + Priority: 3 + +WEAP: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "War Factory" + Tab: "Building" + Prerequisites: [proc] + Owner: soviet,allies + LongDesc: "Produces tanks & light vehicles." + Cost: 2000 + Building: + RenderWarFactory: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + Selectable: + Priority: 3 + +SYRD: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Shipyard" + Tab: "Building" + Prerequisites: [powr] + Owner: allies + LongDesc: "Produces and repairs ships" + Cost: 650 + Building: + RenderBuilding: + ProductionSurround: + IronCurtainable: + Selectable: + Priority: 3 + +SPEN: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Sub Pen" + Tab: "Building" + Prerequisites: [powr] + Owner: soviet + LongDesc: "Produces and repairs submarines and \ntransports" + Cost: 650 + Building: + RenderBuilding: + ProductionSurround: + IronCurtainable: + Selectable: + Priority: 3 + +FACT: + Inherits: DefaultBuilding + Building: + RenderBuilding: + ConstructionYard: + IronCurtainable: + Selectable: + Priority: 3 + +PROC: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Description: "Ore Refinery" + Tab: "Building" + Prerequisites: [powr] + Owner: allies,soviet + LongDesc: "Converts Ore and Gems into money" + Cost: 2000 + Building: + RenderBuilding: + AcceptsOre: + StoresOre: + IronCurtainable: + Selectable: + Priority: 3 + +SILO: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Description: "Silo" + Tab: "Building" + Prerequisites: [proc] + Owner: allies,soviet + LongDesc: "Stores excess harvested Ore" + Cost: 150 + Building: + RenderBuildingOre: + StoresOre: + IronCurtainable: + Selectable: + Priority: 3 + +HPAD: + Inherits: DefaultBuilding + Buildable: + TechLevel: 9 + Description: "Helipad" + Tab: "Building" + Prerequisites: [dome] + Owner: allies + LongDesc: "Produces and reloads helicopters" + Cost: 1500 + Building: + RenderBuilding: + Production: + BelowUnits: + Reservable: + IronCurtainable: + Selectable: + Priority: 3 + +DOME: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Radar Dome" + Tab: "Building" + Prerequisites: [proc] + Owner: allies,soviet + LongDesc: "Provides an overview of the battlefield.\n Requires power to operate." + Cost: 1000 + Building: + RenderBuilding: + ProvidesRadar: + IronCurtainable: + Selectable: + Priority: 3 + +AFLD: + Inherits: DefaultBuilding + Buildable: + TechLevel: 5 + Description: "Airstrip" + Tab: "Building" + Prerequisites: [dome] + Owner: soviet + LongDesc: "Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane" + Cost: 600 + Building: + RenderBuilding: + Production: + BelowUnits: + Reservable: + IronCurtainable: + Selectable: + Priority: 3 + +POWR: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Description: "Power Plant" + Tab: "Building" + Prerequisites: [fact] + Owner: allies,soviet + LongDesc: "Provides power for other structures" + Cost: 300 + Building: + RenderBuilding: + IronCurtainable: + Selectable: + Priority: 3 + +APWR: + Inherits: DefaultBuilding + Buildable: + TechLevel: 8 + Description: "Advanced Power Plant" + Tab: "Building" + Prerequisites: [powr] + Owner: allies,soviet + LongDesc: "Provides more power, cheaper than the \nstandard Power Plant" + Cost: 500 + Building: + RenderBuilding: + IronCurtainable: + Selectable: + Priority: 3 + +STEK: + Inherits: DefaultBuilding + Buildable: + TechLevel: 6 + Description: "Soviet Tech Center" + Tab: "Building" + Prerequisites: [weap,dome] + Owner: soviet + LongDesc: "Provides Soviet advanced technologies" + Cost: 1500 + Building: + RenderBuilding: + IronCurtainable: + Selectable: + Priority: 3 + +BARR: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Description: "Soviet Barracks" + Tab: "Building" + Prerequisites: [powr] + Owner: soviet + LongDesc: "Produces infantry" + Cost: 300 + Building: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + Selectable: + Priority: 3 + +TENT: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Description: "Allied Barracks" + Tab: "Building" + Prerequisites: [powr] + Owner: allies + LongDesc: "Produces infantry" + Cost: 300 + Building: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + Selectable: + Priority: 3 + +KENN: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Kennel" + Tab: "Building" + Prerequisites: [barr] + Owner: soviet + LongDesc: "Produces attack dogs" + Cost: 200 + Building: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + Selectable: + Priority: 3 + +FIX: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Service Depot" + Tab: "Building" + Prerequisites: [weap] + Owner: allies,soviet + LongDesc: "Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases." + Cost: 1200 + Building: + RenderBuilding: + BelowUnits: + Reservable: + IronCurtainable: + Selectable: + Priority: 3 + +FACF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Description: "Fake Construction Yard" + Tab: "Building" + Prerequisites: [] + Owner: allies + LongDesc: "Looks like a Construction Yard." + Cost: 50 + Building: + RenderBuilding: + Image: FACT + Fake: + IronCurtainable: + Selectable: + Priority: 3 + +WEAF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Fake War Factory" + Tab: "Building" + Prerequisites: [proc] + Owner: allies + LongDesc: "Looks like a War Factory." + Cost: 50 + Building: + RenderWarFactory: + RenderBuilding: + Image: WEAP + Fake: + IronCurtainable: + Selectable: + Priority: 3 + +SYRF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Fake Shipyard" + Tab: "Building" + Prerequisites: [powr] + Owner: allies + LongDesc: "Looks like a Shipyard" + Cost: 50 + Building: + RenderBuilding: + Image: SYRD + Fake: + Selectable: + Priority: 3 + +SPEF: + Inherits: DefaultBuilding + Building: + RenderBuilding: + Image: SPEN + Fake: + Selectable: + Priority: 3 + +DOMF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Description: "Fake Radar Dome" + Tab: "Building" + Prerequisites: [proc] + Owner: allies + LongDesc: "Looks like a Radar Dome" + Cost: 50 + Building: + RenderBuilding: + Image: DOME + Fake: + Selectable: + Priority: 3 + +MINP: + Inherits: DefaultBuilding + Unit: + HP: 1 + RenderUnit: + APMine: + BelowUnits: + InvisibleToOthers: + +MINV: + Inherits: DefaultBuilding + Unit: + HP: 1 + RenderUnit: + ATMine: + BelowUnits: + InvisibleToOthers: + +DOG: + Inherits: DefaultInfantry + Buildable: + TechLevel: 3 + Description: "Attack Dog" + Tab: "Infantry" + Prerequisites: [kenn] + Owner: soviet + LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" + Cost: 200 + Unit: + HP: 12 + Armor: none + Mobile: + Sight: 5 + Speed: 4 + RenderInfantry: + Passenger: + Selectable: + Voice: DogVoice + Bounds: [12,17,-1,-4] + +E1: + Inherits: DefaultInfantry + Buildable: + TechLevel: 1 + Description: "Rifle Infantry" + Tab: "Infantry" + Prerequisites: [] + Owner: allies,soviet + LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" + Cost: 100 + Unit: + HP: 50 + Armor: none + Mobile: + Sight: 4 + Speed: 4 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + Selectable: + Bounds: [12,17,0,-9] + +E2: + Inherits: DefaultInfantry + Buildable: + TechLevel: 1 + Description: "Grenadier" + Tab: "Infantry" + Prerequisites: [] + Owner: soviet + LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" + Cost: 160 + Unit: + HP: 50 + Armor: none + Mobile: + Sight: 4 + Speed: 5 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + Selectable: + Bounds: [12,17,0,-9] + +E3: + Inherits: DefaultInfantry + Buildable: + TechLevel: 2 + Description: "Rocket Soldier" + Tab: "Infantry" + Prerequisites: [] + Owner: allies,soviet + LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Cost: 300 + Unit: + HP: 45 + Armor: none + Mobile: + Sight: 4 + Speed: 3 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + Selectable: + Bounds: [12,17,0,-9] + +E4: + Inherits: DefaultInfantry + Buildable: + TechLevel: 6 + Description: "Flamethrower" + Tab: "Infantry" + Prerequisites: [stek] + Owner: soviet + LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" + Cost: 300 + Unit: + HP: 40 + Armor: none + Mobile: + Sight: 4 + Speed: 3 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + Selectable: + Bounds: [12,17,0,-9] + +E6: + Inherits: DefaultInfantry + Buildable: + TechLevel: 5 + Description: "Engineer" + Tab: "Infantry" + Prerequisites: [] + Owner: soviet,allies + LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" + Cost: 500 + Unit: + HP: 25 + Armor: none + Mobile: + Sight: 4 + Speed: 4 + EngineerCapture: + RenderInfantry: + TakeCover: + SquishByTank: + Passenger: + Selectable: + Voice: EngineerVoice + Bounds: [12,17,0,-9] + +SPY: + Inherits: DefaultInfantry + Buildable: + TechLevel: 6 + Description: "Spy" + Tab: "Infantry" + Prerequisites: [dome] + Owner: allies + LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" + Cost: 500 + Unit: + HP: 25 + Armor: none + Mobile: + Sight: 5 + Speed: 4 + RenderInfantry: + TakeCover: + SquishByTank: + Passenger: + Selectable: + Voice: SpyVoice + Bounds: [12,17,0,-9] + +THF: + Inherits: DefaultInfantry + Buildable: + TechLevel: 11 + Description: "Thief" + Tab: "Infantry" + Prerequisites: [atek] + Owner: allies + LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" + Cost: 500 + Unit: + HP: 25 + Armor: none + Mobile: + Sight: 5 + Speed: 4 + RenderInfantry: + TakeCover: + SquishByTank: + Passenger: + Thief: + Selectable: + Voice: ThiefVoice + Bounds: [12,17,0,-9] + +E7: + Inherits: DefaultInfantry + Buildable: + TechLevel: 11 + Description: "Tanya" + Tab: "Infantry" + Prerequisites: [atek,stek] + Owner: allies,soviet + LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" + Cost: 1200 + Unit: + HP: 100 + Armor: none + Mobile: + Sight: 6 + Speed: 5 + RenderInfantry: + C4Demolition: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + Selectable: + Voice: TanyaVoice + Bounds: [12,17,0,-9] + +MEDI: + Inherits: DefaultInfantry + Buildable: + TechLevel: 2 + Description: "Medic" + Tab: "Infantry" + Prerequisites: [] + Owner: allies + LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" + Cost: 800 + Unit: + HP: 80 + Armor: none + Mobile: + Sight: 3 + Speed: 4 + RenderInfantry: + AutoHeal: + AttackBase: + TakeCover: + SquishByTank: + Passenger: + Selectable: + Voice: MedicVoice + Bounds: [12,17,0,-9] + From c268c9678d4f9958785417ad639f4927b40ecf15 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 21:56:23 +1300 Subject: [PATCH 03/83] less of a hack --- RulesConverter/Program.cs | 36 ++- out.rul | 665 +++++++++++++++++++------------------- 2 files changed, 348 insertions(+), 353 deletions(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 7cbb7f228d..2b512f5b94 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -108,6 +108,17 @@ namespace RulesConverter { "RenderUnitTurreted", new PL { { "Image", "Image" } } }, + + { "Buildable", new PL { + { "TechLevel", "TechLevel" }, + { "Tab", "$Tab" }, + { "@Prerequisites", "Prerequisite" }, + { "Owner", "Owner" }, + { "Cost", "Cost" }, + { "Icon", "Icon" }, + { "$Description", "Description" }, + { "$LongDesc", "LongDesc" } } + } }; using (var writer = File.CreateText(outputFile)) @@ -119,34 +130,25 @@ namespace RulesConverter writer.WriteLine("{0}:", item); writer.WriteLine("\tInherits: {0}", cat.Value.First); - var techLevel = iniSection.GetValue("TechLevel", "-1"); - if (techLevel != "-1") - { - writer.WriteLine("\tBuildable:"); - writer.WriteLine("\t\tTechLevel: {0}", techLevel); - writer.WriteLine("\t\tDescription: \"{0}\"", iniSection.GetValue("Description", "")); - writer.WriteLine("\t\tTab: \"{0}\"", cat.Value.Second); - writer.WriteLine("\t\tPrerequisites: [{0}]", iniSection.GetValue("Prerequisite", "")); - writer.WriteLine("\t\tOwner: {0}", iniSection.GetValue("Owner", "")); - writer.WriteLine("\t\tLongDesc: \"{0}\"", iniSection.GetValue("LongDesc", "")); - writer.WriteLine("\t\tCost: {0}", iniSection.GetValue("Cost", "")); - if (iniSection.Contains( "Icon" )) - writer.WriteLine("\t\tIcon: {0}", iniSection.GetValue("Icon", "")); - } - var traits = iniSection.GetValue("Traits", "") .Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (iniSection.GetValue("Selectable", "yes") == "yes") - traits.Add("Selectable"); + traits.Insert(0, "Selectable"); + + if (iniSection.GetValue("TechLevel", "-1") != "-1") + traits.Insert(0, "Buildable"); + + foreach (var t in traits) { writer.WriteLine("\t{0}:", t); + if (traitMap.ContainsKey(t)) foreach (var kv in traitMap[t]) { - var v = iniSection.GetValue(kv.Value, ""); + var v = kv.Value == "$Tab" ? cat.Value.Second : iniSection.GetValue(kv.Value, ""); var fmt = "\t\t{0}: {1}"; var k = kv.Key; if (k.StartsWith("@")) { k = k.Substring(1); fmt = "\t\t{0}: [{1}]"; } diff --git a/out.rul b/out.rul index a9658f9e4f..6071ee19e4 100644 --- a/out.rul +++ b/out.rul @@ -2,12 +2,14 @@ V2RL: Inherits: DefaultVehicle Buildable: TechLevel: 4 - Description: "V2 Rocket" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,dome] Owner: soviet - LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" Cost: 700 + Description: "V2 Rocket" + LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 150 Armor: light @@ -23,19 +25,19 @@ V2RL: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice 1TNK: Inherits: DefaultVehicle Buildable: TechLevel: 4 - Description: "Light Tank" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap] Owner: allies - LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" Cost: 700 + Description: "Light Tank" + LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 300 Armor: heavy @@ -52,19 +54,19 @@ V2RL: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice 2TNK: Inherits: DefaultVehicle Buildable: TechLevel: 6 - Description: "Medium Tank" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap] Owner: allies - LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" Cost: 800 + Description: "Medium Tank" + LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 400 Armor: heavy @@ -81,19 +83,19 @@ V2RL: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice 3TNK: Inherits: DefaultVehicle Buildable: TechLevel: 4 - Description: "Heavy Tank" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap] Owner: soviet - LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" Cost: 950 + Description: "Heavy Tank" + LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 400 Armor: heavy @@ -110,19 +112,19 @@ V2RL: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice 4TNK: Inherits: DefaultVehicle Buildable: TechLevel: 10 - Description: "Mammoth Tank" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,stek] Owner: soviet - LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" Cost: 1700 + Description: "Mammoth Tank" + LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Selectable: + Voice: VehicleVoice Unit: HP: 600 Armor: heavy @@ -139,19 +141,20 @@ V2RL: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice MRJ: Inherits: DefaultVehicle Buildable: TechLevel: 12 - Description: "Radar Jammer" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,dome] Owner: allies - LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" Cost: 600 + Description: "Radar Jammer" + LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" + Selectable: + Priority: 3 + Voice: VehicleVoice Unit: HP: 110 Armor: light @@ -165,20 +168,20 @@ MRJ: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Priority: 3 - Voice: VehicleVoice MGG: Inherits: DefaultVehicle Buildable: TechLevel: 11 - Description: "Mobile Gap Generator" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,atek] Owner: allies - LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" Cost: 600 + Description: "Mobile Gap Generator" + LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" + Selectable: + Priority: 3 + Voice: VehicleVoice Unit: HP: 110 Armor: light @@ -192,20 +195,19 @@ MGG: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Priority: 3 - Voice: VehicleVoice ARTY: Inherits: DefaultVehicle Buildable: TechLevel: 8 - Description: "Artillery" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap] Owner: allies - LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" Cost: 600 + Description: "Artillery" + LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 75 Armor: light @@ -222,19 +224,20 @@ ARTY: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice HARV: Inherits: DefaultVehicle Buildable: TechLevel: 1 - Description: "Ore Truck" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,proc] Owner: allies,soviet - LongDesc: "Collects Ore and Gems for processing.\n Unarmed" Cost: 1400 + Description: "Ore Truck" + LongDesc: "Collects Ore and Gems for processing.\n Unarmed" + Selectable: + Priority: 7 + Voice: VehicleVoice Harvester: Unit: HP: 600 @@ -249,20 +252,20 @@ HARV: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Priority: 7 - Voice: VehicleVoice MCV: Inherits: DefaultVehicle Buildable: TechLevel: 11 - Description: "Mobile Construction Vehicle" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,fix] Owner: allies,soviet - LongDesc: "Deploys into another Construction Yard.\n Unarmed" Cost: 2500 + Description: "Mobile Construction Vehicle" + LongDesc: "Deploys into another Construction Yard.\n Unarmed" + Selectable: + Priority: 3 + Voice: VehicleVoice Unit: HP: 600 Armor: light @@ -277,20 +280,19 @@ MCV: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Priority: 3 - Voice: VehicleVoice JEEP: Inherits: DefaultVehicle Buildable: TechLevel: 3 - Description: "Ranger" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap] Owner: allies - LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" Cost: 600 + Description: "Ranger" + LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 150 Armor: light @@ -307,19 +309,19 @@ JEEP: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice APC: Inherits: DefaultVehicle Buildable: TechLevel: 5 - Description: "Armored Personnel Carrier" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,tent] Owner: allies - LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" Cost: 800 + Description: "Armored Personnel Carrier" + LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice Unit: HP: 200 Armor: heavy @@ -335,20 +337,20 @@ APC: Cargo: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice MNLY.AP: Inherits: DefaultVehicle Buildable: TechLevel: 3 - Description: "Minelayer (Anti-Personnel)" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,fix] Owner: soviet - LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" Cost: 800 Icon: MNLYICON + Description: "Minelayer (Anti-Personnel)" + LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Selectable: + Voice: VehicleVoice Unit: HP: 100 Armor: heavy @@ -366,20 +368,20 @@ MNLY.AP: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice MNLY.AT: Inherits: DefaultVehicle Buildable: TechLevel: 3 - Description: "Minelayer (Anti-Tank)" - Tab: "Vehicle" + Tab: Vehicle Prerequisites: [weap,fix] Owner: allies - LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" Cost: 800 Icon: MNLYICON + Description: "Minelayer (Anti-Tank)" + LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Selectable: + Voice: VehicleVoice Unit: HP: 100 Armor: heavy @@ -397,19 +399,18 @@ MNLY.AT: Chronoshiftable: Passenger: IronCurtainable: - Selectable: - Voice: VehicleVoice SS: Inherits: DefaultShip Buildable: TechLevel: 5 - Description: "Submarine" - Tab: "Ship" + Tab: Ship Prerequisites: [spen] Owner: soviet - LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" Cost: 950 + Description: "Submarine" + LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" + Selectable: Unit: HP: 120 Armor: light @@ -422,18 +423,18 @@ SS: AttackBase: Chronoshiftable: IronCurtainable: - Selectable: DD: Inherits: DefaultShip Buildable: TechLevel: 7 - Description: "Destroyer" - Tab: "Ship" + Tab: Ship Prerequisites: [syrd] Owner: allies - LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" Cost: 1000 + Description: "Destroyer" + LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" + Selectable: Unit: HP: 400 Armor: heavy @@ -447,18 +448,18 @@ DD: AutoTarget: Chronoshiftable: IronCurtainable: - Selectable: CA: Inherits: DefaultShip Buildable: TechLevel: 10 - Description: "Cruiser" - Tab: "Ship" + Tab: Ship Prerequisites: [syrd,atek] Owner: allies - LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" Cost: 2000 + Description: "Cruiser" + LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" + Selectable: Unit: HP: 700 Armor: heavy @@ -472,18 +473,17 @@ CA: AutoTarget: Chronoshiftable: IronCurtainable: - Selectable: LST: Inherits: DefaultShip Buildable: TechLevel: 3 - Description: "Transport" - Tab: "Ship" - Prerequisites: [] + Tab: Ship Owner: allies,soviet - LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" Cost: 700 + Description: "Transport" + LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" + Selectable: Unit: HP: 350 Armor: heavy @@ -494,18 +494,18 @@ LST: RenderUnit: Cargo: IronCurtainable: - Selectable: PT: Inherits: DefaultShip Buildable: TechLevel: 5 - Description: "Gunboat" - Tab: "Ship" + Tab: Ship Prerequisites: [syrd] Owner: allies - LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" Cost: 500 + Description: "Gunboat" + LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" + Selectable: Unit: HP: 200 Armor: heavy @@ -519,18 +519,18 @@ PT: AutoTarget: Chronoshiftable: IronCurtainable: - Selectable: MIG: Inherits: DefaultPlane Buildable: TechLevel: 10 - Description: "Mig Attack Plane" - Tab: "Plane" + Tab: Plane Prerequisites: [afld] Owner: soviet - LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" Cost: 1200 + Description: "Mig Attack Plane" + LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" + Selectable: Unit: HP: 50 Armor: light @@ -542,18 +542,18 @@ MIG: WithShadow: LimitedAmmo: IronCurtainable: - Selectable: YAK: Inherits: DefaultPlane Buildable: TechLevel: 5 - Description: "Yak Attack Plane" - Tab: "Plane" + Tab: Plane Prerequisites: [afld] Owner: soviet - LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" Cost: 800 + Description: "Yak Attack Plane" + LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" + Selectable: Unit: HP: 60 Armor: light @@ -566,18 +566,18 @@ YAK: WithShadow: LimitedAmmo: IronCurtainable: - Selectable: TRAN: Inherits: DefaultPlane Buildable: TechLevel: 11 - Description: "Transport Helicopter" - Tab: "Plane" + Tab: Plane Prerequisites: [hpad] Owner: allies - LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" Cost: 1200 + Description: "Transport Helicopter" + LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" + Selectable: Unit: HP: 90 Armor: light @@ -588,18 +588,18 @@ TRAN: WithShadow: Cargo: IronCurtainable: - Selectable: HELI: Inherits: DefaultPlane Buildable: TechLevel: 9 - Description: "Longbow" - Tab: "Plane" + Tab: Plane Prerequisites: [hpad] Owner: allies - LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" Cost: 1200 + Description: "Longbow" + LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" + Selectable: Unit: HP: 225 Armor: heavy @@ -612,18 +612,18 @@ HELI: WithShadow: LimitedAmmo: IronCurtainable: - Selectable: HIND: Inherits: DefaultPlane Buildable: TechLevel: 9 - Description: "Hind" - Tab: "Plane" + Tab: Plane Prerequisites: [hpad] Owner: allies - LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" Cost: 1200 + Description: "Hind" + LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" + Selectable: Unit: HP: 225 Armor: heavy @@ -636,575 +636,573 @@ HIND: WithShadow: LimitedAmmo: IronCurtainable: - Selectable: IRON: Inherits: DefaultDefense Buildable: TechLevel: 12 - Description: "Iron Curtain" - Tab: "Defense" + Tab: Defense Prerequisites: [stek] Owner: soviet - LongDesc: "Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability" Cost: 2800 + Description: "Iron Curtain" + LongDesc: "Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: IronCurtain: - Selectable: - Priority: 3 PDOX: Inherits: DefaultDefense Buildable: TechLevel: 12 - Description: "Chronosphere" - Tab: "Defense" + Tab: Defense Prerequisites: [atek] Owner: allies - LongDesc: "Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift" Cost: 2800 + Description: "Chronosphere" + LongDesc: "Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift" + Selectable: + Priority: 3 Building: RenderBuilding: Chronosphere: IronCurtainable: - Selectable: - Priority: 3 PBOX: Inherits: DefaultDefense Buildable: TechLevel: 2 - Description: "Pillbox" - Tab: "Defense" + Tab: Defense Prerequisites: [tent] Owner: allies - LongDesc: "Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" Cost: 400 + Description: "Pillbox" + LongDesc: "Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Priority: 3 Building: Turreted: RenderBuilding: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 HBOX: Inherits: DefaultDefense Buildable: TechLevel: 3 - Description: "Camo Pillbox" - Tab: "Defense" + Tab: Defense Prerequisites: [tent] Owner: allies - LongDesc: "Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" Cost: 600 + Description: "Camo Pillbox" + LongDesc: "Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Priority: 3 Building: Turreted: RenderBuilding: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 TSLA: Inherits: DefaultDefense Buildable: TechLevel: 7 - Description: "Tesla Coil" - Tab: "Defense" + Tab: Defense Prerequisites: [weap] Owner: soviet - LongDesc: "Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft" Cost: 1500 + Description: "Tesla Coil" + LongDesc: "Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft" + Selectable: + Priority: 3 Building: Turreted: RenderBuildingCharge: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 GUN: Inherits: DefaultDefense Buildable: TechLevel: 4 - Description: "Turret" - Tab: "Defense" + Tab: Defense Prerequisites: [tent] Owner: allies - LongDesc: "Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft" Cost: 600 + Description: "Turret" + LongDesc: "Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft" + Selectable: + Priority: 3 Building: Turreted: RenderBuildingTurreted: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 AGUN: Inherits: DefaultDefense Buildable: TechLevel: 5 - Description: "AA Gun" - Tab: "Defense" + Tab: Defense Prerequisites: [dome] Owner: allies - LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" Cost: 600 + Description: "AA Gun" + LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Selectable: + Priority: 3 Building: Turreted: RenderBuildingTurreted: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 FTUR: Inherits: DefaultDefense Buildable: TechLevel: 2 - Description: "Flame Turret" - Tab: "Defense" + Tab: Defense Prerequisites: [barr] Owner: soviet - LongDesc: "Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft" Cost: 600 + Description: "Flame Turret" + LongDesc: "Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft" + Selectable: + Priority: 3 Turreted: Building: RenderBuilding: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 GAP: Inherits: DefaultDefense Buildable: TechLevel: 10 - Description: "Gap Generator" - Tab: "Defense" + Tab: Defense Prerequisites: [atek] Owner: allies - LongDesc: "Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed" Cost: 500 + Description: "Gap Generator" + LongDesc: "Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: - Selectable: - Priority: 3 SAM: Inherits: DefaultDefense Buildable: TechLevel: 9 - Description: "SAM Site" - Tab: "Defense" + Tab: Defense Prerequisites: [dome] Owner: soviet - LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" Cost: 750 + Description: "SAM Site" + LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Selectable: + Priority: 3 Building: Turreted: RenderBuildingTurreted: AttackTurreted: AutoTarget: IronCurtainable: - Selectable: - Priority: 3 MSLO: Inherits: DefaultDefense Buildable: TechLevel: 13 - Description: "Missile Silo" - Tab: "Defense" + Tab: Defense Prerequisites: [stek,atek] Owner: soviet,allies - LongDesc: "Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile" Cost: 2500 + Description: "Missile Silo" + LongDesc: "Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: - Selectable: - Priority: 3 ATEK: Inherits: DefaultBuilding Buildable: TechLevel: 10 - Description: "Allied Tech Center" - Tab: "Building" + Tab: Building Prerequisites: [weap,dome] Owner: allies - LongDesc: "Provides Allied advanced technologies.\n Special Ability: GPS Satellite" Cost: 1500 + Description: "Allied Tech Center" + LongDesc: "Provides Allied advanced technologies.\n Special Ability: GPS Satellite" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: GpsLaunchSite: - Selectable: - Priority: 3 WEAP: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "War Factory" - Tab: "Building" + Tab: Building Prerequisites: [proc] Owner: soviet,allies - LongDesc: "Produces tanks & light vehicles." Cost: 2000 + Description: "War Factory" + LongDesc: "Produces tanks & light vehicles." + Selectable: + Priority: 3 Building: RenderWarFactory: RenderBuilding: RallyPoint: Production: IronCurtainable: - Selectable: - Priority: 3 SYRD: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Shipyard" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: allies - LongDesc: "Produces and repairs ships" Cost: 650 + Description: "Shipyard" + LongDesc: "Produces and repairs ships" + Selectable: + Priority: 3 Building: RenderBuilding: ProductionSurround: IronCurtainable: - Selectable: - Priority: 3 SPEN: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Sub Pen" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: soviet - LongDesc: "Produces and repairs submarines and \ntransports" Cost: 650 + Description: "Sub Pen" + LongDesc: "Produces and repairs submarines and \ntransports" + Selectable: + Priority: 3 Building: RenderBuilding: ProductionSurround: IronCurtainable: - Selectable: - Priority: 3 FACT: Inherits: DefaultBuilding + Selectable: + Priority: 3 Building: RenderBuilding: ConstructionYard: IronCurtainable: - Selectable: - Priority: 3 PROC: Inherits: DefaultBuilding Buildable: TechLevel: 1 - Description: "Ore Refinery" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: allies,soviet - LongDesc: "Converts Ore and Gems into money" Cost: 2000 + Description: "Ore Refinery" + LongDesc: "Converts Ore and Gems into money" + Selectable: + Priority: 3 Building: RenderBuilding: AcceptsOre: StoresOre: IronCurtainable: - Selectable: - Priority: 3 SILO: Inherits: DefaultBuilding Buildable: TechLevel: 1 - Description: "Silo" - Tab: "Building" + Tab: Building Prerequisites: [proc] Owner: allies,soviet - LongDesc: "Stores excess harvested Ore" Cost: 150 + Description: "Silo" + LongDesc: "Stores excess harvested Ore" + Selectable: + Priority: 3 Building: RenderBuildingOre: StoresOre: IronCurtainable: - Selectable: - Priority: 3 HPAD: Inherits: DefaultBuilding Buildable: TechLevel: 9 - Description: "Helipad" - Tab: "Building" + Tab: Building Prerequisites: [dome] Owner: allies - LongDesc: "Produces and reloads helicopters" Cost: 1500 + Description: "Helipad" + LongDesc: "Produces and reloads helicopters" + Selectable: + Priority: 3 Building: RenderBuilding: Production: BelowUnits: Reservable: IronCurtainable: - Selectable: - Priority: 3 DOME: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Radar Dome" - Tab: "Building" + Tab: Building Prerequisites: [proc] Owner: allies,soviet - LongDesc: "Provides an overview of the battlefield.\n Requires power to operate." Cost: 1000 + Description: "Radar Dome" + LongDesc: "Provides an overview of the battlefield.\n Requires power to operate." + Selectable: + Priority: 3 Building: RenderBuilding: ProvidesRadar: IronCurtainable: - Selectable: - Priority: 3 AFLD: Inherits: DefaultBuilding Buildable: TechLevel: 5 - Description: "Airstrip" - Tab: "Building" + Tab: Building Prerequisites: [dome] Owner: soviet - LongDesc: "Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane" Cost: 600 + Description: "Airstrip" + LongDesc: "Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane" + Selectable: + Priority: 3 Building: RenderBuilding: Production: BelowUnits: Reservable: IronCurtainable: - Selectable: - Priority: 3 POWR: Inherits: DefaultBuilding Buildable: TechLevel: 1 - Description: "Power Plant" - Tab: "Building" + Tab: Building Prerequisites: [fact] Owner: allies,soviet - LongDesc: "Provides power for other structures" Cost: 300 + Description: "Power Plant" + LongDesc: "Provides power for other structures" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: - Selectable: - Priority: 3 APWR: Inherits: DefaultBuilding Buildable: TechLevel: 8 - Description: "Advanced Power Plant" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: allies,soviet - LongDesc: "Provides more power, cheaper than the \nstandard Power Plant" Cost: 500 + Description: "Advanced Power Plant" + LongDesc: "Provides more power, cheaper than the \nstandard Power Plant" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: - Selectable: - Priority: 3 STEK: Inherits: DefaultBuilding Buildable: TechLevel: 6 - Description: "Soviet Tech Center" - Tab: "Building" + Tab: Building Prerequisites: [weap,dome] Owner: soviet - LongDesc: "Provides Soviet advanced technologies" Cost: 1500 + Description: "Soviet Tech Center" + LongDesc: "Provides Soviet advanced technologies" + Selectable: + Priority: 3 Building: RenderBuilding: IronCurtainable: - Selectable: - Priority: 3 BARR: Inherits: DefaultBuilding Buildable: TechLevel: 1 - Description: "Soviet Barracks" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: soviet - LongDesc: "Produces infantry" Cost: 300 + Description: "Soviet Barracks" + LongDesc: "Produces infantry" + Selectable: + Priority: 3 Building: RenderBuilding: RallyPoint: Production: IronCurtainable: - Selectable: - Priority: 3 TENT: Inherits: DefaultBuilding Buildable: TechLevel: 1 - Description: "Allied Barracks" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: allies - LongDesc: "Produces infantry" Cost: 300 + Description: "Allied Barracks" + LongDesc: "Produces infantry" + Selectable: + Priority: 3 Building: RenderBuilding: RallyPoint: Production: IronCurtainable: - Selectable: - Priority: 3 KENN: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Kennel" - Tab: "Building" + Tab: Building Prerequisites: [barr] Owner: soviet - LongDesc: "Produces attack dogs" Cost: 200 + Description: "Kennel" + LongDesc: "Produces attack dogs" + Selectable: + Priority: 3 Building: RenderBuilding: RallyPoint: Production: IronCurtainable: - Selectable: - Priority: 3 FIX: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Service Depot" - Tab: "Building" + Tab: Building Prerequisites: [weap] Owner: allies,soviet - LongDesc: "Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases." Cost: 1200 + Description: "Service Depot" + LongDesc: "Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases." + Selectable: + Priority: 3 Building: RenderBuilding: BelowUnits: Reservable: IronCurtainable: - Selectable: - Priority: 3 FACF: Inherits: DefaultBuilding Buildable: TechLevel: 1 - Description: "Fake Construction Yard" - Tab: "Building" - Prerequisites: [] + Tab: Building Owner: allies - LongDesc: "Looks like a Construction Yard." Cost: 50 + Description: "Fake Construction Yard" + LongDesc: "Looks like a Construction Yard." + Selectable: + Priority: 3 Building: RenderBuilding: Image: FACT Fake: IronCurtainable: - Selectable: - Priority: 3 WEAF: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Fake War Factory" - Tab: "Building" + Tab: Building Prerequisites: [proc] Owner: allies - LongDesc: "Looks like a War Factory." Cost: 50 + Description: "Fake War Factory" + LongDesc: "Looks like a War Factory." + Selectable: + Priority: 3 Building: RenderWarFactory: RenderBuilding: Image: WEAP Fake: IronCurtainable: - Selectable: - Priority: 3 SYRF: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Fake Shipyard" - Tab: "Building" + Tab: Building Prerequisites: [powr] Owner: allies - LongDesc: "Looks like a Shipyard" Cost: 50 + Description: "Fake Shipyard" + LongDesc: "Looks like a Shipyard" + Selectable: + Priority: 3 Building: RenderBuilding: Image: SYRD Fake: - Selectable: - Priority: 3 SPEF: Inherits: DefaultBuilding + Selectable: + Priority: 3 Building: RenderBuilding: Image: SPEN Fake: - Selectable: - Priority: 3 DOMF: Inherits: DefaultBuilding Buildable: TechLevel: 3 - Description: "Fake Radar Dome" - Tab: "Building" + Tab: Building Prerequisites: [proc] Owner: allies - LongDesc: "Looks like a Radar Dome" Cost: 50 + Description: "Fake Radar Dome" + LongDesc: "Looks like a Radar Dome" + Selectable: + Priority: 3 Building: RenderBuilding: Image: DOME Fake: - Selectable: - Priority: 3 MINP: Inherits: DefaultBuilding @@ -1228,12 +1226,15 @@ DOG: Inherits: DefaultInfantry Buildable: TechLevel: 3 - Description: "Attack Dog" - Tab: "Infantry" + Tab: Infantry Prerequisites: [kenn] Owner: soviet - LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" Cost: 200 + Description: "Attack Dog" + LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" + Selectable: + Voice: DogVoice + Bounds: [12,17,-1,-4] Unit: HP: 12 Armor: none @@ -1242,20 +1243,18 @@ DOG: Speed: 4 RenderInfantry: Passenger: - Selectable: - Voice: DogVoice - Bounds: [12,17,-1,-4] E1: Inherits: DefaultInfantry Buildable: TechLevel: 1 - Description: "Rifle Infantry" - Tab: "Infantry" - Prerequisites: [] + Tab: Infantry Owner: allies,soviet - LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" Cost: 100 + Description: "Rifle Infantry" + LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" + Selectable: + Bounds: [12,17,0,-9] Unit: HP: 50 Armor: none @@ -1268,19 +1267,18 @@ E1: SquishByTank: AutoTarget: Passenger: - Selectable: - Bounds: [12,17,0,-9] E2: Inherits: DefaultInfantry Buildable: TechLevel: 1 - Description: "Grenadier" - Tab: "Infantry" - Prerequisites: [] + Tab: Infantry Owner: soviet - LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" Cost: 160 + Description: "Grenadier" + LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" + Selectable: + Bounds: [12,17,0,-9] Unit: HP: 50 Armor: none @@ -1293,19 +1291,18 @@ E2: SquishByTank: AutoTarget: Passenger: - Selectable: - Bounds: [12,17,0,-9] E3: Inherits: DefaultInfantry Buildable: TechLevel: 2 - Description: "Rocket Soldier" - Tab: "Infantry" - Prerequisites: [] + Tab: Infantry Owner: allies,soviet - LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" Cost: 300 + Description: "Rocket Soldier" + LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Selectable: + Bounds: [12,17,0,-9] Unit: HP: 45 Armor: none @@ -1318,19 +1315,19 @@ E3: SquishByTank: AutoTarget: Passenger: - Selectable: - Bounds: [12,17,0,-9] E4: Inherits: DefaultInfantry Buildable: TechLevel: 6 - Description: "Flamethrower" - Tab: "Infantry" + Tab: Infantry Prerequisites: [stek] Owner: soviet - LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" Cost: 300 + Description: "Flamethrower" + LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" + Selectable: + Bounds: [12,17,0,-9] Unit: HP: 40 Armor: none @@ -1343,19 +1340,19 @@ E4: SquishByTank: AutoTarget: Passenger: - Selectable: - Bounds: [12,17,0,-9] E6: Inherits: DefaultInfantry Buildable: TechLevel: 5 - Description: "Engineer" - Tab: "Infantry" - Prerequisites: [] + Tab: Infantry Owner: soviet,allies - LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" Cost: 500 + Description: "Engineer" + LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" + Selectable: + Voice: EngineerVoice + Bounds: [12,17,0,-9] Unit: HP: 25 Armor: none @@ -1367,20 +1364,20 @@ E6: TakeCover: SquishByTank: Passenger: - Selectable: - Voice: EngineerVoice - Bounds: [12,17,0,-9] SPY: Inherits: DefaultInfantry Buildable: TechLevel: 6 - Description: "Spy" - Tab: "Infantry" + Tab: Infantry Prerequisites: [dome] Owner: allies - LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" Cost: 500 + Description: "Spy" + LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" + Selectable: + Voice: SpyVoice + Bounds: [12,17,0,-9] Unit: HP: 25 Armor: none @@ -1391,20 +1388,20 @@ SPY: TakeCover: SquishByTank: Passenger: - Selectable: - Voice: SpyVoice - Bounds: [12,17,0,-9] THF: Inherits: DefaultInfantry Buildable: TechLevel: 11 - Description: "Thief" - Tab: "Infantry" + Tab: Infantry Prerequisites: [atek] Owner: allies - LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" Cost: 500 + Description: "Thief" + LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" + Selectable: + Voice: ThiefVoice + Bounds: [12,17,0,-9] Unit: HP: 25 Armor: none @@ -1416,20 +1413,20 @@ THF: SquishByTank: Passenger: Thief: - Selectable: - Voice: ThiefVoice - Bounds: [12,17,0,-9] E7: Inherits: DefaultInfantry Buildable: TechLevel: 11 - Description: "Tanya" - Tab: "Infantry" + Tab: Infantry Prerequisites: [atek,stek] Owner: allies,soviet - LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" Cost: 1200 + Description: "Tanya" + LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" + Selectable: + Voice: TanyaVoice + Bounds: [12,17,0,-9] Unit: HP: 100 Armor: none @@ -1443,20 +1440,19 @@ E7: SquishByTank: AutoTarget: Passenger: - Selectable: - Voice: TanyaVoice - Bounds: [12,17,0,-9] MEDI: Inherits: DefaultInfantry Buildable: TechLevel: 2 - Description: "Medic" - Tab: "Infantry" - Prerequisites: [] + Tab: Infantry Owner: allies - LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" Cost: 800 + Description: "Medic" + LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" + Selectable: + Voice: MedicVoice + Bounds: [12,17,0,-9] Unit: HP: 80 Armor: none @@ -1469,7 +1465,4 @@ MEDI: TakeCover: SquishByTank: Passenger: - Selectable: - Voice: MedicVoice - Bounds: [12,17,0,-9] From f6050503852a828540e636cc42a989aec02d306b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 22:00:44 +1300 Subject: [PATCH 04/83] more --- RulesConverter/Program.cs | 10 +++++++++- out.rul | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 2b512f5b94..a94f312403 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -118,7 +118,15 @@ namespace RulesConverter { "Icon", "Icon" }, { "$Description", "Description" }, { "$LongDesc", "LongDesc" } } - } + }, + + { "Cargo", new PL { + { "@PassengerTypes", "PassengerTypes" } } + }, + + { "LimitedAmmo", new PL { + { "Ammo", "Ammo" } } + }, }; using (var writer = File.CreateText(outputFile)) diff --git a/out.rul b/out.rul index 6071ee19e4..c165256316 100644 --- a/out.rul +++ b/out.rul @@ -335,6 +335,7 @@ APC: Repairable: Chronoshiftable: Cargo: + PassengerTypes: [Foot] Passenger: IronCurtainable: @@ -365,6 +366,7 @@ MNLY.AP: MineImmune: Repairable: LimitedAmmo: + Ammo: 5 Chronoshiftable: Passenger: IronCurtainable: @@ -396,6 +398,7 @@ MNLY.AT: MineImmune: Repairable: LimitedAmmo: + Ammo: 5 Chronoshiftable: Passenger: IronCurtainable: @@ -493,6 +496,7 @@ LST: Speed: 14 RenderUnit: Cargo: + PassengerTypes: [Foot,Wheel,Track] IronCurtainable: PT: @@ -541,6 +545,7 @@ MIG: RenderUnit: WithShadow: LimitedAmmo: + Ammo: 3 IronCurtainable: YAK: @@ -565,6 +570,7 @@ YAK: RenderUnit: WithShadow: LimitedAmmo: + Ammo: 15 IronCurtainable: TRAN: @@ -587,6 +593,7 @@ TRAN: RenderUnitRotor: WithShadow: Cargo: + PassengerTypes: [Foot] IronCurtainable: HELI: @@ -611,6 +618,7 @@ HELI: RenderUnitRotor: WithShadow: LimitedAmmo: + Ammo: 6 IronCurtainable: HIND: @@ -635,6 +643,7 @@ HIND: RenderUnitRotor: WithShadow: LimitedAmmo: + Ammo: 12 IronCurtainable: IRON: From 6f0211d6df2e67d46183617cabed46c707b0d539 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 22:01:19 +1300 Subject: [PATCH 05/83] removing yaml crap --- ra.yaml | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 ra.yaml diff --git a/ra.yaml b/ra.yaml deleted file mode 100644 index 6c6153d54e..0000000000 --- a/ra.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# -# Red Alert rules -# - -Vehicles: - V2RL: - Buildable: - Description="V2 Rocket" - Prerequisites=[weap,dome] - TechLevel=4 - Cost=700, - LongDesc="Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" - Unit: - HP=150 - Armor=light - Crewed=yes - Voice=VehicleVoice - Mobile: - Sight=5 - ROT=5 - Speed=7 - UMT=Track - AttackBase: - Primary=SCUD - Ammo=1 - RenderUnitReload: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: \ No newline at end of file From 454e3a9ca96e07c506446d09db581134106e1176 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 22:02:32 +1300 Subject: [PATCH 06/83] removing yaml lib; don't need it. --- thirdparty/yaml/AssemblyInfo.cs | 55 -- thirdparty/yaml/Binary.cs | 154 ----- thirdparty/yaml/Boolean.cs | 132 ----- thirdparty/yaml/COPYING | 504 ----------------- thirdparty/yaml/Float.cs | 295 ---------- thirdparty/yaml/Integer.cs | 266 --------- thirdparty/yaml/Mapping.cs | 292 ---------- thirdparty/yaml/Node.cs | 469 ---------------- thirdparty/yaml/Null.cs | 100 ---- thirdparty/yaml/ParseException.cs | 63 --- thirdparty/yaml/ParseStream.cs | 899 ------------------------------ thirdparty/yaml/Scalar.cs | 137 ----- thirdparty/yaml/Sequence.cs | 197 ------- thirdparty/yaml/String.cs | 449 --------------- thirdparty/yaml/Timestamp.cs | 356 ------------ thirdparty/yaml/WriteStream.cs | 121 ---- thirdparty/yaml/Yaml.csproj | 188 ------- thirdparty/yaml/Yaml.sln | 19 - thirdparty/yaml/test.yaml | 24 - 19 files changed, 4720 deletions(-) delete mode 100644 thirdparty/yaml/AssemblyInfo.cs delete mode 100644 thirdparty/yaml/Binary.cs delete mode 100644 thirdparty/yaml/Boolean.cs delete mode 100644 thirdparty/yaml/COPYING delete mode 100644 thirdparty/yaml/Float.cs delete mode 100644 thirdparty/yaml/Integer.cs delete mode 100644 thirdparty/yaml/Mapping.cs delete mode 100644 thirdparty/yaml/Node.cs delete mode 100644 thirdparty/yaml/Null.cs delete mode 100644 thirdparty/yaml/ParseException.cs delete mode 100644 thirdparty/yaml/ParseStream.cs delete mode 100644 thirdparty/yaml/Scalar.cs delete mode 100644 thirdparty/yaml/Sequence.cs delete mode 100644 thirdparty/yaml/String.cs delete mode 100644 thirdparty/yaml/Timestamp.cs delete mode 100644 thirdparty/yaml/WriteStream.cs delete mode 100644 thirdparty/yaml/Yaml.csproj delete mode 100644 thirdparty/yaml/Yaml.sln delete mode 100644 thirdparty/yaml/test.yaml diff --git a/thirdparty/yaml/AssemblyInfo.cs b/thirdparty/yaml/AssemblyInfo.cs deleted file mode 100644 index 467ce787b3..0000000000 --- a/thirdparty/yaml/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("Yaml Parser")] -[assembly: AssemblyDescription("Yaml .NET library")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("UHasselt students")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Christophe Lambrechts and Jonathan Slenders")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] diff --git a/thirdparty/yaml/Binary.cs b/thirdparty/yaml/Binary.cs deleted file mode 100644 index e1bd9bf30d..0000000000 --- a/thirdparty/yaml/Binary.cs +++ /dev/null @@ -1,154 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// A Yaml Boolean node - /// tag:yaml.org,2002:binary - /// - public class Binary : Scalar - { - private byte [] content; - - /// Binary constructor from byte array - /// This constructor only sets the reference, no new memory is allocated - public Binary (byte[] val) : - base ("tag:yaml.org,2002:binary", NodeType.Binary) - { - content = val; - } - - /// Parse a binary node - public Binary (ParseStream stream) : - base ("tag:yaml.org,2002:binary", NodeType.Binary) - { - try - { - content = Parse (stream); - } - catch (FormatException e) - { - throw new ParseException (stream, e); - } - } - - /// Binary content - /// There is no new memory allocated in the 'set'. - public byte [] Content - { - get { return content; } - set { content = value; } - } - - /// Parses a binairy node. - /// - /// This is not an efficient method. First the stream is placed - /// in a string. And after that the string is converted in a byte[]. - /// If there is a fault in the binairy string then that will only be detected - /// after reading the whole stream and after coneverting. - /// - public static new byte [] Parse (ParseStream stream) - { - bool quoted = false; - bool block = false; - System.Text.StringBuilder input = new System.Text.StringBuilder(); - - if (stream.EOF) - throw new ParseException (stream, "Empty node"); - - // Detect block scalar - stream.SkipSpaces (); - if (stream.Char == '|') - { - block = true; - stream.Next (); - stream.SkipSpaces (); - } - - while ( ! stream.EOF) - { - // Detect quotes - if (stream.Char == '\"') - if (quoted) - break; //End of stream - else - quoted = true; //Start of quoted stream - // Detect and ignore newline char's - else if (!(stream.Char == '\n' && block)) - input.Append( stream.Char ); - - stream.Next (); - } - - //Console.WriteLine("convert [" + input.ToString() + "]"); - - return System.Convert.FromBase64String (input.ToString ()); - } - - /// To String - /// The hexadecimal notation, 20 bytes for each line - public override string ToString () - { - System.Text.StringBuilder output = new System.Text.StringBuilder (); - - output.Append ("[BINARY]\n\t"); - for (uint i = 0; i < content.Length; i++) - { - if ((i%16) == 0) - output.Append( "\n\t" ); - output.AppendFormat ("{0:X2} ", content[i]); - } - output.Append ("\n[/BINARY]"); - - return output.ToString (); - } - - /// - /// Write the base64 content to YAML - /// - /// The lines are splitted in blocks of 20 bytes - protected internal override void Write (WriteStream stream) - { - stream.Append("!!binary |" + "\n" ); - - string bin = System.Convert.ToBase64String(content); - - while (bin.Length > 75) - { - stream.Append(" " + bin.Substring(0, 75) + "\n"); - bin = bin.Substring(75); - } - stream.Append(" " + bin ); - - // Old coden, everything on one line - // stream.Append ("!!binary \"" + System.Convert.ToBase64String (content) + "\""); - } - } - -} diff --git a/thirdparty/yaml/Boolean.cs b/thirdparty/yaml/Boolean.cs deleted file mode 100644 index a87172c0fc..0000000000 --- a/thirdparty/yaml/Boolean.cs +++ /dev/null @@ -1,132 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// Class for storing a Yaml Boolean node - /// tag:yaml.org,2002:bool - /// - public class Boolean : Scalar - { - private bool content; - - /// New boolean - public Boolean (bool val) : - base ("tag:yaml.org,2002:bool", NodeType.Boolean) - { - content = val; - } - - /// Parse boolean - public Boolean (ParseStream stream) : - base ("tag:yaml.org,2002:bool", NodeType.Boolean) - { - // Read the first 8 chars - char [] chars = new char [8]; - - int length = 0; - for (int i = 0; i < chars.Length && ! stream.EOF; i ++) - { - chars [i] = stream.Char; - length ++; - stream.Next (true); - } - - // Compare - if (length == 1) - { - if (chars[0] == 'Y' || chars[0] == 'y') - { content = true; return; } - - if (chars[0] == 'N' || chars[0] == 'n') - { content = false; return; } - } - if (length == 2) - { - string s = "" + chars [0] + chars [1]; - - if (s == "ON" || s == "On" || s == "on") - { content = true; return; } - - if (s == "NO" || s == "No" || s == "no") - { content = false; return; } - } - if (length == 3) - { - string s = "" + chars [0] + chars [1] + chars [2]; - - if (s == "YES" || s == "Yes" || s == "yes") - { content = true; return; } - - if (s == "OFF" || s == "Off" || s == "off") - { content = false; return; } - } - if (length == 4) - { - string s = "" + chars [0] + chars [1] + chars [2] + chars [3]; - - if (s == "TRUE" || s == "True" || s == "true") - { content = true; return; } - } - if (length == 5) - { - string s = "" + chars [0] + chars [1] + chars [2] + chars [3] + chars[4]; - - if (s == "FALSE" || s == "False" || s == "false") - { content = false; return; } - } - - // No boolean - throw new Exception ("No valid boolean"); - } - - /// Node content - public bool Content - { - get { return content; } - set { content = value; } - } - - /// To String - public override string ToString () - { - return "[BOOLEAN]" + content.ToString () + "[/BOOLEAN]"; - } - - /// Write to YAML - protected internal override void Write (WriteStream stream) - { - if (Content) - stream.Append ("y"); - else - stream.Append ("n"); - } - - } -} diff --git a/thirdparty/yaml/COPYING b/thirdparty/yaml/COPYING deleted file mode 100644 index 5faba9d48c..0000000000 --- a/thirdparty/yaml/COPYING +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/thirdparty/yaml/Float.cs b/thirdparty/yaml/Float.cs deleted file mode 100644 index 4ca857aabd..0000000000 --- a/thirdparty/yaml/Float.cs +++ /dev/null @@ -1,295 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// Class for storing a Yaml Float node - /// tag:yaml.org,2002:float - /// - public class Float : Scalar - { - private double content; - - /// New float - public Float (float val) : base ("tag:yaml.org,2002:float", NodeType.Float) - { - content = val; - } - - /// Parse float - public Float (ParseStream stream) : - base ("tag:yaml.org,2002:float", NodeType.Float) - { - // NaN - if (stream.Char == '.') - { - stream.Next (true); - ParseNaN (stream); - } - else - { - // By default positief - int sign = 1; - - // Negative sign - if (stream.Char == '-') - { - sign = -1; - stream.Next (true); - } - // Positive sign - else if (stream.Char == '+') - stream.Next (true); - - // Test for inf, Inf and INF - if ( ! stream.EOF && stream.Char == '.') - { - stream.Next (true); - ParseInf (stream, sign); - } - // Parse the numbers - else if (!stream.EOF) - ParseNumber (stream, sign); - - else - throw new ParseException (stream, - "No valid float, no data behind the sign"); - } - } - - #region Parse special formats (NaN and Inf) - /// - /// Test for the value's nan, NaN and NAN in the stream. If - /// found then it is placed inside the content. - /// There is no more data excepted behind it - /// - private void ParseNaN (ParseStream stream) - { - // Read the first 8 chars - char [] chars = new char [8]; - - int length = 0; - for (int i = 0; i < chars.Length && ! stream.EOF; i ++) - { - chars [i] = stream.Char; - length ++; - stream.Next (true); - } - - // Compare - if (length == 3) - { - string s = "" + chars [0] + chars [1] + chars [2]; - - if (s == "NAN" || s == "NaN" || s == "nan") - { - content = double.NaN; - return; - } - } - - throw new ParseException (stream, "No valid NaN"); - } - - /// - /// Test for the value's inf, Inf and INF in the stream. If - /// found then it 'merged' with the sign and placed in the content. - /// There is no more data excepted behind it. - /// - private void ParseInf (ParseStream stream, int sign) - { - // Read the first 8 chars - char [] chars = new char [8]; - - int length = 0; - for (int i = 0; i < chars.Length && ! stream.EOF; i ++) - { - chars [i] = stream.Char; - length ++; - stream.Next (true); - } - - // Compare - if (length == 3) - { - string s = "" + chars [0] + chars [1] + chars [2]; - - if (s == "INF" || s == "Inf" || s == "inf") - { - if (sign < 0) - content = double.NegativeInfinity; - else - content = double.PositiveInfinity; - - return; - } - } - - throw new ParseException (stream, "No valid infinity"); - } - #endregion - - /// - /// If it is not Infinity or NaN, then parse as a number - /// - private void ParseNumber (ParseStream stream, int sign) - { - bool base60 = false; // Base 60 with ':' - bool afterDecimal = false; // Before or after the decimal point - - double factor = 0.1; - double part; // If base60 different parts, else output value - - // Set sign - content = sign >= 0 ? 1 : -1; - - // First char must 0-9 - if (stream.Char >= '0' && stream.Char <= '9') - { - part = (uint) (stream.Char - '0'); - stream.Next (true); - } - else - throw new ParseException (stream, - "No valid float: Invalid first character of float: " + stream.Char); - - while (! stream.EOF) - { - // Decimal - if (stream.Char >= '0' && stream.Char <= '9') - if (afterDecimal) - { - part += (uint) (stream.Char - '0') * factor; - factor *= 0.1; - } - else - part = (part * 10) + (uint) (stream.Char - '0'); - - // Base60 detected - else if (stream.Char == ':') - { - if ( ! base60) // First time - { - content *= part; // Multiply to get sign - part = 0; - base60 = true; // We are now sure base 60 - } - else - { - if (part > 59) - throw new ParseException (stream, - "Part of base 60 can't be larger then 59"); - content = (60 * content) + part; - part = 0; - } - } - // If first '.', then after decimal, else it is ignored if not in Base60 - else if ( (!base60 || (base60 && !afterDecimal)) && stream.Char == '.' ) - afterDecimal = true; - - // Determine scientific notation - else if ( (stream.Char == 'E' || stream.Char == 'e') && ! base60 ) - { - stream.Next (true); - content *= Math.Pow (10, ParseScient (stream)); - } - // Ignore underscores if before the decimal point, special case if base 60 - else if ((!afterDecimal || (afterDecimal && base60)) && stream.Char != '_') - throw new ParseException (stream, "Unknown char"); - - stream.Next (true); - } - - // Add last part of base to content - if (base60) - content = (60 * content) + part; - else - content *= part; // Multiply to get sign - } - - /// Parses the exponential part of the float - private static long ParseScient (ParseStream stream) - { - ulong output = 0; - short sign; - - if (stream.Char == '-') - sign = -1; - else if (stream.Char == '+') - sign = 1; - else - throw new ParseException (stream, - "Excepted + or - for the exponential part"); - - stream.Next (true); - - while (! stream.EOF) - { - if (stream.Char >= '0' && stream.Char <= '9') - output = (10 * output) + (uint) stream.Char - '0'; - else - throw new ParseException (stream, - "Unexepted char in exponential part: >" + - stream.Char + "<"); - - stream.Next (true); - } - - return sign * (long) output; - } - - /// Content - public double Content - { - get { return content; } - set { content = value; } - } - - /// To string - public override string ToString() - { - return "[FLOAT]" + content + "[/FLOAT]"; - } - - /// Write to a YAML node - protected internal override void Write (WriteStream stream) - { - if (content.Equals( double.NaN )) - stream.Append ("!!float .NaN"); - - else if (content.Equals( double.NegativeInfinity )) - stream.Append ("!!float -.Inf"); - - else if (content.Equals( double.PositiveInfinity )) - stream.Append ("!!float +.Inf"); - - else stream.Append ("!!float " + content); - } - } -} diff --git a/thirdparty/yaml/Integer.cs b/thirdparty/yaml/Integer.cs deleted file mode 100644 index 948984e983..0000000000 --- a/thirdparty/yaml/Integer.cs +++ /dev/null @@ -1,266 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// Class for storing a Yaml Integer node - /// uri: tag:yaml.org,2002:int - /// - public class Integer : Scalar - { - private long content; - - /// New Integer - public Integer (long val) : - base ("tag:yaml.org,2002:int", NodeType.Integer) - { - content = val; - } - - /// Content - public long Content - { - get { return content; } - set { content = value; } - } - - /// Parse an integer - public Integer (ParseStream stream) : - base ("tag:yaml.org,2002:int", NodeType.Integer) - { - short sign = 1; // Positive sign by default - - // Negative sign - if (stream.Char == '-') - { - sign = -1; - stream.Next (); - } - // Positive sign - else if (stream.Char == '+') - stream.Next (); - - try - { - // Determine base - if (stream.Char == '0') - { - stream.Next (); - - // Base 2 - if (stream.Char == 'b') - { - stream.Next (); - content = ParseBase (stream, 2, sign); - return; - } - // Base 16 - else if (stream.Char == 'x') - { - stream.Next (); - content = Parse16 (stream, sign); - return; - } - // Base 8 - else - { - content = ParseBase (stream, 8, sign); - return; - } - } - - // Other base - stream.BuildLookaheadBuffer (); - - // First, try to parse with base 10 - try - { - content = ParseBase (stream, 10, sign); - stream.DestroyLookaheadBuffer (); - return; - } - catch { } - - // If not parseable with base 10, then try base 60 - stream.RewindLookaheadBuffer (); - stream.DestroyLookaheadBuffer (); - - content = Parse60 (stream, sign); - } - catch (Exception ex) - { - throw new ParseException (stream, ex.ToString ()); - } - } - - /// Hexadecimal string - private static long Parse16 (ParseStream stream, short sign) - { - uint output = 0; - - while (! stream.EOF) - { - // 0 .. 9 - if (stream.Char >= '0' && stream.Char <= '9') - { - output = (output * 16) + (uint) (stream.Char - '0'); - OverflowTest (output, sign); - } - // a .. f - else if (stream.Char >= 'a' && stream.Char <= 'f') - { - output = (output * 16) + (uint) (stream.Char - 'a') + 10; - OverflowTest (output, sign); - } - // A .. F - else if (stream.Char >= 'A' && stream.Char <= 'F') - { - output = (output * 16) + (uint) (stream.Char - 'A') + 10; - OverflowTest(output, sign); - } - // Ignore underscores, other chars are not allowed - else if (stream.Char != '_') - throw new Exception ("Unknown char in base 16"); - - stream.Next (); - } - - return (long) (sign * output); - } - - /// Parses a string with a given base (maximum 10) - /// - /// This is not completly correct. For base10 the first char may not be a '_' - /// The other bases allow this... - /// - private static long ParseBase (ParseStream stream, uint basis, short sign) - { - // Base must be <= 10 - if (basis > 10) - throw new Exception ("Base to large. Maximum 10"); - - ulong output = 0; - char max = (char) ((basis - 1) + (int) '0'); - - // Parse - while (! stream.EOF) - { - // Decimal - if (stream.Char >= '0' && stream.Char <= max) - { - output = (output * basis) + (uint) (stream.Char - '0'); - OverflowTest (output, sign); - } - // Ignore underscores, but other chars are not allowed - // see remarks - else if (stream.Char != '_') - throw new Exception ("Unknown char in base " + basis); - - stream.Next (); - } - return sign * (long) output; - } - - /// Parses a string with base 60, without sign - private static long Parse60 (ParseStream stream, short sign) - { - ulong output = 0; - - // Parse - ulong part = 0; - bool firstPart = true; // Only the first part can be larger then 59 - - while (! stream.EOF) - { - // Decimal - if (stream.Char >= '0' && stream.Char <= '9') - part = (part * 10) + (uint) (stream.Char - '0'); - - // New part - else if (stream.Char == ':') - { - // Only the first part can be largen then 60 - if ( ! firstPart) - if (part >= 60) - throw new - Exception ("Part of base 60 scalar is too large (max. 59)"); - else - firstPart = false; - - output = (output * 60) + part; - OverflowTest(output, sign); - part = 0; - } - - // Ignore underscores, other chars are not allowed - else if (stream.Char != '_') - throw new Exception ("Unknown char in base 16"); - - stream.Next (); - } - - // Add last part to the output - if (!firstPart) - if (part >= 60) - throw new Exception ( - "Part of base 60 scalar is too large (max. 59)"); - else - firstPart = false; - - output = (output * 60) + part; - OverflowTest (output, sign); - - return sign * (long) output; - } - - /// Test that the unsigned int fits in a signed int - /// Value to test - /// Sign of the int where it must fit in - private static void OverflowTest (ulong number, short sign) - { - // NOTE: Negatif numbers can be one larger - if ((sign >= 0 && number > System.Int64.MaxValue) || - (sign < 0 && number > (ulong) System.Int64.MaxValue + 1) ) - - throw new Exception ("YAML overflow exception"); - } - - /// To String - public override string ToString () - { - return "[INTEGER]" + content.ToString () + "[/INTEGER]"; - } - - /// Write to YAML - protected internal override void Write (WriteStream stream) - { - stream.Append (content.ToString ()); - } - } -} diff --git a/thirdparty/yaml/Mapping.cs b/thirdparty/yaml/Mapping.cs deleted file mode 100644 index c91133cfab..0000000000 --- a/thirdparty/yaml/Mapping.cs +++ /dev/null @@ -1,292 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; -using System.Collections; - - -// TODO Access to nodes via the [] overload - -namespace Yaml -{ - /// - /// Yaml Mapping - /// - public class Mapping : Node - { - private ArrayList childNodes = new ArrayList (); - - /// New empty mapping - public Mapping () : base ("tag:yaml.org,2002:map", NodeType.Mapping) { } - - /// New mapping from a mappingnode array - public Mapping (MappingNode [] nodes) : - base ("tag:yaml.org,2002:map", NodeType.Mapping) - { - foreach (MappingNode node in nodes) - childNodes.Add (node); - } - - /// Parse a mapping - public Mapping (ParseStream stream) : - base ("tag:yaml.org,2002:map", NodeType.Mapping) - { - // Mapping with eplicit key, (implicit mappings are threaded - // in Node.cs) - if (stream.Char == '?') - { - // Parse recursively - do { - Node key, val; - - // Skip over '?' - stream.Next (); - stream.SkipSpaces (); - - // Parse recursively. The false param avoids - // looking recursively for implicit mappings. - stream.StopAt (new char [] {':'}); - stream.Indent (); - key = Parse (stream, false); - stream.UnIndent (); - stream.DontStop (); - - // Parse recursively. The false param avoids - // looking for implit nodes - if (stream.Char == ':') - { - // Skip over ':' - stream.Next (); - stream.SkipSpaces (); - - // Parse recursively - stream.Indent (); - val = Parse (stream); - stream.UnIndent (); - } - else - val = new Null (); - - AddMappingNode (key, val); - - // Skip possible newline - // NOTE: this can't be done by the drop-newline - // method since this is not the end of a block - if (stream.Char == '\n') - stream.Next (); - } - while ( ! stream.EOF && stream.Char == '?'); - } - // Inline mapping - else if (stream.Char == '{') - { - // Override the parent's stop chars, never stop - stream.StopAt (new char [] { }); - - // Skip '{' - stream.Next (); - - do { - Node key, val; - - // Skip '?' - // (NOTE: it's not obligated to use this '?', - // especially because this is an inline mapping) - if (stream.Char == '?') - { - stream.Next (); - stream.SkipSpaces (); - } - - // Parse recursively the key - stream.StopAt (new char [] {':', ',', '}'}); - stream.Indent (); - key = Parse (stream, false); - stream.UnIndent (); - stream.DontStop (); - - // Value - if (stream.Char == ':') - { - // Skip colon - stream.Next (); - stream.SkipSpaces (); - - // Parse recursively the value - stream.StopAt (new char [] {'}', ','}); - stream.Indent (); - val = Parse (stream, false); - stream.UnIndent (); - stream.DontStop (); - } - else - val = new Null (); - - AddMappingNode (key, val); - - // Skip comma (key sepatator) - if (stream.Char != '}' && stream.Char != ',') - { - stream.DontStop (); - throw new ParseException (stream, "Comma expected in inline sequence"); - } - - if (stream.Char == ',') - { - stream.Next (); - stream.SkipSpaces (); - } - } - while ( ! stream.EOF && stream.Char != '}' ); - - // Re-accept the parent's stop chars - stream.DontStop (); - - // Skip '}' - if (stream.Char == '}') - stream.Next (); - else - throw new ParseException (stream, "Inline mapping not closed"); - } - } - - /// Add a node to this mapping - public void AddMappingNode (Node key, Node val) - { - childNodes.Add (new MappingNode (key, val)); - } - - /// Add a node to this mapping - public void AddMappingNode (MappingNode node) - { - if (node != null) - childNodes.Add (node); - else - childNodes.Add (new MappingNode (null, null)); - } - - /// Number of mappings - public int Count - { - get { return childNodes.Count; } - } - - /// To String - public override string ToString () - { - string result = ""; - foreach (MappingNode node in childNodes) - result += node.ToString (); - - return "[MAPPING]" + result + "[/MAPPING]"; - } - - /// Node info - public override Node Info () - { - Mapping mapping = new Mapping (); - mapping.AddMappingNode (new String ("kind"), new String ("mapping")); - mapping.AddMappingNode (new String ("type_id"), new String (URI)); - - Mapping childs = new Mapping (); - int i = 0; - foreach (MappingNode child in childNodes) - { - Sequence keyvaluepair = new Sequence (); - keyvaluepair.AddNode (child.Key.Info () ); - keyvaluepair.AddNode (child.Value.Info ()); - - childs.AddMappingNode (new String ("key_" + i), keyvaluepair); - i ++; - } - - mapping.AddMappingNode (new String ("value"), childs); - return mapping; - } - - /// Write to YAML - protected internal override void Write (WriteStream stream) - { - foreach (MappingNode node in childNodes) - { - stream.Append ("? "); - - stream.Indent (); - Yaml.Node key = node.Key; - key.Write (stream); - stream.UnIndent (); - - stream.Append (": "); - - stream.Indent (); - node.Value.Write (stream); - stream.UnIndent (); - } - } - - } - - /// - /// Node pair (key, value) of a mapping - /// - public class MappingNode - { - private Node key; - private Node val; - - /// Create a new mappingnode - public MappingNode (Node key, Node val) - { - if (key == null) key = new Null (); - if (val == null) val = new Null (); - - this.key = key; - this.val = val; - } - - /// Key property - public Node Key - { - get { return key; } - set { key = (value == null ? new Null () : value); } - } - - /// Value property - public Node Value - { - get { return val; } - set { val = (value == null ? new Null () : value); } - } - - /// To String - public override string ToString () - { - return - "[KEY]" + key.ToString () + "[/KEY]" + - "[VAL]" + val.ToString () + "[/VAL]"; - } - } -} diff --git a/thirdparty/yaml/Node.cs b/thirdparty/yaml/Node.cs deleted file mode 100644 index ea19cd6ddd..0000000000 --- a/thirdparty/yaml/Node.cs +++ /dev/null @@ -1,469 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -#define UNSTABLE -#define SUPPORT_EXPLICIT_TYPES -#define SUPPORT_IMPLICIT_MAPPINGS - -using System; -using System.Text; -using System.Collections; - -using System.IO; - -namespace Yaml -{ - /// - /// Kind of node, used to determine the type of node. - /// - public enum NodeType - { - /// A Yaml mapping - collection type - Mapping, - /// A Yaml sequence - collection type - Sequence, - - /// A Yaml binary scalar - Binary, - /// A Yaml boolean scalar - Boolean, - /// A Yaml float scalar - Float, - /// A Yaml integer scalar - Integer, - /// A Yaml null scalar - Null, - /// A Yaml string scalar - String, - /// A Yaml timestamp scalar - Timestamp - }; - - /// - /// Node in the Yaml tree - /// - - public abstract class Node - { - /// The uri given by http://yaml.org/type/ - protected readonly string uri; - - /// Determines wich node we are talking about - protected NodeType nodetype; - - /// Node Constructor - /// URI of the node - /// The type of node that we want to store - public Node (string uri, NodeType nodetype) - { - this.uri = uri; - this.nodetype = nodetype; - } - - /// Parse a Yaml string and return a Yaml tree - public static Node Parse (string lines) - { - StringReader reader = new StringReader (lines); - Node node = Parse (new ParseStream (reader)); - reader.Close (); - return node; - } - - /// Parse a Yaml string from a textreader and return a Yaml tree - public static Node Parse (TextReader textreader) - { - return Parse (new ParseStream (textreader)); - } - - /// Return a Yaml string - public string Write () - { - StringWriter stringWriter = new StringWriter (); - WriteStream writeStream = new WriteStream (stringWriter); - - Write (writeStream); - - stringWriter.Close (); - return stringWriter.ToString (); - } - - /// - /// Parse a Yaml string from a textfile and return a Yaml tree - /// - public static Node FromFile (string filename) - { - // Open YAML file - StreamReader reader = File.OpenText (filename); - ParseStream parsestream = new ParseStream (reader); - - // Parse - Node node = Parse (parsestream); - - // Close YAML file - reader.Close (); - return node; - } - - /// - /// Write a YAML tree to a file using UTF-8 encoding - /// - public void ToFile (string filename) - { - ToFile (filename, Encoding.UTF8); - } - - /// - /// Write a YAML tree to a file - /// - public void ToFile (string filename, Encoding enc) - { - // Open YAML file - StreamWriter writer = new StreamWriter (filename, false, enc); - WriteStream writestream = new WriteStream (writer); - - // Write - Write (writestream); - - // Close YAML file - writer.Close (); - } - - /// Parse function - protected static Node Parse (ParseStream stream) { return Parse (stream, true); } - - /// Internal parse method - /// - /// Avoids ethernal loops while parsing implicit mappings. Implicit mappings are - /// not rocognized by a leading character. So while trying to parse the key of - /// something we think that could be a mapping, we're sure that if it is a mapping, - /// the key of this implicit mapping is not a mapping itself. - /// - /// NOTE: Implicit mapping still belong to unstable code and require the UNSTABLE and - /// IMPLICIT_MAPPINGS preprocessor flags. - /// - /// - protected static Node Parse (ParseStream stream, bool parseImplicitMappings) - { - // ---------------- - // Skip Whitespace - // ---------------- - if (! stream.EOF) - { - // Move the firstindentation pointer after the whitespaces of this line - stream.SkipSpaces (); - while (stream.Char == '\n' && ! stream.EOF) - { - // Skip newline and next whitespaces - stream.Next (); - stream.SkipSpaces (); - } - } - - // ----------------- - // No remaining chars (Null/empty stream) - // ----------------- - if (stream.EOF) - return new Null (); - - // ----------------- - // Explicit type - // ----------------- - -#if SUPPORT_EXPLICIT_TYPES - stream.BuildLookaheadBuffer (); - - char a = '\0', b = '\0'; - - a = stream.Char; stream.Next (); - b = stream.Char; stream.Next (); - - // Starting with !! - if (a == '!' && b == '!' && ! stream.EOF) - { - stream.DestroyLookaheadBuffer (); - - // Read the tagname - string tag = ""; - - while (stream.Char != ' ' && stream.Char != '\n' && ! stream.EOF) - { - tag += stream.Char; - stream.Next (); - } - - // Skip Whitespace - if (! stream.EOF) - { - stream.SkipSpaces (); - while (stream.Char == '\n' && ! stream.EOF) - { - stream.Next (); - stream.SkipSpaces (); - } - } - - // Parse - Node n; - switch (tag) - { - // Mappings and sequences - // NOTE: - // - sets are mappings without values - // - Ordered maps are ordered sequence of key: value - // pairs without duplicates. - // - Pairs are ordered sequence of key: value pairs - // allowing duplicates. - - // TODO: Create new datatypes for omap and pairs - // derived from sequence with a extra duplicate - // checking. - - case "seq": n = new Sequence (stream); break; - case "map": n = new Mapping (stream); break; - case "set": n = new Mapping (stream); break; - case "omap": n = new Sequence (stream); break; - case "pairs": n = new Sequence (stream); break; - - // Scalars - // - // TODO: do we have to move this to Scalar.cs - // in order to get the following working: - // - // !!str "...": "..." - // !!str "...": "..." - - case "timestamp": n = new Timestamp (stream); break; - case "binary": n = new Binary (stream); break; - case "null": n = new Null (stream); break; - case "float": n = new Float (stream); break; - case "int": n = new Integer (stream); break; - case "bool": n = new Boolean (stream); break; - case "str": n = new String (stream); break; - - // Unknown data type - default: - throw new Exception ("Incorrect tag '!!" + tag + "'"); - } - - return n; - } - else - { - stream.RewindLookaheadBuffer (); - stream.DestroyLookaheadBuffer (); - } -#endif - // ----------------- - // Sequence - // ----------------- - - if (stream.Char == '-' || stream.Char == '[') - return new Sequence (stream); - - // ----------------- - // Mapping - // ----------------- - - if (stream.Char == '?' || stream.Char == '{') - return new Mapping (stream); - - // ----------------- - // Try implicit mapping - // ----------------- - - // This are mappings which are not preceded by a question - // mark. The keys have to be scalars. - -#if (UNSTABLE && SUPPORT_IMPLICIT_MAPPINGS) - - // NOTE: This code can't be included in Mapping.cs - // because of the way we are using to rewind the buffer. - - Node key, val; - - if (parseImplicitMappings) - { - // First Key/value pair - - stream.BuildLookaheadBuffer (); - - stream.StopAt (new char [] {':'}); - - // Keys of implicit mappings can't be sequences, or other mappings - // just look for scalars - key = Scalar.Parse (stream, false); - stream.DontStop (); - -Console.WriteLine ("key: " + key); - - // Followed by a colon, so this is a real mapping - if (stream.Char == ':') - { - stream.DestroyLookaheadBuffer (); - - Mapping mapping = new Mapping (); - - // Skip colon and spaces - stream.Next (); - stream.SkipSpaces (); - - // Parse the value -Console.Write ("using buffer: " + stream.UsingBuffer ()); - stream.Indent (); -Console.Write ("using buffer: " + stream.UsingBuffer ()); -// val = Parse (stream, false); -Console.Write ("<<"); -while (!stream.EOF) {Console.Write (stream.Char);stream.Next (true);} -Console.Write (">>"); - -val = new String (stream); - - -Console.Write ("using buffer: " + stream.UsingBuffer ()); - stream.UnIndent (); -Console.Write ("using buffer: " + stream.UsingBuffer ()); - -Console.Write ("<<"); -while (!stream.EOF) {Console.Write (stream.Char);stream.Next (true);} -Console.Write (">>"); - - - - -Console.WriteLine ("val: " + val); - mapping.AddMappingNode (key, val); - - // Skip possible newline - // NOTE: this can't be done by the drop-newline - // method since this is not the end of a block - while (stream.Char == '\n') - stream.Next (true); - - // Other key/value pairs - while (! stream.EOF) - { - stream.StopAt (new char [] {':'} ); - stream.Indent (); - key = Scalar.Parse (stream); - stream.UnIndent (); - stream.DontStop (); - -Console.WriteLine ("key 2: " + key); - if (stream.Char == ':') - { - // Skip colon and spaces - stream.Next (); - stream.SkipSpaces (); - - // Parse the value - stream.Indent (); - val = Parse (stream); - stream.UnIndent (); - -Console.WriteLine ("val 2: " + val); - mapping.AddMappingNode (key, val); - } - else // TODO: Is this an error? - { - // NOTE: We can't recover from this error, - // the last buffer has been destroyed, so - // rewinding is impossible. - throw new ParseException (stream, - "Implicit mapping without value node"); - } - - // Skip possible newline - while (stream.Char == '\n') - stream.Next (); - } - - return mapping; - } - - stream.RewindLookaheadBuffer (); - stream.DestroyLookaheadBuffer (); - } - -#endif - // ----------------- - // No known data structure, assume this is a scalar - // ----------------- - - Scalar scalar = Scalar.Parse (stream); - - // Skip trash - while (! stream.EOF) - stream.Next (); - - - return scalar; - } - - /// - /// URI of this node, according to the YAML documentation. - /// - public string URI - { - get { return uri; } - } - - /// - /// Kind of node: mapping, sequence, string, ... - /// - public NodeType Type - { - get { return nodetype; } - } - - /// - /// Writes a Yaml tree back to a file or stream - /// - /// - /// should not be called from outside the parser. This method - /// is only public from inside the Sequence and Mapping Write - /// methods. - /// - /// Were the output data go's - protected internal virtual void Write (WriteStream stream) {} - - /// - /// The ToString method here, and in all the classses - /// derived from this class, is used mainly for debugging - /// purpose. ToString returns a xml-like textual representation - /// of the objects. It's very useful to see how a Yaml document - /// has been parsed because of the disambiguous representation - /// of this notation. - /// - public override abstract string ToString (); - - /// - /// Node info returns a YAML node and is also mostly used - /// for debugging the parser. This could be used for - /// traversing the meta-info of another YAML tree - /// - public abstract Node Info (); - } -} diff --git a/thirdparty/yaml/Null.cs b/thirdparty/yaml/Null.cs deleted file mode 100644 index f68eb5fbaa..0000000000 --- a/thirdparty/yaml/Null.cs +++ /dev/null @@ -1,100 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// Class for storing a Yaml Null node - /// tag:yaml.org,2002:null - /// - public class Null : Scalar - { - /// Null Constructor - public Null () : base ("tag:yaml.org,2002:null", NodeType.Null) { } - - /// Parse a null node - public Null (ParseStream stream) : - base ("tag:yaml.org,2002:null", NodeType.Null) - { - // An empty string is a valid null node - if (stream.EOF) - return; - - else - { - // Read the first 4 chars - char [] chars = new char [8]; - int length = 0; - for (int i = 0; i < chars.Length && ! stream.EOF; i ++) - { - chars [i] = stream.Char; - length ++; - stream.Next (); - } - - // Compare - if (length == 1) - { - string s = "" + chars [0]; - - // Canonical notation - if (s == "~") - return; - } - if (length == 4) - { - string s = "" + chars [0] + chars [1] + chars [2] + chars [3]; - - // null, Null, NULL - if (s == "NULL" || s == "Null" || s == "null") - return; - } - - throw new ParseException (stream, "Not NULL"); - } - } - - /// Content property - public object Content - { - get { return null; } - } - - /// To String - public override string ToString () - { - return "[NULL]~[/NULL]"; - } - - /// Write to YAML - protected internal override void Write (WriteStream stream) - { - stream.Append ("~"); - } - } -} diff --git a/thirdparty/yaml/ParseException.cs b/thirdparty/yaml/ParseException.cs deleted file mode 100644 index b4298a0ed4..0000000000 --- a/thirdparty/yaml/ParseException.cs +++ /dev/null @@ -1,63 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// ParseException, could be thrown while parsing a YAML stream - /// - public class ParseException : Exception - { - // Line of the Yaml stream/file where the fault occures - private readonly int linenr; - - /// Constructor - /// The parse stream (contains the line number where it went wrong) - /// Info about the exception - public ParseException (ParseStream stream, string message) : - base ("Parse error near line " + stream.CurrentLine + ": " + message) - { - this.linenr = stream.CurrentLine; - } - - /// Constructor - /// The parse stream (contains the line number where it went wrong) - /// The exception that is for example throwed again - public ParseException (ParseStream stream, Exception child) : - base ( "Parse error near line " + stream.CurrentLine, child ) - { - this.linenr = stream.CurrentLine; - } - - /// The line where the error occured - public int LineNumber - { - get { return linenr; } - } - } -} diff --git a/thirdparty/yaml/ParseStream.cs b/thirdparty/yaml/ParseStream.cs deleted file mode 100644 index 271a59e5ec..0000000000 --- a/thirdparty/yaml/ParseStream.cs +++ /dev/null @@ -1,899 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; -using System.Collections; - -using System.IO; - -namespace Yaml -{ - /// - /// The Preprocessor class - /// Given a character stream, this class will - /// walk through that stream. - /// NOTE: Comments are not longer skipped at this level, - /// but now in the last level instead. (because of - /// problems with comments within the buffer) - /// NOTE: Null characters are skipped, read nulls should - /// be escaped. \0 - /// - public class Preprocessor - { - private TextReader stream; - private int currentline = 1; // Line numbers start with one - private bool literal = false; // Parse literal/verbatim - - /// Constuctor - public Preprocessor (TextReader stream) - { - this.stream = stream; - } - - /// Jump to the next character - public void Next () - { - // Transition to the next line? - if (Char == '\n') - currentline ++; - - // Not yet passed the end of file - if (! EOF) - { - // Next - stream.Read (); - - // Skip null chars - while (stream.Peek () == '\0') - stream.Read (); - } - } - - /// Start parsing literal - public void StartLiteral () - { - literal = true; - } - - /// Stop parsing literal - public void StopLiteral () - { - if (literal) - literal = false; - else - throw new Exception ("Called StopLiteral without " + - "calling StartLiteral before"); - } - - /// Literal parsing - public bool Literal - { - get { return literal; } - // No set method, setting must by using the {Start,Stop}Literal - // methods. They provide mory symmetry in the parser. - } - - /// The current character - public char Char - { - get - { - if (EOF) - return '\0'; - else - return (char) stream.Peek (); - } - } - - /// End of file/stream - public bool EOF - { - get { return stream.Peek () == -1; } - } - - /// Returns the current line number - public int CurrentLine - { - get { return currentline; } - } - } - - /// - /// The indentation processor, - /// This class divides the stream from the preprocessor - /// in substreams, according to the current level - /// of indentation. - /// - public class IndentationProcessor : Preprocessor - { - // While trying to readahead over whitespaces, - // This is how many whitespaces were skipped that weren't yet read - private int whitespaces = 0; - private int whitespacesSkipped = 0; - - // Reached the end - private bool endofstream = false; - - // Current level of indentation - private int indentationLevel = 0; - private bool indentationRequest = false; - private Stack indentationStack = new Stack (); - - /// Constructor - public IndentationProcessor (TextReader stream) : base (stream) { } - - /// - /// Request an indentation. When we meet a \n and the following - /// line is more indented then the current indentationlever, then - /// save this request - /// - public void Indent () - { - if (Literal) - throw new Exception ("Cannot (un)indent while literal parsing " + - "has been enabled"); - else - { - // Handle double requests - if (indentationRequest) - indentationStack.Push ((object) indentationLevel); - - // Remember - indentationRequest = true; - } - } - - /// Cancel the last indentation - public void UnIndent () - { - if (Literal) - throw new Exception ("Cannot (un)indent while literal parsing " + - "has been enabled"); - else - { - // Cancel the indentation request - if (indentationRequest) - { - indentationRequest = false; - return; - } - - // Unpop the last indentation - if (indentationStack.Count > 0) - indentationLevel = (int) indentationStack.Pop (); - - // When not indented - else - throw new Exception ("Unable to unindent a not indented parse stream"); - - // Parent stream not yet finished - // Skipped whitespaces in the childstream (at that time assumed to be - // indentation) can become content. - if (endofstream && indentationLevel <= whitespaces) - { - endofstream = false; - if (whitespaces == this.indentationLevel) - whitespaces = 0; - } - } - } - - /// Go to the next parsable char in the stream - public new void Next () - { - if (endofstream) - return; - - // Are there still whitespaces to skip - if (whitespaces > 0) - { - // All whitespaces were skipped - if (whitespaces == whitespacesSkipped + this.indentationLevel) - whitespaces = 0; - - // Else, skip one - else - { - whitespacesSkipped ++; - return; - } - } - - // All whitespaces have been skipped - if (whitespaces == 0 && ! base.EOF) - { - // When a char is positioned at a newline '\n', - // then skip 'indentation' chars and continue. - // When there are less spaces available, then we are - // at the end of the (sub)stream - if (! base.EOF && base.Char == '\n' && ! Literal) - { - // Skip over newline - base.Next (); - - // Skip indentation (and count the spaces) - int i = 0; - while (! base.EOF && base.Char == ' ' && i < this.indentationLevel) - { - i ++; - base.Next (); - } - - // Not enough indented? - if (i < this.indentationLevel) - { - // Remember the number of whitespaces, and - // continue at the moment that the indentationlevel - // drops below this number of whitespaces - whitespaces = i; - whitespacesSkipped = 0; - endofstream = true; - return; - } - // Indentation request - else if (indentationRequest) - { - while (! base.EOF && base.Char == ' ') - { - i ++; - base.Next (); - } - - // Remember current indentation - indentationStack.Push ((object) indentationLevel); - indentationRequest = false; - - // Number of spaces before this line is equal to the - // current level of indentation, so the - // indentation request cannot be fulfilled - if (indentationLevel == i) - { - whitespaces = i; - whitespacesSkipped = 0; - endofstream = true; - return; - } - else // i > indentationLevel - indentationLevel = i; - } - } - else - // Next char - base.Next (); - } - else - endofstream = true; - } - - /// Reads the current char from the stream - public new char Char - { - get - { - // In case of spaces - if (whitespaces > 0) - return ' '; - - // \0 at the end of the stream - else if (base.EOF || endofstream) - return '\0'; - - // Return the char - else - return base.Char; - } - } - - /// End of File/Stream - public new bool EOF - { - get { return endofstream || base.EOF; } - } - } - - /// - /// Third stream processor, this class adds a buffer with a maximum - /// size of 1024 chars. The buffer cannot encapsulate multiple lines - /// because that could do strange things while rewinding/indenting - /// - - public class BufferStream : IndentationProcessor - { - LookaheadBuffer buffer = new LookaheadBuffer (); - - // When the buffer is used, this is true - private bool useLookaheadBuffer = false; - - // In use, but requested to destroy. The buffer will keep to exists - // (only in this layer) and shall be destroyed when we move out of - // the buffer - private bool destroyRequest = false; - - /// Constructor - public BufferStream (TextReader stream) : base (stream) { } - - /// Build lookahead buffer - public void BuildLookaheadBuffer () - { - if (Literal) - throw new Exception ("Cannot build a buffer while " + - "literal parsing is enabled"); - else - { - // When the buffer is already in use - if (useLookaheadBuffer && ! destroyRequest) - throw new Exception ("Buffer already exist, cannot rebuild " + - "the buffer at this level"); - - // Cancel the destroy request - if (destroyRequest) - destroyRequest = false; - - // Or start a new buffer - else - { - buffer.Clear (); - buffer.Append (Char); - } - - useLookaheadBuffer = true; - } - } - - /// Move to the next character in the parse stream. - public new void Next () - { - // End of file (This check is not really necessary because base.next - // would skip this anyway) - if (EOF) return; - - // When it's not allowed to leave the buffer - if (useLookaheadBuffer && ! destroyRequest && ! NextInBuffer () ) - return; - - // When using the lookahead buffer - if (useLookaheadBuffer) - { - // Requested to destroy - if (destroyRequest) - { - // But not yet reached the end of the buffer - if (buffer.Position < buffer.LastPosition) - { - buffer.Position ++; - buffer.ForgetThePast (); - } - // Reached the end - else - { - buffer.Clear (); - useLookaheadBuffer = false; - destroyRequest = false; - - base.Next (); - } - } - // Continue in the buffer - else - { - // We've been here before - if (buffer.Position < buffer.LastPosition) - buffer.Position ++; - - // This is new to the buffer, but there is place - // to remember new chars - else if ( - buffer.Position == buffer.LastPosition && - ! buffer.Full) - { - // Save the next char in the buffer - base.Next(); - buffer.Append (base.Char); - } - // Otherwise, the buffer is full - else - throw new Exception ("buffer overflow"); - } - } - // Not using the buffer - else - base.Next(); - } - - /// Returns true when using a buffer - public bool UsingBuffer () - { - return useLookaheadBuffer && ! destroyRequest; - } - - /// - /// Returns true when the next char will still be in the buffer - /// (after calling next) - /// - private bool NextInBuffer () - { - return - // Using the buffer - useLookaheadBuffer && - - // Next char has been read before - (buffer.Position < buffer.LastPosition || - - // Or the next char will also be in the buffer - (Char != '\n' && ! base.EOF && - - // There is still unused space - ! buffer.Full)); - } - - /// Destroys the current lookaheadbuffer, if there is one - public void DestroyLookaheadBuffer () - { - if (useLookaheadBuffer && ! destroyRequest) - { - buffer.ForgetThePast (); - destroyRequest = true; - } - else - throw new Exception ("Called destroy buffer before building the buffer"); - } - - /// Rewind the buffer - public void RewindLookaheadBuffer () - { - if (! useLookaheadBuffer || destroyRequest) - throw new Exception ("Cannot rewind the buffer. No buffer in use"); - - else - buffer.Rewind (); - } - - /// The current character - public new char Char - { - get - { - // When using a buffer - if (useLookaheadBuffer) - return buffer.Char; - - else - return base.Char; - } - } - - /// End of stream/file - public new bool EOF - { - get - { - return - // When it's not allowed to run out of the buffer - (useLookaheadBuffer && ! destroyRequest && ! NextInBuffer () ) || - - // Not using the buffer, but the end of stream has been reached - (! useLookaheadBuffer && base.EOF); - } - } - - /// Current position in the lookahead buffer - protected int LookaheadPosition - { - get - { - if (useLookaheadBuffer) - return buffer.Position; - - else - throw new Exception ("Not using a lookahead buffer"); - } - set - { - if (useLookaheadBuffer) - { - if (value >= 0 && value <= buffer.LastPosition) - buffer.Position = value; - - else - throw new Exception ("Lookahead position not between 0 " + - "and the buffer size"); - } - else - throw new Exception ("Not using a lookahead buffer"); - } - } - } - - /// Parsestream with multilever buffer - public class MultiBufferStream : BufferStream - { - private Stack bufferStack = new Stack (); // Top is current buffer start - - /// Constructor - public MultiBufferStream (TextReader stream) : base (stream) { } - - /// Destroy the current buffer - public new void BuildLookaheadBuffer () - { - if (Literal) - throw new Exception ("Cannot build a buffer while " + - "literal parsing is enabled"); - else - { - // Already using a buffer - if (base.UsingBuffer ()) - // Remember the current position - bufferStack.Push ((object) base.LookaheadPosition); - - // Otherwise, create a new buffer - else - { - // Remember the current position (= 0) - bufferStack .Push ((object) 0); - - base.BuildLookaheadBuffer (); - } - } - } - - /// Destroy the current buffer - public new void DestroyLookaheadBuffer () - { - // Clear the buffer info when we runned out of the buffer, - if ( ! base.UsingBuffer () ) - bufferStack.Clear (); - - else - { - // Unpop the buffers start index - bufferStack.Pop (); - - // Destroy it when the last buffer is gone - if (bufferStack.Count == 0) - base.DestroyLookaheadBuffer (); - } - } - - /// Rewind the current buffer - public new void RewindLookaheadBuffer () - { - if (base.UsingBuffer () ) - base.LookaheadPosition = (int) bufferStack.Peek (); - else - throw new Exception ("Rewinding not possible. Not using a " + - "lookahead buffer."); - } - } - - /// - /// Drop the comments - /// (This is disabled when literal parsing is enabled) - /// - public class DropComments : MultiBufferStream - { - /// Constructor - public DropComments (TextReader stream) : base (stream) { } - - /// Move to the next character in the parse stream. - public new void Next () - { - base.Next (); - - // Skip comments - if (base.Char == '#' && ! Literal) - while (! base.EOF && base.Char != '\n') - base.Next (); - } - } - - /// - /// This layer removes the trailing newline at the end of each (sub)stream - /// - public class DropTrailingNewline : DropComments - { - // One char buffer - private bool newline = false; - - /// Constructor - public DropTrailingNewline (TextReader stream) : base (stream) { } - - /// The current character - public new char Char - { - get - { - if (EOF) - return '\0'; - else if (newline) - return '\n'; - else - return base.Char; - } - } - - /// End of File/Stream - public new bool EOF - { - get { return ! newline && base.EOF; } - } - - /// Skip space characters - public int SkipSpaces () - { - int count = 0; - while (Char == ' ') - { - Next (); - count ++; - } - return count; - } - - /// Move to the next character in the parse stream. - public new void Next () - { - Next (false); - } - - /// Move to the next character in the parse stream. - /// Forget the last newline - public void Next (bool dropLastNewLine) - { - if (newline) - newline = false; - else - { - base.Next (); - - if (dropLastNewLine && ! base.EOF && Char == '\n') - { - base.Next (); - - if (base.EOF) - newline = false; - else - newline = true; - } - } - } - } - - - /// - /// Stops parsing at specific characters, useful for parsing inline - /// structures like (for instance): - /// - /// [aaa, bbb, ccc, {ddd: eee, "fff": ggg}] - /// - public class ParseStream : DropTrailingNewline - { - private Stack stopstack = new Stack (); - - /// Constructor - public ParseStream (TextReader stream) : base (stream) { } - - /// Set the characters where we should stop. - public void StopAt (char [] characters) - { - stopstack.Push (characters); - } - - /// Unset the characters where we should stop. - public void DontStop () - { - if (stopstack.Count > 0) - stopstack.Pop (); - else - throw new Exception ("Called DontStop without " + - "calling StopAt before"); - } - - /// True when we have to stop here - private bool StopNow - { - get { - if (stopstack.Count > 0) - foreach (char c in (char []) stopstack.Peek ()) - if (c == base.Char) - return true; - - return false; - } - } - - /// Start parsing literal - public new void StartLiteral () - { - base.StartLiteral (); - - // Parsing literal disables stopping - StopAt (new Char [] { }); - } - - /// Stop parsing literal - public new void StopLiteral () - { - base.StopLiteral (); - - DontStop (); - } - /// Move to the next character in the parse stream. - public new void Next () - { - Next (false); - } - - /// Move to the next character in the parse stream. - public new void Next (bool dropLastNewLine) - { - if ( ! StopNow ) - base.Next (dropLastNewLine); - } - - /// The current character - public new char Char - { - get - { - if (StopNow) - return '\0'; - - else - return base.Char; - } - } - - /// End of stream/file - public new bool EOF - { - get { return StopNow || base.EOF; } - } - } - - /// - /// The lookahead buffer, used by the buffer layer in the parser - /// - class LookaheadBuffer - { - // The buffer array - private char [] buffer = new char [1024]; - - private int size = 0; // 0 = Nothing in the buffer - private int position = -1; // Current position - private int rotation = 0; // Start of circular buffer - - /// Character at the current position - public char Char - { - get - { - if (size > 0) - return buffer [(position + rotation) % buffer.Length]; - - else - throw new Exception ("Trying to read from an emty buffer"); - } - } - - /// The current position - public int Position - { - get { return position; } - - set - { - if (value >= 0 && value < size) - position = value; - else - throw new Exception ("Buffer position should be " + - "between zero and 'size' "); - } - } - - /// The last possible postition which could be set - public int LastPosition - { - get { return size - 1; } - } - - /// - /// The last possible position which could be set if - /// the buffer where full - /// - public int MaxPosition - { - get { return buffer.Length - 1; } - } - - /// True when the buffer is full - public bool Full - { - get { return size == buffer.Length; } - } - - /// Current buffer size - public int Size - { - get { return size; } - } - - /// Append a character to the buffer - public void Append (char c) - { - // Appending is only possible when the current position is the - // last in the buffer - if (position < LastPosition) - throw new Exception ("Appending to buffer only possible " + - "when the position is the last"); - - // Buffer overflow - if (size == buffer.Length) - throw new Exception ("Buffer full"); - - // Append - position ++; - size ++; - buffer [(position + rotation) % buffer.Length] = c; - } - - /// Rewind the buffer - public void Rewind () - { - position = 0; - } - - /// Reset (clear) the buffer - public void Clear () - { - position = -1; - size = 0; - } - - /// Move to the next character - public void Next () - { - if (Position < Size) - Position ++; - - else throw new Exception ("Cannot move past the buffer"); - } - - /// - /// Remove characters from the buffer before the current character - /// - public void ForgetThePast () - { - // Size becomes smaller, characters before the position should be dropped - size -= position; - - // The current position becomes the new startposition - rotation = (rotation + position + buffer.Length) % buffer.Length; - - // The current position in the new buffer becomes zero - position = 0; - } - } -} diff --git a/thirdparty/yaml/Scalar.cs b/thirdparty/yaml/Scalar.cs deleted file mode 100644 index 9d2cb849c0..0000000000 --- a/thirdparty/yaml/Scalar.cs +++ /dev/null @@ -1,137 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -#define SUPPORT_NULL_NODES -#define SUPPORT_INTEGER_NODES -#define SUPPORT_FLOAT_NODES -#define SUPPORT_BOOLEAN_NODES -#define SUPPORT_TIMESTAMP_NODES - -using System; - -namespace Yaml -{ - /// - /// All Yaml scalars are derived from this class - /// - public abstract class Scalar : Node - { - /// Constructor - public Scalar (string uri, NodeType nodetype) : base (uri, nodetype) { } - - - /// - /// Parses a scalar - /// - /// Integer - /// String - /// Boolean - /// Null - /// Timestamp - /// Float - /// Binary - /// - /// - /// - /// Binary is only parsed behind an explicit !!binary tag (in Node.cs) - /// - public static new Scalar Parse (ParseStream stream) - { - // ----------------- - // Parse scalars - // ----------------- - - stream.BuildLookaheadBuffer (); - - // Try Null -#if SUPPORT_NULL_NODES - try - { - Scalar s = new Null (stream); - stream.DestroyLookaheadBuffer (); - return s; - } catch { } -#endif - // Try boolean -#if SUPPORT_BOOLEAN_NODES - stream.RewindLookaheadBuffer (); - try - { - Scalar scalar = new Boolean (stream); - stream.DestroyLookaheadBuffer (); - return scalar; - } - catch { } -#endif - // Try integer -#if SUPPORT_INTEGER_NODES - stream.RewindLookaheadBuffer (); - try - { - Scalar scalar = new Integer (stream); - stream.DestroyLookaheadBuffer (); - return scalar; - } catch { } -#endif - // Try Float -#if SUPPORT_FLOAT_NODES - stream.RewindLookaheadBuffer (); - try - { - Scalar scalar = new Float (stream); - stream.DestroyLookaheadBuffer (); - return scalar; - } - catch { } -#endif - // Try timestamp -#if SUPPORT_TIMESTAMP_NODES - stream.RewindLookaheadBuffer (); - try { - Scalar scalar = new Timestamp (stream); - stream.DestroyLookaheadBuffer (); - return scalar; - } catch { } -#endif - // Other scalars are strings - stream.RewindLookaheadBuffer (); - stream.DestroyLookaheadBuffer (); - - return new String (stream); - } - - /// Node info -// TODO, move to each induvidual child - public override Node Info () - { - Mapping mapping = new Mapping (); - mapping.AddMappingNode (new String ("kind"), new String ("scalar")); - mapping.AddMappingNode (new String ("type_id"), new String (URI)); - mapping.AddMappingNode (new String ("value"), this); - return mapping; - } - } -} diff --git a/thirdparty/yaml/Sequence.cs b/thirdparty/yaml/Sequence.cs deleted file mode 100644 index e26bdbd8aa..0000000000 --- a/thirdparty/yaml/Sequence.cs +++ /dev/null @@ -1,197 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; -using System.Collections; - -namespace Yaml -{ - /// - /// Represents a Yaml Sequence - /// - public class Sequence : Node - { - private ArrayList childNodes = new ArrayList (); - - /// New, empty sequence - public Sequence ( ) : base ("tag:yaml.org,2002:seq", NodeType.Sequence) { } - - /// New sequence from a node array - public Sequence (Node [] nodes) : - base ("tag:yaml.org,2002:seq", NodeType.Sequence) - { - foreach (Node node in nodes) - childNodes.Add (node); - } - - /// Parse a sequence - public Sequence (ParseStream stream) : - base ("tag:yaml.org,2002:seq", NodeType.Sequence) - { - // Is this really a sequence? - if (stream.Char == '-') - { - // Parse recursively - do { - // Override the parent's stop chars, never stop - stream.StopAt (new char [] { } ); - - // Skip over '-' - stream.Next (); - - // Parse recursively - stream.Indent (); - AddNode (Parse (stream)); - stream.UnIndent (); - - // Re-accept the parent's stop chars - stream.DontStop (); - } - while ( ! stream.EOF && stream.Char == '-' ); - } - // Or inline Sequence - else if (stream.Char == '[') - { - // Override the parent's stop chars, never stop - stream.StopAt (new char [] { }); - - // Skip '[' - stream.Next (); - - do { - stream.StopAt (new char [] {']', ','}); - stream.Indent (); - AddNode (Parse (stream, false)); - stream.UnIndent (); - stream.DontStop (); - - // Skip ',' - if (stream.Char != ']' && stream.Char != ',') - { - stream.DontStop (); - throw new ParseException (stream, "Comma expected in inline sequence"); - } - - if (stream.Char == ',') - { - stream.Next (); - stream.SkipSpaces (); - } - } - while ( ! stream.EOF && stream.Char != ']'); - - // Re-accept the parent's stop chars - stream.DontStop (); - - // Skip ']' - if (stream.Char == ']') - stream.Next (true); - else - throw new ParseException (stream, "Inline sequence not closed"); - - } - // Throw an exception when not - else - throw new Exception ("This is not a sequence"); - } - - /// Add a node to this sequence - public void AddNode (Node node) - { - if (node != null) - childNodes.Add (node); - else - childNodes.Add (new Null ()); - } - - /// Get a node - public Node this [int index] - { - get - { - if (index > 0 && index < childNodes.Count) - return (Node) childNodes [index]; - - else - throw new IndexOutOfRangeException (); - } - } - - /// The node array - public Node [] Nodes - { - get - { - Node [] nodes = new Node [childNodes.Count]; - - for (int i = 0; i < childNodes.Count; i ++) - nodes [i] = (Node) childNodes [i]; - - return nodes; - } - } - - /// Textual destription of this node - public override string ToString () - { - string result = ""; - foreach (Node node in childNodes) - result += node.ToString (); - - return "[SEQUENCE]" + result + "[/SEQUENCE]"; - } - - /// Node info - public override Node Info () - { - Mapping mapping = new Mapping (); - mapping.AddMappingNode (new String ("kind"), new String ("sequence")); - mapping.AddMappingNode (new String ("type_id"), new String (URI)); - - Sequence childs = new Sequence (); - - foreach (Node child in childNodes) - childs.AddNode (child.Info ()); - - mapping.AddMappingNode (new String ("value"), childs); - return mapping; - } - - /// Write back to a stream - protected internal override void Write (WriteStream stream) - { - foreach (Node node in childNodes) - { - stream.Append ("- "); - - stream.Indent (); - node.Write (stream); - stream.UnIndent (); - } - } - - } -} diff --git a/thirdparty/yaml/String.cs b/thirdparty/yaml/String.cs deleted file mode 100644 index 25243dfbe2..0000000000 --- a/thirdparty/yaml/String.cs +++ /dev/null @@ -1,449 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -// Unicode support: -// http://www.yoda.arachsys.com/csharp/unicode.html - -namespace Yaml -{ - /// - /// Yaml String node - /// - public class String : Scalar - { - private string content; - private bool block = false; - private bool folded = false; - - /// New string constructor - public String (string val) : - base ("tag:yaml.org,2002:str", NodeType.String) - { - content = val; - } - - /// Parse a string - public String (ParseStream stream) : - base ("tag:yaml.org,2002:str", NodeType.String) - { - // set flags for folded or block scalar - if (stream.Char == '>') // TODO: '+' and '-' chomp chars - folded = true; - - else if (stream.Char == '|') - block = true; - - if (block || folded) - { - stream.Next (); - stream.SkipSpaces (); - } - - // ----------------- - // Folded Scalar - // ----------------- - if (folded) - { - System.Text.StringBuilder builder = new System.Text.StringBuilder (); - - // First line (the \n after the first line is always ignored, - // not replaced with a whitespace) - while (! stream.EOF && stream.Char != '\n') - { - builder.Append (stream.Char); - stream.Next (); - } - - // Skip the first newline - stream.Next (); - - // Next lines (newlines will be replaced by spaces in folded scalars) - while (! stream.EOF) - { - if (stream.Char == '\n') - builder.Append (' '); - else - builder.Append (stream.Char); - - stream.Next (true); - } - content = builder.ToString (); - } - - // ----------------- - // Block Scalar (verbatim block without folding) - // ----------------- - else if (block) - { -/* -Console.Write(">>"); -while (! stream.EOF) -{ - Console.Write (stream.Char); - stream.Next(); -} -Console.Write("<<"); -// */ - - System.Text.StringBuilder builder = new System.Text.StringBuilder (); - while (! stream.EOF) - { - builder.Append (stream.Char); - stream.Next (true); - } - content = builder.ToString (); - } - - // String between double quotes - if (stream.Char == '\"') - content = ParseDoubleQuoted (stream); - - // Single quoted string - else if (stream.Char == '\'') - content = ParseSingleQuoted (stream); - - // String without quotes - else - content = ParseUnQuoted (stream); - } - - /// - /// Parses a String surrounded with single quotes - /// - private string ParseSingleQuoted (ParseStream stream) - { - System.Text.StringBuilder builder = new System.Text.StringBuilder (); - - // Start literal parsing - stream.StartLiteral (); - - // Skip ''' - stream.Next (true); - - while (! stream.EOF) - { - if (stream.Char == '\'') - { - stream.Next (); - - // Escaped single quote - if (stream.Char == '\'') - builder.Append (stream.Char); - - // End of string - else - break; - } - else - builder.Append (stream.Char); - - stream.Next (); - - // Skip \' - if (stream.EOF) - { - stream.StopLiteral (); - throw new ParseException (stream, - "Single quoted string not closed"); - } - } - - // Stop literal parsing - stream.StopLiteral (); - - return builder.ToString(); - } - - /// - /// Parses a String surrounded with double quotes - /// - private string ParseDoubleQuoted(ParseStream stream) - { - System.Text.StringBuilder builder = new System.Text.StringBuilder (); - - // Skip '"' - stream.Next (); - - // Stop at " - stream.StopAt (new char [] {'\"'} ); - - while (! stream.EOF) - { - if (stream.Char == '\n') - { - builder.Append (' '); - stream.Next (); - } - else - builder.Append (NextUnescapedChar (stream)); - } - - // Don't stop at " - stream.DontStop (); - - // Skip '"' - if (stream.Char != '\"') - throw new ParseException (stream, - "Double quoted string not closed"); - else - stream.Next (true); - - return builder.ToString(); - } - - /// - /// Parses a String surrounded without nothing - /// - private string ParseUnQuoted(ParseStream stream) - { - System.Text.StringBuilder builder = new System.Text.StringBuilder (); - - while (! stream.EOF) - builder.Append (NextUnescapedChar (stream)); - - // Trimming left - int count = 0; - while (count < builder.Length && - (builder [count] == ' ' || builder [count] == '\t')) - count ++; - - if (count >= 0) - builder.Remove (0, count); - - // Trimming right - count = 0; - while (count < builder.Length && - (builder [builder.Length - count - 1] == ' ' || - builder [builder.Length - count - 1] == '\t')) - count ++; - - if (count >= 0) - builder.Remove (builder.Length - count, count); - - return builder.ToString(); - } - - /// - /// Reads a character from the stream, unescapes it, - /// and moves to the next character. - /// - private char NextUnescapedChar (ParseStream stream) - { - char c = stream.Char; - - // If escaped - if (c == '\\') - { - // Never stop, every special character - // looses its meaning behind a backslash. - stream.StopAt (new Char [] { }); - - stream.Next (true); - c = stream.Char; - - // ASCII null - if (c == '0') c = '\0'; - - // ASCII bell - else if (c == 'a') c = (char) 0x7; - - // ASCII backspace - else if (c == 'b') c = (char) 0x8; - - // ASCII horizontal tab - else if (c == 't') c = (char) 0x9; - - // ASCII newline - else if (c == 'n') c = (char) 0xA; - - // ASCII vertical tab - else if (c == 'v') c = (char) 0xB; - - // ASCII form feed - else if (c == 'f') c = (char) 0xC; - - // ASCII carriage return - else if (c == 'r') c = (char) 0xD; - - // ASCII escape - else if (c == 'e') c = (char) 0x1D; - - // Unicode next line - else if (c == 'N') c = (char) 0x85; - - // Unicode non breaking space - else if (c == '_') c = (char) 0xA0; - - // TODO larger unicode characters - - // Unicode line separator - // else if (c == 'L') c = (char) 0x20282028; - - // 8 bit hexadecimal - else if (c == 'x') - { - int c_int = (char) 0; - - for (int i = 0; i < 2; i ++) - { - c_int *= 16; - - stream.Next (); - char d = stream.Char; - - if (d >= '0' && d <= '9') - c_int += d - '0'; - - else if (d >= 'a' && d <= 'f') - c_int += d - 'a'; - - else if (d >= 'A' && d <= 'F') - c_int += d - 'A'; - else - { - stream.DontStop (); - throw new ParseException (stream, - "Invalid escape sequence"); - } - } - c = (char) c_int; - } - - stream.Next (true); - - // Restore last stop settings - stream.DontStop (); - } - else - stream.Next (true); - - return c; - } - - /// Content property - public string Content - { - get { return content; } - set { content = value; } - } - - /// To String - public override string ToString () - { - return "[STRING]" + content + "[/STRING]"; - } - - /// Write - protected internal override void Write (WriteStream stream) - { - // TODO, not required, but writing to block or folded scalars - // generates a little more neat code. - - // Analyze string - bool multiline = false; - bool mustbequoted = false; - - for (int i = 0; i < content.Length; i ++) - { - char c = content [i]; - - if (c == '\n') - multiline = true; - - // We quote everything except strings like /[a-zA-Z]*/ - // However there are more strings which don't require - // quotes. - if ( ! ( c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) - mustbequoted = true; - } - - // Double quoted strings - if (mustbequoted) - { - stream.Append ("\""); - - for (int i = 0; i < content.Length; i ++) - { - char c = content [i]; - - // Backslash - if (c == '\\') stream.Append ("\\" + "\\"); - - // Double quote - else if (c == '\"') stream.Append ("\\" + "\""); - - // Single quote - else if (c == '\'') stream.Append ("\\" + "\'"); - - // ASCII null - else if (c == '\0') stream.Append ("\\0"); - - // ASCII bell - else if (c == (char) 0x7) stream.Append ("\\a"); - - // ASCII backspace - else if (c == (char) 0x8) stream.Append ("\\b"); - - // ASCII horizontal tab - else if (c == (char) 0x9) stream.Append ("\\t"); - - // ASCII newline - else if (c == (char) 0xA) stream.Append ("\\n"); - - // ASCII vertical tab - else if (c == (char) 0xB) stream.Append ("\\v"); - - // ASCII form feed - else if (c == (char) 0xC) stream.Append ("\\f"); - - // ASCII carriage return - else if (c == (char) 0xD) stream.Append ("\\r"); - - // ASCII escape - else if (c == (char) 0x1D) stream.Append ("\\e"); - - // Unicode next line - else if (c == (char) 0x85) stream.Append ("\\N"); - - // Unicode non breaking space - else if (c == (char) 0xA0) stream.Append ("\\_"); - - // TODO larger unicode characters - - else - stream.Append ("" + c); - } - stream.Append ("\""); - } - - // Simple non-quoted strings - else - stream.Append (content); - } - } -} diff --git a/thirdparty/yaml/Timestamp.cs b/thirdparty/yaml/Timestamp.cs deleted file mode 100644 index d8dc3f8e6f..0000000000 --- a/thirdparty/yaml/Timestamp.cs +++ /dev/null @@ -1,356 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -using System; - -namespace Yaml -{ - /// - /// Yaml Timestamp node - /// uri: tag:yaml.org,2002:timestamp - /// - public class Timestamp : Scalar - { - private System.DateTime content; - - /// - /// Represents the offset from the UTC time in hours - /// - /// - /// We use this extra variable for compatibility with Mono - /// and .NET 1.0. .NET 2.0 has an extra property for - /// System.Datetime for the timezone. - /// - private double timezone = 0; - - /// - /// Basic constructor that takes a given datetime - /// - /// A .NET 1.0 datetime - public Timestamp (DateTime datetime) : - base ("tag:yaml.org,2002:timestamp", NodeType.Timestamp) - { - this.content = datetime; - this.timezone = 0; - } - - /// - /// Basic constructor, that also gives the posibility to set a timezone - /// - /// A .NET 1.0 datetime - /// The offset, in hours,r to UTC that determine the timezone - public Timestamp (DateTime datetime, double timezone) : - base ("tag:yaml.org,2002:timestamp", NodeType.Timestamp) - { - this.content = datetime; - this.timezone = timezone; - } - - /// Content property - public System.DateTime Content - { - get { return content; } - set { content = value; } - } - - /// Timezone, an offset in hours - public double Timezone - { - get { return timezone; } - set { timezone = value; } - } - - /// To String - public override string ToString () - { - return "[TIMESTAMP]" + YamlString () + "[/TIMESTAMP]"; - } - - /// Parse a DateTime - public Timestamp (ParseStream stream) : - base ("tag:yaml.org,2002:timestamp", NodeType.Timestamp) - { - int year = 0; - int month = 0; - int day = 0; - int hour = 0; - int minutes = 0; - int seconds = 0; - int ms = 0; - - try - { - // Parse year - year = ParseNumber (stream, 4); - SkipChar (stream, '-'); - - // Parse month - month = ParseNumber (stream, 2); - SkipChar (stream, '-'); - - // Parse day - day = ParseNumber (stream, 2); - - // Additional, the time - if ( ! stream.EOF) - ParseTime (stream, out hour, out minutes, out seconds); - - // Additional, milliseconds - if ( ! stream.EOF) - ms = ParseMilliSeconds (stream); - - // Additional, the timezone - if ( ! stream.EOF) - timezone = ParseTimezone (stream); - - // If there is more, then a format exception - if ( ! stream.EOF) - throw new Exception ("More data then excepted"); - - content = new DateTime (year, month, day, hour, minutes, seconds, ms); - } - catch (Exception ex) - { - throw new ParseException (stream, ex.ToString ()); - } - } - - /// - /// Parse the time (hours, minutes, seconds) - /// - private void ParseTime (ParseStream stream, - out int hour, out int minutes, out int seconds) - { - if (stream.Char == 't' || stream.Char == 'T') - stream.Next (true); - else - SkipWhitespace (stream); - - // Parse hour - // Note: A hour can be represented by one or two digits. - string hulp = ""; - while (stream.Char >= '0' && stream.Char <= '9' && - ! stream.EOF && hulp.Length <= 2) - { - hulp += stream.Char; - stream.Next (true); - } - hour = Int32.Parse (hulp); - - SkipChar (stream, ':'); - - // Parse minutes - minutes = ParseNumber (stream, 2); - SkipChar (stream, ':'); - - // Parse seconds - seconds = ParseNumber (stream, 2); - } - - /// - /// Parse the milliseconds - /// - private int ParseMilliSeconds (ParseStream stream) - { - int ms = 0; - - // Look for fraction - if (stream.Char == '.') - { - stream.Next (true); - - // Parse fraction, can consists of an - // unlimited sequence of numbers, we only - // look to the first three (max 1000) - int count = 0; - - while (stream.Char >= '0' && stream.Char <= '9' && - count < 3 && ! stream.EOF) - { - ms *= 10; - ms += stream.Char - '0'; - - stream.Next (true); - count ++; - } - - if (count == 1) ms *= 100; - if (count == 2) ms *= 10; - if (count == 3) ms *= 1; - - // Ignore the rest - while (stream.Char >= '0' && stream.Char <= '9' && - ! stream.EOF) - stream.Next (true); - } - return ms; - } - - /// - /// Parse the time zone - /// - private double ParseTimezone (ParseStream stream) - { - double timezone = 0; - - SkipWhitespace (stream); - - // Timezone = UTC, use by default 0 - if (stream.Char == 'Z') - stream.Next (true); - else - { - // Find the sign of the offset - int sign = 0; - - if (stream.Char == '-') - sign = -1; - - else if (stream.Char == '+') - sign = +1; - - else - throw new Exception ("Invalid time zone: " + - "unexpected character"); - - // Read next char and test for more chars - stream.Next (true); - if (stream.EOF) - throw new Exception ("Invalid time zone"); - - // Parse hour offset - // Note: A hour can be represented by one or two digits. - string hulp = ""; - while (stream.Char >= '0' && - stream.Char <= '9' && - !stream.EOF && hulp.Length <= 2) - { - hulp += (stream.Char); - stream.Next (true); - } - timezone = sign * Double.Parse (hulp); - - // Parse the minutes of the timezone - // when there is still more to parse - if ( ! stream.EOF) - { - SkipChar (stream, ':'); - int temp = ParseNumber (stream, 2); - - timezone += (temp / 60.0); - } - } - - return timezone; - } - - /// - /// Parse an integer - /// - /// - /// The number of characters that the integer is expected to be. - /// - /// The stream that will be parsed - private int ParseNumber (ParseStream stream, int length) - { - System.Text.StringBuilder hulp = new System.Text.StringBuilder (); - - int i; - for (i = 0; i < length && !stream.EOF; i++) - { - hulp.Append (stream.Char); - stream.Next (true); - } - if (i == length) - return Int32.Parse (hulp.ToString ()); - else - throw new Exception ("Can't parse number"); - - } - - /// - /// Skips a specified char, and throws an exception when - /// another char was found. - /// - private void SkipChar (ParseStream stream, char toSkip) - { - if (stream.Char == toSkip) - stream.Next (true); - else - throw new Exception ("Unexpected character"); - } - - /// - /// Skips the spaces * and tabs * in the current stream - /// - private void SkipWhitespace (ParseStream stream) - { - while ((stream.Char == ' ' || stream.Char == '\t') && ! stream.EOF) - stream.Next (true); - } - - /// Yaml notation for this datetime - private string YamlString () - { - string date = content.ToString ("yyyy-MM-ddTHH:mm:ss"); - int ms = content.Millisecond; - if (ms != 0) - { - string hulp = "" + (ms / 1000.0); - hulp = hulp.Substring(2); // Cut of the '0,', first 2 digits - - date += "." + hulp; - } - string zone = ""; - - if (timezone != 0) - { - int timezoneHour = (int) Math.Floor (timezone); - int timezoneMinutes = (int) (60 * (timezone - timezoneHour)); - - // if positif offset add '+', a '-' is default added - if (timezone > 0) - zone = "+"; - - zone += timezoneHour.ToString (); - if (timezoneMinutes != 0) - zone += ":" + timezoneMinutes; - } - else - zone = "Z"; // UTC timezone as default and if offset == 0 - - return date + zone; - } - - /// Write to YAML - protected internal override void Write (WriteStream stream) - { - stream.Append (YamlString ()); - } - } -} - - diff --git a/thirdparty/yaml/WriteStream.cs b/thirdparty/yaml/WriteStream.cs deleted file mode 100644 index 508250d311..0000000000 --- a/thirdparty/yaml/WriteStream.cs +++ /dev/null @@ -1,121 +0,0 @@ -// ==================================================================================================== -// YAML Parser for the .NET Framework -// ==================================================================================================== -// -// Copyright (c) 2006 -// Christophe Lambrechts -// Jonathan Slenders -// -// ==================================================================================================== -// This file is part of the .NET YAML Parser. -// -// This .NET YAML parser is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or -// (at your option) any later version. -// -// The .NET YAML parser is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with Foobar; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USAusing System.Reflection; -// ==================================================================================================== - -#define ENABLE_COMPRESSION - -using System; -using System.Collections; - -using System.IO; - -namespace Yaml -{ - /// - /// Help class for writing a Yaml tree to a string - /// - public class WriteStream - { - private TextWriter stream; - private int indentation = 0; - private bool lastcharisnewline = false; - - private static string indentationChars = " "; - - /// Constructor - public WriteStream (TextWriter stream) - { - this.stream = stream; - } - - /// Append a string - public void Append (string s) - { - // Just add the text to the output stream when - // there is no indentation - if (indentation == 0) - stream.Write (s); - - // Otherwise process each individual char - else - for (int i = 0; i < s.Length; i ++) - { - // Indent after a newline - if (lastcharisnewline) - { - WriteIndentation (); - lastcharisnewline = false; - } - - // Add char - stream.Write (s [i]); - - // Remember newlines - if (s [i] == '\n') - lastcharisnewline = true; - } - } - - /// Indentation - public void Indent () - { - // Increase indentation level - indentation ++; - - // Add a newline -#if ENABLE_COMPRESSION - lastcharisnewline = false; -#else - stream.Write ("\n"); - lastcharisnewline = true; -#endif - } - - /// Write the indentation to the output stream - private void WriteIndentation () - { - for (int i = 0; i < indentation; i ++) - stream.Write (indentationChars); - } - - /// Unindent - public void UnIndent () - { - if (indentation > 0) - { - // Decrease indentation level - indentation --; - - // Add a newline - if (! lastcharisnewline) - stream.Write ("\n"); - lastcharisnewline = true; - } - else - throw new Exception ("Cannot unindent a not indented writestream."); - - } - } -} diff --git a/thirdparty/yaml/Yaml.csproj b/thirdparty/yaml/Yaml.csproj deleted file mode 100644 index ee12932481..0000000000 --- a/thirdparty/yaml/Yaml.csproj +++ /dev/null @@ -1,188 +0,0 @@ - - - Local - 9.0.30729 - 2.0 - {D4424F4D-7939-4247-98F5-6A7F6DEBA7C9} - Debug - AnyCPU - - - - - Yaml - - - JScript - Grid - IE50 - false - Library - Yaml - OnBuildSuccess - - - - - 0.0 - - - v3.5 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - bin\Debug\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - .\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - 3.5 - - - System.Data - - - System.XML - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - False - .NET Framework Client Profile - false - - - False - .NET Framework 2.0 %28x86%29 - true - - - False - .NET Framework 3.0 %28x86%29 - false - - - False - .NET Framework 3.5 - false - - - False - .NET Framework 3.5 SP1 - false - - - - - - - - - - \ No newline at end of file diff --git a/thirdparty/yaml/Yaml.sln b/thirdparty/yaml/Yaml.sln deleted file mode 100644 index a451a53232..0000000000 --- a/thirdparty/yaml/Yaml.sln +++ /dev/null @@ -1,19 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yaml", "Yaml.csproj", "{D4424F4D-7939-4247-98F5-6A7F6DEBA7C9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D4424F4D-7939-4247-98F5-6A7F6DEBA7C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4424F4D-7939-4247-98F5-6A7F6DEBA7C9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4424F4D-7939-4247-98F5-6A7F6DEBA7C9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4424F4D-7939-4247-98F5-6A7F6DEBA7C9}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/thirdparty/yaml/test.yaml b/thirdparty/yaml/test.yaml deleted file mode 100644 index 0271bb757e..0000000000 --- a/thirdparty/yaml/test.yaml +++ /dev/null @@ -1,24 +0,0 @@ -? boolean: y -? float: 8.6e2 -? integer: 174832 -? null: ~ -? inline sequence: [item1, item2] -? inline mappings: {key: value, key2: value2} -? sequence: - - item 1 - - item 2 -? tricky situations: - - ? block scalar: | - regel 1 - regel 2 - - ? folded scalar: > - regel 1 - nog steeds regel 1 - - ? double quoted: "met veel escapes aa\"bb\n\'cc" - - ? met tags: - - !!int 2 - - !!string 2 - - !!float 2 - - { key: value, key 3: "{a: b}", key 2: a } - - ? [aaa]: bbb - - ? single quotes: 'regel 1 regel 2' From da6106520f848ad2c69b09d3c5eba1c3e07a3b5a Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 22:20:43 +1300 Subject: [PATCH 07/83] more conversion --- RulesConverter/Program.cs | 17 ++++++ out.rul | 109 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index a94f312403..f9272a3fbe 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -127,6 +127,23 @@ namespace RulesConverter { "LimitedAmmo", new PL { { "Ammo", "Ammo" } } }, + + { "Building", new PL { + { "Power", "Power" }, + { "RequiresPower", "Powered" }, + { "Footprint", "Footprint" }, + { "@Dimensions", "Dimensions" } } + }, + + { "StoresOre", new PL { + { "Pips", "OrePips" }, + { "Capacity", "Storage" } } + }, + + { "Harvester", new PL { + { "Pips", "OrePips" } } + //{ "Capacity" + }, }; using (var writer = File.CreateText(outputFile)) diff --git a/out.rul b/out.rul index c165256316..3da3c2cc4a 100644 --- a/out.rul +++ b/out.rul @@ -659,6 +659,10 @@ IRON: Selectable: Priority: 3 Building: + Power: -200 + RequiresPower: true + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: IronCurtainable: IronCurtain: @@ -676,6 +680,10 @@ PDOX: Selectable: Priority: 3 Building: + Power: -200 + RequiresPower: true + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: Chronosphere: IronCurtainable: @@ -693,6 +701,9 @@ PBOX: Selectable: Priority: 3 Building: + Power: -15 + Footprint: x + Dimensions: [1,1] Turreted: RenderBuilding: AttackTurreted: @@ -712,6 +723,9 @@ HBOX: Selectable: Priority: 3 Building: + Power: -15 + Footprint: x + Dimensions: [1,1] Turreted: RenderBuilding: AttackTurreted: @@ -731,6 +745,10 @@ TSLA: Selectable: Priority: 3 Building: + Power: -150 + RequiresPower: true + Footprint: _ x + Dimensions: [1,2] Turreted: RenderBuildingCharge: AttackTurreted: @@ -750,6 +768,9 @@ GUN: Selectable: Priority: 3 Building: + Power: -40 + Footprint: x + Dimensions: [1,1] Turreted: RenderBuildingTurreted: AttackTurreted: @@ -769,6 +790,10 @@ AGUN: Selectable: Priority: 3 Building: + Power: -50 + RequiresPower: true + Footprint: _ x + Dimensions: [1,2] Turreted: RenderBuildingTurreted: AttackTurreted: @@ -789,6 +814,9 @@ FTUR: Priority: 3 Turreted: Building: + Power: -20 + Footprint: x + Dimensions: [1,1] RenderBuilding: AttackTurreted: AutoTarget: @@ -807,6 +835,10 @@ GAP: Selectable: Priority: 3 Building: + Power: -60 + RequiresPower: true + Footprint: _ x + Dimensions: [1,2] RenderBuilding: IronCurtainable: @@ -823,6 +855,9 @@ SAM: Selectable: Priority: 3 Building: + Power: -20 + Footprint: xx + Dimensions: [2,1] Turreted: RenderBuildingTurreted: AttackTurreted: @@ -842,6 +877,9 @@ MSLO: Selectable: Priority: 3 Building: + Power: -100 + Footprint: xx + Dimensions: [2,1] RenderBuilding: IronCurtainable: @@ -858,6 +896,9 @@ ATEK: Selectable: Priority: 3 Building: + Power: -200 + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: IronCurtainable: GpsLaunchSite: @@ -875,6 +916,9 @@ WEAP: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx + Dimensions: [3,2] RenderWarFactory: RenderBuilding: RallyPoint: @@ -894,6 +938,9 @@ SYRD: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx xxx + Dimensions: [3,3] RenderBuilding: ProductionSurround: IronCurtainable: @@ -911,6 +958,9 @@ SPEN: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx xxx + Dimensions: [3,3] RenderBuilding: ProductionSurround: IronCurtainable: @@ -920,6 +970,9 @@ FACT: Selectable: Priority: 3 Building: + Power: 0 + Footprint: xxx xxx xxx + Dimensions: [3,3] RenderBuilding: ConstructionYard: IronCurtainable: @@ -937,9 +990,14 @@ PROC: Selectable: Priority: 3 Building: + Power: -30 + Footprint: _x_ xxx x== + Dimensions: [3,3] RenderBuilding: AcceptsOre: StoresOre: + Pips: 17 + Capacity: 2000 IronCurtainable: SILO: @@ -955,8 +1013,13 @@ SILO: Selectable: Priority: 3 Building: + Power: -10 + Footprint: x + Dimensions: [1,1] RenderBuildingOre: StoresOre: + Pips: 5 + Capacity: 1500 IronCurtainable: HPAD: @@ -972,6 +1035,9 @@ HPAD: Selectable: Priority: 3 Building: + Power: -10 + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: Production: BelowUnits: @@ -991,6 +1057,10 @@ DOME: Selectable: Priority: 3 Building: + Power: -40 + RequiresPower: true + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: ProvidesRadar: IronCurtainable: @@ -1008,6 +1078,9 @@ AFLD: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx + Dimensions: [3,2] RenderBuilding: Production: BelowUnits: @@ -1027,6 +1100,9 @@ POWR: Selectable: Priority: 3 Building: + Power: 100 + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: IronCurtainable: @@ -1043,6 +1119,9 @@ APWR: Selectable: Priority: 3 Building: + Power: 200 + Footprint: ___ xxx xxx + Dimensions: [3,3] RenderBuilding: IronCurtainable: @@ -1059,6 +1138,9 @@ STEK: Selectable: Priority: 3 Building: + Power: -100 + Footprint: xxx xxx + Dimensions: [3,2] RenderBuilding: IronCurtainable: @@ -1075,6 +1157,9 @@ BARR: Selectable: Priority: 3 Building: + Power: -20 + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: RallyPoint: Production: @@ -1093,6 +1178,9 @@ TENT: Selectable: Priority: 3 Building: + Power: -20 + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: RallyPoint: Production: @@ -1111,6 +1199,9 @@ KENN: Selectable: Priority: 3 Building: + Power: -10 + Footprint: x + Dimensions: [1,1] RenderBuilding: RallyPoint: Production: @@ -1129,6 +1220,9 @@ FIX: Selectable: Priority: 3 Building: + Power: -30 + Footprint: _x_ xxx _x_ + Dimensions: [3,3] RenderBuilding: BelowUnits: Reservable: @@ -1146,6 +1240,9 @@ FACF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx xxx + Dimensions: [3,3] RenderBuilding: Image: FACT Fake: @@ -1164,6 +1261,9 @@ WEAF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx + Dimensions: [3,2] RenderWarFactory: RenderBuilding: Image: WEAP @@ -1183,6 +1283,9 @@ SYRF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx xxx + Dimensions: [3,3] RenderBuilding: Image: SYRD Fake: @@ -1192,6 +1295,9 @@ SPEF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx xxx + Dimensions: [3,3] RenderBuilding: Image: SPEN Fake: @@ -1209,6 +1315,9 @@ DOMF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xx xx + Dimensions: [2,2] RenderBuilding: Image: DOME Fake: From e2b90e06ce7fdc9d2f3763b86de52e91a2908b2f Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 22:36:03 +1300 Subject: [PATCH 08/83] attack trait support --- RulesConverter/Program.cs | 78 +++++++++++++---------------- out.rul | 101 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 44 deletions(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index f9272a3fbe..baa1187620 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -69,46 +69,6 @@ namespace RulesConverter { "Image", "Image" } } }, - { "RenderUnit", new PL { - { "Image", "Image" } } - }, - - { "RenderBuildingCharge", new PL { - { "Image", "Image" } } - }, - - { "RenderBuildingOre", new PL { - { "Image", "Image" } } - }, - - { "RenderBuildingTurreted", new PL { - { "Image", "Image" } } - }, - - { "RenderInfantry", new PL { - { "Image", "Image" } } - }, - - { "RenderUnitMuzzleFlash", new PL { - { "Image", "Image" } } - }, - - { "RenderUnitReload", new PL { - { "Image", "Image" } } - }, - - { "RenderUnitRotor", new PL { - { "Image", "Image" } } - }, - - { "RenderUnitSpinner", new PL { - { "Image", "Image" } } - }, - - { "RenderUnitTurreted", new PL { - { "Image", "Image" } } - }, - { "Buildable", new PL { { "TechLevel", "TechLevel" }, { "Tab", "$Tab" }, @@ -121,7 +81,8 @@ namespace RulesConverter }, { "Cargo", new PL { - { "@PassengerTypes", "PassengerTypes" } } + { "@PassengerTypes", "PassengerTypes" }, + { "UnloadFacing", "UnloadFacing" } } }, { "LimitedAmmo", new PL { @@ -132,7 +93,12 @@ namespace RulesConverter { "Power", "Power" }, { "RequiresPower", "Powered" }, { "Footprint", "Footprint" }, - { "@Dimensions", "Dimensions" } } + { "@Dimensions", "Dimensions" }, + { "Capturable", "Capturable" }, + { "Repairable", "Repairable" }, + { "BaseNormal", "BaseNormal" }, + { "Adjacent", "Adjacent" }, + { "Bib", "Bib" } } }, { "StoresOre", new PL { @@ -144,8 +110,34 @@ namespace RulesConverter { "Pips", "OrePips" } } //{ "Capacity" }, + + { "AttackBase", new PL { + { "PrimaryWeapon", "Primary" }, + { "SecondaryWeapon", "SecondaryWeapon" }, + { "PrimaryOffset", "PrimaryOffset" }, + { "SecondaryOffset", "SecondaryOffset" }, + { "PrimaryLocalOffset", "PrimaryLocalOffset" }, + { "SecondaryLocalOffset", "SecondaryLocalOffset" }, + { "MuzzleFlash", "MuzzleFlash" }, // maybe + { "Recoil", "Recoil"} } + }, }; + traitMap["RenderUnit"] = traitMap["RenderBuilding"]; + traitMap["RenderBuildingCharge"] = traitMap["RenderBuilding"]; + traitMap["RenderBuildingOre"] = traitMap["RenderBuilding"]; + traitMap["RenderBuildingTurreted"] = traitMap["RenderBuilding"]; + traitMap["RenderInfantry"] = traitMap["RenderBuilding"]; + traitMap["RenderUnitMuzzleFlash"] = traitMap["RenderBuilding"]; + traitMap["RenderUnitReload"] = traitMap["RenderBuilding"]; + traitMap["RenderUnitRotor"] = traitMap["RenderBuilding"]; + traitMap["RenderUnitSpinner"] = traitMap["RenderBuilding"]; + traitMap["RenderUnitTurreted"] = traitMap["RenderBuilding"]; + + traitMap["AttackTurreted"] = traitMap["AttackBase"]; + traitMap["AttackPlane"] = traitMap["AttackBase"]; + traitMap["AttackHeli"] = traitMap["AttackBase"]; + using (var writer = File.CreateText(outputFile)) { foreach (var cat in categoryMap) @@ -164,8 +156,6 @@ namespace RulesConverter if (iniSection.GetValue("TechLevel", "-1") != "-1") traits.Insert(0, "Buildable"); - - foreach (var t in traits) { writer.WriteLine("\t{0}:", t); diff --git a/out.rul b/out.rul index 3da3c2cc4a..194d66b659 100644 --- a/out.rul +++ b/out.rul @@ -19,6 +19,7 @@ V2RL: ROT: 5 Speed: 7 AttackBase: + PrimaryWeapon: SCUD RenderUnitReload: AutoTarget: Repairable: @@ -48,6 +49,8 @@ V2RL: Speed: 9 Turreted: AttackTurreted: + PrimaryWeapon: 75mm + Recoil: 2 RenderUnitTurreted: AutoTarget: Repairable: @@ -77,6 +80,8 @@ V2RL: Speed: 8 Turreted: AttackTurreted: + PrimaryWeapon: 90mm + Recoil: 3 RenderUnitTurreted: AutoTarget: Repairable: @@ -106,6 +111,8 @@ V2RL: Speed: 7 Turreted: AttackTurreted: + PrimaryWeapon: 105mm + Recoil: 3 RenderUnitTurreted: AutoTarget: Repairable: @@ -135,6 +142,10 @@ V2RL: Speed: 4 Turreted: AttackTurreted: + PrimaryWeapon: 120mm + PrimaryLocalOffset: -4,-5,0,4,-5,0 + SecondaryLocalOffset: -7,2,25,7,2,-25 + Recoil: 4 RenderUnitTurreted: AutoTarget: Repairable: @@ -217,6 +228,7 @@ ARTY: ROT: 2 Speed: 6 AttackBase: + PrimaryWeapon: 155mm RenderUnit: Explodes: AutoTarget: @@ -303,6 +315,9 @@ JEEP: Speed: 10 Turreted: AttackTurreted: + PrimaryWeapon: M60mg + PrimaryOffset: 0,0,0,-2 + MuzzleFlash: yes RenderUnitTurreted: AutoTarget: Repairable: @@ -330,12 +345,16 @@ APC: ROT: 5 Speed: 10 AttackBase: + PrimaryWeapon: M60mg + PrimaryOffset: 0,0,0,-4 + MuzzleFlash: yes RenderUnitMuzzleFlash: AutoTarget: Repairable: Chronoshiftable: Cargo: PassengerTypes: [Foot] + UnloadFacing: 220 Passenger: IronCurtainable: @@ -424,6 +443,7 @@ SS: RenderUnit: Submarine: AttackBase: + PrimaryWeapon: TorpTube Chronoshiftable: IronCurtainable: @@ -447,6 +467,8 @@ DD: Speed: 6 Turreted: AttackTurreted: + PrimaryWeapon: Stinger + PrimaryOffset: 0,-8,0,-3 RenderUnitTurreted: AutoTarget: Chronoshiftable: @@ -472,6 +494,10 @@ CA: Speed: 4 Turreted: AttackTurreted: + PrimaryWeapon: 8Inch + PrimaryOffset: 0,17,0,-2 + SecondaryOffset: 0,-17,0,-2 + Recoil: 3 RenderUnitTurreted: AutoTarget: Chronoshiftable: @@ -519,6 +545,8 @@ PT: Speed: 9 Turreted: AttackTurreted: + PrimaryWeapon: 2Inch + PrimaryOffset: 0,-6,0,-1 RenderUnitTurreted: AutoTarget: Chronoshiftable: @@ -539,6 +567,7 @@ MIG: HP: 50 Armor: light AttackPlane: + PrimaryWeapon: Maverick Plane: ROT: 5 Speed: 20 @@ -564,6 +593,7 @@ YAK: Armor: light Crewed: yes AttackPlane: + PrimaryWeapon: ChainGun Plane: ROT: 5 Speed: 16 @@ -612,6 +642,9 @@ HELI: Armor: heavy Crewed: yes AttackHeli: + PrimaryWeapon: Hellfire + PrimaryOffset: -5,0,0,2 + SecondaryOffset: 5,0,0,2 Helicopter: ROT: 4 Speed: 16 @@ -637,6 +670,9 @@ HIND: Armor: heavy Crewed: yes AttackHeli: + PrimaryWeapon: ChainGun + PrimaryOffset: -5,0,0,2 + SecondaryOffset: 5,0,0,2 Helicopter: ROT: 4 Speed: 12 @@ -663,6 +699,7 @@ IRON: RequiresPower: true Footprint: xx xx Dimensions: [2,2] + Capturable: true RenderBuilding: IronCurtainable: IronCurtain: @@ -684,6 +721,7 @@ PDOX: RequiresPower: true Footprint: xx xx Dimensions: [2,2] + Capturable: true RenderBuilding: Chronosphere: IronCurtainable: @@ -707,6 +745,7 @@ PBOX: Turreted: RenderBuilding: AttackTurreted: + PrimaryWeapon: Vulcan AutoTarget: IronCurtainable: @@ -729,6 +768,7 @@ HBOX: Turreted: RenderBuilding: AttackTurreted: + PrimaryWeapon: Vulcan AutoTarget: IronCurtainable: @@ -752,6 +792,7 @@ TSLA: Turreted: RenderBuildingCharge: AttackTurreted: + PrimaryWeapon: TeslaZap AutoTarget: IronCurtainable: @@ -774,6 +815,7 @@ GUN: Turreted: RenderBuildingTurreted: AttackTurreted: + PrimaryWeapon: TurretGun AutoTarget: IronCurtainable: @@ -797,6 +839,7 @@ AGUN: Turreted: RenderBuildingTurreted: AttackTurreted: + PrimaryWeapon: ZSU-23 AutoTarget: IronCurtainable: @@ -819,6 +862,7 @@ FTUR: Dimensions: [1,1] RenderBuilding: AttackTurreted: + PrimaryWeapon: FireballLauncher AutoTarget: IronCurtainable: @@ -839,6 +883,7 @@ GAP: RequiresPower: true Footprint: _ x Dimensions: [1,2] + Capturable: true RenderBuilding: IronCurtainable: @@ -861,6 +906,7 @@ SAM: Turreted: RenderBuildingTurreted: AttackTurreted: + PrimaryWeapon: Nike AutoTarget: IronCurtainable: @@ -899,6 +945,8 @@ ATEK: Power: -200 Footprint: xx xx Dimensions: [2,2] + Capturable: true + Bib: yes RenderBuilding: IronCurtainable: GpsLaunchSite: @@ -919,6 +967,8 @@ WEAP: Power: -30 Footprint: xxx xxx Dimensions: [3,2] + Capturable: true + Bib: yes RenderWarFactory: RenderBuilding: RallyPoint: @@ -941,6 +991,9 @@ SYRD: Power: -30 Footprint: xxx xxx xxx Dimensions: [3,3] + Capturable: true + BaseNormal: no + Adjacent: 8 RenderBuilding: ProductionSurround: IronCurtainable: @@ -961,6 +1014,9 @@ SPEN: Power: -30 Footprint: xxx xxx xxx Dimensions: [3,3] + Capturable: true + BaseNormal: no + Adjacent: 8 RenderBuilding: ProductionSurround: IronCurtainable: @@ -973,6 +1029,8 @@ FACT: Power: 0 Footprint: xxx xxx xxx Dimensions: [3,3] + Capturable: true + Bib: yes RenderBuilding: ConstructionYard: IronCurtainable: @@ -993,6 +1051,8 @@ PROC: Power: -30 Footprint: _x_ xxx x== Dimensions: [3,3] + Capturable: true + Bib: yes RenderBuilding: AcceptsOre: StoresOre: @@ -1016,6 +1076,7 @@ SILO: Power: -10 Footprint: x Dimensions: [1,1] + Capturable: true RenderBuildingOre: StoresOre: Pips: 5 @@ -1038,6 +1099,8 @@ HPAD: Power: -10 Footprint: xx xx Dimensions: [2,2] + Capturable: true + Bib: yes RenderBuilding: Production: BelowUnits: @@ -1061,6 +1124,8 @@ DOME: RequiresPower: true Footprint: xx xx Dimensions: [2,2] + Capturable: true + Bib: yes RenderBuilding: ProvidesRadar: IronCurtainable: @@ -1081,6 +1146,7 @@ AFLD: Power: -30 Footprint: xxx xxx Dimensions: [3,2] + Capturable: true RenderBuilding: Production: BelowUnits: @@ -1103,6 +1169,8 @@ POWR: Power: 100 Footprint: xx xx Dimensions: [2,2] + Capturable: true + Bib: yes RenderBuilding: IronCurtainable: @@ -1122,6 +1190,8 @@ APWR: Power: 200 Footprint: ___ xxx xxx Dimensions: [3,3] + Capturable: true + Bib: yes RenderBuilding: IronCurtainable: @@ -1141,6 +1211,8 @@ STEK: Power: -100 Footprint: xxx xxx Dimensions: [3,2] + Capturable: true + Bib: yes RenderBuilding: IronCurtainable: @@ -1160,6 +1232,8 @@ BARR: Power: -20 Footprint: xx xx Dimensions: [2,2] + Capturable: true + Bib: yes RenderBuilding: RallyPoint: Production: @@ -1181,6 +1255,8 @@ TENT: Power: -20 Footprint: xx xx Dimensions: [2,2] + Capturable: true + Bib: yes RenderBuilding: RallyPoint: Production: @@ -1223,6 +1299,7 @@ FIX: Power: -30 Footprint: _x_ xxx _x_ Dimensions: [3,3] + Capturable: true RenderBuilding: BelowUnits: Reservable: @@ -1243,6 +1320,9 @@ FACF: Power: -2 Footprint: xxx xxx xxx Dimensions: [3,3] + Capturable: true + BaseNormal: no + Bib: yes RenderBuilding: Image: FACT Fake: @@ -1264,6 +1344,9 @@ WEAF: Power: -2 Footprint: xxx xxx Dimensions: [3,2] + Capturable: true + BaseNormal: no + Bib: yes RenderWarFactory: RenderBuilding: Image: WEAP @@ -1286,6 +1369,9 @@ SYRF: Power: -2 Footprint: xxx xxx xxx Dimensions: [3,3] + Capturable: true + BaseNormal: no + Adjacent: 8 RenderBuilding: Image: SYRD Fake: @@ -1298,6 +1384,9 @@ SPEF: Power: -2 Footprint: xxx xxx xxx Dimensions: [3,3] + Capturable: true + BaseNormal: no + Adjacent: 8 RenderBuilding: Image: SPEN Fake: @@ -1318,6 +1407,9 @@ DOMF: Power: -2 Footprint: xx xx Dimensions: [2,2] + Capturable: true + BaseNormal: no + Bib: yes RenderBuilding: Image: DOME Fake: @@ -1381,6 +1473,7 @@ E1: Speed: 4 RenderInfantry: AttackBase: + PrimaryWeapon: M1Carbine TakeCover: SquishByTank: AutoTarget: @@ -1405,6 +1498,8 @@ E2: Speed: 5 RenderInfantry: AttackBase: + PrimaryWeapon: Grenade + PrimaryOffset: 0,0,0,-13 TakeCover: SquishByTank: AutoTarget: @@ -1429,6 +1524,8 @@ E3: Speed: 3 RenderInfantry: AttackBase: + PrimaryWeapon: RedEye + PrimaryOffset: 0,0,0,-13 TakeCover: SquishByTank: AutoTarget: @@ -1454,6 +1551,8 @@ E4: Speed: 3 RenderInfantry: AttackBase: + PrimaryWeapon: Flamer + PrimaryOffset: 0,0,0,-7 TakeCover: SquishByTank: AutoTarget: @@ -1554,6 +1653,7 @@ E7: RenderInfantry: C4Demolition: AttackBase: + PrimaryWeapon: Colt45 TakeCover: SquishByTank: AutoTarget: @@ -1580,6 +1680,7 @@ MEDI: RenderInfantry: AutoHeal: AttackBase: + PrimaryWeapon: Heal TakeCover: SquishByTank: Passenger: From a2b0a2362683c67cdaba832ffa046f731e729ffa Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 22:38:32 +1300 Subject: [PATCH 09/83] removing [] from .rul output as per ytinasni's request --- RulesConverter/Program.cs | 2 +- out.rul | 208 +++++++++++++++++++------------------- 2 files changed, 105 insertions(+), 105 deletions(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index baa1187620..cb1089223b 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -166,7 +166,7 @@ namespace RulesConverter var v = kv.Value == "$Tab" ? cat.Value.Second : iniSection.GetValue(kv.Value, ""); var fmt = "\t\t{0}: {1}"; var k = kv.Key; - if (k.StartsWith("@")) { k = k.Substring(1); fmt = "\t\t{0}: [{1}]"; } + if (k.StartsWith("@")) { k = k.Substring(1); /*fmt = "\t\t{0}: [{1}]";*/ } if (k.StartsWith("$")) { k = k.Substring(1); fmt = "\t\t{0}: \"{1}\""; } if (!string.IsNullOrEmpty(v)) writer.WriteLine(fmt, k, v); diff --git a/out.rul b/out.rul index 194d66b659..7b4d216bf0 100644 --- a/out.rul +++ b/out.rul @@ -3,7 +3,7 @@ V2RL: Buildable: TechLevel: 4 Tab: Vehicle - Prerequisites: [weap,dome] + Prerequisites: weap,dome Owner: soviet Cost: 700 Description: "V2 Rocket" @@ -32,7 +32,7 @@ V2RL: Buildable: TechLevel: 4 Tab: Vehicle - Prerequisites: [weap] + Prerequisites: weap Owner: allies Cost: 700 Description: "Light Tank" @@ -63,7 +63,7 @@ V2RL: Buildable: TechLevel: 6 Tab: Vehicle - Prerequisites: [weap] + Prerequisites: weap Owner: allies Cost: 800 Description: "Medium Tank" @@ -94,7 +94,7 @@ V2RL: Buildable: TechLevel: 4 Tab: Vehicle - Prerequisites: [weap] + Prerequisites: weap Owner: soviet Cost: 950 Description: "Heavy Tank" @@ -125,7 +125,7 @@ V2RL: Buildable: TechLevel: 10 Tab: Vehicle - Prerequisites: [weap,stek] + Prerequisites: weap,stek Owner: soviet Cost: 1700 Description: "Mammoth Tank" @@ -158,7 +158,7 @@ MRJ: Buildable: TechLevel: 12 Tab: Vehicle - Prerequisites: [weap,dome] + Prerequisites: weap,dome Owner: allies Cost: 600 Description: "Radar Jammer" @@ -185,7 +185,7 @@ MGG: Buildable: TechLevel: 11 Tab: Vehicle - Prerequisites: [weap,atek] + Prerequisites: weap,atek Owner: allies Cost: 600 Description: "Mobile Gap Generator" @@ -212,7 +212,7 @@ ARTY: Buildable: TechLevel: 8 Tab: Vehicle - Prerequisites: [weap] + Prerequisites: weap Owner: allies Cost: 600 Description: "Artillery" @@ -242,7 +242,7 @@ HARV: Buildable: TechLevel: 1 Tab: Vehicle - Prerequisites: [weap,proc] + Prerequisites: weap,proc Owner: allies,soviet Cost: 1400 Description: "Ore Truck" @@ -270,7 +270,7 @@ MCV: Buildable: TechLevel: 11 Tab: Vehicle - Prerequisites: [weap,fix] + Prerequisites: weap,fix Owner: allies,soviet Cost: 2500 Description: "Mobile Construction Vehicle" @@ -298,7 +298,7 @@ JEEP: Buildable: TechLevel: 3 Tab: Vehicle - Prerequisites: [weap] + Prerequisites: weap Owner: allies Cost: 600 Description: "Ranger" @@ -330,7 +330,7 @@ APC: Buildable: TechLevel: 5 Tab: Vehicle - Prerequisites: [weap,tent] + Prerequisites: weap,tent Owner: allies Cost: 800 Description: "Armored Personnel Carrier" @@ -353,7 +353,7 @@ APC: Repairable: Chronoshiftable: Cargo: - PassengerTypes: [Foot] + PassengerTypes: Foot UnloadFacing: 220 Passenger: IronCurtainable: @@ -363,7 +363,7 @@ MNLY.AP: Buildable: TechLevel: 3 Tab: Vehicle - Prerequisites: [weap,fix] + Prerequisites: weap,fix Owner: soviet Cost: 800 Icon: MNLYICON @@ -395,7 +395,7 @@ MNLY.AT: Buildable: TechLevel: 3 Tab: Vehicle - Prerequisites: [weap,fix] + Prerequisites: weap,fix Owner: allies Cost: 800 Icon: MNLYICON @@ -427,7 +427,7 @@ SS: Buildable: TechLevel: 5 Tab: Ship - Prerequisites: [spen] + Prerequisites: spen Owner: soviet Cost: 950 Description: "Submarine" @@ -452,7 +452,7 @@ DD: Buildable: TechLevel: 7 Tab: Ship - Prerequisites: [syrd] + Prerequisites: syrd Owner: allies Cost: 1000 Description: "Destroyer" @@ -479,7 +479,7 @@ CA: Buildable: TechLevel: 10 Tab: Ship - Prerequisites: [syrd,atek] + Prerequisites: syrd,atek Owner: allies Cost: 2000 Description: "Cruiser" @@ -522,7 +522,7 @@ LST: Speed: 14 RenderUnit: Cargo: - PassengerTypes: [Foot,Wheel,Track] + PassengerTypes: Foot,Wheel,Track IronCurtainable: PT: @@ -530,7 +530,7 @@ PT: Buildable: TechLevel: 5 Tab: Ship - Prerequisites: [syrd] + Prerequisites: syrd Owner: allies Cost: 500 Description: "Gunboat" @@ -557,7 +557,7 @@ MIG: Buildable: TechLevel: 10 Tab: Plane - Prerequisites: [afld] + Prerequisites: afld Owner: soviet Cost: 1200 Description: "Mig Attack Plane" @@ -582,7 +582,7 @@ YAK: Buildable: TechLevel: 5 Tab: Plane - Prerequisites: [afld] + Prerequisites: afld Owner: soviet Cost: 800 Description: "Yak Attack Plane" @@ -608,7 +608,7 @@ TRAN: Buildable: TechLevel: 11 Tab: Plane - Prerequisites: [hpad] + Prerequisites: hpad Owner: allies Cost: 1200 Description: "Transport Helicopter" @@ -623,7 +623,7 @@ TRAN: RenderUnitRotor: WithShadow: Cargo: - PassengerTypes: [Foot] + PassengerTypes: Foot IronCurtainable: HELI: @@ -631,7 +631,7 @@ HELI: Buildable: TechLevel: 9 Tab: Plane - Prerequisites: [hpad] + Prerequisites: hpad Owner: allies Cost: 1200 Description: "Longbow" @@ -659,7 +659,7 @@ HIND: Buildable: TechLevel: 9 Tab: Plane - Prerequisites: [hpad] + Prerequisites: hpad Owner: allies Cost: 1200 Description: "Hind" @@ -687,7 +687,7 @@ IRON: Buildable: TechLevel: 12 Tab: Defense - Prerequisites: [stek] + Prerequisites: stek Owner: soviet Cost: 2800 Description: "Iron Curtain" @@ -698,7 +698,7 @@ IRON: Power: -200 RequiresPower: true Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true RenderBuilding: IronCurtainable: @@ -709,7 +709,7 @@ PDOX: Buildable: TechLevel: 12 Tab: Defense - Prerequisites: [atek] + Prerequisites: atek Owner: allies Cost: 2800 Description: "Chronosphere" @@ -720,7 +720,7 @@ PDOX: Power: -200 RequiresPower: true Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true RenderBuilding: Chronosphere: @@ -731,7 +731,7 @@ PBOX: Buildable: TechLevel: 2 Tab: Defense - Prerequisites: [tent] + Prerequisites: tent Owner: allies Cost: 400 Description: "Pillbox" @@ -741,7 +741,7 @@ PBOX: Building: Power: -15 Footprint: x - Dimensions: [1,1] + Dimensions: 1,1 Turreted: RenderBuilding: AttackTurreted: @@ -754,7 +754,7 @@ HBOX: Buildable: TechLevel: 3 Tab: Defense - Prerequisites: [tent] + Prerequisites: tent Owner: allies Cost: 600 Description: "Camo Pillbox" @@ -764,7 +764,7 @@ HBOX: Building: Power: -15 Footprint: x - Dimensions: [1,1] + Dimensions: 1,1 Turreted: RenderBuilding: AttackTurreted: @@ -777,7 +777,7 @@ TSLA: Buildable: TechLevel: 7 Tab: Defense - Prerequisites: [weap] + Prerequisites: weap Owner: soviet Cost: 1500 Description: "Tesla Coil" @@ -788,7 +788,7 @@ TSLA: Power: -150 RequiresPower: true Footprint: _ x - Dimensions: [1,2] + Dimensions: 1,2 Turreted: RenderBuildingCharge: AttackTurreted: @@ -801,7 +801,7 @@ GUN: Buildable: TechLevel: 4 Tab: Defense - Prerequisites: [tent] + Prerequisites: tent Owner: allies Cost: 600 Description: "Turret" @@ -811,7 +811,7 @@ GUN: Building: Power: -40 Footprint: x - Dimensions: [1,1] + Dimensions: 1,1 Turreted: RenderBuildingTurreted: AttackTurreted: @@ -824,7 +824,7 @@ AGUN: Buildable: TechLevel: 5 Tab: Defense - Prerequisites: [dome] + Prerequisites: dome Owner: allies Cost: 600 Description: "AA Gun" @@ -835,7 +835,7 @@ AGUN: Power: -50 RequiresPower: true Footprint: _ x - Dimensions: [1,2] + Dimensions: 1,2 Turreted: RenderBuildingTurreted: AttackTurreted: @@ -848,7 +848,7 @@ FTUR: Buildable: TechLevel: 2 Tab: Defense - Prerequisites: [barr] + Prerequisites: barr Owner: soviet Cost: 600 Description: "Flame Turret" @@ -859,7 +859,7 @@ FTUR: Building: Power: -20 Footprint: x - Dimensions: [1,1] + Dimensions: 1,1 RenderBuilding: AttackTurreted: PrimaryWeapon: FireballLauncher @@ -871,7 +871,7 @@ GAP: Buildable: TechLevel: 10 Tab: Defense - Prerequisites: [atek] + Prerequisites: atek Owner: allies Cost: 500 Description: "Gap Generator" @@ -882,7 +882,7 @@ GAP: Power: -60 RequiresPower: true Footprint: _ x - Dimensions: [1,2] + Dimensions: 1,2 Capturable: true RenderBuilding: IronCurtainable: @@ -892,7 +892,7 @@ SAM: Buildable: TechLevel: 9 Tab: Defense - Prerequisites: [dome] + Prerequisites: dome Owner: soviet Cost: 750 Description: "SAM Site" @@ -902,7 +902,7 @@ SAM: Building: Power: -20 Footprint: xx - Dimensions: [2,1] + Dimensions: 2,1 Turreted: RenderBuildingTurreted: AttackTurreted: @@ -915,7 +915,7 @@ MSLO: Buildable: TechLevel: 13 Tab: Defense - Prerequisites: [stek,atek] + Prerequisites: stek,atek Owner: soviet,allies Cost: 2500 Description: "Missile Silo" @@ -925,7 +925,7 @@ MSLO: Building: Power: -100 Footprint: xx - Dimensions: [2,1] + Dimensions: 2,1 RenderBuilding: IronCurtainable: @@ -934,7 +934,7 @@ ATEK: Buildable: TechLevel: 10 Tab: Building - Prerequisites: [weap,dome] + Prerequisites: weap,dome Owner: allies Cost: 1500 Description: "Allied Tech Center" @@ -944,7 +944,7 @@ ATEK: Building: Power: -200 Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true Bib: yes RenderBuilding: @@ -956,7 +956,7 @@ WEAP: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [proc] + Prerequisites: proc Owner: soviet,allies Cost: 2000 Description: "War Factory" @@ -966,7 +966,7 @@ WEAP: Building: Power: -30 Footprint: xxx xxx - Dimensions: [3,2] + Dimensions: 3,2 Capturable: true Bib: yes RenderWarFactory: @@ -980,7 +980,7 @@ SYRD: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: allies Cost: 650 Description: "Shipyard" @@ -990,7 +990,7 @@ SYRD: Building: Power: -30 Footprint: xxx xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true BaseNormal: no Adjacent: 8 @@ -1003,7 +1003,7 @@ SPEN: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: soviet Cost: 650 Description: "Sub Pen" @@ -1013,7 +1013,7 @@ SPEN: Building: Power: -30 Footprint: xxx xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true BaseNormal: no Adjacent: 8 @@ -1028,7 +1028,7 @@ FACT: Building: Power: 0 Footprint: xxx xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true Bib: yes RenderBuilding: @@ -1040,7 +1040,7 @@ PROC: Buildable: TechLevel: 1 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: allies,soviet Cost: 2000 Description: "Ore Refinery" @@ -1050,7 +1050,7 @@ PROC: Building: Power: -30 Footprint: _x_ xxx x== - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true Bib: yes RenderBuilding: @@ -1065,7 +1065,7 @@ SILO: Buildable: TechLevel: 1 Tab: Building - Prerequisites: [proc] + Prerequisites: proc Owner: allies,soviet Cost: 150 Description: "Silo" @@ -1075,7 +1075,7 @@ SILO: Building: Power: -10 Footprint: x - Dimensions: [1,1] + Dimensions: 1,1 Capturable: true RenderBuildingOre: StoresOre: @@ -1088,7 +1088,7 @@ HPAD: Buildable: TechLevel: 9 Tab: Building - Prerequisites: [dome] + Prerequisites: dome Owner: allies Cost: 1500 Description: "Helipad" @@ -1098,7 +1098,7 @@ HPAD: Building: Power: -10 Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true Bib: yes RenderBuilding: @@ -1112,7 +1112,7 @@ DOME: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [proc] + Prerequisites: proc Owner: allies,soviet Cost: 1000 Description: "Radar Dome" @@ -1123,7 +1123,7 @@ DOME: Power: -40 RequiresPower: true Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true Bib: yes RenderBuilding: @@ -1135,7 +1135,7 @@ AFLD: Buildable: TechLevel: 5 Tab: Building - Prerequisites: [dome] + Prerequisites: dome Owner: soviet Cost: 600 Description: "Airstrip" @@ -1145,7 +1145,7 @@ AFLD: Building: Power: -30 Footprint: xxx xxx - Dimensions: [3,2] + Dimensions: 3,2 Capturable: true RenderBuilding: Production: @@ -1158,7 +1158,7 @@ POWR: Buildable: TechLevel: 1 Tab: Building - Prerequisites: [fact] + Prerequisites: fact Owner: allies,soviet Cost: 300 Description: "Power Plant" @@ -1168,7 +1168,7 @@ POWR: Building: Power: 100 Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true Bib: yes RenderBuilding: @@ -1179,7 +1179,7 @@ APWR: Buildable: TechLevel: 8 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: allies,soviet Cost: 500 Description: "Advanced Power Plant" @@ -1189,7 +1189,7 @@ APWR: Building: Power: 200 Footprint: ___ xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true Bib: yes RenderBuilding: @@ -1200,7 +1200,7 @@ STEK: Buildable: TechLevel: 6 Tab: Building - Prerequisites: [weap,dome] + Prerequisites: weap,dome Owner: soviet Cost: 1500 Description: "Soviet Tech Center" @@ -1210,7 +1210,7 @@ STEK: Building: Power: -100 Footprint: xxx xxx - Dimensions: [3,2] + Dimensions: 3,2 Capturable: true Bib: yes RenderBuilding: @@ -1221,7 +1221,7 @@ BARR: Buildable: TechLevel: 1 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: soviet Cost: 300 Description: "Soviet Barracks" @@ -1231,7 +1231,7 @@ BARR: Building: Power: -20 Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true Bib: yes RenderBuilding: @@ -1244,7 +1244,7 @@ TENT: Buildable: TechLevel: 1 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: allies Cost: 300 Description: "Allied Barracks" @@ -1254,7 +1254,7 @@ TENT: Building: Power: -20 Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true Bib: yes RenderBuilding: @@ -1267,7 +1267,7 @@ KENN: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [barr] + Prerequisites: barr Owner: soviet Cost: 200 Description: "Kennel" @@ -1277,7 +1277,7 @@ KENN: Building: Power: -10 Footprint: x - Dimensions: [1,1] + Dimensions: 1,1 RenderBuilding: RallyPoint: Production: @@ -1288,7 +1288,7 @@ FIX: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [weap] + Prerequisites: weap Owner: allies,soviet Cost: 1200 Description: "Service Depot" @@ -1298,7 +1298,7 @@ FIX: Building: Power: -30 Footprint: _x_ xxx _x_ - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true RenderBuilding: BelowUnits: @@ -1319,7 +1319,7 @@ FACF: Building: Power: -2 Footprint: xxx xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true BaseNormal: no Bib: yes @@ -1333,7 +1333,7 @@ WEAF: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [proc] + Prerequisites: proc Owner: allies Cost: 50 Description: "Fake War Factory" @@ -1343,7 +1343,7 @@ WEAF: Building: Power: -2 Footprint: xxx xxx - Dimensions: [3,2] + Dimensions: 3,2 Capturable: true BaseNormal: no Bib: yes @@ -1358,7 +1358,7 @@ SYRF: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [powr] + Prerequisites: powr Owner: allies Cost: 50 Description: "Fake Shipyard" @@ -1368,7 +1368,7 @@ SYRF: Building: Power: -2 Footprint: xxx xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true BaseNormal: no Adjacent: 8 @@ -1383,7 +1383,7 @@ SPEF: Building: Power: -2 Footprint: xxx xxx xxx - Dimensions: [3,3] + Dimensions: 3,3 Capturable: true BaseNormal: no Adjacent: 8 @@ -1396,7 +1396,7 @@ DOMF: Buildable: TechLevel: 3 Tab: Building - Prerequisites: [proc] + Prerequisites: proc Owner: allies Cost: 50 Description: "Fake Radar Dome" @@ -1406,7 +1406,7 @@ DOMF: Building: Power: -2 Footprint: xx xx - Dimensions: [2,2] + Dimensions: 2,2 Capturable: true BaseNormal: no Bib: yes @@ -1437,14 +1437,14 @@ DOG: Buildable: TechLevel: 3 Tab: Infantry - Prerequisites: [kenn] + Prerequisites: kenn Owner: soviet Cost: 200 Description: "Attack Dog" LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" Selectable: Voice: DogVoice - Bounds: [12,17,-1,-4] + Bounds: 12,17,-1,-4 Unit: HP: 12 Armor: none @@ -1464,7 +1464,7 @@ E1: Description: "Rifle Infantry" LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" Selectable: - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 50 Armor: none @@ -1489,7 +1489,7 @@ E2: Description: "Grenadier" LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" Selectable: - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 50 Armor: none @@ -1515,7 +1515,7 @@ E3: Description: "Rocket Soldier" LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" Selectable: - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 45 Armor: none @@ -1536,13 +1536,13 @@ E4: Buildable: TechLevel: 6 Tab: Infantry - Prerequisites: [stek] + Prerequisites: stek Owner: soviet Cost: 300 Description: "Flamethrower" LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" Selectable: - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 40 Armor: none @@ -1569,7 +1569,7 @@ E6: LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" Selectable: Voice: EngineerVoice - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 25 Armor: none @@ -1587,14 +1587,14 @@ SPY: Buildable: TechLevel: 6 Tab: Infantry - Prerequisites: [dome] + Prerequisites: dome Owner: allies Cost: 500 Description: "Spy" LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" Selectable: Voice: SpyVoice - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 25 Armor: none @@ -1611,14 +1611,14 @@ THF: Buildable: TechLevel: 11 Tab: Infantry - Prerequisites: [atek] + Prerequisites: atek Owner: allies Cost: 500 Description: "Thief" LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" Selectable: Voice: ThiefVoice - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 25 Armor: none @@ -1636,14 +1636,14 @@ E7: Buildable: TechLevel: 11 Tab: Infantry - Prerequisites: [atek,stek] + Prerequisites: atek,stek Owner: allies,soviet Cost: 1200 Description: "Tanya" LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" Selectable: Voice: TanyaVoice - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 100 Armor: none @@ -1670,7 +1670,7 @@ MEDI: LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" Selectable: Voice: MedicVoice - Bounds: [12,17,0,-9] + Bounds: 12,17,0,-9 Unit: HP: 80 Armor: none From 0b6a05fcee701964094d54616ae824a6455a5275 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 9 Jan 2010 22:50:56 +1300 Subject: [PATCH 10/83] Load unit data from ra.yaml --- OpenRa.FileFormats/MiniYaml.cs | 58 + OpenRa.FileFormats/OpenRa.FileFormats.csproj | 1 + OpenRa.Game/Actor.cs | 7 +- OpenRa.Game/GameRules/FieldLoader.cs | 34 + OpenRa.Game/GameRules/NewUnitInfo.cs | 24 + OpenRa.Game/GameRules/Rules.cs | 10 + OpenRa.Game/OpenRa.Game.csproj | 3 + OpenRa.Game/Support/PerfHistory.cs | 2 +- OpenRa.Game/Traits/Buildable.cs | 12 + OpenRa.Game/Traits/Selectable.cs | 12 + RulesConverter/Program.cs | 6 +- RulesConverter/RulesConverter.csproj | 1 + ra.yaml | 1543 ++++++++++++++++++ 13 files changed, 1707 insertions(+), 6 deletions(-) create mode 100755 OpenRa.FileFormats/MiniYaml.cs create mode 100755 OpenRa.Game/GameRules/NewUnitInfo.cs create mode 100755 OpenRa.Game/Traits/Buildable.cs create mode 100755 OpenRa.Game/Traits/Selectable.cs create mode 100644 ra.yaml diff --git a/OpenRa.FileFormats/MiniYaml.cs b/OpenRa.FileFormats/MiniYaml.cs new file mode 100755 index 0000000000..3b51b27e72 --- /dev/null +++ b/OpenRa.FileFormats/MiniYaml.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +namespace OpenRa.FileFormats +{ + public class MiniYaml + { + public string Value; + public Dictionary Nodes = new Dictionary(); + + public MiniYaml( string value ) : this( value, new Dictionary() ) { } + + public MiniYaml( string value, Dictionary nodes ) + { + Value = value; + Nodes = nodes; + } + + public static Dictionary FromFile( string path ) + { + var lines = File.ReadAllLines( path ); + + var levels = new List>(); + levels.Add( new Dictionary() ); + + foreach( var line in lines ) + { + var t = line.TrimStart( ' ', '\t' ); + if( t.Length == 0 || t[ 0 ] == '#' ) + continue; + var level = line.Length - t.Length; + + if( levels.Count <= level ) + throw new InvalidOperationException( "Bad indent in miniyaml" ); + while( levels.Count > level + 1 ) + levels.RemoveAt( levels.Count - 1 ); + + var colon = t.IndexOf( ':' ); + var d = new Dictionary(); + + if( colon == -1 ) + levels[ level ].Add( t.Trim(), new MiniYaml( null, d ) ); + else + { + var value = t.Substring( colon + 1 ).Trim(); + if( value.Length == 0 ) + value = null; + levels[ level ].Add( t.Substring( 0, colon ).Trim(), new MiniYaml( value, d ) ); + } + levels.Add( d ); + } + return levels[ 0 ]; + } + } +} diff --git a/OpenRa.FileFormats/OpenRa.FileFormats.csproj b/OpenRa.FileFormats/OpenRa.FileFormats.csproj index 0016cbc237..5c8fd2cd1b 100644 --- a/OpenRa.FileFormats/OpenRa.FileFormats.csproj +++ b/OpenRa.FileFormats/OpenRa.FileFormats.csproj @@ -57,6 +57,7 @@ + diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 2c7e3b9677..76044e28a0 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -48,8 +48,11 @@ namespace OpenRa.Game if( Info.Traits == null ) throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) ); - foreach (var traitName in Info.Traits) - traits.Add(ConstructTrait(traitName)); + //foreach (var traitName in Info.Traits) + // traits.Add(ConstructTrait(traitName)); + + foreach( var traitName in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.Keys ) + traits.Add( ConstructTrait( traitName ) ); } public void Tick() diff --git a/OpenRa.Game/GameRules/FieldLoader.cs b/OpenRa.Game/GameRules/FieldLoader.cs index bff21b7c5a..dc5107be51 100755 --- a/OpenRa.Game/GameRules/FieldLoader.cs +++ b/OpenRa.Game/GameRules/FieldLoader.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using OpenRa.FileFormats; +using System.Collections.Generic; namespace OpenRa.Game.GameRules { @@ -15,6 +16,39 @@ namespace OpenRa.Game.GameRules } } + public static void CheckYaml( object self, Dictionary d ) + { + //foreach( var x in d ) + //{ + // if( x.Key == "Tab" ) continue; + // if( x.Key == "Description" ) continue; + // if( x.Key == "LongDesc" ) continue; + + // var key = x.Key; + // if( key == "Prerequisites" ) key = "Prerequisite"; + // if( key == "HP" ) key = "Strength"; + // if( key == "Priority" ) key = "SelectionPriority"; + // if( key == "Bounds" ) key = "SelectionSize"; + // var field = self.GetType().GetField( key ); + // var old = field.GetValue( self ); + // var neww = GetValue( field.FieldType, x.Value.Value.Trim() ); + // if( old.ToString() != neww.ToString() ) + // throw new NotImplementedException(); + //} + foreach( var x in d ) + { + var key = x.Key; + if( key == "Tab" ) + continue; + if( key == "Prerequisites" ) key = "Prerequisite"; + if( key == "HP" ) key = "Strength"; + if( key == "Priority" ) key = "SelectionPriority"; + if( key == "Bounds" ) key = "SelectionSize"; + var field = self.GetType().GetField( key.Trim() ); + field.SetValue( self, GetValue( field.FieldType, x.Value.Value.Trim() ) ); + } + } + static object GetValue( Type fieldType, string x ) { if( fieldType == typeof( int ) ) diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs new file mode 100755 index 0000000000..dd37e7115c --- /dev/null +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRa.FileFormats; + +namespace OpenRa.Game.GameRules +{ + class NewUnitInfo + { + public readonly string Parent; + public readonly Dictionary Traits = new Dictionary(); + + public NewUnitInfo( MiniYaml node ) + { + MiniYaml inherit; + if( node.Nodes.TryGetValue( "Inherits", out inherit ) ) + { + Parent = inherit.Value; + node.Nodes.Remove( "Inherits" ); + } + Traits = node.Nodes; + } + } +} diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 3a9c135180..ae9bf199f7 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -24,6 +24,8 @@ namespace OpenRa.Game public static Map Map; public static TileSet TileSet; + public static Dictionary NewUnitInfo; + public static void LoadRules(string mapFileName, bool useAftermath) { if( useAftermath ) @@ -91,6 +93,14 @@ namespace OpenRa.Game Map = new Map( AllRules ); FileSystem.MountTemporary( new Package( Rules.Map.Theater + ".mix" ) ); TileSet = new TileSet( Map.TileSuffix ); + + NewUnitInfo = new Dictionary(); + foreach( var kv in MiniYaml.FromFile( "ra.yaml" ) ) + NewUnitInfo.Add( kv.Key.ToLowerInvariant(), new NewUnitInfo( kv.Value ) ); + + foreach( var unit in NewUnitInfo ) + foreach( var trait in unit.Value.Traits.Values ) + FieldLoader.CheckYaml( UnitInfo[ unit.Key.ToLowerInvariant() ], trait.Nodes ); } static void LoadCategories(params string[] types) diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 088f626e4e..f43e6f6383 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -95,6 +95,7 @@ + @@ -215,6 +216,7 @@ + @@ -240,6 +242,7 @@ + diff --git a/OpenRa.Game/Support/PerfHistory.cs b/OpenRa.Game/Support/PerfHistory.cs index 1b05dc49ad..f17546548b 100644 --- a/OpenRa.Game/Support/PerfHistory.cs +++ b/OpenRa.Game/Support/PerfHistory.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.Support { static class PerfHistory { - static readonly Color[] colors = { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Orange, Color.Fuchsia, Color.Lime, Color.LightBlue }; + static readonly Color[] colors = { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Orange, Color.Fuchsia, Color.Lime, Color.LightBlue, Color.White, Color.Black }; static int nextColor; public static Cache items = new Cache( diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs new file mode 100755 index 0000000000..fb1f95dc52 --- /dev/null +++ b/OpenRa.Game/Traits/Buildable.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game.Traits +{ + class Buildable + { + public Buildable( Actor self ) { } + } +} diff --git a/OpenRa.Game/Traits/Selectable.cs b/OpenRa.Game/Traits/Selectable.cs new file mode 100755 index 0000000000..902d9d8df2 --- /dev/null +++ b/OpenRa.Game/Traits/Selectable.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game.Traits +{ + class Selectable + { + public Selectable( Actor self ) { } + } +} diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index a94f312403..546dfdc6bb 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -45,7 +45,7 @@ namespace RulesConverter { "Selectable", new PL { { "Priority", "SelectionPriority" }, { "Voice", "Voice" }, - { "@Bounds", "SelectionSize" } } + { "Bounds", "SelectionSize" } } }, { "Mobile", new PL { @@ -112,7 +112,7 @@ namespace RulesConverter { "Buildable", new PL { { "TechLevel", "TechLevel" }, { "Tab", "$Tab" }, - { "@Prerequisites", "Prerequisite" }, + { "Prerequisites", "Prerequisite" }, { "Owner", "Owner" }, { "Cost", "Cost" }, { "Icon", "Icon" }, @@ -121,7 +121,7 @@ namespace RulesConverter }, { "Cargo", new PL { - { "@PassengerTypes", "PassengerTypes" } } + { "PassengerTypes", "PassengerTypes" } } }, { "LimitedAmmo", new PL { diff --git a/RulesConverter/RulesConverter.csproj b/RulesConverter/RulesConverter.csproj index 207bcfcfbf..cb7cdaa697 100644 --- a/RulesConverter/RulesConverter.csproj +++ b/RulesConverter/RulesConverter.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + false pdbonly diff --git a/ra.yaml b/ra.yaml new file mode 100644 index 0000000000..419bad4e12 --- /dev/null +++ b/ra.yaml @@ -0,0 +1,1543 @@ +# +# Red Alert rules +# + +DefaultVehicle: +# Unit: +# HP: 1 +# Armor: none +# Crewed: yes +# Voice: VehicleVoice +# Mobile: +# Sight: 1 +# ROT: 5 +# Speed: 1 +# UMT: Wheel +# Repairable: +# Chronoshiftable: +# Passenger: +# IronCurtainable: + +V2RL: + Inherits: DefaultVehicle + Buildable: + TechLevel: 4 + Tab: Vehicle + Prerequisites: weap,dome + Owner: soviet + Cost: 700 + Description: "V2 Rocket" + LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 150 + Armor: light + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 7 + AttackBase: + RenderUnitReload: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +1TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 4 + Tab: Vehicle + Prerequisites: weap + Owner: allies + Cost: 700 + Description: "Light Tank" + LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 300 + Armor: heavy + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 9 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +2TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 6 + Tab: Vehicle + Prerequisites: weap + Owner: allies + Cost: 800 + Description: "Medium Tank" + LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 400 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 8 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +3TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 4 + Tab: Vehicle + Prerequisites: weap + Owner: soviet + Cost: 950 + Description: "Heavy Tank" + LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 400 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 7 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +4TNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 10 + Tab: Vehicle + Prerequisites: weap,stek + Owner: soviet + Cost: 1700 + Description: "Mammoth Tank" + LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Selectable: + Voice: VehicleVoice + Unit: + HP: 600 + Armor: heavy + Crewed: yes + Mobile: + Sight: 6 + ROT: 5 + Speed: 4 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +MRJ: + Inherits: DefaultVehicle + Buildable: + TechLevel: 12 + Tab: Vehicle + Prerequisites: weap,dome + Owner: allies + Cost: 600 + Description: "Radar Jammer" + LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" + Selectable: + Priority: 3 + Voice: VehicleVoice + Unit: + HP: 110 + Armor: light + Crewed: yes + Mobile: + Sight: 7 + ROT: 5 + Speed: 9 + RenderUnitSpinner: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +MGG: + Inherits: DefaultVehicle + Buildable: + TechLevel: 11 + Tab: Vehicle + Prerequisites: weap,atek + Owner: allies + Cost: 600 + Description: "Mobile Gap Generator" + LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" + Selectable: + Priority: 3 + Voice: VehicleVoice + Unit: + HP: 110 + Armor: light + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 9 + RenderUnitSpinner: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +ARTY: + Inherits: DefaultVehicle + Buildable: + TechLevel: 8 + Tab: Vehicle + Prerequisites: weap + Owner: allies + Cost: 600 + Description: "Artillery" + LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 75 + Armor: light + Crewed: yes + Mobile: + Sight: 5 + ROT: 2 + Speed: 6 + AttackBase: + RenderUnit: + Explodes: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +HARV: + Inherits: DefaultVehicle + Buildable: + TechLevel: 1 + Tab: Vehicle + Prerequisites: weap,proc + Owner: allies,soviet + Cost: 1400 + Description: "Ore Truck" + LongDesc: "Collects Ore and Gems for processing.\n Unarmed" + Selectable: + Priority: 7 + Voice: VehicleVoice + Harvester: + Unit: + HP: 600 + Armor: heavy + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 6 + RenderUnit: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +MCV: + Inherits: DefaultVehicle + Buildable: + TechLevel: 11 + Tab: Vehicle + Prerequisites: weap,fix + Owner: allies,soviet + Cost: 2500 + Description: "Mobile Construction Vehicle" + LongDesc: "Deploys into another Construction Yard.\n Unarmed" + Selectable: + Priority: 3 + Voice: VehicleVoice + Unit: + HP: 600 + Armor: light + Crewed: yes + Mobile: + Sight: 4 + ROT: 5 + Speed: 6 + McvDeploy: + RenderUnit: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +JEEP: + Inherits: DefaultVehicle + Buildable: + TechLevel: 3 + Tab: Vehicle + Prerequisites: weap + Owner: allies + Cost: 600 + Description: "Ranger" + LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 150 + Armor: light + Crewed: yes + Mobile: + Sight: 6 + ROT: 10 + Speed: 10 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + +APC: + Inherits: DefaultVehicle + Buildable: + TechLevel: 5 + Tab: Vehicle + Prerequisites: weap,tent + Owner: allies + Cost: 800 + Description: "Armored Personnel Carrier" + LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Voice: VehicleVoice + Unit: + HP: 200 + Armor: heavy + Mobile: + Sight: 5 + ROT: 5 + Speed: 10 + AttackBase: + RenderUnitMuzzleFlash: + AutoTarget: + Repairable: + Chronoshiftable: + Cargo: + PassengerTypes: Foot + Passenger: + IronCurtainable: + +MNLY.AP: + Inherits: DefaultVehicle + Buildable: + TechLevel: 3 + Tab: Vehicle + Prerequisites: weap,fix + Owner: soviet + Cost: 800 + Icon: MNLYICON + Description: "Minelayer (Anti-Personnel)" + LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Selectable: + Voice: VehicleVoice + Unit: + HP: 100 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 9 + RenderUnit: + Image: MNLY + Minelayer: + MineImmune: + Repairable: + LimitedAmmo: + Ammo: 5 + Chronoshiftable: + Passenger: + IronCurtainable: + +MNLY.AT: + Inherits: DefaultVehicle + Buildable: + TechLevel: 3 + Tab: Vehicle + Prerequisites: weap,fix + Owner: allies + Cost: 800 + Icon: MNLYICON + Description: "Minelayer (Anti-Tank)" + LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Selectable: + Voice: VehicleVoice + Unit: + HP: 100 + Armor: heavy + Crewed: yes + Mobile: + Sight: 5 + ROT: 5 + Speed: 9 + RenderUnit: + Image: MNLY + Minelayer: + MineImmune: + Repairable: + LimitedAmmo: + Ammo: 5 + Chronoshiftable: + Passenger: + IronCurtainable: + +SS: + Inherits: DefaultShip + Buildable: + TechLevel: 5 + Tab: Ship + Prerequisites: spen + Owner: soviet + Cost: 950 + Description: "Submarine" + LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" + Selectable: + Unit: + HP: 120 + Armor: light + Mobile: + Sight: 6 + ROT: 7 + Speed: 6 + RenderUnit: + Submarine: + AttackBase: + Chronoshiftable: + IronCurtainable: + +DD: + Inherits: DefaultShip + Buildable: + TechLevel: 7 + Tab: Ship + Prerequisites: syrd + Owner: allies + Cost: 1000 + Description: "Destroyer" + LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" + Selectable: + Unit: + HP: 400 + Armor: heavy + Mobile: + Sight: 6 + ROT: 7 + Speed: 6 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Chronoshiftable: + IronCurtainable: + +CA: + Inherits: DefaultShip + Buildable: + TechLevel: 10 + Tab: Ship + Prerequisites: syrd,atek + Owner: allies + Cost: 2000 + Description: "Cruiser" + LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" + Selectable: + Unit: + HP: 700 + Armor: heavy + Mobile: + Sight: 7 + ROT: 5 + Speed: 4 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Chronoshiftable: + IronCurtainable: + +LST: + Inherits: DefaultShip + Buildable: + TechLevel: 3 + Tab: Ship + Owner: allies,soviet + Cost: 700 + Description: "Transport" + LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" + Selectable: + Unit: + HP: 350 + Armor: heavy + Mobile: + Sight: 6 + ROT: 10 + Speed: 14 + RenderUnit: + Cargo: + PassengerTypes: Foot,Wheel,Track + IronCurtainable: + +PT: + Inherits: DefaultShip + Buildable: + TechLevel: 5 + Tab: Ship + Prerequisites: syrd + Owner: allies + Cost: 500 + Description: "Gunboat" + LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" + Selectable: + Unit: + HP: 200 + Armor: heavy + Mobile: + Sight: 7 + ROT: 7 + Speed: 9 + Turreted: + AttackTurreted: + RenderUnitTurreted: + AutoTarget: + Chronoshiftable: + IronCurtainable: + +MIG: + Inherits: DefaultPlane + Buildable: + TechLevel: 10 + Tab: Plane + Prerequisites: afld + Owner: soviet + Cost: 1200 + Description: "Mig Attack Plane" + LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" + Selectable: + Unit: + HP: 50 + Armor: light + AttackPlane: + Plane: + ROT: 5 + Speed: 20 + RenderUnit: + WithShadow: + LimitedAmmo: + Ammo: 3 + IronCurtainable: + +YAK: + Inherits: DefaultPlane + Buildable: + TechLevel: 5 + Tab: Plane + Prerequisites: afld + Owner: soviet + Cost: 800 + Description: "Yak Attack Plane" + LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" + Selectable: + Unit: + HP: 60 + Armor: light + Crewed: yes + AttackPlane: + Plane: + ROT: 5 + Speed: 16 + RenderUnit: + WithShadow: + LimitedAmmo: + Ammo: 15 + IronCurtainable: + +TRAN: + Inherits: DefaultPlane + Buildable: + TechLevel: 11 + Tab: Plane + Prerequisites: hpad + Owner: allies + Cost: 1200 + Description: "Transport Helicopter" + LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" + Selectable: + Unit: + HP: 90 + Armor: light + Helicopter: + ROT: 5 + Speed: 12 + RenderUnitRotor: + WithShadow: + Cargo: + PassengerTypes: Foot + IronCurtainable: + +HELI: + Inherits: DefaultPlane + Buildable: + TechLevel: 9 + Tab: Plane + Prerequisites: hpad + Owner: allies + Cost: 1200 + Description: "Longbow" + LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" + Selectable: + Unit: + HP: 225 + Armor: heavy + Crewed: yes + AttackHeli: + Helicopter: + ROT: 4 + Speed: 16 + RenderUnitRotor: + WithShadow: + LimitedAmmo: + Ammo: 6 + IronCurtainable: + +HIND: + Inherits: DefaultPlane + Buildable: + TechLevel: 9 + Tab: Plane + Prerequisites: hpad + Owner: allies + Cost: 1200 + Description: "Hind" + LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" + Selectable: + Unit: + HP: 225 + Armor: heavy + Crewed: yes + AttackHeli: + Helicopter: + ROT: 4 + Speed: 12 + RenderUnitRotor: + WithShadow: + LimitedAmmo: + Ammo: 12 + IronCurtainable: + +IRON: + Inherits: DefaultDefense + Buildable: + TechLevel: 12 + Tab: Defense + Prerequisites: stek + Owner: soviet + Cost: 2800 + Description: "Iron Curtain" + LongDesc: "Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + IronCurtain: + +PDOX: + Inherits: DefaultDefense + Buildable: + TechLevel: 12 + Tab: Defense + Prerequisites: atek + Owner: allies + Cost: 2800 + Description: "Chronosphere" + LongDesc: "Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift" + Selectable: + Priority: 3 + Building: + RenderBuilding: + Chronosphere: + IronCurtainable: + +PBOX: + Inherits: DefaultDefense + Buildable: + TechLevel: 2 + Tab: Defense + Prerequisites: tent + Owner: allies + Cost: 400 + Description: "Pillbox" + LongDesc: "Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Priority: 3 + Building: + Turreted: + RenderBuilding: + AttackTurreted: + AutoTarget: + IronCurtainable: + +HBOX: + Inherits: DefaultDefense + Buildable: + TechLevel: 3 + Tab: Defense + Prerequisites: tent + Owner: allies + Cost: 600 + Description: "Camo Pillbox" + LongDesc: "Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Selectable: + Priority: 3 + Building: + Turreted: + RenderBuilding: + AttackTurreted: + AutoTarget: + IronCurtainable: + +TSLA: + Inherits: DefaultDefense + Buildable: + TechLevel: 7 + Tab: Defense + Prerequisites: weap + Owner: soviet + Cost: 1500 + Description: "Tesla Coil" + LongDesc: "Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft" + Selectable: + Priority: 3 + Building: + Turreted: + RenderBuildingCharge: + AttackTurreted: + AutoTarget: + IronCurtainable: + +GUN: + Inherits: DefaultDefense + Buildable: + TechLevel: 4 + Tab: Defense + Prerequisites: tent + Owner: allies + Cost: 600 + Description: "Turret" + LongDesc: "Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft" + Selectable: + Priority: 3 + Building: + Turreted: + RenderBuildingTurreted: + AttackTurreted: + AutoTarget: + IronCurtainable: + +AGUN: + Inherits: DefaultDefense + Buildable: + TechLevel: 5 + Tab: Defense + Prerequisites: dome + Owner: allies + Cost: 600 + Description: "AA Gun" + LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Selectable: + Priority: 3 + Building: + Turreted: + RenderBuildingTurreted: + AttackTurreted: + AutoTarget: + IronCurtainable: + +FTUR: + Inherits: DefaultDefense + Buildable: + TechLevel: 2 + Tab: Defense + Prerequisites: barr + Owner: soviet + Cost: 600 + Description: "Flame Turret" + LongDesc: "Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft" + Selectable: + Priority: 3 + Turreted: + Building: + RenderBuilding: + AttackTurreted: + AutoTarget: + IronCurtainable: + +GAP: + Inherits: DefaultDefense + Buildable: + TechLevel: 10 + Tab: Defense + Prerequisites: atek + Owner: allies + Cost: 500 + Description: "Gap Generator" + LongDesc: "Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + +SAM: + Inherits: DefaultDefense + Buildable: + TechLevel: 9 + Tab: Defense + Prerequisites: dome + Owner: soviet + Cost: 750 + Description: "SAM Site" + LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Selectable: + Priority: 3 + Building: + Turreted: + RenderBuildingTurreted: + AttackTurreted: + AutoTarget: + IronCurtainable: + +MSLO: + Inherits: DefaultDefense + Buildable: + TechLevel: 13 + Tab: Defense + Prerequisites: stek,atek + Owner: soviet,allies + Cost: 2500 + Description: "Missile Silo" + LongDesc: "Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + +ATEK: + Inherits: DefaultBuilding + Buildable: + TechLevel: 10 + Tab: Building + Prerequisites: weap,dome + Owner: allies + Cost: 1500 + Description: "Allied Tech Center" + LongDesc: "Provides Allied advanced technologies.\n Special Ability: GPS Satellite" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + GpsLaunchSite: + +WEAP: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: proc + Owner: soviet,allies + Cost: 2000 + Description: "War Factory" + LongDesc: "Produces tanks & light vehicles." + Selectable: + Priority: 3 + Building: + RenderWarFactory: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + +SYRD: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: powr + Owner: allies + Cost: 650 + Description: "Shipyard" + LongDesc: "Produces and repairs ships" + Selectable: + Priority: 3 + Building: + RenderBuilding: + ProductionSurround: + IronCurtainable: + +SPEN: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: powr + Owner: soviet + Cost: 650 + Description: "Sub Pen" + LongDesc: "Produces and repairs submarines and \ntransports" + Selectable: + Priority: 3 + Building: + RenderBuilding: + ProductionSurround: + IronCurtainable: + +FACT: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + RenderBuilding: + ConstructionYard: + IronCurtainable: + +PROC: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Tab: Building + Prerequisites: powr + Owner: allies,soviet + Cost: 2000 + Description: "Ore Refinery" + LongDesc: "Converts Ore and Gems into money" + Selectable: + Priority: 3 + Building: + RenderBuilding: + AcceptsOre: + StoresOre: + IronCurtainable: + +SILO: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Tab: Building + Prerequisites: proc + Owner: allies,soviet + Cost: 150 + Description: "Silo" + LongDesc: "Stores excess harvested Ore" + Selectable: + Priority: 3 + Building: + RenderBuildingOre: + StoresOre: + IronCurtainable: + +HPAD: + Inherits: DefaultBuilding + Buildable: + TechLevel: 9 + Tab: Building + Prerequisites: dome + Owner: allies + Cost: 1500 + Description: "Helipad" + LongDesc: "Produces and reloads helicopters" + Selectable: + Priority: 3 + Building: + RenderBuilding: + Production: + BelowUnits: + Reservable: + IronCurtainable: + +DOME: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: proc + Owner: allies,soviet + Cost: 1000 + Description: "Radar Dome" + LongDesc: "Provides an overview of the battlefield.\n Requires power to operate." + Selectable: + Priority: 3 + Building: + RenderBuilding: + ProvidesRadar: + IronCurtainable: + +AFLD: + Inherits: DefaultBuilding + Buildable: + TechLevel: 5 + Tab: Building + Prerequisites: dome + Owner: soviet + Cost: 600 + Description: "Airstrip" + LongDesc: "Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane" + Selectable: + Priority: 3 + Building: + RenderBuilding: + Production: + BelowUnits: + Reservable: + IronCurtainable: + +POWR: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Tab: Building + Prerequisites: fact + Owner: allies,soviet + Cost: 300 + Description: "Power Plant" + LongDesc: "Provides power for other structures" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + +APWR: + Inherits: DefaultBuilding + Buildable: + TechLevel: 8 + Tab: Building + Prerequisites: powr + Owner: allies,soviet + Cost: 500 + Description: "Advanced Power Plant" + LongDesc: "Provides more power, cheaper than the \nstandard Power Plant" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + +STEK: + Inherits: DefaultBuilding + Buildable: + TechLevel: 6 + Tab: Building + Prerequisites: weap,dome + Owner: soviet + Cost: 1500 + Description: "Soviet Tech Center" + LongDesc: "Provides Soviet advanced technologies" + Selectable: + Priority: 3 + Building: + RenderBuilding: + IronCurtainable: + +BARR: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Tab: Building + Prerequisites: powr + Owner: soviet + Cost: 300 + Description: "Soviet Barracks" + LongDesc: "Produces infantry" + Selectable: + Priority: 3 + Building: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + +TENT: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Tab: Building + Prerequisites: powr + Owner: allies + Cost: 300 + Description: "Allied Barracks" + LongDesc: "Produces infantry" + Selectable: + Priority: 3 + Building: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + +KENN: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: barr + Owner: soviet + Cost: 200 + Description: "Kennel" + LongDesc: "Produces attack dogs" + Selectable: + Priority: 3 + Building: + RenderBuilding: + RallyPoint: + Production: + IronCurtainable: + +FIX: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: weap + Owner: allies,soviet + Cost: 1200 + Description: "Service Depot" + LongDesc: "Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases." + Selectable: + Priority: 3 + Building: + RenderBuilding: + BelowUnits: + Reservable: + IronCurtainable: + +FACF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 1 + Tab: Building + Owner: allies + Cost: 50 + Description: "Fake Construction Yard" + LongDesc: "Looks like a Construction Yard." + Selectable: + Priority: 3 + Building: + RenderBuilding: + Image: FACT + Fake: + IronCurtainable: + +WEAF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: proc + Owner: allies + Cost: 50 + Description: "Fake War Factory" + LongDesc: "Looks like a War Factory." + Selectable: + Priority: 3 + Building: + RenderWarFactory: + RenderBuilding: + Image: WEAP + Fake: + IronCurtainable: + +SYRF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: powr + Owner: allies + Cost: 50 + Description: "Fake Shipyard" + LongDesc: "Looks like a Shipyard" + Selectable: + Priority: 3 + Building: + RenderBuilding: + Image: SYRD + Fake: + +SPEF: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + RenderBuilding: + Image: SPEN + Fake: + +DOMF: + Inherits: DefaultBuilding + Buildable: + TechLevel: 3 + Tab: Building + Prerequisites: proc + Owner: allies + Cost: 50 + Description: "Fake Radar Dome" + LongDesc: "Looks like a Radar Dome" + Selectable: + Priority: 3 + Building: + RenderBuilding: + Image: DOME + Fake: + +MINP: + Inherits: DefaultBuilding + Unit: + HP: 1 + RenderUnit: + APMine: + BelowUnits: + InvisibleToOthers: + +MINV: + Inherits: DefaultBuilding + Unit: + HP: 1 + RenderUnit: + ATMine: + BelowUnits: + InvisibleToOthers: + +DOG: + Inherits: DefaultInfantry + Buildable: + TechLevel: 3 + Tab: Infantry + Prerequisites: kenn + Owner: soviet + Cost: 200 + Description: "Attack Dog" + LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" + Selectable: + Voice: DogVoice + Bounds: 12,17,-1,-4 + Unit: + HP: 12 + Armor: none + Mobile: + Sight: 5 + Speed: 4 + RenderInfantry: + Passenger: + +E1: + Inherits: DefaultInfantry + Buildable: + TechLevel: 1 + Tab: Infantry + Owner: allies,soviet + Cost: 100 + Description: "Rifle Infantry" + LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" + Selectable: + Bounds: 12,17,0,-9 + Unit: + HP: 50 + Armor: none + Mobile: + Sight: 4 + Speed: 4 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + +E2: + Inherits: DefaultInfantry + Buildable: + TechLevel: 1 + Tab: Infantry + Owner: soviet + Cost: 160 + Description: "Grenadier" + LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" + Selectable: + Bounds: 12,17,0,-9 + Unit: + HP: 50 + Armor: none + Mobile: + Sight: 4 + Speed: 5 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + +E3: + Inherits: DefaultInfantry + Buildable: + TechLevel: 2 + Tab: Infantry + Owner: allies,soviet + Cost: 300 + Description: "Rocket Soldier" + LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Selectable: + Bounds: 12,17,0,-9 + Unit: + HP: 45 + Armor: none + Mobile: + Sight: 4 + Speed: 3 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + +E4: + Inherits: DefaultInfantry + Buildable: + TechLevel: 6 + Tab: Infantry + Prerequisites: stek + Owner: soviet + Cost: 300 + Description: "Flamethrower" + LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" + Selectable: + Bounds: 12,17,0,-9 + Unit: + HP: 40 + Armor: none + Mobile: + Sight: 4 + Speed: 3 + RenderInfantry: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + +E6: + Inherits: DefaultInfantry + Buildable: + TechLevel: 5 + Tab: Infantry + Owner: soviet,allies + Cost: 500 + Description: "Engineer" + LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" + Selectable: + Voice: EngineerVoice + Bounds: 12,17,0,-9 + Unit: + HP: 25 + Armor: none + Mobile: + Sight: 4 + Speed: 4 + EngineerCapture: + RenderInfantry: + TakeCover: + SquishByTank: + Passenger: + +SPY: + Inherits: DefaultInfantry + Buildable: + TechLevel: 6 + Tab: Infantry + Prerequisites: dome + Owner: allies + Cost: 500 + Description: "Spy" + LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" + Selectable: + Voice: SpyVoice + Bounds: 12,17,0,-9 + Unit: + HP: 25 + Armor: none + Mobile: + Sight: 5 + Speed: 4 + RenderInfantry: + TakeCover: + SquishByTank: + Passenger: + +THF: + Inherits: DefaultInfantry + Buildable: + TechLevel: 11 + Tab: Infantry + Prerequisites: atek + Owner: allies + Cost: 500 + Description: "Thief" + LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" + Selectable: + Voice: ThiefVoice + Bounds: 12,17,0,-9 + Unit: + HP: 25 + Armor: none + Mobile: + Sight: 5 + Speed: 4 + RenderInfantry: + TakeCover: + SquishByTank: + Passenger: + Thief: + +E7: + Inherits: DefaultInfantry + Buildable: + TechLevel: 11 + Tab: Infantry + Prerequisites: atek,stek + Owner: allies,soviet + Cost: 1200 + Description: "Tanya" + LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" + Selectable: + Voice: TanyaVoice + Bounds: 12,17,0,-9 + Unit: + HP: 100 + Armor: none + Mobile: + Sight: 6 + Speed: 5 + RenderInfantry: + C4Demolition: + AttackBase: + TakeCover: + SquishByTank: + AutoTarget: + Passenger: + +MEDI: + Inherits: DefaultInfantry + Buildable: + TechLevel: 2 + Tab: Infantry + Owner: allies + Cost: 800 + Description: "Medic" + LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" + Selectable: + Voice: MedicVoice + Bounds: 12,17,0,-9 + Unit: + HP: 80 + Armor: none + Mobile: + Sight: 3 + Speed: 4 + RenderInfantry: + AutoHeal: + AttackBase: + TakeCover: + SquishByTank: + Passenger: + + + + +T01 + Inherits: DefaultTree +T02 + Inherits: DefaultTree +T03 + Inherits: DefaultTree +T05 + Inherits: DefaultTree +T06 + Inherits: DefaultTree +T07 + Inherits: DefaultTree +T08 + Inherits: DefaultTree +T10 + Inherits: DefaultTree +T11 + Inherits: DefaultTree +T12 + Inherits: DefaultTree +T13 + Inherits: DefaultTree +T14 + Inherits: DefaultTree +T15 + Inherits: DefaultTree +T16 + Inherits: DefaultTree +T17 + Inherits: DefaultTree +TC01 + Inherits: DefaultTree +TC02 + Inherits: DefaultTree +TC03 + Inherits: DefaultTree +TC04 + Inherits: DefaultTree +TC05 + Inherits: DefaultTree +MINE + Inherits: DefaultTree + From 5fb2f9128157c368f011374257378fc1a0daf3e5 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 12:34:17 +1300 Subject: [PATCH 11/83] ITraitInfo, plumbing in NewUnitInfo --- OpenRa.Game/GameRules/FieldLoader.cs | 9 +++++++++ OpenRa.Game/GameRules/NewUnitInfo.cs | 20 ++++++++++++++++++-- OpenRa.Game/GameRules/Rules.cs | 5 +---- OpenRa.Game/GameRules/UnitInfo.cs | 8 ++++---- OpenRa.Game/Sound.cs | 2 +- OpenRa.Game/Traits/Mobile.cs | 8 ++++++++ OpenRa.Game/Traits/TraitsInterfaces.cs | 2 ++ OpenRa.Game/Traits/Util.cs | 2 +- 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/OpenRa.Game/GameRules/FieldLoader.cs b/OpenRa.Game/GameRules/FieldLoader.cs index dc5107be51..55731a6445 100755 --- a/OpenRa.Game/GameRules/FieldLoader.cs +++ b/OpenRa.Game/GameRules/FieldLoader.cs @@ -16,6 +16,15 @@ namespace OpenRa.Game.GameRules } } + public static void Load(object self, MiniYaml my) + { + foreach (var x in my.Nodes) + { + var field = self.GetType().GetField(x.Key.Trim()); + field.SetValue(self, GetValue(field.FieldType, x.Value.Value.Trim())); + } + } + public static void CheckYaml( object self, Dictionary d ) { //foreach( var x in d ) diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs index dd37e7115c..4b660ad71d 100755 --- a/OpenRa.Game/GameRules/NewUnitInfo.cs +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -2,13 +2,14 @@ using System.Collections.Generic; using System.Linq; using OpenRa.FileFormats; +using OpenRa.Game.Traits; namespace OpenRa.Game.GameRules { class NewUnitInfo { public readonly string Parent; - public readonly Dictionary Traits = new Dictionary(); + public readonly Dictionary Traits; public NewUnitInfo( MiniYaml node ) { @@ -18,7 +19,22 @@ namespace OpenRa.Game.GameRules Parent = inherit.Value; node.Nodes.Remove( "Inherits" ); } - Traits = node.Nodes; + + Traits = node.Nodes.ToDictionary( + a => a.Key, + a => LoadTraitInfo( a.Key, a.Value )); + } + + static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my) + { + var fullTypeName = typeof(ITraitInfo).Namespace + "." + traitName + "Info"; + var info = (ITraitInfo)typeof(ITraitInfo).Assembly.CreateInstance(fullTypeName); + + if (info == null) + throw new NotImplementedException("Missing traitinfo type `{0}`".F(fullTypeName)); + + FieldLoader.Load(info, my); + return info; } } } diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index ae9bf199f7..46a53ee424 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -4,6 +4,7 @@ using System.Linq; using IjwFramework.Types; using OpenRa.FileFormats; using OpenRa.Game.GameRules; +using OpenRa.Game.Traits; namespace OpenRa.Game { @@ -97,10 +98,6 @@ namespace OpenRa.Game NewUnitInfo = new Dictionary(); foreach( var kv in MiniYaml.FromFile( "ra.yaml" ) ) NewUnitInfo.Add( kv.Key.ToLowerInvariant(), new NewUnitInfo( kv.Value ) ); - - foreach( var unit in NewUnitInfo ) - foreach( var trait in unit.Value.Traits.Values ) - FieldLoader.CheckYaml( UnitInfo[ unit.Key.ToLowerInvariant() ], trait.Nodes ); } static void LoadCategories(params string[] types) diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index 6054874fe0..1b13fa1883 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -67,16 +67,16 @@ namespace OpenRa.Game.GameRules public UnitInfo(string name) { Name = name; } } - public class MobileInfo : UnitInfo + public class LegacyMobileInfo : UnitInfo { public readonly int Speed = 0; public readonly bool NoMovingFire = false; public readonly string Voice = "GenericVoice"; - public MobileInfo(string name) : base(name) { } + public LegacyMobileInfo(string name) : base(name) { } } - public class InfantryInfo : MobileInfo + public class InfantryInfo : LegacyMobileInfo { public readonly bool C4 = false; public readonly bool FraidyCat = false; @@ -87,7 +87,7 @@ namespace OpenRa.Game.GameRules public InfantryInfo(string name) : base(name) { } } - public class VehicleInfo : MobileInfo + public class VehicleInfo : LegacyMobileInfo { public readonly bool Tracked = false; diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index 537d4b59f6..84c637fa02 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -92,7 +92,7 @@ namespace OpenRa.Game { if (voicedUnit == null) return; - var mi = voicedUnit.Info as MobileInfo; + var mi = voicedUnit.Info as LegacyMobileInfo; if (mi == null) return; var vi = Rules.VoiceInfo[mi.Voice]; diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index de1f0dca25..7645d36cab 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -5,6 +5,14 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class MobileInfo : ITraitInfo + { + public readonly int Sight; + public readonly int ROT; + public readonly int Speed; + public object Create(Actor self) { return new Mobile(self); } + } + class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement { readonly Actor self; diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index 849679042b..7a6c05611b 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -69,4 +69,6 @@ namespace OpenRa.Game.Traits public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, newOffset); } public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, ZOffset); } } + + interface ITraitInfo { object Create(Actor self); } } diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index fa918b337d..3a71fb98ae 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -127,7 +127,7 @@ namespace OpenRa.Game.Traits public static float GetEffectiveSpeed(Actor self) { - var mi = self.Info as MobileInfo; + var mi = self.Info as LegacyMobileInfo; if (mi == null) return 0f; var modifier = self.traits From 7a8ab81c91cac81e761c069d11562e1dd3c5c27e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 12:38:26 +1300 Subject: [PATCH 12/83] added BuildableInfo --- OpenRa.Game/GameRules/FieldLoader.cs | 2 ++ OpenRa.Game/Traits/Buildable.cs | 12 ++++++++++++ OpenRa.Game/Traits/Mobile.cs | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/GameRules/FieldLoader.cs b/OpenRa.Game/GameRules/FieldLoader.cs index 55731a6445..f1034dc5f0 100755 --- a/OpenRa.Game/GameRules/FieldLoader.cs +++ b/OpenRa.Game/GameRules/FieldLoader.cs @@ -21,6 +21,8 @@ namespace OpenRa.Game.GameRules foreach (var x in my.Nodes) { var field = self.GetType().GetField(x.Key.Trim()); + if (field == null) + throw new NotImplementedException("Missing field `{0}` on `{1}`".F(x.Key.Trim(), self.GetType().Name)); field.SetValue(self, GetValue(field.FieldType, x.Value.Value.Trim())); } } diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs index fb1f95dc52..ebff7ae4d1 100755 --- a/OpenRa.Game/Traits/Buildable.cs +++ b/OpenRa.Game/Traits/Buildable.cs @@ -5,6 +5,18 @@ using System.Text; namespace OpenRa.Game.Traits { + class BuildableInfo : ITraitInfo + { + public readonly int TechLevel = -1; + public readonly string Tab = null; + public readonly string[] Prerequisites = { }; + public readonly Race[] Owner = { }; + public readonly int Cost = 0; + public readonly string Description = ""; + public readonly string LongDesc = ""; + public object Create(Actor self) { return new Buildable(self); } + } + class Buildable { public Buildable( Actor self ) { } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 7645d36cab..3f753ac289 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -7,9 +7,9 @@ namespace OpenRa.Game.Traits { class MobileInfo : ITraitInfo { - public readonly int Sight; - public readonly int ROT; - public readonly int Speed; + public readonly int Sight = 0; + public readonly int ROT = 0; + public readonly int Speed = 0; public object Create(Actor self) { return new Mobile(self); } } From 68fcd2981620a376a9857bded785edc4060ad20f Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 12:45:23 +1300 Subject: [PATCH 13/83] SelectableInfo --- OpenRa.Game/Traits/Selectable.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRa.Game/Traits/Selectable.cs b/OpenRa.Game/Traits/Selectable.cs index 902d9d8df2..85f8b01592 100755 --- a/OpenRa.Game/Traits/Selectable.cs +++ b/OpenRa.Game/Traits/Selectable.cs @@ -5,6 +5,15 @@ using System.Text; namespace OpenRa.Game.Traits { + class SelectableInfo : ITraitInfo + { + public readonly int Priority = 10; + public readonly int[] Bounds = null; + public readonly string Voice = "GenericVoice"; + + public object Create(Actor self) { return new Selectable(self); } + } + class Selectable { public Selectable( Actor self ) { } From 409a48b22a8ca6caf60fcd2d728feaa859a40b74 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:06:39 +1300 Subject: [PATCH 14/83] more --- OpenRa.Game/Actor.cs | 4 ++-- OpenRa.Game/GameRules/Rules.cs | 16 ++++++++-------- OpenRa.Game/GameRules/TechTree.cs | 6 +++--- OpenRa.Game/GameRules/UnitInfo.cs | 8 ++++---- .../Orders/ChronosphereSelectOrderGenerator.cs | 2 +- OpenRa.Game/Orders/IronCurtainOrderGenerator.cs | 2 +- OpenRa.Game/Traits/AttackBase.cs | 7 +++++++ OpenRa.Game/Traits/AutoTarget.cs | 5 +++++ OpenRa.Game/Traits/Chronoshiftable.cs | 5 +++++ OpenRa.Game/Traits/Production.cs | 4 ++-- OpenRa.Game/Traits/ProductionSurround.cs | 2 +- OpenRa.Game/Traits/RenderUnitReload.cs | 5 +++++ OpenRa.Game/Traits/Repairable.cs | 5 +++++ OpenRa.Game/Traits/TraitsInterfaces.cs | 2 +- OpenRa.Game/Traits/Unit.cs | 12 +++++++++++- 15 files changed, 61 insertions(+), 24 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 76044e28a0..1493fd8625 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -12,7 +12,7 @@ namespace OpenRa.Game { [Sync] public readonly TypeDictionary traits = new TypeDictionary(); - public readonly UnitInfo Info; + public readonly LegacyUnitInfo Info; public readonly uint ActorID; [Sync] @@ -36,7 +36,7 @@ namespace OpenRa.Game public Actor( ActorInfo info, int2 location, Player owner ) { ActorID = Game.world.NextAID(); - Info = (UnitInfo)info; // temporary + Info = (LegacyUnitInfo)info; // temporary Location = location; CenterLocation = Traits.Util.CenterOfCell(Location); Owner = owner; diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 46a53ee424..fd5207b3d6 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -13,7 +13,7 @@ namespace OpenRa.Game public static IniFile AllRules; public static Dictionary> Categories = new Dictionary>(); public static Dictionary UnitCategory; - public static InfoLoader UnitInfo; + public static InfoLoader UnitInfo; public static InfoLoader WeaponInfo; public static InfoLoader WarheadInfo; public static InfoLoader ProjectileInfo; @@ -64,13 +64,13 @@ namespace OpenRa.Game "Plane"); UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair(y, x.Key))).ToDictionary(x => x.Key, x => x.Value); - UnitInfo = new InfoLoader( - Pair.New>("Building", s => new BuildingInfo(s)), - Pair.New>("Defense", s => new BuildingInfo(s)), - Pair.New>("Infantry", s => new InfantryInfo(s)), - Pair.New>("Vehicle", s => new VehicleInfo(s)), - Pair.New>("Ship", s => new VehicleInfo(s)), - Pair.New>("Plane", s => new VehicleInfo(s))); + UnitInfo = new InfoLoader( + Pair.New>("Building", s => new BuildingInfo(s)), + Pair.New>("Defense", s => new BuildingInfo(s)), + Pair.New>("Infantry", s => new InfantryInfo(s)), + Pair.New>("Vehicle", s => new VehicleInfo(s)), + Pair.New>("Ship", s => new VehicleInfo(s)), + Pair.New>("Plane", s => new VehicleInfo(s))); LoadCategories( "Weapon", diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index c2cfb0c230..354cc3a38a 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -6,7 +6,7 @@ namespace OpenRa.Game.GameRules { class TechTree { - readonly Cache> producesIndex = new Cache>( x => new List() ); + readonly Cache> producesIndex = new Cache>( x => new List() ); public TechTree() { @@ -26,7 +26,7 @@ namespace OpenRa.Game.GameRules return ret; } - public bool CanBuild( UnitInfo unit, Player player, Cache> playerBuildings ) + public bool CanBuild( LegacyUnitInfo unit, Player player, Cache> playerBuildings ) { if( unit.TechLevel == -1 ) return false; @@ -59,7 +59,7 @@ namespace OpenRa.Game.GameRules .Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */ } - public IEnumerable UnitBuiltAt( UnitInfo info ) + public IEnumerable UnitBuiltAt( LegacyUnitInfo info ) { if( info.BuiltAt.Length != 0 ) return info.BuiltAt.Select( x => Rules.UnitInfo[ x.ToLowerInvariant() ] ); diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index 1b13fa1883..8f06bf4193 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -11,7 +11,7 @@ namespace OpenRa.Game.GameRules concrete = 4, } - public class UnitInfo : ActorInfo + public class LegacyUnitInfo : ActorInfo { public readonly string Name; @@ -64,10 +64,10 @@ namespace OpenRa.Game.GameRules public readonly int[] PrimaryLocalOffset = { }; public readonly int[] SecondaryLocalOffset = { }; - public UnitInfo(string name) { Name = name; } + public LegacyUnitInfo(string name) { Name = name; } } - public class LegacyMobileInfo : UnitInfo + public class LegacyMobileInfo : LegacyUnitInfo { public readonly int Speed = 0; public readonly bool NoMovingFire = false; @@ -94,7 +94,7 @@ namespace OpenRa.Game.GameRules public VehicleInfo(string name) : base(name) { } } - public class BuildingInfo : UnitInfo + public class BuildingInfo : LegacyUnitInfo { public readonly int2 Dimensions = new int2(1, 1); public readonly string Footprint = "x"; diff --git a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs index ec0c0f4edf..b4a013b15a 100644 --- a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Orders && a.traits.WithInterface().Any() && a.Info.Selectable).FirstOrDefault(); - var unit = underCursor != null ? underCursor.Info as UnitInfo : null; + var unit = underCursor != null ? underCursor.Info as LegacyUnitInfo : null; if (unit != null) yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, power.Name); diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs index 0a75ca1dd6..57f9870c5a 100644 --- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs +++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Orders && a.traits.Contains() && a.Info.Selectable).FirstOrDefault(); - var unit = underCursor != null ? underCursor.Info as UnitInfo : null; + var unit = underCursor != null ? underCursor.Info as LegacyUnitInfo : null; if (unit != null) yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name); diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 6b78edfe9c..ed8bfb08f3 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -6,6 +6,13 @@ using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { + class AttackBaseInfo : ITraitInfo + { + + + public object Create(Actor self) { return new AttackBase(self); } + } + class AttackBase : IIssueOrder, IResolveOrder, ITick { [Sync] public Actor target; diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index bd7730d57c..94e66aeeaf 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class AutoTargetInfo : ITraitInfo + { + public object Create(Actor self) { return new AutoTarget(self); } + } + class AutoTarget : ITick, INotifyDamage { public AutoTarget(Actor self) {} diff --git a/OpenRa.Game/Traits/Chronoshiftable.cs b/OpenRa.Game/Traits/Chronoshiftable.cs index 2df077e0bb..4450d036ce 100644 --- a/OpenRa.Game/Traits/Chronoshiftable.cs +++ b/OpenRa.Game/Traits/Chronoshiftable.cs @@ -5,6 +5,11 @@ using System.Linq; namespace OpenRa.Game.Traits { + class ChronoshiftableInfo : ITraitInfo + { + public object Create(Actor self) { return new Chronoshiftable(self); } + } + class Chronoshiftable : IResolveOrder, ISpeedModifier, ITick { // Return-to-sender logic diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index fb83d73a85..4cebf0f320 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -11,7 +11,7 @@ namespace OpenRa.Game.Traits public Production( Actor self ) { } - public virtual int2? CreationLocation( Actor self, UnitInfo producee ) + public virtual int2? CreationLocation( Actor self, LegacyUnitInfo producee ) { return ( 1 / 24f * self.CenterLocation ).ToInt2(); } @@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits return newUnit.Info.InitialFacing; } - public bool Produce( Actor self, UnitInfo producee ) + public bool Produce( Actor self, LegacyUnitInfo producee ) { var location = CreationLocation( self, producee ); if( location == null || Game.UnitInfluence.GetUnitsAt( location.Value ).Any() ) diff --git a/OpenRa.Game/Traits/ProductionSurround.cs b/OpenRa.Game/Traits/ProductionSurround.cs index 4fb0091697..1c2f1d8327 100644 --- a/OpenRa.Game/Traits/ProductionSurround.cs +++ b/OpenRa.Game/Traits/ProductionSurround.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits return null; } - public override int2? CreationLocation(Actor self, UnitInfo producee) + public override int2? CreationLocation(Actor self, LegacyUnitInfo producee) { return FindAdjacentTile(self, producee.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */ diff --git a/OpenRa.Game/Traits/RenderUnitReload.cs b/OpenRa.Game/Traits/RenderUnitReload.cs index 59f05a5ea7..fe0c8c2f53 100644 --- a/OpenRa.Game/Traits/RenderUnitReload.cs +++ b/OpenRa.Game/Traits/RenderUnitReload.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class RenderUnitReloadInfo : ITraitInfo + { + public object Create(Actor self) { return new RenderUnitReload(self); } + } + class RenderUnitReload : RenderUnit { public RenderUnitReload(Actor self) diff --git a/OpenRa.Game/Traits/Repairable.cs b/OpenRa.Game/Traits/Repairable.cs index c5c38caf84..7e75fd48ce 100644 --- a/OpenRa.Game/Traits/Repairable.cs +++ b/OpenRa.Game/Traits/Repairable.cs @@ -6,6 +6,11 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class RepairableInfo : ITraitInfo + { + public object Create(Actor self) { return new Repairable(self); } + } + class Repairable : IIssueOrder, IResolveOrder { IDisposable reservation; diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index 7a6c05611b..440eda8a1f 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits interface IProducer { - bool Produce( Actor self, UnitInfo producee ); + bool Produce( Actor self, LegacyUnitInfo producee ); void SetPrimaryProducer(Actor self, bool isPrimary); } interface IOccupySpace { IEnumerable OccupiedCells(); } diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index ebfc56cf31..c3de5d2dfe 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -1,6 +1,16 @@ - +using OpenRa.Game.GameRules; + namespace OpenRa.Game.Traits { + class UnitInfo : ITraitInfo + { + public readonly int HP = 0; + public readonly ArmorType Armor = ArmorType.none; + public readonly bool Crewed = false; // replace with trait? + + public object Create(Actor self) { return new Unit(self); } + } + class Unit : INotifyDamage { [Sync] From fee63593d7e39811277da01ff803b5508b8c1d83 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:20:51 +1300 Subject: [PATCH 15/83] more traitinfos --- OpenRa.Game/GameRules/FieldLoader.cs | 8 ++++---- OpenRa.Game/Traits/AttackTurreted.cs | 2 ++ OpenRa.Game/Traits/Buildable.cs | 2 ++ OpenRa.Game/Traits/Cargo.cs | 7 +++++++ OpenRa.Game/Traits/Explodes.cs | 5 +++++ OpenRa.Game/Traits/Harvester.cs | 5 +++++ OpenRa.Game/Traits/IronCurtainable.cs | 5 +++++ OpenRa.Game/Traits/LimitedAmmo.cs | 7 +++++++ OpenRa.Game/Traits/McvDeploy.cs | 5 +++++ OpenRa.Game/Traits/MineImmune.cs | 5 +++++ OpenRa.Game/Traits/Minelayer.cs | 5 +++++ OpenRa.Game/Traits/Passenger.cs | 5 +++++ OpenRa.Game/Traits/RenderBuilding.cs | 5 +++++ OpenRa.Game/Traits/RenderBuildingCharge.cs | 5 +++++ OpenRa.Game/Traits/RenderBuildingOre.cs | 5 +++++ OpenRa.Game/Traits/RenderSimple.cs | 7 +++++++ OpenRa.Game/Traits/RenderUnit.cs | 5 +++++ OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs | 5 +++++ OpenRa.Game/Traits/RenderUnitSpinner.cs | 5 +++++ OpenRa.Game/Traits/RenderUnitTurreted.cs | 2 ++ OpenRa.Game/Traits/Turreted.cs | 5 +++++ 21 files changed, 101 insertions(+), 4 deletions(-) diff --git a/OpenRa.Game/GameRules/FieldLoader.cs b/OpenRa.Game/GameRules/FieldLoader.cs index f1034dc5f0..71fb420c06 100755 --- a/OpenRa.Game/GameRules/FieldLoader.cs +++ b/OpenRa.Game/GameRules/FieldLoader.cs @@ -7,12 +7,12 @@ namespace OpenRa.Game.GameRules { static class FieldLoader { - public static void Load( object self, IniSection ini ) + public static void Load(object self, IniSection ini) { - foreach( var x in ini ) + foreach (var x in ini) { - var field = self.GetType().GetField( x.Key.Trim() ); - field.SetValue( self, GetValue( field.FieldType, x.Value.Trim() ) ); + var field = self.GetType().GetField(x.Key.Trim()); + field.SetValue(self, GetValue(field.FieldType, x.Value.Trim())); } } diff --git a/OpenRa.Game/Traits/AttackTurreted.cs b/OpenRa.Game/Traits/AttackTurreted.cs index 9c0f513251..c574e309a8 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -3,6 +3,8 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class AttackTurretedInfo : AttackBaseInfo { } + class AttackTurreted : AttackBase, INotifyBuildComplete { public AttackTurreted( Actor self ) : base(self) { self.traits.Get(); } diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs index ebff7ae4d1..25eec93980 100755 --- a/OpenRa.Game/Traits/Buildable.cs +++ b/OpenRa.Game/Traits/Buildable.cs @@ -14,6 +14,8 @@ namespace OpenRa.Game.Traits public readonly int Cost = 0; public readonly string Description = ""; public readonly string LongDesc = ""; + public readonly string Icon = null; + public object Create(Actor self) { return new Buildable(self); } } diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index 088cde0640..d9798efd0c 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -7,6 +7,13 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class CargoInfo : ITraitInfo + { + public readonly UnitMovementType[] PassengerTypes = { }; + + public object Create(Actor self) { return new Cargo(self); } + } + class Cargo : IPips, IIssueOrder, IResolveOrder { List cargo = new List(); diff --git a/OpenRa.Game/Traits/Explodes.cs b/OpenRa.Game/Traits/Explodes.cs index 08fc4e0db4..712ded0e4f 100644 --- a/OpenRa.Game/Traits/Explodes.cs +++ b/OpenRa.Game/Traits/Explodes.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class ExplodesInfo : ITraitInfo + { + public object Create(Actor self) { return new Explodes(self); } + } + class Explodes : INotifyDamage { public Explodes(Actor self) {} diff --git a/OpenRa.Game/Traits/Harvester.cs b/OpenRa.Game/Traits/Harvester.cs index aa374e943c..4d038d93c9 100644 --- a/OpenRa.Game/Traits/Harvester.cs +++ b/OpenRa.Game/Traits/Harvester.cs @@ -3,6 +3,11 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class HarvesterInfo : ITraitInfo + { + public object Create(Actor self) { return new Harvester(self); } + } + class Harvester : IIssueOrder, IResolveOrder, IPips { [Sync] diff --git a/OpenRa.Game/Traits/IronCurtainable.cs b/OpenRa.Game/Traits/IronCurtainable.cs index 4feda533ad..45344f3c34 100644 --- a/OpenRa.Game/Traits/IronCurtainable.cs +++ b/OpenRa.Game/Traits/IronCurtainable.cs @@ -3,6 +3,11 @@ using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { + class IronCurtainableInfo : ITraitInfo + { + public object Create(Actor self) { return new IronCurtain(self); } + } + class IronCurtainable : IResolveOrder, IDamageModifier, ITick { [Sync] diff --git a/OpenRa.Game/Traits/LimitedAmmo.cs b/OpenRa.Game/Traits/LimitedAmmo.cs index b3ffe3535f..e2c5cc0797 100644 --- a/OpenRa.Game/Traits/LimitedAmmo.cs +++ b/OpenRa.Game/Traits/LimitedAmmo.cs @@ -2,6 +2,13 @@ namespace OpenRa.Game.Traits { + class LimitedAmmoInfo : ITraitInfo + { + public readonly int Ammo = 0; + + public object Create(Actor self) { return new LimitedAmmo(self); } + } + class LimitedAmmo : INotifyAttack, IPips { [Sync] diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index 4848378acb..5b5cb880b1 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -3,6 +3,11 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class McvDeployInfo : ITraitInfo + { + public object Create(Actor self) { return new McvDeploy(self); } + } + class McvDeploy : IIssueOrder, IResolveOrder { public McvDeploy(Actor self) { } diff --git a/OpenRa.Game/Traits/MineImmune.cs b/OpenRa.Game/Traits/MineImmune.cs index d711a036ba..f82acf08c4 100644 --- a/OpenRa.Game/Traits/MineImmune.cs +++ b/OpenRa.Game/Traits/MineImmune.cs @@ -1,6 +1,11 @@  namespace OpenRa.Game.Traits { + class MineImmuneInfo : ITraitInfo + { + public object Create(Actor self) { return new MineImmune(self); } + } + class MineImmune { public MineImmune(Actor self) { } diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index 871029b159..7fe567bd2b 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -5,6 +5,11 @@ using System.Text; namespace OpenRa.Game.Traits { + class MinelayerInfo : ITraitInfo + { + public object Create(Actor self) { return new Minelayer(self); } + } + class Minelayer : IIssueOrder, IResolveOrder { public Minelayer(Actor self) { } diff --git a/OpenRa.Game/Traits/Passenger.cs b/OpenRa.Game/Traits/Passenger.cs index 20ee863d2d..36cc0f3f5f 100644 --- a/OpenRa.Game/Traits/Passenger.cs +++ b/OpenRa.Game/Traits/Passenger.cs @@ -6,6 +6,11 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class PassengerInfo : ITraitInfo + { + public object Create(Actor self) { return new Passenger(self); } + } + class Passenger : IIssueOrder, IResolveOrder { public Passenger(Actor self) { } diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index d5291d0b59..d73b16915b 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -5,6 +5,11 @@ using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { + class RenderBuildingInfo : RenderSimpleInfo + { + public override object Create(Actor self) { return new RenderBuilding(self); } + } + class RenderBuilding : RenderSimple, INotifyDamage, INotifySold { const int SmallBibStart = 1; diff --git a/OpenRa.Game/Traits/RenderBuildingCharge.cs b/OpenRa.Game/Traits/RenderBuildingCharge.cs index e0a5e7bd3f..f76821b972 100644 --- a/OpenRa.Game/Traits/RenderBuildingCharge.cs +++ b/OpenRa.Game/Traits/RenderBuildingCharge.cs @@ -5,6 +5,11 @@ using System.Text; namespace OpenRa.Game.Traits { + class RenderBuildingChargeInfo : RenderBuildingInfo + { + public override object Create(Actor self) { return new RenderBuildingCharge(self); } + } + /* used for tesla */ class RenderBuildingCharge : RenderBuilding, INotifyAttack { diff --git a/OpenRa.Game/Traits/RenderBuildingOre.cs b/OpenRa.Game/Traits/RenderBuildingOre.cs index 015db7721e..0909475d78 100644 --- a/OpenRa.Game/Traits/RenderBuildingOre.cs +++ b/OpenRa.Game/Traits/RenderBuildingOre.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class RenderBuildingOreInfo : RenderBuildingInfo + { + public override object Create(Actor self) { return new RenderBuildingOre(self); } + } + class RenderBuildingOre : RenderBuilding, INotifyBuildComplete { public RenderBuildingOre(Actor self) diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index d5db307c09..7975607053 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -5,6 +5,13 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + abstract class RenderSimpleInfo : ITraitInfo + { + public readonly string Image = null; + + public abstract object Create(Actor self); + } + abstract class RenderSimple : IRender, ITick { public Dictionary anims = new Dictionary(); diff --git a/OpenRa.Game/Traits/RenderUnit.cs b/OpenRa.Game/Traits/RenderUnit.cs index 9d293d8340..067b4ccc90 100644 --- a/OpenRa.Game/Traits/RenderUnit.cs +++ b/OpenRa.Game/Traits/RenderUnit.cs @@ -5,6 +5,11 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class RenderUnitInfo : RenderSimpleInfo + { + public override object Create(Actor self) { return new RenderUnit(self); } + } + class RenderUnit : RenderSimple, INotifyDamage { public RenderUnit(Actor self) diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index 0e198ba1ad..d8beee320d 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -5,6 +5,11 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class RenderUnitMuzzleFlashInfo : RenderUnitInfo + { + public override object Create(Actor self) { return new RenderUnitMuzzleFlash(self); } + } + class RenderUnitMuzzleFlash : RenderUnit { public RenderUnitMuzzleFlash(Actor self) diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index aefb72329f..8dc54c535b 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -3,6 +3,11 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class RenderUnitSpinnerInfo : RenderUnitInfo + { + public override object Create(Actor self) { return new RenderUnitSpinner(self); } + } + class RenderUnitSpinner : RenderUnit { public Animation spinnerAnim; diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index f05caa57f4..38079af844 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -4,6 +4,8 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class RenderUnitTurretedInfo : RenderUnitInfo { } + class RenderUnitTurreted : RenderUnit { public Animation muzzleFlash; diff --git a/OpenRa.Game/Traits/Turreted.cs b/OpenRa.Game/Traits/Turreted.cs index b20de37e63..0e2c7318d7 100644 --- a/OpenRa.Game/Traits/Turreted.cs +++ b/OpenRa.Game/Traits/Turreted.cs @@ -1,6 +1,11 @@  namespace OpenRa.Game.Traits { + class TurretedInfo : ITraitInfo + { + public object Create(Actor self) { return new Turreted(self); } + } + class Turreted : ITick { [Sync] From 040d2513506c7944627f19e1895a8035bee97997 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:28:46 +1300 Subject: [PATCH 16/83] everything StoresOreInfo onward --- OpenRa.Game/OpenRa.Game.csproj | 1 - OpenRa.Game/Traits/StoresOre.cs | 17 +++++++++-------- OpenRa.Game/Traits/Submarine.cs | 5 +++++ OpenRa.Game/Traits/TakeCover.cs | 5 +++++ OpenRa.Game/Traits/Thief.cs | 5 +++++ OpenRa.Game/Traits/Tree.cs | 20 -------------------- OpenRa.Game/Traits/WaterPaletteRotation.cs | 5 +++++ OpenRa.Game/Traits/WithShadow.cs | 5 +++++ 8 files changed, 34 insertions(+), 29 deletions(-) delete mode 100644 OpenRa.Game/Traits/Tree.cs diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index f43e6f6383..c2a351bf94 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -271,7 +271,6 @@ - diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index bdabfca5d2..fad732b83c 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -3,16 +3,17 @@ using System; using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class StoresOreInfo : ITraitInfo + { + public readonly int Pips = 0; + public readonly int Capacity = 0; + + public object Create(Actor self) { return new StoresOre(self); } + } + class StoresOre : IPips, IAcceptThief { - public const int MaxStealAmount = 100; //todo: How is cash stolen determined? - - readonly Actor self; - - public StoresOre(Actor self) - { - this.self = self; - } + public StoresOre(Actor self) {} public void OnSteal(Actor self, Actor thief) { diff --git a/OpenRa.Game/Traits/Submarine.cs b/OpenRa.Game/Traits/Submarine.cs index 3183072b85..79033ed5b5 100644 --- a/OpenRa.Game/Traits/Submarine.cs +++ b/OpenRa.Game/Traits/Submarine.cs @@ -4,6 +4,11 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class SubmarineInfo : ITraitInfo + { + public object Create(Actor self) { return new Submarine(self); } + } + class Submarine : IRenderModifier, INotifyAttack, ITick, INotifyDamage { [Sync] diff --git a/OpenRa.Game/Traits/TakeCover.cs b/OpenRa.Game/Traits/TakeCover.cs index 192f2e899b..abd2148592 100644 --- a/OpenRa.Game/Traits/TakeCover.cs +++ b/OpenRa.Game/Traits/TakeCover.cs @@ -1,6 +1,11 @@  namespace OpenRa.Game.Traits { + class TakeCoverInfo : ITraitInfo + { + public object Create(Actor self) { return new TakeCover(self); } + } + // infantry prone behavior class TakeCover : ITick, INotifyDamage, IDamageModifier, ISpeedModifier { diff --git a/OpenRa.Game/Traits/Thief.cs b/OpenRa.Game/Traits/Thief.cs index 54b34b5d5c..591391a164 100644 --- a/OpenRa.Game/Traits/Thief.cs +++ b/OpenRa.Game/Traits/Thief.cs @@ -3,6 +3,11 @@ using System.Collections.Generic; using System.Linq; namespace OpenRa.Game.Traits { + class ThiefInfo : ITraitInfo + { + public object Create(Actor self) { return new Thief(self); } + } + class Thief : IIssueOrder, IResolveOrder { public Thief(Actor self) { } diff --git a/OpenRa.Game/Traits/Tree.cs b/OpenRa.Game/Traits/Tree.cs deleted file mode 100644 index f4c3ebced1..0000000000 --- a/OpenRa.Game/Traits/Tree.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; -using OpenRa.Game.Graphics; - -namespace OpenRa.Game.Traits -{ - class Tree : IRender - { - Sprite Image; - - public Tree(Sprite treeImage) - { - Image = treeImage; - } - - public IEnumerable Render(Actor self) - { - yield return new Renderable(Image, Game.CellSize * (float2)self.Location, 0); - } - } -} diff --git a/OpenRa.Game/Traits/WaterPaletteRotation.cs b/OpenRa.Game/Traits/WaterPaletteRotation.cs index ec31812731..7c5a5eacf9 100644 --- a/OpenRa.Game/Traits/WaterPaletteRotation.cs +++ b/OpenRa.Game/Traits/WaterPaletteRotation.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class WaterPaletteRotationInfo : ITraitInfo + { + public object Create(Actor self) { return new WaterPaletteRotation(self); } + } + class WaterPaletteRotation : ITick, IPaletteModifier { public WaterPaletteRotation(Actor self) { } diff --git a/OpenRa.Game/Traits/WithShadow.cs b/OpenRa.Game/Traits/WithShadow.cs index 7575573781..39153ba058 100644 --- a/OpenRa.Game/Traits/WithShadow.cs +++ b/OpenRa.Game/Traits/WithShadow.cs @@ -6,6 +6,11 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class WithShadowInfo : ITraitInfo + { + public object Create(Actor self) { return new WithShadow(self); } + } + class WithShadow : IRenderModifier { public WithShadow(Actor self) {} From 1803dad53c0a2824f40b55bca184c7a23740f20d Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:32:23 +1300 Subject: [PATCH 17/83] Reservable.. --- OpenRa.Game/Traits/Reservable.cs | 5 +++++ OpenRa.Game/Traits/SeedsOre.cs | 5 +++++ OpenRa.Game/Traits/SquishByTank.cs | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/OpenRa.Game/Traits/Reservable.cs b/OpenRa.Game/Traits/Reservable.cs index b459bc3da7..b25b610839 100644 --- a/OpenRa.Game/Traits/Reservable.cs +++ b/OpenRa.Game/Traits/Reservable.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class ReservableInfo : ITraitInfo + { + public object Create(Actor self) { return new Reservable(self); } + } + class Reservable : ITick { public Reservable(Actor self) { } diff --git a/OpenRa.Game/Traits/SeedsOre.cs b/OpenRa.Game/Traits/SeedsOre.cs index 98bb98ab9e..f5dd4a123d 100644 --- a/OpenRa.Game/Traits/SeedsOre.cs +++ b/OpenRa.Game/Traits/SeedsOre.cs @@ -1,6 +1,11 @@  namespace OpenRa.Game.Traits { + class SeedsOreInfo : ITraitInfo + { + public object Create(Actor self) { return new SeedsOre(self); } + } + class SeedsOre : ITick { public SeedsOre( Actor self ) {} diff --git a/OpenRa.Game/Traits/SquishByTank.cs b/OpenRa.Game/Traits/SquishByTank.cs index ed84275899..baaeacb70b 100644 --- a/OpenRa.Game/Traits/SquishByTank.cs +++ b/OpenRa.Game/Traits/SquishByTank.cs @@ -5,6 +5,11 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class SquishByTankInfo : ITraitInfo + { + public object Create(Actor self) { return new SquishByTank(self); } + } + class SquishByTank : ICrushable { readonly Actor self; From f4d19aa78c2c86e79290491b6762ced2c39ca578 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:37:21 +1300 Subject: [PATCH 18/83] ProvidesRadar.. --- OpenRa.Game/Traits/ProvidesRadar.cs | 5 +++++ OpenRa.Game/Traits/RallyPoint.cs | 5 +++++ OpenRa.Game/Traits/RenderBuildingTurreted.cs | 5 +++++ OpenRa.Game/Traits/RenderBuildingWarFactory.cs | 5 +++++ OpenRa.Game/Traits/RenderInfantry.cs | 5 +++++ OpenRa.Game/Traits/RenderUnitReload.cs | 4 ++-- OpenRa.Game/Traits/RenderUnitRotor.cs | 5 +++++ OpenRa.Game/Traits/RenderUnitTurreted.cs | 5 ++++- 8 files changed, 36 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Traits/ProvidesRadar.cs b/OpenRa.Game/Traits/ProvidesRadar.cs index 7a4ba5e0c6..db8b01fc4e 100644 --- a/OpenRa.Game/Traits/ProvidesRadar.cs +++ b/OpenRa.Game/Traits/ProvidesRadar.cs @@ -5,6 +5,11 @@ using System.Text; namespace OpenRa.Game.Traits { + class ProvidesRadarInfo : ITraitInfo + { + public object Create(Actor self) { return new ProvidesRadar(self); } + } + class ProvidesRadar { Actor self; diff --git a/OpenRa.Game/Traits/RallyPoint.cs b/OpenRa.Game/Traits/RallyPoint.cs index fb2006fa5d..1daf34c844 100644 --- a/OpenRa.Game/Traits/RallyPoint.cs +++ b/OpenRa.Game/Traits/RallyPoint.cs @@ -4,6 +4,11 @@ using OpenRa.Game.Orders; namespace OpenRa.Game.Traits { + class RallyPointInfo : ITraitInfo + { + public object Create(Actor self) { return new RallyPoint(self); } + } + class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick { [Sync] diff --git a/OpenRa.Game/Traits/RenderBuildingTurreted.cs b/OpenRa.Game/Traits/RenderBuildingTurreted.cs index 628377efd2..021c23ad65 100644 --- a/OpenRa.Game/Traits/RenderBuildingTurreted.cs +++ b/OpenRa.Game/Traits/RenderBuildingTurreted.cs @@ -1,6 +1,11 @@  namespace OpenRa.Game.Traits { + class RenderBuildingTurretedInfo : RenderBuildingInfo + { + public override object Create(Actor self) { return new RenderBuildingTurreted(self); } + } + class RenderBuildingTurreted : RenderBuilding, INotifyBuildComplete { public RenderBuildingTurreted(Actor self) diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index 074d058068..aa33fe1c18 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -4,6 +4,11 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class RenderWarFactoryInfo : ITraitInfo + { + public object Create(Actor self) { return new RenderWarFactory(self); } + } + class RenderWarFactory : IRender, INotifyBuildComplete, INotifyDamage, ITick, INotifyProduction { public Animation roof; diff --git a/OpenRa.Game/Traits/RenderInfantry.cs b/OpenRa.Game/Traits/RenderInfantry.cs index 04ae828be7..babf20589f 100644 --- a/OpenRa.Game/Traits/RenderInfantry.cs +++ b/OpenRa.Game/Traits/RenderInfantry.cs @@ -8,6 +8,11 @@ using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { + class RenderInfantryInfo : RenderSimpleInfo + { + public override object Create(Actor self) { return new RenderInfantry(self); } + } + class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage { public RenderInfantry(Actor self) diff --git a/OpenRa.Game/Traits/RenderUnitReload.cs b/OpenRa.Game/Traits/RenderUnitReload.cs index fe0c8c2f53..f1b67973e9 100644 --- a/OpenRa.Game/Traits/RenderUnitReload.cs +++ b/OpenRa.Game/Traits/RenderUnitReload.cs @@ -2,9 +2,9 @@ namespace OpenRa.Game.Traits { - class RenderUnitReloadInfo : ITraitInfo + class RenderUnitReloadInfo : RenderUnitInfo { - public object Create(Actor self) { return new RenderUnitReload(self); } + public override object Create(Actor self) { return new RenderUnitReload(self); } } class RenderUnitReload : RenderUnit diff --git a/OpenRa.Game/Traits/RenderUnitRotor.cs b/OpenRa.Game/Traits/RenderUnitRotor.cs index b2174a97c4..32ea23ad80 100755 --- a/OpenRa.Game/Traits/RenderUnitRotor.cs +++ b/OpenRa.Game/Traits/RenderUnitRotor.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class RenderUnitRotorInfo : RenderUnitInfo + { + public override object Create(Actor self) { return new RenderUnitRotor(self); } + } + class RenderUnitRotor : RenderUnit { public Animation rotorAnim, secondRotorAnim; diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index 38079af844..041fa20c78 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -4,7 +4,10 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { - class RenderUnitTurretedInfo : RenderUnitInfo { } + class RenderUnitTurretedInfo : RenderUnitInfo + { + public override object Create(Actor self) { return new RenderUnitTurreted(self); } + } class RenderUnitTurreted : RenderUnit { From c9d758c83447057874a6aa6db4352e2305f8341e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:40:49 +1300 Subject: [PATCH 19/83] Production.. --- OpenRa.Game/Traits/Production.cs | 5 +++++ OpenRa.Game/Traits/ProductionQueue.cs | 5 +++++ OpenRa.Game/Traits/ProductionSurround.cs | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 4cebf0f320..406109f882 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -4,6 +4,11 @@ using System.Collections.Generic; namespace OpenRa.Game.Traits { + class ProductionInfo : ITraitInfo + { + public object Create(Actor self) { return new Production(self); } + } + class Production : IIssueOrder, IResolveOrder, IProducer, ITags { bool isPrimary = false; diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index eabd106c8c..b5945c76ff 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -6,6 +6,11 @@ using IjwFramework.Collections; namespace OpenRa.Game.Traits { + class ProductionQueueInfo : ITraitInfo + { + public object Create(Actor self) { return new ProductionQueue(self); } + } + class ProductionQueue : IResolveOrder, ITick { Actor self; diff --git a/OpenRa.Game/Traits/ProductionSurround.cs b/OpenRa.Game/Traits/ProductionSurround.cs index 1c2f1d8327..39facf6cc8 100644 --- a/OpenRa.Game/Traits/ProductionSurround.cs +++ b/OpenRa.Game/Traits/ProductionSurround.cs @@ -6,6 +6,11 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class ProductionSurroundInfo : ITraitInfo + { + public object Create(Actor self) { return new ProductionSurround(self); } + } + class ProductionSurround : Production { public ProductionSurround(Actor self) : base(self) { } From 1c1b0be8bbf099d6bdf2e42eea6dcfbdd00ec10b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:47:31 +1300 Subject: [PATCH 20/83] StatelessTraitInfo --- OpenRa.Game/Traits/TraitsInterfaces.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index 440eda8a1f..1b0b8d7fc7 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -2,6 +2,7 @@ using System.Drawing; using OpenRa.Game.GameRules; using OpenRa.Game.Graphics; +using IjwFramework.Types; namespace OpenRa.Game.Traits { @@ -71,4 +72,12 @@ namespace OpenRa.Game.Traits } interface ITraitInfo { object Create(Actor self); } + + class StatelessTraitInfo : ITraitInfo + where T : new() + { + static Lazy Instance = Lazy.New(() => new T()); + public object Create(Actor self) { return Instance.Value; } + } + } From aeda044f834700409b949aa992c34cb0c411ee8e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:50:46 +1300 Subject: [PATCH 21/83] Helicopter.. --- OpenRa.Game/Traits/Helicopter.cs | 5 +++++ OpenRa.Game/Traits/InvisibleToOthers.cs | 5 +++++ OpenRa.Game/Traits/IronCurtain.cs | 5 +++++ OpenRa.Game/Traits/Mobile.cs | 1 + OpenRa.Game/Traits/Plane.cs | 5 +++++ 5 files changed, 21 insertions(+) diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 27d6143c8b..999bc6a68f 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -4,6 +4,11 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { + class HelicopterInfo : ITraitInfo + { + public object Create(Actor self) { return new Helicopter(self); } + } + class Helicopter : IIssueOrder, IResolveOrder, IMovement { public IDisposable reservation; diff --git a/OpenRa.Game/Traits/InvisibleToOthers.cs b/OpenRa.Game/Traits/InvisibleToOthers.cs index 46491a6766..969dc31d68 100644 --- a/OpenRa.Game/Traits/InvisibleToOthers.cs +++ b/OpenRa.Game/Traits/InvisibleToOthers.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class InvisibleToOthersInfo : ITraitInfo + { + public object Create(Actor self) { return new InvisibleToOthers(self); } + } + class InvisibleToOthers : IRenderModifier { public InvisibleToOthers(Actor self) { } diff --git a/OpenRa.Game/Traits/IronCurtain.cs b/OpenRa.Game/Traits/IronCurtain.cs index 668b469bd1..8126493e6e 100644 --- a/OpenRa.Game/Traits/IronCurtain.cs +++ b/OpenRa.Game/Traits/IronCurtain.cs @@ -5,6 +5,11 @@ using System.Text; namespace OpenRa.Game.Traits { + class IronCurtainInfo : ITraitInfo + { + public object Create(Actor self) { return new IronCurtain(self); } + } + class IronCurtain { public IronCurtain(Actor self) {} diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 3f753ac289..0e0efe835b 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits public readonly int Sight = 0; public readonly int ROT = 0; public readonly int Speed = 0; + public object Create(Actor self) { return new Mobile(self); } } diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 6b5c9827a3..cd4af54edd 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -6,6 +6,11 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class PlaneInfo : ITraitInfo + { + public object Create(Actor self) { return new Plane(self); } + } + class Plane : IIssueOrder, IResolveOrder, IMovement { public IDisposable reservation; From 367d1e776107ecd0954d4b9d7ad2713827110c32 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:52:35 +1300 Subject: [PATCH 22/83] EngineerCapture.. --- OpenRa.Game/Traits/EngineerCapture.cs | 5 +++++ OpenRa.Game/Traits/Fake.cs | 5 +++++ OpenRa.Game/Traits/GpsLaunchSite.cs | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/OpenRa.Game/Traits/EngineerCapture.cs b/OpenRa.Game/Traits/EngineerCapture.cs index 771e2a015a..f06873e662 100644 --- a/OpenRa.Game/Traits/EngineerCapture.cs +++ b/OpenRa.Game/Traits/EngineerCapture.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class EngineerCaptureInfo : ITraitInfo + { + public object Create(Actor self) { return new EngineerCapture(self); } + } + class EngineerCapture : IIssueOrder, IResolveOrder { public const int EngineerDamage = 300; // todo: push into rules, as a weapon diff --git a/OpenRa.Game/Traits/Fake.cs b/OpenRa.Game/Traits/Fake.cs index a14a0142ff..b62b4cfeee 100644 --- a/OpenRa.Game/Traits/Fake.cs +++ b/OpenRa.Game/Traits/Fake.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class FakeInfo : ITraitInfo + { + public object Create(Actor self) { return new Fake(self); } + } + class Fake : ITags { public Fake(Actor self){} diff --git a/OpenRa.Game/Traits/GpsLaunchSite.cs b/OpenRa.Game/Traits/GpsLaunchSite.cs index 639f5b93a1..1a7bfaa461 100644 --- a/OpenRa.Game/Traits/GpsLaunchSite.cs +++ b/OpenRa.Game/Traits/GpsLaunchSite.cs @@ -2,5 +2,10 @@ namespace OpenRa.Game.Traits { + class GpsLaunchSiteInfo : ITraitInfo + { + public object Create(Actor self) { return new GpsLaunchSite(self); } + } + class GpsLaunchSite { public GpsLaunchSite(Actor self) { } } } From 30bed96259c8c78331f4e0ea810348ccb644f504 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 13:55:22 +1300 Subject: [PATCH 23/83] ConstructionYard.. --- OpenRa.Game/Traits/ConstructionYard.cs | 5 +++++ OpenRa.Game/Traits/DemoTruck.cs | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/OpenRa.Game/Traits/ConstructionYard.cs b/OpenRa.Game/Traits/ConstructionYard.cs index 0dbcc76277..4d4368b21a 100644 --- a/OpenRa.Game/Traits/ConstructionYard.cs +++ b/OpenRa.Game/Traits/ConstructionYard.cs @@ -3,6 +3,11 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class ConstructionYardInfo : ITraitInfo + { + public object Create(Actor self) { return new ConstructionYard(self); } + } + class ConstructionYard : IIssueOrder, IResolveOrder, IMovement { readonly Actor self; diff --git a/OpenRa.Game/Traits/DemoTruck.cs b/OpenRa.Game/Traits/DemoTruck.cs index 53a3d86a1e..2659a3bb3e 100644 --- a/OpenRa.Game/Traits/DemoTruck.cs +++ b/OpenRa.Game/Traits/DemoTruck.cs @@ -6,14 +6,14 @@ using OpenRa.Game.Orders; namespace OpenRa.Game.Traits { + class DemoTruckInfo : ITraitInfo + { + public object Create(Actor self) { return new DemoTruck(self); } + } + class DemoTruck : Chronoshiftable, IResolveOrder, INotifyDamage { - readonly Actor self; - public DemoTruck(Actor self) - : base(self) - { - this.self = self; - } + public DemoTruck(Actor self) : base(self) {} public new void ResolveOrder(Actor self, Order order) { From 79ce6b70b6a126f25da5d9061729f4bbce34a3ee Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 14:03:21 +1300 Subject: [PATCH 24/83] new actor wiring for NewUnitInfo --- OpenRa.Game/Actor.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 1493fd8625..5bbba3e2fa 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -23,16 +23,6 @@ namespace OpenRa.Game public int Health; IActivity currentActivity; - object ConstructTrait(string traitName) - { - /* todo: allow mods to introduce traits */ - var type = typeof(Mobile).Assembly.GetType(typeof(Mobile).Namespace + "." + traitName, true, false); - var ctor = type.GetConstructor(new[] { typeof(Actor) }); - if (ctor == null) - throw new InvalidOperationException("Trait {0} does not have the correct constructor: {0}(Actor self)".F(type.Name)); - return ctor.Invoke(new object[] { this }); - } - public Actor( ActorInfo info, int2 location, Player owner ) { ActorID = Game.world.NextAID(); @@ -48,11 +38,8 @@ namespace OpenRa.Game if( Info.Traits == null ) throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) ); - //foreach (var traitName in Info.Traits) - // traits.Add(ConstructTrait(traitName)); - - foreach( var traitName in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.Keys ) - traits.Add( ConstructTrait( traitName ) ); + foreach (var trait in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.Values) + traits.Add(trait.Create(this)); } public void Tick() From be9fd1e277e48ceea0b756f5750d3e1816f1757e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 14:15:45 +1300 Subject: [PATCH 25/83] using StatelessTraitInfo<> for some things --- OpenRa.Game/Chrome.cs | 2 +- OpenRa.Game/Traits/Passenger.cs | 12 ++---------- OpenRa.Game/Traits/Plane.cs | 3 --- OpenRa.Game/Traits/Production.cs | 4 ++-- OpenRa.Game/Traits/ProductionSurround.cs | 5 +---- OpenRa.Game/Traits/ProvidesRadar.cs | 19 +++---------------- OpenRa.Game/Traits/RenderBuilding.cs | 2 -- OpenRa.Game/Traits/RenderBuildingCharge.cs | 6 +----- OpenRa.Game/Traits/RenderBuildingOre.cs | 3 +-- OpenRa.Game/Traits/RenderInfantry.cs | 8 +------- OpenRa.Game/Traits/RenderSimple.cs | 1 - OpenRa.Game/Traits/RenderUnitSpinner.cs | 4 +--- OpenRa.Game/Traits/RenderUnitTurreted.cs | 4 +--- OpenRa.Game/Traits/SeedsOre.cs | 7 +------ OpenRa.Game/Traits/Selectable.cs | 9 ++------- OpenRa.Game/Traits/StoresOre.cs | 6 +----- OpenRa.Game/Traits/Thief.cs | 7 +------ OpenRa.Game/Traits/WithShadow.cs | 7 +------ 18 files changed, 20 insertions(+), 89 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index e350f282f6..3033c1a2fc 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -198,7 +198,7 @@ namespace OpenRa.Game { var hasRadar = Game.world.Actors.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.traits.Get().IsActive()); + && a.traits.Get().IsActive(a)); if (hasRadar != hadRadar) Sound.Play((hasRadar) ? "radaron2.aud" : "radardn1.aud"); diff --git a/OpenRa.Game/Traits/Passenger.cs b/OpenRa.Game/Traits/Passenger.cs index 36cc0f3f5f..7a7305a060 100644 --- a/OpenRa.Game/Traits/Passenger.cs +++ b/OpenRa.Game/Traits/Passenger.cs @@ -1,20 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { - class PassengerInfo : ITraitInfo - { - public object Create(Actor self) { return new Passenger(self); } - } + class PassengerInfo : StatelessTraitInfo {} class Passenger : IIssueOrder, IResolveOrder { - public Passenger(Actor self) { } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button != MouseButton.Right) diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index cd4af54edd..17602323e3 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 406109f882..fa17b7fbff 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -1,6 +1,6 @@ -using OpenRa.Game.GameRules; +using System.Collections.Generic; using System.Linq; -using System.Collections.Generic; +using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { diff --git a/OpenRa.Game/Traits/ProductionSurround.cs b/OpenRa.Game/Traits/ProductionSurround.cs index 39facf6cc8..fb81449bb1 100644 --- a/OpenRa.Game/Traits/ProductionSurround.cs +++ b/OpenRa.Game/Traits/ProductionSurround.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits diff --git a/OpenRa.Game/Traits/ProvidesRadar.cs b/OpenRa.Game/Traits/ProvidesRadar.cs index db8b01fc4e..ec6c0c0536 100644 --- a/OpenRa.Game/Traits/ProvidesRadar.cs +++ b/OpenRa.Game/Traits/ProvidesRadar.cs @@ -1,24 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - + namespace OpenRa.Game.Traits { - class ProvidesRadarInfo : ITraitInfo - { - public object Create(Actor self) { return new ProvidesRadar(self); } - } + class ProvidesRadarInfo : StatelessTraitInfo {} class ProvidesRadar { - Actor self; - public ProvidesRadar(Actor self) - { - this.self = self; - } - - public bool IsActive() + public bool IsActive(Actor self) { // TODO: Check for nearby MRJ diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index d73b16915b..48e58af0ca 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using OpenRa.Game.Graphics; using OpenRa.Game.Effects; namespace OpenRa.Game.Traits diff --git a/OpenRa.Game/Traits/RenderBuildingCharge.cs b/OpenRa.Game/Traits/RenderBuildingCharge.cs index f76821b972..9c6b88efd5 100644 --- a/OpenRa.Game/Traits/RenderBuildingCharge.cs +++ b/OpenRa.Game/Traits/RenderBuildingCharge.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - + namespace OpenRa.Game.Traits { class RenderBuildingChargeInfo : RenderBuildingInfo diff --git a/OpenRa.Game/Traits/RenderBuildingOre.cs b/OpenRa.Game/Traits/RenderBuildingOre.cs index 0909475d78..1e06072a1e 100644 --- a/OpenRa.Game/Traits/RenderBuildingOre.cs +++ b/OpenRa.Game/Traits/RenderBuildingOre.cs @@ -1,5 +1,4 @@ -using System; - + namespace OpenRa.Game.Traits { class RenderBuildingOreInfo : RenderBuildingInfo diff --git a/OpenRa.Game/Traits/RenderInfantry.cs b/OpenRa.Game/Traits/RenderInfantry.cs index babf20589f..d3edc1ee33 100644 --- a/OpenRa.Game/Traits/RenderInfantry.cs +++ b/OpenRa.Game/Traits/RenderInfantry.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using OpenRa.Game.Graphics; -using OpenRa.Game.GameRules; -using OpenRa.Game.Effects; +using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 7975607053..4eb4570dad 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using IjwFramework.Collections; using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index 8dc54c535b..ab1212f97f 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -10,14 +10,12 @@ namespace OpenRa.Game.Traits class RenderUnitSpinner : RenderUnit { - public Animation spinnerAnim; - public RenderUnitSpinner( Actor self ) : base(self) { var unit = self.traits.Get(); - spinnerAnim = new Animation( self.Info.Name ); + var spinnerAnim = new Animation( self.Info.Name ); spinnerAnim.PlayRepeating( "spinner" ); anims.Add( "spinner", new AnimationWithOffset( spinnerAnim, diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index 041fa20c78..e88d9fd29a 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -11,8 +11,6 @@ namespace OpenRa.Game.Traits class RenderUnitTurreted : RenderUnit { - public Animation muzzleFlash; - public RenderUnitTurreted(Actor self) : base(self) { @@ -37,7 +35,7 @@ namespace OpenRa.Game.Traits if( self.Info.MuzzleFlash ) { - muzzleFlash = new Animation( self.Info.Name ); + var muzzleFlash = new Animation( self.Info.Name ); muzzleFlash.PlayFetchIndex( "muzzle", () => ( Util.QuantizeFacing( self.traits.Get().turretFacing, 8 ) ) * 6 + (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */ diff --git a/OpenRa.Game/Traits/SeedsOre.cs b/OpenRa.Game/Traits/SeedsOre.cs index f5dd4a123d..a722e3f858 100644 --- a/OpenRa.Game/Traits/SeedsOre.cs +++ b/OpenRa.Game/Traits/SeedsOre.cs @@ -1,15 +1,10 @@  namespace OpenRa.Game.Traits { - class SeedsOreInfo : ITraitInfo - { - public object Create(Actor self) { return new SeedsOre(self); } - } + class SeedsOreInfo : StatelessTraitInfo {} class SeedsOre : ITick { - public SeedsOre( Actor self ) {} - const double OreSeedProbability = .05; // todo: push this out into rules public void Tick(Actor self) diff --git a/OpenRa.Game/Traits/Selectable.cs b/OpenRa.Game/Traits/Selectable.cs index 85f8b01592..5e7a42c575 100755 --- a/OpenRa.Game/Traits/Selectable.cs +++ b/OpenRa.Game/Traits/Selectable.cs @@ -5,17 +5,12 @@ using System.Text; namespace OpenRa.Game.Traits { - class SelectableInfo : ITraitInfo + class SelectableInfo : StatelessTraitInfo { public readonly int Priority = 10; public readonly int[] Bounds = null; public readonly string Voice = "GenericVoice"; - - public object Create(Actor self) { return new Selectable(self); } } - class Selectable - { - public Selectable( Actor self ) { } - } + class Selectable {} } diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index fad732b83c..4fa5945e96 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -3,18 +3,14 @@ using System; using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { - class StoresOreInfo : ITraitInfo + class StoresOreInfo : StatelessTraitInfo { public readonly int Pips = 0; public readonly int Capacity = 0; - - public object Create(Actor self) { return new StoresOre(self); } } class StoresOre : IPips, IAcceptThief { - public StoresOre(Actor self) {} - public void OnSteal(Actor self, Actor thief) { // Steal half the ore the building holds diff --git a/OpenRa.Game/Traits/Thief.cs b/OpenRa.Game/Traits/Thief.cs index 591391a164..685ccefa68 100644 --- a/OpenRa.Game/Traits/Thief.cs +++ b/OpenRa.Game/Traits/Thief.cs @@ -3,15 +3,10 @@ using System.Collections.Generic; using System.Linq; namespace OpenRa.Game.Traits { - class ThiefInfo : ITraitInfo - { - public object Create(Actor self) { return new Thief(self); } - } + class ThiefInfo : StatelessTraitInfo { } class Thief : IIssueOrder, IResolveOrder { - public Thief(Actor self) { } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button != MouseButton.Right) return null; diff --git a/OpenRa.Game/Traits/WithShadow.cs b/OpenRa.Game/Traits/WithShadow.cs index 39153ba058..5eb49890bc 100644 --- a/OpenRa.Game/Traits/WithShadow.cs +++ b/OpenRa.Game/Traits/WithShadow.cs @@ -6,15 +6,10 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { - class WithShadowInfo : ITraitInfo - { - public object Create(Actor self) { return new WithShadow(self); } - } + class WithShadowInfo : StatelessTraitInfo {} class WithShadow : IRenderModifier { - public WithShadow(Actor self) {} - public IEnumerable ModifyRender(Actor self, IEnumerable r) { var unit = self.traits.Get(); From 9add15464cb69a0808a2e5c1263d3c574a9fb310 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 14:29:26 +1300 Subject: [PATCH 26/83] change NewUnitInfo to use a TypeDictionary --- OpenRa.Game/Actor.cs | 2 +- OpenRa.Game/GameRules/NewUnitInfo.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 5bbba3e2fa..95ec80365a 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -38,7 +38,7 @@ namespace OpenRa.Game if( Info.Traits == null ) throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) ); - foreach (var trait in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.Values) + foreach (var trait in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.WithInterface()) traits.Add(trait.Create(this)); } diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs index 4b660ad71d..3d80aba9f1 100755 --- a/OpenRa.Game/GameRules/NewUnitInfo.cs +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.GameRules class NewUnitInfo { public readonly string Parent; - public readonly Dictionary Traits; + public readonly TypeDictionary Traits = new TypeDictionary(); public NewUnitInfo( MiniYaml node ) { @@ -20,9 +20,8 @@ namespace OpenRa.Game.GameRules node.Nodes.Remove( "Inherits" ); } - Traits = node.Nodes.ToDictionary( - a => a.Key, - a => LoadTraitInfo( a.Key, a.Value )); + foreach (var t in node.Nodes) + Traits.Add(LoadTraitInfo(t.Key, t.Value)); } static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my) From 12b84a84686d1801073c9116578a6bc57d88d523 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 17:28:05 +1300 Subject: [PATCH 27/83] finished building *Infos --- OpenRa.Game/Chrome.cs | 2 +- OpenRa.Game/Game.cs | 6 +++--- OpenRa.Game/GameRules/Footprint.cs | 8 ++++---- OpenRa.Game/GameRules/Rules.cs | 4 ++-- OpenRa.Game/GameRules/TechTree.cs | 4 ++-- OpenRa.Game/GameRules/UnitInfo.cs | 4 ++-- .../Orders/PlaceBuildingOrderGenerator.cs | 4 ++-- OpenRa.Game/Orders/PowerDownOrderGenerator.cs | 2 +- OpenRa.Game/Orders/RepairOrderGenerator.cs | 2 +- OpenRa.Game/Orders/SellOrderGenerator.cs | 2 +- OpenRa.Game/Orders/UnitOrderGenerator.cs | 2 +- OpenRa.Game/Orders/UnitOrders.cs | 2 +- OpenRa.Game/Player.cs | 2 +- OpenRa.Game/Traits/APMine.cs | 11 +++++++---- OpenRa.Game/Traits/ATMine.cs | 10 ++++++---- OpenRa.Game/Traits/AcceptsOre.cs | 5 +++++ OpenRa.Game/Traits/Activities/HeliReturn.cs | 2 +- OpenRa.Game/Traits/AttackBase.cs | 4 +--- OpenRa.Game/Traits/AttackHeli.cs | 5 +++++ OpenRa.Game/Traits/AttackPlane.cs | 5 +++++ OpenRa.Game/Traits/AttackTurreted.cs | 7 +++++-- OpenRa.Game/Traits/AutoHeal.cs | 4 ++-- OpenRa.Game/Traits/AutoTarget.cs | 7 +------ OpenRa.Game/Traits/BelowUnits.cs | 4 ++-- OpenRa.Game/Traits/Buildable.cs | 9 ++------- OpenRa.Game/Traits/Building.cs | 9 +++++++-- OpenRa.Game/Traits/C4Demolition.cs | 4 ++-- OpenRa.Game/Traits/ChronoshiftDeploy.cs | 5 +++++ OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs | 3 +++ OpenRa.Game/Traits/Chronosphere.cs | 6 ++---- OpenRa.Game/Traits/Cloak.cs | 5 +++++ OpenRa.Game/Traits/EngineerCapture.cs | 7 +------ OpenRa.Game/Traits/Explodes.cs | 7 +------ OpenRa.Game/Traits/Fake.cs | 12 ++---------- OpenRa.Game/Traits/GpsLaunchSite.cs | 8 ++------ OpenRa.Game/Traits/Harvester.cs | 4 +--- OpenRa.Game/Traits/Helicopter.cs | 5 ++++- OpenRa.Game/Traits/InvisibleToOthers.cs | 7 +------ OpenRa.Game/Traits/IronCurtain.cs | 17 +++-------------- OpenRa.Game/Traits/IronCurtainable.cs | 4 +--- OpenRa.Game/Traits/McvDeploy.cs | 2 +- OpenRa.Game/Traits/MineImmune.cs | 11 ++--------- OpenRa.Game/Traits/Minelayer.cs | 16 ++++------------ OpenRa.Game/Traits/Plane.cs | 3 +++ OpenRa.Game/Traits/Production.cs | 6 +++--- OpenRa.Game/Traits/StoresOre.cs | 2 +- OpenRa.Game/Traits/WaterPaletteRotation.cs | 6 ++---- OpenRa.Game/UiOverlay.cs | 2 +- 48 files changed, 121 insertions(+), 147 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 3033c1a2fc..51cca4e4d2 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -647,7 +647,7 @@ namespace OpenRa.Game DrawRightAligned( "${0}".F(info.Cost), pos + new int2(-5,5), Game.LocalPlayer.Cash + Game.LocalPlayer.Ore >= info.Cost ? Color.White : Color.Red); - var bi = info as BuildingInfo; + var bi = info as LegacyBuildingInfo; if (bi != null) DrawRightAligned("ϟ{0}".F(bi.Power), pos + new int2(-5, 20), Game.LocalPlayer.PowerProvided - Game.LocalPlayer.PowerDrained + bi.Power >= 0 diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 271d636519..1fa4fac1ac 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -321,7 +321,7 @@ namespace OpenRa.Game public static Random SharedRandom = new Random(0); /* for things that require sync */ public static Random CosmeticRandom = new Random(); /* for things that are just fluff */ - public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) + public static bool CanPlaceBuilding(LegacyBuildingInfo building, int2 xy, Actor toIgnore, bool adjust) { return !Footprint.Tiles(building, xy, adjust).Any( t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t, @@ -329,7 +329,7 @@ namespace OpenRa.Game toIgnore)); } - public static bool IsCloseEnoughToBase(Player p, BuildingInfo bi, int2 position) + public static bool IsCloseEnoughToBase(Player p, LegacyBuildingInfo bi, int2 position) { var maxDistance = bi.Adjacent + 1; @@ -338,7 +338,7 @@ namespace OpenRa.Game heuristic = loc => { var b = Game.BuildingInfluence.GetBuildingAt(loc); - if (b != null && b.Owner == p && (b.Info as BuildingInfo).BaseNormal) return 0; + if (b != null && b.Owner == p && (b.Info as LegacyBuildingInfo).BaseNormal) return 0; if ((loc - position).Length > maxDistance) return float.PositiveInfinity; /* not quite right */ return 1; diff --git a/OpenRa.Game/GameRules/Footprint.cs b/OpenRa.Game/GameRules/Footprint.cs index 2a2311496d..3d740fd1d2 100644 --- a/OpenRa.Game/GameRules/Footprint.cs +++ b/OpenRa.Game/GameRules/Footprint.cs @@ -6,12 +6,12 @@ namespace OpenRa.Game.GameRules { static class Footprint { - public static IEnumerable Tiles( BuildingInfo buildingInfo, int2 position ) + public static IEnumerable Tiles( LegacyBuildingInfo buildingInfo, int2 position ) { return Tiles(buildingInfo, position, true); } - public static IEnumerable Tiles( BuildingInfo buildingInfo, int2 position, bool adjustForPlacement ) + public static IEnumerable Tiles( LegacyBuildingInfo buildingInfo, int2 position, bool adjustForPlacement ) { var dim = buildingInfo.Dimensions; @@ -33,7 +33,7 @@ namespace OpenRa.Game.GameRules return Tiles( building.unitInfo, a.Location, false ); } - public static IEnumerable UnpathableTiles( BuildingInfo buildingInfo, int2 position ) + public static IEnumerable UnpathableTiles( LegacyBuildingInfo buildingInfo, int2 position ) { var footprint = buildingInfo.Footprint.Where( x => !char.IsWhiteSpace( x ) ).ToArray(); foreach( var tile in TilesWhere( buildingInfo.Name, buildingInfo.Dimensions, footprint, a => a == 'x' ) ) @@ -52,7 +52,7 @@ namespace OpenRa.Game.GameRules yield return new int2( x, y ); } - public static int2 AdjustForBuildingSize( BuildingInfo unitInfo ) + public static int2 AdjustForBuildingSize( LegacyBuildingInfo unitInfo ) { var dim = unitInfo.Dimensions; return new int2( dim.X / 2, dim.Y > 1 ? ( dim.Y + 1 ) / 2 : 0 ); diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index fd5207b3d6..30c9781e35 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -65,8 +65,8 @@ namespace OpenRa.Game UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair(y, x.Key))).ToDictionary(x => x.Key, x => x.Value); UnitInfo = new InfoLoader( - Pair.New>("Building", s => new BuildingInfo(s)), - Pair.New>("Defense", s => new BuildingInfo(s)), + Pair.New>("Building", s => new LegacyBuildingInfo(s)), + Pair.New>("Defense", s => new LegacyBuildingInfo(s)), Pair.New>("Infantry", s => new InfantryInfo(s)), Pair.New>("Vehicle", s => new VehicleInfo(s)), Pair.New>("Ship", s => new VehicleInfo(s)), diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 354cc3a38a..8e8253f782 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -12,7 +12,7 @@ namespace OpenRa.Game.GameRules { foreach( var b in Rules.Categories[ "Building" ] ) { - var info = (BuildingInfo)Rules.UnitInfo[ b ]; + var info = (LegacyBuildingInfo)Rules.UnitInfo[ b ]; foreach( var p in info.Produces ) producesIndex[ p ].Add( info ); } @@ -21,7 +21,7 @@ namespace OpenRa.Game.GameRules public Cache> GatherBuildings( Player player ) { var ret = new Cache>( x => new List() ); - foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is BuildingInfo ) ) + foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is LegacyBuildingInfo ) ) ret[ b.Info.Name ].Add( b ); return ret; } diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index 8f06bf4193..e3daf1eb12 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -94,7 +94,7 @@ namespace OpenRa.Game.GameRules public VehicleInfo(string name) : base(name) { } } - public class BuildingInfo : LegacyUnitInfo + public class LegacyBuildingInfo : LegacyUnitInfo { public readonly int2 Dimensions = new int2(1, 1); public readonly string Footprint = "x"; @@ -112,6 +112,6 @@ namespace OpenRa.Game.GameRules public readonly int[] RallyPoint = { 1, 3 }; public readonly float[] SpawnOffset = null; - public BuildingInfo(string name) : base(name) { } + public LegacyBuildingInfo(string name) : base(name) { } } } diff --git a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs index 5c9d2b25fc..193f5872d0 100644 --- a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs @@ -6,12 +6,12 @@ namespace OpenRa.Game.Orders class PlaceBuildingOrderGenerator : IOrderGenerator { readonly Actor Producer; - readonly BuildingInfo Building; + readonly LegacyBuildingInfo Building; public PlaceBuildingOrderGenerator(Actor producer, string name) { Producer = producer; - Building = (BuildingInfo)Rules.UnitInfo[ name ]; + Building = (LegacyBuildingInfo)Rules.UnitInfo[ name ]; } public IEnumerable Order(int2 xy, MouseInput mi) diff --git a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs index 5779e81a20..5a33cbf1d0 100644 --- a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs +++ b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs @@ -27,7 +27,7 @@ namespace OpenRa.Game.Orders && a.traits.Contains() && a.Info.Selectable).FirstOrDefault(); - var building = underCursor != null ? underCursor.Info as BuildingInfo : null; + var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; if (building != null) yield return new Order("PowerDown", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/RepairOrderGenerator.cs b/OpenRa.Game/Orders/RepairOrderGenerator.cs index bc79d65ed4..84da77c725 100644 --- a/OpenRa.Game/Orders/RepairOrderGenerator.cs +++ b/OpenRa.Game/Orders/RepairOrderGenerator.cs @@ -27,7 +27,7 @@ namespace OpenRa.Game.Orders && a.traits.Contains() && a.Info.Selectable).FirstOrDefault(); - var building = underCursor != null ? underCursor.Info as BuildingInfo : null; + var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; if (building != null && building.Repairable && underCursor.Health < building.Strength) yield return new Order("Repair", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/SellOrderGenerator.cs b/OpenRa.Game/Orders/SellOrderGenerator.cs index 3576c59d1e..c46b459d55 100644 --- a/OpenRa.Game/Orders/SellOrderGenerator.cs +++ b/OpenRa.Game/Orders/SellOrderGenerator.cs @@ -27,7 +27,7 @@ namespace OpenRa.Game.Orders && a.traits.Contains() && a.Info.Selectable).FirstOrDefault(); - var building = underCursor != null ? underCursor.Info as BuildingInfo : null; + var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; if (building != null && !building.Unsellable) yield return new Order("Sell", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/UnitOrderGenerator.cs b/OpenRa.Game/Orders/UnitOrderGenerator.cs index 95ad375bbb..c578db1f34 100644 --- a/OpenRa.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRa.Game/Orders/UnitOrderGenerator.cs @@ -69,7 +69,7 @@ namespace OpenRa.Game.Orders else return Cursor.MoveBlocked; case "DeployMcv": - var factBuildingInfo = (BuildingInfo)Rules.UnitInfo["fact"]; + var factBuildingInfo = (LegacyBuildingInfo)Rules.UnitInfo["fact"]; if (Game.CanPlaceBuilding(factBuildingInfo, a.Location - new int2(1, 1), a, false)) return Cursor.Deploy; else diff --git a/OpenRa.Game/Orders/UnitOrders.cs b/OpenRa.Game/Orders/UnitOrders.cs index 6e11cfad3a..66646d787c 100644 --- a/OpenRa.Game/Orders/UnitOrders.cs +++ b/OpenRa.Game/Orders/UnitOrders.cs @@ -16,7 +16,7 @@ namespace OpenRa.Game.Orders Game.world.AddFrameEndTask( _ => { var queue = order.Player.PlayerActor.traits.Get(); - var building = (BuildingInfo)Rules.UnitInfo[ order.TargetString ]; + var building = (LegacyBuildingInfo)Rules.UnitInfo[ order.TargetString ]; var producing = queue.CurrentItem(Rules.UnitCategory[order.TargetString]); if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 ) return; diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index b4ff66fe75..9a162aa067 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -84,7 +84,7 @@ namespace OpenRa.Game { OreCapacity = Game.world.Actors .Where(a => a.Owner == this && a.traits.Contains()) - .Select(a => a.Info as BuildingInfo) + .Select(a => a.Info as LegacyBuildingInfo) .Where(b => b != null) .Sum(b => b.Storage); } diff --git a/OpenRa.Game/Traits/APMine.cs b/OpenRa.Game/Traits/APMine.cs index 41a6b3db9c..4d443321ed 100644 --- a/OpenRa.Game/Traits/APMine.cs +++ b/OpenRa.Game/Traits/APMine.cs @@ -1,10 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using OpenRa.Game.GameRules; +using System.Collections.Generic; using OpenRa.Game.Effects; + namespace OpenRa.Game.Traits { + class APMineInfo : ITraitInfo + { + public object Create(Actor self) { return new APMine(self); } + } + class APMine : ICrushable, IOccupySpace { readonly Actor self; diff --git a/OpenRa.Game/Traits/ATMine.cs b/OpenRa.Game/Traits/ATMine.cs index 9ee444195c..0a0bcda360 100644 --- a/OpenRa.Game/Traits/ATMine.cs +++ b/OpenRa.Game/Traits/ATMine.cs @@ -1,11 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using OpenRa.Game.GameRules; +using System.Collections.Generic; using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { + class ATMineInfo : ITraitInfo + { + public object Create(Actor self) { return new ATMine(self); } + } + class ATMine : ICrushable, IOccupySpace { readonly Actor self; diff --git a/OpenRa.Game/Traits/AcceptsOre.cs b/OpenRa.Game/Traits/AcceptsOre.cs index 49d6bc129a..6c8c200afa 100644 --- a/OpenRa.Game/Traits/AcceptsOre.cs +++ b/OpenRa.Game/Traits/AcceptsOre.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class AcceptsOreInfo : ITraitInfo + { + public object Create(Actor self) { return new AcceptsOre(self); } + } + class AcceptsOre { public AcceptsOre(Actor self) diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index 913ab24a84..6a26fc918b 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits.Activities if (res != null) self.traits.Get().reservation = res.Reserve(self); - var offset = (dest.Info as BuildingInfo).SpawnOffset; + var offset = (dest.Info as LegacyBuildingInfo).SpawnOffset; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; return Util.SequenceActivities( diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index ed8bfb08f3..4b99833445 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -8,9 +8,7 @@ namespace OpenRa.Game.Traits { class AttackBaseInfo : ITraitInfo { - - - public object Create(Actor self) { return new AttackBase(self); } + public virtual object Create(Actor self) { return new AttackBase(self); } } class AttackBase : IIssueOrder, IResolveOrder, ITick diff --git a/OpenRa.Game/Traits/AttackHeli.cs b/OpenRa.Game/Traits/AttackHeli.cs index 4749edc089..41d3fc2c51 100644 --- a/OpenRa.Game/Traits/AttackHeli.cs +++ b/OpenRa.Game/Traits/AttackHeli.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class AttackHeliInfo : AttackBaseInfo + { + public override object Create(Actor self) { return new AttackHeli(self); } + } + class AttackHeli : AttackFrontal { public AttackHeli(Actor self) : base(self, 20) { } diff --git a/OpenRa.Game/Traits/AttackPlane.cs b/OpenRa.Game/Traits/AttackPlane.cs index 05fad7ecb8..b4f4f9e02a 100644 --- a/OpenRa.Game/Traits/AttackPlane.cs +++ b/OpenRa.Game/Traits/AttackPlane.cs @@ -2,6 +2,11 @@ namespace OpenRa.Game.Traits { + class AttackPlaneInfo : AttackBaseInfo + { + public override object Create(Actor self) { return new AttackPlane(self); } + } + class AttackPlane : AttackFrontal { public AttackPlane(Actor self) : base(self, 20) { } diff --git a/OpenRa.Game/Traits/AttackTurreted.cs b/OpenRa.Game/Traits/AttackTurreted.cs index c574e309a8..dff7ff4001 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -3,11 +3,14 @@ using OpenRa.Game.GameRules; namespace OpenRa.Game.Traits { - class AttackTurretedInfo : AttackBaseInfo { } + class AttackTurretedInfo : AttackBaseInfo + { + public override object Create(Actor self) { return new AttackTurreted( self ); } + } class AttackTurreted : AttackBase, INotifyBuildComplete { - public AttackTurreted( Actor self ) : base(self) { self.traits.Get(); } + public AttackTurreted(Actor self) : base(self) { } public override void Tick(Actor self) { diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index 61018ed3cd..eb882df245 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -3,10 +3,10 @@ using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { + class AutoHealInfo : StatelessTraitInfo { } + class AutoHeal : ITick { - public AutoHeal(Actor self) { } - void AttackTarget(Actor self, Actor target) { var attack = self.traits.WithInterface().First(); diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 94e66aeeaf..0906fac297 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -2,15 +2,10 @@ namespace OpenRa.Game.Traits { - class AutoTargetInfo : ITraitInfo - { - public object Create(Actor self) { return new AutoTarget(self); } - } + class AutoTargetInfo : StatelessTraitInfo { } class AutoTarget : ITick, INotifyDamage { - public AutoTarget(Actor self) {} - void AttackTarget(Actor self, Actor target) { var attack = self.traits.WithInterface().First(); diff --git a/OpenRa.Game/Traits/BelowUnits.cs b/OpenRa.Game/Traits/BelowUnits.cs index 7bc4d84681..f5d82d6727 100644 --- a/OpenRa.Game/Traits/BelowUnits.cs +++ b/OpenRa.Game/Traits/BelowUnits.cs @@ -3,10 +3,10 @@ using System.Linq; namespace OpenRa.Game.Traits { + class BelowUnitsInfo : StatelessTraitInfo { } + class BelowUnits : IRenderModifier { - public BelowUnits(Actor self) { } - public IEnumerable ModifyRender(Actor self, IEnumerable r) { return r.Select(a => a.WithZOffset(-1)); diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs index 25eec93980..273fdf1d97 100755 --- a/OpenRa.Game/Traits/Buildable.cs +++ b/OpenRa.Game/Traits/Buildable.cs @@ -5,7 +5,7 @@ using System.Text; namespace OpenRa.Game.Traits { - class BuildableInfo : ITraitInfo + class BuildableInfo : StatelessTraitInfo { public readonly int TechLevel = -1; public readonly string Tab = null; @@ -15,12 +15,7 @@ namespace OpenRa.Game.Traits public readonly string Description = ""; public readonly string LongDesc = ""; public readonly string Icon = null; - - public object Create(Actor self) { return new Buildable(self); } } - class Buildable - { - public Buildable( Actor self ) { } - } + class Buildable { } } diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 1fa3538314..2e7b204008 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -9,10 +9,15 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class BuildingInfo : ITraitInfo + { + public object Create(Actor self) { return new Building(self); } + } + class Building : INotifyDamage, IResolveOrder, ITick { readonly Actor self; - public readonly BuildingInfo unitInfo; + public readonly LegacyBuildingInfo unitInfo; [Sync] bool isRepairing = false; [Sync] @@ -24,7 +29,7 @@ namespace OpenRa.Game.Traits public Building(Actor self) { this.self = self; - unitInfo = (BuildingInfo)self.Info; + unitInfo = (LegacyBuildingInfo)self.Info; self.CenterLocation = Game.CellSize * ((float2)self.Location + .5f * (float2)unitInfo.Dimensions); } diff --git a/OpenRa.Game/Traits/C4Demolition.cs b/OpenRa.Game/Traits/C4Demolition.cs index e6b75178b2..68ae518333 100644 --- a/OpenRa.Game/Traits/C4Demolition.cs +++ b/OpenRa.Game/Traits/C4Demolition.cs @@ -2,10 +2,10 @@ namespace OpenRa.Game.Traits { + class C4DemolitionInfo : StatelessTraitInfo { } + class C4Demolition : IIssueOrder, IResolveOrder { - public C4Demolition(Actor self) { } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button != MouseButton.Right) return null; diff --git a/OpenRa.Game/Traits/ChronoshiftDeploy.cs b/OpenRa.Game/Traits/ChronoshiftDeploy.cs index 2cc8a2a9a4..08c24000ba 100644 --- a/OpenRa.Game/Traits/ChronoshiftDeploy.cs +++ b/OpenRa.Game/Traits/ChronoshiftDeploy.cs @@ -4,6 +4,11 @@ using OpenRa.Game.Orders; namespace OpenRa.Game.Traits { + class ChronoshiftDeployInfo : ITraitInfo + { + public object Create(Actor self) { return new ChronoshiftDeploy(self); } + } + class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ISpeedModifier, ITick, IPips { // Recharge logic diff --git a/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs b/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs index 36a4f0e40c..dc2ef912e2 100644 --- a/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs +++ b/OpenRa.Game/Traits/ChronoshiftPaletteEffect.cs @@ -3,6 +3,9 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + // this is NOT bound through rules (it belongs on the world actor!) + // so no *Info required + class ChronoshiftPaletteEffect : IPaletteModifier, ITick { const int chronoEffectLength = 20; diff --git a/OpenRa.Game/Traits/Chronosphere.cs b/OpenRa.Game/Traits/Chronosphere.cs index cad8a1cf13..34f660a014 100644 --- a/OpenRa.Game/Traits/Chronosphere.cs +++ b/OpenRa.Game/Traits/Chronosphere.cs @@ -5,8 +5,6 @@ using System.Text; namespace OpenRa.Game.Traits { - class Chronosphere - { - public Chronosphere(Actor self) { } - } + class ChronosphereInfo : StatelessTraitInfo { } + class Chronosphere { } } diff --git a/OpenRa.Game/Traits/Cloak.cs b/OpenRa.Game/Traits/Cloak.cs index 5b225438d6..b782d854e1 100644 --- a/OpenRa.Game/Traits/Cloak.cs +++ b/OpenRa.Game/Traits/Cloak.cs @@ -4,6 +4,11 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { + class CloakInfo : ITraitInfo + { + public object Create(Actor self) { return new Cloak(self); } + } + class Cloak : IRenderModifier, INotifyAttack, ITick { [Sync] diff --git a/OpenRa.Game/Traits/EngineerCapture.cs b/OpenRa.Game/Traits/EngineerCapture.cs index f06873e662..efc03dc6cd 100644 --- a/OpenRa.Game/Traits/EngineerCapture.cs +++ b/OpenRa.Game/Traits/EngineerCapture.cs @@ -2,17 +2,12 @@ namespace OpenRa.Game.Traits { - class EngineerCaptureInfo : ITraitInfo - { - public object Create(Actor self) { return new EngineerCapture(self); } - } + class EngineerCaptureInfo : StatelessTraitInfo { } class EngineerCapture : IIssueOrder, IResolveOrder { public const int EngineerDamage = 300; // todo: push into rules, as a weapon - public EngineerCapture(Actor self) { } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { if (mi.Button != MouseButton.Right) return null; diff --git a/OpenRa.Game/Traits/Explodes.cs b/OpenRa.Game/Traits/Explodes.cs index 712ded0e4f..2b058de917 100644 --- a/OpenRa.Game/Traits/Explodes.cs +++ b/OpenRa.Game/Traits/Explodes.cs @@ -2,15 +2,10 @@ namespace OpenRa.Game.Traits { - class ExplodesInfo : ITraitInfo - { - public object Create(Actor self) { return new Explodes(self); } - } + class ExplodesInfo : StatelessTraitInfo { } class Explodes : INotifyDamage { - public Explodes(Actor self) {} - public void Damaged(Actor self, AttackInfo e) { if (self.IsDead) diff --git a/OpenRa.Game/Traits/Fake.cs b/OpenRa.Game/Traits/Fake.cs index b62b4cfeee..9eb9127856 100644 --- a/OpenRa.Game/Traits/Fake.cs +++ b/OpenRa.Game/Traits/Fake.cs @@ -2,18 +2,10 @@ namespace OpenRa.Game.Traits { - class FakeInfo : ITraitInfo - { - public object Create(Actor self) { return new Fake(self); } - } + class FakeInfo : StatelessTraitInfo { } class Fake : ITags { - public Fake(Actor self){} - - public IEnumerable GetTags() - { - yield return TagType.Fake; - } + public IEnumerable GetTags() { yield return TagType.Fake; } } } diff --git a/OpenRa.Game/Traits/GpsLaunchSite.cs b/OpenRa.Game/Traits/GpsLaunchSite.cs index 1a7bfaa461..ed10b56620 100644 --- a/OpenRa.Game/Traits/GpsLaunchSite.cs +++ b/OpenRa.Game/Traits/GpsLaunchSite.cs @@ -2,10 +2,6 @@ namespace OpenRa.Game.Traits { - class GpsLaunchSiteInfo : ITraitInfo - { - public object Create(Actor self) { return new GpsLaunchSite(self); } - } - - class GpsLaunchSite { public GpsLaunchSite(Actor self) { } } + class GpsLaunchSiteInfo : StatelessTraitInfo { } + class GpsLaunchSite { } } diff --git a/OpenRa.Game/Traits/Harvester.cs b/OpenRa.Game/Traits/Harvester.cs index 4d038d93c9..d9f72f592f 100644 --- a/OpenRa.Game/Traits/Harvester.cs +++ b/OpenRa.Game/Traits/Harvester.cs @@ -5,7 +5,7 @@ namespace OpenRa.Game.Traits { class HarvesterInfo : ITraitInfo { - public object Create(Actor self) { return new Harvester(self); } + public object Create(Actor self) { return new Harvester(); } } class Harvester : IIssueOrder, IResolveOrder, IPips @@ -18,8 +18,6 @@ namespace OpenRa.Game.Traits public bool IsFull { get { return oreCarried + gemsCarried == Rules.General.BailCount; } } public bool IsEmpty { get { return oreCarried == 0 && gemsCarried == 0; } } - public Harvester(Actor self) { } - public void AcceptResource(bool isGem) { if (isGem) gemsCarried++; diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 999bc6a68f..8477103c63 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -6,6 +6,9 @@ namespace OpenRa.Game.Traits { class HelicopterInfo : ITraitInfo { + public readonly int ROT = 0; + public readonly int Speed = 0; + public object Create(Actor self) { return new Helicopter(self); } } @@ -60,7 +63,7 @@ namespace OpenRa.Game.Traits if (res != null) reservation = res.Reserve(self); - var offset = (order.TargetActor.Info as BuildingInfo).SpawnOffset; + var offset = (order.TargetActor.Info as LegacyBuildingInfo).SpawnOffset; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; self.CancelActivity(); diff --git a/OpenRa.Game/Traits/InvisibleToOthers.cs b/OpenRa.Game/Traits/InvisibleToOthers.cs index 969dc31d68..dab24dfc59 100644 --- a/OpenRa.Game/Traits/InvisibleToOthers.cs +++ b/OpenRa.Game/Traits/InvisibleToOthers.cs @@ -2,15 +2,10 @@ namespace OpenRa.Game.Traits { - class InvisibleToOthersInfo : ITraitInfo - { - public object Create(Actor self) { return new InvisibleToOthers(self); } - } + class InvisibleToOthersInfo : StatelessTraitInfo { } class InvisibleToOthers : IRenderModifier { - public InvisibleToOthers(Actor self) { } - public IEnumerable ModifyRender(Actor self, IEnumerable r) { return Game.LocalPlayer == self.Owner diff --git a/OpenRa.Game/Traits/IronCurtain.cs b/OpenRa.Game/Traits/IronCurtain.cs index 8126493e6e..5ea72102c8 100644 --- a/OpenRa.Game/Traits/IronCurtain.cs +++ b/OpenRa.Game/Traits/IronCurtain.cs @@ -1,17 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - + namespace OpenRa.Game.Traits { - class IronCurtainInfo : ITraitInfo - { - public object Create(Actor self) { return new IronCurtain(self); } - } - - class IronCurtain - { - public IronCurtain(Actor self) {} - } + class IronCurtainInfo : StatelessTraitInfo { } + class IronCurtain { } } diff --git a/OpenRa.Game/Traits/IronCurtainable.cs b/OpenRa.Game/Traits/IronCurtainable.cs index 45344f3c34..e00474fdd1 100644 --- a/OpenRa.Game/Traits/IronCurtainable.cs +++ b/OpenRa.Game/Traits/IronCurtainable.cs @@ -5,7 +5,7 @@ namespace OpenRa.Game.Traits { class IronCurtainableInfo : ITraitInfo { - public object Create(Actor self) { return new IronCurtain(self); } + public object Create(Actor self) { return new IronCurtainable(); } } class IronCurtainable : IResolveOrder, IDamageModifier, ITick @@ -13,8 +13,6 @@ namespace OpenRa.Game.Traits [Sync] int RemainingTicks = 0; - public IronCurtainable(Actor self) { } - public void Tick(Actor self) { if (RemainingTicks > 0) diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index 5b5cb880b1..20221549a3 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits { if( order.OrderString == "DeployMcv" ) { - var factBuildingInfo = (BuildingInfo)Rules.UnitInfo[ "fact" ]; + var factBuildingInfo = (LegacyBuildingInfo)Rules.UnitInfo[ "fact" ]; if( Game.CanPlaceBuilding( factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) ) { self.CancelActivity(); diff --git a/OpenRa.Game/Traits/MineImmune.cs b/OpenRa.Game/Traits/MineImmune.cs index f82acf08c4..04f488a096 100644 --- a/OpenRa.Game/Traits/MineImmune.cs +++ b/OpenRa.Game/Traits/MineImmune.cs @@ -1,13 +1,6 @@  namespace OpenRa.Game.Traits { - class MineImmuneInfo : ITraitInfo - { - public object Create(Actor self) { return new MineImmune(self); } - } - - class MineImmune - { - public MineImmune(Actor self) { } - } + class MineImmuneInfo : StatelessTraitInfo { } + class MineImmune { } } diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index 7fe567bd2b..1012998d5e 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -1,27 +1,19 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; namespace OpenRa.Game.Traits { - class MinelayerInfo : ITraitInfo - { - public object Create(Actor self) { return new Minelayer(self); } - } + class MinelayerInfo : StatelessTraitInfo { } class Minelayer : IIssueOrder, IResolveOrder { - public Minelayer(Actor self) { } - public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) { var limitedAmmo = self.traits.GetOrDefault(); if (limitedAmmo != null && !limitedAmmo.HasAmmo()) return null; - + // Ensure that the cell is empty except for the minelayer - if (Game.UnitInfluence.GetUnitsAt( xy ).Any(a => a != self)) + if (Game.UnitInfluence.GetUnitsAt(xy).Any(a => a != self)) return null; if (mi.Button == MouseButton.Right && underCursor == self) diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 17602323e3..27030b4705 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -5,6 +5,9 @@ namespace OpenRa.Game.Traits { class PlaneInfo : ITraitInfo { + public readonly int ROT = 0; + public readonly int Speed = 0; + public object Create(Actor self) { return new Plane(self); } } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index fa17b7fbff..1a6a270a94 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -43,7 +43,7 @@ namespace OpenRa.Game.Traits newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) ); } - var bi = self.Info as BuildingInfo; + var bi = self.Info as LegacyBuildingInfo; if (bi != null && bi.SpawnOffset != null) newUnit.CenterLocation = self.CenterLocation + new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]); @@ -83,12 +83,12 @@ namespace OpenRa.Game.Traits } // Cancel existing primaries - foreach (var p in (self.Info as BuildingInfo).Produces) + foreach (var p in (self.Info as LegacyBuildingInfo).Produces) { foreach (var b in Game.world.Actors.Where(x => x.traits.Contains() && x.Owner == self.Owner && x.traits.Get().IsPrimary == true - && (x.Info as BuildingInfo).Produces.Contains(p))) + && (x.Info as LegacyBuildingInfo).Produces.Contains(p))) { b.traits.Get().SetPrimaryProducer(b, false); } diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index 4fa5945e96..5630ef83c3 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits public void OnSteal(Actor self, Actor thief) { // Steal half the ore the building holds - var toSteal = (self.Info as BuildingInfo).Storage/2; + var toSteal = (self.Info as LegacyBuildingInfo).Storage/2; self.Owner.TakeCash(toSteal); thief.Owner.GiveCash(toSteal); diff --git a/OpenRa.Game/Traits/WaterPaletteRotation.cs b/OpenRa.Game/Traits/WaterPaletteRotation.cs index 7c5a5eacf9..cba52f71a5 100644 --- a/OpenRa.Game/Traits/WaterPaletteRotation.cs +++ b/OpenRa.Game/Traits/WaterPaletteRotation.cs @@ -2,10 +2,8 @@ namespace OpenRa.Game.Traits { - class WaterPaletteRotationInfo : ITraitInfo - { - public object Create(Actor self) { return new WaterPaletteRotation(self); } - } + // this is NOT bound through rules (it belongs on the world actor!) + // so no *Info required class WaterPaletteRotation : ITick, IPaletteModifier { diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index 0dfc1272cc..7a0e4c8c29 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -42,7 +42,7 @@ namespace OpenRa.Game spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0); } - public void DrawBuildingGrid( BuildingInfo bi ) + public void DrawBuildingGrid( LegacyBuildingInfo bi ) { var position = Game.controller.MousePosition.ToInt2(); var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, bi, position); From 74a2ed9624f833d13440c367cbd51fdcc019f562 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 17:32:14 +1300 Subject: [PATCH 28/83] more conversion changes. --- RulesConverter/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index cb1089223b..358a3871d4 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -98,7 +98,11 @@ namespace RulesConverter { "Repairable", "Repairable" }, { "BaseNormal", "BaseNormal" }, { "Adjacent", "Adjacent" }, - { "Bib", "Bib" } } + { "Bib", "Bib" }, + { "HP", "Strength" }, + { "Armor", "Armor" }, + { "Crewed", "Crewed" }, + { "WaterBound", "WaterBound" } } }, { "StoresOre", new PL { From 99a61ca8d92a78f42e5844925b3f58e36cdf28b0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 18:28:24 +1300 Subject: [PATCH 29/83] renamed Info to LegacyInfo, marked Obsolete. added NewUnitInfo ref as Info. --- OpenRa.Game/Actor.cs | 35 +++++++++++-------- OpenRa.Game/Combat.cs | 14 ++++---- OpenRa.Game/Effects/Corpse.cs | 2 +- OpenRa.Game/Game.cs | 8 ++--- OpenRa.Game/GameRules/TechTree.cs | 4 +-- OpenRa.Game/Graphics/Viewport.cs | 2 +- OpenRa.Game/Graphics/WorldRenderer.cs | 2 +- .../ChronosphereSelectOrderGenerator.cs | 4 +-- .../Orders/IronCurtainOrderGenerator.cs | 4 +-- OpenRa.Game/Orders/PowerDownOrderGenerator.cs | 4 +-- OpenRa.Game/Orders/RepairOrderGenerator.cs | 4 +-- OpenRa.Game/Orders/SellOrderGenerator.cs | 4 +-- OpenRa.Game/Player.cs | 2 +- OpenRa.Game/Shroud.cs | 2 +- OpenRa.Game/Sound.cs | 2 +- .../Traits/Activities/CaptureBuilding.cs | 2 +- OpenRa.Game/Traits/Activities/Fly.cs | 2 +- OpenRa.Game/Traits/Activities/HeliAttack.cs | 4 +-- OpenRa.Game/Traits/Activities/HeliFly.cs | 2 +- OpenRa.Game/Traits/Activities/HeliReturn.cs | 8 ++--- OpenRa.Game/Traits/Activities/Land.cs | 2 +- OpenRa.Game/Traits/Activities/Repair.cs | 6 ++-- OpenRa.Game/Traits/Activities/ReturnToBase.cs | 4 +-- OpenRa.Game/Traits/Activities/Sell.cs | 2 +- OpenRa.Game/Traits/Activities/Turn.cs | 2 +- OpenRa.Game/Traits/Activities/UnloadCargo.cs | 4 +-- OpenRa.Game/Traits/AttackBase.cs | 20 +++++------ OpenRa.Game/Traits/AttackTurreted.cs | 2 +- OpenRa.Game/Traits/AutoHeal.cs | 6 ++-- OpenRa.Game/Traits/AutoTarget.cs | 2 +- OpenRa.Game/Traits/Building.cs | 8 ++--- OpenRa.Game/Traits/Cargo.cs | 4 +-- OpenRa.Game/Traits/DemoTruck.cs | 2 +- OpenRa.Game/Traits/Helicopter.cs | 12 +++---- OpenRa.Game/Traits/LimitedAmmo.cs | 6 ++-- OpenRa.Game/Traits/Minelayer.cs | 2 +- OpenRa.Game/Traits/Mobile.cs | 4 +-- OpenRa.Game/Traits/Passenger.cs | 2 +- OpenRa.Game/Traits/Plane.cs | 6 ++-- OpenRa.Game/Traits/Production.cs | 8 ++--- OpenRa.Game/Traits/ProductionQueue.cs | 4 +-- .../Traits/RenderBuildingWarFactory.cs | 2 +- OpenRa.Game/Traits/RenderSimple.cs | 2 +- OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs | 6 ++-- OpenRa.Game/Traits/RenderUnitRotor.cs | 10 +++--- OpenRa.Game/Traits/RenderUnitSpinner.cs | 4 +-- OpenRa.Game/Traits/RenderUnitTurreted.cs | 16 ++++----- OpenRa.Game/Traits/Repairable.cs | 2 +- OpenRa.Game/Traits/StoresOre.cs | 6 ++-- OpenRa.Game/Traits/Turreted.cs | 4 +-- OpenRa.Game/Traits/Util.cs | 6 ++-- OpenRa.Game/UnitInfluenceMap.cs | 2 +- 52 files changed, 142 insertions(+), 137 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 95ec80365a..51b31518a2 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -12,7 +12,10 @@ namespace OpenRa.Game { [Sync] public readonly TypeDictionary traits = new TypeDictionary(); - public readonly LegacyUnitInfo Info; + + [Obsolete] + public readonly LegacyUnitInfo LegacyInfo; + public readonly NewUnitInfo Info; public readonly uint ActorID; [Sync] @@ -26,19 +29,21 @@ namespace OpenRa.Game public Actor( ActorInfo info, int2 location, Player owner ) { ActorID = Game.world.NextAID(); - Info = (LegacyUnitInfo)info; // temporary + LegacyInfo = (LegacyUnitInfo)info; // temporary Location = location; CenterLocation = Traits.Util.CenterOfCell(Location); Owner = owner; - if (Info == null) return; + if (LegacyInfo == null) return; - Health = Info.Strength; /* todo: fix walls, etc so this is always true! */ + Health = LegacyInfo.Strength; /* todo: fix walls, etc so this is always true! */ - if( Info.Traits == null ) - throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(Info.Name) ); + if( LegacyInfo.Traits == null ) + throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(LegacyInfo.Name) ); - foreach (var trait in Rules.NewUnitInfo[Info.Name.ToLower()].Traits.WithInterface()) + Info = Rules.NewUnitInfo[LegacyInfo.Name.ToLowerInvariant()]; + + foreach (var trait in Info.Traits.WithInterface()) traits.Add(trait.Create(this)); } @@ -65,8 +70,8 @@ namespace OpenRa.Game { get { - if (Info != null && Info.SelectionSize != null) - return new float2(Info.SelectionSize[0], Info.SelectionSize[1]); + if (LegacyInfo != null && LegacyInfo.SelectionSize != null) + return new float2(LegacyInfo.SelectionSize[0], LegacyInfo.SelectionSize[1]); var firstSprite = Render().FirstOrDefault(); if (firstSprite.Sprite == null) return float2.Zero; @@ -92,7 +97,7 @@ namespace OpenRa.Game var loc = mi.Location + Game.viewport.Location; var underCursor = Game.FindUnits(loc, loc).FirstOrDefault(); - if (underCursor != null && !underCursor.Info.Selectable) + if (underCursor != null && !underCursor.LegacyInfo.Selectable) underCursor = null; return traits.WithInterface() @@ -104,8 +109,8 @@ namespace OpenRa.Game { var size = SelectedSize; var loc = CenterLocation - 0.5f * size; - if (Info != null && Info.SelectionSize != null && Info.SelectionSize.Length > 2) - loc += new float2(Info.SelectionSize[2], Info.SelectionSize[3]); + if (LegacyInfo != null && LegacyInfo.SelectionSize != null && LegacyInfo.SelectionSize.Length > 2) + loc += new float2(LegacyInfo.SelectionSize[2], LegacyInfo.SelectionSize[3]); if (useAltitude) { @@ -122,7 +127,7 @@ namespace OpenRa.Game public DamageState GetDamageState() { if (Health <= 0) return DamageState.Dead; - var halfStrength = Info.Strength * Rules.General.ConditionYellow; + var halfStrength = LegacyInfo.Strength * Rules.General.ConditionYellow; return Health < halfStrength ? DamageState.Half : DamageState.Normal; } @@ -145,8 +150,8 @@ namespace OpenRa.Game Game.world.AddFrameEndTask(w => w.Remove(this)); } - if (Health > Info.Strength) - Health = Info.Strength; + if (Health > LegacyInfo.Strength) + Health = LegacyInfo.Strength; var newState = GetDamageState(); diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index b6cb373754..e8100a5495 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -49,7 +49,7 @@ namespace OpenRa.Game var distance = (target.CenterLocation - loc).Length*1/24f; var rawDamage = weapon.Damage * (float)Math.Exp(-distance / warhead.Spread); - var multiplier = warhead.EffectivenessAgainst(target.Info.Armor); + var multiplier = warhead.EffectivenessAgainst(target.LegacyInfo.Armor); return rawDamage * multiplier; } @@ -59,7 +59,7 @@ namespace OpenRa.Game var warhead = Rules.WarheadInfo[weapon.Warhead]; var unit = target.traits.GetOrDefault(); - if (warhead.EffectivenessAgainst(target.Info.Armor) <= 0) + if (warhead.EffectivenessAgainst(target.LegacyInfo.Armor) <= 0) return false; if (target.traits.Contains()) @@ -68,7 +68,7 @@ namespace OpenRa.Game if (unit != null && unit.Altitude > 0) return projectile.AA; - if (projectile.UnderWater && !target.Info.WaterBound) + if (projectile.UnderWater && !target.LegacyInfo.WaterBound) return false; return projectile.AG; @@ -76,10 +76,10 @@ namespace OpenRa.Game public static bool HasAnyValidWeapons(Actor self, Actor target) { - if (self.Info.Primary != null && - WeaponValidForTarget(Rules.WeaponInfo[self.Info.Primary], target)) return true; - if (self.Info.Secondary != null && - WeaponValidForTarget(Rules.WeaponInfo[self.Info.Secondary], target)) return true; + if (self.LegacyInfo.Primary != null && + WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Primary], target)) return true; + if (self.LegacyInfo.Secondary != null && + WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Secondary], target)) return true; return false; } diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs index efdbf8cb4c..f37a1116b3 100755 --- a/OpenRa.Game/Effects/Corpse.cs +++ b/OpenRa.Game/Effects/Corpse.cs @@ -15,7 +15,7 @@ namespace OpenRa.Game.Effects public Corpse(Actor fromActor, int death) { - anim = new Animation(fromActor.Info.Image ?? fromActor.Info.Name); + anim = new Animation(fromActor.LegacyInfo.Image ?? fromActor.LegacyInfo.Name); anim.PlayThen("die{0}".F(death + 1), () => Game.world.AddFrameEndTask(w => w.Remove(this))); diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 1fa4fac1ac..38b24f3c4c 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -61,7 +61,7 @@ namespace OpenRa.Game world = new World(); Game.world.ActorAdded += a => { - if (a.Owner != null && a.Info != null) + if (a.Owner != null && a.LegacyInfo != null) a.Owner.Shroud.Explore(a); }; @@ -310,8 +310,8 @@ namespace OpenRa.Game public static IEnumerable SelectActorsInBox(float2 a, float2 b) { return FindUnits(a, b) - .Where( x => x.Info.Selectable ) - .GroupBy(x => (x.Owner == LocalPlayer) ? x.Info.SelectionPriority : 0) + .Where( x => x.LegacyInfo.Selectable ) + .GroupBy(x => (x.Owner == LocalPlayer) ? x.LegacyInfo.SelectionPriority : 0) .OrderByDescending(g => g.Key) .Select( g => g.AsEnumerable() ) .DefaultIfEmpty( new Actor[] {} ) @@ -338,7 +338,7 @@ namespace OpenRa.Game heuristic = loc => { var b = Game.BuildingInfluence.GetBuildingAt(loc); - if (b != null && b.Owner == p && (b.Info as LegacyBuildingInfo).BaseNormal) return 0; + if (b != null && b.Owner == p && (b.LegacyInfo as LegacyBuildingInfo).BaseNormal) return 0; if ((loc - position).Length > maxDistance) return float.PositiveInfinity; /* not quite right */ return 1; diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 8e8253f782..c732f7819d 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -21,8 +21,8 @@ namespace OpenRa.Game.GameRules public Cache> GatherBuildings( Player player ) { var ret = new Cache>( x => new List() ); - foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info is LegacyBuildingInfo ) ) - ret[ b.Info.Name ].Add( b ); + foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.LegacyInfo is LegacyBuildingInfo ) ) + ret[ b.LegacyInfo.Name ].Add( b ); return ret; } diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 9a35a4ef5b..5af11ba1d5 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -97,7 +97,7 @@ namespace OpenRa.Game.Graphics public void GoToStartLocation() { - Center(Game.world.Actors.Where(a => a.Info != null && a.Owner == Game.LocalPlayer)); + Center(Game.world.Actors.Where(a => a.LegacyInfo != null && a.Owner == Game.LocalPlayer)); } } } diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 1060f5467a..4223cb2de1 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -169,7 +169,7 @@ namespace OpenRa.Game.Graphics lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c); lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c); - var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Strength; + var healthAmount = (float)selectedUnit.Health / selectedUnit.LegacyInfo.Strength; var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs index b4a013b15a..889965abbc 100644 --- a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs @@ -31,9 +31,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.WithInterface().Any() - && a.Info.Selectable).FirstOrDefault(); + && a.LegacyInfo.Selectable).FirstOrDefault(); - var unit = underCursor != null ? underCursor.Info as LegacyUnitInfo : null; + var unit = underCursor != null ? underCursor.LegacyInfo as LegacyUnitInfo : null; if (unit != null) yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, power.Name); diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs index 57f9870c5a..a33d67587e 100644 --- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs +++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs @@ -31,9 +31,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.Info.Selectable).FirstOrDefault(); + && a.LegacyInfo.Selectable).FirstOrDefault(); - var unit = underCursor != null ? underCursor.Info as LegacyUnitInfo : null; + var unit = underCursor != null ? underCursor.LegacyInfo as LegacyUnitInfo : null; if (unit != null) yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name); diff --git a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs index 5a33cbf1d0..2bfbb12359 100644 --- a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs +++ b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.Info.Selectable).FirstOrDefault(); + && a.LegacyInfo.Selectable).FirstOrDefault(); - var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; + var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; if (building != null) yield return new Order("PowerDown", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/RepairOrderGenerator.cs b/OpenRa.Game/Orders/RepairOrderGenerator.cs index 84da77c725..3d87fe6b6d 100644 --- a/OpenRa.Game/Orders/RepairOrderGenerator.cs +++ b/OpenRa.Game/Orders/RepairOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.Info.Selectable).FirstOrDefault(); + && a.LegacyInfo.Selectable).FirstOrDefault(); - var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; + var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; if (building != null && building.Repairable && underCursor.Health < building.Strength) yield return new Order("Repair", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Orders/SellOrderGenerator.cs b/OpenRa.Game/Orders/SellOrderGenerator.cs index c46b459d55..b74c3b79cb 100644 --- a/OpenRa.Game/Orders/SellOrderGenerator.cs +++ b/OpenRa.Game/Orders/SellOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.Info.Selectable).FirstOrDefault(); + && a.LegacyInfo.Selectable).FirstOrDefault(); - var building = underCursor != null ? underCursor.Info as LegacyBuildingInfo : null; + var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; if (building != null && !building.Unsellable) yield return new Order("Sell", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 9a162aa067..9e3d335b31 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -84,7 +84,7 @@ namespace OpenRa.Game { OreCapacity = Game.world.Actors .Where(a => a.Owner == this && a.traits.Contains()) - .Select(a => a.Info as LegacyBuildingInfo) + .Select(a => a.LegacyInfo as LegacyBuildingInfo) .Where(b => b != null) .Sum(b => b.Storage); } diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 697e774406..18dab2724d 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -32,7 +32,7 @@ namespace OpenRa.Game public void Explore(Actor a) { - foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight)) + foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.LegacyInfo.Sight)) explored[t.X, t.Y] = true; dirty = true; diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index 84c637fa02..f3dea39130 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -92,7 +92,7 @@ namespace OpenRa.Game { if (voicedUnit == null) return; - var mi = voicedUnit.Info as LegacyMobileInfo; + var mi = voicedUnit.LegacyInfo as LegacyMobileInfo; if (mi == null) return; var vi = Rules.VoiceInfo[mi.Voice]; diff --git a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs index 6cb033960c..66fa2fdf5a 100644 --- a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs +++ b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if (target.Owner == self.Owner) { - if (target.Health == target.Info.Strength) + if (target.Health == target.LegacyInfo.Strength) return NextActivity; target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]); } diff --git a/OpenRa.Game/Traits/Activities/Fly.cs b/OpenRa.Game/Traits/Activities/Fly.cs index 4f7a4241f7..cae1f43899 100644 --- a/OpenRa.Game/Traits/Activities/Fly.cs +++ b/OpenRa.Game/Traits/Activities/Fly.cs @@ -31,7 +31,7 @@ namespace OpenRa.Game.Traits.Activities var desiredFacing = Util.GetFacing(d, unit.Facing); if (unit.Altitude == CruiseAltitude) - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); var speed = .2f * Util.GetEffectiveSpeed(self); var angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/HeliAttack.cs b/OpenRa.Game/Traits/Activities/HeliAttack.cs index 65c6f44ef3..1a50596e64 100644 --- a/OpenRa.Game/Traits/Activities/HeliAttack.cs +++ b/OpenRa.Game/Traits/Activities/HeliAttack.cs @@ -30,11 +30,11 @@ namespace OpenRa.Game.Traits.Activities return this; } - var range = Rules.WeaponInfo[ self.Info.Primary ].Range - 1; + var range = Rules.WeaponInfo[ self.LegacyInfo.Primary ].Range - 1; var dist = target.CenterLocation - self.CenterLocation; var desiredFacing = Util.GetFacing(dist, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize)) { diff --git a/OpenRa.Game/Traits/Activities/HeliFly.cs b/OpenRa.Game/Traits/Activities/HeliFly.cs index 4f9fb658c6..fd1ac6aa50 100644 --- a/OpenRa.Game/Traits/Activities/HeliFly.cs +++ b/OpenRa.Game/Traits/Activities/HeliFly.cs @@ -39,7 +39,7 @@ namespace OpenRa.Game.Traits.Activities } var desiredFacing = Util.GetFacing(dist, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); var rawSpeed = .2f * Util.GetEffectiveSpeed(self); self.CenterLocation += (rawSpeed / dist.Length) * dist; diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index 6a26fc918b..dcaf9f7f3b 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities static Actor ChooseHelipad(Actor self) { return Game.world.Actors.FirstOrDefault( - a => a.Info == Rules.UnitInfo["HPAD"] && + a => a.LegacyInfo == Rules.UnitInfo["HPAD"] && a.Owner == self.Owner && !Reservable.IsReserved(a)); } @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits.Activities if (dest == null) return Util.SequenceActivities( - new Turn(self.Info.InitialFacing), + new Turn(self.LegacyInfo.InitialFacing), new HeliLand(true), NextActivity); @@ -34,12 +34,12 @@ namespace OpenRa.Game.Traits.Activities if (res != null) self.traits.Get().reservation = res.Reserve(self); - var offset = (dest.Info as LegacyBuildingInfo).SpawnOffset; + var offset = (dest.LegacyInfo as LegacyBuildingInfo).SpawnOffset; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; return Util.SequenceActivities( new HeliFly(dest.CenterLocation + offsetVec), - new Turn(self.Info.InitialFacing), + new Turn(self.LegacyInfo.InitialFacing), new HeliLand(false), new Rearm(), NextActivity); diff --git a/OpenRa.Game/Traits/Activities/Land.cs b/OpenRa.Game/Traits/Activities/Land.cs index 5c4cf06ea5..5f99dd6b19 100644 --- a/OpenRa.Game/Traits/Activities/Land.cs +++ b/OpenRa.Game/Traits/Activities/Land.cs @@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits.Activities --unit.Altitude; var desiredFacing = Util.GetFacing(d, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); var speed = .2f * Util.GetEffectiveSpeed(self); var angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/Repair.cs b/OpenRa.Game/Traits/Activities/Repair.cs index 63f6e1fd92..f6fcf06b59 100644 --- a/OpenRa.Game/Traits/Activities/Repair.cs +++ b/OpenRa.Game/Traits/Activities/Repair.cs @@ -16,8 +16,8 @@ namespace OpenRa.Game.Traits.Activities if (isCanceled) return NextActivity; if (remainingTicks == 0) { - var costPerHp = (Rules.General.URepairPercent * self.Info.Cost) / self.Info.Strength; - var hpToRepair = Math.Min(Rules.General.URepairStep, self.Info.Strength - self.Health); + var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength; + var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits.Activities } self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); - if (self.Health == self.Info.Strength) + if (self.Health == self.LegacyInfo.Strength) return NextActivity; var hostBuilding = Game.FindUnits(self.CenterLocation, self.CenterLocation) diff --git a/OpenRa.Game/Traits/Activities/ReturnToBase.cs b/OpenRa.Game/Traits/Activities/ReturnToBase.cs index 29aad3bc5d..75715798ea 100644 --- a/OpenRa.Game/Traits/Activities/ReturnToBase.cs +++ b/OpenRa.Game/Traits/Activities/ReturnToBase.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities Actor ChooseAirfield(Actor self) { var airfield = Game.world.Actors - .Where(a => a.Info == Rules.UnitInfo["AFLD"] /* todo: generalize this */ + .Where(a => a.LegacyInfo == Rules.UnitInfo["AFLD"] /* todo: generalize this */ && a.Owner == self.Owner && !Reservable.IsReserved(a)) .FirstOrDefault(); @@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits.Activities var unit = self.traits.Get(); var speed = .2f * Util.GetEffectiveSpeed(self); var approachStart = landPos - new float2(unit.Altitude * speed, 0); - var turnRadius = (128f / self.Info.ROT) * speed / (float)Math.PI; + var turnRadius = (128f / self.LegacyInfo.ROT) * speed / (float)Math.PI; /* work out the center points */ var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI); diff --git a/OpenRa.Game/Traits/Activities/Sell.cs b/OpenRa.Game/Traits/Activities/Sell.cs index 109d93785a..330e69692b 100644 --- a/OpenRa.Game/Traits/Activities/Sell.cs +++ b/OpenRa.Game/Traits/Activities/Sell.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities void DoSell(Actor self) { var refund = Rules.General.RefundPercent - * self.Health * self.Info.Cost / self.Info.Strength; + * self.Health * self.LegacyInfo.Cost / self.LegacyInfo.Strength; self.Owner.GiveCash((int)refund); self.Health = 0; diff --git a/OpenRa.Game/Traits/Activities/Turn.cs b/OpenRa.Game/Traits/Activities/Turn.cs index 1b81859e31..4750cc7574 100755 --- a/OpenRa.Game/Traits/Activities/Turn.cs +++ b/OpenRa.Game/Traits/Activities/Turn.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if( desiredFacing == unit.Facing ) return NextActivity; - Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.ROT ); + Util.TickFacing( ref unit.Facing, desiredFacing, self.LegacyInfo.ROT ); return this; } diff --git a/OpenRa.Game/Traits/Activities/UnloadCargo.cs b/OpenRa.Game/Traits/Activities/UnloadCargo.cs index b0af980ab5..ff2c8d6fcb 100644 --- a/OpenRa.Game/Traits/Activities/UnloadCargo.cs +++ b/OpenRa.Game/Traits/Activities/UnloadCargo.cs @@ -33,8 +33,8 @@ namespace OpenRa.Game.Traits.Activities // if we're a thing that can turn, turn to the // right facing for the unload animation var unit = self.traits.GetOrDefault(); - if (unit != null && unit.Facing != self.Info.UnloadFacing) - return new Turn(self.Info.UnloadFacing) { NextActivity = this }; + if (unit != null && unit.Facing != self.LegacyInfo.UnloadFacing) + return new Turn(self.LegacyInfo.UnloadFacing) { NextActivity = this }; // todo: handle the BS of open/close sequences, which are inconsistent, // for reasons that probably make good sense to the westwood guys. diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 4b99833445..2e38d3dc15 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -28,8 +28,8 @@ namespace OpenRa.Game.Traits public AttackBase(Actor self) { - var primaryWeapon = self.Info.Primary != null ? Rules.WeaponInfo[self.Info.Primary] : null; - var secondaryWeapon = self.Info.Secondary != null ? Rules.WeaponInfo[self.Info.Secondary] : null; + var primaryWeapon = self.LegacyInfo.Primary != null ? Rules.WeaponInfo[self.LegacyInfo.Primary] : null; + var secondaryWeapon = self.LegacyInfo.Secondary != null ? Rules.WeaponInfo[self.LegacyInfo.Secondary] : null; primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1; secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1; @@ -79,18 +79,18 @@ namespace OpenRa.Game.Traits { var unit = self.traits.GetOrDefault(); - if (self.Info.Primary != null && CheckFire(self, unit, self.Info.Primary, ref primaryFireDelay, - self.Info.PrimaryOffset, ref primaryBurst, self.Info.PrimaryLocalOffset)) + if (self.LegacyInfo.Primary != null && CheckFire(self, unit, self.LegacyInfo.Primary, ref primaryFireDelay, + self.LegacyInfo.PrimaryOffset, ref primaryBurst, self.LegacyInfo.PrimaryLocalOffset)) { secondaryFireDelay = Math.Max(4, secondaryFireDelay); primaryRecoil = 1; return; } - if (self.Info.Secondary != null && CheckFire(self, unit, self.Info.Secondary, ref secondaryFireDelay, - self.Info.SecondaryOffset ?? self.Info.PrimaryOffset, ref secondaryBurst, self.Info.SecondaryLocalOffset)) + if (self.LegacyInfo.Secondary != null && CheckFire(self, unit, self.LegacyInfo.Secondary, ref secondaryFireDelay, + self.LegacyInfo.SecondaryOffset ?? self.LegacyInfo.PrimaryOffset, ref secondaryBurst, self.LegacyInfo.SecondaryLocalOffset)) { - if (self.Info.SecondaryOffset != null) secondaryRecoil = 1; + if (self.LegacyInfo.SecondaryOffset != null) secondaryRecoil = 1; else primaryRecoil = 1; return; } @@ -132,7 +132,7 @@ namespace OpenRa.Game.Traits var thisTarget = target; // closure. var destUnit = thisTarget.traits.GetOrDefault(); - ScheduleDelayedAction(self.Info.FireDelay, () => + ScheduleDelayedAction(self.LegacyInfo.FireDelay, () => { var srcAltitude = unit != null ? unit.Altitude : 0; var destAltitude = destUnit != null ? destUnit.Altitude : 0; @@ -166,7 +166,7 @@ namespace OpenRa.Game.Traits { if (mi.Button == MouseButton.Left || underCursor == null) return null; if (self == underCursor) return null; - var isHeal = Rules.WeaponInfo[self.Info.Primary].Damage < 0; + var isHeal = Rules.WeaponInfo[self.LegacyInfo.Primary].Damage < 0; if (((underCursor.Owner == self.Owner) ^ isHeal) && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null; if (!Combat.HasAnyValidWeapons(self, underCursor)) return null; @@ -191,7 +191,7 @@ namespace OpenRa.Game.Traits { const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ /* todo: choose the appropriate weapon, when only one works against this target */ - var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; + var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary; self.QueueActivity(new Activities.Attack(order.TargetActor, Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance))); diff --git a/OpenRa.Game/Traits/AttackTurreted.cs b/OpenRa.Game/Traits/AttackTurreted.cs index dff7ff4001..c8305e192c 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -36,7 +36,7 @@ namespace OpenRa.Game.Traits const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ /* todo: choose the appropriate weapon, when only one works against this target */ - var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary; + var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary; if (self.traits.Contains()) self.QueueActivity( new Traits.Activities.Follow( order.TargetActor, diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index eb882df245..a833cc8c25 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits float GetMaximumRange(Actor self) { - return new[] { self.Info.Primary, self.Info.Secondary } + return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary } .Where(w => w != null) .Max(w => Rules.WeaponInfo[w].Range); } @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits return true; // he's dead. if ((attack.target.Location - self.Location).LengthSquared > range * range + 2) return true; // wandered off faster than we could follow - if (attack.target.Health == attack.target.Info.Strength) + if (attack.target.Health == attack.target.LegacyInfo.Strength) return true; // fully healed return false; @@ -55,7 +55,7 @@ namespace OpenRa.Game.Traits return inRange .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ .Where(a => Combat.HasAnyValidWeapons(self, a)) - .Where(a => a.Health < a.Info.Strength) + .Where(a => a.Health < a.LegacyInfo.Strength) .OrderBy(a => (a.Location - self.Location).LengthSquared) .FirstOrDefault(); } diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 0906fac297..f247ca218a 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -15,7 +15,7 @@ namespace OpenRa.Game.Traits float GetMaximumRange(Actor self) { - return new[] { self.Info.Primary, self.Info.Secondary } + return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary } .Where(w => w != null) .Max(w => Rules.WeaponInfo[w].Range); } diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 2e7b204008..934f2c8156 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -29,7 +29,7 @@ namespace OpenRa.Game.Traits public Building(Actor self) { this.self = self; - unitInfo = (LegacyBuildingInfo)self.Info; + unitInfo = (LegacyBuildingInfo)self.LegacyInfo; self.CenterLocation = Game.CellSize * ((float2)self.Location + .5f * (float2)unitInfo.Dimensions); } @@ -84,8 +84,8 @@ namespace OpenRa.Game.Traits if (remainingTicks == 0) { - var costPerHp = (Rules.General.URepairPercent * self.Info.Cost) / self.Info.Strength; - var hpToRepair = Math.Min(Rules.General.URepairStep, self.Info.Strength - self.Health); + var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength; + var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -95,7 +95,7 @@ namespace OpenRa.Game.Traits Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self))); self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); - if (self.Health == self.Info.Strength) + if (self.Health == self.LegacyInfo.Strength) { isRepairing = false; return; diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index d9798efd0c..87bcb94e65 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -46,7 +46,7 @@ namespace OpenRa.Game.Traits public bool IsFull(Actor self) { - return cargo.Count == self.Info.Passengers; + return cargo.Count == self.LegacyInfo.Passengers; } public bool IsEmpty(Actor self) @@ -63,7 +63,7 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips( Actor self ) { - for (var i = 0; i < self.Info.Passengers; i++) + for (var i = 0; i < self.LegacyInfo.Passengers; i++) if (i >= cargo.Count) yield return PipType.Transparent; else diff --git a/OpenRa.Game/Traits/DemoTruck.cs b/OpenRa.Game/Traits/DemoTruck.cs index 2659a3bb3e..6cc66b11b1 100644 --- a/OpenRa.Game/Traits/DemoTruck.cs +++ b/OpenRa.Game/Traits/DemoTruck.cs @@ -44,7 +44,7 @@ namespace OpenRa.Game.Traits int2 detonateLocation = self.CenterLocation.ToInt2(); Game.world.AddFrameEndTask( - w => w.Add(new Bullet(self.Info.Primary, detonatedBy.Owner, detonatedBy, + w => w.Add(new Bullet(self.LegacyInfo.Primary, detonatedBy.Owner, detonatedBy, detonateLocation, detonateLocation, altitude, altitude))); } } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 8477103c63..4773133a30 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits // todo: push into data! static bool HeliCanEnter(Actor a) { - if (a.Info == Rules.UnitInfo["HPAD"]) return true; - if (a.Info == Rules.UnitInfo["FIX"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["HPAD"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true; return false; } @@ -52,7 +52,7 @@ namespace OpenRa.Game.Traits { self.CancelActivity(); self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation))); - self.QueueActivity(new Turn(self.Info.InitialFacing)); + self.QueueActivity(new Turn(self.LegacyInfo.InitialFacing)); self.QueueActivity(new HeliLand(true)); } @@ -63,14 +63,14 @@ namespace OpenRa.Game.Traits if (res != null) reservation = res.Reserve(self); - var offset = (order.TargetActor.Info as LegacyBuildingInfo).SpawnOffset; + var offset = (order.TargetActor.LegacyInfo as LegacyBuildingInfo).SpawnOffset; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; self.CancelActivity(); self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec)); - self.QueueActivity(new Turn(self.Info.InitialFacing)); + self.QueueActivity(new Turn(self.LegacyInfo.InitialFacing)); self.QueueActivity(new HeliLand(false)); - self.QueueActivity(order.TargetActor.Info == Rules.UnitInfo["HPAD"] + self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["HPAD"] ? (IActivity)new Rearm() : new Repair()); } } diff --git a/OpenRa.Game/Traits/LimitedAmmo.cs b/OpenRa.Game/Traits/LimitedAmmo.cs index e2c5cc0797..3e8536b948 100644 --- a/OpenRa.Game/Traits/LimitedAmmo.cs +++ b/OpenRa.Game/Traits/LimitedAmmo.cs @@ -17,14 +17,14 @@ namespace OpenRa.Game.Traits public LimitedAmmo(Actor self) { - ammo = self.Info.Ammo; + ammo = self.LegacyInfo.Ammo; this.self = self; } public bool HasAmmo() { return ammo > 0; } public bool GiveAmmo() { - if (ammo >= self.Info.Ammo) return false; + if (ammo >= self.LegacyInfo.Ammo) return false; ++ammo; return true; } @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips(Actor self) { - return Graphics.Util.MakeArray(self.Info.Ammo, + return Graphics.Util.MakeArray(self.LegacyInfo.Ammo, i => ammo > i ? PipType.Green : PipType.Transparent); } } diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index 1012998d5e..cc590269c7 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits // todo: delay a bit? (req making deploy-mine an activity) Game.world.AddFrameEndTask( - w => w.Add(new Actor(Rules.UnitInfo[self.Info.Primary], self.Location, self.Owner))); + w => w.Add(new Actor(Rules.UnitInfo[self.LegacyInfo.Primary], self.Location, self.Owner))); } } } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 0e0efe835b..febe071a7c 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -87,12 +87,12 @@ namespace OpenRa.Game.Traits public UnitMovementType GetMovementType() { - switch (Rules.UnitCategory[self.Info.Name]) + switch (Rules.UnitCategory[self.LegacyInfo.Name]) { case "Infantry": return UnitMovementType.Foot; case "Vehicle": - return (self.Info as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; + return (self.LegacyInfo as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; case "Ship": return UnitMovementType.Float; case "Plane": diff --git a/OpenRa.Game/Traits/Passenger.cs b/OpenRa.Game/Traits/Passenger.cs index 7a7305a060..ecf4a42a5a 100644 --- a/OpenRa.Game/Traits/Passenger.cs +++ b/OpenRa.Game/Traits/Passenger.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits return null; var umt = self.traits.WithInterface().First().GetMovementType(); - if (!underCursor.Info.PassengerTypes.Contains(umt)) + if (!underCursor.LegacyInfo.PassengerTypes.Contains(umt)) return null; return new Order("EnterTransport", self, underCursor, int2.Zero, null); diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 27030b4705..0733fcf541 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits // todo: push into data! static bool PlaneCanEnter(Actor a) { - if (a.Info == Rules.UnitInfo["AFLD"]) return true; - if (a.Info == Rules.UnitInfo["FIX"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["AFLD"]) return true; + if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true; return false; } @@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits self.CancelActivity(); self.QueueActivity(new ReturnToBase(self, order.TargetActor)); - self.QueueActivity(order.TargetActor.Info == Rules.UnitInfo["AFLD"] + self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["AFLD"] ? (IActivity)new Rearm() : new Repair()); } } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 1a6a270a94..b6b2481248 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -23,7 +23,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - return newUnit.Info.InitialFacing; + return newUnit.LegacyInfo.InitialFacing; } public bool Produce( Actor self, LegacyUnitInfo producee ) @@ -43,7 +43,7 @@ namespace OpenRa.Game.Traits newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) ); } - var bi = self.Info as LegacyBuildingInfo; + var bi = self.LegacyInfo as LegacyBuildingInfo; if (bi != null && bi.SpawnOffset != null) newUnit.CenterLocation = self.CenterLocation + new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]); @@ -83,12 +83,12 @@ namespace OpenRa.Game.Traits } // Cancel existing primaries - foreach (var p in (self.Info as LegacyBuildingInfo).Produces) + foreach (var p in (self.LegacyInfo as LegacyBuildingInfo).Produces) { foreach (var b in Game.world.Actors.Where(x => x.traits.Contains() && x.Owner == self.Owner && x.traits.Get().IsPrimary == true - && (x.Info as LegacyBuildingInfo).Produces.Contains(p))) + && (x.LegacyInfo as LegacyBuildingInfo).Produces.Contains(p))) { b.traits.Get().SetPrimaryProducer(b, false); } diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index b5945c76ff..06340287dd 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -133,7 +133,7 @@ namespace OpenRa.Game.Traits // Prioritise primary structure in build order var primaryProducers = Game.world.Actors .Where(x => x.traits.Contains() - && producerTypes.Contains(x.Info) + && producerTypes.Contains(x.LegacyInfo) && x.Owner == self.Owner && x.traits.Get().IsPrimary == true); @@ -153,7 +153,7 @@ namespace OpenRa.Game.Traits if (producer == null) { producer = Game.world.Actors - .Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner ) + .Where( x => producerTypes.Contains( x.LegacyInfo ) && x.Owner == self.Owner ) .FirstOrDefault(); } diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index aa33fe1c18..f55731579c 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits public RenderWarFactory(Actor self) { this.self = self; - roof = new Animation(self.Info.Image ?? self.Info.Name); + roof = new Animation(self.LegacyInfo.Image ?? self.LegacyInfo.Name); } public void BuildingComplete( Actor self ) diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 4eb4570dad..1b1ed3ff26 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits public RenderSimple(Actor self) { - anims.Add( "", new Animation( self.Info.Image ?? self.Info.Name ) ); + anims.Add( "", new Animation( self.LegacyInfo.Image ?? self.LegacyInfo.Name ) ); } public virtual IEnumerable Render( Actor self ) diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index d8beee320d..118abcbe18 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -15,17 +15,17 @@ namespace OpenRa.Game.Traits public RenderUnitMuzzleFlash(Actor self) : base(self) { - if (!self.Info.MuzzleFlash) throw new InvalidOperationException("wtf??"); + if (!self.LegacyInfo.MuzzleFlash) throw new InvalidOperationException("wtf??"); var unit = self.traits.Get(); var attack = self.traits.WithInterface().First(); - var muzzleFlash = new Animation(self.Info.Name); + var muzzleFlash = new Animation(self.LegacyInfo.Name); muzzleFlash.PlayFetchIndex("muzzle", () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); anims.Add( "muzzle", new AnimationWithOffset( muzzleFlash, - () => self.Info.PrimaryOffset.AbsOffset(), + () => self.LegacyInfo.PrimaryOffset.AbsOffset(), () => attack.primaryRecoil <= 0 ) ); } } diff --git a/OpenRa.Game/Traits/RenderUnitRotor.cs b/OpenRa.Game/Traits/RenderUnitRotor.cs index 32ea23ad80..ef4f70431b 100755 --- a/OpenRa.Game/Traits/RenderUnitRotor.cs +++ b/OpenRa.Game/Traits/RenderUnitRotor.cs @@ -16,20 +16,20 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); - rotorAnim = new Animation(self.Info.Name); + rotorAnim = new Animation(self.LegacyInfo.Name); rotorAnim.PlayRepeating("rotor"); anims.Add( "rotor_1", new AnimationWithOffset( rotorAnim, - () => Util.GetTurretPosition( self, unit, self.Info.RotorOffset, 0 ), + () => Util.GetTurretPosition( self, unit, self.LegacyInfo.RotorOffset, 0 ), null ) ); - if (self.Info.RotorOffset2 == null) return; + if (self.LegacyInfo.RotorOffset2 == null) return; - secondRotorAnim = new Animation( self.Info.Name ); + secondRotorAnim = new Animation( self.LegacyInfo.Name ); secondRotorAnim.PlayRepeating( "rotor2" ); anims.Add( "rotor_2", new AnimationWithOffset( secondRotorAnim, - () => Util.GetTurretPosition(self, unit, self.Info.RotorOffset2, 0), + () => Util.GetTurretPosition(self, unit, self.LegacyInfo.RotorOffset2, 0), null ) ); } diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index ab1212f97f..54794eb915 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -15,11 +15,11 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); - var spinnerAnim = new Animation( self.Info.Name ); + var spinnerAnim = new Animation( self.LegacyInfo.Name ); spinnerAnim.PlayRepeating( "spinner" ); anims.Add( "spinner", new AnimationWithOffset( spinnerAnim, - () => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ), + () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, 0 ), null ) ); } } diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index e88d9fd29a..3aa1c94a9f 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -18,30 +18,30 @@ namespace OpenRa.Game.Traits var turreted = self.traits.Get(); var attack = self.traits.WithInterface().FirstOrDefault(); - var turretAnim = new Animation(self.Info.Name); + var turretAnim = new Animation(self.LegacyInfo.Name); turretAnim.PlayFacing( "turret", () => turreted.turretFacing ); - if( self.Info.PrimaryOffset != null ) + if( self.LegacyInfo.PrimaryOffset != null ) anims.Add("turret_1", new AnimationWithOffset( turretAnim, - () => Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil), + () => Util.GetTurretPosition(self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil), null) { ZOffset = 1 }); - if( self.Info.SecondaryOffset != null ) + if( self.LegacyInfo.SecondaryOffset != null ) anims.Add("turret_2", new AnimationWithOffset( turretAnim, - () => Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil), + () => Util.GetTurretPosition(self, unit, self.LegacyInfo.SecondaryOffset, attack.secondaryRecoil), null) { ZOffset = 1 }); - if( self.Info.MuzzleFlash ) + if( self.LegacyInfo.MuzzleFlash ) { - var muzzleFlash = new Animation( self.Info.Name ); + var muzzleFlash = new Animation( self.LegacyInfo.Name ); muzzleFlash.PlayFetchIndex( "muzzle", () => ( Util.QuantizeFacing( self.traits.Get().turretFacing, 8 ) ) * 6 + (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */ anims.Add( "muzzle_flash", new AnimationWithOffset( muzzleFlash, - () => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, attack.primaryRecoil ), + () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil ), () => attack.primaryRecoil <= 0 ) ); } } diff --git a/OpenRa.Game/Traits/Repairable.cs b/OpenRa.Game/Traits/Repairable.cs index 7e75fd48ce..77de5d6e35 100644 --- a/OpenRa.Game/Traits/Repairable.cs +++ b/OpenRa.Game/Traits/Repairable.cs @@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits if (mi.Button != MouseButton.Right) return null; if (underCursor == null) return null; - if (underCursor.Info == Rules.UnitInfo["FIX"] + if (underCursor.LegacyInfo == Rules.UnitInfo["FIX"] && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor, int2.Zero, null); diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index 5630ef83c3..67aa4af48d 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits public void OnSteal(Actor self, Actor thief) { // Steal half the ore the building holds - var toSteal = (self.Info as LegacyBuildingInfo).Storage/2; + var toSteal = (self.LegacyInfo as LegacyBuildingInfo).Storage/2; self.Owner.TakeCash(toSteal); thief.Owner.GiveCash(toSteal); @@ -28,9 +28,9 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips(Actor self) { - for (int i = 0; i < self.Info.OrePips; i++) + for (int i = 0; i < self.LegacyInfo.OrePips; i++) { - if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.Info.OrePips) + if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.LegacyInfo.OrePips) { yield return PipType.Yellow; continue; diff --git a/OpenRa.Game/Traits/Turreted.cs b/OpenRa.Game/Traits/Turreted.cs index 0e2c7318d7..cacb90e7aa 100644 --- a/OpenRa.Game/Traits/Turreted.cs +++ b/OpenRa.Game/Traits/Turreted.cs @@ -14,13 +14,13 @@ namespace OpenRa.Game.Traits public Turreted(Actor self) { - turretFacing = self.Info.InitialFacing; + turretFacing = self.LegacyInfo.InitialFacing; } public void Tick( Actor self ) { var df = desiredFacing ?? ( self.traits.Contains() ? self.traits.Get().Facing : turretFacing ); - Util.TickFacing( ref turretFacing, df, self.Info.ROT ); + Util.TickFacing( ref turretFacing, df, self.LegacyInfo.ROT ); } } } diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 3a71fb98ae..fda0a447a1 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -82,14 +82,14 @@ namespace OpenRa.Game.Traits static float2 GetRecoil(Actor self, float recoil) { - if (self.Info.Recoil == 0) return float2.Zero; + if (self.LegacyInfo.Recoil == 0) return float2.Zero; var rut = self.traits.WithInterface().FirstOrDefault(); if (rut == null) return float2.Zero; var facing = self.traits.Get().turretFacing; var quantizedFacing = QuantizeFacing(facing, rut.anim.CurrentSequence.Length) * (256 / rut.anim.CurrentSequence.Length); - return RotateVectorByFacing(new float2(0, recoil * self.Info.Recoil), quantizedFacing, .7f); + return RotateVectorByFacing(new float2(0, recoil * self.LegacyInfo.Recoil), quantizedFacing, .7f); } public static float2 CenterOfCell(int2 loc) @@ -127,7 +127,7 @@ namespace OpenRa.Game.Traits public static float GetEffectiveSpeed(Actor self) { - var mi = self.Info as LegacyMobileInfo; + var mi = self.LegacyInfo as LegacyMobileInfo; if (mi == null) return 0f; var modifier = self.traits diff --git a/OpenRa.Game/UnitInfluenceMap.cs b/OpenRa.Game/UnitInfluenceMap.cs index 0982ea957d..6f50bf1dad 100644 --- a/OpenRa.Game/UnitInfluenceMap.cs +++ b/OpenRa.Game/UnitInfluenceMap.cs @@ -36,7 +36,7 @@ namespace OpenRa.Game var crusher = GetUnitsAt(cell).Where(b => a != b && Game.IsActorCrushableByActor(a, b)).FirstOrDefault(); if (crusher != null) { - Log.Write("{0} crushes {1}", crusher.Info.Name, a.Info.Name); + Log.Write("{0} crushes {1}", crusher.LegacyInfo.Name, a.LegacyInfo.Name); // Apply the crush action foreach (var crush in a.traits.WithInterface()) crush.OnCrush(crusher); From e7f9023aca12b1b21f70a9a03e9a57a6476d783f Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 18:55:10 +1300 Subject: [PATCH 30/83] started porting traits to use new trait args. --- OpenRa.Game/Traits/Activities/HeliReturn.cs | 2 +- OpenRa.Game/Traits/Activities/Sell.cs | 5 +- OpenRa.Game/Traits/AttackBase.cs | 9 + OpenRa.Game/Traits/Building.cs | 22 +- OpenRa.Game/Traits/Cargo.cs | 1 + OpenRa.Game/Traits/StoresOre.cs | 17 +- OpenRa.Game/Traits/Unit.cs | 6 +- RulesConverter/Program.cs | 6 +- ra.yaml | 520 +++++++++++++++++--- 9 files changed, 501 insertions(+), 87 deletions(-) diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index dcaf9f7f3b..83dd9cac75 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities static Actor ChooseHelipad(Actor self) { return Game.world.Actors.FirstOrDefault( - a => a.LegacyInfo == Rules.UnitInfo["HPAD"] && + a => a.Info == Rules.NewUnitInfo["HPAD"] && a.Owner == self.Owner && !Reservable.IsReserved(a)); } diff --git a/OpenRa.Game/Traits/Activities/Sell.cs b/OpenRa.Game/Traits/Activities/Sell.cs index 330e69692b..87d2a0425c 100644 --- a/OpenRa.Game/Traits/Activities/Sell.cs +++ b/OpenRa.Game/Traits/Activities/Sell.cs @@ -13,8 +13,9 @@ namespace OpenRa.Game.Traits.Activities void DoSell(Actor self) { - var refund = Rules.General.RefundPercent - * self.Health * self.LegacyInfo.Cost / self.LegacyInfo.Strength; + var cost = self.Info.Traits.Get().Cost; + var hp = self.Info.Traits.WithInterface().First().HP; + var refund = Rules.General.RefundPercent * self.Health * cost / hp; self.Owner.GiveCash((int)refund); self.Health = 0; diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 2e38d3dc15..1c7b0c9139 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -8,6 +8,15 @@ namespace OpenRa.Game.Traits { class AttackBaseInfo : ITraitInfo { + public readonly string PrimaryWeapon = null; + public readonly string SecondaryWeapon = null; + public readonly int Recoil = 0; + public readonly int[] PrimaryLocalOffset = { }; + public readonly int[] SecondaryLocalOffset = { }; + public readonly int[] PrimaryOffset = { 0, 0 }; + public readonly int[] SecondaryOffset = null; + public readonly bool MuzzleFlash = false; + public virtual object Create(Actor self) { return new AttackBase(self); } } diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 934f2c8156..a626b65a9e 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -9,8 +9,28 @@ using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { - class BuildingInfo : ITraitInfo + class OwnedActorInfo { + public readonly int HP = 0; + public readonly ArmorType Armor = ArmorType.none; + public readonly bool Crewed = false; // replace with trait? + public readonly int InitialFacing = 128; + } + + class BuildingInfo : OwnedActorInfo, ITraitInfo + { + public readonly int Power = 0; + public readonly bool RequiresPower = false; + public readonly bool BaseNormal = true; + public readonly int Adjacent = 1; + public readonly bool Bib = false; + public readonly bool Capturable = false; + public readonly bool Repairable = true; + public readonly string Footprint = "x"; + public readonly string[] Produces = { }; // does this go somewhere else? + public readonly int2 Dimensions = new int2(1, 1); + public readonly bool WaterBound = false; + public object Create(Actor self) { return new Building(self); } } diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index 87bcb94e65..72d774eb61 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits class CargoInfo : ITraitInfo { public readonly UnitMovementType[] PassengerTypes = { }; + public readonly int UnloadFacing = 0; public object Create(Actor self) { return new Cargo(self); } } diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index 67aa4af48d..f3591580c3 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits public void OnSteal(Actor self, Actor thief) { // Steal half the ore the building holds - var toSteal = (self.LegacyInfo as LegacyBuildingInfo).Storage/2; + var toSteal = self.Info.Traits.Get().Capacity / 2; self.Owner.TakeCash(toSteal); thief.Owner.GiveCash(toSteal); @@ -28,15 +28,12 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips(Actor self) { - for (int i = 0; i < self.LegacyInfo.OrePips; i++) - { - if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.LegacyInfo.OrePips) - { - yield return PipType.Yellow; - continue; - } - yield return PipType.Transparent; - } + var numPips = self.Info.Traits.Get().Pips; + + return Graphics.Util.MakeArray( numPips, + i => (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / numPips) + ? PipType.Yellow : PipType.Transparent ); + } } } diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index c3de5d2dfe..9b44ae78b2 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -2,12 +2,8 @@ namespace OpenRa.Game.Traits { - class UnitInfo : ITraitInfo + class UnitInfo : OwnedActorInfo, ITraitInfo { - public readonly int HP = 0; - public readonly ArmorType Armor = ArmorType.none; - public readonly bool Crewed = false; // replace with trait? - public object Create(Actor self) { return new Unit(self); } } diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 358a3871d4..0ff9208a33 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -39,7 +39,8 @@ namespace RulesConverter { "Unit", new PL { { "HP", "Strength" }, { "Armor", "Armor" }, - { "Crewed", "Crewed" } } + { "Crewed", "Crewed" }, + { "InitialFacing", "InitialFacing" } } }, { "Selectable", new PL { @@ -102,7 +103,8 @@ namespace RulesConverter { "HP", "Strength" }, { "Armor", "Armor" }, { "Crewed", "Crewed" }, - { "WaterBound", "WaterBound" } } + { "WaterBound", "WaterBound" }, + { "InitialFacing", "InitialFacing" } } }, { "StoresOre", new PL { diff --git a/ra.yaml b/ra.yaml index 419bad4e12..086b7975eb 100644 --- a/ra.yaml +++ b/ra.yaml @@ -1,23 +1,3 @@ -# -# Red Alert rules -# - -DefaultVehicle: -# Unit: -# HP: 1 -# Armor: none -# Crewed: yes -# Voice: VehicleVoice -# Mobile: -# Sight: 1 -# ROT: 5 -# Speed: 1 -# UMT: Wheel -# Repairable: -# Chronoshiftable: -# Passenger: -# IronCurtainable: - V2RL: Inherits: DefaultVehicle Buildable: @@ -39,6 +19,7 @@ V2RL: ROT: 5 Speed: 7 AttackBase: + PrimaryWeapon: SCUD RenderUnitReload: AutoTarget: Repairable: @@ -68,6 +49,8 @@ V2RL: Speed: 9 Turreted: AttackTurreted: + PrimaryWeapon: 75mm + Recoil: 2 RenderUnitTurreted: AutoTarget: Repairable: @@ -97,6 +80,8 @@ V2RL: Speed: 8 Turreted: AttackTurreted: + PrimaryWeapon: 90mm + Recoil: 3 RenderUnitTurreted: AutoTarget: Repairable: @@ -126,6 +111,8 @@ V2RL: Speed: 7 Turreted: AttackTurreted: + PrimaryWeapon: 105mm + Recoil: 3 RenderUnitTurreted: AutoTarget: Repairable: @@ -155,6 +142,10 @@ V2RL: Speed: 4 Turreted: AttackTurreted: + PrimaryWeapon: 120mm + PrimaryLocalOffset: -4,-5,0,4,-5,0 + SecondaryLocalOffset: -7,2,25,7,2,-25 + Recoil: 4 RenderUnitTurreted: AutoTarget: Repairable: @@ -237,6 +228,7 @@ ARTY: ROT: 2 Speed: 6 AttackBase: + PrimaryWeapon: 155mm RenderUnit: Explodes: AutoTarget: @@ -323,6 +315,9 @@ JEEP: Speed: 10 Turreted: AttackTurreted: + PrimaryWeapon: M60mg + PrimaryOffset: 0,0,0,-2 + MuzzleFlash: yes RenderUnitTurreted: AutoTarget: Repairable: @@ -350,12 +345,16 @@ APC: ROT: 5 Speed: 10 AttackBase: + PrimaryWeapon: M60mg + PrimaryOffset: 0,0,0,-4 + MuzzleFlash: yes RenderUnitMuzzleFlash: AutoTarget: Repairable: Chronoshiftable: Cargo: PassengerTypes: Foot + UnloadFacing: 220 Passenger: IronCurtainable: @@ -444,6 +443,7 @@ SS: RenderUnit: Submarine: AttackBase: + PrimaryWeapon: TorpTube Chronoshiftable: IronCurtainable: @@ -467,6 +467,8 @@ DD: Speed: 6 Turreted: AttackTurreted: + PrimaryWeapon: Stinger + PrimaryOffset: 0,-8,0,-3 RenderUnitTurreted: AutoTarget: Chronoshiftable: @@ -492,6 +494,10 @@ CA: Speed: 4 Turreted: AttackTurreted: + PrimaryWeapon: 8Inch + PrimaryOffset: 0,17,0,-2 + SecondaryOffset: 0,-17,0,-2 + Recoil: 3 RenderUnitTurreted: AutoTarget: Chronoshiftable: @@ -539,6 +545,8 @@ PT: Speed: 9 Turreted: AttackTurreted: + PrimaryWeapon: 2Inch + PrimaryOffset: 0,-6,0,-1 RenderUnitTurreted: AutoTarget: Chronoshiftable: @@ -558,7 +566,9 @@ MIG: Unit: HP: 50 Armor: light + InitialFacing: 192 AttackPlane: + PrimaryWeapon: Maverick Plane: ROT: 5 Speed: 20 @@ -583,7 +593,9 @@ YAK: HP: 60 Armor: light Crewed: yes + InitialFacing: 192 AttackPlane: + PrimaryWeapon: ChainGun Plane: ROT: 5 Speed: 16 @@ -607,6 +619,7 @@ TRAN: Unit: HP: 90 Armor: light + InitialFacing: 20 Helicopter: ROT: 5 Speed: 12 @@ -631,7 +644,11 @@ HELI: HP: 225 Armor: heavy Crewed: yes + InitialFacing: 20 AttackHeli: + PrimaryWeapon: Hellfire + PrimaryOffset: -5,0,0,2 + SecondaryOffset: 5,0,0,2 Helicopter: ROT: 4 Speed: 16 @@ -656,7 +673,11 @@ HIND: HP: 225 Armor: heavy Crewed: yes + InitialFacing: 20 AttackHeli: + PrimaryWeapon: ChainGun + PrimaryOffset: -5,0,0,2 + SecondaryOffset: 5,0,0,2 Helicopter: ROT: 4 Speed: 12 @@ -679,6 +700,14 @@ IRON: Selectable: Priority: 3 Building: + Power: -200 + RequiresPower: true + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + HP: 400 + Armor: wood + Crewed: yes RenderBuilding: IronCurtainable: IronCurtain: @@ -696,6 +725,14 @@ PDOX: Selectable: Priority: 3 Building: + Power: -200 + RequiresPower: true + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + HP: 400 + Armor: wood + Crewed: yes RenderBuilding: Chronosphere: IronCurtainable: @@ -713,9 +750,16 @@ PBOX: Selectable: Priority: 3 Building: + Power: -15 + Footprint: x + Dimensions: 1,1 + HP: 400 + Armor: wood + Crewed: yes Turreted: RenderBuilding: AttackTurreted: + PrimaryWeapon: Vulcan AutoTarget: IronCurtainable: @@ -732,9 +776,16 @@ HBOX: Selectable: Priority: 3 Building: + Power: -15 + Footprint: x + Dimensions: 1,1 + HP: 600 + Armor: wood + Crewed: yes Turreted: RenderBuilding: AttackTurreted: + PrimaryWeapon: Vulcan AutoTarget: IronCurtainable: @@ -751,9 +802,17 @@ TSLA: Selectable: Priority: 3 Building: + Power: -150 + RequiresPower: true + Footprint: _ x + Dimensions: 1,2 + HP: 400 + Armor: heavy + Crewed: yes Turreted: RenderBuildingCharge: AttackTurreted: + PrimaryWeapon: TeslaZap AutoTarget: IronCurtainable: @@ -770,9 +829,17 @@ GUN: Selectable: Priority: 3 Building: + Power: -40 + Footprint: x + Dimensions: 1,1 + HP: 400 + Armor: heavy + Crewed: yes + InitialFacing: 50 Turreted: RenderBuildingTurreted: AttackTurreted: + PrimaryWeapon: TurretGun AutoTarget: IronCurtainable: @@ -789,9 +856,18 @@ AGUN: Selectable: Priority: 3 Building: + Power: -50 + RequiresPower: true + Footprint: _ x + Dimensions: 1,2 + HP: 400 + Armor: heavy + Crewed: yes + InitialFacing: 224 Turreted: RenderBuildingTurreted: AttackTurreted: + PrimaryWeapon: ZSU-23 AutoTarget: IronCurtainable: @@ -809,8 +885,15 @@ FTUR: Priority: 3 Turreted: Building: + Power: -20 + Footprint: x + Dimensions: 1,1 + HP: 400 + Armor: heavy + Crewed: yes RenderBuilding: AttackTurreted: + PrimaryWeapon: FireballLauncher AutoTarget: IronCurtainable: @@ -827,6 +910,14 @@ GAP: Selectable: Priority: 3 Building: + Power: -60 + RequiresPower: true + Footprint: _ x + Dimensions: 1,2 + Capturable: true + HP: 1000 + Armor: wood + Crewed: yes RenderBuilding: IronCurtainable: @@ -843,9 +934,16 @@ SAM: Selectable: Priority: 3 Building: + Power: -20 + Footprint: xx + Dimensions: 2,1 + HP: 400 + Armor: heavy + Crewed: yes Turreted: RenderBuildingTurreted: AttackTurreted: + PrimaryWeapon: Nike AutoTarget: IronCurtainable: @@ -862,6 +960,12 @@ MSLO: Selectable: Priority: 3 Building: + Power: -100 + Footprint: xx + Dimensions: 2,1 + HP: 400 + Armor: heavy + Crewed: yes RenderBuilding: IronCurtainable: @@ -878,6 +982,14 @@ ATEK: Selectable: Priority: 3 Building: + Power: -200 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 400 + Armor: wood + Crewed: yes RenderBuilding: IronCurtainable: GpsLaunchSite: @@ -895,6 +1007,14 @@ WEAP: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx + Dimensions: 3,2 + Capturable: true + Bib: yes + HP: 1000 + Armor: light + Crewed: yes RenderWarFactory: RenderBuilding: RallyPoint: @@ -914,6 +1034,15 @@ SYRD: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Adjacent: 8 + HP: 1000 + Armor: light + WaterBound: yes RenderBuilding: ProductionSurround: IronCurtainable: @@ -931,6 +1060,15 @@ SPEN: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Adjacent: 8 + HP: 1000 + Armor: light + WaterBound: yes RenderBuilding: ProductionSurround: IronCurtainable: @@ -940,6 +1078,14 @@ FACT: Selectable: Priority: 3 Building: + Power: 0 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + Bib: yes + HP: 1000 + Armor: heavy + Crewed: yes RenderBuilding: ConstructionYard: IronCurtainable: @@ -957,9 +1103,19 @@ PROC: Selectable: Priority: 3 Building: + Power: -30 + Footprint: _x_ xxx x== + Dimensions: 3,3 + Capturable: true + Bib: yes + HP: 900 + Armor: wood + Crewed: yes RenderBuilding: AcceptsOre: StoresOre: + Pips: 17 + Capacity: 2000 IronCurtainable: SILO: @@ -975,8 +1131,16 @@ SILO: Selectable: Priority: 3 Building: + Power: -10 + Footprint: x + Dimensions: 1,1 + Capturable: true + HP: 300 + Armor: wood RenderBuildingOre: StoresOre: + Pips: 5 + Capacity: 1500 IronCurtainable: HPAD: @@ -992,6 +1156,14 @@ HPAD: Selectable: Priority: 3 Building: + Power: -10 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 800 + Armor: wood + Crewed: yes RenderBuilding: Production: BelowUnits: @@ -1011,6 +1183,15 @@ DOME: Selectable: Priority: 3 Building: + Power: -40 + RequiresPower: true + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 1000 + Armor: wood + Crewed: yes RenderBuilding: ProvidesRadar: IronCurtainable: @@ -1028,6 +1209,13 @@ AFLD: Selectable: Priority: 3 Building: + Power: -30 + Footprint: xxx xxx + Dimensions: 3,2 + Capturable: true + HP: 1000 + Armor: heavy + Crewed: yes RenderBuilding: Production: BelowUnits: @@ -1047,6 +1235,14 @@ POWR: Selectable: Priority: 3 Building: + Power: 100 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 400 + Armor: wood + Crewed: yes RenderBuilding: IronCurtainable: @@ -1063,6 +1259,14 @@ APWR: Selectable: Priority: 3 Building: + Power: 200 + Footprint: ___ xxx xxx + Dimensions: 3,3 + Capturable: true + Bib: yes + HP: 700 + Armor: wood + Crewed: yes RenderBuilding: IronCurtainable: @@ -1079,6 +1283,14 @@ STEK: Selectable: Priority: 3 Building: + Power: -100 + Footprint: xxx xxx + Dimensions: 3,2 + Capturable: true + Bib: yes + HP: 600 + Armor: wood + Crewed: yes RenderBuilding: IronCurtainable: @@ -1095,6 +1307,14 @@ BARR: Selectable: Priority: 3 Building: + Power: -20 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 800 + Armor: wood + Crewed: yes RenderBuilding: RallyPoint: Production: @@ -1113,6 +1333,14 @@ TENT: Selectable: Priority: 3 Building: + Power: -20 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 800 + Armor: wood + Crewed: yes RenderBuilding: RallyPoint: Production: @@ -1131,6 +1359,11 @@ KENN: Selectable: Priority: 3 Building: + Power: -10 + Footprint: x + Dimensions: 1,1 + HP: 400 + Armor: wood RenderBuilding: RallyPoint: Production: @@ -1149,6 +1382,13 @@ FIX: Selectable: Priority: 3 Building: + Power: -30 + Footprint: _x_ xxx _x_ + Dimensions: 3,3 + Capturable: true + HP: 800 + Armor: wood + Crewed: yes RenderBuilding: BelowUnits: Reservable: @@ -1166,6 +1406,13 @@ FACF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Bib: yes + HP: 30 RenderBuilding: Image: FACT Fake: @@ -1184,6 +1431,13 @@ WEAF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx + Dimensions: 3,2 + Capturable: true + BaseNormal: no + Bib: yes + HP: 30 RenderWarFactory: RenderBuilding: Image: WEAP @@ -1203,6 +1457,14 @@ SYRF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Adjacent: 8 + HP: 30 + WaterBound: yes RenderBuilding: Image: SYRD Fake: @@ -1212,6 +1474,14 @@ SPEF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Adjacent: 8 + HP: 30 + WaterBound: yes RenderBuilding: Image: SPEN Fake: @@ -1229,6 +1499,13 @@ DOMF: Selectable: Priority: 3 Building: + Power: -2 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + BaseNormal: no + Bib: yes + HP: 30 RenderBuilding: Image: DOME Fake: @@ -1251,6 +1528,154 @@ MINV: BelowUnits: InvisibleToOthers: +T01: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T02: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T03: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T05: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T06: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T07: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T08: + Inherits: DefaultBuilding + Building: + Footprint: x_ + Dimensions: 2,1 + RenderBuilding: + +T10: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T11: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T12: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T13: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T14: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T15: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T16: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T17: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +TC01: + Inherits: DefaultBuilding + Building: + Footprint: xx_ xx_ + Dimensions: 3,2 + RenderBuilding: + +TC02: + Inherits: DefaultBuilding + Building: + Footprint: xx_ xx_ + Dimensions: 3,2 + RenderBuilding: + +TC03: + Inherits: DefaultBuilding + Building: + Footprint: xx_ xx_ + Dimensions: 3,2 + RenderBuilding: + +TC04: + Inherits: DefaultBuilding + Building: + Footprint: xxx_ xxx_ xxx_ + Dimensions: 4,3 + RenderBuilding: + +TC05: + Inherits: DefaultBuilding + Building: + Footprint: xxx_ xxx_ xxx_ + Dimensions: 4,3 + RenderBuilding: + +MINE: + Inherits: DefaultBuilding + Building: + Footprint: x + Dimensions: 1,1 + RenderBuilding: + SeedsOre: + DOG: Inherits: DefaultInfantry Buildable: @@ -1292,6 +1717,7 @@ E1: Speed: 4 RenderInfantry: AttackBase: + PrimaryWeapon: M1Carbine TakeCover: SquishByTank: AutoTarget: @@ -1316,6 +1742,8 @@ E2: Speed: 5 RenderInfantry: AttackBase: + PrimaryWeapon: Grenade + PrimaryOffset: 0,0,0,-13 TakeCover: SquishByTank: AutoTarget: @@ -1340,6 +1768,8 @@ E3: Speed: 3 RenderInfantry: AttackBase: + PrimaryWeapon: RedEye + PrimaryOffset: 0,0,0,-13 TakeCover: SquishByTank: AutoTarget: @@ -1365,6 +1795,8 @@ E4: Speed: 3 RenderInfantry: AttackBase: + PrimaryWeapon: Flamer + PrimaryOffset: 0,0,0,-7 TakeCover: SquishByTank: AutoTarget: @@ -1465,6 +1897,7 @@ E7: RenderInfantry: C4Demolition: AttackBase: + PrimaryWeapon: Colt45 TakeCover: SquishByTank: AutoTarget: @@ -1491,53 +1924,8 @@ MEDI: RenderInfantry: AutoHeal: AttackBase: + PrimaryWeapon: Heal TakeCover: SquishByTank: Passenger: - - - -T01 - Inherits: DefaultTree -T02 - Inherits: DefaultTree -T03 - Inherits: DefaultTree -T05 - Inherits: DefaultTree -T06 - Inherits: DefaultTree -T07 - Inherits: DefaultTree -T08 - Inherits: DefaultTree -T10 - Inherits: DefaultTree -T11 - Inherits: DefaultTree -T12 - Inherits: DefaultTree -T13 - Inherits: DefaultTree -T14 - Inherits: DefaultTree -T15 - Inherits: DefaultTree -T16 - Inherits: DefaultTree -T17 - Inherits: DefaultTree -TC01 - Inherits: DefaultTree -TC02 - Inherits: DefaultTree -TC03 - Inherits: DefaultTree -TC04 - Inherits: DefaultTree -TC05 - Inherits: DefaultTree -MINE - Inherits: DefaultTree - From 8e944871fae56a7ee9ec0d981c3f22132deda633 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 19:11:58 +1300 Subject: [PATCH 31/83] more ported bits --- OpenRa.Game/Effects/Corpse.cs | 3 ++- OpenRa.Game/GameRules/NewUnitInfo.cs | 6 +++++- OpenRa.Game/GameRules/Rules.cs | 2 +- OpenRa.Game/Traits/AutoTarget.cs | 3 ++- OpenRa.Game/Traits/LimitedAmmo.cs | 7 ++++--- OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs | 2 -- OpenRa.Game/Traits/RenderUnitRotor.cs | 14 +++++++++----- OpenRa.Game/Traits/RenderUnitSpinner.cs | 7 +++++-- OpenRa.Game/Traits/Turreted.cs | 10 +++++++--- RulesConverter/Program.cs | 13 +++++++++++-- ra.yaml | 5 +++++ 11 files changed, 51 insertions(+), 21 deletions(-) diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs index f37a1116b3..470a790f12 100755 --- a/OpenRa.Game/Effects/Corpse.cs +++ b/OpenRa.Game/Effects/Corpse.cs @@ -15,7 +15,8 @@ namespace OpenRa.Game.Effects public Corpse(Actor fromActor, int death) { - anim = new Animation(fromActor.LegacyInfo.Image ?? fromActor.LegacyInfo.Name); + var info = fromActor.Info.Traits.WithInterface().First(); + anim = new Animation(info.Image ?? fromActor.Info.Name); anim.PlayThen("die{0}".F(death + 1), () => Game.world.AddFrameEndTask(w => w.Remove(this))); diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs index 3d80aba9f1..62cee867be 100755 --- a/OpenRa.Game/GameRules/NewUnitInfo.cs +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -10,9 +10,13 @@ namespace OpenRa.Game.GameRules { public readonly string Parent; public readonly TypeDictionary Traits = new TypeDictionary(); + public readonly string Name; - public NewUnitInfo( MiniYaml node ) + public NewUnitInfo( string name, MiniYaml node ) { + Name = name; + + // todo: make inheritance actually work MiniYaml inherit; if( node.Nodes.TryGetValue( "Inherits", out inherit ) ) { diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 30c9781e35..d7200d93ec 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -97,7 +97,7 @@ namespace OpenRa.Game NewUnitInfo = new Dictionary(); foreach( var kv in MiniYaml.FromFile( "ra.yaml" ) ) - NewUnitInfo.Add( kv.Key.ToLowerInvariant(), new NewUnitInfo( kv.Value ) ); + NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value)); } static void LoadCategories(params string[] types) diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index f247ca218a..29d588a8f3 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -15,7 +15,8 @@ namespace OpenRa.Game.Traits float GetMaximumRange(Actor self) { - return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary } + var info = self.Info.Traits.WithInterface().First(); + return new[] { info.PrimaryWeapon, info.SecondaryWeapon } .Where(w => w != null) .Max(w => Rules.WeaponInfo[w].Range); } diff --git a/OpenRa.Game/Traits/LimitedAmmo.cs b/OpenRa.Game/Traits/LimitedAmmo.cs index 3e8536b948..5d1a705e6d 100644 --- a/OpenRa.Game/Traits/LimitedAmmo.cs +++ b/OpenRa.Game/Traits/LimitedAmmo.cs @@ -17,14 +17,14 @@ namespace OpenRa.Game.Traits public LimitedAmmo(Actor self) { - ammo = self.LegacyInfo.Ammo; + ammo = self.Info.Traits.Get().Ammo; this.self = self; } public bool HasAmmo() { return ammo > 0; } public bool GiveAmmo() { - if (ammo >= self.LegacyInfo.Ammo) return false; + if (ammo >= self.Info.Traits.Get().Ammo) return false; ++ammo; return true; } @@ -33,7 +33,8 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips(Actor self) { - return Graphics.Util.MakeArray(self.LegacyInfo.Ammo, + var maxAmmo = self.Info.Traits.Get().Ammo; + return Graphics.Util.MakeArray(maxAmmo, i => ammo > i ? PipType.Green : PipType.Transparent); } } diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index 118abcbe18..53211abcf6 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -15,8 +15,6 @@ namespace OpenRa.Game.Traits public RenderUnitMuzzleFlash(Actor self) : base(self) { - if (!self.LegacyInfo.MuzzleFlash) throw new InvalidOperationException("wtf??"); - var unit = self.traits.Get(); var attack = self.traits.WithInterface().First(); diff --git a/OpenRa.Game/Traits/RenderUnitRotor.cs b/OpenRa.Game/Traits/RenderUnitRotor.cs index ef4f70431b..a8d6b75f23 100755 --- a/OpenRa.Game/Traits/RenderUnitRotor.cs +++ b/OpenRa.Game/Traits/RenderUnitRotor.cs @@ -4,6 +4,9 @@ namespace OpenRa.Game.Traits { class RenderUnitRotorInfo : RenderUnitInfo { + public readonly int[] PrimaryOffset = { 0, 0 }; + public readonly int[] SecondaryOffset = null; + public override object Create(Actor self) { return new RenderUnitRotor(self); } } @@ -15,21 +18,22 @@ namespace OpenRa.Game.Traits : base(self) { var unit = self.traits.Get(); + var info = self.Info.Traits.Get(); - rotorAnim = new Animation(self.LegacyInfo.Name); + rotorAnim = new Animation(info.Image ?? self.Info.Name); rotorAnim.PlayRepeating("rotor"); anims.Add( "rotor_1", new AnimationWithOffset( rotorAnim, - () => Util.GetTurretPosition( self, unit, self.LegacyInfo.RotorOffset, 0 ), + () => Util.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ), null ) ); - if (self.LegacyInfo.RotorOffset2 == null) return; + if (info.SecondaryOffset == null) return; - secondRotorAnim = new Animation( self.LegacyInfo.Name ); + secondRotorAnim = new Animation(info.Image ?? self.Info.Name); secondRotorAnim.PlayRepeating( "rotor2" ); anims.Add( "rotor_2", new AnimationWithOffset( secondRotorAnim, - () => Util.GetTurretPosition(self, unit, self.LegacyInfo.RotorOffset2, 0), + () => Util.GetTurretPosition(self, unit, info.SecondaryOffset, 0), null ) ); } diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index 54794eb915..f0415e816b 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; +using System.Linq; using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits { class RenderUnitSpinnerInfo : RenderUnitInfo { + public readonly int[] Offset = { 0, 0 }; public override object Create(Actor self) { return new RenderUnitSpinner(self); } } @@ -14,12 +16,13 @@ namespace OpenRa.Game.Traits : base(self) { var unit = self.traits.Get(); + var info = self.Info.Traits.Get(); - var spinnerAnim = new Animation( self.LegacyInfo.Name ); + var spinnerAnim = new Animation( info.Image ?? self.Info.Name ); spinnerAnim.PlayRepeating( "spinner" ); anims.Add( "spinner", new AnimationWithOffset( spinnerAnim, - () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, 0 ), + () => Util.GetTurretPosition( self, unit, info.Offset, 0 ), null ) ); } } diff --git a/OpenRa.Game/Traits/Turreted.cs b/OpenRa.Game/Traits/Turreted.cs index cacb90e7aa..3df089fae2 100644 --- a/OpenRa.Game/Traits/Turreted.cs +++ b/OpenRa.Game/Traits/Turreted.cs @@ -1,8 +1,12 @@ - +using System.Linq; + namespace OpenRa.Game.Traits { class TurretedInfo : ITraitInfo { + public readonly int ROT = 0; + public readonly int InitialFacing = 128; + public object Create(Actor self) { return new Turreted(self); } } @@ -14,13 +18,13 @@ namespace OpenRa.Game.Traits public Turreted(Actor self) { - turretFacing = self.LegacyInfo.InitialFacing; + turretFacing = self.Info.Traits.Get().InitialFacing; } public void Tick( Actor self ) { var df = desiredFacing ?? ( self.traits.Contains() ? self.traits.Get().Facing : turretFacing ); - Util.TickFacing( ref turretFacing, df, self.LegacyInfo.ROT ); + Util.TickFacing(ref turretFacing, df, self.Info.Traits.Get().ROT); } } } diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 0ff9208a33..7dc38d3f6f 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -70,6 +70,17 @@ namespace RulesConverter { "Image", "Image" } } }, + { "RenderUnitSpinner", new PL { + { "Image", "Image" }, + { "Offset", "PrimaryOffset" } } + }, + + { "RenderUnitRotor", new PL { + { "Image", "Image" }, + { "PrimaryOffset", "RotorOffset" }, + { "SecondaryOffset", "RotorOffset2" } } + }, + { "Buildable", new PL { { "TechLevel", "TechLevel" }, { "Tab", "$Tab" }, @@ -136,8 +147,6 @@ namespace RulesConverter traitMap["RenderInfantry"] = traitMap["RenderBuilding"]; traitMap["RenderUnitMuzzleFlash"] = traitMap["RenderBuilding"]; traitMap["RenderUnitReload"] = traitMap["RenderBuilding"]; - traitMap["RenderUnitRotor"] = traitMap["RenderBuilding"]; - traitMap["RenderUnitSpinner"] = traitMap["RenderBuilding"]; traitMap["RenderUnitTurreted"] = traitMap["RenderBuilding"]; traitMap["AttackTurreted"] = traitMap["AttackBase"]; diff --git a/ra.yaml b/ra.yaml index 086b7975eb..51defaa4c3 100644 --- a/ra.yaml +++ b/ra.yaml @@ -175,6 +175,7 @@ MRJ: ROT: 5 Speed: 9 RenderUnitSpinner: + Offset: 0,4,0,-6 Repairable: Chronoshiftable: Passenger: @@ -202,6 +203,7 @@ MGG: ROT: 5 Speed: 9 RenderUnitSpinner: + Offset: 0,6,0,-3 Repairable: Chronoshiftable: Passenger: @@ -624,6 +626,8 @@ TRAN: ROT: 5 Speed: 12 RenderUnitRotor: + PrimaryOffset: 0,14,0,-4 + SecondaryOffset: 0,-14,0,-2 WithShadow: Cargo: PassengerTypes: Foot @@ -653,6 +657,7 @@ HELI: ROT: 4 Speed: 16 RenderUnitRotor: + PrimaryOffset: 0,0,0,-2 WithShadow: LimitedAmmo: Ammo: 6 From e131963c5310f3690b8cfa3e55d935bb5b07f878 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 19:15:32 +1300 Subject: [PATCH 32/83] Repair ported --- OpenRa.Game/Traits/Activities/Repair.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Traits/Activities/Repair.cs b/OpenRa.Game/Traits/Activities/Repair.cs index f6fcf06b59..b343b3f506 100644 --- a/OpenRa.Game/Traits/Activities/Repair.cs +++ b/OpenRa.Game/Traits/Activities/Repair.cs @@ -16,8 +16,11 @@ namespace OpenRa.Game.Traits.Activities if (isCanceled) return NextActivity; if (remainingTicks == 0) { - var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength; - var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health); + var unitCost = self.Info.Traits.Get().Cost; + var hp = self.Info.Traits.WithInterface().First().HP; + + var costPerHp = (Rules.General.URepairPercent * unitCost) / hp; + var hpToRepair = Math.Min(Rules.General.URepairStep, hp - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -26,7 +29,7 @@ namespace OpenRa.Game.Traits.Activities } self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); - if (self.Health == self.LegacyInfo.Strength) + if (self.Health == hp) return NextActivity; var hostBuilding = Game.FindUnits(self.CenterLocation, self.CenterLocation) From 356b7dae7a56f4d93d870fc2fef0a91016d6b6b3 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 10 Jan 2010 19:25:16 +1300 Subject: [PATCH 33/83] more porting --- OpenRa.Game/Shroud.cs | 1 + OpenRa.Game/Traits/AutoHeal.cs | 13 +++---------- OpenRa.Game/Traits/AutoTarget.cs | 10 +--------- OpenRa.Game/Traits/Util.cs | 8 ++++++++ 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 18dab2724d..a6cc09b4d2 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using IjwFramework.Types; using OpenRa.Game.Graphics; +using OpenRa.Game.Traits; namespace OpenRa.Game { diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index a833cc8c25..66cc04ba6a 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -17,23 +17,16 @@ namespace OpenRa.Game.Traits self.CancelActivity(); } - float GetMaximumRange(Actor self) - { - return new[] { self.LegacyInfo.Primary, self.LegacyInfo.Secondary } - .Where(w => w != null) - .Max(w => Rules.WeaponInfo[w].Range); - } - bool NeedsNewTarget(Actor self) { var attack = self.traits.WithInterface().First(); - var range = GetMaximumRange(self); + var range = Util.GetMaximumRange(self); if (attack.target == null) return true; // he's dead. if ((attack.target.Location - self.Location).LengthSquared > range * range + 2) return true; // wandered off faster than we could follow - if (attack.target.Health == attack.target.LegacyInfo.Strength) + if (attack.target.Health == attack.target.Info.Traits.WithInterface().First().HP) return true; // fully healed return false; @@ -42,7 +35,7 @@ namespace OpenRa.Game.Traits public void Tick(Actor self) { var attack = self.traits.WithInterface().First(); - var range = GetMaximumRange(self); + var range = Util.GetMaximumRange(self); if (NeedsNewTarget(self)) AttackTarget(self, ChooseTarget(self, range)); diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 29d588a8f3..33fc5002c5 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -13,20 +13,12 @@ namespace OpenRa.Game.Traits attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null)); } - float GetMaximumRange(Actor self) - { - var info = self.Info.Traits.WithInterface().First(); - return new[] { info.PrimaryWeapon, info.SecondaryWeapon } - .Where(w => w != null) - .Max(w => Rules.WeaponInfo[w].Range); - } - public void Tick(Actor self) { if (!self.IsIdle) return; var attack = self.traits.WithInterface().First(); - var range = GetMaximumRange(self); + var range = Util.GetMaximumRange(self); if (attack.target == null || (attack.target.Location - self.Location).LengthSquared > range * range + 2) diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index fda0a447a1..bef22a08b9 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -142,5 +142,13 @@ namespace OpenRa.Game.Traits return acts.Reverse().Aggregate( (next, a) => { a.NextActivity = next; return a; }); } + + public static float GetMaximumRange(Actor self) + { + var info = self.Info.Traits.WithInterface().First(); + return new[] { info.PrimaryWeapon, info.SecondaryWeapon } + .Where(w => w != null) + .Max(w => Rules.WeaponInfo[w].Range); + } } } From cf6bb26f83f48ba46a185947842bfeccf7809c3f Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 17:50:16 +1300 Subject: [PATCH 34/83] more ported bits --- OpenRa.Game/Traits/Activities/CaptureBuilding.cs | 2 +- OpenRa.Game/Traits/Activities/Fly.cs | 2 +- OpenRa.Game/Traits/Activities/ReturnToBase.cs | 4 ++-- OpenRa.Game/Traits/Activities/Turn.cs | 2 +- OpenRa.Game/Traits/Helicopter.cs | 12 ++++++------ OpenRa.Game/Traits/Passenger.cs | 2 +- OpenRa.Game/Traits/Plane.cs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs index 66fa2fdf5a..69b7bc91d7 100644 --- a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs +++ b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if (target.Owner == self.Owner) { - if (target.Health == target.LegacyInfo.Strength) + if (target.Health == target.Info.Traits.WithInterface().First().HP) return NextActivity; target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]); } diff --git a/OpenRa.Game/Traits/Activities/Fly.cs b/OpenRa.Game/Traits/Activities/Fly.cs index cae1f43899..b9b820d8c0 100644 --- a/OpenRa.Game/Traits/Activities/Fly.cs +++ b/OpenRa.Game/Traits/Activities/Fly.cs @@ -31,7 +31,7 @@ namespace OpenRa.Game.Traits.Activities var desiredFacing = Util.GetFacing(d, unit.Facing); if (unit.Altitude == CruiseAltitude) - Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); var speed = .2f * Util.GetEffectiveSpeed(self); var angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/ReturnToBase.cs b/OpenRa.Game/Traits/Activities/ReturnToBase.cs index 75715798ea..aed998b9be 100644 --- a/OpenRa.Game/Traits/Activities/ReturnToBase.cs +++ b/OpenRa.Game/Traits/Activities/ReturnToBase.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities Actor ChooseAirfield(Actor self) { var airfield = Game.world.Actors - .Where(a => a.LegacyInfo == Rules.UnitInfo["AFLD"] /* todo: generalize this */ + .Where(a => a.Info.Name == "afld" && a.Owner == self.Owner && !Reservable.IsReserved(a)) .FirstOrDefault(); @@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits.Activities var unit = self.traits.Get(); var speed = .2f * Util.GetEffectiveSpeed(self); var approachStart = landPos - new float2(unit.Altitude * speed, 0); - var turnRadius = (128f / self.LegacyInfo.ROT) * speed / (float)Math.PI; + var turnRadius = (128f / self.Info.Traits.Get().ROT) * speed / (float)Math.PI; /* work out the center points */ var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI); diff --git a/OpenRa.Game/Traits/Activities/Turn.cs b/OpenRa.Game/Traits/Activities/Turn.cs index 4750cc7574..2f29a1bab5 100755 --- a/OpenRa.Game/Traits/Activities/Turn.cs +++ b/OpenRa.Game/Traits/Activities/Turn.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if( desiredFacing == unit.Facing ) return NextActivity; - Util.TickFacing( ref unit.Facing, desiredFacing, self.LegacyInfo.ROT ); + Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT ); return this; } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 4773133a30..8fa02f6fca 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -1,6 +1,7 @@ -using OpenRa.Game.Traits.Activities; -using System; +using System; +using System.Linq; using OpenRa.Game.GameRules; +using OpenRa.Game.Traits.Activities; namespace OpenRa.Game.Traits { @@ -17,11 +18,10 @@ namespace OpenRa.Game.Traits public IDisposable reservation; public Helicopter(Actor self) {} - // todo: push into data! static bool HeliCanEnter(Actor a) { - if (a.LegacyInfo == Rules.UnitInfo["HPAD"]) return true; - if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true; + if (a.Info.Name == "hpad") return true; + if (a.Info.Name == "fix") return true; return false; } @@ -52,7 +52,7 @@ namespace OpenRa.Game.Traits { self.CancelActivity(); self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation))); - self.QueueActivity(new Turn(self.LegacyInfo.InitialFacing)); + self.QueueActivity(new Turn(self.Info.Traits.WithInterface().FirstOrDefault().InitialFacing)); self.QueueActivity(new HeliLand(true)); } diff --git a/OpenRa.Game/Traits/Passenger.cs b/OpenRa.Game/Traits/Passenger.cs index ecf4a42a5a..33b17b2b8d 100644 --- a/OpenRa.Game/Traits/Passenger.cs +++ b/OpenRa.Game/Traits/Passenger.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits return null; var umt = self.traits.WithInterface().First().GetMovementType(); - if (!underCursor.LegacyInfo.PassengerTypes.Contains(umt)) + if (!underCursor.Info.Traits.Get().PassengerTypes.Contains(umt)) return null; return new Order("EnterTransport", self, underCursor, int2.Zero, null); diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 0733fcf541..96c2884d6c 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -20,8 +20,8 @@ namespace OpenRa.Game.Traits // todo: push into data! static bool PlaneCanEnter(Actor a) { - if (a.LegacyInfo == Rules.UnitInfo["AFLD"]) return true; - if (a.LegacyInfo == Rules.UnitInfo["FIX"]) return true; + if (a.Info.Name == "afld") return true; + if (a.Info.Name == "fix") return true; return false; } From 50b138e2de99890982d80afaa0af5ab0b8097755 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 18:31:50 +1300 Subject: [PATCH 35/83] aftermath rules in yaml too. --- RulesConverter/Program.cs | 62 +++++++------ aftermath.yaml | 185 ++++++++++++++++++++++++++++++++++++++ regen-yaml.cmd | 2 + 3 files changed, 220 insertions(+), 29 deletions(-) create mode 100644 aftermath.yaml create mode 100644 regen-yaml.cmd diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 7dc38d3f6f..ac7a6d4cb9 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -22,7 +22,7 @@ namespace RulesConverter var rules = new IniFile(ruleStreams); - var outputFile = args.Single(a => a.EndsWith(".rul")); + var outputFile = args.Single(a => !a.EndsWith(".ini")); var categoryMap = new Dictionary> { @@ -156,40 +156,44 @@ namespace RulesConverter using (var writer = File.CreateText(outputFile)) { foreach (var cat in categoryMap) - foreach (var item in rules.GetSection(cat.Key).Select(a => a.Key)) + try { - var iniSection = rules.GetSection(item); - writer.WriteLine("{0}:", item); - writer.WriteLine("\tInherits: {0}", cat.Value.First); - - var traits = iniSection.GetValue("Traits", "") - .Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - - if (iniSection.GetValue("Selectable", "yes") == "yes") - traits.Insert(0, "Selectable"); - - if (iniSection.GetValue("TechLevel", "-1") != "-1") - traits.Insert(0, "Buildable"); - - foreach (var t in traits) + foreach (var item in rules.GetSection(cat.Key).Select(a => a.Key)) { - writer.WriteLine("\t{0}:", t); + var iniSection = rules.GetSection(item); + writer.WriteLine("{0}:", item); + writer.WriteLine("\tInherits: {0}", cat.Value.First); - if (traitMap.ContainsKey(t)) - foreach (var kv in traitMap[t]) - { - var v = kv.Value == "$Tab" ? cat.Value.Second : iniSection.GetValue(kv.Value, ""); - var fmt = "\t\t{0}: {1}"; - var k = kv.Key; - if (k.StartsWith("@")) { k = k.Substring(1); /*fmt = "\t\t{0}: [{1}]";*/ } - if (k.StartsWith("$")) { k = k.Substring(1); fmt = "\t\t{0}: \"{1}\""; } + var traits = iniSection.GetValue("Traits", "") + .Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); - if (!string.IsNullOrEmpty(v)) writer.WriteLine(fmt, k, v); - } + if (iniSection.GetValue("Selectable", "yes") == "yes") + traits.Insert(0, "Selectable"); + + if (iniSection.GetValue("TechLevel", "-1") != "-1") + traits.Insert(0, "Buildable"); + + foreach (var t in traits) + { + writer.WriteLine("\t{0}:", t); + + if (traitMap.ContainsKey(t)) + foreach (var kv in traitMap[t]) + { + var v = kv.Value == "$Tab" ? cat.Value.Second : iniSection.GetValue(kv.Value, ""); + var fmt = "\t\t{0}: {1}"; + var k = kv.Key; + if (k.StartsWith("@")) { k = k.Substring(1); /*fmt = "\t\t{0}: [{1}]";*/ } + if (k.StartsWith("$")) { k = k.Substring(1); fmt = "\t\t{0}: \"{1}\""; } + + if (!string.IsNullOrEmpty(v)) writer.WriteLine(fmt, k, v); + } + } + + writer.WriteLine(); } - - writer.WriteLine(); } + catch { } } } } diff --git a/aftermath.yaml b/aftermath.yaml new file mode 100644 index 0000000000..28e8147282 --- /dev/null +++ b/aftermath.yaml @@ -0,0 +1,185 @@ +STNK: + Inherits: DefaultVehicle + Selectable: + Voice: VehicleVoice + Unit: + HP: 200 + Armor: heavy + Mobile: + Sight: 5 + ROT: 5 + Speed: 10 + Turreted: + AttackTurreted: + PrimaryWeapon: APTusk + Recoil: 2 + RenderUnitTurreted: + Cloak: + Chronoshiftable: + +TTNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 8 + Tab: Vehicle + Prerequisites: tsla + Owner: soviet + Cost: 1500 + Description: "Tesla Tank" + Selectable: + Voice: VehicleVoice + Unit: + HP: 110 + Armor: light + Crewed: yes + Mobile: + Sight: 7 + ROT: 5 + Speed: 8 + AttackBase: + PrimaryWeapon: TTankZap + RenderUnitSpinner: + Chronoshiftable: + +CTNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 12 + Tab: Vehicle + Prerequisites: atek + Owner: allies + Cost: 2400 + Description: "Chrono Tank" + Selectable: + Voice: VehicleVoice + Unit: + HP: 350 + Armor: light + Mobile: + Sight: 5 + ROT: 5 + Speed: 5 + AttackBase: + PrimaryWeapon: APTusk + RenderUnit: + ChronoshiftDeploy: + Chronoshiftable: + +DTRK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 13 + Tab: Vehicle + Prerequisites: mslo + Owner: allies,soviet + Cost: 2400 + Description: "Demo Truck" + Selectable: + Voice: VehicleVoice + Unit: + HP: 110 + Armor: light + Mobile: + Sight: 3 + ROT: 5 + Speed: 8 + AttackBase: + PrimaryWeapon: Democharge + RenderUnit: + DemoTruck: + +QTNK: + Inherits: DefaultVehicle + Buildable: + TechLevel: 10 + Tab: Vehicle + Prerequisites: stek + Owner: soviet + Cost: 2300 + Description: "M.A.D. Tank" + Selectable: + Voice: VehicleVoice + Unit: + HP: 300 + Armor: heavy + Crewed: no + Mobile: + Sight: 6 + ROT: 5 + Speed: 3 + RenderUnit: + Chronoshiftable: + +MSUB: + Inherits: DefaultShip + Buildable: + TechLevel: 9 + Tab: Ship + Prerequisites: stek + Owner: soviet + Cost: 1650 + Description: "Missile Submarine" + Selectable: + Unit: + HP: 150 + Armor: light + Mobile: + Sight: 6 + ROT: 7 + Speed: 5 + AttackBase: + PrimaryWeapon: SubSCUD + RenderUnit: + Submarine: + Chronoshiftable: + +SHOK: + Inherits: DefaultInfantry + Buildable: + TechLevel: 7 + Tab: Infantry + Prerequisites: tsla + Owner: soviet + Cost: 900 + Description: "Tesla Trooper" + Selectable: + Voice: ShokVoice + Unit: + HP: 80 + Armor: none + Mobile: + Sight: 4 + Speed: 3 + AttackBase: + PrimaryWeapon: PortaTesla + RenderInfantry: + TakeCover: + Passenger: + +MECH: + Inherits: DefaultInfantry + Buildable: + TechLevel: 7 + Tab: Infantry + Prerequisites: fix + Owner: allies + Cost: 950 + Description: "Mechanic" + LongDesc: "Heals nearby vehicles.\n Strong vs Nothing\n Weak vs Everything" + Selectable: + Voice: MechVoice + Bounds: 12,17,0,-9 + Unit: + HP: 60 + Armor: none + Mobile: + Sight: 3 + Speed: 4 + RenderInfantry: + AutoHeal: + AttackBase: + PrimaryWeapon: GoodWrench + TakeCover: + SquishByTank: + Passenger: + diff --git a/regen-yaml.cmd b/regen-yaml.cmd new file mode 100644 index 0000000000..5e83f3b6d1 --- /dev/null +++ b/regen-yaml.cmd @@ -0,0 +1,2 @@ +RulesConverter/bin/debug/RulesConverter units.ini rules.ini ra.yaml +RulesConverter/bin/debug/RulesConverter aftermathUnits.ini aftrmath.ini aftermath.yaml \ No newline at end of file From 4b19f1dfe550ecd9d1fb8b7a8ae07c7d33f5ae10 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 18:37:35 +1300 Subject: [PATCH 36/83] sight moved to Unit/Building --- OpenRa.Game/Shroud.cs | 2 +- OpenRa.Game/Traits/Building.cs | 1 + OpenRa.Game/Traits/Mobile.cs | 1 - RulesConverter/Program.cs | 7 +- aftermath.yaml | 16 +-- ra.yaml | 244 +++++++++------------------------ regen-yaml.cmd | 4 +- 7 files changed, 83 insertions(+), 192 deletions(-) diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index a6cc09b4d2..a34931aa8b 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game public void Explore(Actor a) { - foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.LegacyInfo.Sight)) + foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Traits.Get().Sight)) explored[t.X, t.Y] = true; dirty = true; diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index a626b65a9e..c8a6c4c08a 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -15,6 +15,7 @@ namespace OpenRa.Game.Traits public readonly ArmorType Armor = ArmorType.none; public readonly bool Crewed = false; // replace with trait? public readonly int InitialFacing = 128; + public readonly int Sight = 0; } class BuildingInfo : OwnedActorInfo, ITraitInfo diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index febe071a7c..041ac270f4 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -7,7 +7,6 @@ namespace OpenRa.Game.Traits { class MobileInfo : ITraitInfo { - public readonly int Sight = 0; public readonly int ROT = 0; public readonly int Speed = 0; diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index ac7a6d4cb9..5fba5729c5 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -40,7 +40,8 @@ namespace RulesConverter { "HP", "Strength" }, { "Armor", "Armor" }, { "Crewed", "Crewed" }, - { "InitialFacing", "InitialFacing" } } + { "InitialFacing", "InitialFacing" }, + { "Sight", "Sight" } } }, { "Selectable", new PL { @@ -50,7 +51,6 @@ namespace RulesConverter }, { "Mobile", new PL { - { "Sight", "Sight" }, { "ROT", "ROT" }, { "Speed", "Speed" } } //{ "MovementType", ... }, @@ -115,7 +115,8 @@ namespace RulesConverter { "Armor", "Armor" }, { "Crewed", "Crewed" }, { "WaterBound", "WaterBound" }, - { "InitialFacing", "InitialFacing" } } + { "InitialFacing", "InitialFacing" }, + { "Sight", "Sight" } } }, { "StoresOre", new PL { diff --git a/aftermath.yaml b/aftermath.yaml index 28e8147282..7d422e542f 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -5,8 +5,8 @@ STNK: Unit: HP: 200 Armor: heavy - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 10 Turreted: @@ -32,8 +32,8 @@ TTNK: HP: 110 Armor: light Crewed: yes - Mobile: Sight: 7 + Mobile: ROT: 5 Speed: 8 AttackBase: @@ -55,8 +55,8 @@ CTNK: Unit: HP: 350 Armor: light - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 5 AttackBase: @@ -79,8 +79,8 @@ DTRK: Unit: HP: 110 Armor: light - Mobile: Sight: 3 + Mobile: ROT: 5 Speed: 8 AttackBase: @@ -103,8 +103,8 @@ QTNK: HP: 300 Armor: heavy Crewed: no - Mobile: Sight: 6 + Mobile: ROT: 5 Speed: 3 RenderUnit: @@ -123,8 +123,8 @@ MSUB: Unit: HP: 150 Armor: light - Mobile: Sight: 6 + Mobile: ROT: 7 Speed: 5 AttackBase: @@ -147,8 +147,8 @@ SHOK: Unit: HP: 80 Armor: none - Mobile: Sight: 4 + Mobile: Speed: 3 AttackBase: PrimaryWeapon: PortaTesla @@ -172,8 +172,8 @@ MECH: Unit: HP: 60 Armor: none - Mobile: Sight: 3 + Mobile: Speed: 4 RenderInfantry: AutoHeal: diff --git a/ra.yaml b/ra.yaml index 51defaa4c3..4a97483009 100644 --- a/ra.yaml +++ b/ra.yaml @@ -14,8 +14,8 @@ V2RL: HP: 150 Armor: light Crewed: yes - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 7 AttackBase: @@ -43,8 +43,8 @@ V2RL: HP: 300 Armor: heavy Crewed: yes - Mobile: Sight: 4 + Mobile: ROT: 5 Speed: 9 Turreted: @@ -74,8 +74,8 @@ V2RL: HP: 400 Armor: heavy Crewed: yes - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 8 Turreted: @@ -105,8 +105,8 @@ V2RL: HP: 400 Armor: heavy Crewed: yes - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 7 Turreted: @@ -136,8 +136,8 @@ V2RL: HP: 600 Armor: heavy Crewed: yes - Mobile: Sight: 6 + Mobile: ROT: 5 Speed: 4 Turreted: @@ -170,8 +170,8 @@ MRJ: HP: 110 Armor: light Crewed: yes - Mobile: Sight: 7 + Mobile: ROT: 5 Speed: 9 RenderUnitSpinner: @@ -198,8 +198,8 @@ MGG: HP: 110 Armor: light Crewed: yes - Mobile: Sight: 4 + Mobile: ROT: 5 Speed: 9 RenderUnitSpinner: @@ -225,8 +225,8 @@ ARTY: HP: 75 Armor: light Crewed: yes - Mobile: Sight: 5 + Mobile: ROT: 2 Speed: 6 AttackBase: @@ -257,8 +257,8 @@ HARV: HP: 600 Armor: heavy Crewed: yes - Mobile: Sight: 4 + Mobile: ROT: 5 Speed: 6 RenderUnit: @@ -284,8 +284,8 @@ MCV: HP: 600 Armor: light Crewed: yes - Mobile: Sight: 4 + Mobile: ROT: 5 Speed: 6 McvDeploy: @@ -311,8 +311,8 @@ JEEP: HP: 150 Armor: light Crewed: yes - Mobile: Sight: 6 + Mobile: ROT: 10 Speed: 10 Turreted: @@ -342,8 +342,8 @@ APC: Unit: HP: 200 Armor: heavy - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 10 AttackBase: @@ -377,8 +377,8 @@ MNLY.AP: HP: 100 Armor: heavy Crewed: yes - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 9 RenderUnit: @@ -409,8 +409,8 @@ MNLY.AT: HP: 100 Armor: heavy Crewed: yes - Mobile: Sight: 5 + Mobile: ROT: 5 Speed: 9 RenderUnit: @@ -438,8 +438,8 @@ SS: Unit: HP: 120 Armor: light - Mobile: Sight: 6 + Mobile: ROT: 7 Speed: 6 RenderUnit: @@ -463,8 +463,8 @@ DD: Unit: HP: 400 Armor: heavy - Mobile: Sight: 6 + Mobile: ROT: 7 Speed: 6 Turreted: @@ -490,8 +490,8 @@ CA: Unit: HP: 700 Armor: heavy - Mobile: Sight: 7 + Mobile: ROT: 5 Speed: 4 Turreted: @@ -518,8 +518,8 @@ LST: Unit: HP: 350 Armor: heavy - Mobile: Sight: 6 + Mobile: ROT: 10 Speed: 14 RenderUnit: @@ -541,8 +541,8 @@ PT: Unit: HP: 200 Armor: heavy - Mobile: Sight: 7 + Mobile: ROT: 7 Speed: 9 Turreted: @@ -569,6 +569,7 @@ MIG: HP: 50 Armor: light InitialFacing: 192 + Sight: 0 AttackPlane: PrimaryWeapon: Maverick Plane: @@ -596,6 +597,7 @@ YAK: Armor: light Crewed: yes InitialFacing: 192 + Sight: 0 AttackPlane: PrimaryWeapon: ChainGun Plane: @@ -622,6 +624,7 @@ TRAN: HP: 90 Armor: light InitialFacing: 20 + Sight: 0 Helicopter: ROT: 5 Speed: 12 @@ -649,6 +652,7 @@ HELI: Armor: heavy Crewed: yes InitialFacing: 20 + Sight: 0 AttackHeli: PrimaryWeapon: Hellfire PrimaryOffset: -5,0,0,2 @@ -679,6 +683,7 @@ HIND: Armor: heavy Crewed: yes InitialFacing: 20 + Sight: 0 AttackHeli: PrimaryWeapon: ChainGun PrimaryOffset: -5,0,0,2 @@ -713,6 +718,7 @@ IRON: HP: 400 Armor: wood Crewed: yes + Sight: 10 RenderBuilding: IronCurtainable: IronCurtain: @@ -738,6 +744,7 @@ PDOX: HP: 400 Armor: wood Crewed: yes + Sight: 10 RenderBuilding: Chronosphere: IronCurtainable: @@ -761,6 +768,7 @@ PBOX: HP: 400 Armor: wood Crewed: yes + Sight: 5 Turreted: RenderBuilding: AttackTurreted: @@ -787,6 +795,7 @@ HBOX: HP: 600 Armor: wood Crewed: yes + Sight: 5 Turreted: RenderBuilding: AttackTurreted: @@ -814,6 +823,7 @@ TSLA: HP: 400 Armor: heavy Crewed: yes + Sight: 8 Turreted: RenderBuildingCharge: AttackTurreted: @@ -841,6 +851,7 @@ GUN: Armor: heavy Crewed: yes InitialFacing: 50 + Sight: 6 Turreted: RenderBuildingTurreted: AttackTurreted: @@ -869,6 +880,7 @@ AGUN: Armor: heavy Crewed: yes InitialFacing: 224 + Sight: 6 Turreted: RenderBuildingTurreted: AttackTurreted: @@ -896,6 +908,7 @@ FTUR: HP: 400 Armor: heavy Crewed: yes + Sight: 6 RenderBuilding: AttackTurreted: PrimaryWeapon: FireballLauncher @@ -923,6 +936,7 @@ GAP: HP: 1000 Armor: wood Crewed: yes + Sight: 10 RenderBuilding: IronCurtainable: @@ -945,6 +959,7 @@ SAM: HP: 400 Armor: heavy Crewed: yes + Sight: 5 Turreted: RenderBuildingTurreted: AttackTurreted: @@ -971,6 +986,7 @@ MSLO: HP: 400 Armor: heavy Crewed: yes + Sight: 5 RenderBuilding: IronCurtainable: @@ -995,6 +1011,7 @@ ATEK: HP: 400 Armor: wood Crewed: yes + Sight: 10 RenderBuilding: IronCurtainable: GpsLaunchSite: @@ -1020,6 +1037,7 @@ WEAP: HP: 1000 Armor: light Crewed: yes + Sight: 4 RenderWarFactory: RenderBuilding: RallyPoint: @@ -1048,6 +1066,7 @@ SYRD: HP: 1000 Armor: light WaterBound: yes + Sight: 4 RenderBuilding: ProductionSurround: IronCurtainable: @@ -1074,6 +1093,7 @@ SPEN: HP: 1000 Armor: light WaterBound: yes + Sight: 4 RenderBuilding: ProductionSurround: IronCurtainable: @@ -1091,6 +1111,7 @@ FACT: HP: 1000 Armor: heavy Crewed: yes + Sight: 5 RenderBuilding: ConstructionYard: IronCurtainable: @@ -1116,6 +1137,7 @@ PROC: HP: 900 Armor: wood Crewed: yes + Sight: 6 RenderBuilding: AcceptsOre: StoresOre: @@ -1142,6 +1164,7 @@ SILO: Capturable: true HP: 300 Armor: wood + Sight: 4 RenderBuildingOre: StoresOre: Pips: 5 @@ -1169,6 +1192,7 @@ HPAD: HP: 800 Armor: wood Crewed: yes + Sight: 5 RenderBuilding: Production: BelowUnits: @@ -1197,6 +1221,7 @@ DOME: HP: 1000 Armor: wood Crewed: yes + Sight: 10 RenderBuilding: ProvidesRadar: IronCurtainable: @@ -1221,6 +1246,7 @@ AFLD: HP: 1000 Armor: heavy Crewed: yes + Sight: 7 RenderBuilding: Production: BelowUnits: @@ -1248,6 +1274,7 @@ POWR: HP: 400 Armor: wood Crewed: yes + Sight: 4 RenderBuilding: IronCurtainable: @@ -1272,6 +1299,7 @@ APWR: HP: 700 Armor: wood Crewed: yes + Sight: 4 RenderBuilding: IronCurtainable: @@ -1296,6 +1324,7 @@ STEK: HP: 600 Armor: wood Crewed: yes + Sight: 4 RenderBuilding: IronCurtainable: @@ -1320,6 +1349,7 @@ BARR: HP: 800 Armor: wood Crewed: yes + Sight: 5 RenderBuilding: RallyPoint: Production: @@ -1346,6 +1376,7 @@ TENT: HP: 800 Armor: wood Crewed: yes + Sight: 5 RenderBuilding: RallyPoint: Production: @@ -1369,6 +1400,7 @@ KENN: Dimensions: 1,1 HP: 400 Armor: wood + Sight: 4 RenderBuilding: RallyPoint: Production: @@ -1394,6 +1426,7 @@ FIX: HP: 800 Armor: wood Crewed: yes + Sight: 5 RenderBuilding: BelowUnits: Reservable: @@ -1418,6 +1451,7 @@ FACF: BaseNormal: no Bib: yes HP: 30 + Sight: 4 RenderBuilding: Image: FACT Fake: @@ -1443,6 +1477,7 @@ WEAF: BaseNormal: no Bib: yes HP: 30 + Sight: 4 RenderWarFactory: RenderBuilding: Image: WEAP @@ -1470,6 +1505,7 @@ SYRF: Adjacent: 8 HP: 30 WaterBound: yes + Sight: 4 RenderBuilding: Image: SYRD Fake: @@ -1487,6 +1523,7 @@ SPEF: Adjacent: 8 HP: 30 WaterBound: yes + Sight: 4 RenderBuilding: Image: SPEN Fake: @@ -1511,6 +1548,7 @@ DOMF: BaseNormal: no Bib: yes HP: 30 + Sight: 4 RenderBuilding: Image: DOME Fake: @@ -1533,154 +1571,6 @@ MINV: BelowUnits: InvisibleToOthers: -T01: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T02: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T03: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T05: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T06: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T07: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T08: - Inherits: DefaultBuilding - Building: - Footprint: x_ - Dimensions: 2,1 - RenderBuilding: - -T10: - Inherits: DefaultBuilding - Building: - Footprint: xx xx - Dimensions: 2,2 - RenderBuilding: - -T11: - Inherits: DefaultBuilding - Building: - Footprint: xx xx - Dimensions: 2,2 - RenderBuilding: - -T12: - Inherits: DefaultBuilding - Building: - Footprint: xx xx - Dimensions: 2,2 - RenderBuilding: - -T13: - Inherits: DefaultBuilding - Building: - Footprint: xx xx - Dimensions: 2,2 - RenderBuilding: - -T14: - Inherits: DefaultBuilding - Building: - Footprint: xx xx - Dimensions: 2,2 - RenderBuilding: - -T15: - Inherits: DefaultBuilding - Building: - Footprint: xx xx - Dimensions: 2,2 - RenderBuilding: - -T16: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -T17: - Inherits: DefaultBuilding - Building: - Footprint: x_ x_ - Dimensions: 2,2 - RenderBuilding: - -TC01: - Inherits: DefaultBuilding - Building: - Footprint: xx_ xx_ - Dimensions: 3,2 - RenderBuilding: - -TC02: - Inherits: DefaultBuilding - Building: - Footprint: xx_ xx_ - Dimensions: 3,2 - RenderBuilding: - -TC03: - Inherits: DefaultBuilding - Building: - Footprint: xx_ xx_ - Dimensions: 3,2 - RenderBuilding: - -TC04: - Inherits: DefaultBuilding - Building: - Footprint: xxx_ xxx_ xxx_ - Dimensions: 4,3 - RenderBuilding: - -TC05: - Inherits: DefaultBuilding - Building: - Footprint: xxx_ xxx_ xxx_ - Dimensions: 4,3 - RenderBuilding: - -MINE: - Inherits: DefaultBuilding - Building: - Footprint: x - Dimensions: 1,1 - RenderBuilding: - SeedsOre: - DOG: Inherits: DefaultInfantry Buildable: @@ -1697,8 +1587,8 @@ DOG: Unit: HP: 12 Armor: none - Mobile: Sight: 5 + Mobile: Speed: 4 RenderInfantry: Passenger: @@ -1717,8 +1607,8 @@ E1: Unit: HP: 50 Armor: none - Mobile: Sight: 4 + Mobile: Speed: 4 RenderInfantry: AttackBase: @@ -1742,8 +1632,8 @@ E2: Unit: HP: 50 Armor: none - Mobile: Sight: 4 + Mobile: Speed: 5 RenderInfantry: AttackBase: @@ -1768,8 +1658,8 @@ E3: Unit: HP: 45 Armor: none - Mobile: Sight: 4 + Mobile: Speed: 3 RenderInfantry: AttackBase: @@ -1795,8 +1685,8 @@ E4: Unit: HP: 40 Armor: none - Mobile: Sight: 4 + Mobile: Speed: 3 RenderInfantry: AttackBase: @@ -1822,8 +1712,8 @@ E6: Unit: HP: 25 Armor: none - Mobile: Sight: 4 + Mobile: Speed: 4 EngineerCapture: RenderInfantry: @@ -1847,8 +1737,8 @@ SPY: Unit: HP: 25 Armor: none - Mobile: Sight: 5 + Mobile: Speed: 4 RenderInfantry: TakeCover: @@ -1871,8 +1761,8 @@ THF: Unit: HP: 25 Armor: none - Mobile: Sight: 5 + Mobile: Speed: 4 RenderInfantry: TakeCover: @@ -1896,8 +1786,8 @@ E7: Unit: HP: 100 Armor: none - Mobile: Sight: 6 + Mobile: Speed: 5 RenderInfantry: C4Demolition: @@ -1923,8 +1813,8 @@ MEDI: Unit: HP: 80 Armor: none - Mobile: Sight: 3 + Mobile: Speed: 4 RenderInfantry: AutoHeal: diff --git a/regen-yaml.cmd b/regen-yaml.cmd index 5e83f3b6d1..416408aa0b 100644 --- a/regen-yaml.cmd +++ b/regen-yaml.cmd @@ -1,2 +1,2 @@ -RulesConverter/bin/debug/RulesConverter units.ini rules.ini ra.yaml -RulesConverter/bin/debug/RulesConverter aftermathUnits.ini aftrmath.ini aftermath.yaml \ No newline at end of file +RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini ra.yaml +RulesConverter\bin\debug\RulesConverter.exe aftermathUnits.ini aftrmath.ini aftermath.yaml \ No newline at end of file From b94e5441dc54cb335da0848fed75a3a6b970f255 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 18:49:28 +1300 Subject: [PATCH 37/83] RenderUnitTurreted ported --- OpenRa.Game/Effects/Corpse.cs | 3 +-- OpenRa.Game/Traits/RenderSimple.cs | 8 +++++++- OpenRa.Game/Traits/RenderUnitRotor.cs | 4 ++-- OpenRa.Game/Traits/RenderUnitSpinner.cs | 2 +- OpenRa.Game/Traits/RenderUnitTurreted.cs | 17 +++++++++-------- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs index 470a790f12..2c4570d46c 100755 --- a/OpenRa.Game/Effects/Corpse.cs +++ b/OpenRa.Game/Effects/Corpse.cs @@ -15,8 +15,7 @@ namespace OpenRa.Game.Effects public Corpse(Actor fromActor, int death) { - var info = fromActor.Info.Traits.WithInterface().First(); - anim = new Animation(info.Image ?? fromActor.Info.Name); + anim = new Animation(fromActor.traits.WithInterface().FirstOrDefault().GetImage(fromActor)); anim.PlayThen("die{0}".F(death + 1), () => Game.world.AddFrameEndTask(w => w.Remove(this))); diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 1b1ed3ff26..30cc447c8f 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using OpenRa.Game.Graphics; namespace OpenRa.Game.Traits @@ -16,9 +17,14 @@ namespace OpenRa.Game.Traits public Dictionary anims = new Dictionary(); public Animation anim { get { return anims[ "" ].Animation; } } + public string GetImage(Actor self) + { + return self.Info.Traits.WithInterface().First().Image ?? self.Info.Name; + } + public RenderSimple(Actor self) { - anims.Add( "", new Animation( self.LegacyInfo.Image ?? self.LegacyInfo.Name ) ); + anims.Add( "", new Animation( GetImage(self) ) ); } public virtual IEnumerable Render( Actor self ) diff --git a/OpenRa.Game/Traits/RenderUnitRotor.cs b/OpenRa.Game/Traits/RenderUnitRotor.cs index a8d6b75f23..7606453a91 100755 --- a/OpenRa.Game/Traits/RenderUnitRotor.cs +++ b/OpenRa.Game/Traits/RenderUnitRotor.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits var unit = self.traits.Get(); var info = self.Info.Traits.Get(); - rotorAnim = new Animation(info.Image ?? self.Info.Name); + rotorAnim = new Animation(GetImage(self)); rotorAnim.PlayRepeating("rotor"); anims.Add( "rotor_1", new AnimationWithOffset( rotorAnim, @@ -29,7 +29,7 @@ namespace OpenRa.Game.Traits if (info.SecondaryOffset == null) return; - secondRotorAnim = new Animation(info.Image ?? self.Info.Name); + secondRotorAnim = new Animation(GetImage(self)); secondRotorAnim.PlayRepeating( "rotor2" ); anims.Add( "rotor_2", new AnimationWithOffset( secondRotorAnim, diff --git a/OpenRa.Game/Traits/RenderUnitSpinner.cs b/OpenRa.Game/Traits/RenderUnitSpinner.cs index f0415e816b..f0a3f3dce0 100755 --- a/OpenRa.Game/Traits/RenderUnitSpinner.cs +++ b/OpenRa.Game/Traits/RenderUnitSpinner.cs @@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits var unit = self.traits.Get(); var info = self.Info.Traits.Get(); - var spinnerAnim = new Animation( info.Image ?? self.Info.Name ); + var spinnerAnim = new Animation( GetImage(self) ); spinnerAnim.PlayRepeating( "spinner" ); anims.Add( "spinner", new AnimationWithOffset( spinnerAnim, diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index 3aa1c94a9f..c6222bd0b8 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -17,31 +17,32 @@ namespace OpenRa.Game.Traits var unit = self.traits.Get(); var turreted = self.traits.Get(); var attack = self.traits.WithInterface().FirstOrDefault(); + var attackInfo = self.Info.Traits.WithInterface().First(); - var turretAnim = new Animation(self.LegacyInfo.Name); + var turretAnim = new Animation(GetImage(self)); turretAnim.PlayFacing( "turret", () => turreted.turretFacing ); - if( self.LegacyInfo.PrimaryOffset != null ) + if( attackInfo.PrimaryOffset != null ) anims.Add("turret_1", new AnimationWithOffset( turretAnim, - () => Util.GetTurretPosition(self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil), + () => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil), null) { ZOffset = 1 }); - if( self.LegacyInfo.SecondaryOffset != null ) + if (attackInfo.SecondaryOffset != null) anims.Add("turret_2", new AnimationWithOffset( turretAnim, - () => Util.GetTurretPosition(self, unit, self.LegacyInfo.SecondaryOffset, attack.secondaryRecoil), + () => Util.GetTurretPosition(self, unit, attackInfo.SecondaryOffset, attack.secondaryRecoil), null) { ZOffset = 1 }); - if( self.LegacyInfo.MuzzleFlash ) + if( attackInfo.MuzzleFlash ) { - var muzzleFlash = new Animation( self.LegacyInfo.Name ); + var muzzleFlash = new Animation( GetImage(self) ); muzzleFlash.PlayFetchIndex( "muzzle", () => ( Util.QuantizeFacing( self.traits.Get().turretFacing, 8 ) ) * 6 + (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */ anims.Add( "muzzle_flash", new AnimationWithOffset( muzzleFlash, - () => Util.GetTurretPosition( self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil ), + () => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil), () => attack.primaryRecoil <= 0 ) ); } } From 21bf3cd0e189a6231eb7e68d04e72d4852e9ca50 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 18:57:49 +1300 Subject: [PATCH 38/83] fixed some dumb bugs; more porting --- OpenRa.Game/Graphics/Viewport.cs | 2 +- OpenRa.Game/Shroud.cs | 4 +- OpenRa.Game/Traits/Production.cs | 10 +- OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs | 5 +- RulesConverter/Program.cs | 4 + ra.yaml | 149 ++++++++++++++++++++ regen-yaml.cmd | 2 +- 7 files changed, 167 insertions(+), 9 deletions(-) diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 5af11ba1d5..9a35a4ef5b 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -97,7 +97,7 @@ namespace OpenRa.Game.Graphics public void GoToStartLocation() { - Center(Game.world.Actors.Where(a => a.LegacyInfo != null && a.Owner == Game.LocalPlayer)); + Center(Game.world.Actors.Where(a => a.Info != null && a.Owner == Game.LocalPlayer)); } } } diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index a34931aa8b..1b0cdfae55 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -33,7 +33,9 @@ namespace OpenRa.Game public void Explore(Actor a) { - foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Traits.Get().Sight)) + foreach (var t in Game.FindTilesInCircle( + (1f / Game.CellSize * a.CenterLocation).ToInt2(), + a.Info.Traits.WithInterface().First().Sight)) explored[t.X, t.Y] = true; dirty = true; diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index b6b2481248..5297112145 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -6,6 +6,8 @@ namespace OpenRa.Game.Traits { class ProductionInfo : ITraitInfo { + public readonly int[] SpawnOffset = null; + public object Create(Actor self) { return new Production(self); } } @@ -23,7 +25,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - return newUnit.LegacyInfo.InitialFacing; + return newUnit.Info.Traits.WithInterface().FirstOrDefault().InitialFacing; } public bool Produce( Actor self, LegacyUnitInfo producee ) @@ -43,10 +45,10 @@ namespace OpenRa.Game.Traits newUnit.QueueActivity( new Activities.Move( rp.rallyPoint, 1 ) ); } - var bi = self.LegacyInfo as LegacyBuildingInfo; - if (bi != null && bi.SpawnOffset != null) + var pi = self.Info.Traits.Get(); + if (pi != null && pi.SpawnOffset != null) newUnit.CenterLocation = self.CenterLocation - + new float2(bi.SpawnOffset[0], bi.SpawnOffset[1]); + + new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]); Game.world.Add( newUnit ); diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index 53211abcf6..fa8f569bbc 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -17,13 +17,14 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); var attack = self.traits.WithInterface().First(); + var attackInfo = self.Info.Traits.WithInterface().First(); - var muzzleFlash = new Animation(self.LegacyInfo.Name); + var muzzleFlash = new Animation(GetImage(self)); muzzleFlash.PlayFetchIndex("muzzle", () => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f)); anims.Add( "muzzle", new AnimationWithOffset( muzzleFlash, - () => self.LegacyInfo.PrimaryOffset.AbsOffset(), + () => attackInfo.PrimaryOffset.AbsOffset(), () => attack.primaryRecoil <= 0 ) ); } } diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 5fba5729c5..345476347b 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -139,6 +139,10 @@ namespace RulesConverter { "MuzzleFlash", "MuzzleFlash" }, // maybe { "Recoil", "Recoil"} } }, + + { "Production", new PL { + { "SpawnOffset", "SpawnOffset" } } + }, }; traitMap["RenderUnit"] = traitMap["RenderBuilding"]; diff --git a/ra.yaml b/ra.yaml index 4a97483009..32b914b875 100644 --- a/ra.yaml +++ b/ra.yaml @@ -1195,6 +1195,7 @@ HPAD: Sight: 5 RenderBuilding: Production: + SpawnOffset: 0,-4 BelowUnits: Reservable: IronCurtainable: @@ -1571,6 +1572,154 @@ MINV: BelowUnits: InvisibleToOthers: +T01: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T02: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T03: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T05: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T06: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T07: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T08: + Inherits: DefaultBuilding + Building: + Footprint: x_ + Dimensions: 2,1 + RenderBuilding: + +T10: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T11: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T12: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T13: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T14: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T15: + Inherits: DefaultBuilding + Building: + Footprint: xx xx + Dimensions: 2,2 + RenderBuilding: + +T16: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +T17: + Inherits: DefaultBuilding + Building: + Footprint: x_ x_ + Dimensions: 2,2 + RenderBuilding: + +TC01: + Inherits: DefaultBuilding + Building: + Footprint: xx_ xx_ + Dimensions: 3,2 + RenderBuilding: + +TC02: + Inherits: DefaultBuilding + Building: + Footprint: xx_ xx_ + Dimensions: 3,2 + RenderBuilding: + +TC03: + Inherits: DefaultBuilding + Building: + Footprint: xx_ xx_ + Dimensions: 3,2 + RenderBuilding: + +TC04: + Inherits: DefaultBuilding + Building: + Footprint: xxx_ xxx_ xxx_ + Dimensions: 4,3 + RenderBuilding: + +TC05: + Inherits: DefaultBuilding + Building: + Footprint: xxx_ xxx_ xxx_ + Dimensions: 4,3 + RenderBuilding: + +MINE: + Inherits: DefaultBuilding + Building: + Footprint: x + Dimensions: 1,1 + RenderBuilding: + SeedsOre: + DOG: Inherits: DefaultInfantry Buildable: diff --git a/regen-yaml.cmd b/regen-yaml.cmd index 416408aa0b..f5018afb67 100644 --- a/regen-yaml.cmd +++ b/regen-yaml.cmd @@ -1,2 +1,2 @@ -RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini ra.yaml +RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini trees.ini ra.yaml RulesConverter\bin\debug\RulesConverter.exe aftermathUnits.ini aftrmath.ini aftermath.yaml \ No newline at end of file From 5faa1ea72491949809285a9b5b1c984e1f1f4363 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 19:07:22 +1300 Subject: [PATCH 39/83] more --- OpenRa.Game/Game.cs | 2 +- OpenRa.Game/GameRules/TechTree.cs | 5 +++-- OpenRa.Game/Orders/PowerDownOrderGenerator.cs | 2 +- OpenRa.Game/Orders/RepairOrderGenerator.cs | 6 +++--- OpenRa.Game/Orders/SellOrderGenerator.cs | 4 ++-- OpenRa.Game/Traits/Activities/HeliReturn.cs | 9 ++++++--- OpenRa.Game/Traits/Building.cs | 1 + OpenRa.Game/Traits/Repairable.cs | 2 +- RulesConverter/Program.cs | 3 ++- 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 50addb641b..7ed631fc74 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -339,7 +339,7 @@ namespace OpenRa.Game heuristic = loc => { var b = Game.BuildingInfluence.GetBuildingAt(loc); - if (b != null && b.Owner == p && (b.LegacyInfo as LegacyBuildingInfo).BaseNormal) return 0; + if (b != null && b.Owner == p && b.Info.Traits.Get().BaseNormal) return 0; if ((loc - position).Length > maxDistance) return float.PositiveInfinity; /* not quite right */ return 1; diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index c732f7819d..57b707f670 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using IjwFramework.Collections; +using OpenRa.Game.Traits; namespace OpenRa.Game.GameRules { @@ -21,8 +22,8 @@ namespace OpenRa.Game.GameRules public Cache> GatherBuildings( Player player ) { var ret = new Cache>( x => new List() ); - foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.LegacyInfo is LegacyBuildingInfo ) ) - ret[ b.LegacyInfo.Name ].Add( b ); + foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info != null && x.Info.Traits.Contains() ) ) + ret[ b.Info.Name ].Add( b ); return ret; } diff --git a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs index 2bfbb12359..84631b0596 100644 --- a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs +++ b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs @@ -25,7 +25,7 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.LegacyInfo.Selectable).FirstOrDefault(); + && a.traits.Contains()).FirstOrDefault(); var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; diff --git a/OpenRa.Game/Orders/RepairOrderGenerator.cs b/OpenRa.Game/Orders/RepairOrderGenerator.cs index 3d87fe6b6d..60d36c79ef 100644 --- a/OpenRa.Game/Orders/RepairOrderGenerator.cs +++ b/OpenRa.Game/Orders/RepairOrderGenerator.cs @@ -25,11 +25,11 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.LegacyInfo.Selectable).FirstOrDefault(); + && a.traits.Contains()).FirstOrDefault(); - var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; + var building = underCursor != null ? underCursor.Info.Traits.Get() : null; - if (building != null && building.Repairable && underCursor.Health < building.Strength) + if (building != null && building.Repairable && underCursor.Health < building.HP) yield return new Order("Repair", underCursor, null, int2.Zero, null); } } diff --git a/OpenRa.Game/Orders/SellOrderGenerator.cs b/OpenRa.Game/Orders/SellOrderGenerator.cs index b74c3b79cb..5c6f240f5b 100644 --- a/OpenRa.Game/Orders/SellOrderGenerator.cs +++ b/OpenRa.Game/Orders/SellOrderGenerator.cs @@ -25,9 +25,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.LegacyInfo.Selectable).FirstOrDefault(); + && a.traits.Contains()).FirstOrDefault(); - var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; + var building = underCursor != null ? underCursor.Info.Traits.Get() : null; if (building != null && !building.Unsellable) yield return new Order("Sell", underCursor, null, int2.Zero, null); diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index 83dd9cac75..3595f7dd6f 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -24,9 +24,11 @@ namespace OpenRa.Game.Traits.Activities if (isCanceled) return NextActivity; var dest = ChooseHelipad(self); + var initialFacing = self.Info.Traits.WithInterface().First().InitialFacing; + if (dest == null) return Util.SequenceActivities( - new Turn(self.LegacyInfo.InitialFacing), + new Turn(initialFacing), new HeliLand(true), NextActivity); @@ -34,12 +36,13 @@ namespace OpenRa.Game.Traits.Activities if (res != null) self.traits.Get().reservation = res.Reserve(self); - var offset = (dest.LegacyInfo as LegacyBuildingInfo).SpawnOffset; + var pi = dest.Info.Traits.GetOrDefault(); + var offset = pi != null ? pi.SpawnOffset : null; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; return Util.SequenceActivities( new HeliFly(dest.CenterLocation + offsetVec), - new Turn(self.LegacyInfo.InitialFacing), + new Turn(initialFacing), new HeliLand(false), new Rearm(), NextActivity); diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index c8a6c4c08a..66608059ae 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -31,6 +31,7 @@ namespace OpenRa.Game.Traits public readonly string[] Produces = { }; // does this go somewhere else? public readonly int2 Dimensions = new int2(1, 1); public readonly bool WaterBound = false; + public readonly bool Unsellable = false; public object Create(Actor self) { return new Building(self); } } diff --git a/OpenRa.Game/Traits/Repairable.cs b/OpenRa.Game/Traits/Repairable.cs index 77de5d6e35..0cada1212e 100644 --- a/OpenRa.Game/Traits/Repairable.cs +++ b/OpenRa.Game/Traits/Repairable.cs @@ -21,7 +21,7 @@ namespace OpenRa.Game.Traits if (mi.Button != MouseButton.Right) return null; if (underCursor == null) return null; - if (underCursor.LegacyInfo == Rules.UnitInfo["FIX"] + if (underCursor.Info.Name == "fix" && underCursor.Owner == self.Owner && !Reservable.IsReserved(underCursor)) return new Order("Enter", self, underCursor, int2.Zero, null); diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 345476347b..4c51a1fe1d 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -116,7 +116,8 @@ namespace RulesConverter { "Crewed", "Crewed" }, { "WaterBound", "WaterBound" }, { "InitialFacing", "InitialFacing" }, - { "Sight", "Sight" } } + { "Sight", "Sight" }, + { "Unsellable", "Unsellable" } } }, { "StoresOre", new PL { From 66a1ab0e4e1167496206a4aaa8ea4fdcedf0b0f9 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 19:13:14 +1300 Subject: [PATCH 40/83] production/techtree starting to port --- OpenRa.Game/GameRules/Rules.cs | 8 +- OpenRa.Game/GameRules/TechTree.cs | 14 +- OpenRa.Game/Traits/Production.cs | 1 + OpenRa.Game/Traits/ProductionQueue.cs | 4 +- ra.yaml | 496 ++++++++++++++++++++++++++ regen-yaml.cmd | 2 +- 6 files changed, 512 insertions(+), 13 deletions(-) diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index d7200d93ec..87eb755a35 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -90,14 +90,14 @@ namespace OpenRa.Game SupportPowerInfo = new InfoLoader( Pair.New>("SupportPower", _ => new SupportPowerInfo())); + NewUnitInfo = new Dictionary(); + foreach (var kv in MiniYaml.FromFile("ra.yaml")) + NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value)); + TechTree = new TechTree(); Map = new Map( AllRules ); FileSystem.MountTemporary( new Package( Rules.Map.Theater + ".mix" ) ); TileSet = new TileSet( Map.TileSuffix ); - - NewUnitInfo = new Dictionary(); - foreach( var kv in MiniYaml.FromFile( "ra.yaml" ) ) - NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value)); } static void LoadCategories(params string[] types) diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 57b707f670..6f70cf883a 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -7,15 +7,17 @@ namespace OpenRa.Game.GameRules { class TechTree { - readonly Cache> producesIndex = new Cache>( x => new List() ); + readonly Cache> producesIndex = new Cache>(x => new List()); public TechTree() { foreach( var b in Rules.Categories[ "Building" ] ) { - var info = (LegacyBuildingInfo)Rules.UnitInfo[ b ]; - foreach( var p in info.Produces ) - producesIndex[ p ].Add( info ); + var info = Rules.NewUnitInfo[ b ]; + var pi = info.Traits.WithInterface().FirstOrDefault(); + if (pi != null) + foreach( var p in pi.Produces ) + producesIndex[ p ].Add( info ); } } @@ -60,10 +62,10 @@ namespace OpenRa.Game.GameRules .Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */ } - public IEnumerable UnitBuiltAt( LegacyUnitInfo info ) + public IEnumerable UnitBuiltAt( LegacyUnitInfo info ) { if( info.BuiltAt.Length != 0 ) - return info.BuiltAt.Select( x => Rules.UnitInfo[ x.ToLowerInvariant() ] ); + return info.BuiltAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] ); else return producesIndex[ Rules.UnitCategory[ info.Name ] ]; } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 5297112145..8ed3520461 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -7,6 +7,7 @@ namespace OpenRa.Game.Traits class ProductionInfo : ITraitInfo { public readonly int[] SpawnOffset = null; + public readonly string[] Produces = { }; public object Create(Actor self) { return new Production(self); } } diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index 06340287dd..b5945c76ff 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -133,7 +133,7 @@ namespace OpenRa.Game.Traits // Prioritise primary structure in build order var primaryProducers = Game.world.Actors .Where(x => x.traits.Contains() - && producerTypes.Contains(x.LegacyInfo) + && producerTypes.Contains(x.Info) && x.Owner == self.Owner && x.traits.Get().IsPrimary == true); @@ -153,7 +153,7 @@ namespace OpenRa.Game.Traits if (producer == null) { producer = Game.world.Actors - .Where( x => producerTypes.Contains( x.LegacyInfo ) && x.Owner == self.Owner ) + .Where( x => producerTypes.Contains( x.Info ) && x.Owner == self.Owner ) .FirstOrDefault(); } diff --git a/ra.yaml b/ra.yaml index 32b914b875..36eb9d8fd8 100644 --- a/ra.yaml +++ b/ra.yaml @@ -424,6 +424,18 @@ MNLY.AT: Passenger: IronCurtainable: +TRUK: + Inherits: DefaultVehicle + Selectable: + Unit: + HP: 110 + Armor: light + Sight: 3 + Mobile: + ROT: 5 + Speed: 10 + RenderUnit: + SS: Inherits: DefaultShip Buildable: @@ -1720,6 +1732,490 @@ MINE: RenderBuilding: SeedsOre: +FCOM: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Power: -200 + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Bib: yes + HP: 400 + Armor: wood + Crewed: yes + Sight: 10 + RenderBuilding: + +V01: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx xx + Dimensions: 2,2 + Capturable: true + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V02: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx xx + Dimensions: 2,2 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V03: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx xx + Dimensions: 2,2 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V04: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx xx + Dimensions: 2,2 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V05: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx + Dimensions: 2,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V06: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx + Dimensions: 2,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V07: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: xx + Dimensions: 2,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V08: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V09: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V10: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V11: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V12: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V13: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V14: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V15: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V16: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V17: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V18: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V19: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + +V20: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V21: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V22: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V23: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V24: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V25: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V26: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V27: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V28: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V29: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V30: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V31: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V32: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V33: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V34: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V35: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V36: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +V37: + Inherits: DefaultBuilding + Selectable: + Priority: 3 + Building: + Repairable: false + HP: 400 + Armor: wood + RenderBuilding: + Image: FCOM + +BARL: + Inherits: DefaultBuilding + Selectable: + Priority: 0 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + BaseNormal: no + Adjacent: 0 + HP: 10 + RenderBuilding: + Explodes: + +BRL3: + Inherits: DefaultBuilding + Selectable: + Priority: 0 + Building: + Footprint: x + Dimensions: 1,1 + Repairable: false + BaseNormal: no + Adjacent: 0 + HP: 10 + RenderBuilding: + Explodes: + +MISS: + Inherits: DefaultBuilding + Selectable: + Priority: 0 + Building: + Footprint: xxx xxx + Dimensions: 3,2 + Capturable: true + Bib: yes + HP: 400 + Armor: wood + RenderBuilding: + DOG: Inherits: DefaultInfantry Buildable: diff --git a/regen-yaml.cmd b/regen-yaml.cmd index f5018afb67..296337b094 100644 --- a/regen-yaml.cmd +++ b/regen-yaml.cmd @@ -1,2 +1,2 @@ -RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini trees.ini ra.yaml +RulesConverter\bin\debug\RulesConverter.exe units.ini rules.ini trees.ini campaignUnits.ini ra.yaml RulesConverter\bin\debug\RulesConverter.exe aftermathUnits.ini aftrmath.ini aftermath.yaml \ No newline at end of file From 6fae4ed96893512f34e3d70653030bca503613e4 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 19:19:15 +1300 Subject: [PATCH 41/83] AttackBase porting --- OpenRa.Game/Traits/AttackBase.cs | 30 ++++++++++++++++++++---------- RulesConverter/Program.cs | 3 ++- aftermath.yaml | 1 + ra.yaml | 4 ++++ 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 1c7b0c9139..b989b967e4 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits public readonly int[] PrimaryOffset = { 0, 0 }; public readonly int[] SecondaryOffset = null; public readonly bool MuzzleFlash = false; + public readonly int FireDelay = 0; public virtual object Create(Actor self) { return new AttackBase(self); } } @@ -37,8 +38,10 @@ namespace OpenRa.Game.Traits public AttackBase(Actor self) { - var primaryWeapon = self.LegacyInfo.Primary != null ? Rules.WeaponInfo[self.LegacyInfo.Primary] : null; - var secondaryWeapon = self.LegacyInfo.Secondary != null ? Rules.WeaponInfo[self.LegacyInfo.Secondary] : null; + var info = self.Info.Traits.WithInterface().First(); + + var primaryWeapon = info.PrimaryWeapon != null ? Rules.WeaponInfo[info.PrimaryWeapon] : null; + var secondaryWeapon = info.SecondaryWeapon != null ? Rules.WeaponInfo[info.SecondaryWeapon] : null; primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1; secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1; @@ -87,19 +90,20 @@ namespace OpenRa.Game.Traits public void DoAttack(Actor self) { var unit = self.traits.GetOrDefault(); + var info = self.Info.Traits.WithInterface().First(); - if (self.LegacyInfo.Primary != null && CheckFire(self, unit, self.LegacyInfo.Primary, ref primaryFireDelay, - self.LegacyInfo.PrimaryOffset, ref primaryBurst, self.LegacyInfo.PrimaryLocalOffset)) + if (info.PrimaryWeapon != null && CheckFire(self, unit, info.PrimaryWeapon, ref primaryFireDelay, + info.PrimaryOffset, ref primaryBurst, info.PrimaryLocalOffset)) { secondaryFireDelay = Math.Max(4, secondaryFireDelay); primaryRecoil = 1; return; } - if (self.LegacyInfo.Secondary != null && CheckFire(self, unit, self.LegacyInfo.Secondary, ref secondaryFireDelay, - self.LegacyInfo.SecondaryOffset ?? self.LegacyInfo.PrimaryOffset, ref secondaryBurst, self.LegacyInfo.SecondaryLocalOffset)) + if (info.SecondaryWeapon != null && CheckFire(self, unit, info.SecondaryWeapon, ref secondaryFireDelay, + info.SecondaryOffset ?? info.PrimaryOffset, ref secondaryBurst, info.SecondaryLocalOffset)) { - if (self.LegacyInfo.SecondaryOffset != null) secondaryRecoil = 1; + if (info.SecondaryOffset != null) secondaryRecoil = 1; else primaryRecoil = 1; return; } @@ -140,8 +144,9 @@ namespace OpenRa.Game.Traits var firePos = self.CenterLocation.ToInt2() + Util.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(); var thisTarget = target; // closure. var destUnit = thisTarget.traits.GetOrDefault(); + var info = self.Info.Traits.WithInterface().First(); - ScheduleDelayedAction(self.LegacyInfo.FireDelay, () => + ScheduleDelayedAction(info.FireDelay, () => { var srcAltitude = unit != null ? unit.Altitude : 0; var destAltitude = destUnit != null ? destUnit.Altitude : 0; @@ -175,10 +180,14 @@ namespace OpenRa.Game.Traits { if (mi.Button == MouseButton.Left || underCursor == null) return null; if (self == underCursor) return null; - var isHeal = Rules.WeaponInfo[self.LegacyInfo.Primary].Damage < 0; + + var info = self.Info.Traits.WithInterface().First(); + var isHeal = Rules.WeaponInfo[info.PrimaryWeapon].Damage < 0; if (((underCursor.Owner == self.Owner) ^ isHeal) && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null; + if (!Combat.HasAnyValidWeapons(self, underCursor)) return null; + return new Order(isHeal ? "Heal" : "Attack", self, underCursor, int2.Zero, null); } @@ -198,9 +207,10 @@ namespace OpenRa.Game.Traits protected virtual void QueueAttack(Actor self, Order order) { + var info = self.Info.Traits.WithInterface().First(); const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ /* todo: choose the appropriate weapon, when only one works against this target */ - var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary; + var weapon = info.PrimaryWeapon ?? info.SecondaryWeapon; self.QueueActivity(new Activities.Attack(order.TargetActor, Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance))); diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 4c51a1fe1d..29c2a8ae03 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -138,7 +138,8 @@ namespace RulesConverter { "PrimaryLocalOffset", "PrimaryLocalOffset" }, { "SecondaryLocalOffset", "SecondaryLocalOffset" }, { "MuzzleFlash", "MuzzleFlash" }, // maybe - { "Recoil", "Recoil"} } + { "Recoil", "Recoil"}, + { "FireDelay", "FireDelay" } } }, { "Production", new PL { diff --git a/aftermath.yaml b/aftermath.yaml index 7d422e542f..5eaff6733b 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -129,6 +129,7 @@ MSUB: Speed: 5 AttackBase: PrimaryWeapon: SubSCUD + FireDelay: 2 RenderUnit: Submarine: Chronoshiftable: diff --git a/ra.yaml b/ra.yaml index 36eb9d8fd8..47c9ae40db 100644 --- a/ra.yaml +++ b/ra.yaml @@ -458,6 +458,7 @@ SS: Submarine: AttackBase: PrimaryWeapon: TorpTube + FireDelay: 2 Chronoshiftable: IronCurtainable: @@ -840,6 +841,7 @@ TSLA: RenderBuildingCharge: AttackTurreted: PrimaryWeapon: TeslaZap + FireDelay: 8 AutoTarget: IronCurtainable: @@ -2284,6 +2286,7 @@ E2: AttackBase: PrimaryWeapon: Grenade PrimaryOffset: 0,0,0,-13 + FireDelay: 15 TakeCover: SquishByTank: AutoTarget: @@ -2337,6 +2340,7 @@ E4: AttackBase: PrimaryWeapon: Flamer PrimaryOffset: 0,0,0,-7 + FireDelay: 8 TakeCover: SquishByTank: AutoTarget: From bd6f22c57ea11ea421a296d17bdbe60c7762c7d4 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 19:22:40 +1300 Subject: [PATCH 42/83] more --- OpenRa.Game/Combat.cs | 13 +++++++------ OpenRa.Game/Traits/Activities/UnloadCargo.cs | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index e8100a5495..eaa282844b 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -49,7 +49,7 @@ namespace OpenRa.Game var distance = (target.CenterLocation - loc).Length*1/24f; var rawDamage = weapon.Damage * (float)Math.Exp(-distance / warhead.Spread); - var multiplier = warhead.EffectivenessAgainst(target.LegacyInfo.Armor); + var multiplier = warhead.EffectivenessAgainst(target.Info.Traits.WithInterface().First().Armor); return rawDamage * multiplier; } @@ -59,7 +59,7 @@ namespace OpenRa.Game var warhead = Rules.WarheadInfo[weapon.Warhead]; var unit = target.traits.GetOrDefault(); - if (warhead.EffectivenessAgainst(target.LegacyInfo.Armor) <= 0) + if (warhead.EffectivenessAgainst(target.Info.Traits.WithInterface().First().Armor) <= 0) return false; if (target.traits.Contains()) @@ -76,10 +76,11 @@ namespace OpenRa.Game public static bool HasAnyValidWeapons(Actor self, Actor target) { - if (self.LegacyInfo.Primary != null && - WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Primary], target)) return true; - if (self.LegacyInfo.Secondary != null && - WeaponValidForTarget(Rules.WeaponInfo[self.LegacyInfo.Secondary], target)) return true; + var info = self.Info.Traits.WithInterface().First(); + if (info.PrimaryWeapon != null && + WeaponValidForTarget(Rules.WeaponInfo[info.PrimaryWeapon], target)) return true; + if (info.SecondaryWeapon != null && + WeaponValidForTarget(Rules.WeaponInfo[info.SecondaryWeapon], target)) return true; return false; } diff --git a/OpenRa.Game/Traits/Activities/UnloadCargo.cs b/OpenRa.Game/Traits/Activities/UnloadCargo.cs index ff2c8d6fcb..32b9da09ca 100644 --- a/OpenRa.Game/Traits/Activities/UnloadCargo.cs +++ b/OpenRa.Game/Traits/Activities/UnloadCargo.cs @@ -33,8 +33,9 @@ namespace OpenRa.Game.Traits.Activities // if we're a thing that can turn, turn to the // right facing for the unload animation var unit = self.traits.GetOrDefault(); - if (unit != null && unit.Facing != self.LegacyInfo.UnloadFacing) - return new Turn(self.LegacyInfo.UnloadFacing) { NextActivity = this }; + var unloadFacing = self.Info.Traits.Get().UnloadFacing; + if (unit != null && unit.Facing != unloadFacing) + return new Turn(unloadFacing) { NextActivity = this }; // todo: handle the BS of open/close sequences, which are inconsistent, // for reasons that probably make good sense to the westwood guys. From e7a99541e501c94615be47798e91ee0f4b2506c8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 19:29:45 +1300 Subject: [PATCH 43/83] more --- OpenRa.Game/Graphics/WorldRenderer.cs | 2 +- OpenRa.Game/Orders/PowerDownOrderGenerator.cs | 4 +--- OpenRa.Game/Traits/Activities/HeliAttack.cs | 4 ++-- OpenRa.Game/Traits/Activities/Land.cs | 2 +- OpenRa.Game/Traits/DemoTruck.cs | 2 +- OpenRa.Game/Traits/Helicopter.cs | 7 ++++--- OpenRa.Game/Traits/RenderBuildingWarFactory.cs | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 4223cb2de1..b90d6ec98f 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -169,7 +169,7 @@ namespace OpenRa.Game.Graphics lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c); lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c); - var healthAmount = (float)selectedUnit.Health / selectedUnit.LegacyInfo.Strength; + var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Traits.WithInterface().First().HP; var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs index 84631b0596..80ecba3ad1 100644 --- a/OpenRa.Game/Orders/PowerDownOrderGenerator.cs +++ b/OpenRa.Game/Orders/PowerDownOrderGenerator.cs @@ -27,9 +27,7 @@ namespace OpenRa.Game.Orders && a.traits.Contains() && a.traits.Contains()).FirstOrDefault(); - var building = underCursor != null ? underCursor.LegacyInfo as LegacyBuildingInfo : null; - - if (building != null) + if (underCursor != null) yield return new Order("PowerDown", underCursor, null, int2.Zero, null); } } diff --git a/OpenRa.Game/Traits/Activities/HeliAttack.cs b/OpenRa.Game/Traits/Activities/HeliAttack.cs index 1a50596e64..42574e4a80 100644 --- a/OpenRa.Game/Traits/Activities/HeliAttack.cs +++ b/OpenRa.Game/Traits/Activities/HeliAttack.cs @@ -30,11 +30,11 @@ namespace OpenRa.Game.Traits.Activities return this; } - var range = Rules.WeaponInfo[ self.LegacyInfo.Primary ].Range - 1; + var range = Rules.WeaponInfo[ self.Info.Traits.WithInterface().First().PrimaryWeapon ].Range - 1; var dist = target.CenterLocation - self.CenterLocation; var desiredFacing = Util.GetFacing(dist, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize)) { diff --git a/OpenRa.Game/Traits/Activities/Land.cs b/OpenRa.Game/Traits/Activities/Land.cs index 5f99dd6b19..2164f2bfd2 100644 --- a/OpenRa.Game/Traits/Activities/Land.cs +++ b/OpenRa.Game/Traits/Activities/Land.cs @@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits.Activities --unit.Altitude; var desiredFacing = Util.GetFacing(d, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); var speed = .2f * Util.GetEffectiveSpeed(self); var angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/DemoTruck.cs b/OpenRa.Game/Traits/DemoTruck.cs index 6cc66b11b1..c8ff6c5f73 100644 --- a/OpenRa.Game/Traits/DemoTruck.cs +++ b/OpenRa.Game/Traits/DemoTruck.cs @@ -44,7 +44,7 @@ namespace OpenRa.Game.Traits int2 detonateLocation = self.CenterLocation.ToInt2(); Game.world.AddFrameEndTask( - w => w.Add(new Bullet(self.LegacyInfo.Primary, detonatedBy.Owner, detonatedBy, + w => w.Add(new Bullet(self.Info.Traits.WithInterface().First().PrimaryWeapon, detonatedBy.Owner, detonatedBy, detonateLocation, detonateLocation, altitude, altitude))); } } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 8fa02f6fca..6c8114c764 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -63,14 +63,15 @@ namespace OpenRa.Game.Traits if (res != null) reservation = res.Reserve(self); - var offset = (order.TargetActor.LegacyInfo as LegacyBuildingInfo).SpawnOffset; + var productionInfo = order.TargetActor.Info.Traits.Get(); + var offset = productionInfo.SpawnOffset; var offsetVec = offset != null ? new float2(offset[0], offset[1]) : float2.Zero; self.CancelActivity(); self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec)); - self.QueueActivity(new Turn(self.LegacyInfo.InitialFacing)); + self.QueueActivity(new Turn(self.Info.Traits.WithInterface().FirstOrDefault().InitialFacing)); self.QueueActivity(new HeliLand(false)); - self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["HPAD"] + self.QueueActivity(order.TargetActor.Info.Name == "hpad" ? (IActivity)new Rearm() : new Repair()); } } diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index f55731579c..2990363d0d 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits public RenderWarFactory(Actor self) { this.self = self; - roof = new Animation(self.LegacyInfo.Image ?? self.LegacyInfo.Name); + roof = new Animation(self.traits.WithInterface().First().GetImage(self)); } public void BuildingComplete( Actor self ) From 10a5b40e1652b4df1b0304a4be1e29617d249939 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 21:59:32 +1300 Subject: [PATCH 44/83] some accessors --- OpenRa.Game/Combat.cs | 4 ++-- OpenRa.Game/Exts.cs | 24 +++++++++++++++++++++ OpenRa.Game/Traits/Activities/HeliAttack.cs | 2 +- OpenRa.Game/Traits/AttackBase.cs | 14 +++++------- OpenRa.Game/Traits/Util.cs | 5 ++--- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index eaa282844b..241f6c9852 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -78,9 +78,9 @@ namespace OpenRa.Game { var info = self.Info.Traits.WithInterface().First(); if (info.PrimaryWeapon != null && - WeaponValidForTarget(Rules.WeaponInfo[info.PrimaryWeapon], target)) return true; + WeaponValidForTarget(self.GetPrimaryWeapon(), target)) return true; if (info.SecondaryWeapon != null && - WeaponValidForTarget(Rules.WeaponInfo[info.SecondaryWeapon], target)) return true; + WeaponValidForTarget(self.GetSecondaryWeapon(), target)) return true; return false; } diff --git a/OpenRa.Game/Exts.cs b/OpenRa.Game/Exts.cs index 3de1b767a5..ae908bedc1 100644 --- a/OpenRa.Game/Exts.cs +++ b/OpenRa.Game/Exts.cs @@ -2,6 +2,8 @@ using System.Windows.Forms; using System.Collections.Generic; using System.Linq; +using OpenRa.Game.GameRules; +using OpenRa.Game.Traits; namespace OpenRa.Game { @@ -27,5 +29,27 @@ namespace OpenRa.Game { return xs.Aggregate(1f, (a, x) => a * x); } + + public static WeaponInfo GetPrimaryWeapon(this Actor self) + { + var info = self.Info.Traits.WithInterface().FirstOrDefault(); + if (info == null) return null; + + var weapon = info.PrimaryWeapon; + if (weapon == null) return null; + + return Rules.WeaponInfo[weapon]; + } + + public static WeaponInfo GetSecondaryWeapon(this Actor self) + { + var info = self.Info.Traits.WithInterface().FirstOrDefault(); + if (info == null) return null; + + var weapon = info.SecondaryWeapon; + if (weapon == null) return null; + + return Rules.WeaponInfo[weapon]; + } } } diff --git a/OpenRa.Game/Traits/Activities/HeliAttack.cs b/OpenRa.Game/Traits/Activities/HeliAttack.cs index 42574e4a80..71b27ab22f 100644 --- a/OpenRa.Game/Traits/Activities/HeliAttack.cs +++ b/OpenRa.Game/Traits/Activities/HeliAttack.cs @@ -30,7 +30,7 @@ namespace OpenRa.Game.Traits.Activities return this; } - var range = Rules.WeaponInfo[ self.Info.Traits.WithInterface().First().PrimaryWeapon ].Range - 1; + var range = self.GetPrimaryWeapon().Range - 1; var dist = target.CenterLocation - self.CenterLocation; var desiredFacing = Util.GetFacing(dist, unit.Facing); diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index b989b967e4..725ef2f753 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -38,10 +38,8 @@ namespace OpenRa.Game.Traits public AttackBase(Actor self) { - var info = self.Info.Traits.WithInterface().First(); - - var primaryWeapon = info.PrimaryWeapon != null ? Rules.WeaponInfo[info.PrimaryWeapon] : null; - var secondaryWeapon = info.SecondaryWeapon != null ? Rules.WeaponInfo[info.SecondaryWeapon] : null; + var primaryWeapon = self.GetPrimaryWeapon(); + var secondaryWeapon = self.GetSecondaryWeapon(); primaryBurst = primaryWeapon != null ? primaryWeapon.Burst : 1; secondaryBurst = secondaryWeapon != null ? secondaryWeapon.Burst : 1; @@ -181,8 +179,7 @@ namespace OpenRa.Game.Traits if (mi.Button == MouseButton.Left || underCursor == null) return null; if (self == underCursor) return null; - var info = self.Info.Traits.WithInterface().First(); - var isHeal = Rules.WeaponInfo[info.PrimaryWeapon].Damage < 0; + var isHeal = self.GetPrimaryWeapon().Damage < 0; if (((underCursor.Owner == self.Owner) ^ isHeal) && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null; @@ -207,13 +204,12 @@ namespace OpenRa.Game.Traits protected virtual void QueueAttack(Actor self, Order order) { - var info = self.Info.Traits.WithInterface().First(); const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ /* todo: choose the appropriate weapon, when only one works against this target */ - var weapon = info.PrimaryWeapon ?? info.SecondaryWeapon; + var weapon = self.GetPrimaryWeapon() ?? self.GetSecondaryWeapon(); self.QueueActivity(new Activities.Attack(order.TargetActor, - Math.Max(0, (int)Rules.WeaponInfo[weapon].Range - RangeTolerance))); + Math.Max(0, (int)weapon.Range - RangeTolerance))); } } } diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index bef22a08b9..9b8345796c 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -146,9 +146,8 @@ namespace OpenRa.Game.Traits public static float GetMaximumRange(Actor self) { var info = self.Info.Traits.WithInterface().First(); - return new[] { info.PrimaryWeapon, info.SecondaryWeapon } - .Where(w => w != null) - .Max(w => Rules.WeaponInfo[w].Range); + return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() } + .Where(w => w != null).Max(w => w.Range); } } } From 889828aa02e91d8130d1eb9b8986889721c1d222 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 22:13:44 +1300 Subject: [PATCH 45/83] weapon stuff --- OpenRa.Game/Effects/Bullet.cs | 8 ++++++-- OpenRa.Game/Effects/Missile.cs | 4 ++-- OpenRa.Game/Traits/AttackBase.cs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/OpenRa.Game/Effects/Bullet.cs b/OpenRa.Game/Effects/Bullet.cs index 5104585dd3..15b6e80fc8 100755 --- a/OpenRa.Game/Effects/Bullet.cs +++ b/OpenRa.Game/Effects/Bullet.cs @@ -23,8 +23,12 @@ namespace OpenRa.Game.Effects const int BaseBulletSpeed = 100; /* pixels / 40ms frame */ + public Bullet(string weapon, Player owner, Actor firedBy, + int2 src, int2 dest, int srcAltitude, int destAltitude) + : this(Rules.WeaponInfo[weapon], owner, firedBy, src, dest, srcAltitude, destAltitude) { } + /* src, dest are *pixel* coords */ - public Bullet(string weapon, Player owner, Actor firedBy, + public Bullet(WeaponInfo weapon, Player owner, Actor firedBy, int2 src, int2 dest, int srcAltitude, int destAltitude) { Owner = owner; @@ -36,7 +40,7 @@ namespace OpenRa.Game.Effects VisualDest = Dest + new int2( Game.CosmeticRandom.Next(-10, 10), Game.CosmeticRandom.Next(-10, 10)); - Weapon = Rules.WeaponInfo[weapon]; + Weapon = weapon; Projectile = Rules.ProjectileInfo[Weapon.Projectile]; Warhead = Rules.WarheadInfo[Weapon.Warhead]; diff --git a/OpenRa.Game/Effects/Missile.cs b/OpenRa.Game/Effects/Missile.cs index c0247567d1..bf71137b03 100755 --- a/OpenRa.Game/Effects/Missile.cs +++ b/OpenRa.Game/Effects/Missile.cs @@ -20,10 +20,10 @@ namespace OpenRa.Game.Effects int t; int Altitude; - public Missile(string weapon, Player owner, Actor firedBy, + public Missile(WeaponInfo weapon, Player owner, Actor firedBy, int2 src, Actor target, int altitude, int facing) { - Weapon = Rules.WeaponInfo[weapon]; + Weapon = weapon; Projectile = Rules.ProjectileInfo[Weapon.Projectile]; Warhead = Rules.WarheadInfo[Weapon.Warhead]; FiredBy = firedBy; diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 725ef2f753..366d3902c6 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -157,11 +157,11 @@ namespace OpenRa.Game.Traits var fireFacing = thisLocalOffset.ElementAtOrDefault(2) + (self.traits.Contains() ? self.traits.Get().turretFacing : unit.Facing); - Game.world.Add(new Missile(weaponName, self.Owner, self, + Game.world.Add(new Missile(weapon, self.Owner, self, firePos, thisTarget, srcAltitude, fireFacing)); } else - Game.world.Add(new Bullet(weaponName, self.Owner, self, + Game.world.Add(new Bullet(weapon, self.Owner, self, firePos, thisTarget.CenterLocation.ToInt2(), srcAltitude, destAltitude)); if (!string.IsNullOrEmpty(weapon.Report)) From 9c520e07b13b95ed36e9be90c3d2b1d3c3f6c43b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 22:15:54 +1300 Subject: [PATCH 46/83] more --- OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs | 6 ++---- OpenRa.Game/Orders/IronCurtainOrderGenerator.cs | 6 ++---- OpenRa.Game/Sound.cs | 3 ++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs index 889965abbc..bc59e480c5 100644 --- a/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronosphereSelectOrderGenerator.cs @@ -31,11 +31,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.WithInterface().Any() - && a.LegacyInfo.Selectable).FirstOrDefault(); + && a.traits.Contains()).FirstOrDefault(); - var unit = underCursor != null ? underCursor.LegacyInfo as LegacyUnitInfo : null; - - if (unit != null) + if (underCursor != null) yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, power.Name); } } diff --git a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs index a33d67587e..2d56000335 100644 --- a/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs +++ b/OpenRa.Game/Orders/IronCurtainOrderGenerator.cs @@ -31,11 +31,9 @@ namespace OpenRa.Game.Orders var underCursor = Game.FindUnits(loc, loc) .Where(a => a.Owner == Game.LocalPlayer && a.traits.Contains() - && a.LegacyInfo.Selectable).FirstOrDefault(); + && a.traits.Contains()).FirstOrDefault(); - var unit = underCursor != null ? underCursor.LegacyInfo as LegacyUnitInfo : null; - - if (unit != null) + if (underCursor != null) yield return new Order("IronCurtain", underCursor, null, int2.Zero, power.Name); } } diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index f3dea39130..6c773d0ae0 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -2,6 +2,7 @@ using IrrKlang; using OpenRa.FileFormats; using OpenRa.Game.GameRules; +using OpenRa.Game.Traits; namespace OpenRa.Game { @@ -92,7 +93,7 @@ namespace OpenRa.Game { if (voicedUnit == null) return; - var mi = voicedUnit.LegacyInfo as LegacyMobileInfo; + var mi = voicedUnit.Info.Traits.GetOrDefault(); if (mi == null) return; var vi = Rules.VoiceInfo[mi.Voice]; From e6e5275f057ccf8e0b77ff7bb669a9f337df9649 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Jan 2010 22:26:14 +1300 Subject: [PATCH 47/83] more --- OpenRa.Game/Actor.cs | 27 ++++++++++---------- OpenRa.Game/Game.cs | 10 +++----- OpenRa.Game/Graphics/WorldRenderer.cs | 2 +- OpenRa.Game/Orders/UnitOrders.cs | 9 +++---- OpenRa.Game/Traits/AcceptsOre.cs | 2 +- OpenRa.Game/Traits/Activities/DeployMcv.cs | 2 +- OpenRa.Game/Traits/Activities/UndeployMcv.cs | 2 +- OpenRa.Game/Traits/AutoHeal.cs | 2 +- OpenRa.Game/Traits/Minelayer.cs | 2 +- OpenRa.Game/Traits/Production.cs | 2 +- 10 files changed, 28 insertions(+), 32 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 51b31518a2..b802a517cf 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -26,10 +26,10 @@ namespace OpenRa.Game public int Health; IActivity currentActivity; - public Actor( ActorInfo info, int2 location, Player owner ) + public Actor( string name, int2 location, Player owner ) { ActorID = Game.world.NextAID(); - LegacyInfo = (LegacyUnitInfo)info; // temporary + LegacyInfo = name != null ? Rules.UnitInfo[name.ToLowerInvariant()] : null; // temporary Location = location; CenterLocation = Traits.Util.CenterOfCell(Location); Owner = owner; @@ -38,10 +38,7 @@ namespace OpenRa.Game Health = LegacyInfo.Strength; /* todo: fix walls, etc so this is always true! */ - if( LegacyInfo.Traits == null ) - throw new InvalidOperationException( "No Actor traits for {0}; add Traits= to units.ini for appropriate unit".F(LegacyInfo.Name) ); - - Info = Rules.NewUnitInfo[LegacyInfo.Name.ToLowerInvariant()]; + Info = Rules.NewUnitInfo[name.ToLowerInvariant()]; foreach (var trait in Info.Traits.WithInterface()) traits.Add(trait.Create(this)); @@ -66,12 +63,13 @@ namespace OpenRa.Game } public float2 CenterLocation; - public float2 SelectedSize + float2 SelectedSize { - get + get // todo: inline into GetBounds { - if (LegacyInfo != null && LegacyInfo.SelectionSize != null) - return new float2(LegacyInfo.SelectionSize[0], LegacyInfo.SelectionSize[1]); + var si = Info != null ? Info.Traits.GetOrDefault() : null; + if (si != null && si.Bounds != null) + return new float2(si.Bounds[0], si.Bounds[1]); var firstSprite = Render().FirstOrDefault(); if (firstSprite.Sprite == null) return float2.Zero; @@ -97,7 +95,7 @@ namespace OpenRa.Game var loc = mi.Location + Game.viewport.Location; var underCursor = Game.FindUnits(loc, loc).FirstOrDefault(); - if (underCursor != null && !underCursor.LegacyInfo.Selectable) + if (underCursor != null && !underCursor.traits.Contains()) underCursor = null; return traits.WithInterface() @@ -107,10 +105,13 @@ namespace OpenRa.Game public RectangleF GetBounds(bool useAltitude) { + var si = Info != null ? Info.Traits.GetOrDefault() : null; + var size = SelectedSize; var loc = CenterLocation - 0.5f * size; - if (LegacyInfo != null && LegacyInfo.SelectionSize != null && LegacyInfo.SelectionSize.Length > 2) - loc += new float2(LegacyInfo.SelectionSize[2], LegacyInfo.SelectionSize[3]); + + if (si != null && si.Bounds != null && si.Bounds.Length > 2) + loc += new float2(si.Bounds[2], si.Bounds[3]); if (useAltitude) { diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 7ed631fc74..c3237a5470 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -78,8 +78,8 @@ namespace OpenRa.Game } var worldActor = new Actor(null, new int2(int.MaxValue, int.MaxValue), null); - worldActor.traits.Add(new Traits.WaterPaletteRotation(worldActor)); - worldActor.traits.Add(new Traits.ChronoshiftPaletteEffect(worldActor)); + worldActor.traits.Add(new WaterPaletteRotation(worldActor)); + worldActor.traits.Add(new ChronoshiftPaletteEffect(worldActor)); Game.world.Add(worldActor); Rules.Map.InitOreDensity(); @@ -95,9 +95,7 @@ namespace OpenRa.Game skipMakeAnims = true; foreach (var treeReference in Rules.Map.Trees) - world.Add(new Actor(Rules.UnitInfo[treeReference.Image], - new int2(treeReference.Location), - null)); + world.Add(new Actor(treeReference.Image, new int2(treeReference.Location), null)); LoadMapActors(Rules.AllRules); skipMakeAnims = false; @@ -148,7 +146,7 @@ namespace OpenRa.Game //num=owner,type,health,location,facing,... var parts = s.Value.Split( ',' ); var loc = int.Parse(parts[3]); - world.Add(new Actor(Rules.UnitInfo[parts[1].ToLowerInvariant()], new int2(loc % 128, loc / 128), + world.Add(new Actor(parts[1].ToLowerInvariant(), new int2(loc % 128, loc / 128), players.Values.FirstOrDefault(p => p.InternalName == parts[0]) ?? players[0])); } } diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index b90d6ec98f..44b1d197ab 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -220,7 +220,7 @@ namespace OpenRa.Game.Graphics spriteRenderer.DrawSprite(pipImages.Image, pipxyBase + pipxyOffset, PaletteType.Chrome); pipxyOffset += new float2(4, 0); - if (pipxyOffset.X+5 > selectedUnit.SelectedSize.X) + if (pipxyOffset.X+5 > selectedUnit.GetBounds(false).Width) { pipxyOffset.X = 0; pipxyOffset.Y -= 4; diff --git a/OpenRa.Game/Orders/UnitOrders.cs b/OpenRa.Game/Orders/UnitOrders.cs index 66646d787c..327f1e3a05 100644 --- a/OpenRa.Game/Orders/UnitOrders.cs +++ b/OpenRa.Game/Orders/UnitOrders.cs @@ -15,22 +15,19 @@ namespace OpenRa.Game.Orders { Game.world.AddFrameEndTask( _ => { - var queue = order.Player.PlayerActor.traits.Get(); - var building = (LegacyBuildingInfo)Rules.UnitInfo[ order.TargetString ]; + var queue = order.Player.PlayerActor.traits.Get(); var producing = queue.CurrentItem(Rules.UnitCategory[order.TargetString]); if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 ) return; - Log.Write( "Player \"{0}\" builds {1}", order.Player.PlayerName, building.Name ); - - Game.world.Add( new Actor( building, order.TargetLocation - GameRules.Footprint.AdjustForBuildingSize( building ), order.Player ) ); + Game.world.Add( new Actor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( (LegacyBuildingInfo)Rules.UnitInfo[ order.TargetString ] ), order.Player ) ); if (order.Player == Game.LocalPlayer) { Sound.Play("placbldg.aud"); Sound.Play("build5.aud"); } - queue.FinishProduction(Rules.UnitCategory[building.Name]); + queue.FinishProduction(Rules.UnitCategory[order.TargetString]); } ); break; } diff --git a/OpenRa.Game/Traits/AcceptsOre.cs b/OpenRa.Game/Traits/AcceptsOre.cs index 6c8c200afa..6029420859 100644 --- a/OpenRa.Game/Traits/AcceptsOre.cs +++ b/OpenRa.Game/Traits/AcceptsOre.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits Game.world.AddFrameEndTask( w => { /* create the free harvester! */ - var harvester = new Actor(Rules.UnitInfo["harv"], self.Location + new int2(1, 2), self.Owner); + var harvester = new Actor("harv", self.Location + new int2(1, 2), self.Owner); var unit = harvester.traits.Get(); var mobile = harvester.traits.Get(); unit.Facing = 64; diff --git a/OpenRa.Game/Traits/Activities/DeployMcv.cs b/OpenRa.Game/Traits/Activities/DeployMcv.cs index 49b8488abf..a738664e8a 100755 --- a/OpenRa.Game/Traits/Activities/DeployMcv.cs +++ b/OpenRa.Game/Traits/Activities/DeployMcv.cs @@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits.Activities Sound.Play("placbldg.aud"); Sound.Play("build5.aud"); } - Game.world.Add( new Actor( Rules.UnitInfo["fact"], self.Location - new int2( 1, 1 ), self.Owner ) ); + Game.world.Add( new Actor( "fact", self.Location - new int2( 1, 1 ), self.Owner ) ); } ); return this; } diff --git a/OpenRa.Game/Traits/Activities/UndeployMcv.cs b/OpenRa.Game/Traits/Activities/UndeployMcv.cs index 7e9241157d..912c993616 100644 --- a/OpenRa.Game/Traits/Activities/UndeployMcv.cs +++ b/OpenRa.Game/Traits/Activities/UndeployMcv.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities ns.Sold(self); w.Remove(self); - var mcv = new Actor(Rules.UnitInfo["MCV"], self.Location + new int2(1, 1), self.Owner); + var mcv = new Actor("mcv", self.Location + new int2(1, 1), self.Owner); mcv.traits.Get().Facing = 96; w.Add(mcv); } diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index 66cc04ba6a..d31041939a 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits return inRange .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ .Where(a => Combat.HasAnyValidWeapons(self, a)) - .Where(a => a.Health < a.LegacyInfo.Strength) + .Where(a => a.Health < a.Info.Traits.WithInterface().First().HP) .OrderBy(a => (a.Location - self.Location).LengthSquared) .FirstOrDefault(); } diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index cc590269c7..0f5c5194f6 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits // todo: delay a bit? (req making deploy-mine an activity) Game.world.AddFrameEndTask( - w => w.Add(new Actor(Rules.UnitInfo[self.LegacyInfo.Primary], self.Location, self.Owner))); + w => w.Add(new Actor(self.LegacyInfo.Primary, self.Location, self.Owner))); } } } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 8ed3520461..ade7b28856 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -35,7 +35,7 @@ namespace OpenRa.Game.Traits if( location == null || Game.UnitInfluence.GetUnitsAt( location.Value ).Any() ) return false; - var newUnit = new Actor( producee, location.Value, self.Owner ); + var newUnit = new Actor( producee.Name, location.Value, self.Owner ); newUnit.traits.Get().Facing = CreationFacing( self, newUnit ); ; var rp = self.traits.GetOrDefault(); From 5a29dd6ee2225e41d0b766ccef3fa3def40a237d Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 13:27:59 +1300 Subject: [PATCH 48/83] changes to TypeDictionary's interface. (build-palette is broken, so hasn't been tested) --- .../OpenRa.DataStructures.csproj | 4 ++ OpenRa.DataStructures/TypeDictionary.cs | 58 ++++++++++++------- OpenRa.Game/Combat.cs | 6 +- OpenRa.Game/Effects/Corpse.cs | 2 +- OpenRa.Game/Exts.cs | 4 +- OpenRa.Game/Game.cs | 2 +- OpenRa.Game/GameRules/TechTree.cs | 2 +- OpenRa.Game/Graphics/WorldRenderer.cs | 2 +- .../ChronoshiftDestinationOrderGenerator.cs | 2 +- ...hronoshiftSelfDestinationOrderGenerator.cs | 2 +- OpenRa.Game/Orders/UnitOrderGenerator.cs | 2 +- OpenRa.Game/Shroud.cs | 2 +- OpenRa.Game/Traits/Activities/Attack.cs | 4 +- .../Traits/Activities/CaptureBuilding.cs | 2 +- OpenRa.Game/Traits/Activities/DeliverOre.cs | 2 +- OpenRa.Game/Traits/Activities/Harvest.cs | 2 +- OpenRa.Game/Traits/Activities/HeliReturn.cs | 2 +- OpenRa.Game/Traits/Activities/Repair.cs | 2 +- OpenRa.Game/Traits/Activities/Sell.cs | 4 +- OpenRa.Game/Traits/Activities/UnloadCargo.cs | 2 +- OpenRa.Game/Traits/AttackBase.cs | 4 +- OpenRa.Game/Traits/AutoHeal.cs | 10 ++-- OpenRa.Game/Traits/AutoTarget.cs | 6 +- OpenRa.Game/Traits/ChronoshiftDeploy.cs | 2 +- OpenRa.Game/Traits/Chronoshiftable.cs | 2 +- OpenRa.Game/Traits/DemoTruck.cs | 4 +- OpenRa.Game/Traits/Helicopter.cs | 4 +- OpenRa.Game/Traits/Passenger.cs | 2 +- OpenRa.Game/Traits/Production.cs | 2 +- .../Traits/RenderBuildingWarFactory.cs | 2 +- OpenRa.Game/Traits/RenderSimple.cs | 2 +- OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs | 4 +- OpenRa.Game/Traits/RenderUnitReload.cs | 2 +- OpenRa.Game/Traits/RenderUnitTurreted.cs | 4 +- OpenRa.Game/Traits/Util.cs | 6 +- OpenRa.Game/UnitInfluenceMap.cs | 6 +- 36 files changed, 96 insertions(+), 74 deletions(-) diff --git a/OpenRa.DataStructures/OpenRa.DataStructures.csproj b/OpenRa.DataStructures/OpenRa.DataStructures.csproj index 8da1f21edd..b0d2c9ca21 100644 --- a/OpenRa.DataStructures/OpenRa.DataStructures.csproj +++ b/OpenRa.DataStructures/OpenRa.DataStructures.csproj @@ -33,6 +33,10 @@ prompt + + False + ..\Ijw.DirectX\Release\IjwFramework.dll + 3.5 diff --git a/OpenRa.DataStructures/TypeDictionary.cs b/OpenRa.DataStructures/TypeDictionary.cs index 574e624cbe..e4309999bd 100755 --- a/OpenRa.DataStructures/TypeDictionary.cs +++ b/OpenRa.DataStructures/TypeDictionary.cs @@ -1,50 +1,56 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Linq; +using System.Reflection; +using IjwFramework.Collections; namespace OpenRa { public class TypeDictionary { - Dictionary inner = new Dictionary(); - - public void Add( Type t, object val ) - { - inner.Add( t, val ); - } + Cache> innerInherit = new Cache>( _ => new List() ); public void Add( object val ) { - Add( val.GetType(), val ); - } + var t = val.GetType(); - public void Remove() - { - inner.Remove( typeof( T ) ); + foreach( var i in t.GetInterfaces() ) + innerInherit[ i ].Add( val ); + foreach( var tt in t.BaseTypes() ) + innerInherit[ tt ].Add( val ); } public bool Contains() { - return inner.ContainsKey( typeof( T ) ); + return innerInherit.Keys.Contains( typeof( T ) ); } public T Get() { - return (T)inner[ typeof( T ) ]; + var l = innerInherit[ typeof( T ) ]; + if( l.Count == 1 ) + return (T)l[ 0 ]; + else if( l.Count == 0 ) + throw new InvalidOperationException( string.Format( "TypeDictionary does not contain instance of type `{0}`", typeof( T ) ) ); + else + throw new InvalidOperationException( string.Format( "TypeDictionary contains multiple instance of type `{0}`", typeof( T ) ) ); } public T GetOrDefault() { - object o = null; - inner.TryGetValue(typeof(T), out o); - return (T)o; + var l = innerInherit[ typeof( T ) ]; + if( l.Count == 1 ) + return (T)l[ 0 ]; + else if( l.Count == 0 ) + return default( T ); + else + throw new InvalidOperationException( string.Format( "TypeDictionary contains multiple instance of type `{0}`", typeof( T ) ) ); } public IEnumerable WithInterface() { - foreach( var i in inner ) - if( i.Value is T ) - yield return (T)i.Value; + foreach( var i in innerInherit[ typeof( T ) ] ) + yield return (T)i; } public IEnumerator GetEnumerator() @@ -52,4 +58,16 @@ namespace OpenRa return WithInterface().GetEnumerator(); } } + + static class TypeExts + { + public static IEnumerable BaseTypes( this Type t ) + { + while( t != null ) + { + yield return t; + t = t.BaseType; + } + } + } } diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index 241f6c9852..2147aaceb3 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -49,7 +49,7 @@ namespace OpenRa.Game var distance = (target.CenterLocation - loc).Length*1/24f; var rawDamage = weapon.Damage * (float)Math.Exp(-distance / warhead.Spread); - var multiplier = warhead.EffectivenessAgainst(target.Info.Traits.WithInterface().First().Armor); + var multiplier = warhead.EffectivenessAgainst(target.Info.Traits.Get().Armor); return rawDamage * multiplier; } @@ -59,7 +59,7 @@ namespace OpenRa.Game var warhead = Rules.WarheadInfo[weapon.Warhead]; var unit = target.traits.GetOrDefault(); - if (warhead.EffectivenessAgainst(target.Info.Traits.WithInterface().First().Armor) <= 0) + if (warhead.EffectivenessAgainst(target.Info.Traits.Get().Armor) <= 0) return false; if (target.traits.Contains()) @@ -76,7 +76,7 @@ namespace OpenRa.Game public static bool HasAnyValidWeapons(Actor self, Actor target) { - var info = self.Info.Traits.WithInterface().First(); + var info = self.Info.Traits.Get(); if (info.PrimaryWeapon != null && WeaponValidForTarget(self.GetPrimaryWeapon(), target)) return true; if (info.SecondaryWeapon != null && diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs index 2c4570d46c..2e89a40d7b 100755 --- a/OpenRa.Game/Effects/Corpse.cs +++ b/OpenRa.Game/Effects/Corpse.cs @@ -15,7 +15,7 @@ namespace OpenRa.Game.Effects public Corpse(Actor fromActor, int death) { - anim = new Animation(fromActor.traits.WithInterface().FirstOrDefault().GetImage(fromActor)); + anim = new Animation(fromActor.traits.GetOrDefault().GetImage(fromActor)); anim.PlayThen("die{0}".F(death + 1), () => Game.world.AddFrameEndTask(w => w.Remove(this))); diff --git a/OpenRa.Game/Exts.cs b/OpenRa.Game/Exts.cs index ae908bedc1..804f99b970 100644 --- a/OpenRa.Game/Exts.cs +++ b/OpenRa.Game/Exts.cs @@ -32,7 +32,7 @@ namespace OpenRa.Game public static WeaponInfo GetPrimaryWeapon(this Actor self) { - var info = self.Info.Traits.WithInterface().FirstOrDefault(); + var info = self.Info.Traits.GetOrDefault(); if (info == null) return null; var weapon = info.PrimaryWeapon; @@ -43,7 +43,7 @@ namespace OpenRa.Game public static WeaponInfo GetSecondaryWeapon(this Actor self) { - var info = self.Info.Traits.WithInterface().FirstOrDefault(); + var info = self.Info.Traits.GetOrDefault(); if (info == null) return null; var weapon = info.SecondaryWeapon; diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index c3237a5470..4ee33460d3 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -244,7 +244,7 @@ namespace OpenRa.Game public static bool IsActorCrushableByActor(Actor a, Actor b) { - return IsActorCrushableByMovementType(a, b.traits.WithInterface().FirstOrDefault().GetMovementType()); + return IsActorCrushableByMovementType(a, b.traits.GetOrDefault().GetMovementType()); } public static bool IsActorPathableToCrush(Actor a, UnitMovementType umt) diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 6f70cf883a..d403192261 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.GameRules foreach( var b in Rules.Categories[ "Building" ] ) { var info = Rules.NewUnitInfo[ b ]; - var pi = info.Traits.WithInterface().FirstOrDefault(); + var pi = info.Traits.GetOrDefault(); if (pi != null) foreach( var p in pi.Produces ) producesIndex[ p ].Add( info ); diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 44b1d197ab..a3c82c409c 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -169,7 +169,7 @@ namespace OpenRa.Game.Graphics lineRenderer.DrawLine(xy + new float2(0, -2), xy + new float2(0, -4), c, c); lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c); - var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Traits.WithInterface().First().HP; + var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Traits.Get().HP; var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs b/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs index a32d0ca117..2babfc2232 100644 --- a/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronoshiftDestinationOrderGenerator.cs @@ -40,7 +40,7 @@ namespace OpenRa.Game.Orders if (!Game.LocalPlayer.Shroud.IsExplored(xy)) return Cursor.MoveBlocked; - var movement = self.traits.WithInterface().FirstOrDefault(); + var movement = self.traits.GetOrDefault(); return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked; } } diff --git a/OpenRa.Game/Orders/ChronoshiftSelfDestinationOrderGenerator.cs b/OpenRa.Game/Orders/ChronoshiftSelfDestinationOrderGenerator.cs index 5c949c1c51..d44ccbd88a 100644 --- a/OpenRa.Game/Orders/ChronoshiftSelfDestinationOrderGenerator.cs +++ b/OpenRa.Game/Orders/ChronoshiftSelfDestinationOrderGenerator.cs @@ -38,7 +38,7 @@ namespace OpenRa.Game.Orders if (!Game.LocalPlayer.Shroud.IsExplored(xy)) return Cursor.MoveBlocked; - var movement = self.traits.WithInterface().FirstOrDefault(); + var movement = self.traits.GetOrDefault(); return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked; } } diff --git a/OpenRa.Game/Orders/UnitOrderGenerator.cs b/OpenRa.Game/Orders/UnitOrderGenerator.cs index c578db1f34..a3455ae861 100644 --- a/OpenRa.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRa.Game/Orders/UnitOrderGenerator.cs @@ -57,7 +57,7 @@ namespace OpenRa.Game.Orders Cursor CursorForOrderString(string s, Actor a, int2 location) { - var movement = a.traits.WithInterface().FirstOrDefault(); + var movement = a.traits.GetOrDefault(); switch (s) { case "Attack": return Cursor.Attack; diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 1b0cdfae55..c1cddc65ff 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -35,7 +35,7 @@ namespace OpenRa.Game { foreach (var t in Game.FindTilesInCircle( (1f / Game.CellSize * a.CenterLocation).ToInt2(), - a.Info.Traits.WithInterface().First().Sight)) + a.Info.Traits.Get().Sight)) explored[t.X, t.Y] = true; dirty = true; diff --git a/OpenRa.Game/Traits/Activities/Attack.cs b/OpenRa.Game/Traits/Activities/Attack.cs index edb64ea905..3a13213597 100644 --- a/OpenRa.Game/Traits/Activities/Attack.cs +++ b/OpenRa.Game/Traits/Activities/Attack.cs @@ -27,7 +27,7 @@ namespace OpenRa.Game.Traits.Activities return new Move( Target, Range ) { NextActivity = this }; var desiredFacing = Util.GetFacing((Target.Location - self.Location).ToFloat2(), 0); - var renderUnit = self.traits.WithInterface().FirstOrDefault(); + var renderUnit = self.traits.GetOrDefault(); var numDirs = (renderUnit != null) ? renderUnit.anim.CurrentSequence.Length : 8; @@ -37,7 +37,7 @@ namespace OpenRa.Game.Traits.Activities return new Turn( desiredFacing ) { NextActivity = this }; } - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); attack.target = Target; attack.DoAttack(self); return this; diff --git a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs index 69b7bc91d7..ca304c8505 100644 --- a/OpenRa.Game/Traits/Activities/CaptureBuilding.cs +++ b/OpenRa.Game/Traits/Activities/CaptureBuilding.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if (target.Owner == self.Owner) { - if (target.Health == target.Info.Traits.WithInterface().First().HP) + if (target.Health == target.Info.Traits.Get().HP) return NextActivity; target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]); } diff --git a/OpenRa.Game/Traits/Activities/DeliverOre.cs b/OpenRa.Game/Traits/Activities/DeliverOre.cs index c41c69c6c5..edc5b25f3d 100644 --- a/OpenRa.Game/Traits/Activities/DeliverOre.cs +++ b/OpenRa.Game/Traits/Activities/DeliverOre.cs @@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits.Activities else if( unit.Facing != 64 ) return new Turn( 64 ) { NextActivity = this }; - var renderUnit = self.traits.WithInterface().First(); + var renderUnit = self.traits.Get(); if( renderUnit.anim.CurrentSequence.Name != "empty" ) renderUnit.PlayCustomAnimation( self, "empty", () => isDone = true ); diff --git a/OpenRa.Game/Traits/Activities/Harvest.cs b/OpenRa.Game/Traits/Activities/Harvest.cs index 677c34e953..0de6440655 100644 --- a/OpenRa.Game/Traits/Activities/Harvest.cs +++ b/OpenRa.Game/Traits/Activities/Harvest.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits.Activities { var unit = self.traits.Get(); var harv = self.traits.Get(); - var renderUnit = self.traits.WithInterface().First(); /* better have one of these! */ + var renderUnit = self.traits.Get(); /* better have one of these! */ var isGem = false; if (!Rules.Map.ContainsResource(self.Location) || diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index 3595f7dd6f..425f8cb997 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits.Activities if (isCanceled) return NextActivity; var dest = ChooseHelipad(self); - var initialFacing = self.Info.Traits.WithInterface().First().InitialFacing; + var initialFacing = self.Info.Traits.Get().InitialFacing; if (dest == null) return Util.SequenceActivities( diff --git a/OpenRa.Game/Traits/Activities/Repair.cs b/OpenRa.Game/Traits/Activities/Repair.cs index b343b3f506..1edf56ae36 100644 --- a/OpenRa.Game/Traits/Activities/Repair.cs +++ b/OpenRa.Game/Traits/Activities/Repair.cs @@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits.Activities if (remainingTicks == 0) { var unitCost = self.Info.Traits.Get().Cost; - var hp = self.Info.Traits.WithInterface().First().HP; + var hp = self.Info.Traits.Get().HP; var costPerHp = (Rules.General.URepairPercent * unitCost) / hp; var hpToRepair = Math.Min(Rules.General.URepairStep, hp - self.Health); diff --git a/OpenRa.Game/Traits/Activities/Sell.cs b/OpenRa.Game/Traits/Activities/Sell.cs index b8c784faec..a185d47a7c 100644 --- a/OpenRa.Game/Traits/Activities/Sell.cs +++ b/OpenRa.Game/Traits/Activities/Sell.cs @@ -14,7 +14,7 @@ namespace OpenRa.Game.Traits.Activities void DoSell(Actor self) { var cost = self.Info.Traits.Get().Cost; - var hp = self.Info.Traits.WithInterface().First().HP; + var hp = self.Info.Traits.Get().HP; var refund = Rules.General.RefundPercent * self.Health * cost / hp; self.Owner.GiveCash((int)refund); @@ -30,7 +30,7 @@ namespace OpenRa.Game.Traits.Activities { if (!started) { - var rb = self.traits.WithInterface().First(); + var rb = self.traits.Get(); //var rb = self.traits.Get(); rb.PlayCustomAnimBackwards(self, "make", () => Game.world.AddFrameEndTask(w => DoSell(self))); diff --git a/OpenRa.Game/Traits/Activities/UnloadCargo.cs b/OpenRa.Game/Traits/Activities/UnloadCargo.cs index 32b9da09ca..3b5a1fe3a7 100644 --- a/OpenRa.Game/Traits/Activities/UnloadCargo.cs +++ b/OpenRa.Game/Traits/Activities/UnloadCargo.cs @@ -44,7 +44,7 @@ namespace OpenRa.Game.Traits.Activities if (cargo.IsEmpty(self)) return NextActivity; - var ru = self.traits.WithInterface().FirstOrDefault(); + var ru = self.traits.GetOrDefault(); if (ru != null) ru.PlayCustomAnimation(self, "unload", null); diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 366d3902c6..b5f5bb66dd 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -88,7 +88,7 @@ namespace OpenRa.Game.Traits public void DoAttack(Actor self) { var unit = self.traits.GetOrDefault(); - var info = self.Info.Traits.WithInterface().First(); + var info = self.Info.Traits.Get(); if (info.PrimaryWeapon != null && CheckFire(self, unit, info.PrimaryWeapon, ref primaryFireDelay, info.PrimaryOffset, ref primaryBurst, info.PrimaryLocalOffset)) @@ -142,7 +142,7 @@ namespace OpenRa.Game.Traits var firePos = self.CenterLocation.ToInt2() + Util.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(); var thisTarget = target; // closure. var destUnit = thisTarget.traits.GetOrDefault(); - var info = self.Info.Traits.WithInterface().First(); + var info = self.Info.Traits.Get(); ScheduleDelayedAction(info.FireDelay, () => { diff --git a/OpenRa.Game/Traits/AutoHeal.cs b/OpenRa.Game/Traits/AutoHeal.cs index d31041939a..c9918aee83 100644 --- a/OpenRa.Game/Traits/AutoHeal.cs +++ b/OpenRa.Game/Traits/AutoHeal.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits { void AttackTarget(Actor self, Actor target) { - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); if (target != null) attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null)); else @@ -19,14 +19,14 @@ namespace OpenRa.Game.Traits bool NeedsNewTarget(Actor self) { - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); var range = Util.GetMaximumRange(self); if (attack.target == null) return true; // he's dead. if ((attack.target.Location - self.Location).LengthSquared > range * range + 2) return true; // wandered off faster than we could follow - if (attack.target.Health == attack.target.Info.Traits.WithInterface().First().HP) + if (attack.target.Health == attack.target.Info.Traits.Get().HP) return true; // fully healed return false; @@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits public void Tick(Actor self) { - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); var range = Util.GetMaximumRange(self); if (NeedsNewTarget(self)) @@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits return inRange .Where(a => a.Owner == self.Owner && a != self) /* todo: one day deal with friendly players */ .Where(a => Combat.HasAnyValidWeapons(self, a)) - .Where(a => a.Health < a.Info.Traits.WithInterface().First().HP) + .Where(a => a.Health < a.Info.Traits.Get().HP) .OrderBy(a => (a.Location - self.Location).LengthSquared) .FirstOrDefault(); } diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 33fc5002c5..a6721b6cfb 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -8,7 +8,7 @@ namespace OpenRa.Game.Traits { void AttackTarget(Actor self, Actor target) { - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); if (target != null) attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null)); } @@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits { if (!self.IsIdle) return; - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); var range = Util.GetMaximumRange(self); if (attack.target == null || @@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits if (e.Damage < 0) return; // don't retaliate against healers - var attack = self.traits.WithInterface().First(); + var attack = self.traits.Get(); if (attack.target != null) return; AttackTarget(self, e.Attacker); diff --git a/OpenRa.Game/Traits/ChronoshiftDeploy.cs b/OpenRa.Game/Traits/ChronoshiftDeploy.cs index 08c24000ba..5b814d1038 100644 --- a/OpenRa.Game/Traits/ChronoshiftDeploy.cs +++ b/OpenRa.Game/Traits/ChronoshiftDeploy.cs @@ -40,7 +40,7 @@ namespace OpenRa.Game.Traits return; } - var movement = self.traits.WithInterface().FirstOrDefault(); + var movement = self.traits.GetOrDefault(); if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation)) { // Cannot chronoshift into unexplored location diff --git a/OpenRa.Game/Traits/Chronoshiftable.cs b/OpenRa.Game/Traits/Chronoshiftable.cs index 4450d036ce..067c43716e 100644 --- a/OpenRa.Game/Traits/Chronoshiftable.cs +++ b/OpenRa.Game/Traits/Chronoshiftable.cs @@ -45,7 +45,7 @@ namespace OpenRa.Game.Traits Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self, power); } - var movement = self.traits.WithInterface().FirstOrDefault(); + var movement = self.traits.GetOrDefault(); if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation)) { // Cannot chronoshift into unexplored location diff --git a/OpenRa.Game/Traits/DemoTruck.cs b/OpenRa.Game/Traits/DemoTruck.cs index c8ff6c5f73..2816729f98 100644 --- a/OpenRa.Game/Traits/DemoTruck.cs +++ b/OpenRa.Game/Traits/DemoTruck.cs @@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits public new void ResolveOrder(Actor self, Order order) { // Override chronoshifting action to detonate vehicle - var movement = self.traits.WithInterface().FirstOrDefault(); + var movement = self.traits.GetOrDefault(); var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains()).FirstOrDefault(); if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation)) { @@ -44,7 +44,7 @@ namespace OpenRa.Game.Traits int2 detonateLocation = self.CenterLocation.ToInt2(); Game.world.AddFrameEndTask( - w => w.Add(new Bullet(self.Info.Traits.WithInterface().First().PrimaryWeapon, detonatedBy.Owner, detonatedBy, + w => w.Add( new Bullet( self.Info.Traits.Get().PrimaryWeapon, detonatedBy.Owner, detonatedBy, detonateLocation, detonateLocation, altitude, altitude))); } } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 6c8114c764..58e570fe2f 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -52,7 +52,7 @@ namespace OpenRa.Game.Traits { self.CancelActivity(); self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation))); - self.QueueActivity(new Turn(self.Info.Traits.WithInterface().FirstOrDefault().InitialFacing)); + self.QueueActivity( new Turn( self.Info.Traits.GetOrDefault().InitialFacing ) ); self.QueueActivity(new HeliLand(true)); } @@ -69,7 +69,7 @@ namespace OpenRa.Game.Traits self.CancelActivity(); self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec)); - self.QueueActivity(new Turn(self.Info.Traits.WithInterface().FirstOrDefault().InitialFacing)); + self.QueueActivity( new Turn( self.Info.Traits.GetOrDefault().InitialFacing ) ); self.QueueActivity(new HeliLand(false)); self.QueueActivity(order.TargetActor.Info.Name == "hpad" ? (IActivity)new Rearm() : new Repair()); diff --git a/OpenRa.Game/Traits/Passenger.cs b/OpenRa.Game/Traits/Passenger.cs index 33b17b2b8d..2339b37325 100644 --- a/OpenRa.Game/Traits/Passenger.cs +++ b/OpenRa.Game/Traits/Passenger.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits if (cargo == null || cargo.IsFull(underCursor)) return null; - var umt = self.traits.WithInterface().First().GetMovementType(); + var umt = self.traits.Get().GetMovementType(); if (!underCursor.Info.Traits.Get().PassengerTypes.Contains(umt)) return null; diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index ade7b28856..a35beeb11e 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - return newUnit.Info.Traits.WithInterface().FirstOrDefault().InitialFacing; + return newUnit.Info.Traits.GetOrDefault().InitialFacing; } public bool Produce( Actor self, LegacyUnitInfo producee ) diff --git a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs index 2990363d0d..6386120fa5 100644 --- a/OpenRa.Game/Traits/RenderBuildingWarFactory.cs +++ b/OpenRa.Game/Traits/RenderBuildingWarFactory.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits public RenderWarFactory(Actor self) { this.self = self; - roof = new Animation(self.traits.WithInterface().First().GetImage(self)); + roof = new Animation(self.traits.Get().GetImage(self)); } public void BuildingComplete( Actor self ) diff --git a/OpenRa.Game/Traits/RenderSimple.cs b/OpenRa.Game/Traits/RenderSimple.cs index 30cc447c8f..b27d49f887 100644 --- a/OpenRa.Game/Traits/RenderSimple.cs +++ b/OpenRa.Game/Traits/RenderSimple.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits public string GetImage(Actor self) { - return self.Info.Traits.WithInterface().First().Image ?? self.Info.Name; + return self.Info.Traits.Get().Image ?? self.Info.Name; } public RenderSimple(Actor self) diff --git a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs index fa8f569bbc..9e18c5830a 100644 --- a/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs +++ b/OpenRa.Game/Traits/RenderUnitMuzzleFlash.cs @@ -16,8 +16,8 @@ namespace OpenRa.Game.Traits : base(self) { var unit = self.traits.Get(); - var attack = self.traits.WithInterface().First(); - var attackInfo = self.Info.Traits.WithInterface().First(); + var attack = self.traits.Get(); + var attackInfo = self.Info.Traits.Get(); var muzzleFlash = new Animation(GetImage(self)); muzzleFlash.PlayFetchIndex("muzzle", diff --git a/OpenRa.Game/Traits/RenderUnitReload.cs b/OpenRa.Game/Traits/RenderUnitReload.cs index f1b67973e9..ea966477c4 100644 --- a/OpenRa.Game/Traits/RenderUnitReload.cs +++ b/OpenRa.Game/Traits/RenderUnitReload.cs @@ -16,7 +16,7 @@ namespace OpenRa.Game.Traits { var isAttacking = self.GetCurrentActivity() is Activities.Attack; - var attack = self.traits.WithInterface().FirstOrDefault(); + var attack = self.traits.GetOrDefault(); if (attack != null) anim.ReplaceAnim((attack.IsReloading() ? "empty-" : "") diff --git a/OpenRa.Game/Traits/RenderUnitTurreted.cs b/OpenRa.Game/Traits/RenderUnitTurreted.cs index c6222bd0b8..30a204f6a0 100644 --- a/OpenRa.Game/Traits/RenderUnitTurreted.cs +++ b/OpenRa.Game/Traits/RenderUnitTurreted.cs @@ -16,8 +16,8 @@ namespace OpenRa.Game.Traits { var unit = self.traits.Get(); var turreted = self.traits.Get(); - var attack = self.traits.WithInterface().FirstOrDefault(); - var attackInfo = self.Info.Traits.WithInterface().First(); + var attack = self.traits.GetOrDefault(); + var attackInfo = self.Info.Traits.Get(); var turretAnim = new Animation(GetImage(self)); turretAnim.PlayFacing( "turret", () => turreted.turretFacing ); diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 9b8345796c..246a19721b 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -83,7 +83,7 @@ namespace OpenRa.Game.Traits static float2 GetRecoil(Actor self, float recoil) { if (self.LegacyInfo.Recoil == 0) return float2.Zero; - var rut = self.traits.WithInterface().FirstOrDefault(); + var rut = self.traits.GetOrDefault(); if (rut == null) return float2.Zero; var facing = self.traits.Get().turretFacing; @@ -106,7 +106,7 @@ namespace OpenRa.Game.Traits { if( unit == null ) return int2.Zero; /* things that don't have a rotating base don't need the turrets repositioned */ - var ru = self.traits.WithInterface().FirstOrDefault(); + var ru = self.traits.GetOrDefault(); var numDirs = (ru != null) ? ru.anim.CurrentSequence.Length : 8; var bodyFacing = unit.Facing; var quantizedFacing = QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs); @@ -145,7 +145,7 @@ namespace OpenRa.Game.Traits public static float GetMaximumRange(Actor self) { - var info = self.Info.Traits.WithInterface().First(); + var info = self.Info.Traits.Get(); return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() } .Where(w => w != null).Max(w => w.Range); } diff --git a/OpenRa.Game/UnitInfluenceMap.cs b/OpenRa.Game/UnitInfluenceMap.cs index 6f50bf1dad..4d93aa7e3c 100644 --- a/OpenRa.Game/UnitInfluenceMap.cs +++ b/OpenRa.Game/UnitInfluenceMap.cs @@ -16,8 +16,8 @@ namespace OpenRa.Game for (int i = 0; i < 128; i++) for (int j = 0; j < 128; j++) influence[ i, j ] = new List(); - - Game.world.ActorRemoved += a => Remove(a, a.traits.WithInterface().FirstOrDefault()); + + Game.world.ActorRemoved += a => Remove( a, a.traits.GetOrDefault() ); } public void Tick() @@ -53,7 +53,7 @@ namespace OpenRa.Game for( int x = 0 ; x < 128 ; x++ ) if( influence[ x, y ] != null ) foreach (var a in influence[ x, y ]) - if (!a.traits.WithInterface().First().OccupiedCells().Contains( new int2( x, y ) ) ) + if (!a.traits.Get().OccupiedCells().Contains( new int2( x, y ) ) ) throw new InvalidOperationException( "UIM: Sanity check failed A" ); foreach( Actor a in Game.world.Actors ) From 275100938d89db75ea764764a11e5e6bb1c8e0b8 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 15:25:27 +1300 Subject: [PATCH 49/83] fixes the build palette, and a few silly errors. --- OpenRa.DataStructures/TypeDictionary.cs | 2 +- RulesConverter/Program.cs | 3 ++- ra.yaml | 9 ++++++++- regen-yaml.cmd | 0 units.ini | 6 +++--- 5 files changed, 14 insertions(+), 6 deletions(-) mode change 100644 => 100755 regen-yaml.cmd diff --git a/OpenRa.DataStructures/TypeDictionary.cs b/OpenRa.DataStructures/TypeDictionary.cs index e4309999bd..81fedaf549 100755 --- a/OpenRa.DataStructures/TypeDictionary.cs +++ b/OpenRa.DataStructures/TypeDictionary.cs @@ -22,7 +22,7 @@ namespace OpenRa public bool Contains() { - return innerInherit.Keys.Contains( typeof( T ) ); + return innerInherit[ typeof( T ) ].Count != 0; } public T Get() diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 29c2a8ae03..3a850745fc 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -143,7 +143,8 @@ namespace RulesConverter }, { "Production", new PL { - { "SpawnOffset", "SpawnOffset" } } + { "SpawnOffset", "SpawnOffset" }, + { "Produces", "Produces" } } }, }; diff --git a/ra.yaml b/ra.yaml index 47c9ae40db..0ea0dce87c 100644 --- a/ra.yaml +++ b/ra.yaml @@ -1052,10 +1052,11 @@ WEAP: Armor: light Crewed: yes Sight: 4 - RenderWarFactory: RenderBuilding: + RenderWarFactory: RallyPoint: Production: + Produces: Vehicle IronCurtainable: SYRD: @@ -1127,6 +1128,8 @@ FACT: Crewed: yes Sight: 5 RenderBuilding: + Production: + Produces: Building,Defense ConstructionYard: IronCurtainable: @@ -1210,6 +1213,7 @@ HPAD: RenderBuilding: Production: SpawnOffset: 0,-4 + Produces: Plane BelowUnits: Reservable: IronCurtainable: @@ -1264,6 +1268,7 @@ AFLD: Sight: 7 RenderBuilding: Production: + Produces: Plane BelowUnits: Reservable: IronCurtainable: @@ -1368,6 +1373,7 @@ BARR: RenderBuilding: RallyPoint: Production: + Produces: Infantry IronCurtainable: TENT: @@ -1395,6 +1401,7 @@ TENT: RenderBuilding: RallyPoint: Production: + Produces: Infantry IronCurtainable: KENN: diff --git a/regen-yaml.cmd b/regen-yaml.cmd old mode 100644 new mode 100755 diff --git a/units.ini b/units.ini index 4e22c79415..0386e52630 100644 --- a/units.ini +++ b/units.ini @@ -355,7 +355,7 @@ SelectionPriority=3 LongDesc=Provides Allied advanced technologies.\n Special Ability: GPS Satellite [WEAP] Description=War Factory -Traits=Building, RenderWarFactory, RenderBuilding, RallyPoint, Production, IronCurtainable +Traits=Building, RenderBuilding, RenderWarFactory, RallyPoint, Production, IronCurtainable Dimensions=3,2 Footprint=xxx xxx Produces=Vehicle @@ -380,7 +380,7 @@ SelectionPriority=3 LongDesc=Produces and repairs submarines and \ntransports [FACT] Description=Construction Yard -Traits=Building, RenderBuilding, ConstructionYard, IronCurtainable +Traits=Building, RenderBuilding, Production, ConstructionYard, IronCurtainable Dimensions=3,3 Footprint=xxx xxx xxx Produces=Building,Defense @@ -898,4 +898,4 @@ LongDesc=Makes a single unit invulnerable for a \nshort time. Image=infxicon Prerequisite=IRON TechLevel=12 -Impl=IronCurtainPower +Impl=IronCurtainPower From df330f3151c772df4d9959fbc326ef2d8b006bb8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 15:47:11 +1300 Subject: [PATCH 50/83] fixing some more bits --- OpenRa.Game/Traits/Activities/HeliFly.cs | 3 ++- OpenRa.Game/Traits/AttackTurreted.cs | 4 ++-- OpenRa.Game/Traits/Building.cs | 25 ++++++++++++++---------- OpenRa.Game/Traits/Cargo.cs | 3 ++- OpenRa.Game/Traits/Plane.cs | 2 +- OpenRa.Game/Traits/RallyPoint.cs | 6 ++++-- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/OpenRa.Game/Traits/Activities/HeliFly.cs b/OpenRa.Game/Traits/Activities/HeliFly.cs index fd1ac6aa50..9699a01853 100644 --- a/OpenRa.Game/Traits/Activities/HeliFly.cs +++ b/OpenRa.Game/Traits/Activities/HeliFly.cs @@ -39,7 +39,8 @@ namespace OpenRa.Game.Traits.Activities } var desiredFacing = Util.GetFacing(dist, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.LegacyInfo.ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, + self.Info.Traits.Get().ROT); var rawSpeed = .2f * Util.GetEffectiveSpeed(self); self.CenterLocation += (rawSpeed / dist.Length) * dist; diff --git a/OpenRa.Game/Traits/AttackTurreted.cs b/OpenRa.Game/Traits/AttackTurreted.cs index c8305e192c..33aef0b1ad 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -36,11 +36,11 @@ namespace OpenRa.Game.Traits const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */ /* todo: choose the appropriate weapon, when only one works against this target */ - var weapon = order.Subject.LegacyInfo.Primary ?? order.Subject.LegacyInfo.Secondary; + var weapon = order.Subject.GetPrimaryWeapon() ?? order.Subject.GetSecondaryWeapon(); if (self.traits.Contains()) self.QueueActivity( new Traits.Activities.Follow( order.TargetActor, - Math.Max( 0, (int)Rules.WeaponInfo[ weapon ].Range - RangeTolerance ) ) ); + Math.Max( 0, (int)weapon.Range - RangeTolerance ) ) ); target = order.TargetActor; diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 66608059ae..b351c14202 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -39,32 +39,36 @@ namespace OpenRa.Game.Traits class Building : INotifyDamage, IResolveOrder, ITick { readonly Actor self; - public readonly LegacyBuildingInfo unitInfo; + [Obsolete] public readonly LegacyBuildingInfo unitInfo; + public readonly BuildingInfo Info; [Sync] bool isRepairing = false; [Sync] bool manuallyDisabled = false; public bool ManuallyDisabled { get { return manuallyDisabled; } } - public bool Disabled { get { return (manuallyDisabled || (unitInfo.Powered && self.Owner.GetPowerState() != PowerState.Normal)); } } + public bool Disabled { get { return (manuallyDisabled || (Info.RequiresPower && self.Owner.GetPowerState() != PowerState.Normal)); } } bool wasDisabled = false; public Building(Actor self) { this.self = self; + Info = self.Info.Traits.Get(); unitInfo = (LegacyBuildingInfo)self.LegacyInfo; self.CenterLocation = Game.CellSize - * ((float2)self.Location + .5f * (float2)unitInfo.Dimensions); + * ((float2)self.Location + .5f * (float2)Info.Dimensions); } public int GetPowerUsage() { if (manuallyDisabled) return 0; - - if (unitInfo.Power > 0) /* todo: is this how real-ra scales it? */ - return (self.Health * unitInfo.Power) / unitInfo.Strength; + + var maxHP = self.Info.Traits.Get().HP; + + if (Info.Power > 0) /* todo: is this how real-ra scales it? */ + return (self.Health * Info.Power) / maxHP; else - return unitInfo.Power; + return Info.Power; } public void Damaged(Actor self, AttackInfo e) @@ -106,8 +110,9 @@ namespace OpenRa.Game.Traits if (remainingTicks == 0) { - var costPerHp = (Rules.General.URepairPercent * self.LegacyInfo.Cost) / self.LegacyInfo.Strength; - var hpToRepair = Math.Min(Rules.General.URepairStep, self.LegacyInfo.Strength - self.Health); + var maxHP = self.Info.Traits.Get().HP; + var costPerHp = (Rules.General.URepairPercent * self.Info.Traits.Get().Cost) / maxHP; + var hpToRepair = Math.Min(Rules.General.URepairStep, maxHP - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -117,7 +122,7 @@ namespace OpenRa.Game.Traits Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self))); self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); - if (self.Health == self.LegacyInfo.Strength) + if (self.Health == maxHP) { isRepairing = false; return; diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index 72d774eb61..99707546bc 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -9,6 +9,7 @@ namespace OpenRa.Game.Traits { class CargoInfo : ITraitInfo { + public readonly int Passengers = 0; public readonly UnitMovementType[] PassengerTypes = { }; public readonly int UnloadFacing = 0; @@ -64,7 +65,7 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips( Actor self ) { - for (var i = 0; i < self.LegacyInfo.Passengers; i++) + for (var i = 0; i < self.Info.Traits.Get().Passengers; i++) if (i >= cargo.Count) yield return PipType.Transparent; else diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 96c2884d6c..fefa10a17c 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -64,7 +64,7 @@ namespace OpenRa.Game.Traits self.CancelActivity(); self.QueueActivity(new ReturnToBase(self, order.TargetActor)); - self.QueueActivity(order.TargetActor.LegacyInfo == Rules.UnitInfo["AFLD"] + self.QueueActivity(order.TargetActor.Info.Name == "afld" ? (IActivity)new Rearm() : new Repair()); } } diff --git a/OpenRa.Game/Traits/RallyPoint.cs b/OpenRa.Game/Traits/RallyPoint.cs index 1daf34c844..6a7fc5c434 100644 --- a/OpenRa.Game/Traits/RallyPoint.cs +++ b/OpenRa.Game/Traits/RallyPoint.cs @@ -6,6 +6,8 @@ namespace OpenRa.Game.Traits { class RallyPointInfo : ITraitInfo { + public readonly int[] RallyPoint = { 1, 3 }; + public object Create(Actor self) { return new RallyPoint(self); } } @@ -17,8 +19,8 @@ namespace OpenRa.Game.Traits public RallyPoint(Actor self) { - var bi = self.traits.Get().unitInfo; - rallyPoint = self.Location + new int2(bi.RallyPoint[0], bi.RallyPoint[1]); + var info = self.Info.Traits.Get(); + rallyPoint = self.Location + new int2(info.RallyPoint[0], info.RallyPoint[1]); anim = new Animation("flagfly"); anim.PlayRepeating("idle"); } From d6af22f897c707a0c0ad6c6ca1b55d5ae9dc3db7 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 15:51:57 +1300 Subject: [PATCH 51/83] copy passengers to the right traitinfo --- OpenRa.sln | 1 + RulesConverter/Program.cs | 1 + ra.yaml | 3 +++ 3 files changed, 5 insertions(+) diff --git a/OpenRa.sln b/OpenRa.sln index ae77fb3c37..580ec2fce2 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -165,6 +165,7 @@ Global {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Mixed Platforms.ActiveCfg = Debug|Any CPU {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Mixed Platforms.Build.0 = Debug|Any CPU {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Win32.ActiveCfg = Debug|Any CPU + {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug (x86)|Win32.Build.0 = Debug|Any CPU {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Any CPU.Build.0 = Debug|Any CPU {BBE7C0D7-7529-4C34-9910-206866F204EF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 3a850745fc..c47863ec82 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -94,6 +94,7 @@ namespace RulesConverter { "Cargo", new PL { { "@PassengerTypes", "PassengerTypes" }, + { "Passengers", "Passengers" }, { "UnloadFacing", "UnloadFacing" } } }, diff --git a/ra.yaml b/ra.yaml index 0ea0dce87c..5575716221 100644 --- a/ra.yaml +++ b/ra.yaml @@ -356,6 +356,7 @@ APC: Chronoshiftable: Cargo: PassengerTypes: Foot + Passengers: 5 UnloadFacing: 220 Passenger: IronCurtainable: @@ -538,6 +539,7 @@ LST: RenderUnit: Cargo: PassengerTypes: Foot,Wheel,Track + Passengers: 5 IronCurtainable: PT: @@ -647,6 +649,7 @@ TRAN: WithShadow: Cargo: PassengerTypes: Foot + Passengers: 5 IronCurtainable: HELI: From 3649b3b69f537781b322eae881cdec3137c6c76f Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 16:28:14 +1300 Subject: [PATCH 52/83] aftermath works again, and Inherits... might works. --- OpenRa.FileFormats/MiniYaml.cs | 32 ++++++++++++++++++++++++++++ OpenRa.Game/GameRules/NewUnitInfo.cs | 29 +++++++++++++++---------- OpenRa.Game/GameRules/Rules.cs | 8 +++++-- 3 files changed, 56 insertions(+), 13 deletions(-) diff --git a/OpenRa.FileFormats/MiniYaml.cs b/OpenRa.FileFormats/MiniYaml.cs index 3b51b27e72..b26b69d9b1 100755 --- a/OpenRa.FileFormats/MiniYaml.cs +++ b/OpenRa.FileFormats/MiniYaml.cs @@ -54,5 +54,37 @@ namespace OpenRa.FileFormats } return levels[ 0 ]; } + + public static Dictionary Merge( Dictionary a, Dictionary b ) + { + if( a.Count == 0 ) + return b; + if( b.Count == 0 ) + return a; + + var ret = new Dictionary(); + + var keys = a.Keys.Union( b.Keys ).ToList(); + + foreach( var key in keys ) + { + MiniYaml aa, bb; + a.TryGetValue( key, out aa ); + b.TryGetValue( key, out bb ); + ret.Add( key, Merge( aa, bb ) ); + } + + return ret; + } + + public static MiniYaml Merge( MiniYaml a, MiniYaml b ) + { + if( a == null ) + return b; + if( b == null ) + return a; + + return new MiniYaml( a.Value ?? b.Value, Merge( a.Nodes, b.Nodes ) ); + } } } diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs index 62cee867be..1f84bce4e0 100755 --- a/OpenRa.Game/GameRules/NewUnitInfo.cs +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -8,24 +8,31 @@ namespace OpenRa.Game.GameRules { class NewUnitInfo { - public readonly string Parent; public readonly TypeDictionary Traits = new TypeDictionary(); public readonly string Name; - public NewUnitInfo( string name, MiniYaml node ) + public NewUnitInfo( string name, MiniYaml node, Dictionary allUnits ) { Name = name; - // todo: make inheritance actually work - MiniYaml inherit; - if( node.Nodes.TryGetValue( "Inherits", out inherit ) ) - { - Parent = inherit.Value; - node.Nodes.Remove( "Inherits" ); - } + foreach( var t in MergeWithParent( node, allUnits ).Nodes ) + if( t.Key != "Inherits" ) + Traits.Add( LoadTraitInfo( t.Key, t.Value ) ); + } - foreach (var t in node.Nodes) - Traits.Add(LoadTraitInfo(t.Key, t.Value)); + static MiniYaml MergeWithParent( MiniYaml node, Dictionary allUnits ) + { + MiniYaml inherits; + node.Nodes.TryGetValue( "Inherits", out inherits ); + if( inherits.Value == null || string.IsNullOrEmpty( inherits.Value ) ) + return node; + + MiniYaml parent; + allUnits.TryGetValue( inherits.Value, out parent ); + if( parent == null ) + return node; + + return MiniYaml.Merge( node, MergeWithParent( parent, allUnits ) ); } static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my) diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 87eb755a35..d926f488a4 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -90,9 +90,13 @@ namespace OpenRa.Game SupportPowerInfo = new InfoLoader( Pair.New>("SupportPower", _ => new SupportPowerInfo())); + var yamlRules = MiniYaml.FromFile("ra.yaml"); + if( useAftermath ) + yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules ); + NewUnitInfo = new Dictionary(); - foreach (var kv in MiniYaml.FromFile("ra.yaml")) - NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value)); + foreach( var kv in yamlRules ) + NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules)); TechTree = new TechTree(); Map = new Map( AllRules ); From 4ddf03fc6416cfbe8149b5a3b340037b49e4f79d Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 16:28:39 +1300 Subject: [PATCH 53/83] // yes, that is how real-ra does it. --- OpenRa.Game/Traits/Building.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index b351c14202..82a990aea9 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -65,7 +65,7 @@ namespace OpenRa.Game.Traits var maxHP = self.Info.Traits.Get().HP; - if (Info.Power > 0) /* todo: is this how real-ra scales it? */ + if (Info.Power > 0) return (self.Health * Info.Power) / maxHP; else return Info.Power; From 09517acf18bebc35d30c8fe19536dfa0bfa15509 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 16:33:03 +1300 Subject: [PATCH 54/83] more fixes --- OpenRa.Game/Player.cs | 5 ++--- OpenRa.Game/Traits/Cargo.cs | 5 +++-- OpenRa.Game/Traits/Production.cs | 4 ++-- OpenRa.Game/Traits/RenderBuilding.cs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index 9e3d335b31..a7e29cb8c2 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -84,9 +84,8 @@ namespace OpenRa.Game { OreCapacity = Game.world.Actors .Where(a => a.Owner == this && a.traits.Contains()) - .Select(a => a.LegacyInfo as LegacyBuildingInfo) - .Where(b => b != null) - .Sum(b => b.Storage); + .Select(a => a.Info.Traits.Get()) + .Sum(b => b.Capacity); } void GiveAdvice(string advice) diff --git a/OpenRa.Game/Traits/Cargo.cs b/OpenRa.Game/Traits/Cargo.cs index 99707546bc..c9b99b79a7 100644 --- a/OpenRa.Game/Traits/Cargo.cs +++ b/OpenRa.Game/Traits/Cargo.cs @@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits public bool IsFull(Actor self) { - return cargo.Count == self.LegacyInfo.Passengers; + return cargo.Count == self.Info.Traits.Get().Passengers; } public bool IsEmpty(Actor self) @@ -65,7 +65,8 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips( Actor self ) { - for (var i = 0; i < self.Info.Traits.Get().Passengers; i++) + var numPips = self.Info.Traits.Get().Passengers; + for (var i = 0; i < numPips; i++) if (i >= cargo.Count) yield return PipType.Transparent; else diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index a35beeb11e..0f86a7b41e 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -86,12 +86,12 @@ namespace OpenRa.Game.Traits } // Cancel existing primaries - foreach (var p in (self.LegacyInfo as LegacyBuildingInfo).Produces) + foreach (var p in self.Info.Traits.Get().Produces) { foreach (var b in Game.world.Actors.Where(x => x.traits.Contains() && x.Owner == self.Owner && x.traits.Get().IsPrimary == true - && (x.LegacyInfo as LegacyBuildingInfo).Produces.Contains(p))) + && (x.Info.Traits.Get().Produces.Contains(p)))) { b.traits.Get().SetPrimaryProducer(b, false); } diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index 48e58af0ca..1024581177 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits void DoBib(Actor self, bool isRemove) { - var buildingInfo = self.traits.Get().unitInfo; + var buildingInfo = self.Info.Traits.Get(); if (buildingInfo.Bib) { var size = buildingInfo.Dimensions.X; From 3db8e4cf8fc8917f76f2a1812cdd39ca4729eafc Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 16:36:41 +1300 Subject: [PATCH 55/83] remove spurious reference to Yaml.dll --- RulesConverter/RulesConverter.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RulesConverter/RulesConverter.csproj b/RulesConverter/RulesConverter.csproj index cb7cdaa697..f23f869d56 100644 --- a/RulesConverter/RulesConverter.csproj +++ b/RulesConverter/RulesConverter.csproj @@ -48,10 +48,6 @@ - - False - ..\thirdparty\yaml\bin\Debug\Yaml.dll - From 5afedbf00126bd00c76b643065babea58af3006c Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 16:58:05 +1300 Subject: [PATCH 56/83] BuiltAt in RulesConverter --- OpenRa.Game/GameRules/NewUnitInfo.cs | 2 +- RulesConverter/Program.cs | 1 + aftermath.yaml | 1 + ra.yaml | 10 ++++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs index 1f84bce4e0..3c44f45762 100755 --- a/OpenRa.Game/GameRules/NewUnitInfo.cs +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.GameRules { MiniYaml inherits; node.Nodes.TryGetValue( "Inherits", out inherits ); - if( inherits.Value == null || string.IsNullOrEmpty( inherits.Value ) ) + if( inherits == null || string.IsNullOrEmpty( inherits.Value ) ) return node; MiniYaml parent; diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index c47863ec82..e9cda7e9f1 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -85,6 +85,7 @@ namespace RulesConverter { "TechLevel", "TechLevel" }, { "Tab", "$Tab" }, { "@Prerequisites", "Prerequisite" }, + { "BuiltAt", "BuiltAt" }, { "Owner", "Owner" }, { "Cost", "Cost" }, { "Icon", "Icon" }, diff --git a/aftermath.yaml b/aftermath.yaml index 5eaff6733b..05fe317ae1 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -116,6 +116,7 @@ MSUB: TechLevel: 9 Tab: Ship Prerequisites: stek + BuiltAt: spen Owner: soviet Cost: 1650 Description: "Missile Submarine" diff --git a/ra.yaml b/ra.yaml index 5575716221..73332b05b2 100644 --- a/ra.yaml +++ b/ra.yaml @@ -443,6 +443,7 @@ SS: TechLevel: 5 Tab: Ship Prerequisites: spen + BuiltAt: spen Owner: soviet Cost: 950 Description: "Submarine" @@ -469,6 +470,7 @@ DD: TechLevel: 7 Tab: Ship Prerequisites: syrd + BuiltAt: syrd Owner: allies Cost: 1000 Description: "Destroyer" @@ -496,6 +498,7 @@ CA: TechLevel: 10 Tab: Ship Prerequisites: syrd,atek + BuiltAt: syrd Owner: allies Cost: 2000 Description: "Cruiser" @@ -548,6 +551,7 @@ PT: TechLevel: 5 Tab: Ship Prerequisites: syrd + BuiltAt: syrd Owner: allies Cost: 500 Description: "Gunboat" @@ -575,6 +579,7 @@ MIG: TechLevel: 10 Tab: Plane Prerequisites: afld + BuiltAt: afld Owner: soviet Cost: 1200 Description: "Mig Attack Plane" @@ -602,6 +607,7 @@ YAK: TechLevel: 5 Tab: Plane Prerequisites: afld + BuiltAt: afld Owner: soviet Cost: 800 Description: "Yak Attack Plane" @@ -630,6 +636,7 @@ TRAN: TechLevel: 11 Tab: Plane Prerequisites: hpad + BuiltAt: hpad Owner: allies Cost: 1200 Description: "Transport Helicopter" @@ -658,6 +665,7 @@ HELI: TechLevel: 9 Tab: Plane Prerequisites: hpad + BuiltAt: hpad Owner: allies Cost: 1200 Description: "Longbow" @@ -689,6 +697,7 @@ HIND: TechLevel: 9 Tab: Plane Prerequisites: hpad + BuiltAt: hpad Owner: allies Cost: 1200 Description: "Hind" @@ -2234,6 +2243,7 @@ DOG: TechLevel: 3 Tab: Infantry Prerequisites: kenn + BuiltAt: KENN Owner: soviet Cost: 200 Description: "Attack Dog" From b21e1adc2d442645eea443e1b041b4a47fbff677 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 19:31:06 +1300 Subject: [PATCH 57/83] Fixing uses of legacyInfo.WaterBound --- OpenRa.Game/Combat.cs | 2 +- OpenRa.Game/Traits/Buildable.cs | 1 + OpenRa.Game/Traits/Building.cs | 2 +- OpenRa.Game/Traits/Production.cs | 4 +- OpenRa.Game/Traits/ProductionQueue.cs | 2 +- OpenRa.Game/Traits/ProductionSurround.cs | 4 +- OpenRa.Game/Traits/TraitsInterfaces.cs | 2 +- RulesConverter/MiniYamlExts.cs | 100 +++++++++++++++++++++++ 8 files changed, 109 insertions(+), 8 deletions(-) create mode 100755 RulesConverter/MiniYamlExts.cs diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index 2147aaceb3..7cd6c5cfa8 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -68,7 +68,7 @@ namespace OpenRa.Game if (unit != null && unit.Altitude > 0) return projectile.AA; - if (projectile.UnderWater && !target.LegacyInfo.WaterBound) + if (projectile.UnderWater && !target.Info.Traits.Get().WaterBound) return false; return projectile.AG; diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs index 273fdf1d97..5a420533e6 100755 --- a/OpenRa.Game/Traits/Buildable.cs +++ b/OpenRa.Game/Traits/Buildable.cs @@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits public readonly int TechLevel = -1; public readonly string Tab = null; public readonly string[] Prerequisites = { }; + public readonly string[] BuiltAt = { }; public readonly Race[] Owner = { }; public readonly int Cost = 0; public readonly string Description = ""; diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 82a990aea9..b4816bb971 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits public readonly bool Crewed = false; // replace with trait? public readonly int InitialFacing = 128; public readonly int Sight = 0; + public readonly bool WaterBound = false; } class BuildingInfo : OwnedActorInfo, ITraitInfo @@ -30,7 +31,6 @@ namespace OpenRa.Game.Traits public readonly string Footprint = "x"; public readonly string[] Produces = { }; // does this go somewhere else? public readonly int2 Dimensions = new int2(1, 1); - public readonly bool WaterBound = false; public readonly bool Unsellable = false; public object Create(Actor self) { return new Building(self); } diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 0f86a7b41e..794b7e4479 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits public Production( Actor self ) { } - public virtual int2? CreationLocation( Actor self, LegacyUnitInfo producee ) + public virtual int2? CreationLocation( Actor self, NewUnitInfo producee ) { return ( 1 / 24f * self.CenterLocation ).ToInt2(); } @@ -29,7 +29,7 @@ namespace OpenRa.Game.Traits return newUnit.Info.Traits.GetOrDefault().InitialFacing; } - public bool Produce( Actor self, LegacyUnitInfo producee ) + public bool Produce( Actor self, NewUnitInfo producee ) { var location = CreationLocation( self, producee ); if( location == null || Game.UnitInfluence.GetUnitsAt( location.Value ).Any() ) diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index b5945c76ff..559f78fc81 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -126,7 +126,7 @@ namespace OpenRa.Game.Traits public void BuildUnit( string name ) { - var newUnitType = Rules.UnitInfo[ name ]; + var newUnitType = Rules.NewUnitInfo[ name ]; var producerTypes = Rules.TechTree.UnitBuiltAt( newUnitType ); Actor producer = null; diff --git a/OpenRa.Game/Traits/ProductionSurround.cs b/OpenRa.Game/Traits/ProductionSurround.cs index fb81449bb1..0bf3ec8066 100644 --- a/OpenRa.Game/Traits/ProductionSurround.cs +++ b/OpenRa.Game/Traits/ProductionSurround.cs @@ -26,9 +26,9 @@ namespace OpenRa.Game.Traits return null; } - public override int2? CreationLocation(Actor self, LegacyUnitInfo producee) + public override int2? CreationLocation(Actor self, NewUnitInfo producee) { - return FindAdjacentTile(self, producee.WaterBound ? + return FindAdjacentTile(self, producee.Traits.Get().WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */ } diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index 1b0b8d7fc7..6a1e6aa0a6 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -25,7 +25,7 @@ namespace OpenRa.Game.Traits interface IProducer { - bool Produce( Actor self, LegacyUnitInfo producee ); + bool Produce( Actor self, NewUnitInfo producee ); void SetPrimaryProducer(Actor self, bool isPrimary); } interface IOccupySpace { IEnumerable OccupiedCells(); } diff --git a/RulesConverter/MiniYamlExts.cs b/RulesConverter/MiniYamlExts.cs new file mode 100755 index 0000000000..415e024a25 --- /dev/null +++ b/RulesConverter/MiniYamlExts.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.FileFormats; + +namespace RulesConverter +{ + using MiniYamlNodes = Dictionary; + using System.IO; + + static class MiniYamlExts + { + public static void WriteToFile( this MiniYamlNodes y, string filename ) + { + File.WriteAllLines( filename, y.ToLines( true ).ToArray() ); + } + + public static IEnumerable ToLines( this MiniYamlNodes y, bool lowest ) + { + foreach( var kv in y ) + { + foreach( var line in kv.Value.ToLines( kv.Key ) ) + yield return line; + if( lowest ) + yield return ""; + } + } + + public static IEnumerable ToLines( this MiniYaml y, string name ) + { + yield return name + ": " + y.Value; + foreach( var line in y.Nodes.ToLines( false ) ) + yield return "\t" + line; + } + + public static void OptimizeInherits( this MiniYamlNodes y, MiniYamlNodes baseYaml ) + { + foreach( var key in y.Keys.ToList() ) + { + var node = y[ key ]; + MiniYaml inherits; + node.Nodes.TryGetValue( "Inherits", out inherits ); + if( inherits == null || string.IsNullOrEmpty( inherits.Value ) ) + continue; + + MiniYaml parent; + baseYaml.TryGetValue( inherits.Value, out parent ); + if( parent == null ) + continue; + + y[ key ] = Diff( node, parent ); + if( y[ key ] == null ) + y.Remove( key ); + } + } + + public static MiniYamlNodes Diff( MiniYamlNodes a, MiniYamlNodes b ) + { + if( a.Count == 0 && b.Count == 0 ) + return null; + if( b.Count == 0 ) + return a; + if( a.Count == 0 ) + throw new NotImplementedException( "parent has key not in child" ); + + var ret = new MiniYamlNodes(); + + var keys = a.Keys.Union( b.Keys ).ToList(); + + foreach( var key in keys ) + { + MiniYaml aa, bb; + a.TryGetValue( key, out aa ); + b.TryGetValue( key, out bb ); + var diff = Diff( aa, bb ); + if( diff != null ) + ret.Add( key, diff ); + } + + if( ret.Count == 0 ) return null; + return ret; + } + + public static MiniYaml Diff( MiniYaml a, MiniYaml b ) + { + if( a == null && b == null ) + throw new InvalidOperationException( "can't happen" ); + else if( a == null ) + throw new NotImplementedException( "parent has key not in child" ); + else if( b == null ) + return a; + + var diff = Diff( a.Nodes, b.Nodes ); + if( diff == null ) + return null; + return new MiniYaml( a.Value, diff ); + } + } +} From 0c473aa94113e593724c8c3278b10489be8713e9 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 19:33:14 +1300 Subject: [PATCH 58/83] testing Inherits; seems to work. Also, the Converter knows a bit about Inherits now. --- OpenRa.Game/GameRules/NewUnitInfo.cs | 16 +++-- OpenRa.Game/GameRules/Rules.cs | 2 +- OpenRa.Game/GameRules/TechTree.cs | 7 +- RulesConverter/MiniYamlExts.cs | 2 +- RulesConverter/Program.cs | 7 +- RulesConverter/RulesConverter.csproj | 1 + aftermath.yaml | 20 +----- aftermathUnits.ini | 12 ++-- campaignUnits.ini | 4 +- defaults.yaml | 10 +++ ra.yaml | 101 ++------------------------- 11 files changed, 50 insertions(+), 132 deletions(-) create mode 100644 defaults.yaml diff --git a/OpenRa.Game/GameRules/NewUnitInfo.cs b/OpenRa.Game/GameRules/NewUnitInfo.cs index 3c44f45762..ec966e037d 100755 --- a/OpenRa.Game/GameRules/NewUnitInfo.cs +++ b/OpenRa.Game/GameRules/NewUnitInfo.cs @@ -20,19 +20,27 @@ namespace OpenRa.Game.GameRules Traits.Add( LoadTraitInfo( t.Key, t.Value ) ); } - static MiniYaml MergeWithParent( MiniYaml node, Dictionary allUnits ) + static MiniYaml GetParent( MiniYaml node, Dictionary allUnits ) { MiniYaml inherits; node.Nodes.TryGetValue( "Inherits", out inherits ); if( inherits == null || string.IsNullOrEmpty( inherits.Value ) ) - return node; + return null; MiniYaml parent; allUnits.TryGetValue( inherits.Value, out parent ); if( parent == null ) - return node; + return null; - return MiniYaml.Merge( node, MergeWithParent( parent, allUnits ) ); + return parent; + } + + static MiniYaml MergeWithParent( MiniYaml node, Dictionary allUnits ) + { + var parent = GetParent( node, allUnits ); + if( parent != null ) + return MiniYaml.Merge( node, MergeWithParent( parent, allUnits ) ); + return node; } static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my) diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index d926f488a4..3983385775 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -90,7 +90,7 @@ namespace OpenRa.Game SupportPowerInfo = new InfoLoader( Pair.New>("SupportPower", _ => new SupportPowerInfo())); - var yamlRules = MiniYaml.FromFile("ra.yaml"); + var yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "ra.yaml" ), MiniYaml.FromFile( "defaults.yaml" ) ); if( useAftermath ) yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules ); diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index d403192261..7e1eef92b6 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -62,10 +62,11 @@ namespace OpenRa.Game.GameRules .Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */ } - public IEnumerable UnitBuiltAt( LegacyUnitInfo info ) + public IEnumerable UnitBuiltAt( NewUnitInfo info ) { - if( info.BuiltAt.Length != 0 ) - return info.BuiltAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] ); + var builtAt = info.Traits.Get().BuiltAt; + if( builtAt.Length != 0 ) + return builtAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] ); else return producesIndex[ Rules.UnitCategory[ info.Name ] ]; } diff --git a/RulesConverter/MiniYamlExts.cs b/RulesConverter/MiniYamlExts.cs index 415e024a25..ce7825beea 100755 --- a/RulesConverter/MiniYamlExts.cs +++ b/RulesConverter/MiniYamlExts.cs @@ -13,7 +13,7 @@ namespace RulesConverter { public static void WriteToFile( this MiniYamlNodes y, string filename ) { - File.WriteAllLines( filename, y.ToLines( true ).ToArray() ); + File.WriteAllLines( filename, y.ToLines( true ).Select( x => x.TrimEnd() ).ToArray() ); } public static IEnumerable ToLines( this MiniYamlNodes y, bool lowest ) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index e9cda7e9f1..714deb0797 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -41,7 +41,8 @@ namespace RulesConverter { "Armor", "Armor" }, { "Crewed", "Crewed" }, { "InitialFacing", "InitialFacing" }, - { "Sight", "Sight" } } + { "Sight", "Sight" }, + { "WaterBound", "WaterBound" } } }, { "Selectable", new PL { @@ -205,6 +206,10 @@ namespace RulesConverter } catch { } } + + var yaml = MiniYaml.FromFile( outputFile ); + yaml.OptimizeInherits( MiniYaml.FromFile( "defaults.yaml" ) ); + yaml.WriteToFile( outputFile ); } } } diff --git a/RulesConverter/RulesConverter.csproj b/RulesConverter/RulesConverter.csproj index f23f869d56..4669eb6b9d 100644 --- a/RulesConverter/RulesConverter.csproj +++ b/RulesConverter/RulesConverter.csproj @@ -52,6 +52,7 @@ + diff --git a/aftermath.yaml b/aftermath.yaml index 05fe317ae1..cef2b7f987 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -1,13 +1,10 @@ STNK: Inherits: DefaultVehicle - Selectable: - Voice: VehicleVoice Unit: HP: 200 Armor: heavy Sight: 5 Mobile: - ROT: 5 Speed: 10 Turreted: AttackTurreted: @@ -15,7 +12,6 @@ STNK: Recoil: 2 RenderUnitTurreted: Cloak: - Chronoshiftable: TTNK: Inherits: DefaultVehicle @@ -26,20 +22,16 @@ TTNK: Owner: soviet Cost: 1500 Description: "Tesla Tank" - Selectable: - Voice: VehicleVoice Unit: HP: 110 Armor: light Crewed: yes Sight: 7 Mobile: - ROT: 5 Speed: 8 AttackBase: PrimaryWeapon: TTankZap RenderUnitSpinner: - Chronoshiftable: CTNK: Inherits: DefaultVehicle @@ -50,20 +42,16 @@ CTNK: Owner: allies Cost: 2400 Description: "Chrono Tank" - Selectable: - Voice: VehicleVoice Unit: HP: 350 Armor: light Sight: 5 Mobile: - ROT: 5 Speed: 5 AttackBase: PrimaryWeapon: APTusk RenderUnit: ChronoshiftDeploy: - Chronoshiftable: DTRK: Inherits: DefaultVehicle @@ -74,14 +62,11 @@ DTRK: Owner: allies,soviet Cost: 2400 Description: "Demo Truck" - Selectable: - Voice: VehicleVoice Unit: HP: 110 Armor: light Sight: 3 Mobile: - ROT: 5 Speed: 8 AttackBase: PrimaryWeapon: Democharge @@ -97,18 +82,14 @@ QTNK: Owner: soviet Cost: 2300 Description: "M.A.D. Tank" - Selectable: - Voice: VehicleVoice Unit: HP: 300 Armor: heavy Crewed: no Sight: 6 Mobile: - ROT: 5 Speed: 3 RenderUnit: - Chronoshiftable: MSUB: Inherits: DefaultShip @@ -125,6 +106,7 @@ MSUB: HP: 150 Armor: light Sight: 6 + WaterBound: yes Mobile: ROT: 7 Speed: 5 diff --git a/aftermathUnits.ini b/aftermathUnits.ini index 9e07413c2c..7a9879ecb2 100755 --- a/aftermathUnits.ini +++ b/aftermathUnits.ini @@ -7,28 +7,28 @@ QTNK [STNK] Description=Stealth Tank -Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, Cloak, Chronoshiftable +Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, Cloak, Repairable, Chronoshiftable, Passenger, IronCurtainable Recoil=2 Voice=VehicleVoice [TTNK] Description=Tesla Tank -Traits=Unit, Mobile, AttackBase, RenderUnitSpinner, Chronoshiftable +Traits=Unit, Mobile, AttackBase, RenderUnitSpinner, Repairable, Chronoshiftable, Passenger, IronCurtainable Voice=VehicleVoice [CTNK] Description=Chrono Tank -Traits=Unit, Mobile, AttackBase, RenderUnit, ChronoshiftDeploy, Chronoshiftable +Traits=Unit, Mobile, AttackBase, RenderUnit, ChronoshiftDeploy, Repairable, Chronoshiftable, Passenger, IronCurtainable Voice=VehicleVoice [DTRK] Description=Demo Truck -Traits=Unit, Mobile, AttackBase, RenderUnit, DemoTruck +Traits=Unit, Mobile, AttackBase, RenderUnit, DemoTruck, Repairable, Chronoshiftable, Passenger, IronCurtainable Voice=VehicleVoice [QTNK] Description=M.A.D. Tank -Traits=Unit, Mobile, RenderUnit, Chronoshiftable +Traits=Unit, Mobile, RenderUnit, Repairable, Chronoshiftable, Passenger, IronCurtainable Voice=VehicleVoice @@ -102,4 +102,4 @@ Attack=jburn1,jcrisp1,jshock1,jlight1 [MechVoice] Select=mhowdy1,mhotdig1,mhuh1 Move=mlaff1,mhotdig1,mhear1,mboss1,myeehaw1 -Attack=mwrench1,mrise1,mboss1,myeehaw1 \ No newline at end of file +Attack=mwrench1,mrise1,mboss1,myeehaw1 diff --git a/campaignUnits.ini b/campaignUnits.ini index 15d37bd3f7..13ae1b8008 100755 --- a/campaignUnits.ini +++ b/campaignUnits.ini @@ -238,4 +238,6 @@ SelectionPriority=0 TRUK [TRUK] -Traits=Unit, Mobile, RenderUnit \ No newline at end of file +Traits=Unit, Mobile, RenderUnit, Repairable, Chronoshiftable, Passenger, IronCurtainable +Voice=VehicleVoice + diff --git a/defaults.yaml b/defaults.yaml new file mode 100644 index 0000000000..4f3a4bc637 --- /dev/null +++ b/defaults.yaml @@ -0,0 +1,10 @@ +DefaultVehicle: + Mobile: + ROT: 5 + Selectable: + Voice: VehicleVoice + Repairable: + Chronoshiftable: + Passenger: + IronCurtainable: + diff --git a/ra.yaml b/ra.yaml index 73332b05b2..0baafddc40 100644 --- a/ra.yaml +++ b/ra.yaml @@ -8,24 +8,17 @@ V2RL: Cost: 700 Description: "V2 Rocket" LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 150 Armor: light Crewed: yes Sight: 5 Mobile: - ROT: 5 Speed: 7 AttackBase: PrimaryWeapon: SCUD RenderUnitReload: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: 1TNK: Inherits: DefaultVehicle @@ -37,15 +30,12 @@ V2RL: Cost: 700 Description: "Light Tank" LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 300 Armor: heavy Crewed: yes Sight: 4 Mobile: - ROT: 5 Speed: 9 Turreted: AttackTurreted: @@ -53,10 +43,6 @@ V2RL: Recoil: 2 RenderUnitTurreted: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: 2TNK: Inherits: DefaultVehicle @@ -68,15 +54,12 @@ V2RL: Cost: 800 Description: "Medium Tank" LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 400 Armor: heavy Crewed: yes Sight: 5 Mobile: - ROT: 5 Speed: 8 Turreted: AttackTurreted: @@ -84,10 +67,6 @@ V2RL: Recoil: 3 RenderUnitTurreted: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: 3TNK: Inherits: DefaultVehicle @@ -99,15 +78,12 @@ V2RL: Cost: 950 Description: "Heavy Tank" LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 400 Armor: heavy Crewed: yes Sight: 5 Mobile: - ROT: 5 Speed: 7 Turreted: AttackTurreted: @@ -115,10 +91,6 @@ V2RL: Recoil: 3 RenderUnitTurreted: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: 4TNK: Inherits: DefaultVehicle @@ -130,15 +102,12 @@ V2RL: Cost: 1700 Description: "Mammoth Tank" LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" - Selectable: - Voice: VehicleVoice Unit: HP: 600 Armor: heavy Crewed: yes Sight: 6 Mobile: - ROT: 5 Speed: 4 Turreted: AttackTurreted: @@ -148,10 +117,6 @@ V2RL: Recoil: 4 RenderUnitTurreted: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: MRJ: Inherits: DefaultVehicle @@ -165,21 +130,15 @@ MRJ: LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" Selectable: Priority: 3 - Voice: VehicleVoice Unit: HP: 110 Armor: light Crewed: yes Sight: 7 Mobile: - ROT: 5 Speed: 9 RenderUnitSpinner: Offset: 0,4,0,-6 - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: MGG: Inherits: DefaultVehicle @@ -193,21 +152,15 @@ MGG: LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" Selectable: Priority: 3 - Voice: VehicleVoice Unit: HP: 110 Armor: light Crewed: yes Sight: 4 Mobile: - ROT: 5 Speed: 9 RenderUnitSpinner: Offset: 0,6,0,-3 - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: ARTY: Inherits: DefaultVehicle @@ -219,25 +172,18 @@ ARTY: Cost: 600 Description: "Artillery" LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 75 Armor: light Crewed: yes Sight: 5 Mobile: - ROT: 2 Speed: 6 AttackBase: PrimaryWeapon: 155mm RenderUnit: Explodes: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: HARV: Inherits: DefaultVehicle @@ -251,7 +197,6 @@ HARV: LongDesc: "Collects Ore and Gems for processing.\n Unarmed" Selectable: Priority: 7 - Voice: VehicleVoice Harvester: Unit: HP: 600 @@ -259,13 +204,8 @@ HARV: Crewed: yes Sight: 4 Mobile: - ROT: 5 Speed: 6 RenderUnit: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: MCV: Inherits: DefaultVehicle @@ -279,21 +219,15 @@ MCV: LongDesc: "Deploys into another Construction Yard.\n Unarmed" Selectable: Priority: 3 - Voice: VehicleVoice Unit: HP: 600 Armor: light Crewed: yes Sight: 4 Mobile: - ROT: 5 Speed: 6 McvDeploy: RenderUnit: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: JEEP: Inherits: DefaultVehicle @@ -305,15 +239,12 @@ JEEP: Cost: 600 Description: "Ranger" LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 150 Armor: light Crewed: yes Sight: 6 Mobile: - ROT: 10 Speed: 10 Turreted: AttackTurreted: @@ -322,10 +253,6 @@ JEEP: MuzzleFlash: yes RenderUnitTurreted: AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: APC: Inherits: DefaultVehicle @@ -337,14 +264,11 @@ APC: Cost: 800 Description: "Armored Personnel Carrier" LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice Unit: HP: 200 Armor: heavy Sight: 5 Mobile: - ROT: 5 Speed: 10 AttackBase: PrimaryWeapon: M60mg @@ -352,14 +276,10 @@ APC: MuzzleFlash: yes RenderUnitMuzzleFlash: AutoTarget: - Repairable: - Chronoshiftable: Cargo: PassengerTypes: Foot Passengers: 5 UnloadFacing: 220 - Passenger: - IronCurtainable: MNLY.AP: Inherits: DefaultVehicle @@ -372,26 +292,19 @@ MNLY.AP: Icon: MNLYICON Description: "Minelayer (Anti-Personnel)" LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" - Selectable: - Voice: VehicleVoice Unit: HP: 100 Armor: heavy Crewed: yes Sight: 5 Mobile: - ROT: 5 Speed: 9 RenderUnit: Image: MNLY Minelayer: MineImmune: - Repairable: LimitedAmmo: Ammo: 5 - Chronoshiftable: - Passenger: - IronCurtainable: MNLY.AT: Inherits: DefaultVehicle @@ -404,36 +317,27 @@ MNLY.AT: Icon: MNLYICON Description: "Minelayer (Anti-Tank)" LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" - Selectable: - Voice: VehicleVoice Unit: HP: 100 Armor: heavy Crewed: yes Sight: 5 Mobile: - ROT: 5 Speed: 9 RenderUnit: Image: MNLY Minelayer: MineImmune: - Repairable: LimitedAmmo: Ammo: 5 - Chronoshiftable: - Passenger: - IronCurtainable: TRUK: Inherits: DefaultVehicle - Selectable: Unit: HP: 110 Armor: light Sight: 3 Mobile: - ROT: 5 Speed: 10 RenderUnit: @@ -453,6 +357,7 @@ SS: HP: 120 Armor: light Sight: 6 + WaterBound: yes Mobile: ROT: 7 Speed: 6 @@ -480,6 +385,7 @@ DD: HP: 400 Armor: heavy Sight: 6 + WaterBound: yes Mobile: ROT: 7 Speed: 6 @@ -508,6 +414,7 @@ CA: HP: 700 Armor: heavy Sight: 7 + WaterBound: yes Mobile: ROT: 5 Speed: 4 @@ -536,6 +443,7 @@ LST: HP: 350 Armor: heavy Sight: 6 + WaterBound: yes Mobile: ROT: 10 Speed: 14 @@ -561,6 +469,7 @@ PT: HP: 200 Armor: heavy Sight: 7 + WaterBound: yes Mobile: ROT: 7 Speed: 9 From 52470393456b4b6e5c1a16910c89e7ab04ca6318 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 19:53:20 +1300 Subject: [PATCH 59/83] de-legacied Minelayer --- OpenRa.Game/Traits/Minelayer.cs | 12 ++++++++++-- OpenRa.Game/Traits/Mobile.cs | 2 +- OpenRa.Game/UnitInfluenceMap.cs | 2 +- RulesConverter/Program.cs | 4 ++++ ra.yaml | 2 ++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index 0f5c5194f6..0e6092f922 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -2,7 +2,15 @@ namespace OpenRa.Game.Traits { - class MinelayerInfo : StatelessTraitInfo { } + class MinelayerInfo : ITraitInfo + { + public readonly string Mine = "minv"; + + public object Create( Actor self ) + { + return new Minelayer(); + } + } class Minelayer : IIssueOrder, IResolveOrder { @@ -33,7 +41,7 @@ namespace OpenRa.Game.Traits // todo: delay a bit? (req making deploy-mine an activity) Game.world.AddFrameEndTask( - w => w.Add(new Actor(self.LegacyInfo.Primary, self.Location, self.Owner))); + w => w.Add(new Actor(self.Info.Traits.Get().Mine, self.Location, self.Owner))); } } } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 041ac270f4..bd2cf0e35f 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -86,7 +86,7 @@ namespace OpenRa.Game.Traits public UnitMovementType GetMovementType() { - switch (Rules.UnitCategory[self.LegacyInfo.Name]) + switch (Rules.UnitCategory[self.Info.Name]) { case "Infantry": return UnitMovementType.Foot; diff --git a/OpenRa.Game/UnitInfluenceMap.cs b/OpenRa.Game/UnitInfluenceMap.cs index 4d93aa7e3c..c796f52e0a 100644 --- a/OpenRa.Game/UnitInfluenceMap.cs +++ b/OpenRa.Game/UnitInfluenceMap.cs @@ -36,7 +36,7 @@ namespace OpenRa.Game var crusher = GetUnitsAt(cell).Where(b => a != b && Game.IsActorCrushableByActor(a, b)).FirstOrDefault(); if (crusher != null) { - Log.Write("{0} crushes {1}", crusher.LegacyInfo.Name, a.LegacyInfo.Name); + Log.Write("{0} crushes {1}", crusher.Info.Name, a.Info.Name); // Apply the crush action foreach (var crush in a.traits.WithInterface()) crush.OnCrush(crusher); diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 714deb0797..b31943f87b 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -149,6 +149,10 @@ namespace RulesConverter { "SpawnOffset", "SpawnOffset" }, { "Produces", "Produces" } } }, + + { "Minelayer", new PL { + { "Mine", "Primary" } } + }, }; traitMap["RenderUnit"] = traitMap["RenderBuilding"]; diff --git a/ra.yaml b/ra.yaml index 0baafddc40..550acc3110 100644 --- a/ra.yaml +++ b/ra.yaml @@ -302,6 +302,7 @@ MNLY.AP: RenderUnit: Image: MNLY Minelayer: + Mine: MINP MineImmune: LimitedAmmo: Ammo: 5 @@ -327,6 +328,7 @@ MNLY.AT: RenderUnit: Image: MNLY Minelayer: + Mine: MINV MineImmune: LimitedAmmo: Ammo: 5 From 4f082bbae38fe005b30a87b0204c8f01eda9dd5c Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 19:56:14 +1300 Subject: [PATCH 60/83] game --- OpenRa.Game/Game.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 4ee33460d3..702f24fab4 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -309,8 +309,8 @@ namespace OpenRa.Game public static IEnumerable SelectActorsInBox(float2 a, float2 b) { return FindUnits(a, b) - .Where( x => x.LegacyInfo.Selectable ) - .GroupBy(x => (x.Owner == LocalPlayer) ? x.LegacyInfo.SelectionPriority : 0) + .Where( x => x.traits.Contains() ) + .GroupBy(x => (x.Owner == LocalPlayer) ? x.Info.Traits.Get().Priority : 0) .OrderByDescending(g => g.Key) .Select( g => g.AsEnumerable() ) .DefaultIfEmpty( new Actor[] {} ) From 3b6ccd7f88f7713d7de6866f44ee982a13d17f5d Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 19:59:55 +1300 Subject: [PATCH 61/83] more --- OpenRa.Game/Game.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 702f24fab4..6de64ed586 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -61,7 +61,7 @@ namespace OpenRa.Game world = new World(); Game.world.ActorAdded += a => { - if (a.Owner != null && a.LegacyInfo != null) + if (a.Owner != null && a.Info.Traits.Contains()) a.Owner.Shroud.Explore(a); }; From 4fc89979723785bab498683468a0d21d0c36ded4 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 20:01:30 +1300 Subject: [PATCH 62/83] oops. --- OpenRa.Game/Game.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 6de64ed586..0fa9eaf020 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -61,7 +61,7 @@ namespace OpenRa.Game world = new World(); Game.world.ActorAdded += a => { - if (a.Owner != null && a.Info.Traits.Contains()) + if (a.Owner != null && a.Info != null && a.Info.Traits.Contains()) a.Owner.Shroud.Explore(a); }; From d5d6812e0789fe1cc548d39412b673b987d23f4e Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 20:06:49 +1300 Subject: [PATCH 63/83] fixed Recoil. --- OpenRa.Game/Traits/Util.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 246a19721b..bde7f77c59 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -82,14 +82,14 @@ namespace OpenRa.Game.Traits static float2 GetRecoil(Actor self, float recoil) { - if (self.LegacyInfo.Recoil == 0) return float2.Zero; + if (self.Info.Traits.Get().Recoil == 0) return float2.Zero; var rut = self.traits.GetOrDefault(); if (rut == null) return float2.Zero; var facing = self.traits.Get().turretFacing; var quantizedFacing = QuantizeFacing(facing, rut.anim.CurrentSequence.Length) * (256 / rut.anim.CurrentSequence.Length); - return RotateVectorByFacing(new float2(0, recoil * self.LegacyInfo.Recoil), quantizedFacing, .7f); + return RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get().Recoil), quantizedFacing, .7f); } public static float2 CenterOfCell(int2 loc) From 4a004eda0f1516e3f6532a5cee3bb87828cc8419 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 20:18:36 +1300 Subject: [PATCH 64/83] fixed Building.unitInfo --- OpenRa.Game/BuildingInfluenceMap.cs | 14 +++++++------- OpenRa.Game/Game.cs | 8 ++++---- OpenRa.Game/GameRules/Footprint.cs | 19 ++++++++++--------- .../Orders/PlaceBuildingOrderGenerator.cs | 18 ++++++++++-------- OpenRa.Game/Orders/UnitOrderGenerator.cs | 4 ++-- OpenRa.Game/Orders/UnitOrders.cs | 2 +- OpenRa.Game/Traits/Building.cs | 2 -- OpenRa.Game/Traits/McvDeploy.cs | 4 ++-- OpenRa.Game/UiOverlay.cs | 7 ++++--- 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/OpenRa.Game/BuildingInfluenceMap.cs b/OpenRa.Game/BuildingInfluenceMap.cs index 636a75bdd9..4d8f7bfb54 100644 --- a/OpenRa.Game/BuildingInfluenceMap.cs +++ b/OpenRa.Game/BuildingInfluenceMap.cs @@ -18,15 +18,15 @@ namespace OpenRa.Game ChangeInfluence(a, a.traits.Get(), false); }; } - void ChangeInfluence(Actor a, Building building, bool isAdd) + void ChangeInfluence( Actor a, Building building, bool isAdd ) { - foreach (var u in Footprint.UnpathableTiles(building.unitInfo, a.Location)) - if (IsValid(u)) - blocked[u.X, u.Y] = isAdd; + foreach( var u in Footprint.UnpathableTiles( a.Info.Name, a.Info.Traits.Get(), a.Location ) ) + if( IsValid( u ) ) + blocked[ u.X, u.Y ] = isAdd; - foreach (var u in Footprint.Tiles(building.unitInfo, a.Location, false)) - if (IsValid(u)) - influence[u.X, u.Y] = isAdd ? a : null; + foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location, false ) ) + if( IsValid( u ) ) + influence[ u.X, u.Y ] = isAdd ? a : null; } bool IsValid(int2 t) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 0fa9eaf020..3f052a1f1a 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -320,15 +320,15 @@ namespace OpenRa.Game public static Random SharedRandom = new Random(0); /* for things that require sync */ public static Random CosmeticRandom = new Random(); /* for things that are just fluff */ - public static bool CanPlaceBuilding(LegacyBuildingInfo building, int2 xy, Actor toIgnore, bool adjust) + public static bool CanPlaceBuilding(string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) { - return !Footprint.Tiles(building, xy, adjust).Any( + return !Footprint.Tiles(name, building, xy, adjust).Any( t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t, building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, toIgnore)); } - public static bool IsCloseEnoughToBase(Player p, LegacyBuildingInfo bi, int2 position) + public static bool IsCloseEnoughToBase(Player p, string buildingName, BuildingInfo bi, int2 position) { var maxDistance = bi.Adjacent + 1; @@ -346,7 +346,7 @@ namespace OpenRa.Game ignoreTerrain = true, }; - foreach (var t in Footprint.Tiles(bi, position)) search.AddInitialCell(t); + foreach (var t in Footprint.Tiles(buildingName, bi, position)) search.AddInitialCell(t); return Game.PathFinder.FindPath(search).Count != 0; } diff --git a/OpenRa.Game/GameRules/Footprint.cs b/OpenRa.Game/GameRules/Footprint.cs index 3d740fd1d2..63d1306ab8 100644 --- a/OpenRa.Game/GameRules/Footprint.cs +++ b/OpenRa.Game/GameRules/Footprint.cs @@ -1,17 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenRa.Game.Traits; namespace OpenRa.Game.GameRules { static class Footprint { - public static IEnumerable Tiles( LegacyBuildingInfo buildingInfo, int2 position ) + public static IEnumerable Tiles( string name, BuildingInfo buildingInfo, int2 position ) { - return Tiles(buildingInfo, position, true); + return Tiles(name, buildingInfo, position, true); } - public static IEnumerable Tiles( LegacyBuildingInfo buildingInfo, int2 position, bool adjustForPlacement ) + public static IEnumerable Tiles( string name, BuildingInfo buildingInfo, int2 position, bool adjustForPlacement ) { var dim = buildingInfo.Dimensions; @@ -24,19 +25,19 @@ namespace OpenRa.Game.GameRules var adjustment = adjustForPlacement ? AdjustForBuildingSize(buildingInfo) : int2.Zero; - var tiles = TilesWhere(buildingInfo.Name, dim, footprint.ToArray(), a => a != '_'); + var tiles = TilesWhere(name, dim, footprint.ToArray(), a => a != '_'); return tiles.Select(t => t + position - adjustment); } public static IEnumerable Tiles(Actor a, Traits.Building building) { - return Tiles( building.unitInfo, a.Location, false ); + return Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location, false ); } - public static IEnumerable UnpathableTiles( LegacyBuildingInfo buildingInfo, int2 position ) + public static IEnumerable UnpathableTiles( string name, BuildingInfo buildingInfo, int2 position ) { var footprint = buildingInfo.Footprint.Where( x => !char.IsWhiteSpace( x ) ).ToArray(); - foreach( var tile in TilesWhere( buildingInfo.Name, buildingInfo.Dimensions, footprint, a => a == 'x' ) ) + foreach( var tile in TilesWhere( name, buildingInfo.Dimensions, footprint, a => a == 'x' ) ) yield return tile + position; } @@ -52,9 +53,9 @@ namespace OpenRa.Game.GameRules yield return new int2( x, y ); } - public static int2 AdjustForBuildingSize( LegacyBuildingInfo unitInfo ) + public static int2 AdjustForBuildingSize( BuildingInfo buildingInfo ) { - var dim = unitInfo.Dimensions; + var dim = buildingInfo.Dimensions; return new int2( dim.X / 2, dim.Y > 1 ? ( dim.Y + 1 ) / 2 : 0 ); } } diff --git a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs index 193f5872d0..1377bbc5ec 100644 --- a/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRa.Game/Orders/PlaceBuildingOrderGenerator.cs @@ -1,17 +1,19 @@ using System.Collections.Generic; using OpenRa.Game.GameRules; +using OpenRa.Game.Traits; namespace OpenRa.Game.Orders { class PlaceBuildingOrderGenerator : IOrderGenerator { readonly Actor Producer; - readonly LegacyBuildingInfo Building; + readonly string Building; + BuildingInfo BuildingInfo { get { return Rules.NewUnitInfo[ Building ].Traits.Get(); } } public PlaceBuildingOrderGenerator(Actor producer, string name) { Producer = producer; - Building = (LegacyBuildingInfo)Rules.UnitInfo[ name ]; + Building = name; } public IEnumerable Order(int2 xy, MouseInput mi) @@ -26,27 +28,27 @@ namespace OpenRa.Game.Orders { if (mi.Button == MouseButton.Left) { - if (!Game.CanPlaceBuilding(Building, xy, null, true) - || !Game.IsCloseEnoughToBase(Producer.Owner, Building, xy)) + if (!Game.CanPlaceBuilding( Building, BuildingInfo, xy, null, true) + || !Game.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, xy)) { Sound.Play("nodeply1.aud"); yield break; } - yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, null, xy, Building.Name); + yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, null, xy, Building); } } public void Tick() { - var producing = Producer.traits.Get().CurrentItem( Rules.UnitCategory[ Building.Name ] ); - if (producing == null || producing.Item != Building.Name || producing.RemainingTime != 0) + var producing = Producer.traits.Get().CurrentItem( Rules.UnitCategory[ Building ] ); + if (producing == null || producing.Item != Building || producing.RemainingTime != 0) Game.controller.CancelInputMode(); } public void Render() { - Game.worldRenderer.uiOverlay.DrawBuildingGrid( Building ); + Game.worldRenderer.uiOverlay.DrawBuildingGrid( Building, BuildingInfo ); } public Cursor GetCursor(int2 xy, MouseInput mi) diff --git a/OpenRa.Game/Orders/UnitOrderGenerator.cs b/OpenRa.Game/Orders/UnitOrderGenerator.cs index a3455ae861..a7800482f7 100644 --- a/OpenRa.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRa.Game/Orders/UnitOrderGenerator.cs @@ -69,8 +69,8 @@ namespace OpenRa.Game.Orders else return Cursor.MoveBlocked; case "DeployMcv": - var factBuildingInfo = (LegacyBuildingInfo)Rules.UnitInfo["fact"]; - if (Game.CanPlaceBuilding(factBuildingInfo, a.Location - new int2(1, 1), a, false)) + var factBuildingInfo = Rules.NewUnitInfo["fact"].Traits.Get(); + if (Game.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a, false)) return Cursor.Deploy; else return Cursor.DeployBlocked; diff --git a/OpenRa.Game/Orders/UnitOrders.cs b/OpenRa.Game/Orders/UnitOrders.cs index 327f1e3a05..177a48386b 100644 --- a/OpenRa.Game/Orders/UnitOrders.cs +++ b/OpenRa.Game/Orders/UnitOrders.cs @@ -20,7 +20,7 @@ namespace OpenRa.Game.Orders if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 ) return; - Game.world.Add( new Actor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( (LegacyBuildingInfo)Rules.UnitInfo[ order.TargetString ] ), order.Player ) ); + Game.world.Add( new Actor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( Rules.NewUnitInfo[ order.TargetString ].Traits.Get() ), order.Player ) ); if (order.Player == Game.LocalPlayer) { Sound.Play("placbldg.aud"); diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index b4816bb971..f80deff35e 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -39,7 +39,6 @@ namespace OpenRa.Game.Traits class Building : INotifyDamage, IResolveOrder, ITick { readonly Actor self; - [Obsolete] public readonly LegacyBuildingInfo unitInfo; public readonly BuildingInfo Info; [Sync] bool isRepairing = false; @@ -53,7 +52,6 @@ namespace OpenRa.Game.Traits { this.self = self; Info = self.Info.Traits.Get(); - unitInfo = (LegacyBuildingInfo)self.LegacyInfo; self.CenterLocation = Game.CellSize * ((float2)self.Location + .5f * (float2)Info.Dimensions); } diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index 20221549a3..ac6c0ce924 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -24,8 +24,8 @@ namespace OpenRa.Game.Traits { if( order.OrderString == "DeployMcv" ) { - var factBuildingInfo = (LegacyBuildingInfo)Rules.UnitInfo[ "fact" ]; - if( Game.CanPlaceBuilding( factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) ) + var factBuildingInfo = Rules.NewUnitInfo[ "fact" ].Traits.Get(); + if( Game.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) ) { self.CancelActivity(); self.QueueActivity( new Turn( 96 ) ); diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index 7a0e4c8c29..4c60fd59d3 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -2,6 +2,7 @@ using System.Drawing; using System.Linq; using OpenRa.Game.GameRules; using OpenRa.Game.Graphics; +using OpenRa.Game.Traits; namespace OpenRa.Game { @@ -42,12 +43,12 @@ namespace OpenRa.Game spriteRenderer.DrawSprite(unitDebug, Game.CellSize * new float2(i, j), 0); } - public void DrawBuildingGrid( LegacyBuildingInfo bi ) + public void DrawBuildingGrid( string name, BuildingInfo bi ) { var position = Game.controller.MousePosition.ToInt2(); - var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, bi, position); + var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, name, bi, position); - foreach( var t in Footprint.Tiles( bi, position ) ) + foreach( var t in Footprint.Tiles( name, bi, position ) ) spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel ) && !Rules.Map.ContainsResource( t ) ) ? buildOk : buildBlocked, Game.CellSize * t, 0 ); From 607f11b7febc4093d2569b1c8582f3938f248245 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 20:21:22 +1300 Subject: [PATCH 65/83] fixed Speed. --- OpenRa.Game/Traits/Util.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index bde7f77c59..9c42055e3d 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -127,14 +127,13 @@ namespace OpenRa.Game.Traits public static float GetEffectiveSpeed(Actor self) { - var mi = self.LegacyInfo as LegacyMobileInfo; - if (mi == null) return 0f; + if (!self.Info.Traits.Contains()) return 0f; var modifier = self.traits .WithInterface() .Select(t => t.GetSpeedModifier()) .Product(); - return mi.Speed * modifier; + return self.Info.Traits.Get().Speed * modifier; } public static IActivity SequenceActivities(params IActivity[] acts) From 06969138aa84a52cb874297507a99c3e409fb702 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 21:05:26 +1300 Subject: [PATCH 66/83] reverted prev. (it broken helis/planes) --- OpenRa.Game/Traits/Util.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index 9c42055e3d..bde7f77c59 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -127,13 +127,14 @@ namespace OpenRa.Game.Traits public static float GetEffectiveSpeed(Actor self) { - if (!self.Info.Traits.Contains()) return 0f; + var mi = self.LegacyInfo as LegacyMobileInfo; + if (mi == null) return 0f; var modifier = self.traits .WithInterface() .Select(t => t.GetSpeedModifier()) .Product(); - return self.Info.Traits.Get().Speed * modifier; + return mi.Speed * modifier; } public static IActivity SequenceActivities(params IActivity[] acts) From 901d48edfae84892b1ce8acee4eede8623dc2d26 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 21:11:38 +1300 Subject: [PATCH 67/83] Moved ROT from Mobile/Heli/Plane to Unit. --- OpenRa.Game/Traits/Activities/Fly.cs | 2 +- OpenRa.Game/Traits/Activities/HeliAttack.cs | 2 +- OpenRa.Game/Traits/Activities/HeliFly.cs | 2 +- OpenRa.Game/Traits/Activities/Land.cs | 2 +- OpenRa.Game/Traits/Activities/ReturnToBase.cs | 2 +- OpenRa.Game/Traits/Activities/Turn.cs | 2 +- OpenRa.Game/Traits/Helicopter.cs | 1 - OpenRa.Game/Traits/Plane.cs | 1 - OpenRa.Game/Traits/Unit.cs | 4 +++- RulesConverter/Program.cs | 4 +--- aftermath.yaml | 2 +- defaults.yaml | 3 ++- ra.yaml | 20 +++++++++---------- session.ini | 7 ++++++- 14 files changed, 29 insertions(+), 25 deletions(-) diff --git a/OpenRa.Game/Traits/Activities/Fly.cs b/OpenRa.Game/Traits/Activities/Fly.cs index b9b820d8c0..7c6a497a17 100644 --- a/OpenRa.Game/Traits/Activities/Fly.cs +++ b/OpenRa.Game/Traits/Activities/Fly.cs @@ -31,7 +31,7 @@ namespace OpenRa.Game.Traits.Activities var desiredFacing = Util.GetFacing(d, unit.Facing); if (unit.Altitude == CruiseAltitude) - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); var speed = .2f * Util.GetEffectiveSpeed(self); var angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/HeliAttack.cs b/OpenRa.Game/Traits/Activities/HeliAttack.cs index 71b27ab22f..3bfd902388 100644 --- a/OpenRa.Game/Traits/Activities/HeliAttack.cs +++ b/OpenRa.Game/Traits/Activities/HeliAttack.cs @@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits.Activities var dist = target.CenterLocation - self.CenterLocation; var desiredFacing = Util.GetFacing(dist, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize)) { diff --git a/OpenRa.Game/Traits/Activities/HeliFly.cs b/OpenRa.Game/Traits/Activities/HeliFly.cs index 9699a01853..32ba04e293 100644 --- a/OpenRa.Game/Traits/Activities/HeliFly.cs +++ b/OpenRa.Game/Traits/Activities/HeliFly.cs @@ -40,7 +40,7 @@ namespace OpenRa.Game.Traits.Activities var desiredFacing = Util.GetFacing(dist, unit.Facing); Util.TickFacing(ref unit.Facing, desiredFacing, - self.Info.Traits.Get().ROT); + self.Info.Traits.Get().ROT); var rawSpeed = .2f * Util.GetEffectiveSpeed(self); self.CenterLocation += (rawSpeed / dist.Length) * dist; diff --git a/OpenRa.Game/Traits/Activities/Land.cs b/OpenRa.Game/Traits/Activities/Land.cs index 2164f2bfd2..e6f6145c7e 100644 --- a/OpenRa.Game/Traits/Activities/Land.cs +++ b/OpenRa.Game/Traits/Activities/Land.cs @@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits.Activities --unit.Altitude; var desiredFacing = Util.GetFacing(d, unit.Facing); - Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); + Util.TickFacing(ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT); var speed = .2f * Util.GetEffectiveSpeed(self); var angle = unit.Facing / 128f * Math.PI; diff --git a/OpenRa.Game/Traits/Activities/ReturnToBase.cs b/OpenRa.Game/Traits/Activities/ReturnToBase.cs index aed998b9be..51cac44f92 100644 --- a/OpenRa.Game/Traits/Activities/ReturnToBase.cs +++ b/OpenRa.Game/Traits/Activities/ReturnToBase.cs @@ -41,7 +41,7 @@ namespace OpenRa.Game.Traits.Activities var unit = self.traits.Get(); var speed = .2f * Util.GetEffectiveSpeed(self); var approachStart = landPos - new float2(unit.Altitude * speed, 0); - var turnRadius = (128f / self.Info.Traits.Get().ROT) * speed / (float)Math.PI; + var turnRadius = (128f / self.Info.Traits.Get().ROT) * speed / (float)Math.PI; /* work out the center points */ var fwd = -float2.FromAngle(unit.Facing / 128f * (float)Math.PI); diff --git a/OpenRa.Game/Traits/Activities/Turn.cs b/OpenRa.Game/Traits/Activities/Turn.cs index 2f29a1bab5..a992a2aedd 100755 --- a/OpenRa.Game/Traits/Activities/Turn.cs +++ b/OpenRa.Game/Traits/Activities/Turn.cs @@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits.Activities if( desiredFacing == unit.Facing ) return NextActivity; - Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT ); + Util.TickFacing( ref unit.Facing, desiredFacing, self.Info.Traits.Get().ROT ); return this; } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 58e570fe2f..8084b9dc0e 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -7,7 +7,6 @@ namespace OpenRa.Game.Traits { class HelicopterInfo : ITraitInfo { - public readonly int ROT = 0; public readonly int Speed = 0; public object Create(Actor self) { return new Helicopter(self); } diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index fefa10a17c..235ea7c151 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -5,7 +5,6 @@ namespace OpenRa.Game.Traits { class PlaneInfo : ITraitInfo { - public readonly int ROT = 0; public readonly int Speed = 0; public object Create(Actor self) { return new Plane(self); } diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index 9b44ae78b2..015de81265 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -4,7 +4,9 @@ namespace OpenRa.Game.Traits { class UnitInfo : OwnedActorInfo, ITraitInfo { - public object Create(Actor self) { return new Unit(self); } + public readonly int ROT = 0; + + public object Create( Actor self ) { return new Unit( self ); } } class Unit : INotifyDamage diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index b31943f87b..7181f5fe98 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -41,6 +41,7 @@ namespace RulesConverter { "Armor", "Armor" }, { "Crewed", "Crewed" }, { "InitialFacing", "InitialFacing" }, + { "ROT", "ROT" }, { "Sight", "Sight" }, { "WaterBound", "WaterBound" } } }, @@ -52,18 +53,15 @@ namespace RulesConverter }, { "Mobile", new PL { - { "ROT", "ROT" }, { "Speed", "Speed" } } //{ "MovementType", ... }, }, { "Plane", new PL { - { "ROT", "ROT" }, { "Speed", "Speed" } } }, { "Helicopter", new PL { - { "ROT", "ROT" }, { "Speed", "Speed" } } }, diff --git a/aftermath.yaml b/aftermath.yaml index cef2b7f987..43c5095b8d 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -105,10 +105,10 @@ MSUB: Unit: HP: 150 Armor: light + ROT: 7 Sight: 6 WaterBound: yes Mobile: - ROT: 7 Speed: 5 AttackBase: PrimaryWeapon: SubSCUD diff --git a/defaults.yaml b/defaults.yaml index 4f3a4bc637..6d2a18160b 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -1,6 +1,7 @@ DefaultVehicle: - Mobile: + Unit: ROT: 5 + Mobile: Selectable: Voice: VehicleVoice Repairable: diff --git a/ra.yaml b/ra.yaml index 550acc3110..a586d3a4aa 100644 --- a/ra.yaml +++ b/ra.yaml @@ -358,10 +358,10 @@ SS: Unit: HP: 120 Armor: light + ROT: 7 Sight: 6 WaterBound: yes Mobile: - ROT: 7 Speed: 6 RenderUnit: Submarine: @@ -386,10 +386,10 @@ DD: Unit: HP: 400 Armor: heavy + ROT: 7 Sight: 6 WaterBound: yes Mobile: - ROT: 7 Speed: 6 Turreted: AttackTurreted: @@ -415,10 +415,10 @@ CA: Unit: HP: 700 Armor: heavy + ROT: 5 Sight: 7 WaterBound: yes Mobile: - ROT: 5 Speed: 4 Turreted: AttackTurreted: @@ -444,10 +444,10 @@ LST: Unit: HP: 350 Armor: heavy + ROT: 10 Sight: 6 WaterBound: yes Mobile: - ROT: 10 Speed: 14 RenderUnit: Cargo: @@ -470,10 +470,10 @@ PT: Unit: HP: 200 Armor: heavy + ROT: 7 Sight: 7 WaterBound: yes Mobile: - ROT: 7 Speed: 9 Turreted: AttackTurreted: @@ -500,11 +500,11 @@ MIG: HP: 50 Armor: light InitialFacing: 192 + ROT: 5 Sight: 0 AttackPlane: PrimaryWeapon: Maverick Plane: - ROT: 5 Speed: 20 RenderUnit: WithShadow: @@ -529,11 +529,11 @@ YAK: Armor: light Crewed: yes InitialFacing: 192 + ROT: 5 Sight: 0 AttackPlane: PrimaryWeapon: ChainGun Plane: - ROT: 5 Speed: 16 RenderUnit: WithShadow: @@ -557,9 +557,9 @@ TRAN: HP: 90 Armor: light InitialFacing: 20 + ROT: 5 Sight: 0 Helicopter: - ROT: 5 Speed: 12 RenderUnitRotor: PrimaryOffset: 0,14,0,-4 @@ -587,13 +587,13 @@ HELI: Armor: heavy Crewed: yes InitialFacing: 20 + ROT: 4 Sight: 0 AttackHeli: PrimaryWeapon: Hellfire PrimaryOffset: -5,0,0,2 SecondaryOffset: 5,0,0,2 Helicopter: - ROT: 4 Speed: 16 RenderUnitRotor: PrimaryOffset: 0,0,0,-2 @@ -619,13 +619,13 @@ HIND: Armor: heavy Crewed: yes InitialFacing: 20 + ROT: 4 Sight: 0 AttackHeli: PrimaryWeapon: ChainGun PrimaryOffset: -5,0,0,2 SecondaryOffset: 5,0,0,2 Helicopter: - ROT: 4 Speed: 12 RenderUnitRotor: WithShadow: diff --git a/session.ini b/session.ini index d63ac62a10..8df61230ca 100644 --- a/session.ini +++ b/session.ini @@ -10,4 +10,9 @@ s2=Multi1,mcv,600,12505,0,Guard,None ;s2=Multi1,e3,600,12505,0,Guard,None s3=Multi3,mcv,600,2910,0,Guard,None ;s4=Multi1,ctnk,600,12506,Gaurd,None -s5=Multi1,apc,600,12510,Gaurd,None \ No newline at end of file +s5=Multi1,apc,600,12510,Gaurd,None + + + +s6=Multi0,heli,600,2842,0,Guard,None + From a0bf4f1e0f8a5fc25fc1ec3a987d98d44bad768e Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 21:22:28 +1300 Subject: [PATCH 68/83] Moved speed from Mobile/Heli/Plane to Unit. --- OpenRa.Game/Traits/Helicopter.cs | 2 -- OpenRa.Game/Traits/Mobile.cs | 3 -- OpenRa.Game/Traits/Plane.cs | 2 -- OpenRa.Game/Traits/Unit.cs | 1 + RulesConverter/Program.cs | 11 ++----- aftermath.yaml | 11 ++----- ra.yaml | 55 ++++++++++++-------------------- 7 files changed, 26 insertions(+), 59 deletions(-) diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 8084b9dc0e..6a49fd8aa3 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -7,8 +7,6 @@ namespace OpenRa.Game.Traits { class HelicopterInfo : ITraitInfo { - public readonly int Speed = 0; - public object Create(Actor self) { return new Helicopter(self); } } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index bd2cf0e35f..502521d23a 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -7,9 +7,6 @@ namespace OpenRa.Game.Traits { class MobileInfo : ITraitInfo { - public readonly int ROT = 0; - public readonly int Speed = 0; - public object Create(Actor self) { return new Mobile(self); } } diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 235ea7c151..613bf1863d 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -5,8 +5,6 @@ namespace OpenRa.Game.Traits { class PlaneInfo : ITraitInfo { - public readonly int Speed = 0; - public object Create(Actor self) { return new Plane(self); } } diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index 015de81265..6d07eee4f2 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -5,6 +5,7 @@ namespace OpenRa.Game.Traits class UnitInfo : OwnedActorInfo, ITraitInfo { public readonly int ROT = 0; + public readonly int Speed = 0; public object Create( Actor self ) { return new Unit( self ); } } diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 7181f5fe98..06ce571c06 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -43,6 +43,7 @@ namespace RulesConverter { "InitialFacing", "InitialFacing" }, { "ROT", "ROT" }, { "Sight", "Sight" }, + { "Speed", "Speed" }, { "WaterBound", "WaterBound" } } }, @@ -53,16 +54,8 @@ namespace RulesConverter }, { "Mobile", new PL { - { "Speed", "Speed" } } //{ "MovementType", ... }, - }, - - { "Plane", new PL { - { "Speed", "Speed" } } - }, - - { "Helicopter", new PL { - { "Speed", "Speed" } } + } }, { "RenderBuilding", new PL { diff --git a/aftermath.yaml b/aftermath.yaml index 43c5095b8d..5dcadf08ef 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -4,7 +4,6 @@ STNK: HP: 200 Armor: heavy Sight: 5 - Mobile: Speed: 10 Turreted: AttackTurreted: @@ -27,7 +26,6 @@ TTNK: Armor: light Crewed: yes Sight: 7 - Mobile: Speed: 8 AttackBase: PrimaryWeapon: TTankZap @@ -46,7 +44,6 @@ CTNK: HP: 350 Armor: light Sight: 5 - Mobile: Speed: 5 AttackBase: PrimaryWeapon: APTusk @@ -66,7 +63,6 @@ DTRK: HP: 110 Armor: light Sight: 3 - Mobile: Speed: 8 AttackBase: PrimaryWeapon: Democharge @@ -87,7 +83,6 @@ QTNK: Armor: heavy Crewed: no Sight: 6 - Mobile: Speed: 3 RenderUnit: @@ -107,9 +102,9 @@ MSUB: Armor: light ROT: 7 Sight: 6 + Speed: 5 WaterBound: yes Mobile: - Speed: 5 AttackBase: PrimaryWeapon: SubSCUD FireDelay: 2 @@ -132,8 +127,8 @@ SHOK: HP: 80 Armor: none Sight: 4 - Mobile: Speed: 3 + Mobile: AttackBase: PrimaryWeapon: PortaTesla RenderInfantry: @@ -157,8 +152,8 @@ MECH: HP: 60 Armor: none Sight: 3 - Mobile: Speed: 4 + Mobile: RenderInfantry: AutoHeal: AttackBase: diff --git a/ra.yaml b/ra.yaml index a586d3a4aa..4acd1b9cbd 100644 --- a/ra.yaml +++ b/ra.yaml @@ -13,7 +13,6 @@ V2RL: Armor: light Crewed: yes Sight: 5 - Mobile: Speed: 7 AttackBase: PrimaryWeapon: SCUD @@ -35,7 +34,6 @@ V2RL: Armor: heavy Crewed: yes Sight: 4 - Mobile: Speed: 9 Turreted: AttackTurreted: @@ -59,7 +57,6 @@ V2RL: Armor: heavy Crewed: yes Sight: 5 - Mobile: Speed: 8 Turreted: AttackTurreted: @@ -83,7 +80,6 @@ V2RL: Armor: heavy Crewed: yes Sight: 5 - Mobile: Speed: 7 Turreted: AttackTurreted: @@ -107,7 +103,6 @@ V2RL: Armor: heavy Crewed: yes Sight: 6 - Mobile: Speed: 4 Turreted: AttackTurreted: @@ -135,7 +130,6 @@ MRJ: Armor: light Crewed: yes Sight: 7 - Mobile: Speed: 9 RenderUnitSpinner: Offset: 0,4,0,-6 @@ -157,7 +151,6 @@ MGG: Armor: light Crewed: yes Sight: 4 - Mobile: Speed: 9 RenderUnitSpinner: Offset: 0,6,0,-3 @@ -177,7 +170,6 @@ ARTY: Armor: light Crewed: yes Sight: 5 - Mobile: Speed: 6 AttackBase: PrimaryWeapon: 155mm @@ -203,7 +195,6 @@ HARV: Armor: heavy Crewed: yes Sight: 4 - Mobile: Speed: 6 RenderUnit: @@ -224,7 +215,6 @@ MCV: Armor: light Crewed: yes Sight: 4 - Mobile: Speed: 6 McvDeploy: RenderUnit: @@ -244,7 +234,6 @@ JEEP: Armor: light Crewed: yes Sight: 6 - Mobile: Speed: 10 Turreted: AttackTurreted: @@ -268,7 +257,6 @@ APC: HP: 200 Armor: heavy Sight: 5 - Mobile: Speed: 10 AttackBase: PrimaryWeapon: M60mg @@ -297,7 +285,6 @@ MNLY.AP: Armor: heavy Crewed: yes Sight: 5 - Mobile: Speed: 9 RenderUnit: Image: MNLY @@ -323,7 +310,6 @@ MNLY.AT: Armor: heavy Crewed: yes Sight: 5 - Mobile: Speed: 9 RenderUnit: Image: MNLY @@ -339,7 +325,6 @@ TRUK: HP: 110 Armor: light Sight: 3 - Mobile: Speed: 10 RenderUnit: @@ -360,9 +345,9 @@ SS: Armor: light ROT: 7 Sight: 6 + Speed: 6 WaterBound: yes Mobile: - Speed: 6 RenderUnit: Submarine: AttackBase: @@ -388,9 +373,9 @@ DD: Armor: heavy ROT: 7 Sight: 6 + Speed: 6 WaterBound: yes Mobile: - Speed: 6 Turreted: AttackTurreted: PrimaryWeapon: Stinger @@ -417,9 +402,9 @@ CA: Armor: heavy ROT: 5 Sight: 7 + Speed: 4 WaterBound: yes Mobile: - Speed: 4 Turreted: AttackTurreted: PrimaryWeapon: 8Inch @@ -446,9 +431,9 @@ LST: Armor: heavy ROT: 10 Sight: 6 + Speed: 14 WaterBound: yes Mobile: - Speed: 14 RenderUnit: Cargo: PassengerTypes: Foot,Wheel,Track @@ -472,9 +457,9 @@ PT: Armor: heavy ROT: 7 Sight: 7 + Speed: 9 WaterBound: yes Mobile: - Speed: 9 Turreted: AttackTurreted: PrimaryWeapon: 2Inch @@ -502,10 +487,10 @@ MIG: InitialFacing: 192 ROT: 5 Sight: 0 + Speed: 20 AttackPlane: PrimaryWeapon: Maverick Plane: - Speed: 20 RenderUnit: WithShadow: LimitedAmmo: @@ -531,10 +516,10 @@ YAK: InitialFacing: 192 ROT: 5 Sight: 0 + Speed: 16 AttackPlane: PrimaryWeapon: ChainGun Plane: - Speed: 16 RenderUnit: WithShadow: LimitedAmmo: @@ -559,8 +544,8 @@ TRAN: InitialFacing: 20 ROT: 5 Sight: 0 - Helicopter: Speed: 12 + Helicopter: RenderUnitRotor: PrimaryOffset: 0,14,0,-4 SecondaryOffset: 0,-14,0,-2 @@ -589,12 +574,12 @@ HELI: InitialFacing: 20 ROT: 4 Sight: 0 + Speed: 16 AttackHeli: PrimaryWeapon: Hellfire PrimaryOffset: -5,0,0,2 SecondaryOffset: 5,0,0,2 Helicopter: - Speed: 16 RenderUnitRotor: PrimaryOffset: 0,0,0,-2 WithShadow: @@ -621,12 +606,12 @@ HIND: InitialFacing: 20 ROT: 4 Sight: 0 + Speed: 12 AttackHeli: PrimaryWeapon: ChainGun PrimaryOffset: -5,0,0,2 SecondaryOffset: 5,0,0,2 Helicopter: - Speed: 12 RenderUnitRotor: WithShadow: LimitedAmmo: @@ -2166,8 +2151,8 @@ DOG: HP: 12 Armor: none Sight: 5 - Mobile: Speed: 4 + Mobile: RenderInfantry: Passenger: @@ -2186,8 +2171,8 @@ E1: HP: 50 Armor: none Sight: 4 - Mobile: Speed: 4 + Mobile: RenderInfantry: AttackBase: PrimaryWeapon: M1Carbine @@ -2211,8 +2196,8 @@ E2: HP: 50 Armor: none Sight: 4 - Mobile: Speed: 5 + Mobile: RenderInfantry: AttackBase: PrimaryWeapon: Grenade @@ -2238,8 +2223,8 @@ E3: HP: 45 Armor: none Sight: 4 - Mobile: Speed: 3 + Mobile: RenderInfantry: AttackBase: PrimaryWeapon: RedEye @@ -2265,8 +2250,8 @@ E4: HP: 40 Armor: none Sight: 4 - Mobile: Speed: 3 + Mobile: RenderInfantry: AttackBase: PrimaryWeapon: Flamer @@ -2293,8 +2278,8 @@ E6: HP: 25 Armor: none Sight: 4 - Mobile: Speed: 4 + Mobile: EngineerCapture: RenderInfantry: TakeCover: @@ -2318,8 +2303,8 @@ SPY: HP: 25 Armor: none Sight: 5 - Mobile: Speed: 4 + Mobile: RenderInfantry: TakeCover: SquishByTank: @@ -2342,8 +2327,8 @@ THF: HP: 25 Armor: none Sight: 5 - Mobile: Speed: 4 + Mobile: RenderInfantry: TakeCover: SquishByTank: @@ -2367,8 +2352,8 @@ E7: HP: 100 Armor: none Sight: 6 - Mobile: Speed: 5 + Mobile: RenderInfantry: C4Demolition: AttackBase: @@ -2394,8 +2379,8 @@ MEDI: HP: 80 Armor: none Sight: 3 - Mobile: Speed: 4 + Mobile: RenderInfantry: AutoHeal: AttackBase: From 02b9415277bc74d171bc0296c91855a29e7632ec Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 21:42:47 +1300 Subject: [PATCH 69/83] fixed legacyInfo.Speed --- OpenRa.Game/Traits/Util.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Traits/Util.cs b/OpenRa.Game/Traits/Util.cs index bde7f77c59..3e9018f05b 100755 --- a/OpenRa.Game/Traits/Util.cs +++ b/OpenRa.Game/Traits/Util.cs @@ -127,14 +127,14 @@ namespace OpenRa.Game.Traits public static float GetEffectiveSpeed(Actor self) { - var mi = self.LegacyInfo as LegacyMobileInfo; - if (mi == null) return 0f; + var unitInfo = self.Info.Traits.GetOrDefault(); + if( unitInfo == null ) return 0f; var modifier = self.traits .WithInterface() .Select(t => t.GetSpeedModifier()) .Product(); - return mi.Speed * modifier; + return unitInfo.Speed * modifier; } public static IActivity SequenceActivities(params IActivity[] acts) From ee14b0a670af1e254cd9ff8ff45fac1598868fc0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 21:59:26 +1300 Subject: [PATCH 70/83] movementtype --- OpenRa.Game/Traits/Mobile.cs | 16 +++------------- RulesConverter/Program.cs | 21 ++++++++++++++++++--- aftermath.yaml | 4 ---- defaults.yaml | 16 ++++++++++++++++ ra.yaml | 25 ------------------------- 5 files changed, 37 insertions(+), 45 deletions(-) diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 502521d23a..2a1da2f3aa 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -7,6 +7,8 @@ namespace OpenRa.Game.Traits { class MobileInfo : ITraitInfo { + public readonly UnitMovementType MovementType = UnitMovementType.Wheel; + public object Create(Actor self) { return new Mobile(self); } } @@ -83,19 +85,7 @@ namespace OpenRa.Game.Traits public UnitMovementType GetMovementType() { - switch (Rules.UnitCategory[self.Info.Name]) - { - case "Infantry": - return UnitMovementType.Foot; - case "Vehicle": - return (self.LegacyInfo as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; - case "Ship": - return UnitMovementType.Float; - case "Plane": - return UnitMovementType.Fly; - default: - throw new InvalidOperationException("GetMovementType on unit that shouldn't be able to move."); - } + return self.Info.Traits.Get().MovementType; } public bool CanEnterCell(int2 a) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 06ce571c06..ec0b0e6c06 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -54,8 +54,7 @@ namespace RulesConverter }, { "Mobile", new PL { - //{ "MovementType", ... }, - } + { "MovementType", "$MovementType" } } }, { "RenderBuilding", new PL { @@ -186,7 +185,9 @@ namespace RulesConverter if (traitMap.ContainsKey(t)) foreach (var kv in traitMap[t]) { - var v = kv.Value == "$Tab" ? cat.Value.Second : iniSection.GetValue(kv.Value, ""); + var v = iniSection.GetValue(kv.Value, ""); + if (kv.Value == "$Tab") v = cat.Value.Second; + if (kv.Value == "$MovementType") v = GetMovementType(iniSection, traits); var fmt = "\t\t{0}: {1}"; var k = kv.Key; if (k.StartsWith("@")) { k = k.Substring(1); /*fmt = "\t\t{0}: [{1}]";*/ } @@ -206,5 +207,19 @@ namespace RulesConverter yaml.OptimizeInherits( MiniYaml.FromFile( "defaults.yaml" ) ); yaml.WriteToFile( outputFile ); } + + static string GetMovementType(IniSection unit, List traits) + { + if (unit.GetValue("WaterBound", "no") == "yes") + return "Float"; + if (unit.GetValue("Tracked", "no") == "yes") + return "Track"; + if (traits.Contains("Plane") || traits.Contains("Helicopter")) + return "Fly"; + if (traits.Contains("RenderInfantry")) + return "Foot"; + + return "Wheel"; + } } } diff --git a/aftermath.yaml b/aftermath.yaml index 5dcadf08ef..4ebc49a29a 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -96,7 +96,6 @@ MSUB: Owner: soviet Cost: 1650 Description: "Missile Submarine" - Selectable: Unit: HP: 150 Armor: light @@ -104,7 +103,6 @@ MSUB: Sight: 6 Speed: 5 WaterBound: yes - Mobile: AttackBase: PrimaryWeapon: SubSCUD FireDelay: 2 @@ -128,7 +126,6 @@ SHOK: Armor: none Sight: 4 Speed: 3 - Mobile: AttackBase: PrimaryWeapon: PortaTesla RenderInfantry: @@ -153,7 +150,6 @@ MECH: Armor: none Sight: 3 Speed: 4 - Mobile: RenderInfantry: AutoHeal: AttackBase: diff --git a/defaults.yaml b/defaults.yaml index 6d2a18160b..cd9cc60525 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -2,6 +2,7 @@ DefaultVehicle: Unit: ROT: 5 Mobile: + MovementType: Wheel Selectable: Voice: VehicleVoice Repairable: @@ -9,3 +10,18 @@ DefaultVehicle: Passenger: IronCurtainable: +DefaultInfantry: + Unit: + Mobile: + MovementType: Foot + Selectable: + +DefaultShip: + Unit: + Mobile: + MovementType: Float + Selectable: + +DefaultPlane: + Unit: + Selectable: \ No newline at end of file diff --git a/ra.yaml b/ra.yaml index 4acd1b9cbd..9df3c81702 100644 --- a/ra.yaml +++ b/ra.yaml @@ -339,7 +339,6 @@ SS: Cost: 950 Description: "Submarine" LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" - Selectable: Unit: HP: 120 Armor: light @@ -347,7 +346,6 @@ SS: Sight: 6 Speed: 6 WaterBound: yes - Mobile: RenderUnit: Submarine: AttackBase: @@ -367,7 +365,6 @@ DD: Cost: 1000 Description: "Destroyer" LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" - Selectable: Unit: HP: 400 Armor: heavy @@ -375,7 +372,6 @@ DD: Sight: 6 Speed: 6 WaterBound: yes - Mobile: Turreted: AttackTurreted: PrimaryWeapon: Stinger @@ -396,7 +392,6 @@ CA: Cost: 2000 Description: "Cruiser" LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" - Selectable: Unit: HP: 700 Armor: heavy @@ -404,7 +399,6 @@ CA: Sight: 7 Speed: 4 WaterBound: yes - Mobile: Turreted: AttackTurreted: PrimaryWeapon: 8Inch @@ -425,7 +419,6 @@ LST: Cost: 700 Description: "Transport" LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" - Selectable: Unit: HP: 350 Armor: heavy @@ -433,7 +426,6 @@ LST: Sight: 6 Speed: 14 WaterBound: yes - Mobile: RenderUnit: Cargo: PassengerTypes: Foot,Wheel,Track @@ -451,7 +443,6 @@ PT: Cost: 500 Description: "Gunboat" LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" - Selectable: Unit: HP: 200 Armor: heavy @@ -459,7 +450,6 @@ PT: Sight: 7 Speed: 9 WaterBound: yes - Mobile: Turreted: AttackTurreted: PrimaryWeapon: 2Inch @@ -480,7 +470,6 @@ MIG: Cost: 1200 Description: "Mig Attack Plane" LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" - Selectable: Unit: HP: 50 Armor: light @@ -508,7 +497,6 @@ YAK: Cost: 800 Description: "Yak Attack Plane" LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" - Selectable: Unit: HP: 60 Armor: light @@ -537,7 +525,6 @@ TRAN: Cost: 1200 Description: "Transport Helicopter" LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" - Selectable: Unit: HP: 90 Armor: light @@ -566,7 +553,6 @@ HELI: Cost: 1200 Description: "Longbow" LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" - Selectable: Unit: HP: 225 Armor: heavy @@ -598,7 +584,6 @@ HIND: Cost: 1200 Description: "Hind" LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" - Selectable: Unit: HP: 225 Armor: heavy @@ -2152,7 +2137,6 @@ DOG: Armor: none Sight: 5 Speed: 4 - Mobile: RenderInfantry: Passenger: @@ -2172,7 +2156,6 @@ E1: Armor: none Sight: 4 Speed: 4 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: M1Carbine @@ -2197,7 +2180,6 @@ E2: Armor: none Sight: 4 Speed: 5 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: Grenade @@ -2224,7 +2206,6 @@ E3: Armor: none Sight: 4 Speed: 3 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: RedEye @@ -2251,7 +2232,6 @@ E4: Armor: none Sight: 4 Speed: 3 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: Flamer @@ -2279,7 +2259,6 @@ E6: Armor: none Sight: 4 Speed: 4 - Mobile: EngineerCapture: RenderInfantry: TakeCover: @@ -2304,7 +2283,6 @@ SPY: Armor: none Sight: 5 Speed: 4 - Mobile: RenderInfantry: TakeCover: SquishByTank: @@ -2328,7 +2306,6 @@ THF: Armor: none Sight: 5 Speed: 4 - Mobile: RenderInfantry: TakeCover: SquishByTank: @@ -2353,7 +2330,6 @@ E7: Armor: none Sight: 6 Speed: 5 - Mobile: RenderInfantry: C4Demolition: AttackBase: @@ -2380,7 +2356,6 @@ MEDI: Armor: none Sight: 3 Speed: 4 - Mobile: RenderInfantry: AutoHeal: AttackBase: From 0cb5eca673a510e136863618f42a4b22d4aea3da Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 22:07:42 +1300 Subject: [PATCH 71/83] removed LegacyInfo from Actor --- OpenRa.Game/Actor.cs | 27 ++++++++++++--------------- OpenRa.Game/Exts.cs | 8 ++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index b802a517cf..0d8b72f5a6 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -12,11 +12,7 @@ namespace OpenRa.Game { [Sync] public readonly TypeDictionary traits = new TypeDictionary(); - - [Obsolete] - public readonly LegacyUnitInfo LegacyInfo; public readonly NewUnitInfo Info; - public readonly uint ActorID; [Sync] public int2 Location; @@ -29,19 +25,18 @@ namespace OpenRa.Game public Actor( string name, int2 location, Player owner ) { ActorID = Game.world.NextAID(); - LegacyInfo = name != null ? Rules.UnitInfo[name.ToLowerInvariant()] : null; // temporary Location = location; CenterLocation = Traits.Util.CenterOfCell(Location); Owner = owner; - if (LegacyInfo == null) return; + if (name != null) + { + Info = Rules.NewUnitInfo[name.ToLowerInvariant()]; + Health = this.GetMaxHP(); - Health = LegacyInfo.Strength; /* todo: fix walls, etc so this is always true! */ - - Info = Rules.NewUnitInfo[name.ToLowerInvariant()]; - - foreach (var trait in Info.Traits.WithInterface()) - traits.Add(trait.Create(this)); + foreach (var trait in Info.Traits.WithInterface()) + traits.Add(trait.Create(this)); + } } public void Tick() @@ -128,7 +123,7 @@ namespace OpenRa.Game public DamageState GetDamageState() { if (Health <= 0) return DamageState.Dead; - var halfStrength = LegacyInfo.Strength * Rules.General.ConditionYellow; + var halfStrength = this.GetMaxHP() * Rules.General.ConditionYellow; return Health < halfStrength ? DamageState.Half : DamageState.Normal; } @@ -151,8 +146,10 @@ namespace OpenRa.Game Game.world.AddFrameEndTask(w => w.Remove(this)); } - if (Health > LegacyInfo.Strength) - Health = LegacyInfo.Strength; + + var maxHP = this.GetMaxHP(); + + if (Health > maxHP) Health = maxHP; var newState = GetDamageState(); diff --git a/OpenRa.Game/Exts.cs b/OpenRa.Game/Exts.cs index 804f99b970..e69d1eed42 100644 --- a/OpenRa.Game/Exts.cs +++ b/OpenRa.Game/Exts.cs @@ -51,5 +51,13 @@ namespace OpenRa.Game return Rules.WeaponInfo[weapon]; } + + public static int GetMaxHP(this Actor self) + { + if (self.Info == null) return 0; + var oai = self.Info.Traits.GetOrDefault(); + if (oai == null) return 0; + return oai.HP; + } } } From d707fe420fd7303dcd9bf92f77d4cc96743f5960 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 22:10:27 +1300 Subject: [PATCH 72/83] marking the next bit we need to kill --- OpenRa.Game/GameRules/Rules.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 3983385775..a1ba05b290 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -13,7 +13,7 @@ namespace OpenRa.Game public static IniFile AllRules; public static Dictionary> Categories = new Dictionary>(); public static Dictionary UnitCategory; - public static InfoLoader UnitInfo; + [Obsolete] public static InfoLoader UnitInfo; public static InfoLoader WeaponInfo; public static InfoLoader WarheadInfo; public static InfoLoader ProjectileInfo; From 16a9189bec0c3776a0161c2fa317988d586db124 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 22:22:10 +1300 Subject: [PATCH 73/83] starting to fix refs to Rules.UnitInfo --- OpenRa.Game/Chrome.cs | 19 ++++++++++--------- OpenRa.Game/GameRules/TechTree.cs | 16 ++++++++-------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 8716c928c8..e4d231bba9 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -731,14 +731,15 @@ namespace OpenRa.Game rgbaRenderer.DrawSprite(tooltipSprite, p, PaletteType.Chrome); rgbaRenderer.Flush(); - var info = Rules.UnitInfo[unit]; + var info = Rules.NewUnitInfo[unit]; + var buildable = info.Traits.Get(); - renderer.DrawText2(info.Description, p.ToInt2() + new int2(5,5), Color.White); + renderer.DrawText2(buildable.Description, p.ToInt2() + new int2(5,5), Color.White); - DrawRightAligned( "${0}".F(info.Cost), pos + new int2(-5,5), - Game.LocalPlayer.Cash + Game.LocalPlayer.Ore >= info.Cost ? Color.White : Color.Red); + DrawRightAligned( "${0}".F(buildable.Cost), pos + new int2(-5,5), + Game.LocalPlayer.Cash + Game.LocalPlayer.Ore >= buildable.Cost ? Color.White : Color.Red); - var bi = info as LegacyBuildingInfo; + var bi = info.Traits.GetOrDefault(); if (bi != null) DrawRightAligned("ϟ{0}".F(bi.Power), pos + new int2(-5, 20), Game.LocalPlayer.PowerProvided - Game.LocalPlayer.PowerDrained + bi.Power >= 0 @@ -749,18 +750,18 @@ namespace OpenRa.Game p += new int2(0, 15); if (!Rules.TechTree.CanBuild(info, Game.LocalPlayer, buildings)) { - var prereqs = info.Prerequisite - .Select(a => Rules.UnitInfo[a.ToLowerInvariant()]) + var prereqs = buildable.Prerequisites + .Select(a => Rules.NewUnitInfo[a.ToLowerInvariant()].Traits.Get()) .Where( u => u.Owner.Any( o => o == Game.LocalPlayer.Race ) ) .Select( a => a.Description ); renderer.DrawText("Requires {0}".F( string.Join( ", ", prereqs.ToArray() ) ), p.ToInt2(), Color.White); } - if (info.LongDesc != null) + if (buildable.LongDesc != null) { p += new int2(0, 15); - renderer.DrawText(info.LongDesc.Replace( "\\n", "\n" ), p.ToInt2(), Color.White); + renderer.DrawText(buildable.LongDesc.Replace( "\\n", "\n" ), p.ToInt2(), Color.White); } } diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 7e1eef92b6..d2fcc9aafb 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -29,20 +29,20 @@ namespace OpenRa.Game.GameRules return ret; } - public bool CanBuild( LegacyUnitInfo unit, Player player, Cache> playerBuildings ) + public bool CanBuild( NewUnitInfo info, Player player, Cache> playerBuildings ) { - if( unit.TechLevel == -1 ) + var bi = info.Traits.GetOrDefault(); + if( bi == null ) return false; + + if( !bi.Owner.Any( x => x == player.Race ) ) return false; - if( !unit.Owner.Any( x => x == player.Race ) ) - return false; - - foreach( var p in unit.Prerequisite ) + foreach( var p in bi.Prerequisites ) if (Rules.UnitInfo[p.ToLowerInvariant()].Owner.Any(x => x == player.Race)) if( playerBuildings[ p ].Count == 0 ) return false; - if( producesIndex[ Rules.UnitCategory[ unit.Name ] ].All( x => playerBuildings[ x.Name ].Count == 0 ) ) + if( producesIndex[ Rules.UnitCategory[ info.Name ] ].All( x => playerBuildings[ x.Name ].Count == 0 ) ) return false; return true; @@ -51,7 +51,7 @@ namespace OpenRa.Game.GameRules public IEnumerable BuildableItems( Player player, params string[] categories ) { var playerBuildings = GatherBuildings( player ); - foreach( var unit in categories.SelectMany( x => Rules.Categories[ x ] ).Select( x => Rules.UnitInfo[ x ] ) ) + foreach( var unit in categories.SelectMany( x => Rules.Categories[ x ] ).Select( x => Rules.NewUnitInfo[ x ] ) ) if( CanBuild( unit, player, playerBuildings ) ) yield return unit.Name; } From cecc163e524f8cf0e82eec23bc496837a40c9a48 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 22:32:27 +1300 Subject: [PATCH 74/83] ... and the rest. --- OpenRa.Game/Chrome.cs | 8 +- OpenRa.Game/GameRules/ArmorType.cs | 16 ++++ OpenRa.Game/GameRules/Rules.cs | 9 -- OpenRa.Game/GameRules/TechTree.cs | 6 +- OpenRa.Game/GameRules/UnitInfo.cs | 117 -------------------------- OpenRa.Game/OpenRa.Game.csproj | 2 +- OpenRa.Game/SupportPower.cs | 3 +- OpenRa.Game/Traits/ProductionQueue.cs | 2 +- 8 files changed, 27 insertions(+), 136 deletions(-) create mode 100755 OpenRa.Game/GameRules/ArmorType.cs delete mode 100755 OpenRa.Game/GameRules/UnitInfo.cs diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index e4d231bba9..52ac6de270 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -112,10 +112,10 @@ namespace OpenRa.Game tabSprites = groups .SelectMany(g => Rules.Categories[g]) - .Where(u => Rules.UnitInfo[u].TechLevel != -1) + .Where(u => Rules.NewUnitInfo[u].Traits.Contains()) .ToDictionary( u => u, - u => SpriteSheetBuilder.LoadAllSprites(Rules.UnitInfo[u].Icon ?? (u + "icon"))[0]); + u => SpriteSheetBuilder.LoadAllSprites(Rules.NewUnitInfo[u].Traits.Get().Icon ?? (u + "icon"))[0]); spsprites = Rules.SupportPowerInfo .ToDictionary( @@ -531,8 +531,8 @@ namespace OpenRa.Game var buildableItems = Rules.TechTree.BuildableItems(Game.LocalPlayer, queueName).ToArray(); var allItems = Rules.TechTree.AllItems(Game.LocalPlayer, queueName) - .Where(a => Rules.UnitInfo[a].TechLevel != -1) - .OrderBy(a => Rules.UnitInfo[a].TechLevel); + .Where(a => Rules.NewUnitInfo[a].Traits.Contains()) + .OrderBy(a => Rules.NewUnitInfo[a].Traits.Get().TechLevel); var queue = Game.LocalPlayer.PlayerActor.traits.Get(); diff --git a/OpenRa.Game/GameRules/ArmorType.cs b/OpenRa.Game/GameRules/ArmorType.cs new file mode 100755 index 0000000000..bc2ac7e51b --- /dev/null +++ b/OpenRa.Game/GameRules/ArmorType.cs @@ -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, + } +} diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index a1ba05b290..7571ac1dc2 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -13,7 +13,6 @@ namespace OpenRa.Game public static IniFile AllRules; public static Dictionary> Categories = new Dictionary>(); public static Dictionary UnitCategory; - [Obsolete] public static InfoLoader UnitInfo; public static InfoLoader WeaponInfo; public static InfoLoader WarheadInfo; public static InfoLoader ProjectileInfo; @@ -64,14 +63,6 @@ namespace OpenRa.Game "Plane"); UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair(y, x.Key))).ToDictionary(x => x.Key, x => x.Value); - UnitInfo = new InfoLoader( - Pair.New>("Building", s => new LegacyBuildingInfo(s)), - Pair.New>("Defense", s => new LegacyBuildingInfo(s)), - Pair.New>("Infantry", s => new InfantryInfo(s)), - Pair.New>("Vehicle", s => new VehicleInfo(s)), - Pair.New>("Ship", s => new VehicleInfo(s)), - Pair.New>("Plane", s => new VehicleInfo(s))); - LoadCategories( "Weapon", "Warhead", diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index d2fcc9aafb..706fb7f953 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -38,7 +38,7 @@ namespace OpenRa.Game.GameRules return false; foreach( var p in bi.Prerequisites ) - if (Rules.UnitInfo[p.ToLowerInvariant()].Owner.Any(x => x == player.Race)) + if (Rules.NewUnitInfo[p.ToLowerInvariant()].Traits.Get().Owner.Any(x => x == player.Race)) if( playerBuildings[ p ].Count == 0 ) return false; @@ -58,8 +58,8 @@ namespace OpenRa.Game.GameRules public IEnumerable AllItems(Player player, params string[] categories) { - return categories.SelectMany(x => Rules.Categories[x]).Select(x => Rules.UnitInfo[x].Name) - .Where(x => Rules.UnitInfo[x].Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */ + return categories.SelectMany(x => Rules.Categories[x]).Select(x => Rules.NewUnitInfo[x].Name) + .Where(x => Rules.NewUnitInfo[x].Traits.Get().Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */ } public IEnumerable UnitBuiltAt( NewUnitInfo info ) diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs deleted file mode 100755 index e3daf1eb12..0000000000 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ /dev/null @@ -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) { } - } -} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index d3e2003bae..4bf279b6a5 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -94,6 +94,7 @@ + @@ -157,7 +158,6 @@ - diff --git a/OpenRa.Game/SupportPower.cs b/OpenRa.Game/SupportPower.cs index 0c54dd6718..074c36c7fc 100644 --- a/OpenRa.Game/SupportPower.cs +++ b/OpenRa.Game/SupportPower.cs @@ -2,6 +2,7 @@ using System.Linq; using OpenRa.Game.GameRules; using OpenRa.Game.SupportPowers; +using OpenRa.Game.Traits; namespace OpenRa.Game { @@ -49,7 +50,7 @@ namespace OpenRa.Game var buildings = Rules.TechTree.GatherBuildings(Owner); var effectivePrereq = Info.Prerequisite .Select( a => a.ToLowerInvariant() ) - .Where( a => Rules.UnitInfo[a].Owner + .Where( a => Rules.NewUnitInfo[a].Traits.Get().Owner .Any( r => r == Owner.Race )); IsAvailable = Info.TechLevel > -1 diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index 559f78fc81..edbe3a9a8c 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -34,7 +34,7 @@ namespace OpenRa.Game.Traits case "StartProduction": { string group = Rules.UnitCategory[ order.TargetString ]; - var ui = Rules.UnitInfo[ order.TargetString ]; + var ui = Rules.NewUnitInfo[ order.TargetString ].Traits.Get(); var time = ui.Cost * Rules.General.BuildSpeed /* todo: country-specific build speed bonus */ * ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */ From 1c0aecaaa4dac396bd6668215301ddff5a043fd8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 22:45:45 +1300 Subject: [PATCH 75/83] miniyaml is a bit more mini than i thought. --- RulesConverter/Program.cs | 19 +-- aftermath.yaml | 16 +-- ra.yaml | 260 +++++++++++++++++++------------------- 3 files changed, 145 insertions(+), 150 deletions(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index ec0b0e6c06..56eceaed5b 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -50,7 +50,7 @@ namespace RulesConverter { "Selectable", new PL { { "Priority", "SelectionPriority" }, { "Voice", "Voice" }, - { "@Bounds", "SelectionSize" } } + { "Bounds", "SelectionSize" } } }, { "Mobile", new PL { @@ -75,17 +75,17 @@ namespace RulesConverter { "Buildable", new PL { { "TechLevel", "TechLevel" }, { "Tab", "$Tab" }, - { "@Prerequisites", "Prerequisite" }, + { "Prerequisites", "Prerequisite" }, { "BuiltAt", "BuiltAt" }, { "Owner", "Owner" }, { "Cost", "Cost" }, { "Icon", "Icon" }, - { "$Description", "Description" }, - { "$LongDesc", "LongDesc" } } + { "Description", "Description" }, + { "LongDesc", "LongDesc" } } }, { "Cargo", new PL { - { "@PassengerTypes", "PassengerTypes" }, + { "PassengerTypes", "PassengerTypes" }, { "Passengers", "Passengers" }, { "UnloadFacing", "UnloadFacing" } } }, @@ -98,7 +98,7 @@ namespace RulesConverter { "Power", "Power" }, { "RequiresPower", "Powered" }, { "Footprint", "Footprint" }, - { "@Dimensions", "Dimensions" }, + { "Dimensions", "Dimensions" }, { "Capturable", "Capturable" }, { "Repairable", "Repairable" }, { "BaseNormal", "BaseNormal" }, @@ -188,12 +188,7 @@ namespace RulesConverter var v = iniSection.GetValue(kv.Value, ""); if (kv.Value == "$Tab") v = cat.Value.Second; if (kv.Value == "$MovementType") v = GetMovementType(iniSection, traits); - var fmt = "\t\t{0}: {1}"; - var k = kv.Key; - if (k.StartsWith("@")) { k = k.Substring(1); /*fmt = "\t\t{0}: [{1}]";*/ } - if (k.StartsWith("$")) { k = k.Substring(1); fmt = "\t\t{0}: \"{1}\""; } - - if (!string.IsNullOrEmpty(v)) writer.WriteLine(fmt, k, v); + if (!string.IsNullOrEmpty(v)) writer.WriteLine("\t\t{0}: {1}", kv.Key, v); } } diff --git a/aftermath.yaml b/aftermath.yaml index 4ebc49a29a..3f905e70f8 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -20,7 +20,7 @@ TTNK: Prerequisites: tsla Owner: soviet Cost: 1500 - Description: "Tesla Tank" + Description: Tesla Tank Unit: HP: 110 Armor: light @@ -39,7 +39,7 @@ CTNK: Prerequisites: atek Owner: allies Cost: 2400 - Description: "Chrono Tank" + Description: Chrono Tank Unit: HP: 350 Armor: light @@ -58,7 +58,7 @@ DTRK: Prerequisites: mslo Owner: allies,soviet Cost: 2400 - Description: "Demo Truck" + Description: Demo Truck Unit: HP: 110 Armor: light @@ -77,7 +77,7 @@ QTNK: Prerequisites: stek Owner: soviet Cost: 2300 - Description: "M.A.D. Tank" + Description: M.A.D. Tank Unit: HP: 300 Armor: heavy @@ -95,7 +95,7 @@ MSUB: BuiltAt: spen Owner: soviet Cost: 1650 - Description: "Missile Submarine" + Description: Missile Submarine Unit: HP: 150 Armor: light @@ -118,7 +118,7 @@ SHOK: Prerequisites: tsla Owner: soviet Cost: 900 - Description: "Tesla Trooper" + Description: Tesla Trooper Selectable: Voice: ShokVoice Unit: @@ -140,8 +140,8 @@ MECH: Prerequisites: fix Owner: allies Cost: 950 - Description: "Mechanic" - LongDesc: "Heals nearby vehicles.\n Strong vs Nothing\n Weak vs Everything" + Description: Mechanic + LongDesc: Heals nearby vehicles.\n Strong vs Nothing\n Weak vs Everything Selectable: Voice: MechVoice Bounds: 12,17,0,-9 diff --git a/ra.yaml b/ra.yaml index 9df3c81702..ff7e9b5b79 100644 --- a/ra.yaml +++ b/ra.yaml @@ -6,8 +6,8 @@ V2RL: Prerequisites: weap,dome Owner: soviet Cost: 700 - Description: "V2 Rocket" - LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Description: V2 Rocket + LongDesc: Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft Unit: HP: 150 Armor: light @@ -27,8 +27,8 @@ V2RL: Prerequisites: weap Owner: allies Cost: 700 - Description: "Light Tank" - LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" + Description: Light Tank + LongDesc: Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft Unit: HP: 300 Armor: heavy @@ -50,8 +50,8 @@ V2RL: Prerequisites: weap Owner: allies Cost: 800 - Description: "Medium Tank" - LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Description: Medium Tank + LongDesc: Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft Unit: HP: 400 Armor: heavy @@ -73,8 +73,8 @@ V2RL: Prerequisites: weap Owner: soviet Cost: 950 - Description: "Heavy Tank" - LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" + Description: Heavy Tank + LongDesc: Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft Unit: HP: 400 Armor: heavy @@ -96,8 +96,8 @@ V2RL: Prerequisites: weap,stek Owner: soviet Cost: 1700 - Description: "Mammoth Tank" - LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Description: Mammoth Tank + LongDesc: Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry Unit: HP: 600 Armor: heavy @@ -121,8 +121,8 @@ MRJ: Prerequisites: weap,dome Owner: allies Cost: 600 - Description: "Radar Jammer" - LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" + Description: Radar Jammer + LongDesc: Hides nearby units on the enemy's minimap.\n Unarmed Selectable: Priority: 3 Unit: @@ -142,8 +142,8 @@ MGG: Prerequisites: weap,atek Owner: allies Cost: 600 - Description: "Mobile Gap Generator" - LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" + Description: Mobile Gap Generator + LongDesc: Regenerates Fog of War in a small area \naround the unit.\n Unarmed Selectable: Priority: 3 Unit: @@ -163,8 +163,8 @@ ARTY: Prerequisites: weap Owner: allies Cost: 600 - Description: "Artillery" - LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" + Description: Artillery + LongDesc: Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft Unit: HP: 75 Armor: light @@ -185,8 +185,8 @@ HARV: Prerequisites: weap,proc Owner: allies,soviet Cost: 1400 - Description: "Ore Truck" - LongDesc: "Collects Ore and Gems for processing.\n Unarmed" + Description: Ore Truck + LongDesc: Collects Ore and Gems for processing.\n Unarmed Selectable: Priority: 7 Harvester: @@ -206,8 +206,8 @@ MCV: Prerequisites: weap,fix Owner: allies,soviet Cost: 2500 - Description: "Mobile Construction Vehicle" - LongDesc: "Deploys into another Construction Yard.\n Unarmed" + Description: Mobile Construction Vehicle + LongDesc: Deploys into another Construction Yard.\n Unarmed Selectable: Priority: 3 Unit: @@ -227,8 +227,8 @@ JEEP: Prerequisites: weap Owner: allies Cost: 600 - Description: "Ranger" - LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" + Description: Ranger + LongDesc: Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft Unit: HP: 150 Armor: light @@ -251,8 +251,8 @@ APC: Prerequisites: weap,tent Owner: allies Cost: 800 - Description: "Armored Personnel Carrier" - LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Description: Armored Personnel Carrier + LongDesc: Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft Unit: HP: 200 Armor: heavy @@ -278,8 +278,8 @@ MNLY.AP: Owner: soviet Cost: 800 Icon: MNLYICON - Description: "Minelayer (Anti-Personnel)" - LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Description: Minelayer (Anti-Personnel) + LongDesc: Lays mines to destroy unwary enemy units.\n Unarmed Unit: HP: 100 Armor: heavy @@ -303,8 +303,8 @@ MNLY.AT: Owner: allies Cost: 800 Icon: MNLYICON - Description: "Minelayer (Anti-Tank)" - LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" + Description: Minelayer (Anti-Tank) + LongDesc: Lays mines to destroy unwary enemy units.\n Unarmed Unit: HP: 100 Armor: heavy @@ -337,8 +337,8 @@ SS: BuiltAt: spen Owner: soviet Cost: 950 - Description: "Submarine" - LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" + Description: Submarine + LongDesc: Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge Unit: HP: 120 Armor: light @@ -363,8 +363,8 @@ DD: BuiltAt: syrd Owner: allies Cost: 1000 - Description: "Destroyer" - LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" + Description: Destroyer + LongDesc: Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks Unit: HP: 400 Armor: heavy @@ -390,8 +390,8 @@ CA: BuiltAt: syrd Owner: allies Cost: 2000 - Description: "Cruiser" - LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" + Description: Cruiser + LongDesc: Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines Unit: HP: 700 Armor: heavy @@ -417,8 +417,8 @@ LST: Tab: Ship Owner: allies,soviet Cost: 700 - Description: "Transport" - LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" + Description: Transport + LongDesc: General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed Unit: HP: 350 Armor: heavy @@ -441,8 +441,8 @@ PT: BuiltAt: syrd Owner: allies Cost: 500 - Description: "Gunboat" - LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" + Description: Gunboat + LongDesc: Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft Unit: HP: 200 Armor: heavy @@ -468,8 +468,8 @@ MIG: BuiltAt: afld Owner: soviet Cost: 1200 - Description: "Mig Attack Plane" - LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" + Description: Mig Attack Plane + LongDesc: Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles Unit: HP: 50 Armor: light @@ -495,8 +495,8 @@ YAK: BuiltAt: afld Owner: soviet Cost: 800 - Description: "Yak Attack Plane" - LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" + Description: Yak Attack Plane + LongDesc: Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings Unit: HP: 60 Armor: light @@ -523,8 +523,8 @@ TRAN: BuiltAt: hpad Owner: allies Cost: 1200 - Description: "Transport Helicopter" - LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" + Description: Transport Helicopter + LongDesc: Fast Infantry Transport Helicopter.\n Unarmed Unit: HP: 90 Armor: light @@ -551,8 +551,8 @@ HELI: BuiltAt: hpad Owner: allies Cost: 1200 - Description: "Longbow" - LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" + Description: Longbow + LongDesc: Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry Unit: HP: 225 Armor: heavy @@ -582,8 +582,8 @@ HIND: BuiltAt: hpad Owner: allies Cost: 1200 - Description: "Hind" - LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" + Description: Hind + LongDesc: Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks Unit: HP: 225 Armor: heavy @@ -611,8 +611,8 @@ IRON: Prerequisites: stek Owner: soviet Cost: 2800 - Description: "Iron Curtain" - LongDesc: "Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability" + Description: Iron Curtain + LongDesc: Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability Selectable: Priority: 3 Building: @@ -637,8 +637,8 @@ PDOX: Prerequisites: atek Owner: allies Cost: 2800 - Description: "Chronosphere" - LongDesc: "Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift" + Description: Chronosphere + LongDesc: Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift Selectable: Priority: 3 Building: @@ -663,8 +663,8 @@ PBOX: Prerequisites: tent Owner: allies Cost: 400 - Description: "Pillbox" - LongDesc: "Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Description: Pillbox + LongDesc: Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft Selectable: Priority: 3 Building: @@ -690,8 +690,8 @@ HBOX: Prerequisites: tent Owner: allies Cost: 600 - Description: "Camo Pillbox" - LongDesc: "Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" + Description: Camo Pillbox + LongDesc: Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft Selectable: Priority: 3 Building: @@ -717,8 +717,8 @@ TSLA: Prerequisites: weap Owner: soviet Cost: 1500 - Description: "Tesla Coil" - LongDesc: "Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft" + Description: Tesla Coil + LongDesc: Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft Selectable: Priority: 3 Building: @@ -746,8 +746,8 @@ GUN: Prerequisites: tent Owner: allies Cost: 600 - Description: "Turret" - LongDesc: "Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft" + Description: Turret + LongDesc: Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft Selectable: Priority: 3 Building: @@ -774,8 +774,8 @@ AGUN: Prerequisites: dome Owner: allies Cost: 600 - Description: "AA Gun" - LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Description: AA Gun + LongDesc: Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks Selectable: Priority: 3 Building: @@ -803,8 +803,8 @@ FTUR: Prerequisites: barr Owner: soviet Cost: 600 - Description: "Flame Turret" - LongDesc: "Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft" + Description: Flame Turret + LongDesc: Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft Selectable: Priority: 3 Turreted: @@ -830,8 +830,8 @@ GAP: Prerequisites: atek Owner: allies Cost: 500 - Description: "Gap Generator" - LongDesc: "Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed" + Description: Gap Generator + LongDesc: Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed Selectable: Priority: 3 Building: @@ -855,8 +855,8 @@ SAM: Prerequisites: dome Owner: soviet Cost: 750 - Description: "SAM Site" - LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" + Description: SAM Site + LongDesc: Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks Selectable: Priority: 3 Building: @@ -882,8 +882,8 @@ MSLO: Prerequisites: stek,atek Owner: soviet,allies Cost: 2500 - Description: "Missile Silo" - LongDesc: "Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile" + Description: Missile Silo + LongDesc: Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile Selectable: Priority: 3 Building: @@ -905,8 +905,8 @@ ATEK: Prerequisites: weap,dome Owner: allies Cost: 1500 - Description: "Allied Tech Center" - LongDesc: "Provides Allied advanced technologies.\n Special Ability: GPS Satellite" + Description: Allied Tech Center + LongDesc: Provides Allied advanced technologies.\n Special Ability: GPS Satellite Selectable: Priority: 3 Building: @@ -931,8 +931,8 @@ WEAP: Prerequisites: proc Owner: soviet,allies Cost: 2000 - Description: "War Factory" - LongDesc: "Produces tanks & light vehicles." + Description: War Factory + LongDesc: Produces tanks & light vehicles. Selectable: Priority: 3 Building: @@ -960,8 +960,8 @@ SYRD: Prerequisites: powr Owner: allies Cost: 650 - Description: "Shipyard" - LongDesc: "Produces and repairs ships" + Description: Shipyard + LongDesc: Produces and repairs ships Selectable: Priority: 3 Building: @@ -987,8 +987,8 @@ SPEN: Prerequisites: powr Owner: soviet Cost: 650 - Description: "Sub Pen" - LongDesc: "Produces and repairs submarines and \ntransports" + Description: Sub Pen + LongDesc: Produces and repairs submarines and \ntransports Selectable: Priority: 3 Building: @@ -1034,8 +1034,8 @@ PROC: Prerequisites: powr Owner: allies,soviet Cost: 2000 - Description: "Ore Refinery" - LongDesc: "Converts Ore and Gems into money" + Description: Ore Refinery + LongDesc: Converts Ore and Gems into money Selectable: Priority: 3 Building: @@ -1063,8 +1063,8 @@ SILO: Prerequisites: proc Owner: allies,soviet Cost: 150 - Description: "Silo" - LongDesc: "Stores excess harvested Ore" + Description: Silo + LongDesc: Stores excess harvested Ore Selectable: Priority: 3 Building: @@ -1089,8 +1089,8 @@ HPAD: Prerequisites: dome Owner: allies Cost: 1500 - Description: "Helipad" - LongDesc: "Produces and reloads helicopters" + Description: Helipad + LongDesc: Produces and reloads helicopters Selectable: Priority: 3 Building: @@ -1119,8 +1119,8 @@ DOME: Prerequisites: proc Owner: allies,soviet Cost: 1000 - Description: "Radar Dome" - LongDesc: "Provides an overview of the battlefield.\n Requires power to operate." + Description: Radar Dome + LongDesc: Provides an overview of the battlefield.\n Requires power to operate. Selectable: Priority: 3 Building: @@ -1146,8 +1146,8 @@ AFLD: Prerequisites: dome Owner: soviet Cost: 600 - Description: "Airstrip" - LongDesc: "Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane" + Description: Airstrip + LongDesc: Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane Selectable: Priority: 3 Building: @@ -1174,8 +1174,8 @@ POWR: Prerequisites: fact Owner: allies,soviet Cost: 300 - Description: "Power Plant" - LongDesc: "Provides power for other structures" + Description: Power Plant + LongDesc: Provides power for other structures Selectable: Priority: 3 Building: @@ -1199,8 +1199,8 @@ APWR: Prerequisites: powr Owner: allies,soviet Cost: 500 - Description: "Advanced Power Plant" - LongDesc: "Provides more power, cheaper than the \nstandard Power Plant" + Description: Advanced Power Plant + LongDesc: Provides more power, cheaper than the \nstandard Power Plant Selectable: Priority: 3 Building: @@ -1224,8 +1224,8 @@ STEK: Prerequisites: weap,dome Owner: soviet Cost: 1500 - Description: "Soviet Tech Center" - LongDesc: "Provides Soviet advanced technologies" + Description: Soviet Tech Center + LongDesc: Provides Soviet advanced technologies Selectable: Priority: 3 Building: @@ -1249,8 +1249,8 @@ BARR: Prerequisites: powr Owner: soviet Cost: 300 - Description: "Soviet Barracks" - LongDesc: "Produces infantry" + Description: Soviet Barracks + LongDesc: Produces infantry Selectable: Priority: 3 Building: @@ -1277,8 +1277,8 @@ TENT: Prerequisites: powr Owner: allies Cost: 300 - Description: "Allied Barracks" - LongDesc: "Produces infantry" + Description: Allied Barracks + LongDesc: Produces infantry Selectable: Priority: 3 Building: @@ -1305,8 +1305,8 @@ KENN: Prerequisites: barr Owner: soviet Cost: 200 - Description: "Kennel" - LongDesc: "Produces attack dogs" + Description: Kennel + LongDesc: Produces attack dogs Selectable: Priority: 3 Building: @@ -1329,8 +1329,8 @@ FIX: Prerequisites: weap Owner: allies,soviet Cost: 1200 - Description: "Service Depot" - LongDesc: "Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases." + Description: Service Depot + LongDesc: Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases. Selectable: Priority: 3 Building: @@ -1354,8 +1354,8 @@ FACF: Tab: Building Owner: allies Cost: 50 - Description: "Fake Construction Yard" - LongDesc: "Looks like a Construction Yard." + Description: Fake Construction Yard + LongDesc: Looks like a Construction Yard. Selectable: Priority: 3 Building: @@ -1380,8 +1380,8 @@ WEAF: Prerequisites: proc Owner: allies Cost: 50 - Description: "Fake War Factory" - LongDesc: "Looks like a War Factory." + Description: Fake War Factory + LongDesc: Looks like a War Factory. Selectable: Priority: 3 Building: @@ -1407,8 +1407,8 @@ SYRF: Prerequisites: powr Owner: allies Cost: 50 - Description: "Fake Shipyard" - LongDesc: "Looks like a Shipyard" + Description: Fake Shipyard + LongDesc: Looks like a Shipyard Selectable: Priority: 3 Building: @@ -1451,8 +1451,8 @@ DOMF: Prerequisites: proc Owner: allies Cost: 50 - Description: "Fake Radar Dome" - LongDesc: "Looks like a Radar Dome" + Description: Fake Radar Dome + LongDesc: Looks like a Radar Dome Selectable: Priority: 3 Building: @@ -2127,8 +2127,8 @@ DOG: BuiltAt: KENN Owner: soviet Cost: 200 - Description: "Attack Dog" - LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" + Description: Attack Dog + LongDesc: Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles Selectable: Voice: DogVoice Bounds: 12,17,-1,-4 @@ -2147,8 +2147,8 @@ E1: Tab: Infantry Owner: allies,soviet Cost: 100 - Description: "Rifle Infantry" - LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" + Description: Rifle Infantry + LongDesc: General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles Selectable: Bounds: 12,17,0,-9 Unit: @@ -2171,8 +2171,8 @@ E2: Tab: Infantry Owner: soviet Cost: 160 - Description: "Grenadier" - LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" + Description: Grenadier + LongDesc: Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles Selectable: Bounds: 12,17,0,-9 Unit: @@ -2197,8 +2197,8 @@ E3: Tab: Infantry Owner: allies,soviet Cost: 300 - Description: "Rocket Soldier" - LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" + Description: Rocket Soldier + LongDesc: Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry Selectable: Bounds: 12,17,0,-9 Unit: @@ -2223,8 +2223,8 @@ E4: Prerequisites: stek Owner: soviet Cost: 300 - Description: "Flamethrower" - LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" + Description: Flamethrower + LongDesc: Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles Selectable: Bounds: 12,17,0,-9 Unit: @@ -2249,8 +2249,8 @@ E6: Tab: Infantry Owner: soviet,allies Cost: 500 - Description: "Engineer" - LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" + Description: Engineer + LongDesc: Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything Selectable: Voice: EngineerVoice Bounds: 12,17,0,-9 @@ -2273,8 +2273,8 @@ SPY: Prerequisites: dome Owner: allies Cost: 500 - Description: "Spy" - LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" + Description: Spy + LongDesc: Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised Selectable: Voice: SpyVoice Bounds: 12,17,0,-9 @@ -2296,8 +2296,8 @@ THF: Prerequisites: atek Owner: allies Cost: 500 - Description: "Thief" - LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" + Description: Thief + LongDesc: Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed Selectable: Voice: ThiefVoice Bounds: 12,17,0,-9 @@ -2320,8 +2320,8 @@ E7: Prerequisites: atek,stek Owner: allies,soviet Cost: 1200 - Description: "Tanya" - LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" + Description: Tanya + LongDesc: Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4 Selectable: Voice: TanyaVoice Bounds: 12,17,0,-9 @@ -2346,8 +2346,8 @@ MEDI: Tab: Infantry Owner: allies Cost: 800 - Description: "Medic" - LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" + Description: Medic + LongDesc: Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything Selectable: Voice: MedicVoice Bounds: 12,17,0,-9 From 7c2baa75bbd3423ed4cff1af33bc4399f49d2844 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 12 Jan 2010 23:34:05 +1300 Subject: [PATCH 76/83] fixed crashbug wrt FACT not being Buildable --- OpenRa.Game/GameRules/TechTree.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 706fb7f953..80bb04b47b 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -38,9 +38,8 @@ namespace OpenRa.Game.GameRules return false; foreach( var p in bi.Prerequisites ) - if (Rules.NewUnitInfo[p.ToLowerInvariant()].Traits.Get().Owner.Any(x => x == player.Race)) - if( playerBuildings[ p ].Count == 0 ) - return false; + if( playerBuildings[ p ].Count == 0 ) + return false; if( producesIndex[ Rules.UnitCategory[ info.Name ] ].All( x => playerBuildings[ x.Name ].Count == 0 ) ) return false; @@ -58,8 +57,7 @@ namespace OpenRa.Game.GameRules public IEnumerable AllItems(Player player, params string[] categories) { - return categories.SelectMany(x => Rules.Categories[x]).Select(x => Rules.NewUnitInfo[x].Name) - .Where(x => Rules.NewUnitInfo[x].Traits.Get().Owner.Contains(player.Race)); /* todo: fix for dual-race scenarios (captured buildings) */ + return categories.SelectMany(x => Rules.Categories[x]).Select(x => Rules.NewUnitInfo[x].Name); } public IEnumerable UnitBuiltAt( NewUnitInfo info ) From f1bbbac39d96f7707fa47987c4259c6b17169d54 Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 13 Jan 2010 00:08:44 +1300 Subject: [PATCH 77/83] "Alternate Names" aka pseudo-prerequisites. E7 and MSLO can be built again. --- OpenRa.Game/Chrome.cs | 12 +++++++++--- OpenRa.Game/GameRules/TechTree.cs | 6 ++++++ OpenRa.Game/Traits/Buildable.cs | 1 + RulesConverter/Program.cs | 3 ++- ra.yaml | 6 ++++-- rules.ini | 4 ++-- units.ini | 2 ++ 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 52ac6de270..3bf0f5c137 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -751,9 +751,7 @@ namespace OpenRa.Game if (!Rules.TechTree.CanBuild(info, Game.LocalPlayer, buildings)) { var prereqs = buildable.Prerequisites - .Select(a => Rules.NewUnitInfo[a.ToLowerInvariant()].Traits.Get()) - .Where( u => u.Owner.Any( o => o == Game.LocalPlayer.Race ) ) - .Select( a => a.Description ); + .Select( a => Description( a ) ); renderer.DrawText("Requires {0}".F( string.Join( ", ", prereqs.ToArray() ) ), p.ToInt2(), Color.White); } @@ -765,6 +763,14 @@ namespace OpenRa.Game } } + private static string Description( string a ) + { + if( a[ 0 ] == '@' ) + return "any " + a.Substring( 1 ); + else + return Rules.NewUnitInfo[ a.ToLowerInvariant() ].Traits.Get().Description; + } + void DrawSupportPowers() { var numPowers = Game.LocalPlayer.SupportPowers.Values diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 80bb04b47b..080eff3913 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -25,7 +25,13 @@ namespace OpenRa.Game.GameRules { var ret = new Cache>( x => new List() ); foreach( var b in Game.world.Actors.Where( x => x.Owner == player && x.Info != null && x.Info.Traits.Contains() ) ) + { ret[ b.Info.Name ].Add( b ); + var buildable = b.Info.Traits.GetOrDefault(); + if( buildable != null ) + foreach( var alt in buildable.AlternateName ) + ret[ alt ].Add( b ); + } return ret; } diff --git a/OpenRa.Game/Traits/Buildable.cs b/OpenRa.Game/Traits/Buildable.cs index 5a420533e6..8a15e43b8e 100755 --- a/OpenRa.Game/Traits/Buildable.cs +++ b/OpenRa.Game/Traits/Buildable.cs @@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits public readonly string Description = ""; public readonly string LongDesc = ""; public readonly string Icon = null; + public readonly string[] AlternateName = { }; } class Buildable { } diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 56eceaed5b..abfef1565a 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -81,7 +81,8 @@ namespace RulesConverter { "Cost", "Cost" }, { "Icon", "Icon" }, { "Description", "Description" }, - { "LongDesc", "LongDesc" } } + { "LongDesc", "LongDesc" }, + { "AlternateName", "AlternateName" } } }, { "Cargo", new PL { diff --git a/ra.yaml b/ra.yaml index ff7e9b5b79..4aee273e10 100644 --- a/ra.yaml +++ b/ra.yaml @@ -879,7 +879,7 @@ MSLO: Buildable: TechLevel: 13 Tab: Defense - Prerequisites: stek,atek + Prerequisites: @Tech Center Owner: soviet,allies Cost: 2500 Description: Missile Silo @@ -907,6 +907,7 @@ ATEK: Cost: 1500 Description: Allied Tech Center LongDesc: Provides Allied advanced technologies.\n Special Ability: GPS Satellite + AlternateName: @Tech Center Selectable: Priority: 3 Building: @@ -1226,6 +1227,7 @@ STEK: Cost: 1500 Description: Soviet Tech Center LongDesc: Provides Soviet advanced technologies + AlternateName: @Tech Center Selectable: Priority: 3 Building: @@ -2317,7 +2319,7 @@ E7: Buildable: TechLevel: 11 Tab: Infantry - Prerequisites: atek,stek + Prerequisites: @Tech Center Owner: allies,soviet Cost: 1200 Description: Tanya diff --git a/rules.ini b/rules.ini index 8b753341e0..13a31613ec 100644 --- a/rules.ini +++ b/rules.ini @@ -601,7 +601,7 @@ Infiltrate=yes ; Tanya [E7] -Prerequisite=atek,stek +Prerequisite=@Tech Center Primary=Colt45 Secondary=Colt45 Strength=100 @@ -1228,7 +1228,7 @@ ROT=30 ; big missile silo [MSLO] -Prerequisite=stek,atek +Prerequisite=@Tech Center Primary=none Strength=400 Armor=heavy diff --git a/units.ini b/units.ini index 0386e52630..c05a71a66b 100644 --- a/units.ini +++ b/units.ini @@ -353,6 +353,7 @@ Dimensions=2,2 Footprint=xx xx SelectionPriority=3 LongDesc=Provides Allied advanced technologies.\n Special Ability: GPS Satellite +AlternateName=@Tech Center [WEAP] Description=War Factory Traits=Building, RenderBuilding, RenderWarFactory, RallyPoint, Production, IronCurtainable @@ -448,6 +449,7 @@ Dimensions=3,2 Footprint=xxx xxx SelectionPriority=3 LongDesc=Provides Soviet advanced technologies +AlternateName=@Tech Center [BARR] Description=Soviet Barracks Traits=Building, RenderBuilding, RallyPoint, Production, IronCurtainable From ac9e58cf7343595bc573a2724372e47e22f5816d Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 13 Jan 2010 00:20:55 +1300 Subject: [PATCH 78/83] Only render units our race can build. That FACT prerequisite was unnecessary. --- OpenRa.Game/Chrome.cs | 1 + OpenRa.Game/GameRules/TechTree.cs | 2 +- OpenRa.Game/SupportPower.cs | 3 +-- ra.yaml | 1 - rules.ini | 1 - 5 files changed, 3 insertions(+), 5 deletions(-) diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 3bf0f5c137..e302e3cf27 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -532,6 +532,7 @@ namespace OpenRa.Game var allItems = Rules.TechTree.AllItems(Game.LocalPlayer, queueName) .Where(a => Rules.NewUnitInfo[a].Traits.Contains()) + .Where(a => Rules.NewUnitInfo[a].Traits.Get().Owner.Contains(Game.LocalPlayer.Race)) .OrderBy(a => Rules.NewUnitInfo[a].Traits.Get().TechLevel); var queue = Game.LocalPlayer.PlayerActor.traits.Get(); diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index 080eff3913..135d38dacd 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -40,7 +40,7 @@ namespace OpenRa.Game.GameRules var bi = info.Traits.GetOrDefault(); if( bi == null ) return false; - if( !bi.Owner.Any( x => x == player.Race ) ) + if( !bi.Owner.Contains( player.Race ) ) return false; foreach( var p in bi.Prerequisites ) diff --git a/OpenRa.Game/SupportPower.cs b/OpenRa.Game/SupportPower.cs index 074c36c7fc..75471de595 100644 --- a/OpenRa.Game/SupportPower.cs +++ b/OpenRa.Game/SupportPower.cs @@ -50,8 +50,7 @@ namespace OpenRa.Game var buildings = Rules.TechTree.GatherBuildings(Owner); var effectivePrereq = Info.Prerequisite .Select( a => a.ToLowerInvariant() ) - .Where( a => Rules.NewUnitInfo[a].Traits.Get().Owner - .Any( r => r == Owner.Race )); + .Where( a => Rules.NewUnitInfo[a].Traits.Get().Owner.Contains( Owner.Race )); IsAvailable = Info.TechLevel > -1 && effectivePrereq.Any() diff --git a/ra.yaml b/ra.yaml index 4aee273e10..ee0f4cd8ee 100644 --- a/ra.yaml +++ b/ra.yaml @@ -1172,7 +1172,6 @@ POWR: Buildable: TechLevel: 1 Tab: Building - Prerequisites: fact Owner: allies,soviet Cost: 300 Description: Power Plant diff --git a/rules.ini b/rules.ini index 13a31613ec..1bb007ac1a 100644 --- a/rules.ini +++ b/rules.ini @@ -1256,7 +1256,6 @@ Crewed=yes ; normal power plant [POWR] -Prerequisite=fact Strength=400 Armor=wood TechLevel=1 From 35a4308476b7a31e0bff7c73410ce0390b523cd9 Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 13 Jan 2010 00:53:28 +1300 Subject: [PATCH 79/83] bugfix ("MovementType: Track" is actually in the emitted yaml now!) and some slight changes to how the optimizer works. --- RulesConverter/MiniYamlExts.cs | 36 ++++--- aftermath.yaml | 8 ++ defaults.yaml | 12 ++- ra.yaml | 167 +++++---------------------------- 4 files changed, 63 insertions(+), 160 deletions(-) diff --git a/RulesConverter/MiniYamlExts.cs b/RulesConverter/MiniYamlExts.cs index ce7825beea..fcf0220e65 100755 --- a/RulesConverter/MiniYamlExts.cs +++ b/RulesConverter/MiniYamlExts.cs @@ -30,8 +30,9 @@ namespace RulesConverter public static IEnumerable ToLines( this MiniYaml y, string name ) { yield return name + ": " + y.Value; - foreach( var line in y.Nodes.ToLines( false ) ) - yield return "\t" + line; + if( y.Nodes != null ) + foreach( var line in y.Nodes.ToLines( false ) ) + yield return "\t" + line; } public static void OptimizeInherits( this MiniYamlNodes y, MiniYamlNodes baseYaml ) @@ -39,19 +40,26 @@ namespace RulesConverter foreach( var key in y.Keys.ToList() ) { var node = y[ key ]; - MiniYaml inherits; - node.Nodes.TryGetValue( "Inherits", out inherits ); - if( inherits == null || string.IsNullOrEmpty( inherits.Value ) ) - continue; + try + { + MiniYaml inherits; + node.Nodes.TryGetValue( "Inherits", out inherits ); + if( inherits == null || string.IsNullOrEmpty( inherits.Value ) ) + continue; - MiniYaml parent; - baseYaml.TryGetValue( inherits.Value, out parent ); - if( parent == null ) - continue; + MiniYaml parent; + baseYaml.TryGetValue( inherits.Value, out parent ); + if( parent == null ) + continue; - y[ key ] = Diff( node, parent ); - if( y[ key ] == null ) - y.Remove( key ); + y[ key ] = Diff( node, parent ); + if( y[ key ] == null ) + y.Remove( key ); + } + catch + { + node.Nodes.Remove( "Inherits" ); + } } } @@ -92,7 +100,7 @@ namespace RulesConverter return a; var diff = Diff( a.Nodes, b.Nodes ); - if( diff == null ) + if( diff == null && a.Value == b.Value ) return null; return new MiniYaml( a.Value, diff ); } diff --git a/aftermath.yaml b/aftermath.yaml index 3f905e70f8..60f7a3fc79 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -5,6 +5,8 @@ STNK: Armor: heavy Sight: 5 Speed: 10 + Mobile: + MovementType: Track Turreted: AttackTurreted: PrimaryWeapon: APTusk @@ -27,6 +29,8 @@ TTNK: Crewed: yes Sight: 7 Speed: 8 + Mobile: + MovementType: Track AttackBase: PrimaryWeapon: TTankZap RenderUnitSpinner: @@ -45,6 +49,8 @@ CTNK: Armor: light Sight: 5 Speed: 5 + Mobile: + MovementType: Track AttackBase: PrimaryWeapon: APTusk RenderUnit: @@ -84,6 +90,8 @@ QTNK: Crewed: no Sight: 6 Speed: 3 + Mobile: + MovementType: Track RenderUnit: MSUB: diff --git a/defaults.yaml b/defaults.yaml index cd9cc60525..a070f35542 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -15,13 +15,19 @@ DefaultInfantry: Mobile: MovementType: Foot Selectable: - + DefaultShip: Unit: Mobile: MovementType: Float Selectable: - + DefaultPlane: Unit: - Selectable: \ No newline at end of file + Selectable: + +DefaultBuilding: + Selectable: + Priority: 3 + Building: + diff --git a/ra.yaml b/ra.yaml index ee0f4cd8ee..9c64aa11c4 100644 --- a/ra.yaml +++ b/ra.yaml @@ -14,6 +14,8 @@ V2RL: Crewed: yes Sight: 5 Speed: 7 + Mobile: + MovementType: Track AttackBase: PrimaryWeapon: SCUD RenderUnitReload: @@ -35,6 +37,8 @@ V2RL: Crewed: yes Sight: 4 Speed: 9 + Mobile: + MovementType: Track Turreted: AttackTurreted: PrimaryWeapon: 75mm @@ -58,6 +62,8 @@ V2RL: Crewed: yes Sight: 5 Speed: 8 + Mobile: + MovementType: Track Turreted: AttackTurreted: PrimaryWeapon: 90mm @@ -81,6 +87,8 @@ V2RL: Crewed: yes Sight: 5 Speed: 7 + Mobile: + MovementType: Track Turreted: AttackTurreted: PrimaryWeapon: 105mm @@ -104,6 +112,8 @@ V2RL: Crewed: yes Sight: 6 Speed: 4 + Mobile: + MovementType: Track Turreted: AttackTurreted: PrimaryWeapon: 120mm @@ -131,6 +141,8 @@ MRJ: Crewed: yes Sight: 7 Speed: 9 + Mobile: + MovementType: Track RenderUnitSpinner: Offset: 0,4,0,-6 @@ -169,8 +181,11 @@ ARTY: HP: 75 Armor: light Crewed: yes + ROT: 2 Sight: 5 Speed: 6 + Mobile: + MovementType: Track AttackBase: PrimaryWeapon: 155mm RenderUnit: @@ -196,6 +211,8 @@ HARV: Crewed: yes Sight: 4 Speed: 6 + Mobile: + MovementType: Track RenderUnit: MCV: @@ -233,6 +250,7 @@ JEEP: HP: 150 Armor: light Crewed: yes + ROT: 10 Sight: 6 Speed: 10 Turreted: @@ -258,6 +276,8 @@ APC: Armor: heavy Sight: 5 Speed: 10 + Mobile: + MovementType: Track AttackBase: PrimaryWeapon: M60mg PrimaryOffset: 0,0,0,-4 @@ -286,6 +306,8 @@ MNLY.AP: Crewed: yes Sight: 5 Speed: 9 + Mobile: + MovementType: Track RenderUnit: Image: MNLY Minelayer: @@ -311,6 +333,8 @@ MNLY.AT: Crewed: yes Sight: 5 Speed: 9 + Mobile: + MovementType: Track RenderUnit: Image: MNLY Minelayer: @@ -908,8 +932,6 @@ ATEK: Description: Allied Tech Center LongDesc: Provides Allied advanced technologies.\n Special Ability: GPS Satellite AlternateName: @Tech Center - Selectable: - Priority: 3 Building: Power: -200 Footprint: xx xx @@ -934,8 +956,6 @@ WEAP: Cost: 2000 Description: War Factory LongDesc: Produces tanks & light vehicles. - Selectable: - Priority: 3 Building: Power: -30 Footprint: xxx xxx @@ -963,8 +983,6 @@ SYRD: Cost: 650 Description: Shipyard LongDesc: Produces and repairs ships - Selectable: - Priority: 3 Building: Power: -30 Footprint: xxx xxx xxx @@ -990,8 +1008,6 @@ SPEN: Cost: 650 Description: Sub Pen LongDesc: Produces and repairs submarines and \ntransports - Selectable: - Priority: 3 Building: Power: -30 Footprint: xxx xxx xxx @@ -1009,8 +1025,6 @@ SPEN: FACT: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Power: 0 Footprint: xxx xxx xxx @@ -1037,8 +1051,6 @@ PROC: Cost: 2000 Description: Ore Refinery LongDesc: Converts Ore and Gems into money - Selectable: - Priority: 3 Building: Power: -30 Footprint: _x_ xxx x== @@ -1066,8 +1078,6 @@ SILO: Cost: 150 Description: Silo LongDesc: Stores excess harvested Ore - Selectable: - Priority: 3 Building: Power: -10 Footprint: x @@ -1092,8 +1102,6 @@ HPAD: Cost: 1500 Description: Helipad LongDesc: Produces and reloads helicopters - Selectable: - Priority: 3 Building: Power: -10 Footprint: xx xx @@ -1122,8 +1130,6 @@ DOME: Cost: 1000 Description: Radar Dome LongDesc: Provides an overview of the battlefield.\n Requires power to operate. - Selectable: - Priority: 3 Building: Power: -40 RequiresPower: true @@ -1149,8 +1155,6 @@ AFLD: Cost: 600 Description: Airstrip LongDesc: Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane - Selectable: - Priority: 3 Building: Power: -30 Footprint: xxx xxx @@ -1176,8 +1180,6 @@ POWR: Cost: 300 Description: Power Plant LongDesc: Provides power for other structures - Selectable: - Priority: 3 Building: Power: 100 Footprint: xx xx @@ -1201,8 +1203,6 @@ APWR: Cost: 500 Description: Advanced Power Plant LongDesc: Provides more power, cheaper than the \nstandard Power Plant - Selectable: - Priority: 3 Building: Power: 200 Footprint: ___ xxx xxx @@ -1227,8 +1227,6 @@ STEK: Description: Soviet Tech Center LongDesc: Provides Soviet advanced technologies AlternateName: @Tech Center - Selectable: - Priority: 3 Building: Power: -100 Footprint: xxx xxx @@ -1252,8 +1250,6 @@ BARR: Cost: 300 Description: Soviet Barracks LongDesc: Produces infantry - Selectable: - Priority: 3 Building: Power: -20 Footprint: xx xx @@ -1280,8 +1276,6 @@ TENT: Cost: 300 Description: Allied Barracks LongDesc: Produces infantry - Selectable: - Priority: 3 Building: Power: -20 Footprint: xx xx @@ -1308,8 +1302,6 @@ KENN: Cost: 200 Description: Kennel LongDesc: Produces attack dogs - Selectable: - Priority: 3 Building: Power: -10 Footprint: x @@ -1332,8 +1324,6 @@ FIX: Cost: 1200 Description: Service Depot LongDesc: Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases. - Selectable: - Priority: 3 Building: Power: -30 Footprint: _x_ xxx _x_ @@ -1357,8 +1347,6 @@ FACF: Cost: 50 Description: Fake Construction Yard LongDesc: Looks like a Construction Yard. - Selectable: - Priority: 3 Building: Power: -2 Footprint: xxx xxx xxx @@ -1383,8 +1371,6 @@ WEAF: Cost: 50 Description: Fake War Factory LongDesc: Looks like a War Factory. - Selectable: - Priority: 3 Building: Power: -2 Footprint: xxx xxx @@ -1410,8 +1396,6 @@ SYRF: Cost: 50 Description: Fake Shipyard LongDesc: Looks like a Shipyard - Selectable: - Priority: 3 Building: Power: -2 Footprint: xxx xxx xxx @@ -1428,8 +1412,6 @@ SYRF: SPEF: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Power: -2 Footprint: xxx xxx xxx @@ -1454,8 +1436,6 @@ DOMF: Cost: 50 Description: Fake Radar Dome LongDesc: Looks like a Radar Dome - Selectable: - Priority: 3 Building: Power: -2 Footprint: xx xx @@ -1470,7 +1450,6 @@ DOMF: Fake: MINP: - Inherits: DefaultBuilding Unit: HP: 1 RenderUnit: @@ -1479,7 +1458,6 @@ MINP: InvisibleToOthers: MINV: - Inherits: DefaultBuilding Unit: HP: 1 RenderUnit: @@ -1488,147 +1466,126 @@ MINV: InvisibleToOthers: T01: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T02: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T03: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T05: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T06: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T07: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T08: - Inherits: DefaultBuilding Building: Footprint: x_ Dimensions: 2,1 RenderBuilding: T10: - Inherits: DefaultBuilding Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: T11: - Inherits: DefaultBuilding Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: T12: - Inherits: DefaultBuilding Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: T13: - Inherits: DefaultBuilding Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: T14: - Inherits: DefaultBuilding Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: T15: - Inherits: DefaultBuilding Building: Footprint: xx xx Dimensions: 2,2 RenderBuilding: T16: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: T17: - Inherits: DefaultBuilding Building: Footprint: x_ x_ Dimensions: 2,2 RenderBuilding: TC01: - Inherits: DefaultBuilding Building: Footprint: xx_ xx_ Dimensions: 3,2 RenderBuilding: TC02: - Inherits: DefaultBuilding Building: Footprint: xx_ xx_ Dimensions: 3,2 RenderBuilding: TC03: - Inherits: DefaultBuilding Building: Footprint: xx_ xx_ Dimensions: 3,2 RenderBuilding: TC04: - Inherits: DefaultBuilding Building: Footprint: xxx_ xxx_ xxx_ Dimensions: 4,3 RenderBuilding: TC05: - Inherits: DefaultBuilding Building: Footprint: xxx_ xxx_ xxx_ Dimensions: 4,3 RenderBuilding: MINE: - Inherits: DefaultBuilding Building: Footprint: x Dimensions: 1,1 @@ -1637,8 +1594,6 @@ MINE: FCOM: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Power: -200 Footprint: xx xx @@ -1653,8 +1608,6 @@ FCOM: V01: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx xx Dimensions: 2,2 @@ -1666,8 +1619,6 @@ V01: V02: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx xx Dimensions: 2,2 @@ -1678,8 +1629,6 @@ V02: V03: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx xx Dimensions: 2,2 @@ -1690,8 +1639,6 @@ V03: V04: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx xx Dimensions: 2,2 @@ -1702,8 +1649,6 @@ V04: V05: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx Dimensions: 2,1 @@ -1714,8 +1659,6 @@ V05: V06: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx Dimensions: 2,1 @@ -1726,8 +1669,6 @@ V06: V07: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: xx Dimensions: 2,1 @@ -1738,8 +1679,6 @@ V07: V08: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1750,8 +1689,6 @@ V08: V09: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1762,8 +1699,6 @@ V09: V10: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1774,8 +1709,6 @@ V10: V11: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1786,8 +1719,6 @@ V11: V12: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1798,8 +1729,6 @@ V12: V13: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1810,8 +1739,6 @@ V13: V14: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1822,8 +1749,6 @@ V14: V15: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1834,8 +1759,6 @@ V15: V16: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1846,8 +1769,6 @@ V16: V17: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1858,8 +1779,6 @@ V17: V18: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1870,8 +1789,6 @@ V18: V19: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Footprint: x Dimensions: 1,1 @@ -1882,8 +1799,6 @@ V19: V20: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1893,8 +1808,6 @@ V20: V21: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1904,8 +1817,6 @@ V21: V22: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1915,8 +1826,6 @@ V22: V23: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1926,8 +1835,6 @@ V23: V24: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1937,8 +1844,6 @@ V24: V25: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1948,8 +1853,6 @@ V25: V26: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1959,8 +1862,6 @@ V26: V27: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1970,8 +1871,6 @@ V27: V28: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1981,8 +1880,6 @@ V28: V29: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -1992,8 +1889,6 @@ V29: V30: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2003,8 +1898,6 @@ V30: V31: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2014,8 +1907,6 @@ V31: V32: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2025,8 +1916,6 @@ V32: V33: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2036,8 +1925,6 @@ V33: V34: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2047,8 +1934,6 @@ V34: V35: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2058,8 +1943,6 @@ V35: V36: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 @@ -2069,8 +1952,6 @@ V36: V37: Inherits: DefaultBuilding - Selectable: - Priority: 3 Building: Repairable: false HP: 400 From 6f8eccb1b9e4ad7ed50807690e8f5c529328b418 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 13 Jan 2010 08:26:37 +1300 Subject: [PATCH 80/83] kill old output from rulesconv --- out.rul | 1477 ------------------------------------------------------- 1 file changed, 1477 deletions(-) delete mode 100644 out.rul diff --git a/out.rul b/out.rul deleted file mode 100644 index c165256316..0000000000 --- a/out.rul +++ /dev/null @@ -1,1477 +0,0 @@ -V2RL: - Inherits: DefaultVehicle - Buildable: - TechLevel: 4 - Tab: Vehicle - Prerequisites: [weap,dome] - Owner: soviet - Cost: 700 - Description: "V2 Rocket" - LongDesc: "Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 150 - Armor: light - Crewed: yes - Mobile: - Sight: 5 - ROT: 5 - Speed: 7 - AttackBase: - RenderUnitReload: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -1TNK: - Inherits: DefaultVehicle - Buildable: - TechLevel: 4 - Tab: Vehicle - Prerequisites: [weap] - Owner: allies - Cost: 700 - Description: "Light Tank" - LongDesc: "Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 300 - Armor: heavy - Crewed: yes - Mobile: - Sight: 4 - ROT: 5 - Speed: 9 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -2TNK: - Inherits: DefaultVehicle - Buildable: - TechLevel: 6 - Tab: Vehicle - Prerequisites: [weap] - Owner: allies - Cost: 800 - Description: "Medium Tank" - LongDesc: "Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 400 - Armor: heavy - Crewed: yes - Mobile: - Sight: 5 - ROT: 5 - Speed: 8 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -3TNK: - Inherits: DefaultVehicle - Buildable: - TechLevel: 4 - Tab: Vehicle - Prerequisites: [weap] - Owner: soviet - Cost: 950 - Description: "Heavy Tank" - LongDesc: "Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 400 - Armor: heavy - Crewed: yes - Mobile: - Sight: 5 - ROT: 5 - Speed: 7 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -4TNK: - Inherits: DefaultVehicle - Buildable: - TechLevel: 10 - Tab: Vehicle - Prerequisites: [weap,stek] - Owner: soviet - Cost: 1700 - Description: "Mammoth Tank" - LongDesc: "Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" - Selectable: - Voice: VehicleVoice - Unit: - HP: 600 - Armor: heavy - Crewed: yes - Mobile: - Sight: 6 - ROT: 5 - Speed: 4 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -MRJ: - Inherits: DefaultVehicle - Buildable: - TechLevel: 12 - Tab: Vehicle - Prerequisites: [weap,dome] - Owner: allies - Cost: 600 - Description: "Radar Jammer" - LongDesc: "Hides nearby units on the enemy's minimap.\n Unarmed" - Selectable: - Priority: 3 - Voice: VehicleVoice - Unit: - HP: 110 - Armor: light - Crewed: yes - Mobile: - Sight: 7 - ROT: 5 - Speed: 9 - RenderUnitSpinner: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -MGG: - Inherits: DefaultVehicle - Buildable: - TechLevel: 11 - Tab: Vehicle - Prerequisites: [weap,atek] - Owner: allies - Cost: 600 - Description: "Mobile Gap Generator" - LongDesc: "Regenerates Fog of War in a small area \naround the unit.\n Unarmed" - Selectable: - Priority: 3 - Voice: VehicleVoice - Unit: - HP: 110 - Armor: light - Crewed: yes - Mobile: - Sight: 4 - ROT: 5 - Speed: 9 - RenderUnitSpinner: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -ARTY: - Inherits: DefaultVehicle - Buildable: - TechLevel: 8 - Tab: Vehicle - Prerequisites: [weap] - Owner: allies - Cost: 600 - Description: "Artillery" - LongDesc: "Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 75 - Armor: light - Crewed: yes - Mobile: - Sight: 5 - ROT: 2 - Speed: 6 - AttackBase: - RenderUnit: - Explodes: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -HARV: - Inherits: DefaultVehicle - Buildable: - TechLevel: 1 - Tab: Vehicle - Prerequisites: [weap,proc] - Owner: allies,soviet - Cost: 1400 - Description: "Ore Truck" - LongDesc: "Collects Ore and Gems for processing.\n Unarmed" - Selectable: - Priority: 7 - Voice: VehicleVoice - Harvester: - Unit: - HP: 600 - Armor: heavy - Crewed: yes - Mobile: - Sight: 4 - ROT: 5 - Speed: 6 - RenderUnit: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -MCV: - Inherits: DefaultVehicle - Buildable: - TechLevel: 11 - Tab: Vehicle - Prerequisites: [weap,fix] - Owner: allies,soviet - Cost: 2500 - Description: "Mobile Construction Vehicle" - LongDesc: "Deploys into another Construction Yard.\n Unarmed" - Selectable: - Priority: 3 - Voice: VehicleVoice - Unit: - HP: 600 - Armor: light - Crewed: yes - Mobile: - Sight: 4 - ROT: 5 - Speed: 6 - McvDeploy: - RenderUnit: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -JEEP: - Inherits: DefaultVehicle - Buildable: - TechLevel: 3 - Tab: Vehicle - Prerequisites: [weap] - Owner: allies - Cost: 600 - Description: "Ranger" - LongDesc: "Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 150 - Armor: light - Crewed: yes - Mobile: - Sight: 6 - ROT: 10 - Speed: 10 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Repairable: - Chronoshiftable: - Passenger: - IronCurtainable: - -APC: - Inherits: DefaultVehicle - Buildable: - TechLevel: 5 - Tab: Vehicle - Prerequisites: [weap,tent] - Owner: allies - Cost: 800 - Description: "Armored Personnel Carrier" - LongDesc: "Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" - Selectable: - Voice: VehicleVoice - Unit: - HP: 200 - Armor: heavy - Mobile: - Sight: 5 - ROT: 5 - Speed: 10 - AttackBase: - RenderUnitMuzzleFlash: - AutoTarget: - Repairable: - Chronoshiftable: - Cargo: - PassengerTypes: [Foot] - Passenger: - IronCurtainable: - -MNLY.AP: - Inherits: DefaultVehicle - Buildable: - TechLevel: 3 - Tab: Vehicle - Prerequisites: [weap,fix] - Owner: soviet - Cost: 800 - Icon: MNLYICON - Description: "Minelayer (Anti-Personnel)" - LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" - Selectable: - Voice: VehicleVoice - Unit: - HP: 100 - Armor: heavy - Crewed: yes - Mobile: - Sight: 5 - ROT: 5 - Speed: 9 - RenderUnit: - Image: MNLY - Minelayer: - MineImmune: - Repairable: - LimitedAmmo: - Ammo: 5 - Chronoshiftable: - Passenger: - IronCurtainable: - -MNLY.AT: - Inherits: DefaultVehicle - Buildable: - TechLevel: 3 - Tab: Vehicle - Prerequisites: [weap,fix] - Owner: allies - Cost: 800 - Icon: MNLYICON - Description: "Minelayer (Anti-Tank)" - LongDesc: "Lays mines to destroy unwary enemy units.\n Unarmed" - Selectable: - Voice: VehicleVoice - Unit: - HP: 100 - Armor: heavy - Crewed: yes - Mobile: - Sight: 5 - ROT: 5 - Speed: 9 - RenderUnit: - Image: MNLY - Minelayer: - MineImmune: - Repairable: - LimitedAmmo: - Ammo: 5 - Chronoshiftable: - Passenger: - IronCurtainable: - -SS: - Inherits: DefaultShip - Buildable: - TechLevel: 5 - Tab: Ship - Prerequisites: [spen] - Owner: soviet - Cost: 950 - Description: "Submarine" - LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" - Selectable: - Unit: - HP: 120 - Armor: light - Mobile: - Sight: 6 - ROT: 7 - Speed: 6 - RenderUnit: - Submarine: - AttackBase: - Chronoshiftable: - IronCurtainable: - -DD: - Inherits: DefaultShip - Buildable: - TechLevel: 7 - Tab: Ship - Prerequisites: [syrd] - Owner: allies - Cost: 1000 - Description: "Destroyer" - LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" - Selectable: - Unit: - HP: 400 - Armor: heavy - Mobile: - Sight: 6 - ROT: 7 - Speed: 6 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Chronoshiftable: - IronCurtainable: - -CA: - Inherits: DefaultShip - Buildable: - TechLevel: 10 - Tab: Ship - Prerequisites: [syrd,atek] - Owner: allies - Cost: 2000 - Description: "Cruiser" - LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" - Selectable: - Unit: - HP: 700 - Armor: heavy - Mobile: - Sight: 7 - ROT: 5 - Speed: 4 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Chronoshiftable: - IronCurtainable: - -LST: - Inherits: DefaultShip - Buildable: - TechLevel: 3 - Tab: Ship - Owner: allies,soviet - Cost: 700 - Description: "Transport" - LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" - Selectable: - Unit: - HP: 350 - Armor: heavy - Mobile: - Sight: 6 - ROT: 10 - Speed: 14 - RenderUnit: - Cargo: - PassengerTypes: [Foot,Wheel,Track] - IronCurtainable: - -PT: - Inherits: DefaultShip - Buildable: - TechLevel: 5 - Tab: Ship - Prerequisites: [syrd] - Owner: allies - Cost: 500 - Description: "Gunboat" - LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" - Selectable: - Unit: - HP: 200 - Armor: heavy - Mobile: - Sight: 7 - ROT: 7 - Speed: 9 - Turreted: - AttackTurreted: - RenderUnitTurreted: - AutoTarget: - Chronoshiftable: - IronCurtainable: - -MIG: - Inherits: DefaultPlane - Buildable: - TechLevel: 10 - Tab: Plane - Prerequisites: [afld] - Owner: soviet - Cost: 1200 - Description: "Mig Attack Plane" - LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" - Selectable: - Unit: - HP: 50 - Armor: light - AttackPlane: - Plane: - ROT: 5 - Speed: 20 - RenderUnit: - WithShadow: - LimitedAmmo: - Ammo: 3 - IronCurtainable: - -YAK: - Inherits: DefaultPlane - Buildable: - TechLevel: 5 - Tab: Plane - Prerequisites: [afld] - Owner: soviet - Cost: 800 - Description: "Yak Attack Plane" - LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" - Selectable: - Unit: - HP: 60 - Armor: light - Crewed: yes - AttackPlane: - Plane: - ROT: 5 - Speed: 16 - RenderUnit: - WithShadow: - LimitedAmmo: - Ammo: 15 - IronCurtainable: - -TRAN: - Inherits: DefaultPlane - Buildable: - TechLevel: 11 - Tab: Plane - Prerequisites: [hpad] - Owner: allies - Cost: 1200 - Description: "Transport Helicopter" - LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" - Selectable: - Unit: - HP: 90 - Armor: light - Helicopter: - ROT: 5 - Speed: 12 - RenderUnitRotor: - WithShadow: - Cargo: - PassengerTypes: [Foot] - IronCurtainable: - -HELI: - Inherits: DefaultPlane - Buildable: - TechLevel: 9 - Tab: Plane - Prerequisites: [hpad] - Owner: allies - Cost: 1200 - Description: "Longbow" - LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" - Selectable: - Unit: - HP: 225 - Armor: heavy - Crewed: yes - AttackHeli: - Helicopter: - ROT: 4 - Speed: 16 - RenderUnitRotor: - WithShadow: - LimitedAmmo: - Ammo: 6 - IronCurtainable: - -HIND: - Inherits: DefaultPlane - Buildable: - TechLevel: 9 - Tab: Plane - Prerequisites: [hpad] - Owner: allies - Cost: 1200 - Description: "Hind" - LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" - Selectable: - Unit: - HP: 225 - Armor: heavy - Crewed: yes - AttackHeli: - Helicopter: - ROT: 4 - Speed: 12 - RenderUnitRotor: - WithShadow: - LimitedAmmo: - Ammo: 12 - IronCurtainable: - -IRON: - Inherits: DefaultDefense - Buildable: - TechLevel: 12 - Tab: Defense - Prerequisites: [stek] - Owner: soviet - Cost: 2800 - Description: "Iron Curtain" - LongDesc: "Makes a group of units invulnerable for a \nshort time.\n Special Ability: Invulnerability" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - IronCurtain: - -PDOX: - Inherits: DefaultDefense - Buildable: - TechLevel: 12 - Tab: Defense - Prerequisites: [atek] - Owner: allies - Cost: 2800 - Description: "Chronosphere" - LongDesc: "Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift" - Selectable: - Priority: 3 - Building: - RenderBuilding: - Chronosphere: - IronCurtainable: - -PBOX: - Inherits: DefaultDefense - Buildable: - TechLevel: 2 - Tab: Defense - Prerequisites: [tent] - Owner: allies - Cost: 400 - Description: "Pillbox" - LongDesc: "Basic defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" - Selectable: - Priority: 3 - Building: - Turreted: - RenderBuilding: - AttackTurreted: - AutoTarget: - IronCurtainable: - -HBOX: - Inherits: DefaultDefense - Buildable: - TechLevel: 3 - Tab: Defense - Prerequisites: [tent] - Owner: allies - Cost: 600 - Description: "Camo Pillbox" - LongDesc: "Hidden defensive structure.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft" - Selectable: - Priority: 3 - Building: - Turreted: - RenderBuilding: - AttackTurreted: - AutoTarget: - IronCurtainable: - -TSLA: - Inherits: DefaultDefense - Buildable: - TechLevel: 7 - Tab: Defense - Prerequisites: [weap] - Owner: soviet - Cost: 1500 - Description: "Tesla Coil" - LongDesc: "Advanced base defense. Requires power\nto operate.\n Strong vs Tanks, Infantry\n Weak vs Aircraft" - Selectable: - Priority: 3 - Building: - Turreted: - RenderBuildingCharge: - AttackTurreted: - AutoTarget: - IronCurtainable: - -GUN: - Inherits: DefaultDefense - Buildable: - TechLevel: 4 - Tab: Defense - Prerequisites: [tent] - Owner: allies - Cost: 600 - Description: "Turret" - LongDesc: "Anti-Armor base defense.\n Strong vs Tanks\n Weak vs Infantry, Aircraft" - Selectable: - Priority: 3 - Building: - Turreted: - RenderBuildingTurreted: - AttackTurreted: - AutoTarget: - IronCurtainable: - -AGUN: - Inherits: DefaultDefense - Buildable: - TechLevel: 5 - Tab: Defense - Prerequisites: [dome] - Owner: allies - Cost: 600 - Description: "AA Gun" - LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" - Selectable: - Priority: 3 - Building: - Turreted: - RenderBuildingTurreted: - AttackTurreted: - AutoTarget: - IronCurtainable: - -FTUR: - Inherits: DefaultDefense - Buildable: - TechLevel: 2 - Tab: Defense - Prerequisites: [barr] - Owner: soviet - Cost: 600 - Description: "Flame Turret" - LongDesc: "Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft" - Selectable: - Priority: 3 - Turreted: - Building: - RenderBuilding: - AttackTurreted: - AutoTarget: - IronCurtainable: - -GAP: - Inherits: DefaultDefense - Buildable: - TechLevel: 10 - Tab: Defense - Prerequisites: [atek] - Owner: allies - Cost: 500 - Description: "Gap Generator" - LongDesc: "Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - -SAM: - Inherits: DefaultDefense - Buildable: - TechLevel: 9 - Tab: Defense - Prerequisites: [dome] - Owner: soviet - Cost: 750 - Description: "SAM Site" - LongDesc: "Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks" - Selectable: - Priority: 3 - Building: - Turreted: - RenderBuildingTurreted: - AttackTurreted: - AutoTarget: - IronCurtainable: - -MSLO: - Inherits: DefaultDefense - Buildable: - TechLevel: 13 - Tab: Defense - Prerequisites: [stek,atek] - Owner: soviet,allies - Cost: 2500 - Description: "Missile Silo" - LongDesc: "Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - -ATEK: - Inherits: DefaultBuilding - Buildable: - TechLevel: 10 - Tab: Building - Prerequisites: [weap,dome] - Owner: allies - Cost: 1500 - Description: "Allied Tech Center" - LongDesc: "Provides Allied advanced technologies.\n Special Ability: GPS Satellite" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - GpsLaunchSite: - -WEAP: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [proc] - Owner: soviet,allies - Cost: 2000 - Description: "War Factory" - LongDesc: "Produces tanks & light vehicles." - Selectable: - Priority: 3 - Building: - RenderWarFactory: - RenderBuilding: - RallyPoint: - Production: - IronCurtainable: - -SYRD: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [powr] - Owner: allies - Cost: 650 - Description: "Shipyard" - LongDesc: "Produces and repairs ships" - Selectable: - Priority: 3 - Building: - RenderBuilding: - ProductionSurround: - IronCurtainable: - -SPEN: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [powr] - Owner: soviet - Cost: 650 - Description: "Sub Pen" - LongDesc: "Produces and repairs submarines and \ntransports" - Selectable: - Priority: 3 - Building: - RenderBuilding: - ProductionSurround: - IronCurtainable: - -FACT: - Inherits: DefaultBuilding - Selectable: - Priority: 3 - Building: - RenderBuilding: - ConstructionYard: - IronCurtainable: - -PROC: - Inherits: DefaultBuilding - Buildable: - TechLevel: 1 - Tab: Building - Prerequisites: [powr] - Owner: allies,soviet - Cost: 2000 - Description: "Ore Refinery" - LongDesc: "Converts Ore and Gems into money" - Selectable: - Priority: 3 - Building: - RenderBuilding: - AcceptsOre: - StoresOre: - IronCurtainable: - -SILO: - Inherits: DefaultBuilding - Buildable: - TechLevel: 1 - Tab: Building - Prerequisites: [proc] - Owner: allies,soviet - Cost: 150 - Description: "Silo" - LongDesc: "Stores excess harvested Ore" - Selectable: - Priority: 3 - Building: - RenderBuildingOre: - StoresOre: - IronCurtainable: - -HPAD: - Inherits: DefaultBuilding - Buildable: - TechLevel: 9 - Tab: Building - Prerequisites: [dome] - Owner: allies - Cost: 1500 - Description: "Helipad" - LongDesc: "Produces and reloads helicopters" - Selectable: - Priority: 3 - Building: - RenderBuilding: - Production: - BelowUnits: - Reservable: - IronCurtainable: - -DOME: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [proc] - Owner: allies,soviet - Cost: 1000 - Description: "Radar Dome" - LongDesc: "Provides an overview of the battlefield.\n Requires power to operate." - Selectable: - Priority: 3 - Building: - RenderBuilding: - ProvidesRadar: - IronCurtainable: - -AFLD: - Inherits: DefaultBuilding - Buildable: - TechLevel: 5 - Tab: Building - Prerequisites: [dome] - Owner: soviet - Cost: 600 - Description: "Airstrip" - LongDesc: "Produces and reloads planes\n Special Ability: Paratroopers\n Special Ability: Spy Plane" - Selectable: - Priority: 3 - Building: - RenderBuilding: - Production: - BelowUnits: - Reservable: - IronCurtainable: - -POWR: - Inherits: DefaultBuilding - Buildable: - TechLevel: 1 - Tab: Building - Prerequisites: [fact] - Owner: allies,soviet - Cost: 300 - Description: "Power Plant" - LongDesc: "Provides power for other structures" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - -APWR: - Inherits: DefaultBuilding - Buildable: - TechLevel: 8 - Tab: Building - Prerequisites: [powr] - Owner: allies,soviet - Cost: 500 - Description: "Advanced Power Plant" - LongDesc: "Provides more power, cheaper than the \nstandard Power Plant" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - -STEK: - Inherits: DefaultBuilding - Buildable: - TechLevel: 6 - Tab: Building - Prerequisites: [weap,dome] - Owner: soviet - Cost: 1500 - Description: "Soviet Tech Center" - LongDesc: "Provides Soviet advanced technologies" - Selectable: - Priority: 3 - Building: - RenderBuilding: - IronCurtainable: - -BARR: - Inherits: DefaultBuilding - Buildable: - TechLevel: 1 - Tab: Building - Prerequisites: [powr] - Owner: soviet - Cost: 300 - Description: "Soviet Barracks" - LongDesc: "Produces infantry" - Selectable: - Priority: 3 - Building: - RenderBuilding: - RallyPoint: - Production: - IronCurtainable: - -TENT: - Inherits: DefaultBuilding - Buildable: - TechLevel: 1 - Tab: Building - Prerequisites: [powr] - Owner: allies - Cost: 300 - Description: "Allied Barracks" - LongDesc: "Produces infantry" - Selectable: - Priority: 3 - Building: - RenderBuilding: - RallyPoint: - Production: - IronCurtainable: - -KENN: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [barr] - Owner: soviet - Cost: 200 - Description: "Kennel" - LongDesc: "Produces attack dogs" - Selectable: - Priority: 3 - Building: - RenderBuilding: - RallyPoint: - Production: - IronCurtainable: - -FIX: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [weap] - Owner: allies,soviet - Cost: 1200 - Description: "Service Depot" - LongDesc: "Repairs vehicles, reloads minelayers, and \nallows the construction of additional bases." - Selectable: - Priority: 3 - Building: - RenderBuilding: - BelowUnits: - Reservable: - IronCurtainable: - -FACF: - Inherits: DefaultBuilding - Buildable: - TechLevel: 1 - Tab: Building - Owner: allies - Cost: 50 - Description: "Fake Construction Yard" - LongDesc: "Looks like a Construction Yard." - Selectable: - Priority: 3 - Building: - RenderBuilding: - Image: FACT - Fake: - IronCurtainable: - -WEAF: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [proc] - Owner: allies - Cost: 50 - Description: "Fake War Factory" - LongDesc: "Looks like a War Factory." - Selectable: - Priority: 3 - Building: - RenderWarFactory: - RenderBuilding: - Image: WEAP - Fake: - IronCurtainable: - -SYRF: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [powr] - Owner: allies - Cost: 50 - Description: "Fake Shipyard" - LongDesc: "Looks like a Shipyard" - Selectable: - Priority: 3 - Building: - RenderBuilding: - Image: SYRD - Fake: - -SPEF: - Inherits: DefaultBuilding - Selectable: - Priority: 3 - Building: - RenderBuilding: - Image: SPEN - Fake: - -DOMF: - Inherits: DefaultBuilding - Buildable: - TechLevel: 3 - Tab: Building - Prerequisites: [proc] - Owner: allies - Cost: 50 - Description: "Fake Radar Dome" - LongDesc: "Looks like a Radar Dome" - Selectable: - Priority: 3 - Building: - RenderBuilding: - Image: DOME - Fake: - -MINP: - Inherits: DefaultBuilding - Unit: - HP: 1 - RenderUnit: - APMine: - BelowUnits: - InvisibleToOthers: - -MINV: - Inherits: DefaultBuilding - Unit: - HP: 1 - RenderUnit: - ATMine: - BelowUnits: - InvisibleToOthers: - -DOG: - Inherits: DefaultInfantry - Buildable: - TechLevel: 3 - Tab: Infantry - Prerequisites: [kenn] - Owner: soviet - Cost: 200 - Description: "Attack Dog" - LongDesc: "Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles" - Selectable: - Voice: DogVoice - Bounds: [12,17,-1,-4] - Unit: - HP: 12 - Armor: none - Mobile: - Sight: 5 - Speed: 4 - RenderInfantry: - Passenger: - -E1: - Inherits: DefaultInfantry - Buildable: - TechLevel: 1 - Tab: Infantry - Owner: allies,soviet - Cost: 100 - Description: "Rifle Infantry" - LongDesc: "General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles" - Selectable: - Bounds: [12,17,0,-9] - Unit: - HP: 50 - Armor: none - Mobile: - Sight: 4 - Speed: 4 - RenderInfantry: - AttackBase: - TakeCover: - SquishByTank: - AutoTarget: - Passenger: - -E2: - Inherits: DefaultInfantry - Buildable: - TechLevel: 1 - Tab: Infantry - Owner: soviet - Cost: 160 - Description: "Grenadier" - LongDesc: "Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles" - Selectable: - Bounds: [12,17,0,-9] - Unit: - HP: 50 - Armor: none - Mobile: - Sight: 4 - Speed: 5 - RenderInfantry: - AttackBase: - TakeCover: - SquishByTank: - AutoTarget: - Passenger: - -E3: - Inherits: DefaultInfantry - Buildable: - TechLevel: 2 - Tab: Infantry - Owner: allies,soviet - Cost: 300 - Description: "Rocket Soldier" - LongDesc: "Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry" - Selectable: - Bounds: [12,17,0,-9] - Unit: - HP: 45 - Armor: none - Mobile: - Sight: 4 - Speed: 3 - RenderInfantry: - AttackBase: - TakeCover: - SquishByTank: - AutoTarget: - Passenger: - -E4: - Inherits: DefaultInfantry - Buildable: - TechLevel: 6 - Tab: Infantry - Prerequisites: [stek] - Owner: soviet - Cost: 300 - Description: "Flamethrower" - LongDesc: "Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles" - Selectable: - Bounds: [12,17,0,-9] - Unit: - HP: 40 - Armor: none - Mobile: - Sight: 4 - Speed: 3 - RenderInfantry: - AttackBase: - TakeCover: - SquishByTank: - AutoTarget: - Passenger: - -E6: - Inherits: DefaultInfantry - Buildable: - TechLevel: 5 - Tab: Infantry - Owner: soviet,allies - Cost: 500 - Description: "Engineer" - LongDesc: "Infiltrates and captures enemy structures.\n Strong vs Nothing\n Weak vs Everything" - Selectable: - Voice: EngineerVoice - Bounds: [12,17,0,-9] - Unit: - HP: 25 - Armor: none - Mobile: - Sight: 4 - Speed: 4 - EngineerCapture: - RenderInfantry: - TakeCover: - SquishByTank: - Passenger: - -SPY: - Inherits: DefaultInfantry - Buildable: - TechLevel: 6 - Tab: Infantry - Prerequisites: [dome] - Owner: allies - Cost: 500 - Description: "Spy" - LongDesc: "Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised" - Selectable: - Voice: SpyVoice - Bounds: [12,17,0,-9] - Unit: - HP: 25 - Armor: none - Mobile: - Sight: 5 - Speed: 4 - RenderInfantry: - TakeCover: - SquishByTank: - Passenger: - -THF: - Inherits: DefaultInfantry - Buildable: - TechLevel: 11 - Tab: Infantry - Prerequisites: [atek] - Owner: allies - Cost: 500 - Description: "Thief" - LongDesc: "Infiltrates enemy refineries & \nsilos, and steals money stored there.\n Unarmed" - Selectable: - Voice: ThiefVoice - Bounds: [12,17,0,-9] - Unit: - HP: 25 - Armor: none - Mobile: - Sight: 5 - Speed: 4 - RenderInfantry: - TakeCover: - SquishByTank: - Passenger: - Thief: - -E7: - Inherits: DefaultInfantry - Buildable: - TechLevel: 11 - Tab: Infantry - Prerequisites: [atek,stek] - Owner: allies,soviet - Cost: 1200 - Description: "Tanya" - LongDesc: "Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4" - Selectable: - Voice: TanyaVoice - Bounds: [12,17,0,-9] - Unit: - HP: 100 - Armor: none - Mobile: - Sight: 6 - Speed: 5 - RenderInfantry: - C4Demolition: - AttackBase: - TakeCover: - SquishByTank: - AutoTarget: - Passenger: - -MEDI: - Inherits: DefaultInfantry - Buildable: - TechLevel: 2 - Tab: Infantry - Owner: allies - Cost: 800 - Description: "Medic" - LongDesc: "Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything" - Selectable: - Voice: MedicVoice - Bounds: [12,17,0,-9] - Unit: - HP: 80 - Armor: none - Mobile: - Sight: 3 - Speed: 4 - RenderInfantry: - AutoHeal: - AttackBase: - TakeCover: - SquishByTank: - Passenger: - From e7d1407458ef72adde46a53091bc77f07b0563f3 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 13 Jan 2010 10:13:55 +1300 Subject: [PATCH 81/83] fixed turret InitialFacing and ROT --- RulesConverter/Program.cs | 5 +++++ aftermath.yaml | 1 + ra.yaml | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index abfef1565a..0adc47da5f 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -144,6 +144,11 @@ namespace RulesConverter { "Minelayer", new PL { { "Mine", "Primary" } } }, + + { "Turreted", new PL { + { "ROT", "ROT" }, + { "InitialFacing", "InitialFacing" } } + }, }; traitMap["RenderUnit"] = traitMap["RenderBuilding"]; diff --git a/aftermath.yaml b/aftermath.yaml index 60f7a3fc79..5a844c5c9a 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -8,6 +8,7 @@ STNK: Mobile: MovementType: Track Turreted: + ROT: 5 AttackTurreted: PrimaryWeapon: APTusk Recoil: 2 diff --git a/ra.yaml b/ra.yaml index 9c64aa11c4..896b76af13 100644 --- a/ra.yaml +++ b/ra.yaml @@ -40,6 +40,7 @@ V2RL: Mobile: MovementType: Track Turreted: + ROT: 5 AttackTurreted: PrimaryWeapon: 75mm Recoil: 2 @@ -65,6 +66,7 @@ V2RL: Mobile: MovementType: Track Turreted: + ROT: 5 AttackTurreted: PrimaryWeapon: 90mm Recoil: 3 @@ -90,6 +92,7 @@ V2RL: Mobile: MovementType: Track Turreted: + ROT: 5 AttackTurreted: PrimaryWeapon: 105mm Recoil: 3 @@ -115,6 +118,7 @@ V2RL: Mobile: MovementType: Track Turreted: + ROT: 5 AttackTurreted: PrimaryWeapon: 120mm PrimaryLocalOffset: -4,-5,0,4,-5,0 @@ -254,6 +258,7 @@ JEEP: Sight: 6 Speed: 10 Turreted: + ROT: 10 AttackTurreted: PrimaryWeapon: M60mg PrimaryOffset: 0,0,0,-2 @@ -397,6 +402,7 @@ DD: Speed: 6 WaterBound: yes Turreted: + ROT: 7 AttackTurreted: PrimaryWeapon: Stinger PrimaryOffset: 0,-8,0,-3 @@ -424,6 +430,7 @@ CA: Speed: 4 WaterBound: yes Turreted: + ROT: 5 AttackTurreted: PrimaryWeapon: 8Inch PrimaryOffset: 0,17,0,-2 @@ -475,6 +482,7 @@ PT: Speed: 9 WaterBound: yes Turreted: + ROT: 7 AttackTurreted: PrimaryWeapon: 2Inch PrimaryOffset: 0,-6,0,-1 @@ -784,6 +792,8 @@ GUN: InitialFacing: 50 Sight: 6 Turreted: + ROT: 12 + InitialFacing: 50 RenderBuildingTurreted: AttackTurreted: PrimaryWeapon: TurretGun @@ -813,6 +823,8 @@ AGUN: InitialFacing: 224 Sight: 6 Turreted: + ROT: 15 + InitialFacing: 224 RenderBuildingTurreted: AttackTurreted: PrimaryWeapon: ZSU-23 @@ -892,6 +904,7 @@ SAM: Crewed: yes Sight: 5 Turreted: + ROT: 30 RenderBuildingTurreted: AttackTurreted: PrimaryWeapon: Nike From a3e071c60f555c0ba4c1ac58830e74929574598f Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 13 Jan 2010 11:54:20 +1300 Subject: [PATCH 82/83] moved InitialFacing from OwnedActor to Unit --- OpenRa.Game/Traits/Activities/HeliReturn.cs | 2 +- OpenRa.Game/Traits/Building.cs | 1 - OpenRa.Game/Traits/Helicopter.cs | 4 ++-- OpenRa.Game/Traits/Production.cs | 2 +- OpenRa.Game/Traits/Unit.cs | 1 + RulesConverter/Program.cs | 1 - ra.yaml | 2 -- 7 files changed, 5 insertions(+), 8 deletions(-) diff --git a/OpenRa.Game/Traits/Activities/HeliReturn.cs b/OpenRa.Game/Traits/Activities/HeliReturn.cs index 425f8cb997..52d4c12f47 100644 --- a/OpenRa.Game/Traits/Activities/HeliReturn.cs +++ b/OpenRa.Game/Traits/Activities/HeliReturn.cs @@ -24,7 +24,7 @@ namespace OpenRa.Game.Traits.Activities if (isCanceled) return NextActivity; var dest = ChooseHelipad(self); - var initialFacing = self.Info.Traits.Get().InitialFacing; + var initialFacing = self.Info.Traits.Get().InitialFacing; if (dest == null) return Util.SequenceActivities( diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index f80deff35e..f5920cfae7 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -14,7 +14,6 @@ namespace OpenRa.Game.Traits public readonly int HP = 0; public readonly ArmorType Armor = ArmorType.none; public readonly bool Crewed = false; // replace with trait? - public readonly int InitialFacing = 128; public readonly int Sight = 0; public readonly bool WaterBound = false; } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 6a49fd8aa3..34731a21c7 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -49,7 +49,7 @@ namespace OpenRa.Game.Traits { self.CancelActivity(); self.QueueActivity(new HeliFly(Util.CenterOfCell(order.TargetLocation))); - self.QueueActivity( new Turn( self.Info.Traits.GetOrDefault().InitialFacing ) ); + self.QueueActivity( new Turn( self.Info.Traits.GetOrDefault().InitialFacing ) ); self.QueueActivity(new HeliLand(true)); } @@ -66,7 +66,7 @@ namespace OpenRa.Game.Traits self.CancelActivity(); self.QueueActivity(new HeliFly(order.TargetActor.CenterLocation + offsetVec)); - self.QueueActivity( new Turn( self.Info.Traits.GetOrDefault().InitialFacing ) ); + self.QueueActivity( new Turn( self.Info.Traits.GetOrDefault().InitialFacing ) ); self.QueueActivity(new HeliLand(false)); self.QueueActivity(order.TargetActor.Info.Name == "hpad" ? (IActivity)new Rearm() : new Repair()); diff --git a/OpenRa.Game/Traits/Production.cs b/OpenRa.Game/Traits/Production.cs index 794b7e4479..28cbda8be8 100755 --- a/OpenRa.Game/Traits/Production.cs +++ b/OpenRa.Game/Traits/Production.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits public virtual int CreationFacing( Actor self, Actor newUnit ) { - return newUnit.Info.Traits.GetOrDefault().InitialFacing; + return newUnit.Info.Traits.GetOrDefault().InitialFacing; } public bool Produce( Actor self, NewUnitInfo producee ) diff --git a/OpenRa.Game/Traits/Unit.cs b/OpenRa.Game/Traits/Unit.cs index 6d07eee4f2..d0fe1b0ed6 100755 --- a/OpenRa.Game/Traits/Unit.cs +++ b/OpenRa.Game/Traits/Unit.cs @@ -4,6 +4,7 @@ namespace OpenRa.Game.Traits { class UnitInfo : OwnedActorInfo, ITraitInfo { + public readonly int InitialFacing = 128; public readonly int ROT = 0; public readonly int Speed = 0; diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 0adc47da5f..950eeb3138 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -109,7 +109,6 @@ namespace RulesConverter { "Armor", "Armor" }, { "Crewed", "Crewed" }, { "WaterBound", "WaterBound" }, - { "InitialFacing", "InitialFacing" }, { "Sight", "Sight" }, { "Unsellable", "Unsellable" } } }, diff --git a/ra.yaml b/ra.yaml index 896b76af13..cf0ec2a995 100644 --- a/ra.yaml +++ b/ra.yaml @@ -789,7 +789,6 @@ GUN: HP: 400 Armor: heavy Crewed: yes - InitialFacing: 50 Sight: 6 Turreted: ROT: 12 @@ -820,7 +819,6 @@ AGUN: HP: 400 Armor: heavy Crewed: yes - InitialFacing: 224 Sight: 6 Turreted: ROT: 15 From 6df3420e614d590bf4ae81d7a54bb0fda2c5ebee Mon Sep 17 00:00:00 2001 From: Bob Date: Wed, 13 Jan 2010 13:14:08 +1300 Subject: [PATCH 83/83] imported the original aftrmath.ini, some defaults, a slight hack in converter that we don't use yet. --- RulesConverter/Program.cs | 2 ++ aftermath.yaml | 7 ------- aftrmath.ini | 4 +++- defaults.yaml | 6 +++++- ra.yaml | 35 ----------------------------------- 5 files changed, 10 insertions(+), 44 deletions(-) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 950eeb3138..a5eeebc252 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -204,6 +204,8 @@ namespace RulesConverter } var yaml = MiniYaml.FromFile( outputFile ); + if( File.Exists( "merge-" + outputFile ) ) + yaml = MiniYaml.Merge( MiniYaml.FromFile( "merge-" + outputFile ), yaml ); yaml.OptimizeInherits( MiniYaml.FromFile( "defaults.yaml" ) ); yaml.WriteToFile( outputFile ); } diff --git a/aftermath.yaml b/aftermath.yaml index 5a844c5c9a..96625aaf47 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -132,14 +132,10 @@ SHOK: Voice: ShokVoice Unit: HP: 80 - Armor: none - Sight: 4 Speed: 3 AttackBase: PrimaryWeapon: PortaTesla - RenderInfantry: TakeCover: - Passenger: MECH: Inherits: DefaultInfantry @@ -156,14 +152,11 @@ MECH: Bounds: 12,17,0,-9 Unit: HP: 60 - Armor: none Sight: 3 Speed: 4 - RenderInfantry: AutoHeal: AttackBase: PrimaryWeapon: GoodWrench TakeCover: SquishByTank: - Passenger: diff --git a/aftrmath.ini b/aftrmath.ini index db4e05f689..670d9cc51a 100755 --- a/aftrmath.ini +++ b/aftrmath.ini @@ -119,6 +119,7 @@ Cost=1650 Points=45 ROT=7 Cloakable=yes +Inaccurate=no ; Shock Trooper [SHOK] @@ -134,6 +135,7 @@ Cost=900 Points=15 Explodes=no NoMovingFire=yes +Crushable=no ; field mechanic [MECH] @@ -457,7 +459,7 @@ Cost=200 Points=5 IsCanine=yes GuardRange=7 -SelfHealing=no +Selfhealing=no [CHAN] Strength=25 diff --git a/defaults.yaml b/defaults.yaml index a070f35542..48442b5d48 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -11,10 +11,14 @@ DefaultVehicle: IronCurtainable: DefaultInfantry: - Unit: + Unit: + Armor: none + Sight: 4 Mobile: MovementType: Foot Selectable: + RenderInfantry: + Passenger: DefaultShip: Unit: diff --git a/ra.yaml b/ra.yaml index cf0ec2a995..78cfb50d3d 100644 --- a/ra.yaml +++ b/ra.yaml @@ -2027,11 +2027,8 @@ DOG: Bounds: 12,17,-1,-4 Unit: HP: 12 - Armor: none Sight: 5 Speed: 4 - RenderInfantry: - Passenger: E1: Inherits: DefaultInfantry @@ -2046,16 +2043,12 @@ E1: Bounds: 12,17,0,-9 Unit: HP: 50 - Armor: none - Sight: 4 Speed: 4 - RenderInfantry: AttackBase: PrimaryWeapon: M1Carbine TakeCover: SquishByTank: AutoTarget: - Passenger: E2: Inherits: DefaultInfantry @@ -2070,10 +2063,7 @@ E2: Bounds: 12,17,0,-9 Unit: HP: 50 - Armor: none - Sight: 4 Speed: 5 - RenderInfantry: AttackBase: PrimaryWeapon: Grenade PrimaryOffset: 0,0,0,-13 @@ -2081,7 +2071,6 @@ E2: TakeCover: SquishByTank: AutoTarget: - Passenger: E3: Inherits: DefaultInfantry @@ -2096,17 +2085,13 @@ E3: Bounds: 12,17,0,-9 Unit: HP: 45 - Armor: none - Sight: 4 Speed: 3 - RenderInfantry: AttackBase: PrimaryWeapon: RedEye PrimaryOffset: 0,0,0,-13 TakeCover: SquishByTank: AutoTarget: - Passenger: E4: Inherits: DefaultInfantry @@ -2122,10 +2107,7 @@ E4: Bounds: 12,17,0,-9 Unit: HP: 40 - Armor: none - Sight: 4 Speed: 3 - RenderInfantry: AttackBase: PrimaryWeapon: Flamer PrimaryOffset: 0,0,0,-7 @@ -2133,7 +2115,6 @@ E4: TakeCover: SquishByTank: AutoTarget: - Passenger: E6: Inherits: DefaultInfantry @@ -2149,14 +2130,10 @@ E6: Bounds: 12,17,0,-9 Unit: HP: 25 - Armor: none - Sight: 4 Speed: 4 EngineerCapture: - RenderInfantry: TakeCover: SquishByTank: - Passenger: SPY: Inherits: DefaultInfantry @@ -2173,13 +2150,10 @@ SPY: Bounds: 12,17,0,-9 Unit: HP: 25 - Armor: none Sight: 5 Speed: 4 - RenderInfantry: TakeCover: SquishByTank: - Passenger: THF: Inherits: DefaultInfantry @@ -2196,13 +2170,10 @@ THF: Bounds: 12,17,0,-9 Unit: HP: 25 - Armor: none Sight: 5 Speed: 4 - RenderInfantry: TakeCover: SquishByTank: - Passenger: Thief: E7: @@ -2220,17 +2191,14 @@ E7: Bounds: 12,17,0,-9 Unit: HP: 100 - Armor: none Sight: 6 Speed: 5 - RenderInfantry: C4Demolition: AttackBase: PrimaryWeapon: Colt45 TakeCover: SquishByTank: AutoTarget: - Passenger: MEDI: Inherits: DefaultInfantry @@ -2246,14 +2214,11 @@ MEDI: Bounds: 12,17,0,-9 Unit: HP: 80 - Armor: none Sight: 3 Speed: 4 - RenderInfantry: AutoHeal: AttackBase: PrimaryWeapon: Heal TakeCover: SquishByTank: - Passenger: