Add a force flag to nudging which skips the ownership and idle checks

This commit is contained in:
Paul Chote
2011-07-10 17:37:12 +12:00
parent 98ae8c7630
commit 74d13286a8
3 changed files with 6 additions and 7 deletions

View File

@@ -73,7 +73,7 @@ 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 INudge { void OnNudge(Actor self, Actor nudger); } public interface INudge { void OnNudge(Actor self, Actor nudger, bool force); }
public interface IRadarSignature public interface IRadarSignature
{ {

View File

@@ -269,7 +269,7 @@ namespace OpenRA.Mods.RA.Move
if (order.OrderString == "Scatter") if (order.OrderString == "Scatter")
{ {
OnNudge(self, self); OnNudge(self, self, true);
} }
} }
@@ -365,15 +365,14 @@ namespace OpenRA.Mods.RA.Move
self.World.ActorMap.Remove(self, this); self.World.ActorMap.Remove(self, this);
} }
public void OnNudge(Actor self, Actor nudger) public void OnNudge(Actor self, Actor nudger, bool force)
{ {
/* initial fairly braindead implementation. */ /* initial fairly braindead implementation. */
if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally)
if (self.Owner.Stances[nudger.Owner] != Stance.Ally)
return; /* don't allow ourselves to be pushed around return; /* don't allow ourselves to be pushed around
* by the enemy! */ * by the enemy! */
if (!self.IsIdle) if (!force && !self.IsIdle)
return; /* don't nudge if we're busy doing something! */ return; /* don't nudge if we're busy doing something! */
// pick an adjacent available cell. // pick an adjacent available cell.

View File

@@ -170,7 +170,7 @@ namespace OpenRA.Mods.RA.Move
var nudge = blocker.TraitOrDefault<INudge>(); var nudge = blocker.TraitOrDefault<INudge>();
if (nudge != null) if (nudge != null)
nudge.OnNudge(blocker, self); nudge.OnNudge(blocker, self, false);
} }
Pair<int2, SubCell>? PopPath( Actor self, Mobile mobile ) Pair<int2, SubCell>? PopPath( Actor self, Mobile mobile )