Separate IBodyOrientation from render traits.

This commit is contained in:
Paul Chote
2013-05-25 17:21:17 +12:00
parent 53aa698491
commit c149898592
16 changed files with 122 additions and 26 deletions

View File

@@ -57,6 +57,7 @@ namespace OpenRA.Mods.RA.Render
var self = init.self;
// Work around a bogus crash
anim.PlayRepeating( NormalizeSequence(self, "idle") );
self.Trait<IBodyOrientation>().QuantizedFacings = anim.CurrentSequence.Facings;
// Can't call Complete() directly from ctor because other traits haven't been inited yet
if (self.Info.Traits.Get<RenderBuildingInfo>().HasMakeAnimation && !init.Contains<SkipMakeAnimsInit>())

View File

@@ -61,6 +61,8 @@ namespace OpenRA.Mods.RA.Render
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);
State = AnimationState.Waiting;
mobile = self.Trait<Mobile>();
self.Trait<IBodyOrientation>().QuantizedFacings = anim.CurrentSequence.Facings;
}
public void Attacking(Actor self, Target target)

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
public class Turreted : ITick, ISync, IResolveOrder
{
[Sync] public int QuantizedFacings = -1;
[Sync] public int QuantizedFacings = 0;
[Sync] public int turretFacing = 0;
public int? desiredFacing;
TurretedInfo info;
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA
// Hack: turretFacing is relative to the world, so subtract the body yaw
var local = WRot.FromYaw(WAngle.FromFacing(turretFacing) - self.Orientation.Yaw);
if (QuantizedFacings == -1)
if (QuantizedFacings == 0)
return local;
// Quantize orientation to match a rendered sprite