Prefer own service depots over allies.

This commit is contained in:
Paul Chote
2019-05-19 17:56:35 +01:00
committed by abcdefg30
parent 217221d174
commit c480b2b599
2 changed files with 4 additions and 2 deletions

View File

@@ -155,7 +155,8 @@ namespace OpenRA.Mods.Common.Traits
.Where(a => !a.Actor.IsDead && a.Actor.IsInWorld
&& a.Actor.Owner.IsAlliedWith(self.Owner) &&
Info.RepairActors.Contains(a.Actor.Info.Name))
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
.OrderBy(a => a.Actor.Owner == self.Owner ? 0 : 1)
.ThenBy(p => (self.Location - p.Actor.Location).LengthSquared);
// Worst case FirstOrDefault() will return a TraitPair<null, null>, which is OK.
return repairBuilding.FirstOrDefault().Actor;

View File

@@ -99,7 +99,8 @@ namespace OpenRA.Mods.Common.Traits
.Where(a => !a.Actor.IsDead && a.Actor.IsInWorld
&& a.Actor.Owner.IsAlliedWith(self.Owner) &&
Info.RepairActors.Contains(a.Actor.Info.Name))
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
.OrderBy(a => a.Actor.Owner == self.Owner ? 0 : 1)
.ThenBy(p => (self.Location - p.Actor.Location).LengthSquared);
// Worst case FirstOrDefault() will return a TraitPair<null, null>, which is OK.
return repairBuilding.FirstOrDefault().Actor;