start of some bullet support

This commit is contained in:
Chris Forbes
2009-10-18 22:27:28 +13:00
parent 9a9452c3fa
commit 7b8355beb5
2 changed files with 13 additions and 4 deletions

View File

@@ -75,6 +75,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Actor.cs" />
<Compile Include="Bullet.cs" />
<Compile Include="Controller.cs" />
<Compile Include="Cursor.cs" />
<Compile Include="GameRules\FieldLoader.cs" />

View File

@@ -8,6 +8,7 @@ namespace OpenRa.Game
class World
{
List<Actor> actors = new List<Actor>();
List<Bullet> bullets = new List<Bullet>();
List<Action<World>> frameEndActions = new List<Action<World>>();
readonly Game game;
int lastTime = Environment.TickCount;
@@ -17,6 +18,10 @@ namespace OpenRa.Game
public void Add(Actor a) { actors.Add(a); ActorAdded(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<World> a ) { frameEndActions.Add( a ); }
public event Action<Actor> 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;
}
@@ -41,5 +48,6 @@ namespace OpenRa.Game
}
public IEnumerable<Actor> Actors { get { return actors; } }
public IEnumerable<Bullet> Bullets { get { return bullets; } }
}
}