diff --git a/OpenRA.Mods.Common/Activities/Repair.cs b/OpenRA.Mods.Common/Activities/Repair.cs index 1022a358b2..2dd1a6d5da 100644 --- a/OpenRA.Mods.Common/Activities/Repair.cs +++ b/OpenRA.Mods.Common/Activities/Repair.cs @@ -35,6 +35,15 @@ namespace OpenRA.Mods.Common.Activities health = self.TraitOrDefault(); } + protected override void OnFirstRun(Actor self) + { + if (host.Actor.IsDead) + return; + + foreach (var depot in host.Actor.TraitsImplementing()) + depot.BeforeRepair(host.Actor, self); + } + public override Activity Tick(Actor self) { if (IsCanceled) @@ -81,6 +90,7 @@ namespace OpenRA.Mods.Common.Activities } Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.FinishRepairingNotification, self.Owner.Faction.InternalName); + return NextActivity; } @@ -105,7 +115,7 @@ namespace OpenRA.Mods.Common.Activities self.InflictDamage(host.Actor, new Damage(-hpToRepair)); foreach (var depot in host.Actor.TraitsImplementing()) - depot.Repairing(host.Actor, self); + depot.RepairTick(host.Actor, self); remainingTicks = repairsUnits.Info.Interval; } @@ -114,5 +124,14 @@ namespace OpenRA.Mods.Common.Activities return this; } + + protected override void OnLastRun(Actor self) + { + if (host.Actor.IsDead) + return; + + foreach (var depot in host.Actor.TraitsImplementing()) + depot.AfterRepair(host.Actor, self); + } } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index 7efbaadb0e..b2db09db3e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -33,12 +33,16 @@ namespace OpenRA.Mods.Common.Traits.Render spriteBody = self.TraitOrDefault(); } - void INotifyRepair.Repairing(Actor self, Actor target) + void INotifyRepair.BeforeRepair(Actor self, Actor target) { } + + void INotifyRepair.RepairTick(Actor self, Actor target) { if (buildComplete && spriteBody != null && !IsTraitDisabled) spriteBody.PlayCustomAnimation(self, Info.Sequence); } + void INotifyRepair.AfterRepair(Actor self, Actor target) { } + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs index a09d6061de..3bed8b98d7 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs @@ -18,9 +18,15 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Displays an overlay when the building is being repaired by the player.")] public class WithRepairOverlayInfo : PausableConditionalTraitInfo, Requires, Requires { - [Desc("Sequence name to use")] + [Desc("Sequence to use upon repair beginning.")] + [SequenceReference("Image")] public readonly string StartSequence = null; + + [Desc("Sequence name to play once during repair intervals or repeatedly if a start sequence is set.")] [SequenceReference] public readonly string Sequence = "active"; + [Desc("Sequence to use after repairing has finished.")] + [SequenceReference("Image")] public readonly string EndSequence = null; + [Desc("Position relative to body")] public readonly WVec Offset = WVec.Zero; @@ -73,10 +79,32 @@ namespace OpenRA.Mods.Common.Traits.Render overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); } - void INotifyRepair.Repairing(Actor self, Actor host) + void INotifyRepair.BeforeRepair(Actor self, Actor host) { - visible = true; - overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false); + if (Info.StartSequence != null) + { + visible = true; + overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.StartSequence), + () => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), Info.Sequence))); + } + } + + void INotifyRepair.RepairTick(Actor self, Actor host) + { + if (Info.StartSequence == null) + { + visible = true; + overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false); + } + } + + void INotifyRepair.AfterRepair(Actor self, Actor target) + { + if (Info.EndSequence != null) + { + visible = true; + overlay.PlayThen(Info.EndSequence, () => visible = false); + } } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index c374c15472..88eb1f975b 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -86,8 +86,16 @@ namespace OpenRA.Mods.Common.Traits public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyKilled { void Killed(Actor self, AttackInfo e); } public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } + + [RequireExplicitImplementation] + public interface INotifyRepair + { + void BeforeRepair(Actor self, Actor target); + void RepairTick(Actor self, Actor target); + void AfterRepair(Actor self, Actor target); + } + public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); } - public interface INotifyRepair { void Repairing(Actor self, Actor target); } public interface INotifyNuke { void Launching(Actor self); } public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); } public interface INotifyChat { bool OnChat(string from, string message); } diff --git a/mods/ts/rules/gdi-structures.yaml b/mods/ts/rules/gdi-structures.yaml index 2642133b95..37a7737487 100644 --- a/mods/ts/rules/gdi-structures.yaml +++ b/mods/ts/rules/gdi-structures.yaml @@ -280,7 +280,9 @@ GADEPT: Sequence: circuits WithRepairOverlay@CRANE: PauseOnCondition: empdisable - Sequence: crane + StartSequence: crane-start + Sequence: crane-loop + EndSequence: crane-end WithRepairOverlay@PLATFORM: RequiresCondition: !empdisable Sequence: platform diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index 59c472fa8e..98a5f66000 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -1737,9 +1737,22 @@ gadept.gdi: ZOffset: -1c511 Tick: 120 ZRamp: 1 - crane: gtdept_c - Length: 16 + crane-start: gtdept_c + Length: 6 Offset: 0, -36, 12 + Tick: 60 + DepthSprite: isodepth.shp + crane-loop: gtdept_c + Start: 6 + Length: 5 + Offset: 0, -36, 12 + Tick: 60 + DepthSprite: isodepth.shp + crane-end: gtdept_c + Start: 10 + Length: 6 + Offset: 0, -36, 12 + Tick: 60 DepthSprite: isodepth.shp platform: gtdept_d Length: 7 @@ -1821,10 +1834,23 @@ gadept.nod: ZOffset: -1c511 Tick: 120 ZRamp: 1 - crane: gtdept_c - Length: 16 + crane-start: gtdept_c + Length: 6 Offset: 0, -36, 12 DepthSprite: isodepth.shp + Tick: 60 + crane-loop: gtdept_c + Start: 6 + Length: 5 + Offset: 0, -36, 12 + DepthSprite: isodepth.shp + Tick: 60 + crane-end: gtdept_c + Start: 10 + Length: 6 + Offset: 0, -36, 12 + DepthSprite: isodepth.shp + Tick: 60 platform: gtdept_d Length: 7 ZOffset: -1c511