Prepare condition attributes for new lint rule.

This commit is contained in:
Paul Chote
2016-12-14 13:25:28 +00:00
parent 28182ddc36
commit 024cc3db7e
20 changed files with 36 additions and 28 deletions

View File

@@ -46,11 +46,11 @@ namespace OpenRA.Traits
}
}
[AttributeUsage(AttributeTargets.Field)]
public sealed class UpgradeGrantedReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class GrantedConditionReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)]
public sealed class UpgradeUsedReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class ConsumedConditionReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)]
public sealed class PaletteDefinitionAttribute : Attribute

View File

@@ -52,11 +52,11 @@ namespace OpenRA.Mods.Common.Traits
[VoiceReference] public readonly string Voice = "Action";
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while airborne.")]
public readonly string AirborneCondition = null;
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while at cruise altitude.")]
public readonly string CruisingCondition = null;

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Used together with ClassicProductionQueue.")]
public class PrimaryBuildingInfo : ITraitInfo
{
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while this is the primary building.")]
public readonly string PrimaryCondition = null;

View File

@@ -55,20 +55,22 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Cursor to display when unable to unload the passengers.")]
public readonly string UnloadBlockedCursor = "deploy-blocked";
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while waiting for cargo to load.")]
public readonly string LoadingCondition = null;
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while passengers are loaded.",
"Condition can stack with multiple passengers.")]
public readonly string LoadedCondition = null;
[UpgradeGrantedReference]
[Desc("Conditions to grant when specified actors are loaded inside the transport.",
"A dictionary of [actor id]: [condition].")]
public readonly Dictionary<string, string> PassengerConditions = new Dictionary<string, string>();
[GrantedConditionReference]
public IEnumerable<string> LinterPassengerConditions { get { return PassengerConditions.Values; } }
public object Create(ActorInitializer init) { return new Cargo(init, this); }
}

View File

@@ -17,11 +17,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can be carried by actors with the `Carryall` trait.")]
public class CarryableInfo : UpgradableTraitInfo
{
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while a carryall has been reserved.")]
public readonly string ReservedCondition = null;
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while being carried.")]
public readonly string CarriedCondition = null;

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly HashSet<string> CloakTypes = new HashSet<string> { "Cloak" };
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while cloaked.")]
public readonly string CloakedCondition = null;

View File

@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Traits
"Value is a list of the upgrade types to grant")]
public readonly Dictionary<int, string> Conditions = null;
[GrantedConditionReference]
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }
[Desc("Palette for the level up sprite.")]
[PaletteReference] public readonly string LevelUpPalette = "effect";

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
public class GrantConditionOnPrerequisiteInfo : ITraitInfo
{
[FieldLoader.Require]
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant.")]
public readonly string Condition = null;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int FallRate = 13;
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while parachuting.")]
public readonly string ParachutingCondition = null;

View File

@@ -20,10 +20,12 @@ namespace OpenRA.Mods.Common.Traits
public readonly CVec Offset = CVec.Zero;
[FieldLoader.Require]
[UpgradeGrantedReference]
[Desc("Conditions to grant for each accepted plug type.")]
public readonly Dictionary<string, string> Conditions = null;
[GrantedConditionReference]
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }
public object Create(ActorInitializer init) { return new Pluggable(init, this); }
}

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
"Externally granted conditions that aren't explicitly whitelisted will be silently ignored.")]
public class ExternalConditionsInfo : TraitInfo<ExternalConditions>
{
[UpgradeGrantedReference]
[GrantedConditionReference]
public readonly string[] Conditions = { };
}

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
class GrantConditionInfo : UpgradableTraitInfo
{
[FieldLoader.Require]
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("Condition to grant.")]
public readonly string Condition = null;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
public class GrantConditionOnDamageStateInfo : ITraitInfo, Requires<HealthInfo>
{
[FieldLoader.Require]
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("Condition to grant.")]
public readonly string Condition = null;

View File

@@ -21,11 +21,12 @@ namespace OpenRA.Mods.Common.Traits
{
public class GrantConditionOnDeployInfo : ITraitInfo
{
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant while the actor is undeployed.")]
public readonly string UndeployedCondition = null;
[UpgradeGrantedReference, FieldLoader.Require]
[FieldLoader.Require]
[GrantedConditionReference]
[Desc("The condition to grant after deploying and revoke before undeploying.")]
public readonly string DeployedCondition = null;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
public class GrantConditionOnMovementInfo : UpgradableTraitInfo, Requires<IMoveInfo>
{
[FieldLoader.Require]
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("Condition to grant.")]
public readonly string Condition = null;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
public class GrantConditionOnTerrainInfo : ITraitInfo
{
[FieldLoader.Require]
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("Condition to grant.")]
public readonly string Condition = null;

View File

@@ -17,12 +17,12 @@ namespace OpenRA.Mods.Common.Traits
public class StackedConditionInfo : TraitInfo<StackedCondition>
{
[FieldLoader.Require]
[UpgradeUsedReference]
[ConsumedConditionReference]
[Desc("Condition to monitor.")]
public readonly string Condition = null;
[FieldLoader.Require]
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("Conditions to grant when the monitored condition is granted multiple times.",
"The first entry is activated at 2x grants, second entry at 3x grants, and so on.")]
public readonly string[] StackedConditions = { };

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
{
static readonly IReadOnlyDictionary<string, bool> NoConditions = new ReadOnlyDictionary<string, bool>(new Dictionary<string, bool>());
[UpgradeUsedReference]
[ConsumedConditionReference]
[Desc("Boolean expression defining the condition to enable this trait.")]
public readonly BooleanExpression RequiresCondition = null;

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.D2k.Traits
[Desc("The number of ticks it takes to get in place under the target to attack.")]
public readonly int AttackDelay = 30;
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while attacking.")]
public readonly string AttackingCondition = null;

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Traits
{
[VoiceReference] public readonly string Voice = "Action";
[UpgradeGrantedReference]
[GrantedConditionReference]
[Desc("The condition to grant to self while disguised.")]
public readonly string DisguisedCondition = null;