Clean up usage of DomainIndex

- When a path search is being performed the path search will not attempt route to inaccessible cells, so domain index checks to avoid inaccessible cells in the search predicate are redundant and can be removed.
- DomainIndex is a required world trait, so we don't need to use TraitOrDefault and therefore can avoid dealing with the null case.
This commit is contained in:
RoosterDragon
2022-01-30 14:19:26 +00:00
committed by Matthias Mailänder
parent 4b4b0125a2
commit 2ab3917f29
6 changed files with 4 additions and 15 deletions

View File

@@ -22,7 +22,6 @@ namespace OpenRA.Mods.Common.Activities
public class MoveAdjacentTo : Activity
{
protected readonly Mobile Mobile;
readonly DomainIndex domainIndex;
readonly Color? targetLineColor;
protected Target Target => useLastVisibleTarget ? lastVisibleTarget : target;
@@ -37,7 +36,6 @@ namespace OpenRA.Mods.Common.Activities
this.target = target;
this.targetLineColor = targetLineColor;
Mobile = self.Trait<Mobile>();
domainIndex = self.World.WorldActor.Trait<DomainIndex>();
ChildHasPriority = false;
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
@@ -123,7 +121,7 @@ namespace OpenRA.Mods.Common.Activities
searchCells.Clear();
searchCellsTick = self.World.WorldTick;
foreach (var cell in CandidateMovementCells(self))
if (domainIndex.IsPassable(loc, cell, Mobile.Locomotor) && Mobile.CanEnterCell(cell))
if (Mobile.CanEnterCell(cell))
searchCells.Add(cell);
}