diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index 09dd890e54..c0c2bfd35a 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -83,7 +83,7 @@
-
+
@@ -137,6 +137,7 @@
+
diff --git a/OpenRa.Game/Traits/AcceptsOre.cs b/OpenRa.Game/Traits/AcceptsOre.cs
index 1d4dc247e6..7b0db686f1 100644
--- a/OpenRa.Game/Traits/AcceptsOre.cs
+++ b/OpenRa.Game/Traits/AcceptsOre.cs
@@ -9,7 +9,7 @@ namespace OpenRa.Game.Traits
{
public AcceptsOre(Actor self)
{
- if (!Game.skipMakeAnims)
+ // if (!Game.skipMakeAnims)
Game.world.AddFrameEndTask(
w =>
{ /* create the free harvester! */
diff --git a/OpenRa.Game/Traits/Activities/DeliverOre.cs b/OpenRa.Game/Traits/Activities/DeliverOre.cs
index 8e4eda8ed5..9ce9afa2a5 100644
--- a/OpenRa.Game/Traits/Activities/DeliverOre.cs
+++ b/OpenRa.Game/Traits/Activities/DeliverOre.cs
@@ -5,9 +5,9 @@ using System.Text;
namespace OpenRa.Game.Traits.Activities
{
- class DeliverOre : Activity
+ class DeliverOre : IActivity
{
- public Activity NextActivity { get; set; }
+ public IActivity NextActivity { get; set; }
bool isDone;
Actor refinery;
diff --git a/OpenRa.Game/Traits/Activities/DeployMcv.cs b/OpenRa.Game/Traits/Activities/DeployMcv.cs
index 17f7a10b13..def708eed5 100755
--- a/OpenRa.Game/Traits/Activities/DeployMcv.cs
+++ b/OpenRa.Game/Traits/Activities/DeployMcv.cs
@@ -5,9 +5,9 @@ using System.Text;
namespace OpenRa.Game.Traits.Activities
{
- class DeployMcv : Activity
+ class DeployMcv : IActivity
{
- public Activity NextActivity { get; set; }
+ public IActivity NextActivity { get; set; }
public void Tick( Actor self, Mobile mobile )
{
diff --git a/OpenRa.Game/Traits/Activities/Follow.cs b/OpenRa.Game/Traits/Activities/Follow.cs
new file mode 100644
index 0000000000..e3f66af5b3
--- /dev/null
+++ b/OpenRa.Game/Traits/Activities/Follow.cs
@@ -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) { }
+ }
+}
diff --git a/OpenRa.Game/Traits/Activities/Harvest.cs b/OpenRa.Game/Traits/Activities/Harvest.cs
index f638cf407f..ed444d8bfc 100644
--- a/OpenRa.Game/Traits/Activities/Harvest.cs
+++ b/OpenRa.Game/Traits/Activities/Harvest.cs
@@ -5,9 +5,9 @@ using System.Text;
namespace OpenRa.Game.Traits.Activities
{
- class Harvest : Activity
+ class Harvest : IActivity
{
- public Activity NextActivity { get; set; }
+ public IActivity NextActivity { get; set; }
bool isHarvesting = false;
public void Tick(Actor self, Mobile mobile)
@@ -84,13 +84,10 @@ namespace OpenRa.Game.Traits.Activities
search.AddInitialCell(self.Location);
return Game.PathFinder.FindPath(search);
}));
- mobile.QueueActivity(new Harvest());
-
+ mobile.QueueActivity(new Harvest());
mobile.InternalSetActivity( NextActivity );
}
- public void Cancel(Actor self, Mobile mobile)
- {
- }
+ public void Cancel(Actor self, Mobile mobile) { }
}
}
diff --git a/OpenRa.Game/Traits/Activities/Activity.cs b/OpenRa.Game/Traits/Activities/IActivity.cs
old mode 100755
new mode 100644
similarity index 75%
rename from OpenRa.Game/Traits/Activities/Activity.cs
rename to OpenRa.Game/Traits/Activities/IActivity.cs
index 34697cdde6..53eb5ace06
--- a/OpenRa.Game/Traits/Activities/Activity.cs
+++ b/OpenRa.Game/Traits/Activities/IActivity.cs
@@ -5,9 +5,9 @@ using System.Text;
namespace OpenRa.Game.Traits.Activities
{
- interface Activity
+ interface IActivity
{
- Activity NextActivity { get; set; }
+ IActivity NextActivity { get; set; }
void Tick( Actor self, Mobile mobile );
void Cancel( Actor self, Mobile mobile );
}
diff --git a/OpenRa.Game/Traits/Activities/Move.cs b/OpenRa.Game/Traits/Activities/Move.cs
index c1c55245c0..bb90417c65 100755
--- a/OpenRa.Game/Traits/Activities/Move.cs
+++ b/OpenRa.Game/Traits/Activities/Move.cs
@@ -5,9 +5,9 @@ using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits.Activities
{
- class Move : Activity
+ class Move : IActivity
{
- public Activity NextActivity { get; set; }
+ public IActivity NextActivity { get; set; }
int2? destination;
int nearEnough;
diff --git a/OpenRa.Game/Traits/Activities/Turn.cs b/OpenRa.Game/Traits/Activities/Turn.cs
index e355b2174f..f36285101a 100755
--- a/OpenRa.Game/Traits/Activities/Turn.cs
+++ b/OpenRa.Game/Traits/Activities/Turn.cs
@@ -5,9 +5,9 @@ using System.Text;
namespace OpenRa.Game.Traits.Activities
{
- class Turn : Activity
+ class Turn : IActivity
{
- public Activity NextActivity { get; set; }
+ public IActivity NextActivity { get; set; }
public int desiredFacing;
diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs
index db0ce7fa96..875ab743a5 100644
--- a/OpenRa.Game/Traits/McvDeploy.cs
+++ b/OpenRa.Game/Traits/McvDeploy.cs
@@ -7,10 +7,8 @@ using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
class McvDeploy : IOrder
- {
- public McvDeploy(Actor self)
- {
- }
+ {
+ public McvDeploy(Actor self) { }
public Order Order(Actor self, int2 xy, bool lmb, Actor underCursor)
{
diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs
index 3211383b38..0abdf8cadc 100644
--- a/OpenRa.Game/Traits/Mobile.cs
+++ b/OpenRa.Game/Traits/Mobile.cs
@@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits
public int facing;
public int Voice = Game.CosmeticRandom.Next(2);
- Activity currentActivity;
+ IActivity currentActivity;
public Mobile(Actor self)
{
@@ -27,7 +27,7 @@ namespace OpenRa.Game.Traits
Game.UnitInfluence.Update( this );
}
- public void QueueActivity( Activity nextActivity )
+ public void QueueActivity( IActivity nextActivity )
{
if( currentActivity == null )
{
@@ -42,7 +42,7 @@ namespace OpenRa.Game.Traits
act.NextActivity = nextActivity;
}
- public void InternalSetActivity( Activity activity )
+ public void InternalSetActivity( IActivity activity )
{
currentActivity = activity;
}
diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs
index 577dc58f35..99069a5390 100755
--- a/OpenRa.Game/UnitOrders.cs
+++ b/OpenRa.Game/UnitOrders.cs
@@ -29,15 +29,14 @@ namespace OpenRa.Game
var mobile = order.Subject.traits.GetOrDefault();
var weapon = order.Subject.unitInfo.Primary ?? order.Subject.unitInfo.Secondary;
- mobile.Cancel( order.Subject );
+ mobile.Cancel(order.Subject);
// TODO: this block should be a separate activity; "MoveNear", maybe?
{
/* todo: choose the appropriate weapon, when only one works against this target */
- var range = Rules.WeaponInfo[ weapon ].Range;
+ var range = Rules.WeaponInfo[weapon].Range;
mobile.QueueActivity(
- new Traits.Activities.Move( order.TargetActor,
- Math.Max( 0, (int)range - RangeTolerance ) ) );
+ new Traits.Activities.Follow(order.TargetActor, Math.Max(0, (int)range - RangeTolerance)));
}
order.Subject.traits.Get().target = order.TargetActor;
@@ -49,6 +48,7 @@ namespace OpenRa.Game
break; /* throw the order on the floor */
var mobile = order.Subject.traits.Get();
+ mobile.Cancel(order.Subject);
mobile.QueueActivity( new Traits.Activities.Turn( 96 ) );
mobile.QueueActivity( new Traits.Activities.DeployMcv() );
break;