Replace IDisableMove with upgradability

This commit is contained in:
atlimit8
2015-09-25 16:55:33 -05:00
parent 0fc04b7a4a
commit c827dbe183
23 changed files with 82 additions and 77 deletions

View File

@@ -25,7 +25,6 @@ namespace OpenRA.Mods.Common.Activities
static readonly List<CPos> NoPath = new List<CPos>();
readonly Mobile mobile;
readonly IDisableMove[] moveDisablers;
readonly WDist nearEnough;
readonly Func<List<CPos>> getPath;
readonly Actor ignoredActor;
@@ -43,7 +42,6 @@ namespace OpenRA.Mods.Common.Activities
public Move(Actor self, CPos destination)
{
mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
getPath = () =>
{
@@ -65,7 +63,6 @@ namespace OpenRA.Mods.Common.Activities
public Move(Actor self, CPos destination, WDist nearEnough)
{
mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
getPath = () => self.World.WorldActor.Trait<IPathFinder>()
.FindUnitPath(mobile.ToCell, destination, self);
@@ -76,7 +73,6 @@ namespace OpenRA.Mods.Common.Activities
public Move(Actor self, CPos destination, SubCell subCell, WDist nearEnough)
{
mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
getPath = () => self.World.WorldActor.Trait<IPathFinder>()
.FindUnitPathToRange(mobile.FromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self);
@@ -87,7 +83,6 @@ namespace OpenRA.Mods.Common.Activities
public Move(Actor self, CPos destination, Actor ignoredActor)
{
mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
getPath = () =>
{
@@ -107,7 +102,6 @@ namespace OpenRA.Mods.Common.Activities
public Move(Actor self, Target target, WDist range)
{
mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
getPath = () =>
{
@@ -125,7 +119,6 @@ namespace OpenRA.Mods.Common.Activities
public Move(Actor self, Func<List<CPos>> getPath)
{
mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
this.getPath = getPath;
@@ -155,7 +148,7 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceled)
return NextActivity;
if (mobile.IsTraitDisabled || moveDisablers.Any(d => d.MoveDisabled(self)))
if (mobile.IsTraitDisabled)
return this;
if (destination == mobile.ToCell)