Add force-move

This commit is contained in:
Scott_NZ
2013-05-18 17:52:36 +12:00
parent cfcccb590d
commit ac430bd3bc
16 changed files with 77 additions and 59 deletions

View File

@@ -33,28 +33,29 @@ namespace OpenRA.Mods.RA.Orders
public int OrderPriority { get; private set; }
public bool? ForceAttack = null;
public virtual bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
public virtual bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
if( self == null ) throw new ArgumentNullException( "self" );
if( target == null ) throw new ArgumentNullException( "target" );
cursor = this.cursor;
IsQueued = forceQueued;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
if (ForceAttack != null && forceAttack != ForceAttack) return false;
if (ForceAttack != null && modifiers.HasModifier(TargetModifiers.ForceAttack) != ForceAttack) return false;
var playerRelationship = self.Owner.Stances[ target.Owner ];
var playerRelationship = self.Owner.Stances[target.Owner];
if( !forceAttack && playerRelationship == Stance.Ally && !targetAllyUnits ) return false;
if( !forceAttack && playerRelationship == Stance.Enemy && !targetEnemyUnits ) return false;
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Ally && !targetAllyUnits) return false;
if (!modifiers.HasModifier(TargetModifiers.ForceAttack) && playerRelationship == Stance.Enemy && !targetEnemyUnits) return false;
return true;
}
public virtual bool CanTargetLocation(Actor self, CPos location, List<Actor> actorsAtLocation, bool forceAttack, bool forceQueued, ref string cursor)
public virtual bool CanTargetLocation(Actor self, CPos location, List<Actor> actorsAtLocation, TargetModifiers modifiers, ref string cursor)
{
return false;
}
public virtual bool IsQueued { get; protected set; }
}
@@ -68,15 +69,15 @@ namespace OpenRA.Mods.RA.Orders
this.targetType = targetType;
}
public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
{
if (!base.CanTargetActor(self, target, forceAttack, forceQueued, ref cursor))
if (!base.CanTargetActor(self, target, modifiers, ref cursor))
return false;
if (!target.TraitsImplementing<ITargetable>().Any(t => t.TargetTypes.Contains(targetType)))
return false;
IsQueued = forceQueued;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
return true;
}