Spatially partition NukeLaunch effect

This commit is contained in:
reaperrr
2017-09-03 21:55:02 +02:00
committed by Paul Chote
parent 9aa861eca9
commit be370cb855

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects
{
public class NukeLaunch : IProjectile
public class NukeLaunch : IProjectile, ISpatiallyPartitionable
{
readonly Player firedBy;
readonly Animation anim;
@@ -64,6 +64,8 @@ namespace OpenRA.Mods.Common.Effects
if (skipAscent)
ticks = turn;
firedBy.World.ScreenMap.Add(this, pos, anim.Image);
}
public void Tick(World world)
@@ -81,12 +83,14 @@ namespace OpenRA.Mods.Common.Effects
if (ticks == delay)
Explode(world);
world.ScreenMap.Update(this, pos, anim.Image);
ticks++;
}
void Explode(World world)
{
world.AddFrameEndTask(w => w.Remove(this));
world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); });
weapon.Impact(Target.FromPos(pos), firedBy.PlayerActor, Enumerable.Empty<int>());
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);