Require force move for all undeploy-triggering orders.

This commit is contained in:
Paul Chote
2019-06-07 23:08:11 +00:00
committed by reaperrr
parent 5d886b79f1
commit ebe37a44ad
19 changed files with 249 additions and 90 deletions

View File

@@ -1,57 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2019 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, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Orders
{
public class AircraftMoveOrderTargeter : IOrderTargeter
{
public string OrderID { get; protected set; }
public int OrderPriority { get; protected set; }
public bool TargetOverridesSelection(TargetModifiers modifiers)
{
return modifiers.HasModifier(TargetModifiers.ForceMove);
}
readonly AircraftInfo info;
public AircraftMoveOrderTargeter(AircraftInfo info)
{
this.info = info;
OrderID = "Move";
OrderPriority = 4;
}
public virtual bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
{
if (target.Type != TargetType.Terrain)
return false;
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") :
"move-blocked";
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
if (!explored && !info.MoveIntoShroud)
cursor = "move-blocked";
return true;
}
public bool IsQueued { get; protected set; }
}
}

View File

@@ -16,11 +16,11 @@ namespace OpenRA.Mods.Common.Orders
{
public class EnterAlliedActorTargeter<T> : UnitOrderTargeter where T : ITraitInfo
{
readonly Func<Actor, bool> canTarget;
readonly Func<Actor, TargetModifiers, bool> canTarget;
readonly Func<Actor, bool> useEnterCursor;
public EnterAlliedActorTargeter(string order, int priority,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor)
Func<Actor, TargetModifiers, bool> canTarget, Func<Actor, bool> useEnterCursor)
: base(order, priority, "enter", false, true)
{
this.canTarget = canTarget;
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Orders
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
if (!self.Owner.IsAlliedWith(target.Owner) || !target.Info.HasTraitInfo<T>() || !canTarget(target))
if (!self.Owner.IsAlliedWith(target.Owner) || !target.Info.HasTraitInfo<T>() || !canTarget(target, modifiers))
return false;
cursor = useEnterCursor(target) ? "enter" : "enter-blocked";