From ad6ea52bffc8383cde659127eb278d71eb91891e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 22:13:08 +0200 Subject: [PATCH] Make IPowerModifier require explicit implementation Plus some 'collateral' explicit implementations on the affected traits. --- OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs | 6 ++++-- OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs | 4 ++-- OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs | 7 ++++--- OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs | 7 ++++--- OpenRA.Mods.Common/TraitsInterfaces.cs | 1 + 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs index cd07f34a77..04ac350055 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/PowerMultiplier.cs @@ -26,9 +26,11 @@ namespace OpenRA.Mods.Common.Traits public PowerMultiplier(Actor self, PowerMultiplierInfo info) : base(info, "PowerMultiplier", self.Info.Name) { power = self.Owner.PlayerActor.Trait(); } - public int GetPowerModifier() { return GetModifier(); } + int IPowerModifier.GetPowerModifier() { return GetModifier(); } + protected override void Update(Actor self) { power.UpdateActor(self); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { power = newOwner.PlayerActor.Trait(); } diff --git a/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs b/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs index 19d77e71df..6ef219e225 100644 --- a/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs +++ b/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits bool ISelectionBar.DisplayWhenEmpty { get { return false; } } - public int GetPowerModifier() + int IPowerModifier.GetPowerModifier() { return playerPower.PowerOutageRemainingTicks > 0 ? 0 : 100; } @@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits get { return playerPower.PowerOutageRemainingTicks > 0; } } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { playerPower = newOwner.PlayerActor.Trait(); } diff --git a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs index 1658476df3..0cbb9d9ef9 100644 --- a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs +++ b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits public bool Disabled { get { return disabled; } } - public void ResolveOrder(Actor self, Order order) + void IResolveOrder.ResolveOrder(Actor self, Order order) { if (!IsTraitDisabled && order.OrderString == "PowerDown") { @@ -72,12 +72,12 @@ namespace OpenRA.Mods.Common.Traits } } - public int GetPowerModifier() + int IPowerModifier.GetPowerModifier() { return !IsTraitDisabled && disabled ? 0 : 100; } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { power = newOwner.PlayerActor.Trait(); } @@ -86,6 +86,7 @@ namespace OpenRA.Mods.Common.Traits { if (!disabled || !Info.CancelWhenDisabled) return; + disabled = false; if (Info.PowerupSound != null) diff --git a/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs b/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs index dadfb4591d..3db7c0b728 100644 --- a/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs +++ b/OpenRA.Mods.Common/Traits/Power/ScalePowerWithHealth.cs @@ -30,13 +30,14 @@ namespace OpenRA.Mods.Common.Traits health = self.Trait(); } - public int GetPowerModifier() + int IPowerModifier.GetPowerModifier() { return 100 * health.HP / health.MaxHP; } - public void Damaged(Actor self, AttackInfo e) { power.UpdateActor(self); } - public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + void INotifyDamage.Damaged(Actor self, AttackInfo e) { power.UpdateActor(self); } + + void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { power = newOwner.PlayerActor.Trait(); } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index f15aa06eff..7df5be9111 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -223,5 +223,6 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface IRangeModifierInfo : ITraitInfoInterface { int GetRangeModifierDefault(); } + [RequireExplicitImplementation] public interface IPowerModifier { int GetPowerModifier(); } }