Replace UpgradeMinEnabledLevel checks with an EnabledByDefault shim.

This commit is contained in:
Paul Chote
2016-11-13 15:31:17 +00:00
parent e337048a97
commit 23f4ae5027
16 changed files with 49 additions and 21 deletions

View File

@@ -10,12 +10,14 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Support;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
/// <summary>Use as base class for *Info to subclass of UpgradableTrait. (See UpgradableTrait.)</summary>
public abstract class UpgradableTraitInfo : IUpgradableInfo
public abstract class UpgradableTraitInfo : IUpgradableInfo, IRulesetLoaded
{
[UpgradeUsedReference]
[Desc("The upgrade types which can enable or disable this trait.")]
@@ -34,6 +36,16 @@ namespace OpenRA.Mods.Common.Traits
public readonly int UpgradeMaxAcceptedLevel = 1;
public abstract object Create(ActorInitializer init);
// HACK: A shim for all the ActorPreview code that used to query UpgradeMinEnabledLevel directly
// This can go away after we introduce an InitialUpgrades ActorInit and have the traits query the
// condition directly
public bool EnabledByDefault { get; private set; }
public virtual void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
EnabledByDefault = UpgradeMinEnabledLevel < 1;
}
}
/// <summary>