Remove IDisable for good
This commit is contained in:
@@ -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<IRenderModifier>().ToArray();
|
||||
renders = TraitsImplementing<IRender>().ToArray();
|
||||
mouseBounds = TraitsImplementing<IMouseBounds>().ToArray();
|
||||
disables = TraitsImplementing<IDisable>().ToArray();
|
||||
visibilityModifiers = TraitsImplementing<IVisibilityModifier>().ToArray();
|
||||
defaultVisibility = Trait<IDefaultVisibility>();
|
||||
Targetables = TraitsImplementing<ITargetable>().ToArray();
|
||||
@@ -325,18 +323,6 @@ namespace OpenRA
|
||||
health.Kill(this, attacker);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DEPRECATED! See <see cref="http://bugs.openra.net/10237"/>. Use conditional traits and IsTraitDisabled instead.
|
||||
/// </summary>
|
||||
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.
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -507,7 +507,6 @@
|
||||
<Compile Include="Traits\Turreted.cs" />
|
||||
<Compile Include="Traits\ProducibleWithLevel.cs" />
|
||||
<Compile Include="Traits\Conditions\GrantConditionOnDeploy.cs" />
|
||||
<Compile Include="Traits\Conditions\DisableOnCondition.cs" />
|
||||
<Compile Include="Traits\Conditions\ConditionalTrait.cs" />
|
||||
<Compile Include="Traits\Conditions\PausableConditionalTrait.cs" />
|
||||
<Compile Include="Traits\Conditions\ProximityExternalCondition.cs" />
|
||||
@@ -796,7 +795,6 @@
|
||||
<Compile Include="UtilityCommands\OutputResolvedWeaponsCommand.cs" />
|
||||
<Compile Include="Traits\RevealOnDeath.cs" />
|
||||
<Compile Include="Traits\RevealOnFire.cs" />
|
||||
<Compile Include="Traits\Conditions\GrantConditionOnDisabled.cs" />
|
||||
<Compile Include="Traits\World\ActorMap.cs" />
|
||||
<Compile Include="Traits\World\TerrainTunnelLayer.cs" />
|
||||
<Compile Include="Traits\World\TerrainTunnel.cs" />
|
||||
|
||||
@@ -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<DisableOnConditionInfo>, IDisable
|
||||
{
|
||||
public DisableOnCondition(DisableOnConditionInfo info)
|
||||
: base(info) { }
|
||||
|
||||
public bool Disabled { get { return !IsTraitDisabled; } }
|
||||
}
|
||||
}
|
||||
@@ -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<ConditionManager>();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,8 +92,6 @@
|
||||
WithColoredOverlay@EMPDISABLE:
|
||||
RequiresCondition: empdisable
|
||||
Palette: disabled
|
||||
DisableOnCondition@EMPDISABLE:
|
||||
RequiresCondition: empdisable
|
||||
TimedConditionBar@EMPDISABLE:
|
||||
Condition: empdisable
|
||||
Color: FFFFFF
|
||||
|
||||
Reference in New Issue
Block a user