Add configurable cursors for entering allied actor targeters
This commit is contained in:
committed by
abcdefg30
parent
393f6eca3a
commit
d5ff5c672b
@@ -16,13 +16,17 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
{
|
{
|
||||||
public class EnterAlliedActorTargeter<T> : UnitOrderTargeter where T : ITraitInfoInterface
|
public class EnterAlliedActorTargeter<T> : UnitOrderTargeter where T : ITraitInfoInterface
|
||||||
{
|
{
|
||||||
|
readonly string enterCursor;
|
||||||
|
readonly string enterBlockedCursor;
|
||||||
readonly Func<Actor, TargetModifiers, bool> canTarget;
|
readonly Func<Actor, TargetModifiers, bool> canTarget;
|
||||||
readonly Func<Actor, bool> useEnterCursor;
|
readonly Func<Actor, bool> useEnterCursor;
|
||||||
|
|
||||||
public EnterAlliedActorTargeter(string order, int priority,
|
public EnterAlliedActorTargeter(string order, int priority, string enterCursor, string enterBlockedCursor,
|
||||||
Func<Actor, TargetModifiers, bool> canTarget, Func<Actor, bool> useEnterCursor)
|
Func<Actor, TargetModifiers, bool> canTarget, Func<Actor, bool> useEnterCursor)
|
||||||
: base(order, priority, "enter", false, true)
|
: base(order, priority, enterCursor, false, true)
|
||||||
{
|
{
|
||||||
|
this.enterCursor = enterCursor;
|
||||||
|
this.enterBlockedCursor = enterBlockedCursor;
|
||||||
this.canTarget = canTarget;
|
this.canTarget = canTarget;
|
||||||
this.useEnterCursor = useEnterCursor;
|
this.useEnterCursor = useEnterCursor;
|
||||||
}
|
}
|
||||||
@@ -32,7 +36,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
if (!self.Owner.IsAlliedWith(target.Owner) || !target.Info.HasTraitInfo<T>() || !canTarget(target, modifiers))
|
if (!self.Owner.IsAlliedWith(target.Owner) || !target.Info.HasTraitInfo<T>() || !canTarget(target, modifiers))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cursor = useEnterCursor(target) ? "enter" : "enter-blocked";
|
cursor = useEnterCursor(target) ? enterCursor : enterBlockedCursor;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public int GetInitialFacing() { return InitialFacing; }
|
public int GetInitialFacing() { return InitialFacing; }
|
||||||
public WDist GetCruiseAltitude() { return CruiseAltitude; }
|
public WDist GetCruiseAltitude() { return CruiseAltitude; }
|
||||||
|
|
||||||
@@ -937,11 +940,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("ForceEnter", 6,
|
yield return new EnterAlliedActorTargeter<BuildingInfo>("ForceEnter", 6, Info.EnterCursor, Info.EnterBlockedCursor,
|
||||||
(target, modifiers) => Info.CanForceLand && modifiers.HasModifier(TargetModifiers.ForceMove) && AircraftCanEnter(target),
|
(target, modifiers) => Info.CanForceLand && modifiers.HasModifier(TargetModifiers.ForceMove) && AircraftCanEnter(target),
|
||||||
target => Reservable.IsAvailableFor(target, self) && AircraftCanResupplyAt(target, true));
|
target => Reservable.IsAvailableFor(target, self) && AircraftCanResupplyAt(target, true));
|
||||||
|
|
||||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("Enter", 5,
|
yield return new EnterAlliedActorTargeter<BuildingInfo>("Enter", 5, Info.EnterCursor, Info.EnterBlockedCursor,
|
||||||
AircraftCanEnter,
|
AircraftCanEnter,
|
||||||
target => Reservable.IsAvailableFor(target, self) && AircraftCanResupplyAt(target, !Info.TakeOffOnResupply));
|
target => Reservable.IsAvailableFor(target, self) && AircraftCanResupplyAt(target, !Info.TakeOffOnResupply));
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Require the force-move modifier to display the move cursor.")]
|
[Desc("Require the force-move modifier to display the move cursor.")]
|
||||||
public readonly bool RequiresForceMove = false;
|
public readonly bool RequiresForceMove = false;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new TransformsIntoAircraft(init, this); }
|
public override object Create(ActorInitializer init) { return new TransformsIntoAircraft(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
if (!IsTraitDisabled)
|
if (!IsTraitDisabled)
|
||||||
{
|
{
|
||||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("Enter", 5, AircraftCanEnter,
|
yield return new EnterAlliedActorTargeter<BuildingInfo>("Enter", 5, Info.EnterCursor, Info.EnterBlockedCursor, AircraftCanEnter,
|
||||||
target => Reservable.IsAvailableFor(target, self));
|
target => Reservable.IsAvailableFor(target, self));
|
||||||
|
|
||||||
yield return new AircraftMoveOrderTargeter(self, this);
|
yield return new AircraftMoveOrderTargeter(self, this);
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Require the force-move modifier to display the enter cursor.")]
|
[Desc("Require the force-move modifier to display the enter cursor.")]
|
||||||
public readonly bool RequiresForceMove = false;
|
public readonly bool RequiresForceMove = false;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new TransformsIntoPassenger(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new TransformsIntoPassenger(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!IsTraitDisabled)
|
if (!IsTraitDisabled)
|
||||||
yield return new EnterAlliedActorTargeter<CargoInfo>("EnterTransport", 5, IsCorrectCargoType, CanEnter);
|
yield return new EnterAlliedActorTargeter<CargoInfo>("EnterTransport", 5, Info.EnterCursor, Info.EnterBlockedCursor, IsCorrectCargoType, CanEnter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Require the force-move modifier to display the enter cursor.")]
|
[Desc("Require the force-move modifier to display the enter cursor.")]
|
||||||
public readonly bool RequiresForceMove = false;
|
public readonly bool RequiresForceMove = false;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new TransformsIntoRepairable(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new TransformsIntoRepairable(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!IsTraitDisabled)
|
if (!IsTraitDisabled)
|
||||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("Repair", 5, CanRepairAt, _ => CanRepair());
|
yield return new EnterAlliedActorTargeter<BuildingInfo>("Repair", 5, Info.EnterCursor, Info.EnterBlockedCursor, CanRepairAt, _ => CanRepair());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[VoiceReference]
|
[VoiceReference]
|
||||||
public readonly string DeliverVoice = "Action";
|
public readonly string DeliverVoice = "Action";
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Harvester(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new Harvester(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +281,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
yield return new EnterAlliedActorTargeter<IAcceptResourcesInfo>("Deliver", 5,
|
yield return new EnterAlliedActorTargeter<IAcceptResourcesInfo>("Deliver", 5, Info.EnterCursor, Info.EnterBlockedCursor,
|
||||||
(proc, _) => IsAcceptableProcType(proc),
|
(proc, _) => IsAcceptableProcType(proc),
|
||||||
proc => proc.Trait<IAcceptResources>().AllowDocking);
|
proc => proc.Trait<IAcceptResources>().AllowDocking);
|
||||||
yield return new HarvestOrderTargeter();
|
yield return new HarvestOrderTargeter();
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Passenger(this); }
|
public override object Create(ActorInitializer init) { return new Passenger(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
yield return new EnterAlliedActorTargeter<CargoInfo>("EnterTransport", 5, IsCorrectCargoType, CanEnter);
|
yield return new EnterAlliedActorTargeter<CargoInfo>("EnterTransport", 5, Info.EnterCursor, Info.EnterBlockedCursor, IsCorrectCargoType, CanEnter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Repairable(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new Repairable(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!isAircraft)
|
if (!isAircraft)
|
||||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("Repair", 5, CanRepairAt, _ => CanRepair() || CanRearm());
|
yield return new EnterAlliedActorTargeter<BuildingInfo>("Repair", 5, Info.EnterCursor, Info.EnterBlockedCursor, CanRepairAt, _ => CanRepair() || CanRearm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) enter cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|
||||||
|
public readonly string EnterCursor = "enter";
|
||||||
|
public readonly string EnterBlockedCursor = "enter-blocked";
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("RepairNear", 5,
|
yield return new EnterAlliedActorTargeter<BuildingInfo>("RepairNear", 5, Info.EnterCursor, Info.EnterBlockedCursor,
|
||||||
CanRepairAt, _ => ShouldRepair());
|
CanRepairAt, _ => ShouldRepair());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user