Added ExplosionPalette and WaterExplosionPalette traits to Warheads.

This is needed for TS water splashes, for example (they use unit*.pal instead of anim.pal).
Defaults to "effect".
This commit is contained in:
reaperrr
2014-04-18 01:23:09 +02:00
parent 18381f178b
commit c9b162ec3c
5 changed files with 18 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -41,9 +41,10 @@ namespace OpenRA.Mods.RA
var isWater = pos.Z == 0 && world.GetTerrainInfo(targetTile).IsWater;
var explosionType = isWater ? warhead.WaterExplosion : warhead.Explosion;
var explosionTypePalette = isWater ? warhead.WaterExplosionPalette : warhead.ExplosionPalette;
if (explosionType != null)
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosionType)));
world.AddFrameEndTask(w => w.Add(new Explosion(w, pos, explosionType, explosionTypePalette)));
Sound.Play(GetImpactSound(warhead, isWater), pos);

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -19,15 +19,17 @@ namespace OpenRA.Mods.RA.Effects
World world;
WPos pos;
CPos cell;
string palette;
Animation anim;
public Explosion(World world, WPos pos, string style)
public Explosion(World world, WPos pos, string sequence, string palette)
{
this.world = world;
this.pos = pos;
this.cell = pos.ToCPos();
this.palette = palette;
anim = new Animation("explosion");
anim.PlayThen(style, () => world.AddFrameEndTask(w => w.Remove(this)));
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick(World world) { anim.Tick(); }
@@ -37,7 +39,7 @@ namespace OpenRA.Mods.RA.Effects
if (world.FogObscures(cell))
return SpriteRenderable.None;
return anim.Render(pos, wr.Palette("effect"));
return anim.Render(pos, wr.Palette(palette));
}
}
}

View File

@@ -1,6 +1,6 @@
#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
@@ -19,10 +19,11 @@ namespace OpenRA.Mods.RA.Render
{
public void Killed(Actor self, AttackInfo e)
{
//TODO: Make palette for this customizable as well
var bi = self.Info.Traits.Get<BuildingInfo>();
FootprintUtils.UnpathableTiles(self.Info.Name, bi, self.Location).Do(
t => self.World.AddFrameEndTask(
w => w.Add(new Explosion(w, t.CenterPosition, "building"))));
w => w.Add(new Explosion(w, t.CenterPosition, "building", "effect"))));
}
}
}