In CanMoveFreelyInto, check if transient actor checks are needed at the start.
When transient actors checks are not needed, all control flows in the method return true. Therefore, we can return true directly in this case. Checking this condition is cheaper than checking for a free sub-cell, so this allows us a faster exit when we don't need to check for transient actors.
This commit is contained in:
@@ -194,10 +194,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Determines whether the actor is blocked by other Actors
|
||||
public bool CanMoveFreelyInto(World world, Actor self, CPos cell, Actor ignoreActor, CellConditions check)
|
||||
{
|
||||
if (!check.HasCellCondition(CellConditions.TransientActors))
|
||||
return true;
|
||||
|
||||
if (SharesCell && world.ActorMap.HasFreeSubCell(cell))
|
||||
return true;
|
||||
|
||||
if (check.HasCellCondition(CellConditions.TransientActors))
|
||||
foreach (var otherActor in world.ActorMap.GetUnitsAt(cell))
|
||||
if (IsBlockedBy(self, otherActor, ignoreActor, check))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user