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
|
namespace OpenRA.Mods.Common.Traits.Render
|
||||||
{
|
{
|
||||||
[Desc("Displays an overlay when the building is being repaired by the player.")]
|
[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")]
|
[Desc("Sequence name to use")]
|
||||||
[SequenceReference] public readonly string Sequence = "active";
|
[SequenceReference] public readonly string Sequence = "active";
|
||||||
@@ -30,30 +30,28 @@ 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 WithRepairOverlay(init.Self, this); }
|
||||||
|
|
||||||
public 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;
|
readonly Animation overlay;
|
||||||
bool buildComplete;
|
bool buildComplete;
|
||||||
bool visible;
|
bool visible;
|
||||||
|
|
||||||
public WithRepairOverlay(Actor self, WithRepairOverlayInfo info)
|
public WithRepairOverlay(Actor self, WithRepairOverlayInfo info)
|
||||||
|
: base(info)
|
||||||
{
|
{
|
||||||
var rs = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
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);
|
||||||
() => info.PauseOnLowPower && self.IsDisabled());
|
|
||||||
overlay.PlayThen(info.Sequence, () => visible = false);
|
overlay.PlayThen(info.Sequence, () => visible = false);
|
||||||
|
|
||||||
var anim = new AnimationWithOffset(overlay,
|
var anim = new AnimationWithOffset(overlay,
|
||||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||||
() => !visible || !buildComplete,
|
() => IsTraitDisabled || !visible || !buildComplete,
|
||||||
p => RenderUtils.ZOffsetFromCenter(self, p, 1));
|
p => RenderUtils.ZOffsetFromCenter(self, p, 1));
|
||||||
|
|
||||||
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
||||||
|
|||||||
@@ -271,8 +271,10 @@ GADEPT:
|
|||||||
WithIdleOverlay@CIRCUITS:
|
WithIdleOverlay@CIRCUITS:
|
||||||
Sequence: circuits
|
Sequence: circuits
|
||||||
WithRepairOverlay@CRANE:
|
WithRepairOverlay@CRANE:
|
||||||
|
PauseOnCondition: empdisable
|
||||||
Sequence: crane
|
Sequence: crane
|
||||||
WithRepairOverlay@PLATFORM:
|
WithRepairOverlay@PLATFORM:
|
||||||
|
RequiresCondition: !empdisable
|
||||||
Sequence: platform
|
Sequence: platform
|
||||||
WithDeathAnimation@BIB:
|
WithDeathAnimation@BIB:
|
||||||
DeathSequence: dead-ground
|
DeathSequence: dead-ground
|
||||||
|
|||||||
Reference in New Issue
Block a user