Removed INudge in favor of INotifyBlockingMove.
This commit is contained in:
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
}
|
||||
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IOccupySpace, IMove, IFacing, INudge, ISync
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IOccupySpace, IMove, IFacing, ISync
|
||||
{
|
||||
public readonly Actor self;
|
||||
public readonly MobileInfo Info;
|
||||
@@ -280,7 +280,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
self.CancelActivity();
|
||||
|
||||
if (order.OrderString == "Scatter")
|
||||
OnNudge(self, self, true);
|
||||
Nudge(self, self, true);
|
||||
}
|
||||
|
||||
public string VoicePhraseForOrder(Actor self, Order order)
|
||||
@@ -392,7 +392,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
self.World.ActorMap.Remove(self, this);
|
||||
}
|
||||
|
||||
public void OnNudge(Actor self, Actor nudger, bool force)
|
||||
public void Nudge(Actor self, Actor nudger, bool force)
|
||||
{
|
||||
/* initial fairly braindead implementation. */
|
||||
if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally)
|
||||
|
||||
@@ -164,25 +164,21 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
|
||||
bool hasWaited;
|
||||
bool hasNudged;
|
||||
bool hasNotifiedBlocker;
|
||||
int waitTicksRemaining;
|
||||
|
||||
void NudgeBlocker(Actor self, CPos nextCell)
|
||||
void NotifyBlocker(Actor self, CPos nextCell)
|
||||
{
|
||||
var blocker = self.World.ActorMap.GetUnitsAt(nextCell).FirstOrDefault();
|
||||
if (blocker == null) return;
|
||||
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);
|
||||
|
||||
Log.Write("debug", "NudgeBlocker #{0} nudges #{1} at {2} from {3}",
|
||||
self.ActorID, blocker.ActorID, nextCell, self.Location);
|
||||
|
||||
var nudge = blocker.TraitOrDefault<INudge>();
|
||||
if (nudge != null)
|
||||
nudge.OnNudge(blocker, self, false);
|
||||
|
||||
// Notify the blocker that he's blocking our move:
|
||||
INotifyBlockingMove moveBlocked;
|
||||
if ((moveBlocked = blocker.TraitOrDefault<INotifyBlockingMove>()) != null)
|
||||
moveBlocked.OnNotifyBlockingMove(blocker, self, nextCell);
|
||||
// Notify the blocker that he's blocking our move:
|
||||
var moveBlocked = blocker.TraitOrDefault<INotifyBlockingMove>();
|
||||
if (moveBlocked != null)
|
||||
moveBlocked.OnNotifyBlockingMove(blocker, self);
|
||||
}
|
||||
}
|
||||
|
||||
Pair<CPos, SubCell>? PopPath(Actor self, Mobile mobile)
|
||||
@@ -197,10 +193,10 @@ namespace OpenRA.Mods.RA.Move
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hasNudged)
|
||||
if (!hasNotifiedBlocker)
|
||||
{
|
||||
NudgeBlocker(self, nextCell);
|
||||
hasNudged = true;
|
||||
NotifyBlocker(self, nextCell);
|
||||
hasNotifiedBlocker = true;
|
||||
}
|
||||
|
||||
if (!hasWaited)
|
||||
@@ -228,7 +224,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
return null;
|
||||
}
|
||||
hasNudged = false;
|
||||
hasNotifiedBlocker = false;
|
||||
hasWaited = false;
|
||||
path.RemoveAt( path.Count - 1 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user