Save Mobile trait look-up in AttackBase

This commit is contained in:
reaperrr
2021-02-13 01:18:18 +01:00
committed by Paul Chote
parent 11171ff649
commit a1f974bd40

View File

@@ -152,7 +152,8 @@ namespace OpenRA.Mods.Common.Traits
if (!HasAnyValidWeapons(target))
return false;
var mobile = self.TraitOrDefault<Mobile>();
// PERF: Mobile implements IPositionable, so we can use 'as' to save a trait look-up here.
var mobile = positionable as Mobile;
if (mobile != null && !mobile.CanInteractWithGroundLayer(self))
return false;