split side effect from CanAttack query

This commit is contained in:
Chris Forbes
2009-11-09 23:30:07 +13:00
parent df00598d98
commit b094b102d0

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace OpenRa.Game.Traits
{
abstract class AttackBase : IOrder
abstract class AttackBase : IOrder, ITick
{
public Actor target;
@@ -14,14 +14,16 @@ namespace OpenRa.Game.Traits
protected int secondaryFireDelay = 0;
protected bool CanAttack( Actor self )
{
if( primaryFireDelay > 0 ) --primaryFireDelay;
if( secondaryFireDelay > 0 ) --secondaryFireDelay;
if( target != null && target.IsDead ) target = null; /* he's dead, jim. */
if( target == null ) return false;
return true;
{
return target != null;
}
public virtual void Tick(Actor self)
{
if (primaryFireDelay > 0) --primaryFireDelay;
if (secondaryFireDelay > 0) --secondaryFireDelay;
if (target != null && target.IsDead) target = null; /* he's dead, jim. */
}
protected void DoAttack( Actor self )
@@ -75,12 +77,14 @@ namespace OpenRa.Game.Traits
}
}
class AttackTurreted : AttackBase, ITick
class AttackTurreted : AttackBase
{
public AttackTurreted( Actor self ) { self.traits.Get<Turreted>(); }
public void Tick(Actor self)
{
public override void Tick(Actor self)
{
base.Tick(self);
if( !CanAttack( self ) ) return;
var turreted = self.traits.Get<Turreted>();