Simplifying(?) some of the render stuff.
This commit is contained in:
@@ -6,51 +6,41 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
class RenderUnitTurreted : RenderUnit
|
||||
{
|
||||
public Animation turretAnim;
|
||||
public Animation muzzleFlash;
|
||||
|
||||
public RenderUnitTurreted(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
self.traits.Get<Turreted>();
|
||||
turretAnim = new Animation(self.Info.Name);
|
||||
|
||||
if (self.Info.MuzzleFlash)
|
||||
{
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
muzzleFlash = new Animation(self.Info.Name);
|
||||
muzzleFlash.PlayFetchIndex("muzzle",
|
||||
() => (Util.QuantizeFacing(self.traits.Get<Turreted>().turretFacing,8)) * 6
|
||||
+ (int)(attack.primaryRecoil * 5.9f));
|
||||
/* hack: recoil can be 1.0f, but don't overflow into next anim */
|
||||
}
|
||||
|
||||
turretAnim.PlayFacing("turret", () => self.traits.Get<Turreted>().turretFacing);
|
||||
}
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var turreted = self.traits.Get<Turreted>();
|
||||
var attack = self.traits.WithInterface<AttackBase>().FirstOrDefault();
|
||||
|
||||
yield return Util.Centered(self, anim.Image, self.CenterLocation);
|
||||
yield return Util.Centered(self, turretAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil));
|
||||
if (self.Info.SecondaryOffset != null)
|
||||
yield return Util.Centered(self, turretAnim.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil));
|
||||
var turretAnim = new Animation(self.Info.Name);
|
||||
turretAnim.PlayFacing( "turret", () => turreted.turretFacing );
|
||||
|
||||
if (muzzleFlash != null && attack.primaryRecoil > 0)
|
||||
yield return Util.Centered(self, muzzleFlash.Image, self.CenterLocation
|
||||
+ Util.GetTurretPosition(self, unit, self.Info.PrimaryOffset, attack.primaryRecoil));
|
||||
}
|
||||
if( self.Info.PrimaryOffset != null )
|
||||
anims.Add( "turret_1", new AnimationWithOffset(
|
||||
turretAnim,
|
||||
() => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, attack.primaryRecoil ),
|
||||
null ) );
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
turretAnim.Tick();
|
||||
if (muzzleFlash != null)
|
||||
muzzleFlash.Tick();
|
||||
if( self.Info.SecondaryOffset != null )
|
||||
anims.Add( "turret_2", new AnimationWithOffset(
|
||||
turretAnim,
|
||||
() => Util.GetTurretPosition( self, unit, self.Info.SecondaryOffset, attack.secondaryRecoil ),
|
||||
null ) );
|
||||
|
||||
if( self.Info.MuzzleFlash )
|
||||
{
|
||||
muzzleFlash = new Animation( self.Info.Name );
|
||||
muzzleFlash.PlayFetchIndex( "muzzle",
|
||||
() => ( Util.QuantizeFacing( self.traits.Get<Turreted>().turretFacing, 8 ) ) * 6
|
||||
+ (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */
|
||||
anims.Add( "muzzle_flash", new AnimationWithOffset(
|
||||
muzzleFlash,
|
||||
() => Util.GetTurretPosition( self, unit, self.Info.PrimaryOffset, attack.primaryRecoil ),
|
||||
() => attack.primaryRecoil <= 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user