add Util.RunActivity, and have Actor.Tick use it. fix medic autoheal

This commit is contained in:
Bob
2010-11-14 18:36:36 +13:00
parent d152d21338
commit 80e897abfb
16 changed files with 59 additions and 57 deletions

View File

@@ -12,6 +12,7 @@ using System;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Support;
namespace OpenRA.Traits
{
@@ -115,6 +116,24 @@ namespace OpenRA.Traits
(next, a) => { a.Queue( next ); return a; });
}
public static IActivity RunActivity( Actor self, IActivity act )
{
while( act != null )
{
var prev = act;
var sw = new Stopwatch();
act = act.Tick( self );
var dt = sw.ElapsedTime();
if(dt > Game.Settings.Debug.LongTickThreshold)
Log.Write("perf", "[{2}] Activity: {0} ({1:0.000} ms)", prev, dt * 1000, Game.LocalTick);
if( prev == act )
break;
}
return act;
}
public static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2]); }
public static int2 CellContaining(float2 pos) { return (1f / Game.CellSize * pos).ToInt2(); }