WithRepairOverlay into pausable-conditional trait EMP disabled polish.
This commit is contained in:
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Displays an overlay when the building is being repaired by the player.")]
|
||||
public class WithRepairOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
public class WithRepairOverlayInfo : PausableConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||
{
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = "active";
|
||||
@@ -30,30 +30,28 @@ 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 object Create(ActorInitializer init) { return new WithRepairOverlay(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new WithRepairOverlay(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithRepairOverlay : INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair
|
||||
public class WithRepairOverlay : PausableConditionalTrait<WithRepairOverlayInfo>, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair
|
||||
{
|
||||
readonly Animation overlay;
|
||||
bool buildComplete;
|
||||
bool visible;
|
||||
|
||||
public WithRepairOverlay(Actor self, WithRepairOverlayInfo info)
|
||||
: base(info)
|
||||
{
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
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());
|
||||
overlay = new Animation(self.World, rs.GetImage(self), () => IsTraitPaused);
|
||||
overlay.PlayThen(info.Sequence, () => visible = false);
|
||||
|
||||
var anim = new AnimationWithOffset(overlay,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
() => !visible || !buildComplete,
|
||||
() => IsTraitDisabled || !visible || !buildComplete,
|
||||
p => RenderUtils.ZOffsetFromCenter(self, p, 1));
|
||||
|
||||
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
||||
|
||||
@@ -271,8 +271,10 @@ GADEPT:
|
||||
WithIdleOverlay@CIRCUITS:
|
||||
Sequence: circuits
|
||||
WithRepairOverlay@CRANE:
|
||||
PauseOnCondition: empdisable
|
||||
Sequence: crane
|
||||
WithRepairOverlay@PLATFORM:
|
||||
RequiresCondition: !empdisable
|
||||
Sequence: platform
|
||||
WithDeathAnimation@BIB:
|
||||
DeathSequence: dead-ground
|
||||
|
||||
Reference in New Issue
Block a user