HitShape, query trait via actor cached targetable positions.
This commit is contained in:
committed by
Matthias Mailänder
parent
f88b6d78ff
commit
e3aa2dc6c0
@@ -50,8 +50,14 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
if (!IsValidAgainst(victim, firedBy))
|
||||
return;
|
||||
|
||||
var closestActiveShape = victim.TraitsImplementing<HitShape>().Where(Exts.IsTraitEnabled)
|
||||
.MinByOrDefault(t => t.DistanceFromEdge(victim, victim.CenterPosition));
|
||||
// PERF: Avoid using TraitsImplementing<HitShape> that needs to find the actor in the trait dictionary.
|
||||
var closestActiveShape = (HitShape)victim.EnabledTargetablePositions.MinByOrDefault(t =>
|
||||
{
|
||||
if (t is HitShape h)
|
||||
return h.DistanceFromEdge(victim, victim.CenterPosition);
|
||||
else
|
||||
return WDist.MaxValue;
|
||||
});
|
||||
|
||||
// Cannot be damaged without an active HitShape
|
||||
if (closestActiveShape == null)
|
||||
|
||||
Reference in New Issue
Block a user