Fix TD SAM Site facings being reset when damaged while closed.
This commit is contained in:
@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
[Desc("This actor has turret art with facings baked into the sprite.")]
|
[Desc("This actor has turret art with facings baked into the sprite.")]
|
||||||
public class WithEmbeddedTurretSpriteBodyInfo : WithSpriteBodyInfo, Requires<TurretedInfo>, Requires<BodyOrientationInfo>
|
public class WithEmbeddedTurretSpriteBodyInfo : WithSpriteBodyInfo, Requires<TurretedInfo>, Requires<BodyOrientationInfo>
|
||||||
{
|
{
|
||||||
|
[Desc("Number of facings for gameplay calculations. -1 indicates auto-detection from the sequence.")]
|
||||||
|
public readonly int QuantizedFacings = -1;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new WithEmbeddedTurretSpriteBody(init, this); }
|
public override object Create(ActorInitializer init) { return new WithEmbeddedTurretSpriteBody(init, this); }
|
||||||
|
|
||||||
public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||||
@@ -43,6 +46,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
|
|
||||||
public class WithEmbeddedTurretSpriteBody : WithSpriteBody
|
public class WithEmbeddedTurretSpriteBody : WithSpriteBody
|
||||||
{
|
{
|
||||||
|
readonly WithEmbeddedTurretSpriteBodyInfo info;
|
||||||
readonly Turreted turreted;
|
readonly Turreted turreted;
|
||||||
|
|
||||||
static Func<WAngle> MakeTurretFacingFunc(Actor self)
|
static Func<WAngle> MakeTurretFacingFunc(Actor self)
|
||||||
@@ -52,22 +56,23 @@ namespace OpenRA.Mods.Cnc.Traits.Render
|
|||||||
return () => turreted.WorldOrientation.Yaw;
|
return () => turreted.WorldOrientation.Yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WithEmbeddedTurretSpriteBody(ActorInitializer init, WithSpriteBodyInfo info)
|
public WithEmbeddedTurretSpriteBody(ActorInitializer init, WithEmbeddedTurretSpriteBodyInfo info)
|
||||||
: base(init, info, MakeTurretFacingFunc(init.Self))
|
: base(init, info, MakeTurretFacingFunc(init.Self))
|
||||||
{
|
{
|
||||||
|
this.info = info;
|
||||||
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
turreted = init.Self.TraitsImplementing<Turreted>().FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
{
|
{
|
||||||
base.TraitEnabled(self);
|
base.TraitEnabled(self);
|
||||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
turreted.QuantizedFacings = info.QuantizedFacings >= 0 ? info.QuantizedFacings : DefaultAnimation.CurrentSequence.Facings;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DamageStateChanged(Actor self)
|
protected override void DamageStateChanged(Actor self)
|
||||||
{
|
{
|
||||||
base.DamageStateChanged(self);
|
base.DamageStateChanged(self);
|
||||||
turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
|
turreted.QuantizedFacings = info.QuantizedFacings >= 0 ? info.QuantizedFacings : DefaultAnimation.CurrentSequence.Facings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -909,6 +909,7 @@ SAM:
|
|||||||
RealignDelay: -1
|
RealignDelay: -1
|
||||||
-WithSpriteBody:
|
-WithSpriteBody:
|
||||||
WithEmbeddedTurretSpriteBody:
|
WithEmbeddedTurretSpriteBody:
|
||||||
|
QuantizedFacings: 32
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Dragon
|
Weapon: Dragon
|
||||||
MuzzleSequence: muzzle
|
MuzzleSequence: muzzle
|
||||||
|
|||||||
Reference in New Issue
Block a user