diff --git a/OpenRA.Game/Activities/Activity.cs b/OpenRA.Game/Activities/Activity.cs
index cd82fb454a..e223321c78 100644
--- a/OpenRA.Game/Activities/Activity.cs
+++ b/OpenRA.Game/Activities/Activity.cs
@@ -231,6 +231,34 @@ namespace OpenRA.Activities
ChildActivity = activity;
}
+ ///
+ /// Prints the activity tree, starting from the root or optionally from a given origin.
+ ///
+ /// Call this method from any place that's called during a tick, such as the Tick() method itself or
+ /// the Before(First|Last)Run() methods. The origin activity will be marked in the output.
+ ///
+ /// Activity from which to start traversing, and which to mark. If null, mark the calling activity, and start traversal from the root.
+ /// Initial level of indentation.
+ protected void PrintActivityTree(Activity origin = null, int level = 0)
+ {
+ if (origin == null)
+ RootActivity.PrintActivityTree(this);
+ else
+ {
+ Console.Write(new string(' ', level * 2));
+ if (origin == this)
+ Console.Write("*");
+
+ Console.WriteLine(this.GetType().ToString().Split('.').Last());
+
+ if (ChildActivity != null)
+ ChildActivity.PrintActivityTree(origin, level + 1);
+
+ if (NextInQueue != null)
+ NextInQueue.PrintActivityTree(origin, level);
+ }
+ }
+
public virtual IEnumerable GetTargets(Actor self)
{
yield break;