From df0021eeedc11944a19acc748cf9ee9e39140160 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 16:58:55 +0200 Subject: [PATCH 1/8] Move check for explicit interface violations to the top The interface violation check is fast, so it doesn't really delay the rest, while you don't have to wait for all other code checks to finish to check for violations. --- Makefile | 6 +++--- make.ps1 | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3364a9d9a7..c404363cd4 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,9 @@ check-scripts: @luac -p $(shell find lua/* -iname '*.lua') check: utility mods + @echo + @echo "Checking for explicit interface violations..." + @mono --debug OpenRA.Utility.exe all --check-explicit-interfaces @echo @echo "Checking for code style violations in OpenRA.Game..." @mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Game @@ -220,9 +223,6 @@ check: utility mods @echo "Checking for code style violations in OpenRA.Test..." @mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Test @echo - @echo "Checking for explicit interface violations..." - @mono --debug OpenRA.Utility.exe all --check-explicit-interfaces - @echo @echo "Checking for code style violations in OpenRA.Server..." @mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Server diff --git a/make.ps1 b/make.ps1 index d857e9d0e2..77106319f3 100644 --- a/make.ps1 +++ b/make.ps1 @@ -164,6 +164,8 @@ elseif ($command -eq "check") { if (Test-Path OpenRA.Utility.exe) { + echo "Checking for explicit interface violations..." + ./OpenRA.Utility.exe all --check-explicit-interfaces echo "Checking for code style violations in OpenRA.Platforms.Default..." ./OpenRA.Utility.exe cnc --check-code-style OpenRA.Platforms.Default echo "Checking for code style violations in OpenRA.GameMonitor..." @@ -184,8 +186,6 @@ elseif ($command -eq "check") ./OpenRA.Utility.exe cnc --check-code-style OpenRA.Utility echo "Checking for code style violations in OpenRA.Test..." ./OpenRA.Utility.exe cnc --check-code-style OpenRA.Test - echo "Checking for explicit interface violations..." - ./OpenRA.Utility.exe all --check-explicit-interfaces } else { From b8c04a0887560a66daf5891e7a4606efe38c8c88 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 15:13:13 +0200 Subject: [PATCH 2/8] Move INotifyBlockingMove to Common and require explicit implementation --- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 -- OpenRA.Mods.Common/Traits/Harvester.cs | 4 ++-- OpenRA.Mods.Common/Traits/Mobile.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 3 +++ 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 6e580d5234..e2e488af7d 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -319,8 +319,6 @@ namespace OpenRA.Traits bool IsBlocking(Actor self, CPos cell); } - public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); } - public interface IFacing { int TurnSpeed { get; } diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 1cb9c859e8..5d4ba7be23 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -78,6 +78,7 @@ namespace OpenRA.Mods.Common.Traits readonly Mobile mobile; Dictionary contents = new Dictionary(); bool idleSmart = true; + int idleDuration; [Sync] public Actor OwnerLinkedProc = null; [Sync] public Actor LastLinkedProc = null; @@ -233,7 +234,7 @@ namespace OpenRA.Mods.Common.Traits } } - public void OnNotifyBlockingMove(Actor self, Actor blocking) + void INotifyBlockingMove.OnNotifyBlockingMove(Actor self, Actor blocking) { // I'm blocking someone else from moving to my location: var act = self.GetCurrentActivity(); @@ -253,7 +254,6 @@ namespace OpenRA.Mods.Common.Traits } } - int idleDuration; public void TickIdle(Actor self) { // Should we be intelligent while idle? diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index cdd07f2a70..2f3fc2d0d1 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -770,7 +770,7 @@ namespace OpenRA.Mods.Common.Traits public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange) { return new Follow(self, target, minRange, maxRange); } public Activity MoveTo(Func> pathFunc) { return new Move(self, pathFunc); } - public void OnNotifyBlockingMove(Actor self, Actor blocking) + void INotifyBlockingMove.OnNotifyBlockingMove(Actor self, Actor blocking) { if (self.IsIdle && self.AppearsFriendlyTo(blocking)) Nudge(self, blocking, true); diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index bdacbedcaf..b86c6c8cf6 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -50,6 +50,9 @@ namespace OpenRA.Mods.Common.Traits public interface IRenderActorPreviewInfo : ITraitInfo { IEnumerable RenderPreview(ActorPreviewInitializer init); } public interface ICruiseAltitudeInfo : ITraitInfo { WDist GetCruiseAltitude(); } + [RequireExplicitImplementation] + public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); } + public interface IUpgradable { IEnumerable UpgradeTypes { get; } From 22dcb1c66f2276bf98ea4f575410861d4ad32c3e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 18:44:29 +0200 Subject: [PATCH 3/8] Move INotifySold to Common and require explicit implementation --- OpenRA.Game/Traits/TraitsInterfaces.cs | 1 - OpenRA.Mods.Common/Traits/Buildings/Building.cs | 16 ++++++++-------- OpenRA.Mods.Common/Traits/Buildings/Refinery.cs | 4 ++-- .../Traits/Buildings/Reservable.cs | 8 ++++++-- OpenRA.Mods.Common/Traits/Cargo.cs | 4 ++-- OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs | 4 ++-- .../Traits/Player/ProductionQueue.cs | 4 ++-- .../Traits/Render/WithChargeOverlay.cs | 4 ++-- .../Traits/Render/WithDockedOverlay.cs | 4 ++-- .../Traits/Render/WithIdleAnimation.cs | 4 ++-- .../Traits/Render/WithIdleOverlay.cs | 4 ++-- .../Traits/Render/WithProductionDoorOverlay.cs | 4 ++-- .../Traits/Render/WithProductionOverlay.cs | 4 ++-- .../Traits/Render/WithRearmAnimation.cs | 4 ++-- .../Traits/Render/WithRepairAnimation.cs | 4 ++-- .../Traits/Render/WithRepairOverlay.cs | 4 ++-- .../Traits/Render/WithResources.cs | 4 ++-- OpenRA.Mods.Common/TraitsInterfaces.cs | 7 +++++++ .../Traits/Render/WithDeliveryOverlay.cs | 4 ++-- OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs | 4 ++-- 20 files changed, 53 insertions(+), 43 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index e2e488af7d..7d3d622c95 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -143,7 +143,6 @@ namespace OpenRA.Traits public interface INotifyCreated { void Created(Actor self); } public interface INotifyAddedToWorld { void AddedToWorld(Actor self); } public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); } - public interface INotifySold { void Selling(Actor self); void Sold(Actor self); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } public interface INotifyRepair { void Repairing(Actor self, Actor target); } diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 0f841e4089..34c49e7bd9 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits readonly Actor self; public readonly bool SkipMakeAnimation; - /* shared activity lock: undeploy, sell, capture, etc */ + // Shared activity lock: undeploy, sell, capture, etc. [Sync] public bool Locked = true; public bool Lock() @@ -181,7 +181,7 @@ namespace OpenRA.Mods.Common.Traits return OccupiedCells().Select(c => self.World.Map.CenterOfCell(c.First)); } - public void Created(Actor self) + void INotifyCreated.Created(Actor self) { if (SkipMakeAnimation || !self.Info.HasTraitInfo()) NotifyBuildingComplete(self); @@ -199,7 +199,7 @@ namespace OpenRA.Mods.Common.Traits self.World.ScreenMap.Add(self); } - public void RemovedFromWorld(Actor self) + void INotifyRemovedFromWorld.RemovedFromWorld(Actor self) { self.World.ActorMap.RemoveInfluence(self, this); self.World.ActorMap.RemovePosition(self, this); @@ -220,7 +220,7 @@ namespace OpenRA.Mods.Common.Traits notify.BuildingComplete(self); } - public void Selling(Actor self) + void INotifySold.Selling(Actor self) { if (Info.RemoveSmudgesOnSell) RemoveSmudges(); @@ -228,9 +228,9 @@ namespace OpenRA.Mods.Common.Traits BuildComplete = false; } - public void Sold(Actor self) { } + void INotifySold.Sold(Actor self) { } - public void BeforeTransform(Actor self) + void INotifyTransform.BeforeTransform(Actor self) { if (Info.RemoveSmudgesOnTransform) RemoveSmudges(); @@ -239,8 +239,8 @@ namespace OpenRA.Mods.Common.Traits Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); } - public void OnTransform(Actor self) { } - public void AfterTransform(Actor self) { } + void INotifyTransform.OnTransform(Actor self) { } + void INotifyTransform.AfterTransform(Actor self) { } public void RemoveSmudges() { diff --git a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs index f1d24addc8..417d939d3b 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs @@ -168,8 +168,8 @@ namespace OpenRA.Mods.Common.Traits } } - public void Selling(Actor self) { CancelDock(self); } - public void Sold(Actor self) + void INotifySold.Selling(Actor self) { CancelDock(self); } + void INotifySold.Sold(Actor self) { foreach (var harv in GetLinkedHarvesters()) harv.Trait.UnlinkProc(harv.Actor, self); diff --git a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs index a5b08be5cf..c616973948 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs @@ -76,9 +76,13 @@ namespace OpenRA.Mods.Common.Traits reservedForAircraft.UnReserve(); } - public void Selling(Actor self) { Sold(self); } + void INotifySold.Selling(Actor self) + { + if (reservedForAircraft != null) + reservedForAircraft.UnReserve(); + } - public void Sold(Actor self) + void INotifySold.Sold(Actor self) { if (reservedForAircraft != null) reservedForAircraft.UnReserve(); diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index 29dc1c135c..9e8084b139 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -356,8 +356,8 @@ namespace OpenRA.Mods.Common.Traits cargo.Clear(); } - public void Selling(Actor self) { } - public void Sold(Actor self) + void INotifySold.Selling(Actor self) { } + void INotifySold.Sold(Actor self) { if (!Info.EjectOnSell || cargo == null) return; diff --git a/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs b/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs index 6090b6f151..97508e3f79 100644 --- a/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs +++ b/OpenRA.Mods.Common/Traits/EmitInfantryOnSell.cs @@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits correctFaction = factionsList.Count == 0 || factionsList.Contains(self.Owner.Faction.InternalName); } - public void Selling(Actor self) { } + void INotifySold.Selling(Actor self) { } void Emit(Actor self) { @@ -85,6 +85,6 @@ namespace OpenRA.Mods.Common.Traits } } - public void Sold(Actor self) { Emit(self); } + void INotifySold.Sold(Actor self) { Emit(self); } } } diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index 573e773f35..efe0ad98b1 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -139,8 +139,8 @@ namespace OpenRA.Mods.Common.Traits } public void Killed(Actor killed, AttackInfo e) { if (killed == self) { ClearQueue(); Enabled = false; } } - public void Selling(Actor self) { ClearQueue(); Enabled = false; } - public void Sold(Actor self) { } + void INotifySold.Selling(Actor self) { ClearQueue(); Enabled = false; } + void INotifySold.Sold(Actor self) { } public void BeforeTransform(Actor self) { ClearQueue(); Enabled = false; } public void OnTransform(Actor self) { } diff --git a/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs index d3c243f1c5..338b003286 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs @@ -60,8 +60,8 @@ namespace OpenRA.Mods.Common.Traits.Render overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence)); } - public void Sold(Actor self) { } - public void Selling(Actor self) + void INotifySold.Sold(Actor self) { } + void INotifySold.Selling(Actor self) { charging = false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs index a1f1906709..e87cc32e85 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs @@ -71,8 +71,8 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = true))); } - public void Sold(Actor self) { } - public void Selling(Actor self) + void INotifySold.Sold(Actor self) { } + void INotifySold.Selling(Actor self) { buildComplete = false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs index 904f080083..c1f8c6b195 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs @@ -59,11 +59,11 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = true; } - public void Selling(Actor self) + void INotifySold.Selling(Actor self) { buildComplete = false; } - public void Sold(Actor self) { } + void INotifySold.Sold(Actor self) { } } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs index f0abb02bde..e617dba6a6 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs @@ -105,8 +105,8 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = true; } - public void Sold(Actor self) { } - public void Selling(Actor self) + void INotifySold.Sold(Actor self) { } + void INotifySold.Selling(Actor self) { buildComplete = false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs index 057caa2981..5b36a19626 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs @@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Traits.Render desiredFrame = door.CurrentSequence.Length - 1; } - public void Selling(Actor self) { buildComplete = false; } - public void Sold(Actor self) { } + void INotifySold.Selling(Actor self) { buildComplete = false; } + void INotifySold.Sold(Actor self) { } } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs index d967030419..ca07c64840 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs @@ -97,8 +97,8 @@ namespace OpenRA.Mods.Common.Traits.Render self.World.AddFrameEndTask(w => SelectQueue(self)); } - public void Sold(Actor self) { } - public void Selling(Actor self) + void INotifySold.Sold(Actor self) { } + void INotifySold.Selling(Actor self) { buildComplete = false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs index b478f3b52a..23c6bc7995 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs @@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = true; } - public void Selling(Actor self) + void INotifySold.Selling(Actor self) { buildComplete = false; } - public void Sold(Actor self) { } + void INotifySold.Sold(Actor self) { } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index 18cda57b94..5a8321835d 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = true; } - public void Selling(Actor self) + void INotifySold.Selling(Actor self) { buildComplete = false; } - public void Sold(Actor self) { } + void INotifySold.Sold(Actor self) { } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs index 70b564d38b..2468bef6f2 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs @@ -65,8 +65,8 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = true))); } - public void Sold(Actor self) { } - public void Selling(Actor self) + void INotifySold.Sold(Actor self) { } + void INotifySold.Selling(Actor self) { buildComplete = false; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithResources.cs b/OpenRA.Mods.Common/Traits/Render/WithResources.cs index 2aabddb2aa..f8815bb59e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResources.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResources.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits.Render playerResources = newOwner.PlayerActor.Trait(); } - public void Selling(Actor self) { rs.Remove(anim); } - public void Sold(Actor self) { } + void INotifySold.Selling(Actor self) { rs.Remove(anim); } + void INotifySold.Sold(Actor self) { } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index b86c6c8cf6..bc06006e5e 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -36,6 +36,13 @@ namespace OpenRA.Mods.Common.Traits IEnumerable Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition); } + [RequireExplicitImplementation] + public interface INotifySold + { + void Selling(Actor self); + void Sold(Actor self); + } + [RequireExplicitImplementation] public interface INotifyAttack { diff --git a/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs b/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs index 3b1942c8e5..4d4763af0f 100644 --- a/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs +++ b/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs @@ -75,8 +75,8 @@ namespace OpenRA.Mods.D2k.Traits.Render buildComplete = true))); } - public void Sold(Actor self) { } - public void Selling(Actor self) + void INotifySold.Sold(Actor self) { } + void INotifySold.Selling(Actor self) { buildComplete = false; } diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs index 5e1a3792a2..a00b8a0414 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs @@ -86,8 +86,8 @@ namespace OpenRA.Mods.RA.Traits public void Killed(Actor self, AttackInfo e) { RemoveGps(self); } - public void Selling(Actor self) { } - public void Sold(Actor self) { RemoveGps(self); } + void INotifySold.Selling(Actor self) { } + void INotifySold.Sold(Actor self) { RemoveGps(self); } void RemoveGps(Actor self) { From 61284d73dd3be206adc3660f3a2ccac849bfd247 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 18:51:01 +0200 Subject: [PATCH 4/8] Make interface implementations explicit where possible in traits that implement INotifySold --- OpenRA.Mods.Common/Traits/Buildings/Refinery.cs | 8 ++++---- OpenRA.Mods.Common/Traits/Buildings/Reservable.cs | 6 +++--- OpenRA.Mods.Common/Traits/Cargo.cs | 12 ++++++------ OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs | 10 +++++----- .../Traits/Render/WithChargeOverlay.cs | 4 ++-- .../Traits/Render/WithDockedOverlay.cs | 6 +++--- .../Traits/Render/WithIdleAnimation.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs | 10 +++++----- .../Traits/Render/WithProductionDoorOverlay.cs | 8 ++++---- .../Traits/Render/WithProductionOverlay.cs | 8 ++++---- .../Traits/Render/WithRearmAnimation.cs | 2 +- .../Traits/Render/WithRepairAnimation.cs | 4 ++-- .../Traits/Render/WithRepairOverlay.cs | 6 +++--- OpenRA.Mods.Common/Traits/Render/WithResources.cs | 6 +++--- OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs | 6 +++--- OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs | 6 +++--- 16 files changed, 53 insertions(+), 53 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs index 417d939d3b..d88d52d7d7 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Refinery.cs @@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Traits dockedHarv.CancelActivity(); } - public void Tick(Actor self) + void ITick.Tick(Actor self) { // Harvester was killed while unloading if (dockedHarv != null && dockedHarv.IsDead) @@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits } } - public void Disposing(Actor self) + void INotifyActorDisposing.Disposing(Actor self) { CancelDock(self); foreach (var harv in GetLinkedHarvesters()) @@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Traits harv.QueueActivity(new CallFunc(() => harv.Trait().ContinueHarvesting(harv))); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { // Unlink any harvesters foreach (var harv in GetLinkedHarvesters()) @@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits playerResources = newOwner.PlayerActor.Trait(); } - public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) + void INotifyCapture.OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner) { // Steal any docked harv too if (dockedHarv != null) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs index c616973948..2ba201e2f7 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits Actor reservedFor; Aircraft reservedForAircraft; - public void Tick(Actor self) + void ITick.Tick(Actor self) { if (reservedFor == null) return; /* nothing to do */ @@ -64,13 +64,13 @@ namespace OpenRA.Mods.Common.Traits return res != null && res.reservedForAircraft != null && !res.reservedForAircraft.MayYieldReservation; } - public void Disposing(Actor self) + void INotifyActorDisposing.Disposing(Actor self) { if (reservedForAircraft != null) reservedForAircraft.UnReserve(); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { if (reservedForAircraft != null) reservedForAircraft.UnReserve(); diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index 9e8084b139..202f901220 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits facing = Exts.Lazy(self.TraitOrDefault); } - public void Created(Actor self) + void INotifyCreated.Created(Actor self) { aircraft = self.TraitOrDefault(); } @@ -320,7 +320,7 @@ namespace OpenRA.Mods.Common.Traits upgradeManager.GrantUpgrade(self, u, p); } - public void Killed(Actor self, AttackInfo e) + void INotifyKilled.Killed(Actor self, AttackInfo e) { if (Info.EjectOnDeath) while (!IsEmpty(self) && CanUnload()) @@ -348,7 +348,7 @@ namespace OpenRA.Mods.Common.Traits cargo.Clear(); } - public void Disposing(Actor self) + void INotifyActorDisposing.Disposing(Actor self) { foreach (var c in cargo) c.Dispose(); @@ -377,7 +377,7 @@ namespace OpenRA.Mods.Common.Traits }); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { if (cargo == null) return; @@ -389,7 +389,7 @@ namespace OpenRA.Mods.Common.Traits }); } - public void AddedToWorld(Actor self) + void INotifyAddedToWorld.AddedToWorld(Actor self) { // Force location update to avoid issues when initial spawn is outside map currentCell = self.Location; @@ -397,7 +397,7 @@ namespace OpenRA.Mods.Common.Traits } bool initialized; - public void Tick(Actor self) + void ITick.Tick(Actor self) { // Notify initial cargo load if (!initialized) diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index efe0ad98b1..7bd9e957ce 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits queue.Clear(); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { ClearQueue(); @@ -138,13 +138,13 @@ namespace OpenRA.Mods.Common.Traits newOwner.PlayerActor.Trait().Update(); } - public void Killed(Actor killed, AttackInfo e) { if (killed == self) { ClearQueue(); Enabled = false; } } + void INotifyKilled.Killed(Actor killed, AttackInfo e) { if (killed == self) { ClearQueue(); Enabled = false; } } void INotifySold.Selling(Actor self) { ClearQueue(); Enabled = false; } void INotifySold.Sold(Actor self) { } - public void BeforeTransform(Actor self) { ClearQueue(); Enabled = false; } - public void OnTransform(Actor self) { } - public void AfterTransform(Actor self) { } + void INotifyTransform.BeforeTransform(Actor self) { ClearQueue(); Enabled = false; } + void INotifyTransform.OnTransform(Actor self) { } + void INotifyTransform.AfterTransform(Actor self) { } void CacheProducibles(Actor playerActor) { diff --git a/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs index 338b003286..c64c8759b1 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithChargeOverlay.cs @@ -49,13 +49,13 @@ namespace OpenRA.Mods.Common.Traits.Render info.Palette, info.IsPlayerPalette); } - public void Charging(Actor self, Target target) + void INotifyCharging.Charging(Actor self, Target target) { charging = true; overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence), () => charging = false); } - public void DamageStateChanged(Actor self, AttackInfo e) + void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, info.Sequence)); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs index e87cc32e85..96c2e865d3 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDockedOverlay.cs @@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits.Render anim.Animation.PlayThen(info.Sequence, PlayDockingOverlay); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { self.World.AddFrameEndTask(w => w.Add(new DelayedAction(120, () => buildComplete = true))); @@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = false; } - public void Docked(Actor self, Actor harvester) { docked = true; PlayDockingOverlay(); } - public void Undocked(Actor self, Actor harvester) { docked = false; } + void INotifyDocking.Docked(Actor self, Actor harvester) { docked = true; PlayDockingOverlay(); } + void INotifyDocking.Undocked(Actor self, Actor harvester) { docked = false; } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs index c1f8c6b195..98f6e9efdb 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits.Render ticks = info.Interval; } - public void Tick(Actor self) + void ITick.Tick(Actor self) { if (!buildComplete || IsTraitDisabled) return; @@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits.Render } } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs index e617dba6a6..520ef26767 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs @@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits.Render rs.Add(anim, info.Palette, info.IsPlayerPalette); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; } @@ -111,15 +111,15 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = false; } - public void BeforeTransform(Actor self) + void INotifyTransform.BeforeTransform(Actor self) { buildComplete = false; } - public void OnTransform(Actor self) { } - public void AfterTransform(Actor self) { } + void INotifyTransform.OnTransform(Actor self) { } + void INotifyTransform.AfterTransform(Actor self) { } - public void DamageStateChanged(Actor self, AttackInfo e) + void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs index 5b36a19626..d330d53073 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionDoorOverlay.cs @@ -57,24 +57,24 @@ namespace OpenRA.Mods.Common.Traits.Render renderSprites.Add(new AnimationWithOffset(door, null, () => !buildComplete, offset)); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; } - public void Tick(Actor self) + void ITick.Tick(Actor self) { if (desiredFrame > 0 && !self.World.ActorMap.GetActorsAt(openExit).Any(a => a != self)) desiredFrame = 0; } - public void DamageStateChanged(Actor self, AttackInfo e) + void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { if (door.CurrentSequence != null) door.ReplaceAnim(RenderSprites.NormalizeSequence(door, e.DamageState, door.CurrentSequence.Name)); } - public void UnitProduced(Actor self, Actor other, CPos exit) + void INotifyProduction.UnitProduced(Actor self, Actor other, CPos exit) { openExit = exit; desiredFrame = door.CurrentSequence.Length - 1; diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs index ca07c64840..b11b6710bc 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs @@ -80,19 +80,19 @@ namespace OpenRA.Mods.Common.Traits.Render throw new InvalidOperationException("Can't find production queues."); } - public void Created(Actor self) + void INotifyCreated.Created(Actor self) { if (buildComplete) SelectQueue(self); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; SelectQueue(self); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { self.World.AddFrameEndTask(w => SelectQueue(self)); } @@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = false; } - public void DamageStateChanged(Actor self, AttackInfo e) + void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs index 23c6bc7995..31b96f3a31 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRearmAnimation.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render spriteBody.PlayCustomAnimation(self, info.Sequence, () => spriteBody.CancelCustomAnimation(self)); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; } diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index 5a8321835d..2f4698631e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -36,13 +36,13 @@ namespace OpenRA.Mods.Common.Traits.Render spriteBody = self.TraitOrDefault(); } - public void Repairing(Actor self, Actor target) + void INotifyRepair.Repairing(Actor self, Actor target) { if (buildComplete && spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled())) spriteBody.PlayCustomAnimation(self, info.Sequence, () => spriteBody.CancelCustomAnimation(self)); } - public void BuildingComplete(Actor self) + 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 2468bef6f2..a330e4f29e 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs @@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits.Render rs.Add(anim, info.Palette, info.IsPlayerPalette); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { self.World.AddFrameEndTask(w => w.Add(new DelayedAction(120, () => buildComplete = true))); @@ -71,12 +71,12 @@ namespace OpenRA.Mods.Common.Traits.Render buildComplete = false; } - public void DamageStateChanged(Actor self, AttackInfo e) + void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name)); } - public void Repairing(Actor self, Actor host) + void INotifyRepair.Repairing(Actor self, Actor host) { visible = true; overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false); diff --git a/OpenRA.Mods.Common/Traits/Render/WithResources.cs b/OpenRA.Mods.Common/Traits/Render/WithResources.cs index f8815bb59e..666987f648 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResources.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResources.cs @@ -50,18 +50,18 @@ namespace OpenRA.Mods.Common.Traits.Render rs.Add(anim); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { buildComplete = true; } - public void DamageStateChanged(Actor self, AttackInfo e) + void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { if (anim.Animation.CurrentSequence != null) anim.Animation.ReplaceAnim(wsb.NormalizeSequence(self, info.Sequence)); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { playerResources = newOwner.PlayerActor.Trait(); } diff --git a/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs b/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs index 4d4763af0f..5d8ca9bbdf 100644 --- a/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs +++ b/OpenRA.Mods.D2k/Traits/Render/WithDeliveryOverlay.cs @@ -69,7 +69,7 @@ namespace OpenRA.Mods.D2k.Traits.Render anim.Animation.PlayThen(info.Sequence, PlayDeliveryOverlay); } - public void BuildingComplete(Actor self) + void INotifyBuildComplete.BuildingComplete(Actor self) { self.World.AddFrameEndTask(w => w.Add(new DelayedAction(120, () => buildComplete = true))); @@ -81,7 +81,7 @@ namespace OpenRA.Mods.D2k.Traits.Render buildComplete = false; } - public void IncomingDelivery(Actor self) { delivering = true; PlayDeliveryOverlay(); } - public void Delivered(Actor self) { delivering = false; } + void INotifyDelivery.IncomingDelivery(Actor self) { delivering = true; PlayDeliveryOverlay(); } + void INotifyDelivery.Delivered(Actor self) { delivering = false; } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs index a00b8a0414..81006eecfc 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/GpsPower.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA.Traits }); } - public void Killed(Actor self, AttackInfo e) { RemoveGps(self); } + void INotifyKilled.Killed(Actor self, AttackInfo e) { RemoveGps(self); } void INotifySold.Selling(Actor self) { } void INotifySold.Sold(Actor self) { RemoveGps(self); } @@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA.Traits owner.GpsRemove(self); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { RemoveGps(self); owner = newOwner.PlayerActor.Trait(); @@ -105,7 +105,7 @@ namespace OpenRA.Mods.RA.Traits bool NoActiveRadar { get { return !self.World.ActorsHavingTrait(r => r.IsActive).Any(a => a.Owner == self.Owner); } } bool wasDisabled; - public void Tick(Actor self) + void ITick.Tick(Actor self) { if (!wasDisabled && (self.IsDisabled() || (info.RequiresActiveRadar && NoActiveRadar))) { From 437e142031ddd75672d6d1a11c8232d62df45e7f Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 18:45:59 +0200 Subject: [PATCH 5/8] Reservable style fixes --- .../Traits/Buildings/Reservable.cs | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs index 2ba201e2f7..863a0f65a8 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Reservable.cs @@ -25,12 +25,13 @@ namespace OpenRA.Mods.Common.Traits void ITick.Tick(Actor self) { + // Nothing to do. if (reservedFor == null) - return; /* nothing to do */ + return; if (!Target.FromActor(reservedFor).IsValidFor(self)) { - /* Not likely to arrive now. */ + // Not likely to arrive now. reservedForAircraft.UnReserve(); reservedFor = null; reservedForAircraft = null; @@ -64,28 +65,17 @@ namespace OpenRA.Mods.Common.Traits return res != null && res.reservedForAircraft != null && !res.reservedForAircraft.MayYieldReservation; } - void INotifyActorDisposing.Disposing(Actor self) + private void UnReserve() { if (reservedForAircraft != null) reservedForAircraft.UnReserve(); } - void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) - { - if (reservedForAircraft != null) - reservedForAircraft.UnReserve(); - } + void INotifyActorDisposing.Disposing(Actor self) { UnReserve(); } - void INotifySold.Selling(Actor self) - { - if (reservedForAircraft != null) - reservedForAircraft.UnReserve(); - } + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { UnReserve(); } - void INotifySold.Sold(Actor self) - { - if (reservedForAircraft != null) - reservedForAircraft.UnReserve(); - } + void INotifySold.Selling(Actor self) { UnReserve(); } + void INotifySold.Sold(Actor self) { UnReserve(); } } } From 0eb8def2b86dc6d23fd148c11de2a9c24d825ed5 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 18:46:49 +0200 Subject: [PATCH 6/8] Move Cargo interfaces to TraitsInterfaces --- OpenRA.Mods.Common/Traits/Cargo.cs | 6 ------ OpenRA.Mods.Common/TraitsInterfaces.cs | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Cargo.cs b/OpenRA.Mods.Common/Traits/Cargo.cs index 202f901220..854ba45bac 100644 --- a/OpenRA.Mods.Common/Traits/Cargo.cs +++ b/OpenRA.Mods.Common/Traits/Cargo.cs @@ -422,12 +422,6 @@ namespace OpenRA.Mods.Common.Traits } } - [RequireExplicitImplementation] - public interface INotifyPassengerEntered { void OnPassengerEntered(Actor self, Actor passenger); } - - [RequireExplicitImplementation] - public interface INotifyPassengerExited { void OnPassengerExited(Actor self, Actor passenger); } - public class RuntimeCargoInit : IActorInit, ISuppressInitExport { [FieldFromYamlKey] diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index bc06006e5e..f41b29452d 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -60,6 +60,12 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); } + [RequireExplicitImplementation] + public interface INotifyPassengerEntered { void OnPassengerEntered(Actor self, Actor passenger); } + + [RequireExplicitImplementation] + public interface INotifyPassengerExited { void OnPassengerExited(Actor self, Actor passenger); } + public interface IUpgradable { IEnumerable UpgradeTypes { get; } From 7235835280a65c1010345948e559631e54905539 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 19:24:15 +0200 Subject: [PATCH 7/8] Move ImpactType to Common.Warhead --- OpenRA.Game/Traits/TraitsInterfaces.cs | 14 -------------- OpenRA.Mods.Common/Warheads/Warhead.cs | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 7d3d622c95..66feb9aa24 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -66,20 +66,6 @@ namespace OpenRA.Traits } } - [Flags] - public enum ImpactType - { - None = 0, - Ground = 1, - GroundHit = 2, - Water = 4, - WaterHit = 8, - Air = 16, - AirHit = 32, - TargetTerrain = 64, - TargetHit = 128 - } - public class AttackInfo { public Damage Damage; diff --git a/OpenRA.Mods.Common/Warheads/Warhead.cs b/OpenRA.Mods.Common/Warheads/Warhead.cs index 03ef1c7a97..19e8e24069 100644 --- a/OpenRA.Mods.Common/Warheads/Warhead.cs +++ b/OpenRA.Mods.Common/Warheads/Warhead.cs @@ -9,12 +9,27 @@ */ #endregion +using System; using System.Collections.Generic; using System.Drawing; using OpenRA.Traits; namespace OpenRA.Mods.Common.Warheads { + [Flags] + public enum ImpactType + { + None = 0, + Ground = 1, + GroundHit = 2, + Water = 4, + WaterHit = 8, + Air = 16, + AirHit = 32, + TargetTerrain = 64, + TargetHit = 128 + } + [Desc("Base warhead class. This can be used to derive other warheads from.")] public abstract class Warhead : IWarhead { @@ -32,6 +47,7 @@ namespace OpenRA.Mods.Common.Warheads [Desc("Delay in ticks before applying the warhead effect.", "0 = instant (old model).")] public readonly int Delay = 0; + int IWarhead.Delay { get { return Delay; } } [Desc("The color used for this warhead's visualization in the world's `WarheadDebugOverlay` trait.")] From 72374279f07b539e530842e922872a49d7fd5cee Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 20 Oct 2016 19:47:45 +0200 Subject: [PATCH 8/8] Move interfaces that have no ties to the engine to mod code --- OpenRA.Game/Traits/TraitsInterfaces.cs | 30 ------------------- OpenRA.Mods.Common/TraitsInterfaces.cs | 30 +++++++++++++++++++ .../Infiltration/InfiltrateForDecoration.cs | 1 + .../Infiltration/InfiltrateForExploration.cs | 1 + .../Infiltration/InfiltrateForSupportPower.cs | 1 + 5 files changed, 33 insertions(+), 30 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 66feb9aa24..ec83ce99b6 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -131,20 +131,11 @@ namespace OpenRA.Traits public interface INotifyRemovedFromWorld { void RemovedFromWorld(Actor self); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } - public interface INotifyRepair { void Repairing(Actor self, Actor target); } public interface INotifyKilled { void Killed(Actor self, AttackInfo e); } public interface INotifyActorDisposing { void Disposing(Actor self); } public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } - public interface INotifyBuildComplete { void BuildingComplete(Actor self); } - public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); } - public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); } - public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); } - public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); } public interface INotifyOwnerChanged { void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner); } public interface INotifyEffectiveOwnerChanged { void OnEffectiveOwnerChanged(Actor self, Player oldEffectiveOwner, Player newEffectiveOwner); } - public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } - public interface INotifyInfiltrated { void Infiltrated(Actor self, Actor infiltrator); } - public interface INotifyDiscovered { void OnDiscovered(Actor self, Player discoverer, bool playNotification); } public interface ISeedableResource { void Seed(Actor self); } @@ -161,15 +152,7 @@ namespace OpenRA.Traits bool HasVoice(Actor self, string voice); } - public interface IDemolishableInfo : ITraitInfoInterface { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); } - public interface IDemolishable - { - void Demolish(Actor self, Actor saboteur); - bool IsValidTarget(Actor self, Actor saboteur); - } - public interface IStoreResources { int Capacity { get; } } - public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); } public interface IEffectiveOwner { @@ -312,19 +295,6 @@ namespace OpenRA.Traits public interface IFacingInfo : ITraitInfoInterface { int GetInitialFacing(); } - [RequireExplicitImplementation] - public interface ICrushable - { - bool CrushableBy(Actor self, Actor crusher, HashSet crushClasses); - } - - [RequireExplicitImplementation] - public interface INotifyCrushed - { - void OnCrush(Actor self, Actor crusher, HashSet crushClasses); - void WarnCrush(Actor self, Actor crusher, HashSet crushClasses); - } - public interface ITraitInfoInterface { } public interface ITraitInfo : ITraitInfoInterface { object Create(ActorInitializer init); } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index f41b29452d..906830150c 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -43,6 +43,26 @@ namespace OpenRA.Mods.Common.Traits void Sold(Actor self); } + public interface IDemolishableInfo : ITraitInfoInterface { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); } + public interface IDemolishable + { + void Demolish(Actor self, Actor saboteur); + bool IsValidTarget(Actor self, Actor saboteur); + } + + [RequireExplicitImplementation] + public interface ICrushable + { + bool CrushableBy(Actor self, Actor crusher, HashSet crushClasses); + } + + [RequireExplicitImplementation] + public interface INotifyCrushed + { + void OnCrush(Actor self, Actor crusher, HashSet crushClasses); + void WarnCrush(Actor self, Actor crusher, HashSet crushClasses); + } + [RequireExplicitImplementation] public interface INotifyAttack { @@ -50,10 +70,20 @@ namespace OpenRA.Mods.Common.Traits void PreparingAttack(Actor self, Target target, Armament a, Barrel barrel); } + public interface INotifyBuildComplete { void BuildingComplete(Actor self); } + public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); } + public interface INotifyRepair { void Repairing(Actor self, Actor target); } public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); } public interface INotifyCharging { void Charging(Actor self, Target target); } public interface INotifyChat { bool OnChat(string from, string message); } + public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); } + public interface INotifyOtherProduction { void UnitProducedByOther(Actor self, Actor producer, Actor produced); } + public interface INotifyDelivery { void IncomingDelivery(Actor self); void Delivered(Actor self); } + public interface INotifyDocking { void Docked(Actor self, Actor harvester); void Undocked(Actor self, Actor harvester); } public interface INotifyParachuteLanded { void OnLanded(Actor ignore); } + public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } + public interface INotifyInfiltrated { void Infiltrated(Actor self, Actor infiltrator); } + public interface INotifyDiscovered { void OnDiscovered(Actor self, Player discoverer, bool playNotification); } public interface IRenderActorPreviewInfo : ITraitInfo { IEnumerable RenderPreview(ActorPreviewInitializer init); } public interface ICruiseAltitudeInfo : ITraitInfo { WDist GetCruiseAltitude(); } diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForDecoration.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForDecoration.cs index ab7c6e7b9d..4a3bab997e 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForDecoration.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForDecoration.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; +using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits.Render; using OpenRA.Traits; diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForExploration.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForExploration.cs index ff52e9c157..85dfd86ef3 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForExploration.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForExploration.cs @@ -9,6 +9,7 @@ */ #endregion +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.RA.Traits diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForSupportPower.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForSupportPower.cs index 943bdbe722..2513a86d16 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForSupportPower.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForSupportPower.cs @@ -9,6 +9,7 @@ */ #endregion +using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; using OpenRA.Traits;