PlayFacing() ext
This commit is contained in:
@@ -55,7 +55,7 @@ namespace OpenRa.Game.Traits
|
||||
if (currentSequence == seq) return;
|
||||
|
||||
if (isFacing)
|
||||
anim.PlayFetchIndex(seq, () => Util.QuantizeFacing(facing, anim.CurrentSequence.Length));
|
||||
anim.PlayFacing(seq, () => facing );
|
||||
else
|
||||
anim.PlayRepeatingPreservingPosition(seq);
|
||||
|
||||
@@ -66,8 +66,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
name = type;
|
||||
anim = new Animation(type);
|
||||
anim.PlayFetchIndex("stand",
|
||||
() => Util.QuantizeFacing(facing, anim.CurrentSequence.Length));
|
||||
anim.PlayFacing("stand", () => facing);
|
||||
location = initialLocation;
|
||||
speed = ((InfantryInfo)Rules.UnitInfo[name]).Speed / 2;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
void PlayTurretAnim(Actor self, string a)
|
||||
{
|
||||
anim.PlayFetchIndex(a,
|
||||
() => self.traits.Get<Turreted>().turretFacing / 8);
|
||||
anim.PlayFacing(a, () => self.traits.Get<Turreted>().turretFacing);
|
||||
}
|
||||
|
||||
public override void Damaged(Actor self, DamageState ds)
|
||||
|
||||
@@ -16,11 +16,7 @@ namespace OpenRa.Game.Traits
|
||||
void PlayFacingAnim(Actor self)
|
||||
{
|
||||
var unit = self.traits.Get<Unit>();
|
||||
|
||||
anim.PlayFetchIndex("idle",
|
||||
() => Util.QuantizeFacing(
|
||||
unit.Facing,
|
||||
anim.CurrentSequence.Length ));
|
||||
anim.PlayFacing("idle", () => unit.Facing);
|
||||
}
|
||||
|
||||
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace OpenRa.Game.Traits
|
||||
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));
|
||||
() => (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.PlayFetchIndex("turret",
|
||||
() => self.traits.Get<Turreted>().turretFacing / 8);
|
||||
turretAnim.PlayFacing("turret", () => self.traits.Get<Turreted>().turretFacing);
|
||||
}
|
||||
|
||||
public override IEnumerable<Tuple<Sprite, float2, int>> Render(Actor self)
|
||||
|
||||
@@ -42,6 +42,13 @@ namespace OpenRa.Game.Traits
|
||||
return highest * 8;
|
||||
}
|
||||
|
||||
public static void PlayFacing(this Animation anim, string sequenceName, Func<int> facing)
|
||||
{
|
||||
anim.PlayFetchIndex(sequenceName,
|
||||
() => Traits.Util.QuantizeFacing(facing(),
|
||||
anim.CurrentSequence.Length));
|
||||
}
|
||||
|
||||
public static int GetNearestFacing( int facing, int desiredFacing )
|
||||
{
|
||||
var turn = desiredFacing - facing;
|
||||
|
||||
Reference in New Issue
Block a user