however, we *do* need to know who nudged us, so we can tell them where to shove it if required.

This commit is contained in:
Chris Forbes
2010-07-21 19:27:49 +12:00
parent 5ef651ce6d
commit 8006e20dd3
3 changed files with 12 additions and 3 deletions

View File

@@ -161,7 +161,7 @@ namespace OpenRA.Traits.Activities
var nudge = blocker.traits.GetOrDefault<INudge>(); var nudge = blocker.traits.GetOrDefault<INudge>();
if (nudge != null) if (nudge != null)
nudge.OnNudge(blocker); nudge.OnNudge(blocker, self);
} }
int2? PopPath( Actor self, Mobile mobile ) int2? PopPath( Actor self, Mobile mobile )

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Traits
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); } public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
} }
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove, IProvideCursor public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove, IProvideCursor, INudge
{ {
public readonly Actor self; public readonly Actor self;
public readonly MobileInfo Info; public readonly MobileInfo Info;
@@ -240,5 +240,14 @@ namespace OpenRA.Traits
{ {
self.World.WorldActor.traits.Get<UnitInfluence>().Remove( self, this ); self.World.WorldActor.traits.Get<UnitInfluence>().Remove( self, this );
} }
public void OnNudge(Actor self, Actor nudger)
{
if (self.Owner.Stances[nudger.Owner] != Stance.Ally)
return; /* don't allow ourselves to be pushed around
* by the enemy! */
}
} }
} }

View File

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