From ee14b0a670af1e254cd9ff8ff45fac1598868fc0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 12 Jan 2010 21:59:26 +1300 Subject: [PATCH] movementtype --- OpenRa.Game/Traits/Mobile.cs | 16 +++------------- RulesConverter/Program.cs | 21 ++++++++++++++++++--- aftermath.yaml | 4 ---- defaults.yaml | 16 ++++++++++++++++ ra.yaml | 25 ------------------------- 5 files changed, 37 insertions(+), 45 deletions(-) diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 502521d23a..2a1da2f3aa 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -7,6 +7,8 @@ namespace OpenRa.Game.Traits { class MobileInfo : ITraitInfo { + public readonly UnitMovementType MovementType = UnitMovementType.Wheel; + public object Create(Actor self) { return new Mobile(self); } } @@ -83,19 +85,7 @@ namespace OpenRa.Game.Traits public UnitMovementType GetMovementType() { - switch (Rules.UnitCategory[self.Info.Name]) - { - case "Infantry": - return UnitMovementType.Foot; - case "Vehicle": - return (self.LegacyInfo as VehicleInfo).Tracked ? UnitMovementType.Track : UnitMovementType.Wheel; - case "Ship": - return UnitMovementType.Float; - case "Plane": - return UnitMovementType.Fly; - default: - throw new InvalidOperationException("GetMovementType on unit that shouldn't be able to move."); - } + return self.Info.Traits.Get().MovementType; } public bool CanEnterCell(int2 a) diff --git a/RulesConverter/Program.cs b/RulesConverter/Program.cs index 06ce571c06..ec0b0e6c06 100644 --- a/RulesConverter/Program.cs +++ b/RulesConverter/Program.cs @@ -54,8 +54,7 @@ namespace RulesConverter }, { "Mobile", new PL { - //{ "MovementType", ... }, - } + { "MovementType", "$MovementType" } } }, { "RenderBuilding", new PL { @@ -186,7 +185,9 @@ namespace RulesConverter if (traitMap.ContainsKey(t)) foreach (var kv in traitMap[t]) { - var v = kv.Value == "$Tab" ? cat.Value.Second : iniSection.GetValue(kv.Value, ""); + var v = iniSection.GetValue(kv.Value, ""); + if (kv.Value == "$Tab") v = cat.Value.Second; + if (kv.Value == "$MovementType") v = GetMovementType(iniSection, traits); var fmt = "\t\t{0}: {1}"; var k = kv.Key; if (k.StartsWith("@")) { k = k.Substring(1); /*fmt = "\t\t{0}: [{1}]";*/ } @@ -206,5 +207,19 @@ namespace RulesConverter yaml.OptimizeInherits( MiniYaml.FromFile( "defaults.yaml" ) ); yaml.WriteToFile( outputFile ); } + + static string GetMovementType(IniSection unit, List traits) + { + if (unit.GetValue("WaterBound", "no") == "yes") + return "Float"; + if (unit.GetValue("Tracked", "no") == "yes") + return "Track"; + if (traits.Contains("Plane") || traits.Contains("Helicopter")) + return "Fly"; + if (traits.Contains("RenderInfantry")) + return "Foot"; + + return "Wheel"; + } } } diff --git a/aftermath.yaml b/aftermath.yaml index 5dcadf08ef..4ebc49a29a 100644 --- a/aftermath.yaml +++ b/aftermath.yaml @@ -96,7 +96,6 @@ MSUB: Owner: soviet Cost: 1650 Description: "Missile Submarine" - Selectable: Unit: HP: 150 Armor: light @@ -104,7 +103,6 @@ MSUB: Sight: 6 Speed: 5 WaterBound: yes - Mobile: AttackBase: PrimaryWeapon: SubSCUD FireDelay: 2 @@ -128,7 +126,6 @@ SHOK: Armor: none Sight: 4 Speed: 3 - Mobile: AttackBase: PrimaryWeapon: PortaTesla RenderInfantry: @@ -153,7 +150,6 @@ MECH: Armor: none Sight: 3 Speed: 4 - Mobile: RenderInfantry: AutoHeal: AttackBase: diff --git a/defaults.yaml b/defaults.yaml index 6d2a18160b..cd9cc60525 100644 --- a/defaults.yaml +++ b/defaults.yaml @@ -2,6 +2,7 @@ DefaultVehicle: Unit: ROT: 5 Mobile: + MovementType: Wheel Selectable: Voice: VehicleVoice Repairable: @@ -9,3 +10,18 @@ DefaultVehicle: Passenger: IronCurtainable: +DefaultInfantry: + Unit: + Mobile: + MovementType: Foot + Selectable: + +DefaultShip: + Unit: + Mobile: + MovementType: Float + Selectable: + +DefaultPlane: + Unit: + Selectable: \ No newline at end of file diff --git a/ra.yaml b/ra.yaml index 4acd1b9cbd..9df3c81702 100644 --- a/ra.yaml +++ b/ra.yaml @@ -339,7 +339,6 @@ SS: Cost: 950 Description: "Submarine" LongDesc: "Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n Weak vs Everything\n Special Ability: Submerge" - Selectable: Unit: HP: 120 Armor: light @@ -347,7 +346,6 @@ SS: Sight: 6 Speed: 6 WaterBound: yes - Mobile: RenderUnit: Submarine: AttackBase: @@ -367,7 +365,6 @@ DD: Cost: 1000 Description: "Destroyer" LongDesc: "Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks" - Selectable: Unit: HP: 400 Armor: heavy @@ -375,7 +372,6 @@ DD: Sight: 6 Speed: 6 WaterBound: yes - Mobile: Turreted: AttackTurreted: PrimaryWeapon: Stinger @@ -396,7 +392,6 @@ CA: Cost: 2000 Description: "Cruiser" LongDesc: "Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines" - Selectable: Unit: HP: 700 Armor: heavy @@ -404,7 +399,6 @@ CA: Sight: 7 Speed: 4 WaterBound: yes - Mobile: Turreted: AttackTurreted: PrimaryWeapon: 8Inch @@ -425,7 +419,6 @@ LST: Cost: 700 Description: "Transport" LongDesc: "General-purpose naval transport.\nCan carry infantry and tanks.\n Unarmed" - Selectable: Unit: HP: 350 Armor: heavy @@ -433,7 +426,6 @@ LST: Sight: 6 Speed: 14 WaterBound: yes - Mobile: RenderUnit: Cargo: PassengerTypes: Foot,Wheel,Track @@ -451,7 +443,6 @@ PT: Cost: 500 Description: "Gunboat" LongDesc: "Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft" - Selectable: Unit: HP: 200 Armor: heavy @@ -459,7 +450,6 @@ PT: Sight: 7 Speed: 9 WaterBound: yes - Mobile: Turreted: AttackTurreted: PrimaryWeapon: 2Inch @@ -480,7 +470,6 @@ MIG: Cost: 1200 Description: "Mig Attack Plane" LongDesc: "Fast Ground-Attack Plane.\n Strong vs Buildings\n Weak vs Infantry, Light Vehicles" - Selectable: Unit: HP: 50 Armor: light @@ -508,7 +497,6 @@ YAK: Cost: 800 Description: "Yak Attack Plane" LongDesc: "Anti-Tanks & Anti-Infantry Plane.\n Strong vs Infantry, Tanks\n Weak vs Buildings" - Selectable: Unit: HP: 60 Armor: light @@ -537,7 +525,6 @@ TRAN: Cost: 1200 Description: "Transport Helicopter" LongDesc: "Fast Infantry Transport Helicopter.\n Unarmed" - Selectable: Unit: HP: 90 Armor: light @@ -566,7 +553,6 @@ HELI: Cost: 1200 Description: "Longbow" LongDesc: "Helicopter Gunship with AG Missiles.\n Strong vs Buildings, Tanks\n Weak vs Infantry" - Selectable: Unit: HP: 225 Armor: heavy @@ -598,7 +584,6 @@ HIND: Cost: 1200 Description: "Hind" LongDesc: "Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks" - Selectable: Unit: HP: 225 Armor: heavy @@ -2152,7 +2137,6 @@ DOG: Armor: none Sight: 5 Speed: 4 - Mobile: RenderInfantry: Passenger: @@ -2172,7 +2156,6 @@ E1: Armor: none Sight: 4 Speed: 4 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: M1Carbine @@ -2197,7 +2180,6 @@ E2: Armor: none Sight: 4 Speed: 5 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: Grenade @@ -2224,7 +2206,6 @@ E3: Armor: none Sight: 4 Speed: 3 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: RedEye @@ -2251,7 +2232,6 @@ E4: Armor: none Sight: 4 Speed: 3 - Mobile: RenderInfantry: AttackBase: PrimaryWeapon: Flamer @@ -2279,7 +2259,6 @@ E6: Armor: none Sight: 4 Speed: 4 - Mobile: EngineerCapture: RenderInfantry: TakeCover: @@ -2304,7 +2283,6 @@ SPY: Armor: none Sight: 5 Speed: 4 - Mobile: RenderInfantry: TakeCover: SquishByTank: @@ -2328,7 +2306,6 @@ THF: Armor: none Sight: 5 Speed: 4 - Mobile: RenderInfantry: TakeCover: SquishByTank: @@ -2353,7 +2330,6 @@ E7: Armor: none Sight: 6 Speed: 5 - Mobile: RenderInfantry: C4Demolition: AttackBase: @@ -2380,7 +2356,6 @@ MEDI: Armor: none Sight: 3 Speed: 4 - Mobile: RenderInfantry: AutoHeal: AttackBase: