From 2f2afd9fc56ec723752c0caf7e8c7e25f2960d99 Mon Sep 17 00:00:00 2001 From: "Ian T. Jacobsen" Date: Tue, 4 Feb 2014 13:49:31 +0000 Subject: [PATCH 1/5] Added OnNotifyBlockingMove to Mobile --- OpenRA.Mods.RA/Move/Mobile.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 6c29aa2686..16c043ab96 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,10 @@ 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) + { + Nudge(self, blocking, true); + } + } } From eba8e8f33f84951b017c475e5c108978288244ac Mon Sep 17 00:00:00 2001 From: "Ian T. Jacobsen" Date: Tue, 4 Feb 2014 13:50:08 +0000 Subject: [PATCH 2/5] Added a blocking check to Production::CanUseExit --- OpenRA.Mods.RA/Production.cs | 7 +++++++ 1 file changed, 7 insertions(+) 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); } From 91908c560dd2d50b561e204fdd787cae859aeab2 Mon Sep 17 00:00:00 2001 From: "Ian T. Jacobsen" Date: Wed, 5 Feb 2014 01:40:17 +0000 Subject: [PATCH 3/5] Small cleanup in Harvester::OnNotifyBlockingMove --- OpenRA.Mods.RA/Harvester.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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(); From 3c80024113fd11e47d6a55068d59ce77a63a778f Mon Sep 17 00:00:00 2001 From: "Ian T. Jacobsen" Date: Wed, 5 Feb 2014 02:18:12 +0000 Subject: [PATCH 4/5] Made Move::NotifyBlocker handle traits appropriately --- OpenRA.Mods.RA/Move/Mobile.cs | 3 ++- OpenRA.Mods.RA/Move/Move.cs | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 16c043ab96..b281669538 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -545,7 +545,8 @@ namespace OpenRA.Mods.RA.Move public void OnNotifyBlockingMove(Actor self, Actor blocking) { - Nudge(self, blocking, true); + 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); } } From bb2972333259024f6b8939ce8a9e52a202982824 Mon Sep 17 00:00:00 2001 From: "Ian T. Jacobsen" Date: Sun, 9 Feb 2014 02:46:58 +0000 Subject: [PATCH 5/5] Added entry to CHANGELOG and AUTHORS. Small fix in Mobile.cs --- AUTHORS | 1 + CHANGELOG | 1 + 2 files changed, 2 insertions(+) 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.