Expose targetline colors to yaml.

All targetlines can now be set to a custom color in yaml or set to be invisible.
All automated behaviours including scripted activities now have no visible target lines.
This commit is contained in:
tovl
2020-08-02 22:22:39 +02:00
committed by Paul Chote
parent ea3c7a3c34
commit 84eb3c54ef
41 changed files with 139 additions and 58 deletions

View File

@@ -131,7 +131,7 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
if (ChildActivity == null)
yield return new TargetLineNode(Target.FromActor(dest), Color.Green);
yield return new TargetLineNode(Target.FromActor(dest), aircraft.Info.TargetLineColor);
else
foreach (var n in ChildActivity.TargetLineNodes(self))
yield return n;

View File

@@ -22,8 +22,8 @@ namespace OpenRA.Mods.Common.Activities
Actor enterActor;
CaptureManager enterCaptureManager;
public CaptureActor(Actor self, in Target target)
: base(self, target, Color.Crimson)
public CaptureActor(Actor self, in Target target, Color? targetLineColor)
: base(self, target, targetLineColor)
{
manager = self.Trait<CaptureManager>();
}

View File

@@ -85,9 +85,9 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
if (proc != null)
yield return new TargetLineNode(Target.FromActor(proc), Color.Green);
yield return new TargetLineNode(Target.FromActor(proc), harv.Info.DeliverLineColor);
else
yield return new TargetLineNode(Target.FromActor(harv.LinkedProc), Color.Green);
yield return new TargetLineNode(Target.FromActor(harv.LinkedProc), harv.Info.DeliverLineColor);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
yield return new TargetLineNode(destination, Color.Yellow);
yield return new TargetLineNode(destination, carryall.Info.TargetLineColor);
}
class ReleaseUnit : Activity

View File

@@ -30,9 +30,9 @@ namespace OpenRA.Mods.Common.Activities
Actor enterActor;
IDemolishable[] enterDemolishables;
public Demolish(Actor self, in Target target, EnterBehaviour enterBehaviour, int delay,
int flashes, int flashesDelay, int flashInterval, BitSet<DamageType> damageTypes)
: base(self, target, Color.Crimson)
public Demolish(Actor self, in Target target, EnterBehaviour enterBehaviour, int delay, int flashes,
int flashesDelay, int flashInterval, BitSet<DamageType> damageTypes, Color? targetLineColor)
: base(self, target, targetLineColor)
{
notifiers = self.TraitsImplementing<INotifyDemolition>().ToArray();
this.delay = delay;

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.Common.Activities
readonly int payload;
readonly int playerExperience;
public DonateCash(Actor self, in Target target, int payload, int playerExperience)
: base(self, target, Color.Yellow)
public DonateCash(Actor self, in Target target, int payload, int playerExperience, Color? targetLineColor)
: base(self, target, targetLineColor)
{
this.payload = payload;
this.playerExperience = playerExperience;

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.Activities
Actor enterActor;
GainsExperience enterGainsExperience;
public DonateExperience(Actor self, in Target target, int level, int playerExperience)
: base(self, target, Color.Yellow)
public DonateExperience(Actor self, in Target target, int level, int playerExperience, Color? targetLineColor)
: base(self, target, targetLineColor)
{
this.level = level;
this.playerExperience = playerExperience;

View File

@@ -243,9 +243,9 @@ namespace OpenRA.Mods.Common.Activities
yield return n;
if (orderLocation != null)
yield return new TargetLineNode(Target.FromCell(self.World, orderLocation.Value), Color.Crimson);
yield return new TargetLineNode(Target.FromCell(self.World, orderLocation.Value), harvInfo.HarvestLineColor);
else if (deliverActor != null)
yield return new TargetLineNode(Target.FromActor(deliverActor), Color.Green);
yield return new TargetLineNode(Target.FromActor(deliverActor), harvInfo.DeliverLineColor);
}
CPos? GetSearchFromProcLocation(Actor self)

View File

@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
yield return new TargetLineNode(Target.FromCell(self.World, targetCell), Color.Crimson);
yield return new TargetLineNode(Target.FromCell(self.World, targetCell), harvInfo.HarvestLineColor);
}
}
}

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
yield return new TargetLineNode(Target.FromActor(cargo), Color.Yellow);
yield return new TargetLineNode(Target.FromActor(cargo), carryall.Info.TargetLineColor);
}
class AttachUnit : Activity

View File

@@ -24,8 +24,8 @@ namespace OpenRA.Mods.Common.Activities
BridgeHut enterHut;
LegacyBridgeHut enterLegacyHut;
public RepairBridge(Actor self, in Target target, EnterBehaviour enterBehaviour, string notification)
: base(self, target, Color.Yellow)
public RepairBridge(Actor self, in Target target, EnterBehaviour enterBehaviour, string notification, Color targetLineColor)
: base(self, target, targetLineColor)
{
this.enterBehaviour = enterBehaviour;
this.notification = notification;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities
EngineerRepairable enterEngineerRepariable;
public RepairBuilding(Actor self, in Target target, EngineerRepairInfo info)
: base(self, target, Color.Yellow)
: base(self, target, info.TargetLineColor)
{
this.info = info;
}

View File

@@ -33,6 +33,7 @@ namespace OpenRA.Mods.Common.Activities
readonly ICallForTransport[] transportCallers;
readonly IMove move;
readonly Aircraft aircraft;
readonly IMoveInfo moveInfo;
readonly bool stayOnResupplier;
readonly bool wasRepaired;
readonly PlayerResources playerResources;
@@ -58,6 +59,7 @@ namespace OpenRA.Mods.Common.Activities
transportCallers = self.TraitsImplementing<ICallForTransport>().ToArray();
move = self.Trait<IMove>();
aircraft = move as Aircraft;
moveInfo = self.Info.TraitInfo<IMoveInfo>();
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
var valued = self.Info.TraitInfoOrDefault<ValuedInfo>();
@@ -129,13 +131,12 @@ namespace OpenRA.Mods.Common.Activities
else if (activeResupplyTypes != 0 && aircraft == null && !isCloseEnough)
{
var targetCell = self.World.Map.CellContaining(host.Actor.CenterPosition);
QueueChild(move.MoveWithinRange(host, closeEnough, targetLineColor: Color.Green));
QueueChild(move.MoveWithinRange(host, closeEnough, targetLineColor: moveInfo.GetTargetLineColor()));
// HACK: Repairable needs the actor to move to host center.
// TODO: Get rid of this or at least replace it with something less hacky.
if (repairableNear == null)
QueueChild(move.MoveTo(targetCell, targetLineColor: Color.Green));
QueueChild(move.MoveTo(targetCell, targetLineColor: moveInfo.GetTargetLineColor()));
var delta = (self.CenterPosition - host.CenterPosition).LengthSquared;
transportCallers.FirstOrDefault(t => t.MinimumDistance.LengthSquared < delta)?.RequestTransport(self, targetCell);
@@ -189,7 +190,7 @@ namespace OpenRA.Mods.Common.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
if (ChildActivity == null)
yield return new TargetLineNode(host, Color.Green);
yield return new TargetLineNode(host, moveInfo.GetTargetLineColor());
else
{
var current = ChildActivity;
@@ -212,7 +213,7 @@ namespace OpenRA.Mods.Common.Activities
{
if (self.CurrentActivity.NextActivity == null && rp != null && rp.Path.Count > 0)
foreach (var cell in rp.Path)
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(cell, 1, ignoreActor: repairableNear != null ? null : host.Actor, targetLineColor: Color.OrangeRed)));
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(cell, 1, ignoreActor: repairableNear != null ? null : host.Actor, targetLineColor: aircraft.Info.TargetLineColor)));
else
QueueChild(new TakeOff(self));
@@ -233,7 +234,7 @@ namespace OpenRA.Mods.Common.Activities
{
if (rp != null && rp.Path.Count > 0)
foreach (var cell in rp.Path)
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(cell, 1, repairableNear != null ? null : host.Actor, true, Color.OrangeRed)));
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(cell, 1, repairableNear != null ? null : host.Actor, true, moveInfo.GetTargetLineColor())));
else if (repairableNear == null)
QueueChild(move.MoveToTarget(self, host));
}

View File

@@ -23,8 +23,8 @@ namespace OpenRA.Mods.Common.Activities
Cargo enterCargo;
Aircraft enterAircraft;
public RideTransport(Actor self, in Target target)
: base(self, target, Color.Green)
public RideTransport(Actor self, in Target target, Color? targetLineColor)
: base(self, target, targetLineColor)
{
passenger = self.Trait<Passenger>();
}