Refineries now show which harvesters are linked by holding down ALT key.
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
Actor self;
|
Actor self;
|
||||||
DrawLineToTargetInfo Info;
|
DrawLineToTargetInfo Info;
|
||||||
Target target;
|
List<Target> targets;
|
||||||
Color c;
|
Color c;
|
||||||
int lifetime;
|
int lifetime;
|
||||||
|
|
||||||
@@ -33,7 +34,16 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void SetTarget(Actor self, Target target, Color c, bool display)
|
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;
|
this.c = c;
|
||||||
|
|
||||||
if (display)
|
if (display)
|
||||||
@@ -42,13 +52,13 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void RenderAfterWorld(WorldRenderer wr)
|
public void RenderAfterWorld(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (self.IsIdle) return;
|
//if (self.IsIdle) return;
|
||||||
|
|
||||||
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
|
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
|
||||||
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!target.IsValid)
|
if (targets == null || targets.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var move = self.TraitOrDefault<IMove>();
|
var move = self.TraitOrDefault<IMove>();
|
||||||
@@ -56,9 +66,15 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
var wlr = Game.Renderer.WorldLineRenderer;
|
var wlr = Game.Renderer.WorldLineRenderer;
|
||||||
|
|
||||||
wlr.DrawLine(origin, target.CenterLocation.ToFloat2(), c, c);
|
foreach (var target in targets)
|
||||||
DrawTargetMarker(wlr, target.CenterLocation.ToFloat2());
|
{
|
||||||
DrawTargetMarker(wlr, origin);
|
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)
|
void DrawTargetMarker(LineRenderer wlr, float2 p)
|
||||||
@@ -72,6 +88,18 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public static class LineTargetExts
|
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)
|
public static void SetTargetLine(this Actor self, Target target, Color color)
|
||||||
{
|
{
|
||||||
self.SetTargetLine(target, color, true);
|
self.SetTargetLine(target, color, true);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
harv.LinkedProc = harv.OwnerLinkedProc;
|
harv.LinkProc(self, harv.OwnerLinkedProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld)
|
if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld)
|
||||||
|
|||||||
@@ -82,16 +82,6 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
ResourceClaim claim;
|
ResourceClaim claim;
|
||||||
if (territory.IsClaimedByAnyoneElse(self, loc, out claim)) return 1;
|
if (territory.IsClaimedByAnyoneElse(self, loc, out claim)) return 1;
|
||||||
|
|
||||||
#if false
|
|
||||||
// Is anyone covering the location already?
|
|
||||||
// NOTE(jsd): This is required to prevent harvester deadlocking.
|
|
||||||
var unitsAtLoc =
|
|
||||||
from u in self.World.FindUnits(loc.ToPPos(), loc.ToPPos() + PVecInt.OneCell)
|
|
||||||
where u != self
|
|
||||||
select u;
|
|
||||||
if (unitsAtLoc.Any()) return 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
})
|
})
|
||||||
.FromPoint(self.Location)
|
.FromPoint(self.Location)
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA
|
|||||||
return this;
|
return this;
|
||||||
case State.Complete:
|
case State.Complete:
|
||||||
harv.LastLinkedProc = harv.LinkedProc;
|
harv.LastLinkedProc = harv.LinkedProc;
|
||||||
harv.LinkedProc = null;
|
harv.LinkProc(self, null);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
throw new InvalidOperationException("Invalid harvester dock state");
|
throw new InvalidOperationException("Invalid harvester dock state");
|
||||||
|
|||||||
@@ -50,10 +50,36 @@ namespace OpenRA.Mods.RA
|
|||||||
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
self.QueueActivity(new CallFunc(() => ChooseNewProc(self, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetProcLines(Actor proc)
|
||||||
|
{
|
||||||
|
if (proc == null) return;
|
||||||
|
|
||||||
|
var linkedHarvs = proc.World.ActorsWithTrait<Harvester>()
|
||||||
|
.Where(a => a.Trait.LinkedProc == proc)
|
||||||
|
.Select(a => Target.FromActor(a.Actor))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
proc.SetTargetLines(linkedHarvs, Color.Gold);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LinkProc(Actor self, Actor proc)
|
||||||
|
{
|
||||||
|
var oldProc = LinkedProc;
|
||||||
|
LinkedProc = proc;
|
||||||
|
SetProcLines(oldProc);
|
||||||
|
SetProcLines(proc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnlinkProc(Actor self, Actor proc)
|
||||||
|
{
|
||||||
|
if (LinkedProc == proc)
|
||||||
|
ChooseNewProc(self, proc);
|
||||||
|
}
|
||||||
|
|
||||||
public void ChooseNewProc(Actor self, Actor ignore)
|
public void ChooseNewProc(Actor self, Actor ignore)
|
||||||
{
|
{
|
||||||
LinkedProc = ClosestProc(self, ignore);
|
|
||||||
LastLinkedProc = null;
|
LastLinkedProc = null;
|
||||||
|
LinkProc(self, ClosestProc(self, ignore));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ContinueHarvesting(Actor self)
|
public void ContinueHarvesting(Actor self)
|
||||||
@@ -121,9 +147,11 @@ namespace OpenRA.Mods.RA
|
|||||||
// Get out of the way:
|
// Get out of the way:
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
var harv = self.Trait<Harvester>();
|
var harv = self.Trait<Harvester>();
|
||||||
|
|
||||||
var moveTo = harv.LastHarvestedCell ?? (deliveryLoc + new CVec(0, 4));
|
var moveTo = harv.LastHarvestedCell ?? (deliveryLoc + new CVec(0, 4));
|
||||||
self.QueueActivity(mobile.MoveTo(moveTo, 1));
|
self.QueueActivity(mobile.MoveTo(moveTo, 1));
|
||||||
self.SetTargetLine(Target.FromCell(moveTo), Color.Red, false);
|
self.SetTargetLine(Target.FromCell(moveTo), Color.Gray, false);
|
||||||
|
|
||||||
self.World.WorldActor.Trait<ResourceClaimLayer>().ClaimResource(self, moveTo);
|
self.World.WorldActor.Trait<ResourceClaimLayer>().ClaimResource(self, moveTo);
|
||||||
self.QueueActivity(new FindResources());
|
self.QueueActivity(new FindResources());
|
||||||
return;
|
return;
|
||||||
@@ -140,7 +168,11 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
self.QueueActivity(mobile.MoveTo(mobile.NearestMoveableCell(cell, 2, 5), 0));
|
|
||||||
|
var moveTo = mobile.NearestMoveableCell(cell, 2, 5);
|
||||||
|
self.QueueActivity(mobile.MoveTo(moveTo, 0));
|
||||||
|
self.SetTargetLine(Target.FromCell(moveTo), Color.Gray, false);
|
||||||
|
|
||||||
// Find more resources but not at this location:
|
// Find more resources but not at this location:
|
||||||
self.QueueActivity(new FindResources(cell));
|
self.QueueActivity(new FindResources(cell));
|
||||||
}
|
}
|
||||||
@@ -218,7 +250,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "Harvest")
|
if (order.OrderString == "Harvest")
|
||||||
{
|
{
|
||||||
// NOTE: An explicit harvest order allows the harvester to decide which refinery to deliver to.
|
// NOTE: An explicit harvest order allows the harvester to decide which refinery to deliver to.
|
||||||
OwnerLinkedProc = null;
|
LinkProc(self, OwnerLinkedProc = null);
|
||||||
|
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
@@ -245,7 +277,7 @@ namespace OpenRA.Mods.RA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (order.TargetActor != OwnerLinkedProc)
|
if (order.TargetActor != OwnerLinkedProc)
|
||||||
LinkedProc = OwnerLinkedProc = order.TargetActor;
|
LinkProc(self, OwnerLinkedProc = order.TargetActor);
|
||||||
|
|
||||||
if (IsEmpty)
|
if (IsEmpty)
|
||||||
return;
|
return;
|
||||||
@@ -257,12 +289,6 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnlinkProc(Actor self, Actor proc)
|
|
||||||
{
|
|
||||||
if (LinkedProc == proc)
|
|
||||||
ChooseNewProc(self, proc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnNotifyResourceClaimLost(Actor self, ResourceClaim claim, Actor claimer)
|
public void OnNotifyResourceClaimLost(Actor self, ResourceClaim claim, Actor claimer)
|
||||||
{
|
{
|
||||||
if (self == claimer) return;
|
if (self == claimer) return;
|
||||||
|
|||||||
@@ -872,6 +872,7 @@ PROC:
|
|||||||
PipCount: 17
|
PipCount: 17
|
||||||
Capacity: 2000
|
Capacity: 2000
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
DrawLineToTarget:
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
Value: 600
|
Value: 600
|
||||||
FreeActor:
|
FreeActor:
|
||||||
|
|||||||
Reference in New Issue
Block a user