Refineries now show which harvesters are linked by holding down ALT key.

This commit is contained in:
James Dunne
2012-06-24 17:58:14 -05:00
parent 845379e577
commit 1f0da42a15
6 changed files with 75 additions and 30 deletions

View File

@@ -11,6 +11,7 @@
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Effects;
using System.Collections.Generic;
namespace OpenRA.Traits
{
@@ -25,7 +26,7 @@ namespace OpenRA.Traits
{
Actor self;
DrawLineToTargetInfo Info;
Target target;
List<Target> targets;
Color c;
int lifetime;
@@ -33,7 +34,16 @@ namespace OpenRA.Traits
public void SetTarget(Actor self, Target target, Color c, bool display)
{
this.target = target;
this.targets = new List<Target> { target };
this.c = c;
if (display)
lifetime = Info.Ticks;
}
public void SetTargets(Actor self, List<Target> targets, Color c, bool display)
{
this.targets = targets;
this.c = c;
if (display)
@@ -42,13 +52,13 @@ namespace OpenRA.Traits
public void RenderAfterWorld(WorldRenderer wr)
{
if (self.IsIdle) return;
//if (self.IsIdle) return;
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
if ((lifetime <= 0 || --lifetime <= 0) && !force)
return;
if (!target.IsValid)
if (targets == null || targets.Count == 0)
return;
var move = self.TraitOrDefault<IMove>();
@@ -56,9 +66,15 @@ namespace OpenRA.Traits
var wlr = Game.Renderer.WorldLineRenderer;
wlr.DrawLine(origin, target.CenterLocation.ToFloat2(), c, c);
DrawTargetMarker(wlr, target.CenterLocation.ToFloat2());
DrawTargetMarker(wlr, origin);
foreach (var target in targets)
{
if (!target.IsValid)
continue;
wlr.DrawLine(origin, target.CenterLocation.ToFloat2(), c, c);
DrawTargetMarker(wlr, target.CenterLocation.ToFloat2());
DrawTargetMarker(wlr, origin);
}
}
void DrawTargetMarker(LineRenderer wlr, float2 p)
@@ -72,6 +88,18 @@ namespace OpenRA.Traits
public static class LineTargetExts
{
public static void SetTargetLines(this Actor self, List<Target> targets, Color color)
{
var line = self.TraitOrDefault<DrawLineToTarget>();
if (line != null)
{
self.World.AddFrameEndTask(w =>
{
line.SetTargets(self, targets, color, false);
});
}
}
public static void SetTargetLine(this Actor self, Target target, Color color)
{
self.SetTargetLine(target, color, true);