Replay stuff.

FYI: Don't try to replay a game where you built any vehicles. It WILL fail horribly.
This commit is contained in:
Bob
2009-10-29 01:57:47 +13:00
parent 7c5fc4aa76
commit 89f9a96de5
6 changed files with 308 additions and 225 deletions

View File

@@ -13,15 +13,15 @@ namespace OpenRa.Game
int lastTime = Environment.TickCount;
const int timestep = 40;
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); }
public void Add(IEffect b) { effects.Add(b); }
public void Add(IEffect b) { effects.Add(b); }
public void Remove(IEffect b) { effects.Remove(b); }
public void AddFrameEndTask( Action<World> a ) { frameEndActions.Add( a ); }
public event Action<Actor> ActorAdded = _ => { };
public event Action<Actor> ActorAdded = _ => { };
public event Action<Actor> ActorRemoved = a => { a.Health = 0; }; /* make sure everyone sees it as dead */
public void ResetTimer()
@@ -32,16 +32,16 @@ namespace OpenRa.Game
public void Update()
{
int t = Environment.TickCount;
int dt = t - lastTime;
if (dt >= timestep)
{
lastTime += timestep;
foreach (var a in actors) a.Tick();
foreach (var e in effects) e.Tick();
Renderer.waterFrame += 0.00125f * timestep;
Game.viewport.Tick();
int dt = t - lastTime;
if (dt >= timestep)
{
lastTime += timestep;
foreach (var a in actors) a.Tick();
foreach (var e in effects) e.Tick();
Renderer.waterFrame += 0.00125f * timestep;
Game.viewport.Tick();
}
foreach (Action<World> a in frameEndActions) a(this);
@@ -49,6 +49,12 @@ namespace OpenRa.Game
}
public IEnumerable<Actor> Actors { get { return actors; } }
public IEnumerable<IEffect> Effects { get { return effects; } }
public IEnumerable<IEffect> Effects { get { return effects; } }
uint nextAID = 0;
internal uint NextAID()
{
return nextAID++;
}
}
}