Update copyright header. Normalize line endings to LF.
This commit is contained in:
@@ -1,155 +1,155 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class BulletInfo : IProjectileInfo
|
||||
{
|
||||
public readonly int Speed = 1;
|
||||
public readonly string Trail = null;
|
||||
public readonly float Inaccuracy = 0; // pixels at maximum range
|
||||
public readonly string Image = null;
|
||||
public readonly bool High = false;
|
||||
public readonly int RangeLimit = 0;
|
||||
public readonly int Arm = 0;
|
||||
public readonly bool Shadow = false;
|
||||
public readonly bool Proximity = false;
|
||||
public readonly float Angle = 0;
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Bullet( this, args ); }
|
||||
}
|
||||
|
||||
public class Bullet : IEffect
|
||||
{
|
||||
readonly BulletInfo Info;
|
||||
readonly ProjectileArgs Args;
|
||||
|
||||
int t = 0;
|
||||
Animation anim;
|
||||
|
||||
const int BaseBulletSpeed = 100; /* pixels / 40ms frame */
|
||||
|
||||
public Bullet(BulletInfo info, ProjectileArgs args)
|
||||
{
|
||||
Info = info;
|
||||
Args = args;
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
{
|
||||
var factor = ((Args.dest - Args.src).Length / Game.CellSize) / args.weapon.Range;
|
||||
Args.dest += (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
}
|
||||
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, GetEffectiveFacing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
}
|
||||
|
||||
int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; }
|
||||
|
||||
float GetAltitude()
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
return (Args.dest - Args.src).Length * Info.Angle * 4 * at * (1 - at);
|
||||
}
|
||||
|
||||
int GetEffectiveFacing()
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var attitude = Info.Angle * (1 - 2 * at);
|
||||
|
||||
var rawFacing = Traits.Util.GetFacing(Args.dest - Args.src, 0);
|
||||
var u = (rawFacing % 128) / 128f;
|
||||
var scale = 512 * u * (1 - u);
|
||||
|
||||
return (int)(rawFacing < 128
|
||||
? rawFacing - scale * attitude
|
||||
: rawFacing + scale * attitude);
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
t += 40;
|
||||
|
||||
if (anim != null) anim.Tick();
|
||||
|
||||
if (t > TotalTime()) Explode( world );
|
||||
|
||||
if (Info.Trail != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
|
||||
|
||||
var highPos = (Info.High || Info.Angle > 0)
|
||||
? (pos - new float2(0, GetAltitude()))
|
||||
: pos;
|
||||
|
||||
world.AddFrameEndTask(w => w.Add(
|
||||
new Smoke(w, highPos.ToInt2(), Info.Trail)));
|
||||
}
|
||||
|
||||
if (!Info.High) // check for hitting a wall
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at);
|
||||
var cell = Traits.Util.CellContaining(pos);
|
||||
|
||||
if (world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||
a => a.HasTrait<IBlocksBullets>()))
|
||||
{
|
||||
Args.dest = pos.ToInt2();
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const float height = .1f;
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (anim != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
|
||||
|
||||
if (Info.High || Info.Angle > 0)
|
||||
{
|
||||
if (Info.Shadow)
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
|
||||
|
||||
var highPos = pos - new float2(0, GetAltitude());
|
||||
|
||||
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
else
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size,
|
||||
Args.weapon.Underwater ? "shadow" : Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
void Explode( World world )
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class BulletInfo : IProjectileInfo
|
||||
{
|
||||
public readonly int Speed = 1;
|
||||
public readonly string Trail = null;
|
||||
public readonly float Inaccuracy = 0; // pixels at maximum range
|
||||
public readonly string Image = null;
|
||||
public readonly bool High = false;
|
||||
public readonly int RangeLimit = 0;
|
||||
public readonly int Arm = 0;
|
||||
public readonly bool Shadow = false;
|
||||
public readonly bool Proximity = false;
|
||||
public readonly float Angle = 0;
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Bullet( this, args ); }
|
||||
}
|
||||
|
||||
public class Bullet : IEffect
|
||||
{
|
||||
readonly BulletInfo Info;
|
||||
readonly ProjectileArgs Args;
|
||||
|
||||
int t = 0;
|
||||
Animation anim;
|
||||
|
||||
const int BaseBulletSpeed = 100; /* pixels / 40ms frame */
|
||||
|
||||
public Bullet(BulletInfo info, ProjectileArgs args)
|
||||
{
|
||||
Info = info;
|
||||
Args = args;
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
{
|
||||
var factor = ((Args.dest - Args.src).Length / Game.CellSize) / args.weapon.Range;
|
||||
Args.dest += (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
}
|
||||
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, GetEffectiveFacing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
}
|
||||
|
||||
int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; }
|
||||
|
||||
float GetAltitude()
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
return (Args.dest - Args.src).Length * Info.Angle * 4 * at * (1 - at);
|
||||
}
|
||||
|
||||
int GetEffectiveFacing()
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var attitude = Info.Angle * (1 - 2 * at);
|
||||
|
||||
var rawFacing = Traits.Util.GetFacing(Args.dest - Args.src, 0);
|
||||
var u = (rawFacing % 128) / 128f;
|
||||
var scale = 512 * u * (1 - u);
|
||||
|
||||
return (int)(rawFacing < 128
|
||||
? rawFacing - scale * attitude
|
||||
: rawFacing + scale * attitude);
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
t += 40;
|
||||
|
||||
if (anim != null) anim.Tick();
|
||||
|
||||
if (t > TotalTime()) Explode( world );
|
||||
|
||||
if (Info.Trail != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
|
||||
|
||||
var highPos = (Info.High || Info.Angle > 0)
|
||||
? (pos - new float2(0, GetAltitude()))
|
||||
: pos;
|
||||
|
||||
world.AddFrameEndTask(w => w.Add(
|
||||
new Smoke(w, highPos.ToInt2(), Info.Trail)));
|
||||
}
|
||||
|
||||
if (!Info.High) // check for hitting a wall
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at);
|
||||
var cell = Traits.Util.CellContaining(pos);
|
||||
|
||||
if (world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||
a => a.HasTrait<IBlocksBullets>()))
|
||||
{
|
||||
Args.dest = pos.ToInt2();
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const float height = .1f;
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (anim != null)
|
||||
{
|
||||
var at = (float)t / TotalTime();
|
||||
|
||||
var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at);
|
||||
var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude);
|
||||
|
||||
if (Info.High || Info.Angle > 0)
|
||||
{
|
||||
if (Info.Shadow)
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y);
|
||||
|
||||
var highPos = pos - new float2(0, GetAltitude());
|
||||
|
||||
yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
else
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size,
|
||||
Args.weapon.Underwater ? "shadow" : Args.firedBy.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
void Explode( World world )
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ContrailInfo : ITraitInfo
|
||||
{
|
||||
public readonly int[] ContrailOffset = {0, 0};
|
||||
|
||||
public readonly int TrailLength = 20;
|
||||
public readonly bool UsePlayerColor = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new Contrail(init.self, this); }
|
||||
}
|
||||
|
||||
class Contrail : ITick, IPostRender
|
||||
{
|
||||
private ContrailInfo Info = null;
|
||||
|
||||
private List<float2> positions = new List<float2>();
|
||||
|
||||
private Turret ContrailTurret = null;
|
||||
|
||||
private int TrailLength = 0;
|
||||
private Color TrailColor = Color.White;
|
||||
|
||||
public Contrail(Actor self, ContrailInfo info)
|
||||
{
|
||||
Info = info;
|
||||
|
||||
ContrailTurret = new Turret(Info.ContrailOffset);
|
||||
|
||||
TrailLength = Info.TrailLength;
|
||||
|
||||
if (Info.UsePlayerColor)
|
||||
{
|
||||
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
|
||||
TrailColor = PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var facing = self.Trait<IFacing>();
|
||||
var altitude = new float2(0, self.Trait<IMove>().Altitude);
|
||||
|
||||
float2 pos = self.CenterLocation - Combat.GetTurretPosition(self, facing, ContrailTurret) - altitude;
|
||||
|
||||
positions.Add(pos);
|
||||
|
||||
if (positions.Count >= TrailLength)
|
||||
{
|
||||
positions.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||
{
|
||||
Color trailStart = TrailColor;
|
||||
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
|
||||
trailStart.G, trailStart.B);
|
||||
|
||||
for (int i = positions.Count - 1; i >= 1; --i)
|
||||
{
|
||||
var conPos = positions[i];
|
||||
var nextPos = positions[i - 1];
|
||||
|
||||
if (self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) ||
|
||||
self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos)))
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd);
|
||||
|
||||
trailStart = trailEnd;
|
||||
trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R,
|
||||
trailStart.G, trailStart.B);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 System.Drawing;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ContrailInfo : ITraitInfo
|
||||
{
|
||||
public readonly int[] ContrailOffset = {0, 0};
|
||||
|
||||
public readonly int TrailLength = 20;
|
||||
public readonly bool UsePlayerColor = true;
|
||||
|
||||
public object Create(ActorInitializer init) { return new Contrail(init.self, this); }
|
||||
}
|
||||
|
||||
class Contrail : ITick, IPostRender
|
||||
{
|
||||
private ContrailInfo Info = null;
|
||||
|
||||
private List<float2> positions = new List<float2>();
|
||||
|
||||
private Turret ContrailTurret = null;
|
||||
|
||||
private int TrailLength = 0;
|
||||
private Color TrailColor = Color.White;
|
||||
|
||||
public Contrail(Actor self, ContrailInfo info)
|
||||
{
|
||||
Info = info;
|
||||
|
||||
ContrailTurret = new Turret(Info.ContrailOffset);
|
||||
|
||||
TrailLength = Info.TrailLength;
|
||||
|
||||
if (Info.UsePlayerColor)
|
||||
{
|
||||
var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0));
|
||||
TrailColor = PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var facing = self.Trait<IFacing>();
|
||||
var altitude = new float2(0, self.Trait<IMove>().Altitude);
|
||||
|
||||
float2 pos = self.CenterLocation - Combat.GetTurretPosition(self, facing, ContrailTurret) - altitude;
|
||||
|
||||
positions.Add(pos);
|
||||
|
||||
if (positions.Count >= TrailLength)
|
||||
{
|
||||
positions.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||
{
|
||||
Color trailStart = TrailColor;
|
||||
Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R,
|
||||
trailStart.G, trailStart.B);
|
||||
|
||||
for (int i = positions.Count - 1; i >= 1; --i)
|
||||
{
|
||||
var conPos = positions[i];
|
||||
var nextPos = positions[i - 1];
|
||||
|
||||
if (self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) ||
|
||||
self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos)))
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd);
|
||||
|
||||
trailStart = trailEnd;
|
||||
trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R,
|
||||
trailStart.G, trailStart.B);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Corpse : IEffect
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly float2 pos;
|
||||
readonly Player owner;
|
||||
|
||||
public Corpse(Actor fromActor, int death)
|
||||
{
|
||||
anim = new Animation(fromActor.TraitOrDefault<RenderSimple>().GetImage(fromActor));
|
||||
anim.PlayThen("die{0}".F(death + 1),
|
||||
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
|
||||
pos = fromActor.CenterLocation;
|
||||
owner = fromActor.Owner;
|
||||
}
|
||||
|
||||
public void Tick( World world ) { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Corpse : IEffect
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly float2 pos;
|
||||
readonly Player owner;
|
||||
|
||||
public Corpse(Actor fromActor, int death)
|
||||
{
|
||||
anim = new Animation(fromActor.TraitOrDefault<RenderSimple>().GetImage(fromActor));
|
||||
anim.PlayThen("die{0}".F(death + 1),
|
||||
() => fromActor.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
|
||||
pos = fromActor.CenterLocation;
|
||||
owner = fromActor.Owner;
|
||||
}
|
||||
|
||||
public void Tick( World world ) { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class CrateEffect : IEffect
|
||||
{
|
||||
Actor a;
|
||||
Animation anim = new Animation("crate-effects");
|
||||
float2 offset = new float2(-4,0);
|
||||
|
||||
public CrateEffect(Actor a, string seq, int2 offset)
|
||||
: this(a, seq)
|
||||
{
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public CrateEffect(Actor a, string seq)
|
||||
{
|
||||
this.a = a;
|
||||
anim.PlayThen(seq,
|
||||
() => a.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (a.IsInWorld)
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size + offset, "effect", (int)a.CenterLocation.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class CrateEffect : IEffect
|
||||
{
|
||||
Actor a;
|
||||
Animation anim = new Animation("crate-effects");
|
||||
float2 offset = new float2(-4,0);
|
||||
|
||||
public CrateEffect(Actor a, string seq, int2 offset)
|
||||
: this(a, seq)
|
||||
{
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public CrateEffect(Actor a, string seq)
|
||||
{
|
||||
this.a = a;
|
||||
anim.PlayThen(seq,
|
||||
() => a.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (a.IsInWorld)
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size + offset, "effect", (int)a.CenterLocation.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Explosion : IEffect
|
||||
{
|
||||
Animation anim;
|
||||
int2 pos;
|
||||
int altitude;
|
||||
|
||||
public Explosion(World world, int2 pixelPos, string style, bool isWater, int altitude)
|
||||
{
|
||||
this.pos = pixelPos;
|
||||
this.altitude = altitude;
|
||||
anim = new Animation("explosion");
|
||||
anim.PlayThen(style,
|
||||
() => world.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world ) { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
pos - .5f * anim.Image.size - new int2(0,altitude),
|
||||
"effect", (int)pos.Y - altitude);
|
||||
}
|
||||
|
||||
public Player Owner { get { return null; } }
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Explosion : IEffect
|
||||
{
|
||||
Animation anim;
|
||||
int2 pos;
|
||||
int altitude;
|
||||
|
||||
public Explosion(World world, int2 pixelPos, string style, bool isWater, int altitude)
|
||||
{
|
||||
this.pos = pixelPos;
|
||||
this.altitude = altitude;
|
||||
anim = new Animation("explosion");
|
||||
anim.PlayThen(style,
|
||||
() => world.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world ) { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
pos - .5f * anim.Image.size - new int2(0,altitude),
|
||||
"effect", (int)pos.Y - altitude);
|
||||
}
|
||||
|
||||
public Player Owner { get { return null; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class GpsSatellite : IEffect
|
||||
{
|
||||
readonly float heightPerTick = 10;
|
||||
float2 offset;
|
||||
Animation anim = new Animation("sputnik");
|
||||
|
||||
public GpsSatellite(float2 offset)
|
||||
{
|
||||
this.offset = offset;
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
offset.Y -= heightPerTick;
|
||||
|
||||
if (offset.Y < 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,offset, "effect", (int)offset.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class GpsSatellite : IEffect
|
||||
{
|
||||
readonly float heightPerTick = 10;
|
||||
float2 offset;
|
||||
Animation anim = new Animation("sputnik");
|
||||
|
||||
public GpsSatellite(float2 offset)
|
||||
{
|
||||
this.offset = offset;
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
offset.Y -= heightPerTick;
|
||||
|
||||
if (offset.Y < 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,offset, "effect", (int)offset.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class GravityBombInfo : IProjectileInfo
|
||||
{
|
||||
public readonly string Image = null;
|
||||
public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); }
|
||||
}
|
||||
|
||||
public class GravityBomb : IEffect
|
||||
{
|
||||
Animation anim;
|
||||
int altitude;
|
||||
ProjectileArgs Args;
|
||||
|
||||
public GravityBomb(GravityBombInfo info, ProjectileArgs args)
|
||||
{
|
||||
Args = args;
|
||||
altitude = args.srcAltitude;
|
||||
|
||||
anim = new Animation(info.Image);
|
||||
if (anim.HasSequence("open"))
|
||||
anim.PlayThen("open", () => anim.PlayRepeating("idle"));
|
||||
else
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (--altitude <= Args.destAltitude)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
Args.dest - new int2(0, altitude) - .5f * anim.Image.size, "effect", Args.dest.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class GravityBombInfo : IProjectileInfo
|
||||
{
|
||||
public readonly string Image = null;
|
||||
public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); }
|
||||
}
|
||||
|
||||
public class GravityBomb : IEffect
|
||||
{
|
||||
Animation anim;
|
||||
int altitude;
|
||||
ProjectileArgs Args;
|
||||
|
||||
public GravityBomb(GravityBombInfo info, ProjectileArgs args)
|
||||
{
|
||||
Args = args;
|
||||
altitude = args.srcAltitude;
|
||||
|
||||
anim = new Animation(info.Image);
|
||||
if (anim.HasSequence("open"))
|
||||
anim.PlayThen("open", () => anim.PlayRepeating("idle"));
|
||||
else
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (--altitude <= Args.destAltitude)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
Args.dest - new int2(0, altitude) - .5f * anim.Image.size, "effect", Args.dest.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class InvulnEffect : IEffect
|
||||
{
|
||||
Actor a;
|
||||
IronCurtainable b;
|
||||
|
||||
public InvulnEffect(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = a.Trait<IronCurtainable>();
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if (a.Destroyed || a.IsDead() || b.GetDamageModifier(null, null) > 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (a.Destroyed) // Tick will clean up
|
||||
yield break;
|
||||
|
||||
foreach (var r in a.Render())
|
||||
yield return r.WithPalette("invuln");
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class InvulnEffect : IEffect
|
||||
{
|
||||
Actor a;
|
||||
IronCurtainable b;
|
||||
|
||||
public InvulnEffect(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = a.Trait<IronCurtainable>();
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if (a.Destroyed || a.IsDead() || b.GetDamageModifier(null, null) > 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (a.Destroyed) // Tick will clean up
|
||||
yield break;
|
||||
|
||||
foreach (var r in a.Render())
|
||||
yield return r.WithPalette("invuln");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,77 +1,77 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class LaserZapInfo : IProjectileInfo
|
||||
{
|
||||
public readonly int BeamRadius = 1;
|
||||
public readonly bool UsePlayerColor = false;
|
||||
|
||||
public IEffect Create(ProjectileArgs args)
|
||||
{
|
||||
Color c = UsePlayerColor ? args.firedBy.Owner.ColorRamp.GetColor(0) : Color.Red;
|
||||
return new LaserZap(args, BeamRadius, c);
|
||||
}
|
||||
}
|
||||
|
||||
class LaserZap : IEffect
|
||||
{
|
||||
ProjectileArgs args;
|
||||
readonly int radius;
|
||||
int timeUntilRemove = 10; // # of frames
|
||||
int totalTime = 10;
|
||||
Color color;
|
||||
bool doneDamage = false;
|
||||
|
||||
public LaserZap(ProjectileArgs args, int radius, Color color)
|
||||
{
|
||||
this.args = args;
|
||||
this.color = color;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (timeUntilRemove <= 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
--timeUntilRemove;
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (args.target.IsValid)
|
||||
args.dest = args.target.CenterLocation;
|
||||
|
||||
Combat.DoImpacts(args);
|
||||
doneDamage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
int alpha = (int)((1-(float)(totalTime-timeUntilRemove)/totalTime)*255);
|
||||
Color rc = Color.FromArgb(alpha,color);
|
||||
|
||||
float2 unit = 1.0f/(args.src - args.dest).Length*(args.src - args.dest).ToFloat2();
|
||||
float2 norm = new float2(-unit.Y, unit.X);
|
||||
|
||||
for (int i = -radius; i < radius; i++)
|
||||
Game.Renderer.LineRenderer.DrawLine(args.src + i * norm, args.dest + i * norm, rc, rc);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 System.Drawing;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class LaserZapInfo : IProjectileInfo
|
||||
{
|
||||
public readonly int BeamRadius = 1;
|
||||
public readonly bool UsePlayerColor = false;
|
||||
|
||||
public IEffect Create(ProjectileArgs args)
|
||||
{
|
||||
Color c = UsePlayerColor ? args.firedBy.Owner.ColorRamp.GetColor(0) : Color.Red;
|
||||
return new LaserZap(args, BeamRadius, c);
|
||||
}
|
||||
}
|
||||
|
||||
class LaserZap : IEffect
|
||||
{
|
||||
ProjectileArgs args;
|
||||
readonly int radius;
|
||||
int timeUntilRemove = 10; // # of frames
|
||||
int totalTime = 10;
|
||||
Color color;
|
||||
bool doneDamage = false;
|
||||
|
||||
public LaserZap(ProjectileArgs args, int radius, Color color)
|
||||
{
|
||||
this.args = args;
|
||||
this.color = color;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (timeUntilRemove <= 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
--timeUntilRemove;
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (args.target.IsValid)
|
||||
args.dest = args.target.CenterLocation;
|
||||
|
||||
Combat.DoImpacts(args);
|
||||
doneDamage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
int alpha = (int)((1-(float)(totalTime-timeUntilRemove)/totalTime)*255);
|
||||
Color rc = Color.FromArgb(alpha,color);
|
||||
|
||||
float2 unit = 1.0f/(args.src - args.dest).Length*(args.src - args.dest).ToFloat2();
|
||||
float2 norm = new float2(-unit.Y, unit.X);
|
||||
|
||||
for (int i = -radius; i < radius; i++)
|
||||
Game.Renderer.LineRenderer.DrawLine(args.src + i * norm, args.dest + i * norm, rc, rc);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,139 +1,139 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class MissileInfo : IProjectileInfo
|
||||
{
|
||||
public readonly int Speed = 1;
|
||||
public readonly int Arm = 0;
|
||||
public readonly bool High = false;
|
||||
public readonly bool Shadow = true;
|
||||
public readonly bool Proximity = false;
|
||||
public readonly string Trail = null;
|
||||
public readonly float Inaccuracy = 0;
|
||||
public readonly string Image = null;
|
||||
public readonly int ROT = 5;
|
||||
public readonly int RangeLimit = 0;
|
||||
public readonly bool TurboBoost = false;
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
|
||||
}
|
||||
|
||||
class Missile : IEffect
|
||||
{
|
||||
readonly MissileInfo Info;
|
||||
readonly ProjectileArgs Args;
|
||||
|
||||
int2 offset;
|
||||
public int2 SubPxPosition;
|
||||
public int2 PxPosition { get { return new int2( SubPxPosition.X / 1024, SubPxPosition.Y / 1024 ); } }
|
||||
|
||||
readonly Animation anim;
|
||||
int Facing;
|
||||
int t;
|
||||
int Altitude;
|
||||
|
||||
public Missile(MissileInfo info, ProjectileArgs args)
|
||||
{
|
||||
Info = info;
|
||||
Args = args;
|
||||
|
||||
SubPxPosition = 1024*Args.src;
|
||||
Altitude = Args.srcAltitude;
|
||||
Facing = Args.facing;
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, () => Facing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
}
|
||||
|
||||
// In pixels
|
||||
const int MissileCloseEnough = 7;
|
||||
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
t += 40;
|
||||
|
||||
// In pixels
|
||||
var dist = Args.target.CenterLocation + offset - PxPosition;
|
||||
|
||||
var targetAltitude = 0;
|
||||
if (Args.target.IsValid && Args.target.IsActor && Args.target.Actor.HasTrait<IMove>())
|
||||
targetAltitude = Args.target.Actor.Trait<IMove>().Altitude;
|
||||
|
||||
Altitude += Math.Sign(targetAltitude - Altitude);
|
||||
|
||||
Facing = Traits.Util.TickFacing(Facing,
|
||||
Traits.Util.GetFacing(dist, Facing),
|
||||
Info.ROT);
|
||||
|
||||
anim.Tick();
|
||||
|
||||
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough || !Args.target.IsValid )
|
||||
Explode(world);
|
||||
|
||||
// TODO: Replace this with a lookup table
|
||||
var dir = (-float2.FromAngle((float)(Facing / 128f * Math.PI))*1024).ToInt2();
|
||||
|
||||
var move = Info.Speed * dir;
|
||||
if (targetAltitude > 0 && Info.TurboBoost)
|
||||
move = (move * 3) / 2;
|
||||
move = move / 5;
|
||||
|
||||
SubPxPosition += move;
|
||||
|
||||
if (Info.Trail != null)
|
||||
{
|
||||
var sp = (SubPxPosition - (move * 3) / 2) / 1024 - new int2(0, Altitude);
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, sp, Info.Trail)));
|
||||
}
|
||||
|
||||
if (Info.RangeLimit != 0 && t > Info.RangeLimit * 40)
|
||||
Explode(world);
|
||||
|
||||
if (!Info.High) // check for hitting a wall
|
||||
{
|
||||
var cell = Traits.Util.CellContaining(PxPosition);
|
||||
if (world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||
a => a.HasTrait<IBlocksBullets>()))
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Args.dest = PxPosition;
|
||||
if (t > Info.Arm * 40) /* don't blow up in our launcher's face! */
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
|
||||
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class MissileInfo : IProjectileInfo
|
||||
{
|
||||
public readonly int Speed = 1;
|
||||
public readonly int Arm = 0;
|
||||
public readonly bool High = false;
|
||||
public readonly bool Shadow = true;
|
||||
public readonly bool Proximity = false;
|
||||
public readonly string Trail = null;
|
||||
public readonly float Inaccuracy = 0;
|
||||
public readonly string Image = null;
|
||||
public readonly int ROT = 5;
|
||||
public readonly int RangeLimit = 0;
|
||||
public readonly bool TurboBoost = false;
|
||||
|
||||
public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); }
|
||||
}
|
||||
|
||||
class Missile : IEffect
|
||||
{
|
||||
readonly MissileInfo Info;
|
||||
readonly ProjectileArgs Args;
|
||||
|
||||
int2 offset;
|
||||
public int2 SubPxPosition;
|
||||
public int2 PxPosition { get { return new int2( SubPxPosition.X / 1024, SubPxPosition.Y / 1024 ); } }
|
||||
|
||||
readonly Animation anim;
|
||||
int Facing;
|
||||
int t;
|
||||
int Altitude;
|
||||
|
||||
public Missile(MissileInfo info, ProjectileArgs args)
|
||||
{
|
||||
Info = info;
|
||||
Args = args;
|
||||
|
||||
SubPxPosition = 1024*Args.src;
|
||||
Altitude = Args.srcAltitude;
|
||||
Facing = Args.facing;
|
||||
|
||||
if (info.Inaccuracy > 0)
|
||||
offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
|
||||
|
||||
if (Info.Image != null)
|
||||
{
|
||||
anim = new Animation(Info.Image, () => Facing);
|
||||
anim.PlayRepeating("idle");
|
||||
}
|
||||
}
|
||||
|
||||
// In pixels
|
||||
const int MissileCloseEnough = 7;
|
||||
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
t += 40;
|
||||
|
||||
// In pixels
|
||||
var dist = Args.target.CenterLocation + offset - PxPosition;
|
||||
|
||||
var targetAltitude = 0;
|
||||
if (Args.target.IsValid && Args.target.IsActor && Args.target.Actor.HasTrait<IMove>())
|
||||
targetAltitude = Args.target.Actor.Trait<IMove>().Altitude;
|
||||
|
||||
Altitude += Math.Sign(targetAltitude - Altitude);
|
||||
|
||||
Facing = Traits.Util.TickFacing(Facing,
|
||||
Traits.Util.GetFacing(dist, Facing),
|
||||
Info.ROT);
|
||||
|
||||
anim.Tick();
|
||||
|
||||
if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough || !Args.target.IsValid )
|
||||
Explode(world);
|
||||
|
||||
// TODO: Replace this with a lookup table
|
||||
var dir = (-float2.FromAngle((float)(Facing / 128f * Math.PI))*1024).ToInt2();
|
||||
|
||||
var move = Info.Speed * dir;
|
||||
if (targetAltitude > 0 && Info.TurboBoost)
|
||||
move = (move * 3) / 2;
|
||||
move = move / 5;
|
||||
|
||||
SubPxPosition += move;
|
||||
|
||||
if (Info.Trail != null)
|
||||
{
|
||||
var sp = (SubPxPosition - (move * 3) / 2) / 1024 - new int2(0, Altitude);
|
||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, sp, Info.Trail)));
|
||||
}
|
||||
|
||||
if (Info.RangeLimit != 0 && t > Info.RangeLimit * 40)
|
||||
Explode(world);
|
||||
|
||||
if (!Info.High) // check for hitting a wall
|
||||
{
|
||||
var cell = Traits.Util.CellContaining(PxPosition);
|
||||
if (world.WorldActor.Trait<UnitInfluence>().GetUnitsAt(cell).Any(
|
||||
a => a.HasTrait<IBlocksBullets>()))
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Args.dest = PxPosition;
|
||||
if (t > Info.Arm * 40) /* don't blow up in our launcher's face! */
|
||||
Combat.DoImpacts(Args);
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude),
|
||||
Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class NukeLaunch : IEffect
|
||||
{
|
||||
readonly Player firedBy;
|
||||
Animation anim;
|
||||
int2 pos;
|
||||
int2 targetLocation;
|
||||
int altitude;
|
||||
bool goingUp = true;
|
||||
string weapon;
|
||||
|
||||
public NukeLaunch(Player firedBy, Actor silo, string weapon, int2 spawnOffset, int2 targetLocation)
|
||||
{
|
||||
this.firedBy = firedBy;
|
||||
this.targetLocation = targetLocation;
|
||||
this.weapon = weapon;
|
||||
anim = new Animation(weapon);
|
||||
anim.PlayRepeating("up");
|
||||
|
||||
if (silo == null)
|
||||
{
|
||||
altitude = firedBy.World.Map.Bounds.Height*Game.CellSize;
|
||||
StartDescent(firedBy.World);
|
||||
}
|
||||
else
|
||||
pos = silo.CenterLocation + spawnOffset;
|
||||
}
|
||||
|
||||
void StartDescent(World world)
|
||||
{
|
||||
pos = OpenRA.Traits.Util.CenterOfCell(targetLocation);
|
||||
anim.PlayRepeating("down");
|
||||
goingUp = false;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
anim.Tick();
|
||||
|
||||
if (goingUp)
|
||||
{
|
||||
altitude += 10;
|
||||
if (altitude >= world.Map.Bounds.Height*Game.CellSize)
|
||||
StartDescent(world);
|
||||
}
|
||||
else
|
||||
{
|
||||
altitude -= 10;
|
||||
if (altitude <= 0)
|
||||
{
|
||||
// Trigger screen desaturate effect
|
||||
foreach (var a in world.Queries.WithTrait<NukePaletteEffect>())
|
||||
a.Trait.Enable();
|
||||
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoExplosion(firedBy.PlayerActor, weapon, pos, 0);
|
||||
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - 0.5f * anim.Image.size - new float2(0, altitude),
|
||||
"effect", (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class NukeLaunch : IEffect
|
||||
{
|
||||
readonly Player firedBy;
|
||||
Animation anim;
|
||||
int2 pos;
|
||||
int2 targetLocation;
|
||||
int altitude;
|
||||
bool goingUp = true;
|
||||
string weapon;
|
||||
|
||||
public NukeLaunch(Player firedBy, Actor silo, string weapon, int2 spawnOffset, int2 targetLocation)
|
||||
{
|
||||
this.firedBy = firedBy;
|
||||
this.targetLocation = targetLocation;
|
||||
this.weapon = weapon;
|
||||
anim = new Animation(weapon);
|
||||
anim.PlayRepeating("up");
|
||||
|
||||
if (silo == null)
|
||||
{
|
||||
altitude = firedBy.World.Map.Bounds.Height*Game.CellSize;
|
||||
StartDescent(firedBy.World);
|
||||
}
|
||||
else
|
||||
pos = silo.CenterLocation + spawnOffset;
|
||||
}
|
||||
|
||||
void StartDescent(World world)
|
||||
{
|
||||
pos = OpenRA.Traits.Util.CenterOfCell(targetLocation);
|
||||
anim.PlayRepeating("down");
|
||||
goingUp = false;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
anim.Tick();
|
||||
|
||||
if (goingUp)
|
||||
{
|
||||
altitude += 10;
|
||||
if (altitude >= world.Map.Bounds.Height*Game.CellSize)
|
||||
StartDescent(world);
|
||||
}
|
||||
else
|
||||
{
|
||||
altitude -= 10;
|
||||
if (altitude <= 0)
|
||||
{
|
||||
// Trigger screen desaturate effect
|
||||
foreach (var a in world.Queries.WithTrait<NukePaletteEffect>())
|
||||
a.Trait.Enable();
|
||||
|
||||
Explode(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Explode(World world)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
Combat.DoExplosion(firedBy.PlayerActor, weapon, pos, 0);
|
||||
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - 0.5f * anim.Image.size - new float2(0, altitude),
|
||||
"effect", (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Parachute : IEffect
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly Animation paraAnim;
|
||||
readonly float2 location;
|
||||
|
||||
readonly Actor cargo;
|
||||
readonly Player owner;
|
||||
|
||||
float altitude;
|
||||
const float fallRate = .3f;
|
||||
|
||||
public Parachute(Player owner, string image, float2 location, int altitude, Actor cargo)
|
||||
{
|
||||
this.location = location;
|
||||
this.altitude = altitude;
|
||||
this.cargo = cargo;
|
||||
this.owner = owner;
|
||||
|
||||
anim = new Animation(image);
|
||||
if (anim.HasSequence("idle"))
|
||||
anim.PlayFetchIndex("idle", () => 0);
|
||||
else
|
||||
anim.PlayFetchIndex("stand", () => 0);
|
||||
anim.Tick();
|
||||
|
||||
paraAnim = new Animation("parach");
|
||||
paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
paraAnim.Tick();
|
||||
|
||||
altitude -= fallRate;
|
||||
|
||||
if (altitude <= 0)
|
||||
world.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(this);
|
||||
var loc = Traits.Util.CellContaining(location);
|
||||
cargo.CancelActivity();
|
||||
cargo.Trait<ITeleportable>().SetPosition(cargo, loc);
|
||||
w.Add(cargo);
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
var pos = location - new float2(0, altitude);
|
||||
yield return new Renderable(anim.Image, location - .5f * anim.Image.size, "shadow", 0);
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, owner.Palette, 2);
|
||||
yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size, owner.Palette, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Parachute : IEffect
|
||||
{
|
||||
readonly Animation anim;
|
||||
readonly Animation paraAnim;
|
||||
readonly float2 location;
|
||||
|
||||
readonly Actor cargo;
|
||||
readonly Player owner;
|
||||
|
||||
float altitude;
|
||||
const float fallRate = .3f;
|
||||
|
||||
public Parachute(Player owner, string image, float2 location, int altitude, Actor cargo)
|
||||
{
|
||||
this.location = location;
|
||||
this.altitude = altitude;
|
||||
this.cargo = cargo;
|
||||
this.owner = owner;
|
||||
|
||||
anim = new Animation(image);
|
||||
if (anim.HasSequence("idle"))
|
||||
anim.PlayFetchIndex("idle", () => 0);
|
||||
else
|
||||
anim.PlayFetchIndex("stand", () => 0);
|
||||
anim.Tick();
|
||||
|
||||
paraAnim = new Animation("parach");
|
||||
paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
paraAnim.Tick();
|
||||
|
||||
altitude -= fallRate;
|
||||
|
||||
if (altitude <= 0)
|
||||
world.AddFrameEndTask(w =>
|
||||
{
|
||||
w.Remove(this);
|
||||
var loc = Traits.Util.CellContaining(location);
|
||||
cargo.CancelActivity();
|
||||
cargo.Trait<ITeleportable>().SetPosition(cargo, loc);
|
||||
w.Add(cargo);
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
var pos = location - new float2(0, altitude);
|
||||
yield return new Renderable(anim.Image, location - .5f * anim.Image.size, "shadow", 0);
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, owner.Palette, 2);
|
||||
yield return new Renderable(paraAnim.Image, pos - .5f * paraAnim.Image.size, owner.Palette, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class RallyPoint : IEffect
|
||||
{
|
||||
Actor building;
|
||||
RA.RallyPoint rp;
|
||||
public Animation flag = new Animation("rallypoint");
|
||||
public Animation circles = new Animation("rallypoint");
|
||||
|
||||
public RallyPoint(Actor building)
|
||||
{
|
||||
this.building = building;
|
||||
rp = building.Trait<RA.RallyPoint>();
|
||||
flag.PlayRepeating("flag");
|
||||
circles.Play("circles");
|
||||
}
|
||||
|
||||
int2 cachedLocation;
|
||||
public void Tick( World world )
|
||||
{
|
||||
flag.Tick();
|
||||
circles.Tick();
|
||||
if (cachedLocation != rp.rallyPoint)
|
||||
{
|
||||
cachedLocation = rp.rallyPoint;
|
||||
circles.Play("circles");
|
||||
}
|
||||
|
||||
if (!building.IsInWorld || building.IsDead())
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (building.IsInWorld && building.Owner == building.World.LocalPlayer && building.World.Selection.Actors.Contains(building))
|
||||
{
|
||||
var pos = Traits.Util.CenterOfCell(rp.rallyPoint);
|
||||
yield return new Renderable(circles.Image,
|
||||
pos - .5f * circles.Image.size,
|
||||
building.Owner.Palette, (int)pos.Y);
|
||||
|
||||
yield return new Renderable(flag.Image,
|
||||
pos + new float2(-1,-17),
|
||||
building.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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 System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class RallyPoint : IEffect
|
||||
{
|
||||
Actor building;
|
||||
RA.RallyPoint rp;
|
||||
public Animation flag = new Animation("rallypoint");
|
||||
public Animation circles = new Animation("rallypoint");
|
||||
|
||||
public RallyPoint(Actor building)
|
||||
{
|
||||
this.building = building;
|
||||
rp = building.Trait<RA.RallyPoint>();
|
||||
flag.PlayRepeating("flag");
|
||||
circles.Play("circles");
|
||||
}
|
||||
|
||||
int2 cachedLocation;
|
||||
public void Tick( World world )
|
||||
{
|
||||
flag.Tick();
|
||||
circles.Tick();
|
||||
if (cachedLocation != rp.rallyPoint)
|
||||
{
|
||||
cachedLocation = rp.rallyPoint;
|
||||
circles.Play("circles");
|
||||
}
|
||||
|
||||
if (!building.IsInWorld || building.IsDead())
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (building.IsInWorld && building.Owner == building.World.LocalPlayer && building.World.Selection.Actors.Contains(building))
|
||||
{
|
||||
var pos = Traits.Util.CenterOfCell(rp.rallyPoint);
|
||||
yield return new Renderable(circles.Image,
|
||||
pos - .5f * circles.Image.size,
|
||||
building.Owner.Palette, (int)pos.Y);
|
||||
|
||||
yield return new Renderable(flag.Image,
|
||||
pos + new float2(-1,-17),
|
||||
building.Owner.Palette, (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class RepairIndicator : IEffect
|
||||
{
|
||||
int framesLeft;
|
||||
Actor a;
|
||||
Animation anim = new Animation("select");
|
||||
|
||||
public RepairIndicator(Actor a)
|
||||
{
|
||||
this.a = a; anim.PlayRepeating("repair");
|
||||
framesLeft = (int)(a.Info.Traits.Get<RepairableBuildingInfo>().RepairRate * 25 * 60 / 2);
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if (--framesLeft == 0 || !a.IsInWorld || a.IsDead())
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (a.IsInWorld)
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size, "chrome", (int)a.CenterLocation.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class RepairIndicator : IEffect
|
||||
{
|
||||
int framesLeft;
|
||||
Actor a;
|
||||
Animation anim = new Animation("select");
|
||||
|
||||
public RepairIndicator(Actor a)
|
||||
{
|
||||
this.a = a; anim.PlayRepeating("repair");
|
||||
framesLeft = (int)(a.Info.Traits.Get<RepairableBuildingInfo>().RepairRate * 25 * 60 / 2);
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if (--framesLeft == 0 || !a.IsInWorld || a.IsDead())
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (a.IsInWorld)
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size, "chrome", (int)a.CenterLocation.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class SatelliteLaunch : IEffect
|
||||
{
|
||||
int frame = 0;
|
||||
Actor a;
|
||||
Animation doors = new Animation("atek");
|
||||
float2 doorOffset = new float2(-4,0);
|
||||
|
||||
public SatelliteLaunch(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
doors.PlayThen("active",
|
||||
() => a.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
doors.Tick();
|
||||
|
||||
if (++frame == 19)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(new GpsSatellite(a.CenterLocation - .5f * doors.Image.size + doorOffset)));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(doors.Image,
|
||||
a.CenterLocation - .5f * doors.Image.size + doorOffset, "effect", (int)doorOffset.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class SatelliteLaunch : IEffect
|
||||
{
|
||||
int frame = 0;
|
||||
Actor a;
|
||||
Animation doors = new Animation("atek");
|
||||
float2 doorOffset = new float2(-4,0);
|
||||
|
||||
public SatelliteLaunch(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
doors.PlayThen("active",
|
||||
() => a.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
doors.Tick();
|
||||
|
||||
if (++frame == 19)
|
||||
{
|
||||
world.AddFrameEndTask(w => w.Add(new GpsSatellite(a.CenterLocation - .5f * doors.Image.size + doorOffset)));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(doors.Image,
|
||||
a.CenterLocation - .5f * doors.Image.size + doorOffset, "effect", (int)doorOffset.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Smoke : IEffect
|
||||
{
|
||||
readonly int2 pos;
|
||||
readonly Animation anim;
|
||||
|
||||
public Smoke(World world, int2 pos, string trail)
|
||||
{
|
||||
this.pos = pos;
|
||||
anim = new Animation(trail);
|
||||
anim.PlayThen("idle",
|
||||
() => world.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "effect", (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
public class Smoke : IEffect
|
||||
{
|
||||
readonly int2 pos;
|
||||
readonly Animation anim;
|
||||
|
||||
public Smoke(World world, int2 pos, string trail)
|
||||
{
|
||||
this.pos = pos;
|
||||
anim = new Animation(trail);
|
||||
anim.PlayThen("idle",
|
||||
() => world.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "effect", (int)pos.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,127 +1,127 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class TeslaZapInfo : IProjectileInfo
|
||||
{
|
||||
public IEffect Create(ProjectileArgs args) { return new TeslaZap( this, args ); }
|
||||
}
|
||||
|
||||
class TeslaZap : IEffect
|
||||
{
|
||||
readonly ProjectileArgs Args;
|
||||
int timeUntilRemove = 2; // # of frames
|
||||
bool doneDamage = false;
|
||||
|
||||
const int numZaps = 3;
|
||||
|
||||
readonly List<Renderable> renderables = new List<Renderable>();
|
||||
|
||||
public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
|
||||
{
|
||||
Args = args;
|
||||
var bright = SequenceProvider.GetSequence("litning", "bright");
|
||||
var dim = SequenceProvider.GetSequence("litning", "dim");
|
||||
|
||||
for (var n = 0; n < numZaps; n++)
|
||||
renderables.AddRange(DrawZapWandering(args.src, args.dest, n == numZaps - 1 ? bright : dim));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if( timeUntilRemove <= 0 )
|
||||
world.AddFrameEndTask( w => w.Remove( this ) );
|
||||
--timeUntilRemove;
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (Args.target.IsValid)
|
||||
Args.dest = Args.target.CenterLocation;
|
||||
|
||||
Combat.DoImpacts(Args);
|
||||
doneDamage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render() { return renderables; }
|
||||
|
||||
static IEnumerable<Renderable> DrawZapWandering(int2 from, int2 to, Sequence s)
|
||||
{
|
||||
var z = float2.Zero; /* hack */
|
||||
var dist = to - from;
|
||||
var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);
|
||||
|
||||
var renderables = new List<Renderable>();
|
||||
if (Game.CosmeticRandom.Next(2) != 0)
|
||||
{
|
||||
var p1 = from + (1 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
var p2 = from + (2 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
|
||||
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||
renderables.AddRange(DrawZap(p1, p2, s, out p2));
|
||||
renderables.AddRange(DrawZap(p2, to, s, out z));
|
||||
}
|
||||
else
|
||||
{
|
||||
var p1 = from + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
|
||||
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||
renderables.AddRange(DrawZap(p1, to, s, out z));
|
||||
}
|
||||
|
||||
return renderables;
|
||||
}
|
||||
|
||||
static IEnumerable<Renderable> DrawZap(float2 from, float2 to, Sequence s, out float2 p)
|
||||
{
|
||||
var dist = to - from;
|
||||
var q = new float2(-dist.Y, dist.X);
|
||||
var c = -float2.Dot(from, q);
|
||||
var rs = new List<Renderable>();
|
||||
var z = from;
|
||||
|
||||
while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
|
||||
{
|
||||
var step = steps.Where(t => (to - (z + new float2(t[0],t[1]))).LengthSquared < (to - z).LengthSquared )
|
||||
.OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First();
|
||||
|
||||
rs.Add(new Renderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]), "effect", (int)from.Y));
|
||||
z += new float2(step[0], step[1]);
|
||||
if( rs.Count >= 1000 )
|
||||
break;
|
||||
}
|
||||
|
||||
p = z;
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
static int[][] steps = new []
|
||||
{
|
||||
new int[] { 8, 8, -8, -8, 0 },
|
||||
new int[] { -8, -8, -16, -16, 0 },
|
||||
new int[] { 8, 0, -8, -8, 1 },
|
||||
new int[] { -8, 0, -16, -8, 1 },
|
||||
new int[] { 0, 8, -8, -8, 2 },
|
||||
new int[] { 0, -8, -8, -16, 2 },
|
||||
new int[] { -8, 8, -16, -8, 3 },
|
||||
new int[] { 8, -8, -8, -16, 3 }
|
||||
};
|
||||
}
|
||||
}
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
class TeslaZapInfo : IProjectileInfo
|
||||
{
|
||||
public IEffect Create(ProjectileArgs args) { return new TeslaZap( this, args ); }
|
||||
}
|
||||
|
||||
class TeslaZap : IEffect
|
||||
{
|
||||
readonly ProjectileArgs Args;
|
||||
int timeUntilRemove = 2; // # of frames
|
||||
bool doneDamage = false;
|
||||
|
||||
const int numZaps = 3;
|
||||
|
||||
readonly List<Renderable> renderables = new List<Renderable>();
|
||||
|
||||
public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
|
||||
{
|
||||
Args = args;
|
||||
var bright = SequenceProvider.GetSequence("litning", "bright");
|
||||
var dim = SequenceProvider.GetSequence("litning", "dim");
|
||||
|
||||
for (var n = 0; n < numZaps; n++)
|
||||
renderables.AddRange(DrawZapWandering(args.src, args.dest, n == numZaps - 1 ? bright : dim));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if( timeUntilRemove <= 0 )
|
||||
world.AddFrameEndTask( w => w.Remove( this ) );
|
||||
--timeUntilRemove;
|
||||
|
||||
if (!doneDamage)
|
||||
{
|
||||
if (Args.target.IsValid)
|
||||
Args.dest = Args.target.CenterLocation;
|
||||
|
||||
Combat.DoImpacts(Args);
|
||||
doneDamage = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render() { return renderables; }
|
||||
|
||||
static IEnumerable<Renderable> DrawZapWandering(int2 from, int2 to, Sequence s)
|
||||
{
|
||||
var z = float2.Zero; /* hack */
|
||||
var dist = to - from;
|
||||
var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);
|
||||
|
||||
var renderables = new List<Renderable>();
|
||||
if (Game.CosmeticRandom.Next(2) != 0)
|
||||
{
|
||||
var p1 = from + (1 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
var p2 = from + (2 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
|
||||
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||
renderables.AddRange(DrawZap(p1, p2, s, out p2));
|
||||
renderables.AddRange(DrawZap(p2, to, s, out z));
|
||||
}
|
||||
else
|
||||
{
|
||||
var p1 = from + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||
|
||||
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||
renderables.AddRange(DrawZap(p1, to, s, out z));
|
||||
}
|
||||
|
||||
return renderables;
|
||||
}
|
||||
|
||||
static IEnumerable<Renderable> DrawZap(float2 from, float2 to, Sequence s, out float2 p)
|
||||
{
|
||||
var dist = to - from;
|
||||
var q = new float2(-dist.Y, dist.X);
|
||||
var c = -float2.Dot(from, q);
|
||||
var rs = new List<Renderable>();
|
||||
var z = from;
|
||||
|
||||
while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
|
||||
{
|
||||
var step = steps.Where(t => (to - (z + new float2(t[0],t[1]))).LengthSquared < (to - z).LengthSquared )
|
||||
.OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First();
|
||||
|
||||
rs.Add(new Renderable(s.GetSprite(step[4]), z + new float2(step[2], step[3]), "effect", (int)from.Y));
|
||||
z += new float2(step[0], step[1]);
|
||||
if( rs.Count >= 1000 )
|
||||
break;
|
||||
}
|
||||
|
||||
p = z;
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
static int[][] steps = new []
|
||||
{
|
||||
new int[] { 8, 8, -8, -8, 0 },
|
||||
new int[] { -8, -8, -16, -16, 0 },
|
||||
new int[] { 8, 0, -8, -8, 1 },
|
||||
new int[] { -8, 0, -16, -8, 1 },
|
||||
new int[] { 0, 8, -8, -8, 2 },
|
||||
new int[] { 0, -8, -8, -16, 2 },
|
||||
new int[] { -8, 8, -16, -8, 3 },
|
||||
new int[] { 8, -8, -8, -16, 3 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user