more order targeters

This commit is contained in:
Bob
2010-10-03 05:32:39 +13:00
committed by Paul Chote
parent 4bc9e01516
commit 87a0b52ce5
5 changed files with 58 additions and 43 deletions

View File

@@ -8,18 +8,21 @@ namespace OpenRA.Mods.RA.Orders
{
class EnterBuildingOrderTargeter<T> : UnitTraitOrderTargeter<T>
{
readonly Func<Actor, bool> canTarget;
readonly Func<Actor, bool> useEnterCursor;
public EnterBuildingOrderTargeter( string order, int priority, bool targetEnemy, bool targetAlly, Func<Actor, bool> useEnterCursor )
public EnterBuildingOrderTargeter( string order, int priority, bool targetEnemy, bool targetAlly,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor )
: base( order, priority, "enter", targetEnemy, targetAlly )
{
this.canTarget = canTarget;
this.useEnterCursor = useEnterCursor;
}
public override bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor )
{
if( !base.CanTargetUnit( self, target, forceAttack, forceMove, ref cursor ) ) return false;
if( !canTarget( target ) ) return false;
cursor = useEnterCursor( target ) ? "enter" : "enter-blocked";
return true;
}