Changed: AttackMove actually works

This commit is contained in:
geckosoft
2010-11-12 00:04:07 +01:00
committed by Bob
parent 5d3622b79d
commit 1ac61c5e3e

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System;
using System.Drawing;
using OpenRA.Effects;
using OpenRA.Traits;
@@ -20,8 +21,12 @@ namespace OpenRA.Mods.RA
public readonly bool JustMove = false;
}
class AttackMove : IResolveOrder, IOrderVoice
class AttackMove : IResolveOrder, IOrderVoice, ITick
{
[Sync] public int2 TargetLocation = int2.Zero;
[Sync] public bool AttackMoving = false;
public string VoicePhraseForOrder(Actor self, Order order)
{
if (order.OrderString == "AttackMove")
@@ -34,12 +39,20 @@ namespace OpenRA.Mods.RA
{
if (order.OrderString == "AttackMove")
{
self.CancelActivity();
//if we are just moving, we don't turn on attackmove and this becomes a regular move order
if (self.Info.Traits.Get<AttackMoveInfo>().JustMove)
self.QueueActivity( self.Trait<Mobile>().MoveTo( order.TargetLocation, 1 ));
{
self.QueueActivity(self.Trait<Mobile>().MoveTo(order.TargetLocation, 1));
AttackMoving = false;
}
else
self.QueueActivity( new AttackMoveActivity(order.TargetLocation));
{
self.QueueActivity(new AttackMoveActivity(order.TargetLocation));
AttackMoving = true;
TargetLocation = order.TargetLocation;
}
if (self.Owner == self.World.LocalPlayer)
self.World.AddFrameEndTask(w =>
@@ -54,6 +67,10 @@ namespace OpenRA.Mods.RA
else line.SetTarget(self, Target.FromOrder(order), Color.Red);
});
}
else
{
AttackMoving = false;
}
}
class AttackMoveActivity : CancelableActivity
@@ -84,5 +101,16 @@ namespace OpenRA.Mods.RA
}
}
public void Tick(Actor self)
{
if (!self.IsInWorld) return;
if (AttackMoving && self.IsIdle)
{
self.CancelActivity();
self.QueueActivity(new AttackMoveActivity(TargetLocation));
}
}
}
}