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)] [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class UpgradeGrantedReferenceAttribute : Attribute { } public sealed class GrantedConditionReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class UpgradeUsedReferenceAttribute : Attribute { } public sealed class ConsumedConditionReferenceAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Field)]
public sealed class PaletteDefinitionAttribute : Attribute public sealed class PaletteDefinitionAttribute : Attribute

View File

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

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Used together with ClassicProductionQueue.")] [Desc("Used together with ClassicProductionQueue.")]
public class PrimaryBuildingInfo : ITraitInfo public class PrimaryBuildingInfo : ITraitInfo
{ {
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while this is the primary building.")] [Desc("The condition to grant to self while this is the primary building.")]
public readonly string PrimaryCondition = null; 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.")] [Desc("Cursor to display when unable to unload the passengers.")]
public readonly string UnloadBlockedCursor = "deploy-blocked"; public readonly string UnloadBlockedCursor = "deploy-blocked";
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while waiting for cargo to load.")] [Desc("The condition to grant to self while waiting for cargo to load.")]
public readonly string LoadingCondition = null; public readonly string LoadingCondition = null;
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while passengers are loaded.", [Desc("The condition to grant to self while passengers are loaded.",
"Condition can stack with multiple passengers.")] "Condition can stack with multiple passengers.")]
public readonly string LoadedCondition = null; public readonly string LoadedCondition = null;
[UpgradeGrantedReference]
[Desc("Conditions to grant when specified actors are loaded inside the transport.", [Desc("Conditions to grant when specified actors are loaded inside the transport.",
"A dictionary of [actor id]: [condition].")] "A dictionary of [actor id]: [condition].")]
public readonly Dictionary<string, string> PassengerConditions = new Dictionary<string, string>(); 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); } 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.")] [Desc("Can be carried by actors with the `Carryall` trait.")]
public class CarryableInfo : UpgradableTraitInfo public class CarryableInfo : UpgradableTraitInfo
{ {
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while a carryall has been reserved.")] [Desc("The condition to grant to self while a carryall has been reserved.")]
public readonly string ReservedCondition = null; public readonly string ReservedCondition = null;
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while being carried.")] [Desc("The condition to grant to self while being carried.")]
public readonly string CarriedCondition = null; 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" }; public readonly HashSet<string> CloakTypes = new HashSet<string> { "Cloak" };
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while cloaked.")] [Desc("The condition to grant to self while cloaked.")]
public readonly string CloakedCondition = null; 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")] "Value is a list of the upgrade types to grant")]
public readonly Dictionary<int, string> Conditions = null; public readonly Dictionary<int, string> Conditions = null;
[GrantedConditionReference]
public IEnumerable<string> LinterConditions { get { return Conditions.Values; } }
[Desc("Palette for the level up sprite.")] [Desc("Palette for the level up sprite.")]
[PaletteReference] public readonly string LevelUpPalette = "effect"; [PaletteReference] public readonly string LevelUpPalette = "effect";

View File

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

View File

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

View File

@@ -20,10 +20,12 @@ namespace OpenRA.Mods.Common.Traits
public readonly CVec Offset = CVec.Zero; public readonly CVec Offset = CVec.Zero;
[FieldLoader.Require] [FieldLoader.Require]
[UpgradeGrantedReference]
[Desc("Conditions to grant for each accepted plug type.")] [Desc("Conditions to grant for each accepted plug type.")]
public readonly Dictionary<string, string> Conditions = null; 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); } 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.")] "Externally granted conditions that aren't explicitly whitelisted will be silently ignored.")]
public class ExternalConditionsInfo : TraitInfo<ExternalConditions> public class ExternalConditionsInfo : TraitInfo<ExternalConditions>
{ {
[UpgradeGrantedReference] [GrantedConditionReference]
public readonly string[] Conditions = { }; public readonly string[] Conditions = { };
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -17,12 +17,12 @@ namespace OpenRA.Mods.Common.Traits
public class StackedConditionInfo : TraitInfo<StackedCondition> public class StackedConditionInfo : TraitInfo<StackedCondition>
{ {
[FieldLoader.Require] [FieldLoader.Require]
[UpgradeUsedReference] [ConsumedConditionReference]
[Desc("Condition to monitor.")] [Desc("Condition to monitor.")]
public readonly string Condition = null; public readonly string Condition = null;
[FieldLoader.Require] [FieldLoader.Require]
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("Conditions to grant when the monitored condition is granted multiple times.", [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.")] "The first entry is activated at 2x grants, second entry at 3x grants, and so on.")]
public readonly string[] StackedConditions = { }; 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>()); 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.")] [Desc("Boolean expression defining the condition to enable this trait.")]
public readonly BooleanExpression RequiresCondition = null; 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.")] [Desc("The number of ticks it takes to get in place under the target to attack.")]
public readonly int AttackDelay = 30; public readonly int AttackDelay = 30;
[UpgradeGrantedReference] [GrantedConditionReference]
[Desc("The condition to grant to self while attacking.")] [Desc("The condition to grant to self while attacking.")]
public readonly string AttackingCondition = null; public readonly string AttackingCondition = null;

View File

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