Convert turret facings to WAngle relative to the body.
This commit is contained in:
@@ -76,19 +76,12 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
wsb.PlayCustomAnimationRepeating(self, info.ClosedIdleSequence);
|
||||
turret.DesiredFacing = null;
|
||||
turret.FaceTarget(self, Target.Invalid);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool CanAttack(Actor self, Target target)
|
||||
{
|
||||
if (state == PopupState.Transitioning)
|
||||
return false;
|
||||
|
||||
if (!base.CanAttack(self, target))
|
||||
return false;
|
||||
|
||||
idleTicks = 0;
|
||||
if (state == PopupState.Closed)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
@@ -97,9 +90,14 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
state = PopupState.Open;
|
||||
wsb.PlayCustomAnimationRepeating(self, wsb.Info.Sequence);
|
||||
});
|
||||
return false;
|
||||
|
||||
idleTicks = 0;
|
||||
}
|
||||
|
||||
if (state == PopupState.Transitioning || !base.CanAttack(self, target))
|
||||
return false;
|
||||
|
||||
idleTicks = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,17 +105,18 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
if (state == PopupState.Open && idleTicks++ > info.CloseDelay)
|
||||
{
|
||||
turret.DesiredFacing = info.DefaultFacing.Facing;
|
||||
var facingOffset = new WVec(0, -1024, 0).Rotate(WRot.FromYaw(info.DefaultFacing));
|
||||
turret.FaceTarget(self, Target.FromPos(self.CenterPosition + facingOffset));
|
||||
state = PopupState.Rotating;
|
||||
}
|
||||
else if (state == PopupState.Rotating && turret.TurretFacing == info.DefaultFacing.Facing)
|
||||
else if (state == PopupState.Rotating && turret.HasAchievedDesiredFacing)
|
||||
{
|
||||
state = PopupState.Transitioning;
|
||||
wsb.PlayCustomAnimation(self, info.ClosingSequence, () =>
|
||||
{
|
||||
state = PopupState.Closed;
|
||||
wsb.PlayCustomAnimationRepeating(self, info.ClosedIdleSequence);
|
||||
turret.DesiredFacing = null;
|
||||
turret.FaceTarget(self, Target.Invalid);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
var wsb = init.Actor.TraitInfos<WithSpriteBodyInfo>().FirstOrDefault();
|
||||
|
||||
// Show the correct turret facing
|
||||
var anim = new Animation(init.World, image, Turreted.TurretFacingFromInit(init, t));
|
||||
var anim = new Animation(init.World, image, t.WorldFacingFromInit(init));
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), wsb.Sequence));
|
||||
|
||||
yield return new SpriteActorPreview(anim, () => WVec.Zero, () => 0, p, rs.Scale);
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
{
|
||||
// Turret artwork is baked into the sprite, so only the first turret makes sense.
|
||||
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
return () => WAngle.FromFacing(turreted.TurretFacing);
|
||||
return () => turreted.WorldOrientation.Yaw;
|
||||
}
|
||||
|
||||
public WithEmbeddedTurretSpriteBody(ActorInitializer init, WithSpriteBodyInfo info)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
||||
{
|
||||
// Turret artwork is baked into the sprite, so only the first turret makes sense.
|
||||
var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||
return () => WAngle.FromFacing(turreted.TurretFacing);
|
||||
return () => turreted.WorldOrientation.Yaw;
|
||||
}
|
||||
|
||||
public WithGunboatBody(ActorInitializer init, WithGunboatBodyInfo info)
|
||||
|
||||
Reference in New Issue
Block a user