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:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -37,7 +37,8 @@ namespace OpenRA.Mods.Cnc.Scripting
|
||||
if (infiltrates == null)
|
||||
throw new LuaException("{0} tried to infiltrate invalid target {1}!".F(Self, target));
|
||||
|
||||
Self.QueueActivity(new Infiltrate(Self, Target.FromActor(target), infiltrates));
|
||||
// NB: Scripted actions get no visible targetlines.
|
||||
Self.QueueActivity(new Infiltrate(Self, Target.FromActor(target), infiltrates, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[VoiceReference]
|
||||
public readonly string Voice = "Action";
|
||||
|
||||
[Desc("Color to use for the target line.")]
|
||||
public readonly Color TargetLineColor = Color.Crimson;
|
||||
|
||||
[Desc("What diplomatic stances can be infiltrated by this actor.")]
|
||||
public readonly PlayerRelationship ValidStances = PlayerRelationship.Neutral | PlayerRelationship.Enemy;
|
||||
|
||||
@@ -115,7 +118,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (!CanInfiltrateTarget(self, order.Target))
|
||||
return;
|
||||
|
||||
self.QueueActivity(order.Queued, new Infiltrate(self, order.Target, this));
|
||||
self.QueueActivity(order.Queued, new Infiltrate(self, order.Target, this, Info.TargetLineColor));
|
||||
self.ShowTargetLines();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Cnc.Activities;
|
||||
using OpenRA.Mods.Common.Orders;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
@@ -34,6 +35,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("Voice to use when ordered to lay a minefield.")]
|
||||
public readonly string Voice = "Action";
|
||||
|
||||
[Desc("Color to use for the target line when laying mines.")]
|
||||
public readonly Color TargetLineColor = Color.Crimson;
|
||||
|
||||
[Desc("Sprite overlay to use for valid minefield cells.")]
|
||||
public readonly string TileValidName = "build-valid";
|
||||
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
[Desc("Range circle border width.")]
|
||||
public readonly float CircleBorderWidth = 3;
|
||||
|
||||
[Desc("Color to use for the target line.")]
|
||||
public readonly Color TargetLineColor = Color.LawnGreen;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new PortableChrono(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -128,10 +131,10 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
var cell = self.World.Map.CellContaining(order.Target.CenterPosition);
|
||||
if (maxDistance != null)
|
||||
self.QueueActivity(move.MoveWithinRange(order.Target, WDist.FromCells(maxDistance.Value), targetLineColor: Color.LawnGreen));
|
||||
self.QueueActivity(move.MoveWithinRange(order.Target, WDist.FromCells(maxDistance.Value), targetLineColor: Info.TargetLineColor));
|
||||
|
||||
self.QueueActivity(new Teleport(self, cell, maxDistance, Info.KillCargo, Info.FlashScreen, Info.ChronoshiftSound));
|
||||
self.QueueActivity(move.MoveTo(cell, 5, targetLineColor: Color.LawnGreen));
|
||||
self.QueueActivity(move.MoveTo(cell, 5, targetLineColor: Info.TargetLineColor));
|
||||
self.ShowTargetLines();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
public override object Create(ActorInitializer init) { return new TDGunboat(init, this); }
|
||||
|
||||
public WAngle GetInitialFacing() { return InitialFacing; }
|
||||
public Color GetTargetLineColor() { return Color.Green; }
|
||||
|
||||
IEnumerable<ActorInit> IActorPreviewInitInfo.ActorPreviewInits(ActorInfo ai, ActorPreviewType type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user