From 6b545755697432524bf717696adf6c8b6ce901fa Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 4 Oct 2014 13:38:35 +1300 Subject: [PATCH] Fix Move activity ignoring IDisableMove. --- OpenRA.Mods.RA/Move/Move.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index 59243df776..734a0f5191 100644 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Move static readonly List NoPath = new List(); readonly Mobile mobile; + readonly IEnumerable moveDisablers; readonly WRange nearEnough; readonly Func> getPath; readonly Actor ignoreBuilding; @@ -40,6 +41,7 @@ namespace OpenRA.Mods.RA.Move public Move(Actor self, CPos destination) { mobile = self.Trait(); + moveDisablers = self.TraitsImplementing(); getPath = () => self.World.WorldActor.Trait().FindPath( @@ -56,6 +58,7 @@ namespace OpenRA.Mods.RA.Move public Move(Actor self, CPos destination, WRange nearEnough) { mobile = self.Trait(); + moveDisablers = self.TraitsImplementing(); getPath = () => self.World.WorldActor.Trait() .FindUnitPath(mobile.toCell, destination, self); @@ -66,6 +69,7 @@ namespace OpenRA.Mods.RA.Move public Move(Actor self, CPos destination, SubCell subCell, WRange nearEnough) { mobile = self.Trait(); + moveDisablers = self.TraitsImplementing(); getPath = () => self.World.WorldActor.Trait() .FindUnitPathToRange(mobile.fromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self); @@ -76,6 +80,7 @@ namespace OpenRA.Mods.RA.Move public Move(Actor self, CPos destination, Actor ignoreBuilding) { mobile = self.Trait(); + moveDisablers = self.TraitsImplementing(); getPath = () => self.World.WorldActor.Trait().FindPath( @@ -90,6 +95,7 @@ namespace OpenRA.Mods.RA.Move public Move(Actor self, Target target, WRange range) { mobile = self.Trait(); + moveDisablers = self.TraitsImplementing(); getPath = () => { @@ -107,6 +113,7 @@ namespace OpenRA.Mods.RA.Move public Move(Actor self, Func> getPath) { mobile = self.Trait(); + moveDisablers = self.TraitsImplementing(); this.getPath = getPath; @@ -133,6 +140,8 @@ namespace OpenRA.Mods.RA.Move public override Activity Tick(Actor self) { + if (moveDisablers.Any(d => d.MoveDisabled(self))) + return this; if (destination == mobile.toCell) return NextActivity;