Rename UpgradableTrait to ConditionalTrait.

This commit is contained in:
Paul Chote
2016-12-23 23:28:34 +00:00
parent d0270ab866
commit 268ed016ab
57 changed files with 114 additions and 114 deletions

View File

@@ -493,7 +493,7 @@
<Compile Include="Traits\ProducibleWithLevel.cs" /> <Compile Include="Traits\ProducibleWithLevel.cs" />
<Compile Include="Traits\Upgrades\GrantConditionOnDeploy.cs" /> <Compile Include="Traits\Upgrades\GrantConditionOnDeploy.cs" />
<Compile Include="Traits\Upgrades\DisableOnCondition.cs" /> <Compile Include="Traits\Upgrades\DisableOnCondition.cs" />
<Compile Include="Traits\Upgrades\UpgradableTrait.cs" /> <Compile Include="Traits\Upgrades\ConditionalTrait.cs" />
<Compile Include="Traits\Upgrades\ProximityExternalCondition.cs" /> <Compile Include="Traits\Upgrades\ProximityExternalCondition.cs" />
<Compile Include="Traits\Upgrades\GrantConditionOnDamageState.cs" /> <Compile Include="Traits\Upgrades\GrantConditionOnDamageState.cs" />
<Compile Include="Traits\Upgrades\GrantConditionOnTerrain.cs" /> <Compile Include="Traits\Upgrades\GrantConditionOnTerrain.cs" />

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public abstract class AffectsShroudInfo : UpgradableTraitInfo public abstract class AffectsShroudInfo : ConditionalTraitInfo
{ {
public readonly WDist Range = WDist.Zero; public readonly WDist Range = WDist.Zero;
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly VisibilityType Type = VisibilityType.Footprint; public readonly VisibilityType Type = VisibilityType.Footprint;
} }
public abstract class AffectsShroud : UpgradableTrait<AffectsShroudInfo>, ITick, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld public abstract class AffectsShroud : ConditionalTrait<AffectsShroudInfo>, ITick, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld
{ {
static readonly PPos[] NoCells = { }; static readonly PPos[] NoCells = { };

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
} }
[Desc("Allows you to attach weapons to the unit (use @IdentifierSuffix for > 1)")] [Desc("Allows you to attach weapons to the unit (use @IdentifierSuffix for > 1)")]
public class ArmamentInfo : UpgradableTraitInfo, Requires<AttackBaseInfo> public class ArmamentInfo : ConditionalTraitInfo, Requires<AttackBaseInfo>
{ {
public readonly string Name = "primary"; public readonly string Name = "primary";
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
public class Armament : UpgradableTrait<ArmamentInfo>, ITick, IExplodeModifier public class Armament : ConditionalTrait<ArmamentInfo>, ITick, IExplodeModifier
{ {
public readonly WeaponInfo Weapon; public readonly WeaponInfo Weapon;
public readonly Barrel[] Barrels; public readonly Barrel[] Barrels;

View File

@@ -12,14 +12,14 @@
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Used to define weapon efficiency modifiers with different percentages per Type.")] [Desc("Used to define weapon efficiency modifiers with different percentages per Type.")]
public class ArmorInfo : UpgradableTraitInfo public class ArmorInfo : ConditionalTraitInfo
{ {
public readonly string Type = null; public readonly string Type = null;
public override object Create(ActorInitializer init) { return new Armor(init.Self, this); } public override object Create(ActorInitializer init) { return new Armor(init.Self, this); }
} }
public class Armor : UpgradableTrait<ArmorInfo> public class Armor : ConditionalTrait<ArmorInfo>
{ {
public Armor(Actor self, ArmorInfo info) public Armor(Actor self, ArmorInfo info)
: base(info) { } : base(info) { }

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public abstract class AttackBaseInfo : UpgradableTraitInfo public abstract class AttackBaseInfo : ConditionalTraitInfo
{ {
[Desc("Armament names")] [Desc("Armament names")]
public readonly string[] Armaments = { "primary", "secondary" }; public readonly string[] Armaments = { "primary", "secondary" };
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
public override abstract object Create(ActorInitializer init); public override abstract object Create(ActorInitializer init);
} }
public abstract class AttackBase : UpgradableTrait<AttackBaseInfo>, IIssueOrder, IResolveOrder, IOrderVoice, ISync public abstract class AttackBase : ConditionalTrait<AttackBaseInfo>, IIssueOrder, IResolveOrder, IOrderVoice, ISync
{ {
readonly string attackOrderName = "Attack"; readonly string attackOrderName = "Attack";
readonly string forceAttackOrderName = "ForceAttack"; readonly string forceAttackOrderName = "ForceAttack";

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("The actor will automatically engage the enemy when it is in range.")] [Desc("The actor will automatically engage the enemy when it is in range.")]
public class AutoTargetInfo : UpgradableTraitInfo, Requires<AttackBaseInfo>, UsesInit<StanceInit> public class AutoTargetInfo : ConditionalTraitInfo, Requires<AttackBaseInfo>, UsesInit<StanceInit>
{ {
[Desc("It will try to hunt down the enemy if it is not set to defend.")] [Desc("It will try to hunt down the enemy if it is not set to defend.")]
public readonly bool AllowMovement = true; public readonly bool AllowMovement = true;
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
public enum UnitStance { HoldFire, ReturnFire, Defend, AttackAnything } public enum UnitStance { HoldFire, ReturnFire, Defend, AttackAnything }
public class AutoTarget : UpgradableTrait<AutoTargetInfo>, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync public class AutoTarget : ConditionalTrait<AutoTargetInfo>, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync
{ {
readonly AttackBase[] attackBases; readonly AttackBase[] attackBases;
readonly AttackFollow[] attackFollows; readonly AttackFollow[] attackFollows;

View File

@@ -21,14 +21,14 @@ namespace OpenRA.Mods.Common.Traits
} }
[Desc("This actor blocks bullets and missiles with 'Blockable' property.")] [Desc("This actor blocks bullets and missiles with 'Blockable' property.")]
public class BlocksProjectilesInfo : UpgradableTraitInfo public class BlocksProjectilesInfo : ConditionalTraitInfo
{ {
public readonly WDist Height = WDist.FromCells(1); public readonly WDist Height = WDist.FromCells(1);
public override object Create(ActorInitializer init) { return new BlocksProjectiles(init.Self, this); } public override object Create(ActorInitializer init) { return new BlocksProjectiles(init.Self, this); }
} }
public class BlocksProjectiles : UpgradableTrait<BlocksProjectilesInfo>, IBlocksProjectiles public class BlocksProjectiles : ConditionalTrait<BlocksProjectilesInfo>, IBlocksProjectiles
{ {
public BlocksProjectiles(Actor self, BlocksProjectilesInfo info) public BlocksProjectiles(Actor self, BlocksProjectilesInfo info)
: base(info) { } : base(info) { }

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Building can be repaired by the repair button.")] [Desc("Building can be repaired by the repair button.")]
public class RepairableBuildingInfo : UpgradableTraitInfo, Requires<HealthInfo> public class RepairableBuildingInfo : ConditionalTraitInfo, Requires<HealthInfo>
{ {
public readonly int RepairPercent = 20; public readonly int RepairPercent = 20;
public readonly int RepairInterval = 24; public readonly int RepairInterval = 24;
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); } public override object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); }
} }
public class RepairableBuilding : UpgradableTrait<RepairableBuildingInfo>, ITick public class RepairableBuilding : ConditionalTrait<RepairableBuildingInfo>, ITick
{ {
[Sync] [Sync]
public int RepairersHash public int RepairersHash

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits 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 : ConditionalTraitInfo
{ {
[GrantedConditionReference] [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.")]
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Carryable(init.Self, this); } public override object Create(ActorInitializer init) { return new Carryable(init.Self, this); }
} }
public class Carryable : UpgradableTrait<CarryableInfo> public class Carryable : ConditionalTrait<CarryableInfo>
{ {
ConditionManager conditionManager; ConditionManager conditionManager;
int reservedToken = ConditionManager.InvalidConditionToken; int reservedToken = ConditionManager.InvalidConditionToken;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
} }
[Desc("This unit can cloak and uncloak in specific situations.")] [Desc("This unit can cloak and uncloak in specific situations.")]
public class CloakInfo : UpgradableTraitInfo public class CloakInfo : ConditionalTraitInfo
{ {
[Desc("Measured in game ticks.")] [Desc("Measured in game ticks.")]
public readonly int InitialDelay = 10; public readonly int InitialDelay = 10;
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Cloak(this); } public override object Create(ActorInitializer init) { return new Cloak(this); }
} }
public class Cloak : UpgradableTrait<CloakInfo>, IRenderModifier, INotifyDamage, public class Cloak : ConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage,
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction
{ {
[Sync] int remainingTime; [Sync] int remainingTime;

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("This actor receives damage from the given weapon when on the specified terrain type.")] [Desc("This actor receives damage from the given weapon when on the specified terrain type.")]
class DamagedByTerrainInfo : UpgradableTraitInfo, Requires<HealthInfo> class DamagedByTerrainInfo : ConditionalTraitInfo, Requires<HealthInfo>
{ {
[Desc("Amount of damage received per DamageInterval ticks.")] [Desc("Amount of damage received per DamageInterval ticks.")]
[FieldLoader.Require] public readonly int Damage = 0; [FieldLoader.Require] public readonly int Damage = 0;
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new DamagedByTerrain(init.Self, this); } public override object Create(ActorInitializer init) { return new DamagedByTerrain(init.Self, this); }
} }
class DamagedByTerrain : UpgradableTrait<DamagedByTerrainInfo>, ITick, ISync, INotifyAddedToWorld class DamagedByTerrain : ConditionalTrait<DamagedByTerrainInfo>, ITick, ISync, INotifyAddedToWorld
{ {
readonly Health health; readonly Health health;

View File

@@ -14,7 +14,7 @@ using System.Collections.Generic;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Actor can reveal Cloak actors in a specified range.")] [Desc("Actor can reveal Cloak actors in a specified range.")]
public class DetectCloakedInfo : UpgradableTraitInfo public class DetectCloakedInfo : ConditionalTraitInfo
{ {
[Desc("Specific cloak classifications I can reveal.")] [Desc("Specific cloak classifications I can reveal.")]
public readonly HashSet<string> CloakTypes = new HashSet<string> { "Cloak" }; public readonly HashSet<string> CloakTypes = new HashSet<string> { "Cloak" };
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new DetectCloaked(this); } public override object Create(ActorInitializer init) { return new DetectCloaked(this); }
} }
public class DetectCloaked : UpgradableTrait<DetectCloakedInfo> public class DetectCloaked : ConditionalTrait<DetectCloakedInfo>
{ {
public DetectCloaked(DetectCloakedInfo info) : base(info) { } public DetectCloaked(DetectCloakedInfo info) : base(info) { }
} }

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
class KillsSelfInfo : UpgradableTraitInfo class KillsSelfInfo : ConditionalTraitInfo
{ {
[Desc("Remove the actor from the world (and destroy it) instead of killing it.")] [Desc("Remove the actor from the world (and destroy it) instead of killing it.")]
public readonly bool RemoveInstead = false; public readonly bool RemoveInstead = false;
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new KillsSelf(this); } public override object Create(ActorInitializer init) { return new KillsSelf(this); }
} }
class KillsSelf : UpgradableTrait<KillsSelfInfo>, INotifyAddedToWorld class KillsSelf : ConditionalTrait<KillsSelfInfo>, INotifyAddedToWorld
{ {
public KillsSelf(KillsSelfInfo info) public KillsSelf(KillsSelfInfo info)
: base(info) { } : base(info) { }

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
} }
[Desc("Unit is able to move.")] [Desc("Unit is able to move.")]
public class MobileInfo : UpgradableTraitInfo, IMoveInfo, IPositionableInfo, IOccupySpaceInfo, IFacingInfo, public class MobileInfo : ConditionalTraitInfo, IMoveInfo, IPositionableInfo, IOccupySpaceInfo, IFacingInfo,
UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit> UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
{ {
[FieldLoader.LoadUsing("LoadSpeeds", true)] [FieldLoader.LoadUsing("LoadSpeeds", true)]
@@ -317,7 +317,7 @@ namespace OpenRA.Mods.Common.Traits
bool IOccupySpaceInfo.SharesCell { get { return SharesCell; } } bool IOccupySpaceInfo.SharesCell { get { return SharesCell; } }
} }
public class Mobile : UpgradableTrait<MobileInfo>, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync, public class Mobile : ConditionalTrait<MobileInfo>, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync,
IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier
{ {
const int AverageTicksBeforePathing = 5; const int AverageTicksBeforePathing = 5;

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Display a colored overlay when a timed upgrade is active.")] [Desc("Display a colored overlay when a timed upgrade is active.")]
public class UpgradeOverlayInfo : UpgradableTraitInfo public class UpgradeOverlayInfo : ConditionalTraitInfo
{ {
[Desc("Palette to use when rendering the overlay")] [Desc("Palette to use when rendering the overlay")]
[PaletteReference] public readonly string Palette = "invuln"; [PaletteReference] public readonly string Palette = "invuln";
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new UpgradeOverlay(this); } public override object Create(ActorInitializer init) { return new UpgradeOverlay(this); }
} }
public class UpgradeOverlay : UpgradableTrait<UpgradeOverlayInfo>, IRenderModifier public class UpgradeOverlay : ConditionalTrait<UpgradeOverlayInfo>, IRenderModifier
{ {
public UpgradeOverlay(UpgradeOverlayInfo info) public UpgradeOverlay(UpgradeOverlayInfo info)
: base(info) { } : base(info) { }

View File

@@ -15,7 +15,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the damage applied to this actor.", [Desc("Modifies the damage applied to this actor.",
"Use 0 to make actor invulnerable.")] "Use 0 to make actor invulnerable.")]
public class DamageMultiplierInfo : UpgradableTraitInfo public class DamageMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new DamageMultiplier(this); } public override object Create(ActorInitializer init) { return new DamageMultiplier(this); }
} }
public class DamageMultiplier : UpgradableTrait<DamageMultiplierInfo>, IDamageModifier public class DamageMultiplier : ConditionalTrait<DamageMultiplierInfo>, IDamageModifier
{ {
public DamageMultiplier(DamageMultiplierInfo info) public DamageMultiplier(DamageMultiplierInfo info)
: base(info) { } : base(info) { }

View File

@@ -12,7 +12,7 @@
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the damage applied by this actor.")] [Desc("Modifies the damage applied by this actor.")]
public class FirepowerMultiplierInfo : UpgradableTraitInfo public class FirepowerMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new FirepowerMultiplier(this); } public override object Create(ActorInitializer init) { return new FirepowerMultiplier(this); }
} }
public class FirepowerMultiplier : UpgradableTrait<FirepowerMultiplierInfo>, IFirepowerModifier public class FirepowerMultiplier : ConditionalTrait<FirepowerMultiplierInfo>, IFirepowerModifier
{ {
public FirepowerMultiplier(FirepowerMultiplierInfo info) public FirepowerMultiplier(FirepowerMultiplierInfo info)
: base(info) { } : base(info) { }

View File

@@ -12,7 +12,7 @@
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the inaccuracy of weapons fired by this actor.")] [Desc("Modifies the inaccuracy of weapons fired by this actor.")]
public class InaccuracyMultiplierInfo : UpgradableTraitInfo public class InaccuracyMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new InaccuracyMultiplier(this); } public override object Create(ActorInitializer init) { return new InaccuracyMultiplier(this); }
} }
public class InaccuracyMultiplier : UpgradableTrait<InaccuracyMultiplierInfo>, IInaccuracyModifier public class InaccuracyMultiplier : ConditionalTrait<InaccuracyMultiplierInfo>, IInaccuracyModifier
{ {
public InaccuracyMultiplier(InaccuracyMultiplierInfo info) public InaccuracyMultiplier(InaccuracyMultiplierInfo info)
: base(info) { } : base(info) { }

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the power usage/output of this actor.")] [Desc("Modifies the power usage/output of this actor.")]
public class PowerMultiplierInfo : UpgradableTraitInfo public class PowerMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new PowerMultiplier(init.Self, this); } public override object Create(ActorInitializer init) { return new PowerMultiplier(init.Self, this); }
} }
public class PowerMultiplier : UpgradableTrait<PowerMultiplierInfo>, IPowerModifier, INotifyOwnerChanged public class PowerMultiplier : ConditionalTrait<PowerMultiplierInfo>, IPowerModifier, INotifyOwnerChanged
{ {
PowerManager power; PowerManager power;

View File

@@ -12,7 +12,7 @@
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the range of weapons fired by this actor.")] [Desc("Modifies the range of weapons fired by this actor.")]
public class RangeMultiplierInfo : UpgradableTraitInfo public class RangeMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new RangeMultiplier(this); } public override object Create(ActorInitializer init) { return new RangeMultiplier(this); }
} }
public class RangeMultiplier : UpgradableTrait<RangeMultiplierInfo>, IRangeModifierInfo public class RangeMultiplier : ConditionalTrait<RangeMultiplierInfo>, IRangeModifierInfo
{ {
public RangeMultiplier(RangeMultiplierInfo info) public RangeMultiplier(RangeMultiplierInfo info)
: base(info) { } : base(info) { }

View File

@@ -12,7 +12,7 @@
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the reload time of weapons fired by this actor.")] [Desc("Modifies the reload time of weapons fired by this actor.")]
public class ReloadDelayMultiplierInfo : UpgradableTraitInfo public class ReloadDelayMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new ReloadDelayMultiplier(this); } public override object Create(ActorInitializer init) { return new ReloadDelayMultiplier(this); }
} }
public class ReloadDelayMultiplier : UpgradableTrait<ReloadDelayMultiplierInfo>, IReloadModifier public class ReloadDelayMultiplier : ConditionalTrait<ReloadDelayMultiplierInfo>, IReloadModifier
{ {
public ReloadDelayMultiplier(ReloadDelayMultiplierInfo info) public ReloadDelayMultiplier(ReloadDelayMultiplierInfo info)
: base(info) { } : base(info) { }

View File

@@ -12,7 +12,7 @@
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Modifies the movement speed of this actor.")] [Desc("Modifies the movement speed of this actor.")]
public class SpeedMultiplierInfo : UpgradableTraitInfo public class SpeedMultiplierInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[Desc("Percentage modifier to apply.")] [Desc("Percentage modifier to apply.")]
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new SpeedMultiplier(this); } public override object Create(ActorInitializer init) { return new SpeedMultiplier(this); }
} }
public class SpeedMultiplier : UpgradableTrait<SpeedMultiplierInfo>, ISpeedModifier public class SpeedMultiplier : ConditionalTrait<SpeedMultiplierInfo>, ISpeedModifier
{ {
public SpeedMultiplier(SpeedMultiplierInfo info) public SpeedMultiplier(SpeedMultiplierInfo info)
: base(info) { } : base(info) { }

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("The player can disable the power individually on this actor.")] [Desc("The player can disable the power individually on this actor.")]
public class CanPowerDownInfo : UpgradableTraitInfo, Requires<PowerInfo> public class CanPowerDownInfo : ConditionalTraitInfo, Requires<PowerInfo>
{ {
[Desc("Restore power when this trait is disabled.")] [Desc("Restore power when this trait is disabled.")]
public readonly bool CancelWhenDisabled = false; public readonly bool CancelWhenDisabled = false;
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); } public override object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); }
} }
public class CanPowerDown : UpgradableTrait<CanPowerDownInfo>, IPowerModifier, IResolveOrder, IDisable, INotifyOwnerChanged public class CanPowerDown : ConditionalTrait<CanPowerDownInfo>, IPowerModifier, IResolveOrder, IDisable, INotifyOwnerChanged
{ {
[Sync] bool disabled = false; [Sync] bool disabled = false;
PowerManager power; PowerManager power;

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public class PowerInfo : UpgradableTraitInfo public class PowerInfo : ConditionalTraitInfo
{ {
[Desc("If negative, it will drain power. If positive, it will provide power.")] [Desc("If negative, it will drain power. If positive, it will provide power.")]
public readonly int Amount = 0; public readonly int Amount = 0;
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Power(init.Self, this); } public override object Create(ActorInitializer init) { return new Power(init.Self, this); }
} }
public class Power : UpgradableTrait<PowerInfo>, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged public class Power : ConditionalTrait<PowerInfo>, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged
{ {
readonly Lazy<IPowerModifier[]> powerModifiers; readonly Lazy<IPowerModifier[]> powerModifiers;

View File

@@ -14,12 +14,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Needs power to operate.")] [Desc("Needs power to operate.")]
class RequiresPowerInfo : UpgradableTraitInfo, ITraitInfo class RequiresPowerInfo : ConditionalTraitInfo, ITraitInfo
{ {
public override object Create(ActorInitializer init) { return new RequiresPower(init.Self, this); } public override object Create(ActorInitializer init) { return new RequiresPower(init.Self, this); }
} }
class RequiresPower : UpgradableTrait<RequiresPowerInfo>, IDisable, INotifyOwnerChanged class RequiresPower : ConditionalTrait<RequiresPowerInfo>, IDisable, INotifyOwnerChanged
{ {
PowerManager playerPower; PowerManager playerPower;

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Derive facings from sprite body sequence.")] [Desc("Derive facings from sprite body sequence.")]
public class QuantizeFacingsFromSequenceInfo : UpgradableTraitInfo, IQuantizeBodyOrientationInfo, Requires<RenderSpritesInfo> public class QuantizeFacingsFromSequenceInfo : ConditionalTraitInfo, IQuantizeBodyOrientationInfo, Requires<RenderSpritesInfo>
{ {
[Desc("Defines sequence to derive facings from."), SequenceReference] [Desc("Defines sequence to derive facings from."), SequenceReference]
public readonly string Sequence = "idle"; public readonly string Sequence = "idle";
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new QuantizeFacingsFromSequence(this); } public override object Create(ActorInitializer init) { return new QuantizeFacingsFromSequence(this); }
} }
public class QuantizeFacingsFromSequence : UpgradableTrait<QuantizeFacingsFromSequenceInfo> public class QuantizeFacingsFromSequence : ConditionalTrait<QuantizeFacingsFromSequenceInfo>
{ {
public QuantizeFacingsFromSequence(QuantizeFacingsFromSequenceInfo info) public QuantizeFacingsFromSequence(QuantizeFacingsFromSequenceInfo info)
: base(info) { } : base(info) { }

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Can be used to make a unit partly uncontrollable by the player.")] [Desc("Can be used to make a unit partly uncontrollable by the player.")]
public class RejectsOrdersInfo : UpgradableTraitInfo public class RejectsOrdersInfo : ConditionalTraitInfo
{ {
[Desc("Possible values include Attack, AttackMove, Guard, Move.")] [Desc("Possible values include Attack, AttackMove, Guard, Move.")]
public readonly HashSet<string> Except = new HashSet<string>(); public readonly HashSet<string> Except = new HashSet<string>();
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new RejectsOrders(this); } public override object Create(ActorInitializer init) { return new RejectsOrders(this); }
} }
public class RejectsOrders : UpgradableTrait<RejectsOrdersInfo> public class RejectsOrders : ConditionalTrait<RejectsOrdersInfo>
{ {
public HashSet<string> Except { get { return Info.Except; } } public HashSet<string> Except { get { return Info.Except; } }

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Changes the visual Z position periodically.")] [Desc("Changes the visual Z position periodically.")]
public class HoversInfo : UpgradableTraitInfo, Requires<IMoveInfo> public class HoversInfo : ConditionalTraitInfo, Requires<IMoveInfo>
{ {
[Desc("Amount of Z axis changes in world units.")] [Desc("Amount of Z axis changes in world units.")]
public readonly int OffsetModifier = -43; public readonly int OffsetModifier = -43;
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override object Create(ActorInitializer init) { return new Hovers(this, init.Self); } public override object Create(ActorInitializer init) { return new Hovers(this, init.Self); }
} }
public class Hovers : UpgradableTrait<HoversInfo>, IRenderModifier public class Hovers : ConditionalTrait<HoversInfo>, IRenderModifier
{ {
readonly HoversInfo info; readonly HoversInfo info;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public enum TrailType { Cell, CenterPosition } public enum TrailType { Cell, CenterPosition }
[Desc("Renders a sprite effect when leaving a cell.")] [Desc("Renders a sprite effect when leaving a cell.")]
public class LeavesTrailsInfo : UpgradableTraitInfo public class LeavesTrailsInfo : ConditionalTraitInfo
{ {
public readonly string Image = null; public readonly string Image = null;
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override object Create(ActorInitializer init) { return new LeavesTrails(init.Self, this); } public override object Create(ActorInitializer init) { return new LeavesTrails(init.Self, this); }
} }
public class LeavesTrails : UpgradableTrait<LeavesTrailsInfo>, ITick public class LeavesTrails : ConditionalTrait<LeavesTrailsInfo>, ITick
{ {
BodyOrientation body; BodyOrientation body;
IFacing facing; IFacing facing;

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
[Desc("Displays a custom UI overlay relative to the selection box.")] [Desc("Displays a custom UI overlay relative to the selection box.")]
public class WithDecorationInfo : UpgradableTraitInfo public class WithDecorationInfo : ConditionalTraitInfo
{ {
[Desc("Image used for this decoration. Defaults to the actor's type.")] [Desc("Image used for this decoration. Defaults to the actor's type.")]
public readonly string Image = null; public readonly string Image = null;
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override object Create(ActorInitializer init) { return new WithDecoration(init.Self, this); } public override object Create(ActorInitializer init) { return new WithDecoration(init.Self, this); }
} }
public class WithDecoration : UpgradableTrait<WithDecorationInfo>, ITick, IRenderAboveShroud, IRenderAboveShroudWhenSelected public class WithDecoration : ConditionalTrait<WithDecorationInfo>, ITick, IRenderAboveShroud, IRenderAboveShroudWhenSelected
{ {
protected readonly Animation Anim; protected readonly Animation Anim;

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Periodically plays an idle animation, replacing the default body animation.")] [Desc("Periodically plays an idle animation, replacing the default body animation.")]
public class WithIdleAnimationInfo : UpgradableTraitInfo, Requires<WithSpriteBodyInfo> public class WithIdleAnimationInfo : ConditionalTraitInfo, Requires<WithSpriteBodyInfo>
{ {
[SequenceReference, Desc("Sequence names to use.")] [SequenceReference, Desc("Sequence names to use.")]
public readonly string[] Sequences = { "active" }; public readonly string[] Sequences = { "active" };
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override object Create(ActorInitializer init) { return new WithIdleAnimation(init.Self, this); } public override object Create(ActorInitializer init) { return new WithIdleAnimation(init.Self, this); }
} }
public class WithIdleAnimation : UpgradableTrait<WithIdleAnimationInfo>, ITick, INotifyBuildComplete, INotifySold public class WithIdleAnimation : ConditionalTrait<WithIdleAnimationInfo>, ITick, INotifyBuildComplete, INotifySold
{ {
readonly WithSpriteBody wsb; readonly WithSpriteBody wsb;
bool buildComplete; bool buildComplete;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders a decorative animation on units and buildings.")] [Desc("Renders a decorative animation on units and buildings.")]
public class WithIdleOverlayInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo> public class WithIdleOverlayInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Animation to play when the actor is created.")] [Desc("Animation to play when the actor is created.")]
[SequenceReference] public readonly string StartSequence = null; [SequenceReference] public readonly string StartSequence = null;
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithIdleOverlay : UpgradableTrait<WithIdleOverlayInfo>, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyTransform public class WithIdleOverlay : ConditionalTrait<WithIdleOverlayInfo>, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyTransform
{ {
readonly Animation overlay; readonly Animation overlay;
bool buildComplete; bool buildComplete;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
public class WithInfantryBodyInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<IMoveInfo>, Requires<RenderSpritesInfo> public class WithInfantryBodyInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<IMoveInfo>, Requires<RenderSpritesInfo>
{ {
public readonly int MinIdleDelay = 30; public readonly int MinIdleDelay = 30;
public readonly int MaxIdleDelay = 110; public readonly int MaxIdleDelay = 110;
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithInfantryBody : UpgradableTrait<WithInfantryBodyInfo>, ITick, INotifyAttack, INotifyIdle public class WithInfantryBody : ConditionalTrait<WithInfantryBodyInfo>, ITick, INotifyAttack, INotifyIdle
{ {
readonly IMove move; readonly IMove move;
protected readonly Animation DefaultAnimation; protected readonly Animation DefaultAnimation;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders the MuzzleSequence from the Armament trait.")] [Desc("Renders the MuzzleSequence from the Armament trait.")]
class WithMuzzleOverlayInfo : UpgradableTraitInfo, Requires<RenderSpritesInfo>, Requires<AttackBaseInfo>, Requires<ArmamentInfo> class WithMuzzleOverlayInfo : ConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<AttackBaseInfo>, Requires<ArmamentInfo>
{ {
[Desc("Ignore the weapon position, and always draw relative to the center of the actor")] [Desc("Ignore the weapon position, and always draw relative to the center of the actor")]
public readonly bool IgnoreOffset = false; public readonly bool IgnoreOffset = false;
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override object Create(ActorInitializer init) { return new WithMuzzleOverlay(init.Self, this); } public override object Create(ActorInitializer init) { return new WithMuzzleOverlay(init.Self, this); }
} }
class WithMuzzleOverlay : UpgradableTrait<WithMuzzleOverlayInfo>, INotifyAttack, IRender, ITick class WithMuzzleOverlay : ConditionalTrait<WithMuzzleOverlayInfo>, INotifyAttack, IRender, ITick
{ {
readonly Dictionary<Barrel, bool> visible = new Dictionary<Barrel, bool>(); readonly Dictionary<Barrel, bool> visible = new Dictionary<Barrel, bool>();
readonly Dictionary<Barrel, AnimationWithOffset> anims = new Dictionary<Barrel, AnimationWithOffset>(); readonly Dictionary<Barrel, AnimationWithOffset> anims = new Dictionary<Barrel, AnimationWithOffset>();

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders a parachute on units.")] [Desc("Renders a parachute on units.")]
public class WithParachuteInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo> public class WithParachuteInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("The image that contains the parachute sequences.")] [Desc("The image that contains the parachute sequences.")]
public readonly string Image = null; public readonly string Image = null;
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithParachute : UpgradableTrait<WithParachuteInfo>, ITick, IRender public class WithParachute : ConditionalTrait<WithParachuteInfo>, ITick, IRender
{ {
readonly Animation shadow; readonly Animation shadow;
readonly AnimationWithOffset anim; readonly AnimationWithOffset anim;

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Clones the actor sprite with another palette below it.")] [Desc("Clones the actor sprite with another palette below it.")]
public class WithShadowInfo : UpgradableTraitInfo public class WithShadowInfo : ConditionalTraitInfo
{ {
[PaletteReference] public readonly string Palette = "shadow"; [PaletteReference] public readonly string Palette = "shadow";
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public override object Create(ActorInitializer init) { return new WithShadow(this); } public override object Create(ActorInitializer init) { return new WithShadow(this); }
} }
public class WithShadow : UpgradableTrait<WithShadowInfo>, IRenderModifier public class WithShadow : ConditionalTrait<WithShadowInfo>, IRenderModifier
{ {
readonly WithShadowInfo info; readonly WithShadowInfo info;

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders barrels for units with the Turreted trait.")] [Desc("Renders barrels for units with the Turreted trait.")]
public class WithSpriteBarrelInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<TurretedInfo>, public class WithSpriteBarrelInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<TurretedInfo>,
Requires<ArmamentInfo>, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo> Requires<ArmamentInfo>, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{ {
[Desc("Sequence name to use.")] [Desc("Sequence name to use.")]
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithSpriteBarrel : UpgradableTrait<WithSpriteBarrelInfo> public class WithSpriteBarrel : ConditionalTrait<WithSpriteBarrelInfo>
{ {
public readonly Animation DefaultAnimation; public readonly Animation DefaultAnimation;
readonly RenderSprites rs; readonly RenderSprites rs;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Default trait for rendering sprite-based actors.")] [Desc("Default trait for rendering sprite-based actors.")]
public class WithSpriteBodyInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo> public class WithSpriteBodyInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>
{ {
[Desc("Animation to play when the actor is created."), SequenceReference] [Desc("Animation to play when the actor is created."), SequenceReference]
public readonly string StartSequence = null; public readonly string StartSequence = null;
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithSpriteBody : UpgradableTrait<WithSpriteBodyInfo>, INotifyDamageStateChanged, INotifyBuildComplete public class WithSpriteBody : ConditionalTrait<WithSpriteBodyInfo>, INotifyDamageStateChanged, INotifyBuildComplete
{ {
public readonly Animation DefaultAnimation; public readonly Animation DefaultAnimation;

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Renders turrets for units with the Turreted trait.")] [Desc("Renders turrets for units with the Turreted trait.")]
public class WithSpriteTurretInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, public class WithSpriteTurretInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo,
Requires<RenderSpritesInfo>, Requires<TurretedInfo>, Requires<BodyOrientationInfo>, Requires<ArmamentInfo> Requires<RenderSpritesInfo>, Requires<TurretedInfo>, Requires<BodyOrientationInfo>, Requires<ArmamentInfo>
{ {
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithSpriteTurret : UpgradableTrait<WithSpriteTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform, ITick, INotifyDamageStateChanged public class WithSpriteTurret : ConditionalTrait<WithSpriteTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform, ITick, INotifyDamageStateChanged
{ {
public readonly Animation DefaultAnimation; public readonly Animation DefaultAnimation;
protected readonly AttackBase Attack; protected readonly AttackBase Attack;

View File

@@ -20,7 +20,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Displays a text overlay relative to the selection box.")] [Desc("Displays a text overlay relative to the selection box.")]
public class WithTextDecorationInfo : UpgradableTraitInfo public class WithTextDecorationInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [Translate] public readonly string Text = null; [FieldLoader.Require] [Translate] public readonly string Text = null;
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithTextDecoration : UpgradableTrait<WithTextDecorationInfo>, IRender, IRenderAboveShroudWhenSelected, INotifyCapture public class WithTextDecoration : ConditionalTrait<WithTextDecorationInfo>, IRender, IRenderAboveShroudWhenSelected, INotifyCapture
{ {
readonly SpriteFont font; readonly SpriteFont font;
Color color; Color color;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
public class WithVoxelBarrelInfo : UpgradableTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<ArmamentInfo>, Requires<TurretedInfo> public class WithVoxelBarrelInfo : ConditionalTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<ArmamentInfo>, Requires<TurretedInfo>
{ {
[Desc("Voxel sequence name to use")] [Desc("Voxel sequence name to use")]
public readonly string Sequence = "barrel"; public readonly string Sequence = "barrel";
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithVoxelBarrel : UpgradableTrait<WithVoxelBarrelInfo>, INotifyBuildComplete, INotifySold, INotifyTransform public class WithVoxelBarrel : ConditionalTrait<WithVoxelBarrelInfo>, INotifyBuildComplete, INotifySold, INotifyTransform
{ {
readonly Actor self; readonly Actor self;
readonly Armament armament; readonly Armament armament;

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
[Desc("Also returns a default selection size that is calculated automatically from the voxel dimensions.")] [Desc("Also returns a default selection size that is calculated automatically from the voxel dimensions.")]
public class WithVoxelBodyInfo : UpgradableTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo> public class WithVoxelBodyInfo : ConditionalTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>
{ {
public readonly string Sequence = "idle"; public readonly string Sequence = "idle";
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithVoxelBody : UpgradableTrait<WithVoxelBodyInfo>, IAutoSelectionSize public class WithVoxelBody : ConditionalTrait<WithVoxelBodyInfo>, IAutoSelectionSize
{ {
readonly int2 size; readonly int2 size;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render namespace OpenRA.Mods.Common.Traits.Render
{ {
public class WithVoxelTurretInfo : UpgradableTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<TurretedInfo> public class WithVoxelTurretInfo : ConditionalTraitInfo, IRenderActorPreviewVoxelsInfo, Requires<RenderVoxelsInfo>, Requires<TurretedInfo>
{ {
[Desc("Voxel sequence name to use")] [Desc("Voxel sequence name to use")]
public readonly string Sequence = "turret"; public readonly string Sequence = "turret";
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
public class WithVoxelTurret : UpgradableTrait<WithVoxelTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform public class WithVoxelTurret : ConditionalTrait<WithVoxelTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform
{ {
readonly Actor self; readonly Actor self;
readonly Turreted turreted; readonly Turreted turreted;

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Lets the actor spread resources around it in a circle.")] [Desc("Lets the actor spread resources around it in a circle.")]
class SeedsResourceInfo : UpgradableTraitInfo class SeedsResourceInfo : ConditionalTraitInfo
{ {
public readonly int Interval = 75; public readonly int Interval = 75;
public readonly string ResourceType = "Ore"; public readonly string ResourceType = "Ore";
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new SeedsResource(init.Self, this); } public override object Create(ActorInitializer init) { return new SeedsResource(init.Self, this); }
} }
class SeedsResource : UpgradableTrait<SeedsResourceInfo>, ITick, ISeedableResource class SeedsResource : ConditionalTrait<SeedsResourceInfo>, ITick, ISeedableResource
{ {
readonly SeedsResourceInfo info; readonly SeedsResourceInfo info;

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Attach this to actors which should be able to regenerate their health points.")] [Desc("Attach this to actors which should be able to regenerate their health points.")]
class SelfHealingInfo : UpgradableTraitInfo, Requires<HealthInfo> class SelfHealingInfo : ConditionalTraitInfo, Requires<HealthInfo>
{ {
[Desc("Absolute amount of health points added in each step.")] [Desc("Absolute amount of health points added in each step.")]
public readonly int Step = 5; public readonly int Step = 5;
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); } public override object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); }
} }
class SelfHealing : UpgradableTrait<SelfHealingInfo>, ITick, INotifyDamage class SelfHealing : ConditionalTrait<SelfHealingInfo>, ITick, INotifyDamage
{ {
readonly Health health; readonly Health health;

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Actor can be sold")] [Desc("Actor can be sold")]
public class SellableInfo : UpgradableTraitInfo public class SellableInfo : ConditionalTraitInfo
{ {
public readonly int RefundPercent = 50; public readonly int RefundPercent = 50;
public readonly string[] SellSounds = { }; public readonly string[] SellSounds = { };
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Sellable(init.Self, this); } public override object Create(ActorInitializer init) { return new Sellable(init.Self, this); }
} }
public class Sellable : UpgradableTrait<SellableInfo>, IResolveOrder, IProvideTooltipInfo public class Sellable : ConditionalTrait<SellableInfo>, IResolveOrder, IProvideTooltipInfo
{ {
readonly Actor self; readonly Actor self;
readonly Lazy<Health> health; readonly Lazy<Health> health;

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Sound namespace OpenRA.Mods.Common.Traits.Sound
{ {
[Desc("Plays a looping audio file at the actor position. Attach this to the `World` actor to cover the whole map.")] [Desc("Plays a looping audio file at the actor position. Attach this to the `World` actor to cover the whole map.")]
class AmbientSoundInfo : UpgradableTraitInfo class AmbientSoundInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
public readonly string SoundFile = null; public readonly string SoundFile = null;
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
public override object Create(ActorInitializer init) { return new AmbientSound(init.Self, this); } public override object Create(ActorInitializer init) { return new AmbientSound(init.Self, this); }
} }
class AmbientSound : UpgradableTrait<AmbientSoundInfo>, ITick class AmbientSound : ConditionalTrait<AmbientSoundInfo>, ITick
{ {
ISound currentSound; ISound currentSound;
bool wasDisabled = true; bool wasDisabled = true;

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Sound namespace OpenRA.Mods.Common.Traits.Sound
{ {
[Desc("Played when preparing for an attack or attacking.")] [Desc("Played when preparing for an attack or attacking.")]
public class AttackSoundsInfo : UpgradableTraitInfo public class AttackSoundsInfo : ConditionalTraitInfo
{ {
[Desc("Play a randomly selected sound from this list when preparing for an attack or attacking.")] [Desc("Play a randomly selected sound from this list when preparing for an attack or attacking.")]
public readonly string[] Sounds = { }; public readonly string[] Sounds = { };
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
public override object Create(ActorInitializer init) { return new AttackSounds(init, this); } public override object Create(ActorInitializer init) { return new AttackSounds(init, this); }
} }
public class AttackSounds : UpgradableTrait<AttackSoundsInfo>, INotifyAttack, ITick public class AttackSounds : ConditionalTrait<AttackSoundsInfo>, INotifyAttack, ITick
{ {
readonly AttackSoundsInfo info; readonly AttackSoundsInfo info;
int tick; int tick;

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public abstract class SupportPowerInfo : UpgradableTraitInfo public abstract class SupportPowerInfo : ConditionalTraitInfo
{ {
[Desc("Measured in seconds.")] [Desc("Measured in seconds.")]
public readonly int ChargeTime = 0; public readonly int ChargeTime = 0;
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
public SupportPowerInfo() { OrderName = GetType().Name + "Order"; } public SupportPowerInfo() { OrderName = GetType().Name + "Order"; }
} }
public class SupportPower : UpgradableTrait<SupportPowerInfo> public class SupportPower : ConditionalTrait<SupportPowerInfo>
{ {
public readonly Actor Self; public readonly Actor Self;
readonly SupportPowerInfo info; readonly SupportPowerInfo info;

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Actor can be targeted.")] [Desc("Actor can be targeted.")]
public class TargetableInfo : UpgradableTraitInfo, ITargetableInfo public class TargetableInfo : ConditionalTraitInfo, ITargetableInfo
{ {
[Desc("Target type. Used for filtering (in)valid targets.")] [Desc("Target type. Used for filtering (in)valid targets.")]
public readonly HashSet<string> TargetTypes = new HashSet<string>(); public readonly HashSet<string> TargetTypes = new HashSet<string>();
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Targetable(init.Self, this); } public override object Create(ActorInitializer init) { return new Targetable(init.Self, this); }
} }
public class Targetable : UpgradableTrait<TargetableInfo>, ITargetable public class Targetable : ConditionalTrait<TargetableInfo>, ITargetable
{ {
protected static readonly string[] None = new string[] { }; protected static readonly string[] None = new string[] { };
protected Cloak[] cloaks; protected Cloak[] cloaks;

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public abstract class TooltipInfoBase : UpgradableTraitInfo public abstract class TooltipInfoBase : ConditionalTraitInfo
{ {
[Translate] public readonly string Name = ""; [Translate] public readonly string Name = "";
} }
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
public bool IsOwnerRowVisible { get { return ShowOwnerRow; } } public bool IsOwnerRowVisible { get { return ShowOwnerRow; } }
} }
public class Tooltip : UpgradableTrait<TooltipInfo>, ITooltip public class Tooltip : ConditionalTrait<TooltipInfo>, ITooltip
{ {
readonly Actor self; readonly Actor self;
readonly TooltipInfo info; readonly TooltipInfo info;

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
/// <summary>Use as base class for *Info to subclass of UpgradableTrait. (See UpgradableTrait.)</summary> /// <summary>Use as base class for *Info to subclass of UpgradableTrait. (See UpgradableTrait.)</summary>
public abstract class UpgradableTraitInfo : IConditionConsumerInfo, IRulesetLoaded public abstract class ConditionalTraitInfo : IConditionConsumerInfo, IRulesetLoaded
{ {
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>());
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
/// Requires basing *Info on UpgradableTraitInfo and using base(info) constructor. /// Requires basing *Info on UpgradableTraitInfo and using base(info) constructor.
/// TraitEnabled will be called at creation if the trait starts enabled or does not use conditions. /// TraitEnabled will be called at creation if the trait starts enabled or does not use conditions.
/// </summary> /// </summary>
public abstract class UpgradableTrait<InfoType> : IConditionConsumer, IDisabledTrait, INotifyCreated, ISync where InfoType : UpgradableTraitInfo public abstract class ConditionalTrait<InfoType> : IConditionConsumer, IDisabledTrait, INotifyCreated, ISync where InfoType : ConditionalTraitInfo
{ {
public readonly InfoType Info; public readonly InfoType Info;
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits
[Sync] public bool IsTraitDisabled { get; private set; } [Sync] public bool IsTraitDisabled { get; private set; }
public UpgradableTrait(InfoType info) public ConditionalTrait(InfoType info)
{ {
Info = info; Info = info;

View File

@@ -14,12 +14,12 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Disable the actor when this trait is enabled by a condition.")] [Desc("Disable the actor when this trait is enabled by a condition.")]
public class DisableOnConditionInfo : UpgradableTraitInfo public class DisableOnConditionInfo : ConditionalTraitInfo
{ {
public override object Create(ActorInitializer init) { return new DisableOnCondition(this); } public override object Create(ActorInitializer init) { return new DisableOnCondition(this); }
} }
public class DisableOnCondition : UpgradableTrait<DisableOnConditionInfo>, IDisable public class DisableOnCondition : ConditionalTrait<DisableOnConditionInfo>, IDisable
{ {
public DisableOnCondition(DisableOnConditionInfo info) public DisableOnCondition(DisableOnConditionInfo info)
: base(info) { } : base(info) { }

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Grants a condition while the trait is active.")] [Desc("Grants a condition while the trait is active.")]
class GrantConditionInfo : UpgradableTraitInfo class GrantConditionInfo : ConditionalTraitInfo
{ {
[FieldLoader.Require] [FieldLoader.Require]
[GrantedConditionReference] [GrantedConditionReference]
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new GrantCondition(this); } public override object Create(ActorInitializer init) { return new GrantCondition(this); }
} }
class GrantCondition : UpgradableTrait<GrantConditionInfo> class GrantCondition : ConditionalTrait<GrantConditionInfo>
{ {
ConditionManager conditionManager; ConditionManager conditionManager;
int conditionToken = ConditionManager.InvalidConditionToken; int conditionToken = ConditionManager.InvalidConditionToken;

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
public class GrantConditionOnMovementInfo : UpgradableTraitInfo, Requires<IMoveInfo> public class GrantConditionOnMovementInfo : ConditionalTraitInfo, Requires<IMoveInfo>
{ {
[FieldLoader.Require] [FieldLoader.Require]
[GrantedConditionReference] [GrantedConditionReference]
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new GrantConditionOnMovement(init.Self, this); } public override object Create(ActorInitializer init) { return new GrantConditionOnMovement(init.Self, this); }
} }
public class GrantConditionOnMovement : UpgradableTrait<GrantConditionOnMovementInfo>, ITick public class GrantConditionOnMovement : ConditionalTrait<GrantConditionOnMovementInfo>, ITick
{ {
readonly IMove movement; readonly IMove movement;

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Wanders around aimlessly while idle.")] [Desc("Wanders around aimlessly while idle.")]
public class WandersInfo : UpgradableTraitInfo, Requires<IMoveInfo> public class WandersInfo : ConditionalTraitInfo, Requires<IMoveInfo>
{ {
public readonly int WanderMoveRadius = 1; public readonly int WanderMoveRadius = 1;
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public override object Create(ActorInitializer init) { return new Wanders(init.Self, this); } public override object Create(ActorInitializer init) { return new Wanders(init.Self, this); }
} }
public class Wanders : UpgradableTrait<WandersInfo>, INotifyIdle, INotifyBecomingIdle public class Wanders : ConditionalTrait<WandersInfo>, INotifyIdle, INotifyBecomingIdle
{ {
readonly Actor self; readonly Actor self;
readonly WandersInfo info; readonly WandersInfo info;

View File

@@ -14,7 +14,7 @@ using OpenRA.Mods.Common.Traits;
namespace OpenRA.Mods.D2k.Traits namespace OpenRA.Mods.D2k.Traits
{ {
[Desc("This actor makes noise, which causes them to be targeted by actors with the Sandworm trait.")] [Desc("This actor makes noise, which causes them to be targeted by actors with the Sandworm trait.")]
public class AttractsWormsInfo : UpgradableTraitInfo public class AttractsWormsInfo : ConditionalTraitInfo
{ {
[Desc("How much noise this actor produces.")] [Desc("How much noise this actor produces.")]
public readonly int Intensity = 0; public readonly int Intensity = 0;
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.D2k.Traits
public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); } public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); }
} }
public class AttractsWorms : UpgradableTrait<AttractsWormsInfo> public class AttractsWorms : ConditionalTrait<AttractsWormsInfo>
{ {
readonly Actor self; readonly Actor self;