using System; using System.Collections.Generic; using System.Windows.Forms; namespace OpenRa.Game { class World { List actors = new List(); List> frameEndActions = new List>(); public readonly Game game; public World(Game game) { this.game = game; } public void Add(Actor a) { actors.Add(a); } public void Remove( Actor a ) { actors.Remove( a ); } public void AddFrameEndTask( Action a ) { frameEndActions.Add( a ); } int lastTime = Environment.TickCount; public void Update() { int t = Environment.TickCount; int dt = t - lastTime; lastTime = t; foreach (Actor a in actors) a.Tick(game, dt); foreach (Action a in frameEndActions) a(this); frameEndActions.Clear(); } public IEnumerable Actors { get { return actors; } } } }