Use OccupiesSpace to save more trait look-ups

This time in Locomotor.IsBlockedBy.
This commit is contained in:
reaperrr
2020-05-30 09:56:35 +02:00
committed by Matthias Mailänder
parent 55e85bd9ca
commit f58c3aed32

View File

@@ -348,7 +348,7 @@ namespace OpenRA.Mods.Common.Traits
if (check <= BlockedByActor.Immovable && cellFlag.HasCellFlag(CellFlag.HasMovableActor) &&
actor.Owner.Stances[otherActor.Owner] == Stance.Ally)
{
var mobile = otherActor.TraitOrDefault<Mobile>();
var mobile = otherActor.OccupiesSpace as Mobile;
if (mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable)
return false;
}
@@ -369,7 +369,7 @@ namespace OpenRA.Mods.Common.Traits
if (cellFlag.HasCellFlag(CellFlag.HasTransitOnlyActor))
{
// Transit only tiles should not block movement
var building = otherActor.TraitOrDefault<Building>();
var building = otherActor.OccupiesSpace as Building;
if (building != null && building.TransitOnlyCells().Contains(cell))
return false;
}