follow activity for turreted attacks

This commit is contained in:
Chris Forbes
2009-11-09 22:29:07 +13:00
parent 14e2e3c2eb
commit b13f399ec0
12 changed files with 64 additions and 30 deletions

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game.Traits.Activities
{
class Follow : IActivity
{
Actor Target;
int Range;
public Follow(Actor target, int range)
{
Target = target;
Range = range;
}
public IActivity NextActivity { get; set; }
public void Tick(Actor self, Mobile mobile)
{
if (Target.IsDead)
{
mobile.InternalSetActivity(NextActivity);
return;
}
if ((Target.Location - self.Location).LengthSquared >= Range * Range)
{
mobile.InternalSetActivity(new Move(Target, Range));
mobile.QueueActivity(this);
}
}
public void Cancel(Actor self, Mobile mobile) { }
}
}