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

@@ -24,8 +24,8 @@ namespace OpenRA.Mods.Cnc.Activities
readonly INotifyInfiltration[] notifiers;
Actor enterActor;
public Infiltrate(Actor self, in Target target, Infiltrates infiltrates)
: base(self, target, Color.Crimson)
public Infiltrate(Actor self, in Target target, Infiltrates infiltrates, Color? targetLineColor)
: base(self, target, targetLineColor)
{
this.infiltrates = infiltrates;
notifiers = self.TraitsImplementing<INotifyInfiltration>().ToArray();

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Mods.Cnc.Activities
readonly Minelayer minelayer;
readonly AmmoPool[] ammoPools;
readonly IMove movement;
readonly IMoveInfo moveInfo;
readonly RearmableInfo rearmableInfo;
List<CPos> minefield;
@@ -37,6 +38,7 @@ namespace OpenRA.Mods.Cnc.Activities
minelayer = self.Trait<Minelayer>();
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
movement = self.Trait<IMove>();
moveInfo = self.Info.TraitInfo<IMoveInfo>();
rearmableInfo = self.Info.TraitInfoOrDefault<RearmableInfo>();
this.minefield = minefield;
}
@@ -118,17 +120,17 @@ namespace OpenRA.Mods.Cnc.Activities
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)
{
if (returnToBase)
yield return new TargetLineNode(Target.FromActor(rearmTarget), Color.Green);
yield return new TargetLineNode(Target.FromActor(rearmTarget), moveInfo.GetTargetLineColor());
if (minefield == null || minefield.Count == 0)
yield break;
var nextCell = NextValidCell(self);
if (nextCell != null)
yield return new TargetLineNode(Target.FromCell(self.World, nextCell.Value), Color.Crimson);
yield return new TargetLineNode(Target.FromCell(self.World, nextCell.Value), minelayer.Info.TargetLineColor);
foreach (var c in minefield)
yield return new TargetLineNode(Target.FromCell(self.World, c), Color.Crimson, tile: minelayer.Tile);
yield return new TargetLineNode(Target.FromCell(self.World, c), minelayer.Info.TargetLineColor, tile: minelayer.Tile);
}
static bool CanLayMine(Actor self, CPos p)