Remove ApplyToAllTargetablePositions hack from RectangleShape

In its current form it is bad for performance due to the ITargetablePositions look-up, and fixing that only to remove the hack entirely a few weeks later would be kind of pointless, so let's get this over with.
This commit is contained in:
reaperrr
2017-06-29 01:34:52 +02:00
parent f75115a645
commit 3f8efb1163
2 changed files with 26 additions and 30 deletions

View File

@@ -749,6 +749,28 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
// Removed ApplyToAllTargetablePositions hack from Rectangle shape
if (engineVersion < 20170629)
{
if (node.Key.StartsWith("HitShape", StringComparison.Ordinal))
{
var shape = node.Value.Nodes.FirstOrDefault(n => n.Key == "Type" && n.Value.Value == "Rectangle");
if (shape != null)
{
var hack = shape.Value.Nodes.FirstOrDefault(n => n.Key == "ApplyToAllTargetablePositions");
if (hack != null)
{
Console.WriteLine("Rectangle.ApplyToAllTargetablePositions has been removed due to incompatibilities");
Console.WriteLine("with the HitShape refactor and projectile/warhead victim scans, as well as performance concerns.");
Console.WriteLine("If you absolutely want to use it, please ship a duplicate of the old Rectangle code with your mod code.");
Console.WriteLine("Otherwise, we recommend using inheritable shape templates for rectangular buildings");
Console.WriteLine("and custom setups for the rest (see our official mods for examples).");
shape.Value.Nodes.Remove(hack);
}
}
}
}
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
}