Fix rally point target line exit display.
This commit is contained in:
@@ -23,16 +23,14 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
readonly RallyPoint rp;
|
readonly RallyPoint rp;
|
||||||
readonly Animation flag;
|
readonly Animation flag;
|
||||||
readonly Animation circles;
|
readonly Animation circles;
|
||||||
readonly ExitInfo[] exits;
|
|
||||||
|
|
||||||
List<WPos> targetLineNodes = new List<WPos> { };
|
List<WPos> targetLineNodes = new List<WPos> { };
|
||||||
List<CPos> cachedLocations;
|
List<CPos> cachedLocations;
|
||||||
|
|
||||||
public RallyPointIndicator(Actor building, RallyPoint rp, ExitInfo[] exits)
|
public RallyPointIndicator(Actor building, RallyPoint rp)
|
||||||
{
|
{
|
||||||
this.building = building;
|
this.building = building;
|
||||||
this.rp = rp;
|
this.rp = rp;
|
||||||
this.exits = exits;
|
|
||||||
|
|
||||||
if (rp.Info.Image != null)
|
if (rp.Info.Image != null)
|
||||||
{
|
{
|
||||||
@@ -73,21 +71,8 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
if (targetLineNodes.Count == 0)
|
if (targetLineNodes.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var exitPos = building.CenterPosition;
|
var exit = building.NearestExitOrDefault(targetLineNodes[0]);
|
||||||
|
var exitPos = exit != null ? building.World.Map.CenterOfCell(building.Location + exit.Info.ExitCell) : building.CenterPosition;
|
||||||
// Find closest exit
|
|
||||||
var dist = int.MaxValue;
|
|
||||||
foreach (var exit in exits)
|
|
||||||
{
|
|
||||||
var ep = building.CenterPosition + exit.SpawnOffset;
|
|
||||||
var len = (targetLineNodes[0] - ep).Length;
|
|
||||||
if (len < dist)
|
|
||||||
{
|
|
||||||
dist = len;
|
|
||||||
exitPos = ep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
targetLineNodes.Insert(0, exitPos);
|
targetLineNodes.Insert(0, exitPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,13 +75,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
// Display only the first level of priority
|
self.World.Add(new RallyPointIndicator(self, this));
|
||||||
var priorityExits = self.Info.TraitInfos<ExitInfo>()
|
|
||||||
.GroupBy(e => e.Priority)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
var exits = priorityExits != null ? priorityExits.ToArray() : new ExitInfo[0];
|
|
||||||
self.World.Add(new RallyPointIndicator(self, this, exits));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
|||||||
Reference in New Issue
Block a user