From 93c8be4e79b017cc1edffc5f08d6efdc90725af0 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 8 Mar 2014 12:10:45 +1300 Subject: [PATCH] Clean up AttackOmni. --- OpenRA.Mods.RA/Attack/AttackOmni.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.RA/Attack/AttackOmni.cs b/OpenRA.Mods.RA/Attack/AttackOmni.cs index 80389ca35b..bb56fe35e8 100644 --- a/OpenRA.Mods.RA/Attack/AttackOmni.cs +++ b/OpenRA.Mods.RA/Attack/AttackOmni.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -23,30 +23,37 @@ namespace OpenRA.Mods.RA [Sync] bool buildComplete = false; public void BuildingComplete(Actor self) { buildComplete = true; } - public AttackOmni(Actor self) : base(self) { } + public AttackOmni(Actor self) + : base(self) { } - protected override bool CanAttack( Actor self, Target target ) + protected override bool CanAttack(Actor self, Target target) { - var isBuilding = ( self.HasTrait() && !buildComplete ); - return base.CanAttack( self, target ) && !isBuilding; + var isBuilding = self.HasTrait() && !buildComplete; + return base.CanAttack(self, target) && !isBuilding; } public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove) { - return new SetTarget( newTarget ); + return new SetTarget(newTarget, this); } class SetTarget : Activity { readonly Target target; - public SetTarget( Target target ) { this.target = target; } + readonly AttackOmni ao; - public override Activity Tick( Actor self ) + public SetTarget(Target target, AttackOmni ao) + { + this.target = target; + this.ao = ao; + } + + public override Activity Tick(Actor self) { if (IsCanceled || !target.IsValidFor(self)) return NextActivity; - self.Trait().DoAttack(self, target); + ao.DoAttack(self, target); return this; } }