movementtype

This commit is contained in:
Chris Forbes
2010-01-12 21:59:26 +13:00
parent 02b9415277
commit ee14b0a670
5 changed files with 37 additions and 45 deletions

View File

@@ -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<MobileInfo>().MovementType;
}
public bool CanEnterCell(int2 a)

View File

@@ -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<string> 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";
}
}
}

View File

@@ -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:

View File

@@ -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:

25
ra.yaml
View File

@@ -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: