diff --git a/OpenRa.Game/Combat.cs b/OpenRa.Game/Combat.cs index 7dc43a24db..efc99d224c 100644 --- a/OpenRa.Game/Combat.cs +++ b/OpenRa.Game/Combat.cs @@ -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) diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index 9053b2eafd..3862ea1f5a 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -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)); } } diff --git a/OpenRa.Game/Effects/Bullet.cs b/OpenRa.Game/Effects/Bullet.cs index 9d672f35a8..051a00bae5 100755 --- a/OpenRa.Game/Effects/Bullet.cs +++ b/OpenRa.Game/Effects/Bullet.cs @@ -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); } diff --git a/OpenRa.Game/Effects/Corpse.cs b/OpenRa.Game/Effects/Corpse.cs index bae41ef8a0..f4119aabc9 100755 --- a/OpenRa.Game/Effects/Corpse.cs +++ b/OpenRa.Game/Effects/Corpse.cs @@ -15,13 +15,13 @@ namespace OpenRa.Effects { anim = new Animation(fromActor.traits.GetOrDefault().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 Render() { diff --git a/OpenRa.Game/Effects/DelayedAction.cs b/OpenRa.Game/Effects/DelayedAction.cs index 91ae9bdc2e..bb691aa628 100755 --- a/OpenRa.Game/Effects/DelayedAction.cs +++ b/OpenRa.Game/Effects/DelayedAction.cs @@ -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 Render() { yield break; } diff --git a/OpenRa.Game/Effects/Explosion.cs b/OpenRa.Game/Effects/Explosion.cs index e6ac46ccb2..19215cb6fb 100755 --- a/OpenRa.Game/Effects/Explosion.cs +++ b/OpenRa.Game/Effects/Explosion.cs @@ -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 Render() { diff --git a/OpenRa.Game/Effects/FlashTarget.cs b/OpenRa.Game/Effects/FlashTarget.cs index 7029b2c820..8d9fdf2412 100755 --- a/OpenRa.Game/Effects/FlashTarget.cs +++ b/OpenRa.Game/Effects/FlashTarget.cs @@ -15,14 +15,14 @@ namespace OpenRa.Effects public FlashTarget(Actor target) { this.target = target; - foreach (var e in Game.world.Effects.OfType().Where(a => a.target == target).ToArray()) - Game.world.Remove(e); + foreach (var e in target.World.Effects.OfType().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 Render() diff --git a/OpenRa.Game/Effects/GpsSatellite.cs b/OpenRa.Game/Effects/GpsSatellite.cs index d008fdda22..7dbab9fd15 100755 --- a/OpenRa.Game/Effects/GpsSatellite.cs +++ b/OpenRa.Game/Effects/GpsSatellite.cs @@ -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 Render() diff --git a/OpenRa.Game/Effects/IEffect.cs b/OpenRa.Game/Effects/IEffect.cs index 73cfc5e2a8..12d0ccd158 100755 --- a/OpenRa.Game/Effects/IEffect.cs +++ b/OpenRa.Game/Effects/IEffect.cs @@ -6,7 +6,7 @@ namespace OpenRa.Effects { public interface IEffect { - void Tick(); + void Tick( World world ); IEnumerable Render(); } } diff --git a/OpenRa.Game/Effects/InvulnEffect.cs b/OpenRa.Game/Effects/InvulnEffect.cs index 9f59bb9d8d..e17dfd8382 100755 --- a/OpenRa.Game/Effects/InvulnEffect.cs +++ b/OpenRa.Game/Effects/InvulnEffect.cs @@ -15,10 +15,10 @@ namespace OpenRa.Effects this.b = a.traits.Get(); } - 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 Render() diff --git a/OpenRa.Game/Effects/Missile.cs b/OpenRa.Game/Effects/Missile.cs index da221bccad..8d4a63c1c8 100755 --- a/OpenRa.Game/Effects/Missile.cs +++ b/OpenRa.Game/Effects/Missile.cs @@ -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 } diff --git a/OpenRa.Game/Effects/MoveFlash.cs b/OpenRa.Game/Effects/MoveFlash.cs index 4105da8fb9..7aa214f0a5 100755 --- a/OpenRa.Game/Effects/MoveFlash.cs +++ b/OpenRa.Game/Effects/MoveFlash.cs @@ -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 Render() { diff --git a/OpenRa.Game/Effects/PowerDownIndicator.cs b/OpenRa.Game/Effects/PowerDownIndicator.cs index ee7e1032ac..dc064e4484 100755 --- a/OpenRa.Game/Effects/PowerDownIndicator.cs +++ b/OpenRa.Game/Effects/PowerDownIndicator.cs @@ -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) diff --git a/OpenRa.Game/Effects/RepairIndicator.cs b/OpenRa.Game/Effects/RepairIndicator.cs index c017176b3f..988c21bf3b 100755 --- a/OpenRa.Game/Effects/RepairIndicator.cs +++ b/OpenRa.Game/Effects/RepairIndicator.cs @@ -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 Render() diff --git a/OpenRa.Game/Effects/SatelliteLaunch.cs b/OpenRa.Game/Effects/SatelliteLaunch.cs index 0b3b267c24..441f4c4cf8 100755 --- a/OpenRa.Game/Effects/SatelliteLaunch.cs +++ b/OpenRa.Game/Effects/SatelliteLaunch.cs @@ -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))); } } diff --git a/OpenRa.Game/Effects/Smoke.cs b/OpenRa.Game/Effects/Smoke.cs index 1f515f01fa..33a04604d7 100755 --- a/OpenRa.Game/Effects/Smoke.cs +++ b/OpenRa.Game/Effects/Smoke.cs @@ -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(); } diff --git a/OpenRa.Game/Effects/TeslaZap.cs b/OpenRa.Game/Effects/TeslaZap.cs index ffc18611ef..f9baeb8d65 100755 --- a/OpenRa.Game/Effects/TeslaZap.cs +++ b/OpenRa.Game/Effects/TeslaZap.cs @@ -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; } diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index b2fdc5b3d6..1e0e41a5e7 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -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; } } diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index f970f2995f..cd3793f964 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -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(); diff --git a/OpenRa.Mods.RA/Mine.cs b/OpenRa.Mods.RA/Mine.cs index 9b8ae4744b..a499cdf604 100644 --- a/OpenRa.Mods.RA/Mine.cs +++ b/OpenRa.Mods.RA/Mine.cs @@ -32,10 +32,10 @@ namespace OpenRa.Mods.RA var info = self.Info.Traits.Get(); 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); }); }