Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove landing behaviour from force-move orders on selectable buildings. #17263

Merged
merged 1 commit into from
Nov 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1169,6 +1169,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 @@ -1177,6 +1178,7 @@ public class AircraftMoveOrderTargeter : IOrderTargeter
public AircraftMoveOrderTargeter(Aircraft aircraft)
{
this.aircraft = aircraft;
bi = aircraft.self.World.WorldActor.TraitOrDefault<BuildingInfluence>();
OrderID = "Move";
}

Expand All @@ -1190,10 +1192,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))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hinging this on Selectable may be too much of a hack. We could expose this as a flag on BuildingInfo instead?

Copy link
Contributor

@GraionDilach GraionDilach Oct 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a Footprint flag? Say, l and L for a landable x (since rest are obviously passable already).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an actor-level consideration, so I don't think it makes any sense to tie it to specific cells in the footprint.

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