facings for the rest of mods/ra.

This commit is contained in:
Bob
2010-02-11 13:27:10 +13:00
parent 31f4e23081
commit bb18e426cd
8 changed files with 61 additions and 59 deletions

View File

@@ -5,15 +5,20 @@ namespace OpenRa.Traits
{
public class RenderBuildingInfo : RenderSimpleInfo
{
public override object Create(Actor self) { return new RenderBuilding(self); }
public override object Create(Actor self) { return new RenderBuilding(self);}
}
public class RenderBuilding : RenderSimple, INotifyDamage, INotifySold
{
static readonly int[] bibStarts = { 0, 0, 1, 5, 11 };
public RenderBuilding(Actor self)
: base(self)
public RenderBuilding( Actor self )
: this( self, () => 0 )
{
}
public RenderBuilding(Actor self, Func<int> baseFacing)
: base(self, baseFacing)
{
if( Game.skipMakeAnims )
Complete( self );

View File

@@ -9,7 +9,7 @@ namespace OpenRa.Traits
class RenderBuildingTurreted : RenderBuilding, INotifyBuildComplete
{
public RenderBuildingTurreted(Actor self)
: base(self)
: base(self, () => self.traits.Get<Turreted>().turretFacing)
{
}

View File

@@ -11,9 +11,8 @@ namespace OpenRa.Traits
public class RenderInfantry : RenderSimple, INotifyAttack, INotifyDamage
{
public RenderInfantry(Actor self)
: base(self)
: base(self, () => self.traits.Get<Unit>().Facing)
{
anim = new Animation( GetImage( self ), () => self.traits.Get<Unit>().Facing );
anim.PlayFacing("stand",
() => self.traits.Get<Unit>().Facing);
}

View File

@@ -21,9 +21,9 @@ namespace OpenRa.Traits
return self.Info.Traits.Get<RenderSimpleInfo>().Image ?? self.Info.Name;
}
public RenderSimple(Actor self)
public RenderSimple(Actor self, Func<int> baseFacing)
{
anims.Add( "", new Animation( GetImage(self) ) );
anims.Add( "", new Animation( GetImage(self), baseFacing ) );
}
public virtual IEnumerable<Renderable> Render( Actor self )

View File

@@ -13,9 +13,8 @@ namespace OpenRa.Traits
class RenderUnit : RenderSimple, INotifyDamage
{
public RenderUnit(Actor self)
: base(self)
: base(self, () => self.traits.Get<Unit>().Facing)
{
anim = new Animation( GetImage( self ), () => self.traits.Get<Unit>().Facing );
PlayFacingAnim(self);
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );

View File

@@ -19,9 +19,9 @@ namespace OpenRa.Traits
var attack = self.traits.Get<AttackBase>();
var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();
var muzzleFlash = new Animation(GetImage(self));
var muzzleFlash = new Animation(GetImage(self), ()=>unit.Facing);
muzzleFlash.PlayFetchIndex("muzzle",
() => (Util.QuantizeFacing(unit.Facing, 8)) * 6 + (int)(attack.primaryRecoil * 5.9f));
() => (int)(attack.primaryRecoil * 5.9f));
anims.Add( "muzzle", new AnimationWithOffset(
muzzleFlash,
() => attackInfo.PrimaryOffset.AbsOffset(),

View File

@@ -19,7 +19,7 @@ namespace OpenRa.Traits
var attack = self.traits.GetOrDefault<AttackBase>();
var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();
var turretAnim = new Animation(GetImage(self));
var turretAnim = new Animation(GetImage(self), () => turreted.turretFacing );
turretAnim.PlayFacing( "turret", () => turreted.turretFacing );
if( attackInfo.PrimaryOffset != null )
@@ -36,10 +36,9 @@ namespace OpenRa.Traits
if( attackInfo.MuzzleFlash )
{
var muzzleFlash = new Animation( GetImage(self) );
var muzzleFlash = new Animation( GetImage(self), () => self.traits.Get<Turreted>().turretFacing );
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 */
() => (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, attackInfo.PrimaryOffset, attack.primaryRecoil),