pulling IEffect out of Bullet in prep for Explosion
This commit is contained in:
@@ -4,13 +4,20 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.GameRules;
|
||||
using IjwFramework.Types;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
class Bullet
|
||||
{
|
||||
public readonly Player Owner;
|
||||
{
|
||||
interface IEffect
|
||||
{
|
||||
void Tick(Game g);
|
||||
IEnumerable<Pair<Sprite, float2>> Render();
|
||||
Player Owner { get; }
|
||||
}
|
||||
|
||||
class Bullet : IEffect
|
||||
{
|
||||
public Player Owner { get; private set; }
|
||||
readonly Actor FiredBy;
|
||||
readonly WeaponInfo Weapon;
|
||||
readonly ProjectileInfo Projectile;
|
||||
@@ -46,10 +53,13 @@ namespace OpenRa.Game
|
||||
if (t == 0)
|
||||
game.PlaySound(Weapon.Report + ".aud", false);
|
||||
|
||||
t += 40;
|
||||
|
||||
if (t > TotalTime()) /* remove finished bullets */
|
||||
game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
t += 40;
|
||||
|
||||
if (t > TotalTime()) /* remove finished bullets */
|
||||
{
|
||||
game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
game.PlaySound("kaboom25.aud", false);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<Sprite, float2>> Render()
|
||||
|
||||
@@ -56,8 +56,8 @@ namespace OpenRa.Game.Graphics
|
||||
foreach (Actor a in game.world.Actors)
|
||||
DrawSpriteList(a.Owner, rect, a.Render());
|
||||
|
||||
foreach (Bullet b in game.world.Bullets)
|
||||
DrawSpriteList(b.Owner, rect, b.Render());
|
||||
foreach (IEffect e in game.world.Bullets)
|
||||
DrawSpriteList(e.Owner, rect, e.Render());
|
||||
|
||||
uiOverlay.Draw();
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ using System.Runtime.InteropServices;
|
||||
game.world.Add( jeep );
|
||||
var tank = new Actor( "3tnk", new int2( 12, 7 ), game.players[ 1 ] );
|
||||
game.world.Add( tank );
|
||||
//tank.traits.Get<Traits.AttackTurreted>().target = jeep;
|
||||
tank.traits.Get<Traits.AttackTurreted>().target = jeep;
|
||||
|
||||
sidebar = new Sidebar(renderer, game);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace OpenRa.Game
|
||||
class World
|
||||
{
|
||||
List<Actor> actors = new List<Actor>();
|
||||
List<Bullet> bullets = new List<Bullet>();
|
||||
List<IEffect> bullets = new List<IEffect>();
|
||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
||||
readonly Game game;
|
||||
int lastTime = Environment.TickCount;
|
||||
@@ -53,6 +53,6 @@ namespace OpenRa.Game
|
||||
}
|
||||
|
||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||
public IEnumerable<Bullet> Bullets { get { return bullets; } }
|
||||
public IEnumerable<IEffect> Bullets { get { return bullets; } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user