factored out flying unit render into WithShadow:IRenderModifier
This commit is contained in:
@@ -173,9 +173,6 @@ namespace OpenRa.Game.Traits.Activities
|
||||
w2 = c2 + f;
|
||||
w3 = approachStart;
|
||||
landPoint = landPos;
|
||||
|
||||
var rup = self.traits.Get<RenderUnitPlane>();
|
||||
rup.wps = new[] { self.CenterLocation, w1, w2, w3, landPoint, c1, c2 };
|
||||
}
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderUnitPlane : RenderUnit
|
||||
{
|
||||
Animation debug = new Animation("litning");
|
||||
public float2[] wps;
|
||||
|
||||
public RenderUnitPlane(Actor self)
|
||||
: base(self) { debug.PlayRepeating("bright"); debug.Tick(); }
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
yield return Util.CenteredShadow(self, anim.Image, self.CenterLocation);
|
||||
var p = self.CenterLocation - new float2(0, unit.Altitude);
|
||||
yield return Util.Centered(self, anim.Image, p);
|
||||
|
||||
if (wps != null)
|
||||
foreach (var w in wps)
|
||||
yield return Tuple.New(debug.Image, w - .5f * debug.Image.size, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,20 +24,11 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
yield return Util.CenteredShadow(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.CenteredShadow(self, rotorAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, 0));
|
||||
if (self.Info.SecondaryOffset != null)
|
||||
yield return Util.CenteredShadow(self, (secondRotorAnim ?? rotorAnim).Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, 0));
|
||||
|
||||
var p = self.CenterLocation - new float2( 0, unit.Altitude );
|
||||
|
||||
yield return Util.Centered(self, anim.Image, p);
|
||||
yield return Util.Centered(self, rotorAnim.Image, p
|
||||
yield return Util.Centered(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.Centered(self, rotorAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ) );
|
||||
if (self.Info.SecondaryOffset != null)
|
||||
yield return Util.Centered(self, (secondRotorAnim ?? rotorAnim).Image, p
|
||||
yield return Util.Centered(self, (secondRotorAnim ?? rotorAnim).Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition( self, unit, self.Info.SecondaryOffset, 0 ) );
|
||||
}
|
||||
|
||||
@@ -55,9 +46,9 @@ namespace OpenRa.Game.Traits
|
||||
if (isFlying ^ (rotorAnim.CurrentSequence.Name != "rotor"))
|
||||
return;
|
||||
|
||||
rotorAnim.PlayRepeatingPreservingPosition(isFlying ? "rotor" : "slow-rotor");
|
||||
rotorAnim.ReplaceAnim(isFlying ? "rotor" : "slow-rotor");
|
||||
if (secondRotorAnim != null)
|
||||
secondRotorAnim.PlayRepeatingPreservingPosition(isFlying ? "rotor2" : "slow-rotor2");
|
||||
secondRotorAnim.ReplaceAnim(isFlying ? "rotor2" : "slow-rotor2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
OpenRa.Game/Traits/WithShadow.cs
Normal file
21
OpenRa.Game/Traits/WithShadow.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class WithShadow : IRenderModifier
|
||||
{
|
||||
public WithShadow(Actor self) {}
|
||||
|
||||
public IEnumerable<Tuple<Sprite, float2, int>> ModifyRender(Actor self, IEnumerable<Tuple<Sprite, float2, int>> r)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var shadowSprites = r.Select( a => Tuple.New( a.a, a.b, 8 ));
|
||||
var flyingSprites = r.Select( a => Tuple.New( a.a, a.b - new float2( 0, unit.Altitude ), a.c ));
|
||||
return shadowSprites.Concat(flyingSprites);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user