fix tesla hax with a different style of tesla hax
This commit is contained in:
@@ -23,6 +23,8 @@ using System.Linq;
|
|||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using System;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Effects
|
namespace OpenRA.Effects
|
||||||
{
|
{
|
||||||
@@ -68,6 +70,7 @@ namespace OpenRA.Effects
|
|||||||
|
|
||||||
static IEnumerable<Renderable> DrawZapWandering(int2 from, int2 to, Sequence s)
|
static IEnumerable<Renderable> DrawZapWandering(int2 from, int2 to, Sequence s)
|
||||||
{
|
{
|
||||||
|
var z = float2.Zero; /* hack */
|
||||||
var dist = to - from;
|
var dist = to - from;
|
||||||
var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);
|
var norm = (1f / dist.Length) * new float2(-dist.Y, dist.X);
|
||||||
|
|
||||||
@@ -77,76 +80,53 @@ namespace OpenRA.Effects
|
|||||||
var p1 = from + (1 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
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;
|
var p2 = from + (2 / 3f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||||
|
|
||||||
renderables.AddRange(DrawZap(from, p1.ToInt2(), s));
|
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||||
renderables.AddRange(DrawZap(p1.ToInt2(), p2.ToInt2(), s));
|
renderables.AddRange(DrawZap(p1, p2, s, out p2));
|
||||||
renderables.AddRange(DrawZap(p2.ToInt2(), to, s));
|
renderables.AddRange(DrawZap(p2, to, s, out z));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var p1 = from + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
var p1 = from + (1 / 2f) * dist.ToFloat2() + Game.CosmeticRandom.Gauss1D(1) * .2f * dist.Length * norm;
|
||||||
|
|
||||||
renderables.AddRange(DrawZap(from, p1.ToInt2(), s));
|
renderables.AddRange(DrawZap(from, p1, s, out p1));
|
||||||
renderables.AddRange(DrawZap(p1.ToInt2(), to, s));
|
renderables.AddRange(DrawZap(p1, to, s, out z));
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderables;
|
return renderables;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IEnumerable<Renderable> DrawZap(int2 from, int2 to, Sequence s)
|
static IEnumerable<Renderable> DrawZap(float2 from, float2 to, Sequence s, out float2 p)
|
||||||
{
|
{
|
||||||
if (from.X < to.X)
|
var dist = to - from;
|
||||||
return DrawZapInner(from, to, s);
|
var q = new float2(-dist.Y, dist.X);
|
||||||
else if (from.X > to.X || from.Y > to.Y)
|
var c = -float2.Dot(from, q);
|
||||||
return DrawZapInner(to, from, s);
|
var rs = new List<Renderable>();
|
||||||
else
|
var z = from;
|
||||||
return DrawZapInner(from, to, s);
|
|
||||||
|
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"));
|
||||||
|
z += new float2(step[0], step[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = z;
|
||||||
|
|
||||||
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IEnumerable<Renderable> DrawZapInner( int2 from, int2 to, Sequence s )
|
static int[][] steps = new []
|
||||||
{
|
{
|
||||||
int2 d = to - from;
|
new int[] { 8, 8, -8, -8, 0 },
|
||||||
if( d.X < 8 )
|
new int[] { -8, -8, -16, -16, 0 },
|
||||||
{
|
new int[] { 8, 0, -8, -8, 1 },
|
||||||
var prev = new int2( 0, 0 );
|
new int[] { -8, 0, -16, -8, 1 },
|
||||||
var y = d.Y;
|
new int[] { 0, 8, -8, -8, 2 },
|
||||||
while( y >= prev.Y + 8 )
|
new int[] { 0, -8, -8, -16, 2 },
|
||||||
{
|
new int[] { -8, 8, -16, -8, 3 },
|
||||||
yield return new Renderable( s.GetSprite( 2 ), (float2)( from + prev - new int2( 0, 8 ) ), "effect");
|
new int[] { 8, -8, -8, -16, 3 }
|
||||||
prev.Y += 8;
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var prev = new int2( 0, 0 );
|
|
||||||
for( int i = 1 ; i < d.X ; i += 8 )
|
|
||||||
{
|
|
||||||
var y = i * d.Y / d.X;
|
|
||||||
if( y <= prev.Y - 8 )
|
|
||||||
{
|
|
||||||
yield return new Renderable(s.GetSprite(3), (float2)(from + prev - new int2(8, 16)), "effect");
|
|
||||||
prev.Y -= 8;
|
|
||||||
while( y <= prev.Y - 8 )
|
|
||||||
{
|
|
||||||
yield return new Renderable(s.GetSprite(2), (float2)(from + prev - new int2(0, 16)), "effect");
|
|
||||||
prev.Y -= 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( y >= prev.Y + 8 )
|
|
||||||
{
|
|
||||||
yield return new Renderable(s.GetSprite(0), (float2)(from + prev - new int2(8, 8)), "effect");
|
|
||||||
prev.Y += 8;
|
|
||||||
while( y >= prev.Y + 8 )
|
|
||||||
{
|
|
||||||
yield return new Renderable(s.GetSprite(2), (float2)(from + prev - new int2(0, 8)), "effect");
|
|
||||||
prev.Y += 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
yield return new Renderable(s.GetSprite(1), (float2)(from + prev - new int2(8, 8)), "effect");
|
|
||||||
|
|
||||||
prev.X += 8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user