the rest of yesterday's render changes.
This commit is contained in:
@@ -44,7 +44,6 @@ namespace OpenRa.Game.GameRules
|
||||
public readonly int[] PrimaryOffset = { 0, 0 };
|
||||
public readonly int[] SecondaryOffset = null;
|
||||
public readonly int Recoil = 0;
|
||||
public readonly string SecondaryAnim = null;
|
||||
public readonly bool MuzzleFlash = false;
|
||||
public readonly int SelectionPriority = 10;
|
||||
public readonly int InitialFacing = 128;
|
||||
|
||||
@@ -51,12 +51,6 @@ namespace OpenRa.Game.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
{
|
||||
var pal = self.Owner == null ? 0 : self.Owner.Palette;
|
||||
yield return Tuple.New(anim.Image, 24f * (float2)self.Location, pal);
|
||||
}
|
||||
|
||||
public virtual void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (!e.DamageStateChanged)
|
||||
|
||||
@@ -7,40 +7,21 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderUnitMuzzleFlash : RenderUnit
|
||||
{
|
||||
Animation muzzleFlash;
|
||||
|
||||
public RenderUnitMuzzleFlash(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
if (!self.Info.MuzzleFlash) throw new InvalidOperationException("wtf??");
|
||||
|
||||
muzzleFlash = new Animation(self.Info.Name);
|
||||
muzzleFlash.PlayFetchIndex("muzzle",
|
||||
() =>
|
||||
{
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
var unit = self.traits.Get<Unit>();
|
||||
return (Util.QuantizeFacing(
|
||||
unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f);
|
||||
});
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
muzzleFlash.Tick();
|
||||
}
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
if (attack.primaryRecoil > 0)
|
||||
return base.Render(self).Concat(new[] {Util.Centered(self,
|
||||
muzzleFlash.Image, self.CenterLocation + new float2(
|
||||
self.Info.PrimaryOffset.ElementAtOrDefault(2),
|
||||
self.Info.PrimaryOffset.ElementAtOrDefault(3)))});
|
||||
else
|
||||
return base.Render(self);
|
||||
|
||||
var muzzleFlash = new Animation(self.Info.Name);
|
||||
muzzleFlash.PlayFetchIndex("muzzle",
|
||||
() => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
|
||||
anims.Add( "muzzle", new AnimationWithOffset(
|
||||
muzzleFlash,
|
||||
() => new float2( self.Info.PrimaryOffset.ElementAtOrDefault( 2 ), self.Info.PrimaryOffset.ElementAtOrDefault( 3 ) ),
|
||||
() => attack.primaryRecoil <= 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,35 +9,29 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public RenderUnitRotor( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
rotorAnim = new Animation(self.Info.Name);
|
||||
rotorAnim.PlayRepeating("rotor");
|
||||
|
||||
if (self.Info.SecondaryAnim != null)
|
||||
{
|
||||
secondRotorAnim = new Animation(self.Info.Name);
|
||||
secondRotorAnim.PlayRepeating(self.Info.SecondaryAnim);
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
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, self.CenterLocation
|
||||
+ Util.GetTurretPosition( self, unit, self.Info.SecondaryOffset, 0 ) );
|
||||
rotorAnim = new Animation(self.Info.Name);
|
||||
rotorAnim.PlayRepeating("rotor");
|
||||
anims.Add( "rotor_1", new AnimationWithOffset(
|
||||
rotorAnim,
|
||||
() => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ),
|
||||
null ) );
|
||||
|
||||
if( self.Info.SecondaryOffset == null ) return;
|
||||
|
||||
secondRotorAnim = new Animation( self.Info.Name );
|
||||
secondRotorAnim.PlayRepeating( "rotor2" );
|
||||
anims.Add( "rotor_2", new AnimationWithOffset(
|
||||
secondRotorAnim,
|
||||
() => Util.GetTurretPosition( self, unit, self.Info.SecondaryOffset, 0 ),
|
||||
null ) );
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
rotorAnim.Tick();
|
||||
if (secondRotorAnim != null)
|
||||
secondRotorAnim.Tick();
|
||||
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
|
||||
@@ -9,24 +9,15 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public RenderUnitSpinner( Actor self )
|
||||
: base(self)
|
||||
{
|
||||
spinnerAnim = new Animation( self.Info.Name );
|
||||
spinnerAnim.PlayRepeating( "spinner" );
|
||||
}
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
yield return Util.Centered(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.Centered( self, spinnerAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, 0));
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
spinnerAnim.Tick();
|
||||
spinnerAnim = new Animation( self.Info.Name );
|
||||
spinnerAnim.PlayRepeating( "spinner" );
|
||||
anims.Add( "spinner", new AnimationWithOffset(
|
||||
spinnerAnim,
|
||||
() => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, 0 ),
|
||||
null ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +116,9 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public static Tuple<Sprite, float2, int> Centered(Actor self, Sprite s, float2 location)
|
||||
{
|
||||
var pal = self.Owner == null ? 0 : self.Owner.Palette;
|
||||
var loc = location - 0.5f * s.size;
|
||||
return Tuple.New(s, loc.Round(), self.Owner.Palette);
|
||||
return Tuple.New(s, loc.Round(), pal);
|
||||
}
|
||||
|
||||
public static Tuple<Sprite, float2, int> CenteredShadow(Actor self, Sprite s, float2 location)
|
||||
|
||||
Reference in New Issue
Block a user