From 7b8355beb5c3add1df8df4525150533dc7eab177 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 18 Oct 2009 22:27:28 +1300 Subject: [PATCH] start of some bullet support --- OpenRa.Game/OpenRa.Game.csproj | 1 + OpenRa.Game/World.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index f5d6f3fddf..9764bf668c 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -75,6 +75,7 @@ + diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index 31d5bd134e..bab55dd2bf 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -7,7 +7,8 @@ namespace OpenRa.Game { class World { - List actors = new List(); + List actors = new List(); + List bullets = new List(); List> frameEndActions = new List>(); readonly Game game; int lastTime = Environment.TickCount; @@ -16,7 +17,11 @@ namespace OpenRa.Game public World(Game game) { this.game = game; } public void Add(Actor a) { actors.Add(a); ActorAdded(a); } - public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); } + public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); } + + public void Add(Bullet b) { bullets.Add(b); } + public void Remove(Bullet b) { bullets.Remove(b); } + public void AddFrameEndTask( Action a ) { frameEndActions.Add( a ); } public event Action ActorAdded = _ => { }; @@ -30,8 +35,10 @@ namespace OpenRa.Game { lastTime += timestep; - foreach( Actor a in actors ) + foreach( var a in actors ) a.Tick(game, timestep); + foreach (var b in bullets) + b.Tick(game, timestep); Renderer.waterFrame += 0.00125f * timestep; } @@ -40,6 +47,7 @@ namespace OpenRa.Game frameEndActions.Clear(); } - public IEnumerable Actors { get { return actors; } } + public IEnumerable Actors { get { return actors; } } + public IEnumerable Bullets { get { return bullets; } } } }