From a6b09342bcdce12aab2e87ac22e6233058b87f76 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 21:21:29 +0200 Subject: [PATCH] Make INotifyBuildComplete require explicit implementation --- OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs | 2 +- OpenRA.Mods.Common/Traits/Harvester.cs | 2 +- OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs | 2 +- OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs | 9 +++++++-- OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs | 2 +- OpenRA.Mods.Common/Traits/Sound/AnnounceOnBuild.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 1 + OpenRA.Mods.D2k/Traits/Render/WithCrumbleOverlay.cs | 2 +- 9 files changed, 16 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs b/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs index c2d8808af4..63e1055e9a 100644 --- a/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs +++ b/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs @@ -102,7 +102,7 @@ namespace OpenRA.Mods.Cnc.Traits } } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { if (skippedMakeAnimation) { diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 5d4ba7be23..ad5127677a 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits self.QueueActivity(new FindResources(self)); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { if (Info.SearchOnCreation) self.QueueActivity(new FindResources(self)); diff --git a/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs index 921bcd1c46..a547d81c2d 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits.Render } } - class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, INotifyBuildComplete, IWallConnector, ITick + class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, IWallConnector, ITick { readonly WithGateSpriteBodyInfo gateInfo; readonly Gate gate; @@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits.Render UpdateState(self); } - public override void BuildingComplete(Actor self) + protected override void OnBuildComplete(Actor self) { UpdateState(self); UpdateNeighbours(self); diff --git a/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs index 19987f0c97..be3b86d262 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSiloAnimation.cs @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits.Render playerResources = init.Self.Owner.PlayerActor.Trait(); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { wsb.DefaultAnimation.PlayFetchIndex(wsb.NormalizeSequence(self, info.Sequence), () => playerResources.ResourceCapacity != 0 diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs index 4fc235c0bc..a533351298 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs @@ -75,12 +75,17 @@ namespace OpenRA.Mods.Common.Traits.Render return RenderSprites.NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence); } - // TODO: Get rid of INotifyBuildComplete in favor of using the upgrade system - public virtual void BuildingComplete(Actor self) + protected virtual void OnBuildComplete(Actor self) { DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence)); } + // TODO: Get rid of INotifyBuildComplete in favor of using the upgrade system + void INotifyBuildComplete.BuildingComplete(Actor self) + { + OnBuildComplete(self); + } + public void PlayCustomAnimation(Actor self, string name, Action after = null) { DefaultAnimation.PlayThen(NormalizeSequence(self, name), () => diff --git a/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs index 891e0dcecd..7abc1dce61 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs @@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits.Render dirty = false; } - public override void BuildingComplete(Actor self) + protected override void OnBuildComplete(Actor self) { DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent); UpdateNeighbours(self); diff --git a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnBuild.cs b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnBuild.cs index c2c1bc6293..9cf416d0cd 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnBuild.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnBuild.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits.Sound this.info = info; } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { self.PlayVoice(info.Voice); } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index ffc321215f..4b8f15b3ae 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -70,6 +70,7 @@ namespace OpenRA.Mods.Common.Traits void PreparingAttack(Actor self, Target target, Armament a, Barrel barrel); } + [RequireExplicitImplementation] public interface INotifyBuildComplete { void BuildingComplete(Actor self); } public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); } public interface INotifyRepair { void Repairing(Actor self, Actor target); } diff --git a/OpenRA.Mods.D2k/Traits/Render/WithCrumbleOverlay.cs b/OpenRA.Mods.D2k/Traits/Render/WithCrumbleOverlay.cs index da2d41b3ae..1961a07866 100644 --- a/OpenRA.Mods.D2k/Traits/Render/WithCrumbleOverlay.cs +++ b/OpenRA.Mods.D2k/Traits/Render/WithCrumbleOverlay.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.D2k.Traits.Render rs.Add(anim, info.Palette, info.IsPlayerPalette); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; }