pass World to Effects/*

This commit is contained in:
Bob
2010-01-21 13:27:44 +13:00
parent 90b5df73b5
commit 4fa56f16c0
20 changed files with 43 additions and 43 deletions

View File

@@ -22,7 +22,7 @@ namespace OpenRa
if (warhead.Explosion != 0)
world.AddFrameEndTask(
w => w.Add(new Explosion(visualLoc, warhead.Explosion, hitWater)));
w => w.Add(new Explosion(w, visualLoc, warhead.Explosion, hitWater)));
var impactSound = warhead.ImpactSound;
if (hitWater && warhead.WaterImpactSound != null)

View File

@@ -61,7 +61,7 @@ namespace OpenRa
Sound.PlayVoice(isAttack ? "Attack" : "Move", voicedActor);
if (isMove)
Game.world.Add(new Effects.MoveFlash(Game.CellSize * xy));
Game.world.Add(new Effects.MoveFlash(Game.world, Game.CellSize * xy));
}
}

View File

@@ -56,13 +56,13 @@ namespace OpenRa.Effects
int TotalTime() { return (Dest - Src).Length * BaseBulletSpeed / Weapon.Speed; }
public void Tick()
public void Tick( World world )
{
t += 40;
if (t > TotalTime()) /* remove finished bullets */
{
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
Combat.DoImpact(Dest, VisualDest - new int2( 0, DestAltitude ),
Weapon, Projectile, Warhead, FiredBy);
}

View File

@@ -15,13 +15,13 @@ namespace OpenRa.Effects
{
anim = new Animation(fromActor.traits.GetOrDefault<RenderSimple>().GetImage(fromActor));
anim.PlayThen("die{0}".F(death + 1),
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
pos = fromActor.CenterLocation;
owner = fromActor.Owner;
}
public void Tick() { anim.Tick(); }
public void Tick( World world ) { anim.Tick(); }
public IEnumerable<Renderable> Render()
{

View File

@@ -15,10 +15,10 @@ namespace OpenRa.Effects
this.delay = delay;
}
public void Tick()
public void Tick( World world )
{
if (--delay <= 0)
Game.world.AddFrameEndTask(w => { w.Remove(this); a(); });
world.AddFrameEndTask(w => { w.Remove(this); a(); });
}
public IEnumerable<Renderable> Render() { yield break; }

View File

@@ -9,16 +9,16 @@ namespace OpenRa.Effects
Animation anim;
int2 pos;
public Explosion(int2 pixelPos, int style, bool isWater)
public Explosion( World world, int2 pixelPos, int style, bool isWater)
{
this.pos = pixelPos;
var variantSuffix = isWater ? "w" : "";
anim = new Animation("explosion");
anim.PlayThen(style.ToString() + variantSuffix,
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
() => world.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick() { anim.Tick(); }
public void Tick( World world ) { anim.Tick(); }
public IEnumerable<Renderable> Render()
{

View File

@@ -15,14 +15,14 @@ namespace OpenRa.Effects
public FlashTarget(Actor target)
{
this.target = target;
foreach (var e in Game.world.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
Game.world.Remove(e);
foreach (var e in target.World.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
target.World.Remove(e);
}
public void Tick()
public void Tick( World world )
{
if (--remainingTicks == 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()

View File

@@ -16,13 +16,13 @@ namespace OpenRa.Effects
anim.PlayRepeating("idle");
}
public void Tick()
public void Tick( World world )
{
anim.Tick();
offset.Y -= heightPerTick;
if (offset.Y < 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()

View File

@@ -6,7 +6,7 @@ namespace OpenRa.Effects
{
public interface IEffect
{
void Tick();
void Tick( World world );
IEnumerable<Renderable> Render();
}
}

View File

@@ -15,10 +15,10 @@ namespace OpenRa.Effects
this.b = a.traits.Get<IronCurtainable>();
}
public void Tick()
public void Tick( World world )
{
if (a.IsDead || b.GetDamageModifier() > 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()

View File

@@ -47,7 +47,7 @@ namespace OpenRa.Effects
const int MissileCloseEnough = 7;
const float Scale = .2f;
public void Tick()
public void Tick( World world )
{
t += 40;
@@ -64,7 +64,7 @@ namespace OpenRa.Effects
var dist = Target.CenterLocation - Pos;
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough || Target.IsDead)
{
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
if (t > Projectile.Arm * 40) /* don't blow up in our launcher's face! */
Combat.DoImpact(Pos.ToInt2(), Pos.ToInt2(), Weapon, Projectile, Warhead, FiredBy);
@@ -78,7 +78,7 @@ namespace OpenRa.Effects
Pos += move;
if (Projectile.Animates)
Game.world.AddFrameEndTask(w => w.Add(new Smoke((Pos - 1.5f * move - new int2( 0, Altitude )).ToInt2())));
world.AddFrameEndTask(w => w.Add(new Smoke(w, (Pos - 1.5f * move - new int2( 0, Altitude )).ToInt2())));
// todo: running out of fuel
}

View File

@@ -12,15 +12,15 @@ namespace OpenRa.Effects
Animation anim = new Animation("moveflsh");
float2 pos;
public MoveFlash( float2 pos )
public MoveFlash( World world, float2 pos )
{
this.pos = pos;
anim.PlayThen( "idle",
() => Game.world.AddFrameEndTask(
() => world.AddFrameEndTask(
w => w.Remove( this ) ) );
}
public void Tick() { anim.Tick(); }
public void Tick( World world ) { anim.Tick(); }
public IEnumerable<Renderable> Render()
{

View File

@@ -20,10 +20,10 @@ namespace OpenRa.Effects
anim.PlayRepeating("disabled");
}
public void Tick()
public void Tick( World world )
{
if (removeNextFrame == true)
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
// Fix off-by one frame bug with undisabling causing low-power
if (!b.Disabled || a.IsDead)

View File

@@ -12,10 +12,10 @@ namespace OpenRa.Effects
public RepairIndicator(Actor a) { this.a = a; anim.PlayRepeating("repair"); }
public void Tick()
public void Tick( World world )
{
if (--framesLeft == 0 || a.IsDead)
Game.world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()

View File

@@ -15,16 +15,16 @@ namespace OpenRa.Effects
{
this.a = a;
doors.PlayThen("active",
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
() => a.World.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick()
public void Tick( World world )
{
doors.Tick();
if (++frame == 19)
{
Game.world.AddFrameEndTask(w => w.Add(new GpsSatellite(a.CenterLocation - .5f * doors.Image.size + doorOffset)));
world.AddFrameEndTask(w => w.Add(new GpsSatellite(a.CenterLocation - .5f * doors.Image.size + doorOffset)));
}
}

View File

@@ -9,14 +9,14 @@ namespace OpenRa.Effects
readonly int2 pos;
readonly Animation anim = new Animation("smokey");
public Smoke(int2 pos)
public Smoke(World world, int2 pos)
{
this.pos = pos;
anim.PlayThen("idle",
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
() => world.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick()
public void Tick( World world )
{
anim.Tick();
}

View File

@@ -20,10 +20,10 @@ namespace OpenRa.Effects
this.tesla = SequenceProvider.GetSequence( "litning", "bright" );
}
public void Tick()
public void Tick( World world )
{
if( timeUntilRemove <= 0 )
Game.world.AddFrameEndTask( w => w.Remove( this ) );
world.AddFrameEndTask( w => w.Remove( this ) );
--timeUntilRemove;
}

View File

@@ -87,7 +87,7 @@ namespace OpenRa.Traits
break;
case DamageState.Dead:
DoBib(self, true);
self.World.AddFrameEndTask(w => w.Add(new Explosion(self.CenterLocation.ToInt2(), 7, false)));
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, self.CenterLocation.ToInt2(), 7, false)));
break;
}
}

View File

@@ -110,7 +110,7 @@ namespace OpenRa
}
foreach (var a in actors) a.Tick();
foreach (var e in effects) e.Tick();
foreach (var e in effects) e.Tick( this );
Game.viewport.Tick();

View File

@@ -32,10 +32,10 @@ namespace OpenRa.Mods.RA
var info = self.Info.Traits.Get<MineInfo>();
var warhead = Rules.WarheadInfo[info.Warhead];
self.World.AddFrameEndTask(_ =>
self.World.AddFrameEndTask(w =>
{
self.World.Remove(self);
self.World.Add(new Explosion(self.CenterLocation.ToInt2(), warhead.Explosion, false));
w.Remove(self);
w.Add(new Explosion(w, self.CenterLocation.ToInt2(), warhead.Explosion, false));
crusher.InflictDamage(crusher, info.Damage, warhead);
});
}