Convert WithIdleOverlay from actor disabled to pausable-conditional.
This commit is contained in:
@@ -18,7 +18,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Renders a decorative animation on units and buildings.")]
|
||||
public class WithIdleOverlayInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
public class WithIdleOverlayInfo : PausableConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
{
|
||||
[Desc("Animation to play when the actor is created.")]
|
||||
[SequenceReference] public readonly string StartSequence = null;
|
||||
@@ -35,8 +35,6 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
[Desc("Custom palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = false;
|
||||
|
||||
public readonly bool PauseOnLowPower = false;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new WithIdleOverlay(init.Self, this); }
|
||||
|
||||
public IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
@@ -72,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
}
|
||||
}
|
||||
|
||||
public class WithIdleOverlay : ConditionalTrait<WithIdleOverlayInfo>, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyTransform
|
||||
public class WithIdleOverlay : PausableConditionalTrait<WithIdleOverlayInfo>, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyTransform
|
||||
{
|
||||
readonly Animation overlay;
|
||||
bool buildComplete;
|
||||
@@ -84,8 +82,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units
|
||||
overlay = new Animation(self.World, rs.GetImage(self),
|
||||
() => (info.PauseOnLowPower && self.IsDisabled()) || !buildComplete);
|
||||
overlay = new Animation(self.World, rs.GetImage(self), () => IsTraitPaused || !buildComplete);
|
||||
if (info.StartSequence != null)
|
||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence),
|
||||
() => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence)));
|
||||
|
||||
Reference in New Issue
Block a user