From 9f9d1f9e5f7dcc264ec7e2740c2a66c77c9eab2c Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 4 May 2017 14:12:16 +0200 Subject: [PATCH] Added helper utility for finding best hit-shape scan radius --- OpenRA.Mods.Common/Util.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OpenRA.Mods.Common/Util.cs b/OpenRA.Mods.Common/Util.cs index f2820bf75e..c1b8f33521 100644 --- a/OpenRA.Mods.Common/Util.cs +++ b/OpenRA.Mods.Common/Util.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenRA.GameRules; using OpenRA.Mods.Common.Traits; using OpenRA.Support; using OpenRA.Traits; @@ -175,5 +176,18 @@ namespace OpenRA.Mods.Common return world.SharedRandom.Next(range[0], range[1]); } + + // TODO: Investigate caching this or moving it to ActorMapInfo + public static WDist MinimumRequiredVictimScanRadius(Ruleset rules) + { + return rules.Actors.SelectMany(a => a.Value.TraitInfos()).Max(h => h.Shape.OuterRadius); + } + + // TODO: Investigate caching this or moving it to ActorMapInfo + public static WDist MinimumRequiredBlockerScanRadius(Ruleset rules) + { + return rules.Actors.Where(a => a.Value.HasTraitInfo()) + .SelectMany(a => a.Value.TraitInfos()).Max(h => h.Shape.OuterRadius); + } } }