Make WithSpriteBody a pausable trait
Allowing to drop the PauseAnimationWhenDisabled property (in favor of using PausOnCondition).
This commit is contained in:
@@ -18,7 +18,7 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits.Render
|
namespace OpenRA.Mods.Common.Traits.Render
|
||||||
{
|
{
|
||||||
[Desc("Default trait for rendering sprite-based actors.")]
|
[Desc("Default trait for rendering sprite-based actors.")]
|
||||||
public class WithSpriteBodyInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>
|
public class WithSpriteBodyInfo : PausableConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>
|
||||||
{
|
{
|
||||||
[Desc("Animation to play when the actor is created."), SequenceReference]
|
[Desc("Animation to play when the actor is created."), SequenceReference]
|
||||||
public readonly string StartSequence = null;
|
public readonly string StartSequence = null;
|
||||||
@@ -26,9 +26,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
[Desc("Animation to play when the actor is idle."), SequenceReference]
|
[Desc("Animation to play when the actor is idle."), SequenceReference]
|
||||||
public readonly string Sequence = "idle";
|
public readonly string Sequence = "idle";
|
||||||
|
|
||||||
[Desc("Pause animation when actor is disabled.")]
|
|
||||||
public readonly bool PauseAnimationWhenDisabled = false;
|
|
||||||
|
|
||||||
[Desc("Identifier used to assign modifying traits to this sprite body.")]
|
[Desc("Identifier used to assign modifying traits to this sprite body.")]
|
||||||
public readonly string Name = "body";
|
public readonly string Name = "body";
|
||||||
|
|
||||||
@@ -46,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithSpriteBody : ConditionalTrait<WithSpriteBodyInfo>, INotifyDamageStateChanged, INotifyBuildComplete
|
public class WithSpriteBody : PausableConditionalTrait<WithSpriteBodyInfo>, INotifyDamageStateChanged, INotifyBuildComplete
|
||||||
{
|
{
|
||||||
public readonly Animation DefaultAnimation;
|
public readonly Animation DefaultAnimation;
|
||||||
|
|
||||||
@@ -58,9 +55,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
{
|
{
|
||||||
var rs = init.Self.Trait<RenderSprites>();
|
var rs = init.Self.Trait<RenderSprites>();
|
||||||
|
|
||||||
Func<bool> paused = null;
|
Func<bool> paused = () => IsTraitPaused &&
|
||||||
if (info.PauseAnimationWhenDisabled)
|
|
||||||
paused = () => init.Self.IsDisabled() &&
|
|
||||||
DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence);
|
DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence);
|
||||||
|
|
||||||
DefaultAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
|
DefaultAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
|
||||||
|
|||||||
Reference in New Issue
Block a user