From 12c2dbfd38c569904c9c6bb59d12d833121cfc06 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 9 Jan 2010 20:52:01 +1300 Subject: [PATCH 01/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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/33] 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); + } } }