From 9dfddaf5d928314581342224ff98fecf182d7360 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 19:32:50 +0200 Subject: [PATCH 01/11] Move IRenderInfantrySequenceModifier to mod code and require explicit... implementation. --- OpenRA.Game/Traits/TraitsInterfaces.cs | 6 ------ OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs | 4 ++-- OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs | 10 +++++----- OpenRA.Mods.Common/TraitsInterfaces.cs | 7 +++++++ OpenRA.Mods.TS/Traits/Render/WithPermanentInjury.cs | 7 ++++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index b0741a0203..05c67c4dd8 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -321,12 +321,6 @@ namespace OpenRA.Traits public interface INotifyBecomingIdle { void OnBecomingIdle(Actor self); } public interface INotifyIdle { void TickIdle(Actor self); } - public interface IRenderInfantrySequenceModifier - { - bool IsModifyingSequence { get; } - string SequencePrefix { get; } - } - public interface IRenderAboveWorld { void RenderAboveWorld(Actor self, WorldRenderer wr); } public interface IRenderShroud { void RenderShroud(Shroud shroud, WorldRenderer wr); } public interface IRenderAboveShroud { IEnumerable RenderAboveShroud(Actor self, WorldRenderer wr); } diff --git a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs index 612c71fd5a..46ddd68359 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs @@ -38,8 +38,8 @@ namespace OpenRA.Mods.Common.Traits [Sync] int panicStartedTick; bool Panicking { get { return panicStartedTick > 0; } } - public bool IsModifyingSequence { get { return Panicking; } } - public string SequencePrefix { get { return info.PanicSequencePrefix; } } + bool IRenderInfantrySequenceModifier.IsModifyingSequence { get { return Panicking; } } + string IRenderInfantrySequenceModifier.SequencePrefix { get { return info.PanicSequencePrefix; } } public ScaredyCat(Actor self, ScaredyCatInfo info) { diff --git a/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs b/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs index b47204eab6..62d379e5c2 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/TakeCover.cs @@ -45,8 +45,8 @@ namespace OpenRA.Mods.Common.Traits [Sync] int remainingProneTime = 0; bool IsProne { get { return remainingProneTime > 0; } } - public bool IsModifyingSequence { get { return IsProne; } } - public string SequencePrefix { get { return info.ProneSequencePrefix; } } + bool IRenderInfantrySequenceModifier.IsModifyingSequence { get { return IsProne; } } + string IRenderInfantrySequenceModifier.SequencePrefix { get { return info.ProneSequencePrefix; } } public TakeCover(ActorInitializer init, TakeCoverInfo info) : base(init, info) @@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits this.info = info; } - public void Damaged(Actor self, AttackInfo e) + void INotifyDamage.Damaged(Actor self, AttackInfo e) { if (e.Damage.Value <= 0 || !e.Damage.DamageTypes.Overlaps(info.DamageTriggers)) return; @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits get { return true; } } - public int GetDamageModifier(Actor attacker, Damage damage) + int IDamageModifier.GetDamageModifier(Actor attacker, Damage damage) { if (!IsProne) return 100; @@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits return Util.ApplyPercentageModifiers(100, modifierPercentages); } - public int GetSpeedModifier() + int ISpeedModifier.GetSpeedModifier() { return IsProne ? info.SpeedModifier : 100; } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 2cc0a67c33..4c1b89effe 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -195,4 +195,11 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface INotifyRearm { void Rearming(Actor host, Actor other); } + + [RequireExplicitImplementation] + public interface IRenderInfantrySequenceModifier + { + bool IsModifyingSequence { get; } + string SequencePrefix { get; } + } } diff --git a/OpenRA.Mods.TS/Traits/Render/WithPermanentInjury.cs b/OpenRA.Mods.TS/Traits/Render/WithPermanentInjury.cs index 4417e20d71..c3eb9d0abf 100644 --- a/OpenRA.Mods.TS/Traits/Render/WithPermanentInjury.cs +++ b/OpenRA.Mods.TS/Traits/Render/WithPermanentInjury.cs @@ -9,6 +9,7 @@ */ #endregion +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.TS.Traits.Render @@ -29,15 +30,15 @@ namespace OpenRA.Mods.TS.Traits.Render bool isInjured; - public bool IsModifyingSequence { get { return isInjured; } } - public string SequencePrefix { get { return info.InjuredSequencePrefix; } } + bool IRenderInfantrySequenceModifier.IsModifyingSequence { get { return isInjured; } } + string IRenderInfantrySequenceModifier.SequencePrefix { get { return info.InjuredSequencePrefix; } } public WithPermanentInjury(ActorInitializer init, WithPermanentInjuryInfo info) { this.info = info; } - public void Damaged(Actor self, AttackInfo e) + void INotifyDamage.Damaged(Actor self, AttackInfo e) { if (e.DamageState == info.TriggeringDamageStage) isInjured = true; From f8077dc1132942f97f95e24a822079c69d70c79a Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 19:15:05 +0200 Subject: [PATCH 02/11] Move combat modifier interfaces (damage, speed etc.) to mod code --- OpenRA.Game/Traits/TraitsInterfaces.cs | 8 -------- OpenRA.Mods.Common/TraitsInterfaces.cs | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 05c67c4dd8..eeb343030e 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -233,14 +233,6 @@ namespace OpenRA.Traits } public interface IRenderModifier { IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r); } - public interface IDamageModifier { int GetDamageModifier(Actor attacker, Damage damage); } - public interface ISpeedModifier { int GetSpeedModifier(); } - public interface IFirepowerModifier { int GetFirepowerModifier(); } - public interface IReloadModifier { int GetReloadModifier(); } - public interface IInaccuracyModifier { int GetInaccuracyModifier(); } - public interface IRangeModifier { int GetRangeModifier(); } - public interface IRangeModifierInfo : ITraitInfoInterface { int GetRangeModifierDefault(); } - public interface IPowerModifier { int GetPowerModifier(); } public interface ILoadsPalettes { void LoadPalettes(WorldRenderer wr); } public interface ILoadsPlayerPalettes { void LoadPlayerPalettes(WorldRenderer wr, string playerName, HSLColor playerColor, bool replaceExisting); } public interface IPaletteModifier { void AdjustPalette(IReadOnlyDictionary b); } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 4c1b89effe..4bcf3f9bbb 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -202,4 +202,13 @@ namespace OpenRA.Mods.Common.Traits bool IsModifyingSequence { get; } string SequencePrefix { get; } } + + public interface IDamageModifier { int GetDamageModifier(Actor attacker, Damage damage); } + public interface ISpeedModifier { int GetSpeedModifier(); } + public interface IFirepowerModifier { int GetFirepowerModifier(); } + public interface IReloadModifier { int GetReloadModifier(); } + public interface IInaccuracyModifier { int GetInaccuracyModifier(); } + public interface IRangeModifier { int GetRangeModifier(); } + public interface IRangeModifierInfo : ITraitInfoInterface { int GetRangeModifierDefault(); } + public interface IPowerModifier { int GetPowerModifier(); } } From 97c2c24e8ddc33488ee681a7ccb499dd6f53b051 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 19:34:39 +0200 Subject: [PATCH 03/11] Require explicit implementation of IDamageModifier --- OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs | 2 +- OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs | 2 +- OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs b/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs index 1feba5c954..e8619bf553 100644 --- a/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs +++ b/OpenRA.Mods.Cnc/Traits/AttackPopupTurreted.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Cnc.Traits } } - public int GetDamageModifier(Actor attacker, Damage damage) + int IDamageModifier.GetDamageModifier(Actor attacker, Damage damage) { return state == PopupState.Closed ? info.ClosedDamageMultiplier : 100; } diff --git a/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs b/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs index c06d4a2262..185cfb7880 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits this.self = self; } - public int GetDamageModifier(Actor attacker, Damage damage) + int IDamageModifier.GetDamageModifier(Actor attacker, Damage damage) { if (attacker.Owner.IsAlliedWith(self.Owner) && damage.Value < 0 && !Info.ModifyHealing) return FullDamage; diff --git a/OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs index 87b107fe06..6ba58d0921 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/DamageMultiplier.cs @@ -26,6 +26,6 @@ namespace OpenRA.Mods.Common.Traits public DamageMultiplier(DamageMultiplierInfo info, string actorType) : base(info, "DamageMultiplier", actorType) { } - public int GetDamageModifier(Actor attacker, Damage damage) { return GetModifier(); } + int IDamageModifier.GetDamageModifier(Actor attacker, Damage damage) { return GetModifier(); } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 4bcf3f9bbb..357a73e954 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -203,6 +203,7 @@ namespace OpenRA.Mods.Common.Traits string SequencePrefix { get; } } + [RequireExplicitImplementation] public interface IDamageModifier { int GetDamageModifier(Actor attacker, Damage damage); } public interface ISpeedModifier { int GetSpeedModifier(); } public interface IFirepowerModifier { int GetFirepowerModifier(); } From 4af71341156c66d70a302bbcfd1b5129da85ccb1 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 20:10:49 +0200 Subject: [PATCH 04/11] 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(); } From fc2f006ec163a8beda8d9311d6edc5fff0507b97 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 20:21:22 +0200 Subject: [PATCH 05/11] Make IFirepowerModifier require explicit implementation --- OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs index 4f3d15d7a4..1d09992259 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs @@ -24,6 +24,6 @@ namespace OpenRA.Mods.Common.Traits public FirepowerMultiplier(FirepowerMultiplierInfo info, string actorType) : base(info, "FirepowerMultiplier", actorType) { } - public int GetFirepowerModifier() { return GetModifier(); } + int IFirepowerModifier.GetFirepowerModifier() { return GetModifier(); } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 34339ac0d5..0bd7fdbc78 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -208,6 +208,8 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface ISpeedModifier { int GetSpeedModifier(); } + + [RequireExplicitImplementation] public interface IFirepowerModifier { int GetFirepowerModifier(); } public interface IReloadModifier { int GetReloadModifier(); } public interface IInaccuracyModifier { int GetInaccuracyModifier(); } From 80d9241bbe43b818f89f4c4e6c55bc61d63286de Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 20:21:44 +0200 Subject: [PATCH 06/11] Make IReloadModifier require explicit implementation --- OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs index 8330ee7ffd..c8c9121bb4 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs @@ -24,6 +24,6 @@ namespace OpenRA.Mods.Common.Traits public ReloadDelayMultiplier(ReloadDelayMultiplierInfo info, string actorType) : base(info, "ReloadDelayMultiplier", actorType) { } - public int GetReloadModifier() { return GetModifier(); } + int IReloadModifier.GetReloadModifier() { return GetModifier(); } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 0bd7fdbc78..b2c3ffd62b 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -211,6 +211,8 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface IFirepowerModifier { int GetFirepowerModifier(); } + + [RequireExplicitImplementation] public interface IReloadModifier { int GetReloadModifier(); } public interface IInaccuracyModifier { int GetInaccuracyModifier(); } public interface IRangeModifier { int GetRangeModifier(); } From 02f14f07614156e521fe3e7f15a87eb4ac8dac5b Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 20:22:05 +0200 Subject: [PATCH 07/11] Make IInaccuracyModifier require explicit implementation --- OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs index 1af51f82dc..214147834b 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs @@ -24,6 +24,6 @@ namespace OpenRA.Mods.Common.Traits public InaccuracyMultiplier(InaccuracyMultiplierInfo info, string actorType) : base(info, "InaccuracyMultiplier", actorType) { } - public int GetInaccuracyModifier() { return GetModifier(); } + int IInaccuracyModifier.GetInaccuracyModifier() { return GetModifier(); } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index b2c3ffd62b..e698eecaf5 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -214,6 +214,8 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface IReloadModifier { int GetReloadModifier(); } + + [RequireExplicitImplementation] public interface IInaccuracyModifier { int GetInaccuracyModifier(); } public interface IRangeModifier { int GetRangeModifier(); } public interface IRangeModifierInfo : ITraitInfoInterface { int GetRangeModifierDefault(); } From 2d0560dcb72ad9a175eff7151fde72a1fa8bbc81 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 21:53:14 +0200 Subject: [PATCH 08/11] Make RangeModifier interfaces require explicit implementation --- OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs | 4 ++-- OpenRA.Mods.Common/TraitsInterfaces.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs index 6aa110e78d..496e00ae71 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits { public override object Create(ActorInitializer init) { return new RangeMultiplier(this, init.Self.Info.Name); } - public int GetRangeModifierDefault() + int IRangeModifierInfo.GetRangeModifierDefault() { return BaseLevel > 0 || UpgradeTypes.Length == 0 ? 100 : Modifier[0]; } @@ -29,6 +29,6 @@ namespace OpenRA.Mods.Common.Traits public RangeMultiplier(RangeMultiplierInfo info, string actorType) : base(info, "RangeMultiplier", actorType) { } - public int GetRangeModifier() { return GetModifier(); } + int IRangeModifier.GetRangeModifier() { return GetModifier(); } } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index e698eecaf5..f15aa06eff 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -217,7 +217,11 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface IInaccuracyModifier { int GetInaccuracyModifier(); } + + [RequireExplicitImplementation] public interface IRangeModifier { int GetRangeModifier(); } + [RequireExplicitImplementation] public interface IRangeModifierInfo : ITraitInfoInterface { int GetRangeModifierDefault(); } + public interface IPowerModifier { int GetPowerModifier(); } } From ad6ea52bffc8383cde659127eb278d71eb91891e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 22 Oct 2016 22:13:08 +0200 Subject: [PATCH 09/11] 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(); } } From 03fd591a00b62f6cebd817123d918d65d6d7e928 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 31 Oct 2016 21:12:41 +0100 Subject: [PATCH 10/11] Remove some unused usings --- OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs | 2 -- OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs | 2 -- OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs | 2 -- OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs | 2 -- OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs | 2 -- 5 files changed, 10 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs index 1d09992259..cead62c54b 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/FirepowerMultiplier.cs @@ -9,8 +9,6 @@ */ #endregion -using OpenRA.Traits; - namespace OpenRA.Mods.Common.Traits { [Desc("The firepower of this actor is multiplied based on upgrade level if specified.")] diff --git a/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs index 214147834b..c65d7e1f38 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/InaccuracyMultiplier.cs @@ -9,8 +9,6 @@ */ #endregion -using OpenRA.Traits; - namespace OpenRA.Mods.Common.Traits { [Desc("The inaccuracy of this actor is multiplied based on upgrade level if specified.")] diff --git a/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs index 496e00ae71..df857f759b 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/RangeMultiplier.cs @@ -9,8 +9,6 @@ */ #endregion -using OpenRA.Traits; - namespace OpenRA.Mods.Common.Traits { [Desc("Range of this actor is multiplied based on upgrade level.")] diff --git a/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs index c8c9121bb4..2a3806ab93 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/ReloadDelayMultiplier.cs @@ -9,8 +9,6 @@ */ #endregion -using OpenRA.Traits; - namespace OpenRA.Mods.Common.Traits { [Desc("The reloading time of this actor is multiplied based on upgrade level if specified.")] diff --git a/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs b/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs index f9935ca7d7..7528e8707a 100644 --- a/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs +++ b/OpenRA.Mods.Common/Traits/Multipliers/SpeedMultiplier.cs @@ -9,8 +9,6 @@ */ #endregion -using OpenRA.Traits; - namespace OpenRA.Mods.Common.Traits { [Desc("The speed of this actor is multiplied based on upgrade level if specified.")] From 162fef3da12dcf701539bdc1cd169cc42fe6ea20 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 5 Nov 2016 18:54:41 +0100 Subject: [PATCH 11/11] Fix style nit --- OpenRA.Mods.Common/TraitsInterfaces.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 7df5be9111..38044bd452 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -220,6 +220,7 @@ namespace OpenRA.Mods.Common.Traits [RequireExplicitImplementation] public interface IRangeModifier { int GetRangeModifier(); } + [RequireExplicitImplementation] public interface IRangeModifierInfo : ITraitInfoInterface { int GetRangeModifierDefault(); }