Add support for not displaying target lines
This commit is contained in:
@@ -24,6 +24,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
readonly HarvesterInfo harvInfo;
|
readonly HarvesterInfo harvInfo;
|
||||||
readonly Mobile mobile;
|
readonly Mobile mobile;
|
||||||
readonly ResourceClaimLayer claimLayer;
|
readonly ResourceClaimLayer claimLayer;
|
||||||
|
readonly DockClientManager dockClient;
|
||||||
readonly MoveCooldownHelper moveCooldownHelper;
|
readonly MoveCooldownHelper moveCooldownHelper;
|
||||||
CPos? orderLocation;
|
CPos? orderLocation;
|
||||||
CPos? lastHarvestedCell;
|
CPos? lastHarvestedCell;
|
||||||
@@ -37,6 +38,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
harv = self.Trait<Harvester>();
|
harv = self.Trait<Harvester>();
|
||||||
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
||||||
|
dockClient = self.Trait<DockClientManager>();
|
||||||
|
|
||||||
mobile = self.Trait<Mobile>();
|
mobile = self.Trait<Mobile>();
|
||||||
claimLayer = self.World.WorldActor.Trait<ResourceClaimLayer>();
|
claimLayer = self.World.WorldActor.Trait<ResourceClaimLayer>();
|
||||||
moveCooldownHelper = new MoveCooldownHelper(self.World, mobile) { RetryIfDestinationBlocked = true };
|
moveCooldownHelper = new MoveCooldownHelper(self.World, mobile) { RetryIfDestinationBlocked = true };
|
||||||
@@ -56,7 +59,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// We have to make sure the actual "harvest" order is not skipped if a third order is queued,
|
// We have to make sure the actual "harvest" order is not skipped if a third order is queued,
|
||||||
// so we keep deliveredLoad false.
|
// so we keep deliveredLoad false.
|
||||||
if (harv.IsFull)
|
if (harv.IsFull)
|
||||||
QueueChild(new MoveToDock(self));
|
QueueChild(new MoveToDock(self, dockLineColor: dockClient.DockLineColor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +86,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (harv.DockClientManager.ReservedHost != null)
|
if (harv.DockClientManager.ReservedHost != null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QueueChild(new MoveToDock(self));
|
QueueChild(new MoveToDock(self, dockLineColor: dockClient.DockLineColor));
|
||||||
hasDeliveredLoad = true;
|
hasDeliveredLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -23,18 +24,20 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
Actor dockHostActor;
|
Actor dockHostActor;
|
||||||
IDockHost dockHost;
|
IDockHost dockHost;
|
||||||
readonly INotifyDockClientMoving[] notifyDockClientMoving;
|
readonly INotifyDockClientMoving[] notifyDockClientMoving;
|
||||||
|
readonly Color? dockLineColor;
|
||||||
readonly MoveCooldownHelper moveCooldownHelper;
|
readonly MoveCooldownHelper moveCooldownHelper;
|
||||||
readonly bool forceEnter;
|
readonly bool forceEnter;
|
||||||
readonly bool ignoreOccupancy;
|
readonly bool ignoreOccupancy;
|
||||||
|
|
||||||
public MoveToDock(Actor self, Actor dockHostActor = null, IDockHost dockHost = null,
|
public MoveToDock(Actor self, Actor dockHostActor = null, IDockHost dockHost = null,
|
||||||
bool forceEnter = false, bool ignoreOccupancy = false)
|
bool forceEnter = false, bool ignoreOccupancy = false, Color? dockLineColor = null)
|
||||||
{
|
{
|
||||||
dockClient = self.Trait<DockClientManager>();
|
dockClient = self.Trait<DockClientManager>();
|
||||||
this.dockHostActor = dockHostActor;
|
this.dockHostActor = dockHostActor;
|
||||||
this.dockHost = dockHost;
|
this.dockHost = dockHost;
|
||||||
this.forceEnter = forceEnter;
|
this.forceEnter = forceEnter;
|
||||||
this.ignoreOccupancy = ignoreOccupancy;
|
this.ignoreOccupancy = ignoreOccupancy;
|
||||||
|
this.dockLineColor = dockLineColor;
|
||||||
notifyDockClientMoving = self.TraitsImplementing<INotifyDockClientMoving>().ToArray();
|
notifyDockClientMoving = self.TraitsImplementing<INotifyDockClientMoving>().ToArray();
|
||||||
moveCooldownHelper = new MoveCooldownHelper(self.World, self.Trait<IMove>() as Mobile) { RetryIfDestinationBlocked = true };
|
moveCooldownHelper = new MoveCooldownHelper(self.World, self.Trait<IMove>() as Mobile) { RetryIfDestinationBlocked = true };
|
||||||
}
|
}
|
||||||
@@ -119,12 +122,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
|
||||||
{
|
{
|
||||||
|
if (!dockLineColor.HasValue)
|
||||||
|
yield break;
|
||||||
|
|
||||||
if (dockHostActor != null)
|
if (dockHostActor != null)
|
||||||
yield return new TargetLineNode(Target.FromActor(dockHostActor), dockClient.DockLineColor);
|
yield return new TargetLineNode(Target.FromActor(dockHostActor), dockLineColor.Value);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (dockClient.ReservedHostActor != null)
|
if (dockClient.ReservedHostActor != null)
|
||||||
yield return new TargetLineNode(Target.FromActor(dockClient.ReservedHostActor), dockClient.DockLineColor);
|
yield return new TargetLineNode(Target.FromActor(dockClient.ReservedHostActor), dockLineColor.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
target.Actor,
|
target.Actor,
|
||||||
null,
|
null,
|
||||||
order.OrderString == "ForceDock",
|
order.OrderString == "ForceDock",
|
||||||
true));
|
true,
|
||||||
|
DockLineColor));
|
||||||
|
|
||||||
self.ShowTargetLines();
|
self.ShowTargetLines();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user