From 4af71341156c66d70a302bbcfd1b5129da85ccb1 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 20:10:49 +0200 Subject: [PATCH] Require explicit ISpeedModifier implementation Plus misc "collateral" explicit interfaces. --- OpenRA.Mods.Common/Traits/Harvester.cs | 4 ++-- OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs | 10 +++++----- .../Traits/Multipliers/SpeedMultiplier.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 9b0b0ff9ef..52dd7fddc1 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -447,9 +447,9 @@ namespace OpenRA.Mods.Common.Traits yield return GetPipAt(i); } - public bool ShouldExplode(Actor self) { return !IsEmpty; } + bool IExplodeModifier.ShouldExplode(Actor self) { return !IsEmpty; } - public int GetSpeedModifier() + int ISpeedModifier.GetSpeedModifier() { return 100 - (100 - Info.FullyLoadedSpeed) * contents.Values.Sum() / Info.Capacity; } diff --git a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs index 46ddd68359..89875bf2a3 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits mobile = self.Trait(); } - public void Panic() + void Panic() { if (!Panicking) self.CancelActivity(); @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits panicStartedTick = self.World.WorldTick; } - public void Tick(Actor self) + void ITick.Tick(Actor self) { if (!Panicking) return; @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits } } - public void TickIdle(Actor self) + void INotifyIdle.TickIdle(Actor self) { if (!Panicking) return; @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits mobile.Nudge(self, self, true); } - public void Damaged(Actor self, AttackInfo e) + void INotifyDamage.Damaged(Actor self, AttackInfo e) { if (e.Damage.Value > 0) Panic(); @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel) { } - public int GetSpeedModifier() + int ISpeedModifier.GetSpeedModifier() { return Panicking ? info.PanicSpeedModifier : 100; } diff --git a/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs index 8c64a0a06b..f9935ca7d7 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs @@ -24,6 +24,6 @@ namespace OpenRA.Mods.Common.Traits public SpeedMultiplier(SpeedMultiplierInfo info, string actorType) : base(info, "SpeedMultiplier", actorType) { } - public int GetSpeedModifier() { return GetModifier(); } + int ISpeedModifier.GetSpeedModifier() { return GetModifier(); } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 357a73e954..34339ac0d5 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -205,6 +205,8 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface IDamageModifier { int GetDamageModifier(Actor attacker, Damage damage); } + + [RequireExplicitImplementation] public interface ISpeedModifier { int GetSpeedModifier(); } public interface IFirepowerModifier { int GetFirepowerModifier(); } public interface IReloadModifier { int GetReloadModifier(); }