add INudge interface; Move tries to nudge things that are in the way as a good first option
This commit is contained in:
@@ -151,8 +151,19 @@ namespace OpenRA.Traits.Activities
|
||||
}
|
||||
|
||||
bool hasWaited;
|
||||
bool hasNudged;
|
||||
int waitTicksRemaining;
|
||||
|
||||
void NudgeBlocker(Actor self, int2 nextCell)
|
||||
{
|
||||
var blocker = self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(nextCell).FirstOrDefault();
|
||||
if (blocker == null) return;
|
||||
|
||||
var nudge = blocker.traits.GetOrDefault<INudge>();
|
||||
if (nudge != null)
|
||||
nudge.OnNudge(blocker);
|
||||
}
|
||||
|
||||
int2? PopPath( Actor self, Mobile mobile )
|
||||
{
|
||||
if( path.Count == 0 ) return null;
|
||||
@@ -165,6 +176,12 @@ namespace OpenRA.Traits.Activities
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!hasNudged)
|
||||
{
|
||||
NudgeBlocker(self, nextCell);
|
||||
hasNudged = true;
|
||||
}
|
||||
|
||||
if (!hasWaited)
|
||||
{
|
||||
var info = self.Info.Traits.Get<MobileInfo>();
|
||||
@@ -187,6 +204,7 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
return null;
|
||||
}
|
||||
hasNudged = false;
|
||||
hasWaited = false;
|
||||
path.RemoveAt( path.Count - 1 );
|
||||
return nextCell;
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public interface IDisable { bool Disabled { get; } }
|
||||
public interface IExplodeModifier { bool ShouldExplode(Actor self); }
|
||||
public interface INudge { bool OnNudge(Actor self); }
|
||||
|
||||
public interface IOccupySpace
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user