Replace UnitTraitOrderTargeter with TargetTypeOrderTargeter.

This also makes naval buildings untargetable for c4 and demo trucks, as they don't make much sense.
This commit is contained in:
Paul Chote
2013-04-15 22:31:09 +12:00
parent e545865599
commit 4ca777597f
16 changed files with 81 additions and 56 deletions

View File

@@ -12,14 +12,14 @@ using System;
namespace OpenRA.Mods.RA.Orders
{
public class EnterOrderTargeter<T> : UnitTraitOrderTargeter<T>
public class EnterOrderTargeter<T> : UnitOrderTargeter
{
readonly Func<Actor, bool> canTarget;
readonly Func<Actor, bool> useEnterCursor;
public EnterOrderTargeter( string order, int priority, bool targetEnemy, bool targetAlly,
Func<Actor, bool> canTarget, Func<Actor, bool> useEnterCursor )
: base( order, priority, "enter", targetEnemy, targetAlly )
public EnterOrderTargeter(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;
@@ -27,8 +27,15 @@ namespace OpenRA.Mods.RA.Orders
public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor)
{
if( !base.CanTargetActor( self, target, forceAttack, forceQueued, ref cursor ) ) return false;
if( !canTarget( target ) ) return false;
if (!base.CanTargetActor(self, target, forceAttack, forceQueued, ref cursor))
return false;
if (!target.HasTrait<T>())
return false;
if (!canTarget(target))
return false;
cursor = useEnterCursor(target) ? "enter" : "enter-blocked";
IsQueued = forceQueued;
return true;