Convert WithIdleOverlay from actor disabled to pausable-conditional.

This commit is contained in:
atlimit8
2017-03-16 12:15:45 -05:00
parent 11933c7e2c
commit 1c5427c86f
4 changed files with 6 additions and 9 deletions

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders a decorative animation on units and buildings.")] [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.")] [Desc("Animation to play when the actor is created.")]
[SequenceReference] public readonly string StartSequence = null; [SequenceReference] public readonly string StartSequence = null;
@@ -35,8 +35,6 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Custom palette is a player palette BaseName")] [Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false; public readonly bool IsPlayerPalette = false;
public readonly bool PauseOnLowPower = false;
public override object Create(ActorInitializer init) { return new WithIdleOverlay(init.Self, this); } 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) 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; readonly Animation overlay;
bool buildComplete; bool buildComplete;
@@ -84,8 +82,7 @@ namespace OpenRA.Mods.Common.Traits.Render
var body = self.Trait<BodyOrientation>(); var body = self.Trait<BodyOrientation>();
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units
overlay = new Animation(self.World, rs.GetImage(self), overlay = new Animation(self.World, rs.GetImage(self), () => IsTraitPaused || !buildComplete);
() => (info.PauseOnLowPower && self.IsDisabled()) || !buildComplete);
if (info.StartSequence != null) if (info.StartSequence != null)
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence), overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence),
() => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence))); () => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence)));

View File

@@ -525,7 +525,7 @@ outpost:
mercenary: outpost.ordos mercenary: outpost.ordos
WithIdleOverlay@DISH: WithIdleOverlay@DISH:
Sequence: idle-dish Sequence: idle-dish
PauseOnLowPower: true PauseOnCondition: disabled
RequiresCondition: !severe-damaged RequiresCondition: !severe-damaged
GrantConditionOnDamageState@STOPDISH: GrantConditionOnDamageState@STOPDISH:
Condition: severe-damaged Condition: severe-damaged

View File

@@ -326,7 +326,7 @@ GARADR:
MaxHeightDelta: 3 MaxHeightDelta: 3
WithIdleOverlay@DISH: WithIdleOverlay@DISH:
Sequence: idle-dish Sequence: idle-dish
PauseOnLowPower: yes PauseOnCondition: disabled
Targetable: Targetable:
TargetTypes: Ground, C4, SpyInfiltrate TargetTypes: Ground, C4, SpyInfiltrate
Power: Power:

View File

@@ -285,7 +285,7 @@ NARADR:
MaxHeightDelta: 3 MaxHeightDelta: 3
WithIdleOverlay@DISH: WithIdleOverlay@DISH:
Sequence: idle-dish Sequence: idle-dish
PauseOnLowPower: true PauseOnCondition: disabled
Targetable: Targetable:
TargetTypes: Ground, C4, SpyInfiltrate TargetTypes: Ground, C4, SpyInfiltrate
Power: Power: