unhardcode and reference tesla zap sprite sequences
This commit is contained in:
@@ -20,9 +20,15 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
class TeslaZapInfo : IProjectileInfo
|
class TeslaZapInfo : IProjectileInfo
|
||||||
{
|
{
|
||||||
public readonly string Image = "litning";
|
public readonly string Image = "litning";
|
||||||
|
|
||||||
|
[SequenceReference("Image")] public readonly string BrightSequence = "bright";
|
||||||
|
[SequenceReference("Image")] public readonly string DimSequence = "dim";
|
||||||
|
|
||||||
public readonly string Palette = "effect";
|
public readonly string Palette = "effect";
|
||||||
|
|
||||||
public readonly int BrightZaps = 1;
|
public readonly int BrightZaps = 1;
|
||||||
public readonly int DimZaps = 2;
|
public readonly int DimZaps = 2;
|
||||||
|
|
||||||
public IEffect Create(ProjectileArgs args) { return new TeslaZap(this, args); }
|
public IEffect Create(ProjectileArgs args) { return new TeslaZap(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +65,8 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
var pos = args.GuidedTarget.IsValidFor(args.SourceActor) ? args.GuidedTarget.CenterPosition : args.PassiveTarget;
|
var pos = args.GuidedTarget.IsValidFor(args.SourceActor) ? args.GuidedTarget.CenterPosition : args.PassiveTarget;
|
||||||
zap = new TeslaZapRenderable(args.Source, 0, pos - args.Source, info.Image, info.BrightZaps, info.DimZaps, info.Palette);
|
zap = new TeslaZapRenderable(args.Source, 0, pos - args.Source,
|
||||||
|
info.Image, info.BrightSequence, info.BrightZaps, info.DimSequence, info.DimZaps, info.Palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return zap;
|
yield return zap;
|
||||||
|
|||||||
@@ -35,13 +35,15 @@ namespace OpenRA.Mods.RA.Graphics
|
|||||||
readonly WVec length;
|
readonly WVec length;
|
||||||
readonly string image;
|
readonly string image;
|
||||||
readonly string palette;
|
readonly string palette;
|
||||||
|
readonly string dimSequence;
|
||||||
|
readonly string brightSequence;
|
||||||
readonly int brightZaps, dimZaps;
|
readonly int brightZaps, dimZaps;
|
||||||
|
|
||||||
WPos cachedPos;
|
WPos cachedPos;
|
||||||
WVec cachedLength;
|
WVec cachedLength;
|
||||||
IEnumerable<IFinalizedRenderable> cache;
|
IEnumerable<IFinalizedRenderable> cache;
|
||||||
|
|
||||||
public TeslaZapRenderable(WPos pos, int zOffset, WVec length, string image, int brightZaps, int dimZaps, string palette)
|
public TeslaZapRenderable(WPos pos, int zOffset, WVec length, string image, string brightSequence, int brightZaps, string dimSequence, int dimZaps, string palette)
|
||||||
{
|
{
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.zOffset = zOffset;
|
this.zOffset = zOffset;
|
||||||
@@ -50,6 +52,8 @@ namespace OpenRA.Mods.RA.Graphics
|
|||||||
this.palette = palette;
|
this.palette = palette;
|
||||||
this.brightZaps = brightZaps;
|
this.brightZaps = brightZaps;
|
||||||
this.dimZaps = dimZaps;
|
this.dimZaps = dimZaps;
|
||||||
|
this.dimSequence = dimSequence;
|
||||||
|
this.brightSequence = brightSequence;
|
||||||
|
|
||||||
cachedPos = WPos.Zero;
|
cachedPos = WPos.Zero;
|
||||||
cachedLength = WVec.Zero;
|
cachedLength = WVec.Zero;
|
||||||
@@ -61,17 +65,20 @@ namespace OpenRA.Mods.RA.Graphics
|
|||||||
public int ZOffset { get { return zOffset; } }
|
public int ZOffset { get { return zOffset; } }
|
||||||
public bool IsDecoration { get { return true; } }
|
public bool IsDecoration { get { return true; } }
|
||||||
|
|
||||||
public IRenderable WithPalette(PaletteReference newPalette) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); }
|
public IRenderable WithPalette(PaletteReference newPalette)
|
||||||
public IRenderable WithZOffset(int newOffset) { return new TeslaZapRenderable(pos, zOffset, length, image, brightZaps, dimZaps, palette); }
|
{
|
||||||
public IRenderable OffsetBy(WVec vec) { return new TeslaZapRenderable(pos + vec, zOffset, length, image, brightZaps, dimZaps, palette); }
|
return new TeslaZapRenderable(pos, zOffset, length, image, brightSequence, brightZaps, dimSequence, dimZaps, palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRenderable WithZOffset(int newOffset) { return new TeslaZapRenderable(pos, zOffset, length, image, brightSequence, brightZaps, dimSequence, dimZaps, palette); }
|
||||||
|
public IRenderable OffsetBy(WVec vec) { return new TeslaZapRenderable(pos + vec, zOffset, length, image, brightSequence, brightZaps, dimSequence, dimZaps, palette); }
|
||||||
public IRenderable AsDecoration() { return this; }
|
public IRenderable AsDecoration() { return this; }
|
||||||
|
|
||||||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; }
|
||||||
public void RenderDebugGeometry(WorldRenderer wr) { }
|
public void RenderDebugGeometry(WorldRenderer wr) { }
|
||||||
public void Render(WorldRenderer wr)
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (wr.World.FogObscures(pos) &&
|
if (wr.World.FogObscures(pos) && wr.World.FogObscures(pos + length))
|
||||||
wr.World.FogObscures(pos + length))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!cache.Any() || length != cachedLength || pos != cachedPos)
|
if (!cache.Any() || length != cachedLength || pos != cachedPos)
|
||||||
@@ -84,8 +91,8 @@ namespace OpenRA.Mods.RA.Graphics
|
|||||||
|
|
||||||
public IEnumerable<IFinalizedRenderable> GenerateRenderables(WorldRenderer wr)
|
public IEnumerable<IFinalizedRenderable> GenerateRenderables(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var bright = wr.World.Map.SequenceProvider.GetSequence(image, "bright");
|
var bright = wr.World.Map.SequenceProvider.GetSequence(image, brightSequence);
|
||||||
var dim = wr.World.Map.SequenceProvider.GetSequence(image, "dim");
|
var dim = wr.World.Map.SequenceProvider.GetSequence(image, dimSequence);
|
||||||
|
|
||||||
var source = wr.ScreenPosition(pos);
|
var source = wr.ScreenPosition(pos);
|
||||||
var target = wr.ScreenPosition(pos + length);
|
var target = wr.ScreenPosition(pos + length);
|
||||||
|
|||||||
Reference in New Issue
Block a user