Merge pull request #4568 from Smilex/issue4547

closes #4547
This commit is contained in:
Matthias Mailänder
2014-02-09 18:17:42 +01:00
6 changed files with 20 additions and 9 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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<Mobile>();

View File

@@ -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<List<CPos>> pathFunc) { return new Move(pathFunc); }
}
public void OnNotifyBlockingMove(Actor self, Actor blocking)
{
if (self.IsIdle && self.AppearsFriendlyTo(blocking))
Nudge(self, blocking, true);
}
}
}

View File

@@ -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<INotifyBlockingMove>();
if (moveBlocked != null)
foreach (var moveBlocked in blocker.TraitsImplementing<INotifyBlockingMove>())
moveBlocked.OnNotifyBlockingMove(blocker, self);
}
}

View File

@@ -124,6 +124,13 @@ namespace OpenRA.Mods.RA
{
var mobileInfo = producee.Traits.GetOrDefault<MobileInfo>();
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<INotifyBlockingMove>())
moveBlocked.OnNotifyBlockingMove(blocker, self);
}
return mobileInfo == null ||
mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCell, self, true, true);
}