diff --git a/AUTHORS b/AUTHORS index 9e67bdefa6..df398d4025 100644 --- a/AUTHORS +++ b/AUTHORS @@ -69,6 +69,7 @@ Also thanks to: * Tristan Mühlbacher (MicroBit) * Vladimir Komarov (VrKomarov) * Wuschel + * Ian T. Jacobsen (Smilex) Using Simple DirectMedia Layer distributed under the terms of the zlib license. diff --git a/CHANGELOG b/CHANGELOG index 2a37a59605..e1483a9bcf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ NEW: Added skirmish mode to RA and D2k to complement TD's skirmish mode. Added an Extras submenu for miscellaneous game extras. Engineers can now regain control over husks. + A player's units, and allied units, now move out of the way when blocking production facilities. Dune 2000: Added the Atreides grenadier from the 1.06 patch. Added randomized tiles for Sand and Rock terrain. diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index 3829cd51d1..2222a5186c 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -183,9 +183,9 @@ namespace OpenRA.Mods.RA public void OnNotifyBlockingMove(Actor self, Actor blocking) { // I'm blocking someone else from moving to my location: - Activity act = self.GetCurrentActivity(); + var act = self.GetCurrentActivity(); // If I'm just waiting around then get out of the way: - if (act == null || act.GetType() == typeof(Wait)) + if (act is Wait) { self.CancelActivity(); var mobile = self.Trait(); diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 6c29aa2686..b281669538 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -144,7 +144,7 @@ namespace OpenRA.Mods.RA.Move public int GetInitialFacing() { return InitialFacing; } } - public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld + public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove { public readonly Actor self; public readonly MobileInfo Info; @@ -542,5 +542,11 @@ namespace OpenRA.Mods.RA.Move public Activity MoveWithinRange(Target target, WRange range) { return new Move(target, range); } public Activity MoveFollow(Actor self, Target target, WRange range) { return new Follow(self, target, range); } public Activity MoveTo(Func> pathFunc) { return new Move(pathFunc); } - } + + public void OnNotifyBlockingMove(Actor self, Actor blocking) + { + if (self.IsIdle && self.AppearsFriendlyTo(blocking)) + Nudge(self, blocking, true); + } + } } diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index 0c021faf20..40e0149f82 100755 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -175,12 +175,8 @@ namespace OpenRA.Mods.RA.Move { foreach (var blocker in self.World.ActorMap.GetUnitsAt(nextCell)) { - Log.Write("debug", "NotifyBlocker #{0} nudges #{1} at {2} from {3}", - self.ActorID, blocker.ActorID, nextCell, self.Location); - // Notify the blocker that he's blocking our move: - var moveBlocked = blocker.TraitOrDefault(); - if (moveBlocked != null) + foreach (var moveBlocked in blocker.TraitsImplementing()) moveBlocked.OnNotifyBlockingMove(blocker, self); } } diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index aeb7b2754f..715a37c38f 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -124,6 +124,13 @@ namespace OpenRA.Mods.RA { var mobileInfo = producee.Traits.GetOrDefault(); + foreach (var blocker in self.World.ActorMap.GetUnitsAt(self.Location + s.ExitCell)) + { + // Notify the blocker that he's blocking our move: + foreach (var moveBlocked in blocker.TraitsImplementing()) + moveBlocked.OnNotifyBlockingMove(blocker, self); + } + return mobileInfo == null || mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCell, self, true, true); }