Removed INudge in favor of INotifyBlockingMove.
This commit is contained in:
@@ -75,7 +75,6 @@ namespace OpenRA.Traits
|
|||||||
public interface IDisable { bool Disabled { get; } }
|
public interface IDisable { bool Disabled { get; } }
|
||||||
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
||||||
public interface IHuskModifier { string HuskActor(Actor self); }
|
public interface IHuskModifier { string HuskActor(Actor self); }
|
||||||
public interface INudge { void OnNudge(Actor self, Actor nudger, bool force); }
|
|
||||||
|
|
||||||
public interface IRadarSignature
|
public interface IRadarSignature
|
||||||
{
|
{
|
||||||
@@ -132,7 +131,7 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface IMove : ITeleportable { int Altitude { get; set; } }
|
public interface IMove : ITeleportable { int Altitude { get; set; } }
|
||||||
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking, CPos cell); }
|
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); }
|
||||||
|
|
||||||
public interface IFacing
|
public interface IFacing
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public void WarnCrush(Actor crusher)
|
public void WarnCrush(Actor crusher)
|
||||||
{
|
{
|
||||||
if (self.World.SharedRandom.Next(100) <= Info.WarnProbability)
|
if (self.World.SharedRandom.Next(100) <= Info.WarnProbability)
|
||||||
self.Trait<Mobile>().OnNudge(self, crusher, true);
|
self.Trait<Mobile>().Nudge(self, crusher, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCrush(Actor crusher)
|
public void OnCrush(Actor crusher)
|
||||||
|
|||||||
@@ -159,16 +159,17 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnNotifyBlockingMove(Actor self, Actor blocking, CPos cell)
|
public void OnNotifyBlockingMove(Actor self, Actor blocking)
|
||||||
{
|
{
|
||||||
// I'm blocking someone else from moving to my location:
|
// I'm blocking someone else from moving to my location:
|
||||||
Activity act = self.GetCurrentActivity();
|
Activity act = self.GetCurrentActivity();
|
||||||
// If I'm just waiting around, then get out of the way:
|
// If I'm just waiting around then get out of the way:
|
||||||
if (act.GetType() == typeof(Wait))
|
if (act.GetType() == typeof(Wait))
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
|
|
||||||
|
var cell = self.Location;
|
||||||
var moveTo = mobile.NearestMoveableCell(cell, 2, 5);
|
var moveTo = mobile.NearestMoveableCell(cell, 2, 5);
|
||||||
self.QueueActivity(mobile.MoveTo(moveTo, 0));
|
self.QueueActivity(mobile.MoveTo(moveTo, 0));
|
||||||
self.SetTargetLine(Target.FromCell(moveTo), Color.Gray, false);
|
self.SetTargetLine(Target.FromCell(moveTo), Color.Gray, false);
|
||||||
|
|||||||
@@ -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 Actor self;
|
||||||
public readonly MobileInfo Info;
|
public readonly MobileInfo Info;
|
||||||
@@ -280,7 +280,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
if (order.OrderString == "Scatter")
|
if (order.OrderString == "Scatter")
|
||||||
OnNudge(self, self, true);
|
Nudge(self, self, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
@@ -392,7 +392,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
self.World.ActorMap.Remove(self, this);
|
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. */
|
/* initial fairly braindead implementation. */
|
||||||
if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally)
|
if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally)
|
||||||
|
|||||||
@@ -164,25 +164,21 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hasWaited;
|
bool hasWaited;
|
||||||
bool hasNudged;
|
bool hasNotifiedBlocker;
|
||||||
int waitTicksRemaining;
|
int waitTicksRemaining;
|
||||||
|
|
||||||
void NudgeBlocker(Actor self, CPos nextCell)
|
void NotifyBlocker(Actor self, CPos nextCell)
|
||||||
{
|
{
|
||||||
var blocker = self.World.ActorMap.GetUnitsAt(nextCell).FirstOrDefault();
|
foreach (var blocker in self.World.ActorMap.GetUnitsAt(nextCell))
|
||||||
if (blocker == null) return;
|
{
|
||||||
|
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}",
|
// Notify the blocker that he's blocking our move:
|
||||||
self.ActorID, blocker.ActorID, nextCell, self.Location);
|
var moveBlocked = blocker.TraitOrDefault<INotifyBlockingMove>();
|
||||||
|
if (moveBlocked != null)
|
||||||
var nudge = blocker.TraitOrDefault<INudge>();
|
moveBlocked.OnNotifyBlockingMove(blocker, self);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<CPos, SubCell>? PopPath(Actor self, Mobile mobile)
|
Pair<CPos, SubCell>? PopPath(Actor self, Mobile mobile)
|
||||||
@@ -197,10 +193,10 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasNudged)
|
if (!hasNotifiedBlocker)
|
||||||
{
|
{
|
||||||
NudgeBlocker(self, nextCell);
|
NotifyBlocker(self, nextCell);
|
||||||
hasNudged = true;
|
hasNotifiedBlocker = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasWaited)
|
if (!hasWaited)
|
||||||
@@ -228,7 +224,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
hasNudged = false;
|
hasNotifiedBlocker = false;
|
||||||
hasWaited = false;
|
hasWaited = false;
|
||||||
path.RemoveAt( path.Count - 1 );
|
path.RemoveAt( path.Count - 1 );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user