Eradicate ☠ Mono ☠

Co-Authored-By: Gustas <37534529+punkpun@users.noreply.github.com>
This commit is contained in:
michaeldgg2
2024-09-13 23:01:58 +02:00
committed by Pavel Penev
parent 5450572e0a
commit c7cc9a68fd
35 changed files with 89 additions and 634 deletions

View File

@@ -48,14 +48,9 @@ namespace OpenRA.Mods.Common.Traits
{
public static Exit NearestExitOrDefault(this Actor actor, WPos pos, string productionType = null, Func<Exit, bool> p = null)
{
// The .ToList() is required to work around a bug/unexpected behaviour in mono, where
// the ThenBy clause makes the FirstOrDefault behave differently than under .NET.
// This is important because p may have side-effects that trigger a desync if not
// called on the same exits in the same order!
var all = Exits(actor, productionType)
.OrderByDescending(e => e.Info.Priority)
.ThenBy(e => (actor.World.Map.CenterOfCell(actor.Location + e.Info.ExitCell) - pos).LengthSquared)
.ToList();
.ThenBy(e => (actor.World.Map.CenterOfCell(actor.Location + e.Info.ExitCell) - pos).LengthSquared);
#pragma warning disable RCS1077 // Optimize LINQ method call.
return p != null ? all.FirstOrDefault(p) : all.FirstOrDefault();