Files
OpenRA/OpenRA.Mods.RA/Effects/GravityBomb.cs
reaperrr 9115395fb8 GravityBomb palette can now be customized the same way as for Bullets and Missiles.
Update CHANGELOG.

Also mentioned Bullets and Missiles since it seems there wasn't an entry for that before.
2014-04-18 23:53:03 +02:00

84 lines
2.1 KiB
C#

#region Copyright & License Information
/*
* Copyright 2007-2013 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,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
namespace OpenRA.Mods.RA.Effects
{
public class GravityBombInfo : IProjectileInfo
{
public readonly string Image = null;
public readonly bool Shadow = false;
public readonly WRange Velocity = WRange.Zero;
public readonly WRange Acceleration = new WRange(15);
public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); }
}
public class GravityBomb : IEffect
{
GravityBombInfo info;
Animation anim;
ProjectileArgs args;
WVec velocity;
WPos pos;
public GravityBomb(GravityBombInfo info, ProjectileArgs args)
{
this.info = info;
this.args = args;
pos = args.Source;
velocity = new WVec(WRange.Zero, WRange.Zero, -info.Velocity);
anim = new Animation(info.Image);
if (anim.HasSequence("open"))
anim.PlayThen("open", () => anim.PlayRepeating("idle"));
else
anim.PlayRepeating("idle");
}
public void Tick(World world)
{
velocity -= new WVec(WRange.Zero, WRange.Zero, info.Acceleration);
pos += velocity;
if (pos.Z <= args.PassiveTarget.Z)
{
pos += new WVec(0, 0, args.PassiveTarget.Z - pos.Z);
world.AddFrameEndTask(w => w.Remove(this));
Combat.DoImpacts(pos, args.SourceActor, args.Weapon, args.FirepowerModifier);
}
anim.Tick();
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
var cell = pos.ToCPos();
if (!args.SourceActor.World.FogObscures(cell))
{
if (info.Shadow)
{
var shadowPos = pos - new WVec(0, 0, pos.Z);
foreach (var r in anim.Render(shadowPos, wr.Palette("shadow")))
yield return r;
}
var palette = wr.Palette(args.Weapon.Palette);
foreach (var r in anim.Render(pos, palette))
yield return r;
}
}
}
}