RenderUnitTurreted ported
This commit is contained in:
@@ -17,31 +17,32 @@ namespace OpenRa.Game.Traits
|
||||
var unit = self.traits.Get<Unit>();
|
||||
var turreted = self.traits.Get<Turreted>();
|
||||
var attack = self.traits.WithInterface<AttackBase>().FirstOrDefault();
|
||||
var attackInfo = self.Info.Traits.WithInterface<AttackBaseInfo>().First();
|
||||
|
||||
var turretAnim = new Animation(self.LegacyInfo.Name);
|
||||
var turretAnim = new Animation(GetImage(self));
|
||||
turretAnim.PlayFacing( "turret", () => turreted.turretFacing );
|
||||
|
||||
if( self.LegacyInfo.PrimaryOffset != null )
|
||||
if( attackInfo.PrimaryOffset != null )
|
||||
anims.Add("turret_1", new AnimationWithOffset(
|
||||
turretAnim,
|
||||
() => Util.GetTurretPosition(self, unit, self.LegacyInfo.PrimaryOffset, attack.primaryRecoil),
|
||||
() => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
|
||||
null) { ZOffset = 1 });
|
||||
|
||||
if( self.LegacyInfo.SecondaryOffset != null )
|
||||
if (attackInfo.SecondaryOffset != null)
|
||||
anims.Add("turret_2", new AnimationWithOffset(
|
||||
turretAnim,
|
||||
() => Util.GetTurretPosition(self, unit, self.LegacyInfo.SecondaryOffset, attack.secondaryRecoil),
|
||||
() => Util.GetTurretPosition(self, unit, attackInfo.SecondaryOffset, attack.secondaryRecoil),
|
||||
null) { ZOffset = 1 });
|
||||
|
||||
if( self.LegacyInfo.MuzzleFlash )
|
||||
if( attackInfo.MuzzleFlash )
|
||||
{
|
||||
var muzzleFlash = new Animation( self.LegacyInfo.Name );
|
||||
var muzzleFlash = new Animation( GetImage(self) );
|
||||
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.LegacyInfo.PrimaryOffset, attack.primaryRecoil ),
|
||||
() => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
|
||||
() => attack.primaryRecoil <= 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user