Skip check for ITemporaryBlocker entirely if rules don't contain any temporary blockers
This benefits all mods without temporary blockers like gates or energy walls.
This commit is contained in:
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Will open and be passable for actors that appear friendly when there are no enemies in range.")]
|
||||
public class GateInfo : PausableConditionalTraitInfo, IBlocksProjectilesInfo, Requires<BuildingInfo>
|
||||
public class GateInfo : PausableConditionalTraitInfo, ITemporaryBlockerInfo, IBlocksProjectilesInfo, Requires<BuildingInfo>
|
||||
{
|
||||
public readonly string OpeningSound = null;
|
||||
public readonly string ClosingSound = null;
|
||||
|
||||
@@ -268,10 +268,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
IsMovingInMyDirection(self, otherActor))
|
||||
return false;
|
||||
|
||||
// If there is a temporary blocker in our path, but we can remove it, we are not blocked.
|
||||
var temporaryBlocker = otherActor.TraitOrDefault<ITemporaryBlocker>();
|
||||
if (temporaryBlocker != null && temporaryBlocker.CanRemoveBlockage(otherActor, self))
|
||||
return false;
|
||||
// PERF: Only perform ITemporaryBlocker trait look-up if mod/map rules contain any actors that are temporary blockers
|
||||
if (self.World.RulesContainTemporaryBlocker)
|
||||
{
|
||||
// If there is a temporary blocker in our path, but we can remove it, we are not blocked.
|
||||
var temporaryBlocker = otherActor.TraitOrDefault<ITemporaryBlocker>();
|
||||
if (temporaryBlocker != null && temporaryBlocker.CanRemoveBlockage(otherActor, self))
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we cannot crush the other actor in our way, we are blocked.
|
||||
if (Crushes == null || Crushes.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user