Production now uses nearest exit to rally point.
This commit is contained in:
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
if (ShouldLandAtBuilding(self, dest))
|
if (ShouldLandAtBuilding(self, dest))
|
||||||
{
|
{
|
||||||
var exit = dest.FirstExitOrDefault();
|
var exit = dest.NearestExitOrDefault(self.CenterPosition);
|
||||||
var offset = WVec.Zero;
|
var offset = WVec.Zero;
|
||||||
if (exit != null)
|
if (exit != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
if (rp.Path.Count > 0)
|
if (rp.Path.Count > 0)
|
||||||
return rp.Path.Last();
|
return rp.Path.Last();
|
||||||
|
|
||||||
var exit = Self.FirstExitOrDefault();
|
var exit = Self.NearestExitOrDefault(Self.CenterPosition);
|
||||||
if (exit != null)
|
if (exit != null)
|
||||||
return Self.Location + exit.Info.ExitCell;
|
return Self.Location + exit.Info.ExitCell;
|
||||||
|
|
||||||
|
|||||||
@@ -46,16 +46,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public static class ExitExts
|
public static class ExitExts
|
||||||
{
|
{
|
||||||
public static Exit FirstExitOrDefault(this Actor actor, string productionType = null)
|
public static Exit NearestExitOrDefault(this Actor actor, WPos pos, string productionType = null, Func<Exit, bool> p = null)
|
||||||
{
|
{
|
||||||
var all = actor.TraitsImplementing<Exit>()
|
var all = Exits(actor, productionType)
|
||||||
.Where(Exts.IsTraitEnabled)
|
.OrderBy(e => e.Info.Priority)
|
||||||
.OrderBy(e => e.Info.Priority);
|
.ThenBy(e => (actor.CenterPosition + e.Info.SpawnOffset - pos).Length);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(productionType))
|
return p != null ? all.FirstOrDefault(p) : all.FirstOrDefault();
|
||||||
return all.FirstOrDefault();
|
|
||||||
|
|
||||||
return all.FirstOrDefault(e => e.Info.ProductionTypes.Count == 0 || e.Info.ProductionTypes.Contains(productionType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Exit> Exits(this Actor actor, string productionType = null)
|
public static IEnumerable<Exit> Exits(this Actor actor, string productionType = null)
|
||||||
|
|||||||
@@ -101,7 +101,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected virtual Exit SelectExit(Actor self, ActorInfo producee, string productionType, Func<Exit, bool> p)
|
protected virtual Exit SelectExit(Actor self, ActorInfo producee, string productionType, Func<Exit, bool> p)
|
||||||
{
|
{
|
||||||
|
if (!rp.IsValueCreated || rp.Value.Path.Count == 0)
|
||||||
return self.RandomExitOrDefault(self.World, productionType, p);
|
return self.RandomExitOrDefault(self.World, productionType, p);
|
||||||
|
|
||||||
|
return self.NearestExitOrDefault(self.World.Map.CenterOfCell(rp.Value.Path[0]), productionType, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Exit SelectExit(Actor self, ActorInfo producee, string productionType)
|
protected Exit SelectExit(Actor self, ActorInfo producee, string productionType)
|
||||||
|
|||||||
Reference in New Issue
Block a user