Skip to content

Commit

Permalink
Remove landing behaviour from force-move orders on selectable buildings.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Nov 2, 2019
1 parent 059b850 commit 33b1e74
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions OpenRA.Mods.Common/Traits/Air/Aircraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ Activity ICreationActivity.GetCreationActivity()
public class AircraftMoveOrderTargeter : IOrderTargeter
{
readonly Aircraft aircraft;
readonly BuildingInfluence bi;

public string OrderID { get; protected set; }
public int OrderPriority { get { return 4; } }
Expand All @@ -1182,6 +1183,7 @@ public class AircraftMoveOrderTargeter : IOrderTargeter
public AircraftMoveOrderTargeter(Aircraft aircraft)
{
this.aircraft = aircraft;
bi = aircraft.self.World.WorldActor.TraitOrDefault<BuildingInfluence>();
OrderID = "Move";
}

Expand All @@ -1199,10 +1201,18 @@ public virtual bool CanTarget(Actor self, Target target, List<Actor> othersAtTar
if (target.Type != TargetType.Terrain || (aircraft.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
return false;

var location = self.World.Map.CellContaining(target.CenterPosition);

// Aircraft can be force-landed by issuing a force-move order on a clear terrain cell
// Cells that contain a blocking building are treated as regular force move orders, overriding
// selection for left-mouse orders
if (modifiers.HasModifier(TargetModifiers.ForceMove) && aircraft.Info.CanForceLand)
OrderID = "Land";
{
var building = bi.GetBuildingAt(location);
if (building == null || building.TraitOrDefault<Selectable>() == null || aircraft.CanLand(location, blockedByMobile: false))
OrderID = "Land";
}

var location = self.World.Map.CellContaining(target.CenterPosition);
var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? "move") :
Expand Down

0 comments on commit 33b1e74

Please sign in to comment.