Remove TargetableAircraft

This commit is contained in:
atlimit8
2015-07-16 08:57:50 -05:00
parent 97ce4766f3
commit 6986cd9f0e
13 changed files with 111 additions and 54 deletions

View File

@@ -256,7 +256,6 @@
<Compile Include="Traits\Air\Helicopter.cs" />
<Compile Include="Traits\Air\Plane.cs" />
<Compile Include="Traits\Air\ReturnOnIdle.cs" />
<Compile Include="Traits\Air\TargetableAircraft.cs" />
<Compile Include="Traits\AppearsOnRadar.cs" />
<Compile Include="Traits\Armament.cs" />
<Compile Include="Traits\Armor.cs" />

View File

@@ -1,42 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class TargetableAircraftInfo : TargetableInfo
{
public readonly string[] GroundedTargetTypes = { };
public override object Create(ActorInitializer init) { return new TargetableAircraft(init.Self, this); }
}
public class TargetableAircraft : Targetable
{
readonly TargetableAircraftInfo info;
readonly Actor self;
public TargetableAircraft(Actor self, TargetableAircraftInfo info)
: base(self, info)
{
this.info = info;
this.self = self;
}
public override string[] TargetTypes
{
get
{
return (self.CenterPosition.Z > 0) ? info.TargetTypes : info.GroundedTargetTypes;
}
}
}
}

View File

@@ -2012,6 +2012,42 @@ namespace OpenRA.Mods.Common.UtilityCommands
untargetableSubmarine.Key = "-Targetable";
node.Value.Nodes.Add(new MiniYamlNode("-Targetable@UNDERWATER", ""));
}
// Split TargetableAircraft into two Targetable traits
var targetableAircraft = node.Value.Nodes.FirstOrDefault(n => n.Key == "TargetableAircraft");
if (targetableAircraft != null)
{
node.Value.Nodes.RemoveAll(n => n.Key == "-Targetable");
targetableAircraft.Key = "Targetable@AIRBORNE";
targetableAircraft.Value.Nodes.Add(new MiniYamlNode("UpgradeTypes", "airborne"));
targetableAircraft.Value.Nodes.Add(new MiniYamlNode("UpgradeMinEnabledLevel", "1"));
var groundTargetTypes = targetableAircraft.Value.Nodes.FirstOrDefault(n => n.Key == "GroundedTargetTypes");
if (groundTargetTypes != null)
{
targetableAircraft.Value.Nodes.Remove(groundTargetTypes);
groundTargetTypes.Key = "TargetTypes";
}
else
groundTargetTypes = new MiniYamlNode("TargetTypes", "");
node.Value.Nodes.Add(new MiniYamlNode("Targetable@GROUND", "", new List<MiniYamlNode> {
groundTargetTypes,
new MiniYamlNode("UpgradeTypes", "airborne"),
new MiniYamlNode("UpgradeMaxEnabledLevel", "0")
}));
}
// Add `AirborneUpgrades: airborne` to Plane and Helicopter
var aircraft = node.Value.Nodes.FirstOrDefault(n => n.Key == "Plane" || n.Key == "Helicopter");
if (aircraft != null)
aircraft.Value.Nodes.Add(new MiniYamlNode("AirborneUpgrades", "airborne"));
// Remove split traits if TargetableAircraft was removed
var untargetableAircraft = node.Value.Nodes.FirstOrDefault(n => n.Key == "-TargetableAircraft");
if (untargetableAircraft != null)
{
untargetableAircraft.Key = "-TargetableUnit@GROUND";
node.Value.Nodes.Add(new MiniYamlNode("-TargetableUnit@AIRBORNE", ""));
}
}
}