diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index a6c4340c15..53ba8cd825 100644 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -75,7 +75,6 @@ namespace OpenRA readonly IRenderModifier[] renderModifiers; readonly IRender[] renders; readonly IMouseBounds[] mouseBounds; - readonly IDisable[] disables; readonly IVisibilityModifier[] visibilityModifiers; readonly IDefaultVisibility defaultVisibility; @@ -116,7 +115,6 @@ namespace OpenRA renderModifiers = TraitsImplementing().ToArray(); renders = TraitsImplementing().ToArray(); mouseBounds = TraitsImplementing().ToArray(); - disables = TraitsImplementing().ToArray(); visibilityModifiers = TraitsImplementing().ToArray(); defaultVisibility = Trait(); Targetables = TraitsImplementing().ToArray(); @@ -325,18 +323,6 @@ namespace OpenRA health.Kill(this, attacker); } - /// - /// DEPRECATED! See . Use conditional traits and IsTraitDisabled instead. - /// - public bool IsDisabled() - { - // PERF: Avoid LINQ. - foreach (var disable in disables) - if (disable.Disabled) - return true; - return false; - } - public bool CanBeViewedByPlayer(Player player) { // PERF: Avoid LINQ. diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 83a24b357a..bcba7f4ccb 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -189,7 +189,6 @@ namespace OpenRA.Traits } public interface IDisabledTrait { bool IsTraitDisabled { get; } } - public interface IDisable { bool Disabled { get; } } public interface IDefaultVisibilityInfo : ITraitInfoInterface { } public interface IDefaultVisibility { bool IsVisible(Actor self, Player byPlayer); } diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index aff4ea017f..18e42542c5 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -507,7 +507,6 @@ - @@ -796,7 +795,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Conditions/DisableOnCondition.cs b/OpenRA.Mods.Common/Traits/Conditions/DisableOnCondition.cs deleted file mode 100644 index 5cdd8e8529..0000000000 --- a/OpenRA.Mods.Common/Traits/Conditions/DisableOnCondition.cs +++ /dev/null @@ -1,29 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2017 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Disable the actor when this trait is enabled by a condition.")] - public class DisableOnConditionInfo : ConditionalTraitInfo - { - public override object Create(ActorInitializer init) { return new DisableOnCondition(this); } - } - - public class DisableOnCondition : ConditionalTrait, IDisable - { - public DisableOnCondition(DisableOnConditionInfo info) - : base(info) { } - - public bool Disabled { get { return !IsTraitDisabled; } } - } -} diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDisabled.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDisabled.cs deleted file mode 100644 index 3ff89b9253..0000000000 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDisabled.cs +++ /dev/null @@ -1,65 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2017 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Applies a condition to the actor when it is disabled.", - "This is a temporary shim to help migration away from the legacy IDisable code")] - public class GrantConditionOnDisabledInfo : ITraitInfo - { - [FieldLoader.Require] - [GrantedConditionReference] - [Desc("Condition to grant.")] - public readonly string Condition = null; - - public object Create(ActorInitializer init) { return new GrantConditionOnDisabled(this); } - } - - public class GrantConditionOnDisabled : INotifyCreated, ITick - { - readonly GrantConditionOnDisabledInfo info; - - ConditionManager conditionManager; - int conditionToken = ConditionManager.InvalidConditionToken; - - public GrantConditionOnDisabled(GrantConditionOnDisabledInfo info) - { - this.info = info; - } - - void INotifyCreated.Created(Actor self) - { - conditionManager = self.TraitOrDefault(); - - // Set initial disabled state - Tick(self); - } - - void ITick.Tick(Actor self) - { - Tick(self); - } - - protected void Tick(Actor self) - { - if (conditionManager == null) - return; - - var disabled = self.IsDisabled(); - if (disabled && conditionToken == ConditionManager.InvalidConditionToken) - conditionToken = conditionManager.GrantCondition(self, info.Condition); - else if (!disabled && conditionToken != ConditionManager.InvalidConditionToken) - conditionToken = conditionManager.RevokeCondition(self, conditionToken); - } - } -} diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 0d4bdc08d5..51d347720d 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1547,6 +1547,28 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Removed IDisable interface and all remaining usages + if (engineVersion < 20171119) + { + var doc = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("DisableOnCondition", StringComparison.Ordinal)); + if (doc != null) + { + Console.WriteLine("Actor.IsDisabled has been removed in favor of pausing/disabling traits via conditions."); + Console.WriteLine("DisableOnCondition was a stop-gap solution that has been removed along with it."); + Console.WriteLine("You'll have to use RequiresCondition or PauseOnCondition on individual traits to 'disable' actors."); + node.Value.Nodes.Remove(doc); + } + + var grant = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("GrantConditionOnDisabled", StringComparison.Ordinal)); + if (grant != null) + { + Console.WriteLine("Actor.IsDisabled has been removed in favor of pausing/disabling traits via conditions."); + Console.WriteLine("GrantConditionOnDisabled was a stop-gap solution that has been removed along with it."); + Console.WriteLine("You'll have to use RequiresCondition or PauseOnCondition on individual traits to 'disable' actors."); + node.Value.Nodes.Remove(grant); + } + } + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 2e900df8a6..db8ca06929 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -92,8 +92,6 @@ WithColoredOverlay@EMPDISABLE: RequiresCondition: empdisable Palette: disabled - DisableOnCondition@EMPDISABLE: - RequiresCondition: empdisable TimedConditionBar@EMPDISABLE: Condition: empdisable Color: FFFFFF