HitShape, query trait via actor cached targetable positions.
This commit is contained in:
committed by
Matthias Mailänder
parent
f88b6d78ff
commit
e3aa2dc6c0
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
@@ -49,9 +49,11 @@ namespace OpenRA.Mods.Common
|
||||
foreach (var currActor in actorsInSquare)
|
||||
{
|
||||
var actorWidth = 0;
|
||||
var shapes = currActor.TraitsImplementing<HitShape>().Where(Exts.IsTraitEnabled);
|
||||
if (shapes.Any())
|
||||
actorWidth = shapes.Max(h => h.Info.Type.OuterRadius.Length);
|
||||
|
||||
// PERF: Avoid using TraitsImplementing<HitShape> that needs to find the actor in the trait dictionary.
|
||||
foreach (var targetPos in currActor.EnabledTargetablePositions)
|
||||
if (targetPos is HitShape hitshape)
|
||||
actorWidth = Math.Max(actorWidth, hitshape.Info.Type.OuterRadius.Length);
|
||||
|
||||
var projection = lineStart.MinimumPointLineProjection(lineEnd, currActor.CenterPosition);
|
||||
var distance = (currActor.CenterPosition - projection).HorizontalLength;
|
||||
|
||||
Reference in New Issue
Block a user