Add property requirements to safe traits

This commit is contained in:
atlimit8
2015-07-11 16:30:27 -05:00
parent 7881ff40bf
commit 1bcc07ce69
50 changed files with 68 additions and 41 deletions

View File

@@ -28,8 +28,8 @@ namespace OpenRA.Mods.Common.Traits
{ {
public readonly string Name = "primary"; public readonly string Name = "primary";
[WeaponReference] [WeaponReference, FieldLoader.Require]
[Desc("Has to be defined here and in weapons.yaml.")] [Desc("Has to be defined in weapons.yaml as well.")]
public readonly string Weapon = null; public readonly string Weapon = null;
[Desc("Which limited ammo pool (if present) should this armament be assigned to.")] [Desc("Which limited ammo pool (if present) should this armament be assigned to.")]

View File

@@ -27,14 +27,17 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Cargo can fire their weapons out of fire ports.")] [Desc("Cargo can fire their weapons out of fire ports.")]
public class AttackGarrisonedInfo : AttackFollowInfo, Requires<CargoInfo> public class AttackGarrisonedInfo : AttackFollowInfo, Requires<CargoInfo>
{ {
[FieldLoader.Require]
[Desc("Fire port offsets in local coordinates.")] [Desc("Fire port offsets in local coordinates.")]
public readonly WVec[] PortOffsets = { }; public readonly WVec[] PortOffsets = null;
[FieldLoader.Require]
[Desc("Fire port yaw angles.")] [Desc("Fire port yaw angles.")]
public readonly WAngle[] PortYaws = { }; public readonly WAngle[] PortYaws = null;
[FieldLoader.Require]
[Desc("Fire port yaw cone angle.")] [Desc("Fire port yaw cone angle.")]
public readonly WAngle[] PortCones = { }; public readonly WAngle[] PortCones = null;
public readonly string MuzzlePalette = "effect"; public readonly string MuzzlePalette = "effect";

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
"If you want more than one unit to appear copy this section and assign IDs like FreeActor@2, ...")] "If you want more than one unit to appear copy this section and assign IDs like FreeActor@2, ...")]
public class FreeActorInfo : ITraitInfo public class FreeActorInfo : ITraitInfo
{ {
[ActorReference] [ActorReference, FieldLoader.Require]
[Desc("Name of the actor.")] [Desc("Name of the actor.")]
public readonly string Actor = null; public readonly string Actor = null;

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class TargetableBuildingInfo : ITraitInfo, ITargetableInfo, Requires<BuildingInfo> public class TargetableBuildingInfo : ITraitInfo, ITargetableInfo, Requires<BuildingInfo>
{ {
[FieldLoader.Require]
public readonly string[] TargetTypes = { }; public readonly string[] TargetTypes = { };
public string[] GetTargetTypes() { return TargetTypes; } public string[] GetTargetTypes() { return TargetTypes; }

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
class ExplodeCrateActionInfo : CrateActionInfo class ExplodeCrateActionInfo : CrateActionInfo
{ {
[Desc("The weapon to fire upon collection.")] [Desc("The weapon to fire upon collection.")]
[WeaponReference] public string Weapon = null; [WeaponReference, FieldLoader.Require] public string Weapon = null;
public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.Self, this); } public override object Create(ActorInitializer init) { return new ExplodeCrateAction(init.Self, this); }
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
class GiveUnitCrateActionInfo : CrateActionInfo class GiveUnitCrateActionInfo : CrateActionInfo
{ {
[Desc("The list of units to spawn.")] [Desc("The list of units to spawn.")]
[ActorReference] [ActorReference, FieldLoader.Require]
public readonly string[] Units = { }; public readonly string[] Units = { };
[Desc("Races that are allowed to trigger this action")] [Desc("Races that are allowed to trigger this action")]

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Grants an upgrade to the collector.")] [Desc("Grants an upgrade to the collector.")]
public class GrantUpgradeCrateActionInfo : CrateActionInfo public class GrantUpgradeCrateActionInfo : CrateActionInfo
{ {
[UpgradeGrantedReference] [UpgradeGrantedReference, FieldLoader.Require]
[Desc("The upgrades to apply.")] [Desc("The upgrades to apply.")]
public readonly string[] Upgrades = { }; public readonly string[] Upgrades = { };

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
class SupportPowerCrateActionInfo : CrateActionInfo class SupportPowerCrateActionInfo : CrateActionInfo
{ {
[Desc("Which proxy actor, which grants the support power, to spawn.")] [Desc("Which proxy actor, which grants the support power, to spawn.")]
[ActorReference] public readonly string Proxy = null; [ActorReference, FieldLoader.Require] public readonly string Proxy = null;
public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.Self, this); } public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.Self, this); }
} }

View File

@@ -15,6 +15,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Overrides the build time calculated by actor value.")] [Desc("Overrides the build time calculated by actor value.")]
public class CustomBuildTimeValueInfo : TraitInfo<CustomBuildTimeValue> public class CustomBuildTimeValueInfo : TraitInfo<CustomBuildTimeValue>
{ {
[FieldLoader.Require]
[Desc("Measured in ticks.")] [Desc("Measured in ticks.")]
public readonly int Value = 0; public readonly int Value = 0;
} }

View File

@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
"Examples: bridge huts and crates.")] "Examples: bridge huts and crates.")]
public class CustomSelectionSizeInfo : ITraitInfo public class CustomSelectionSizeInfo : ITraitInfo
{ {
[FieldLoader.Require]
public readonly int[] CustomBounds = null; public readonly int[] CustomBounds = null;
public object Create(ActorInitializer init) { return new CustomSelectionSize(this); } public object Create(ActorInitializer init) { return new CustomSelectionSize(this); }

View File

@@ -15,6 +15,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Allow a non-standard sell/repair value to avoid buy-sell exploits.")] [Desc("Allow a non-standard sell/repair value to avoid buy-sell exploits.")]
public class CustomSellValueInfo : TraitInfo<CustomSellValue> public class CustomSellValueInfo : TraitInfo<CustomSellValue>
{ {
[FieldLoader.Require]
public readonly int Value = 0; public readonly int Value = 0;
} }

View File

@@ -16,10 +16,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Grants upgrades to the actor this is attached to when prerequisites are available.")] [Desc("Grants upgrades to the actor this is attached to when prerequisites are available.")]
public class GlobalUpgradableInfo : ITraitInfo, Requires<UpgradeManagerInfo> public class GlobalUpgradableInfo : ITraitInfo, Requires<UpgradeManagerInfo>
{ {
[UpgradeGrantedReference] [UpgradeGrantedReference, FieldLoader.Require]
[Desc("List of upgrades to apply.")] [Desc("List of upgrades to apply.")]
public readonly string[] Upgrades = { }; public readonly string[] Upgrades = { };
[FieldLoader.Require]
[Desc("List of required prerequisites.")] [Desc("List of required prerequisites.")]
public readonly string[] Prerequisites = { }; public readonly string[] Prerequisites = { };

View File

@@ -24,8 +24,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Prone movement speed as a percentage of the normal speed.")] [Desc("Prone movement speed as a percentage of the normal speed.")]
public readonly int SpeedModifier = 50; public readonly int SpeedModifier = 50;
[FieldLoader.Require]
[Desc("Damage types that trigger prone state. Defined on the warheads.")] [Desc("Damage types that trigger prone state. Defined on the warheads.")]
public readonly string[] DamageTriggers = new string[0]; public readonly string[] DamageTriggers = null;
[FieldLoader.LoadUsing("LoadModifiers")] [FieldLoader.LoadUsing("LoadModifiers")]
[Desc("Damage modifiers for each damage type (defined on the warheads) while the unit is prone.")] [Desc("Damage modifiers for each damage type (defined on the warheads) while the unit is prone.")]

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class TerrainModifiesDamageInfo : ITraitInfo public class TerrainModifiesDamageInfo : ITraitInfo
{ {
[FieldLoader.LoadUsing("LoadPercents")] [FieldLoader.LoadUsing("LoadPercents", true)]
[Desc("Damage percentage for specific terrain types. 120 = 120%, 80 = 80%, etc.")] [Desc("Damage percentage for specific terrain types. 120 = 120%, 80 = 80%, etc.")]
public readonly Dictionary<string, int> TerrainModifier = null; public readonly Dictionary<string, int> TerrainModifier = null;
@@ -28,12 +28,7 @@ namespace OpenRA.Mods.Common.Traits
static object LoadPercents(MiniYaml y) static object LoadPercents(MiniYaml y)
{ {
MiniYaml percents; return y.ToDictionary()["TerrainModifier"].Nodes.ToDictionary(
if (!y.ToDictionary().TryGetValue("TerrainModifier", out percents))
return new Dictionary<string, int>();
return percents.Nodes.ToDictionary(
kv => FieldLoader.GetValue<string>("(key)", kv.Key), kv => FieldLoader.GetValue<string>("(key)", kv.Key),
kv => FieldLoader.GetValue<int>("(value)", kv.Value.Value)); kv => FieldLoader.GetValue<int>("(value)", kv.Value.Value));
} }

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Unit is able to move.")] [Desc("Unit is able to move.")]
public class MobileInfo : IMoveInfo, IOccupySpaceInfo, IFacingInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit> public class MobileInfo : IMoveInfo, IOccupySpaceInfo, IFacingInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
{ {
[FieldLoader.LoadUsing("LoadSpeeds")] [FieldLoader.LoadUsing("LoadSpeeds", true)]
[Desc("Set Water: 0 for ground units and lower the value on rough terrain.")] [Desc("Set Water: 0 for ground units and lower the value on rough terrain.")]
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds; public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Traits
"at the same time. Will only work together with the Production: trait.")] "at the same time. Will only work together with the Production: trait.")]
public class ProductionQueueInfo : ITraitInfo public class ProductionQueueInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("What kind of production will be added (e.g. Building, Infantry, Vehicle, ...)")] [Desc("What kind of production will be added (e.g. Building, Infantry, Vehicle, ...)")]
public readonly string Type = null; public readonly string Type = null;

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class PlugInfo : TraitInfo<Plug> public class PlugInfo : TraitInfo<Plug>
{ {
[FieldLoader.Require]
[Desc("Plug type (matched against Upgrades in Pluggable)")] [Desc("Plug type (matched against Upgrades in Pluggable)")]
public readonly string Type = null; public readonly string Type = null;
} }

View File

@@ -19,18 +19,13 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Footprint cell offset where a plug can be placed.")] [Desc("Footprint cell offset where a plug can be placed.")]
public readonly CVec Offset = CVec.Zero; public readonly CVec Offset = CVec.Zero;
[FieldLoader.LoadUsing("LoadUpgrades")] [FieldLoader.LoadUsing("LoadUpgrades", true)]
[Desc("Upgrades to grant for each accepted plug type.")] [Desc("Upgrades to grant for each accepted plug type.")]
public readonly Dictionary<string, string[]> Upgrades = null; public readonly Dictionary<string, string[]> Upgrades = null;
static object LoadUpgrades(MiniYaml y) static object LoadUpgrades(MiniYaml y)
{ {
MiniYaml upgrades; return y.ToDictionary()["Upgrades"].Nodes.ToDictionary(
if (!y.ToDictionary().TryGetValue("Upgrades", out upgrades))
return new Dictionary<string, string[]>();
return upgrades.Nodes.ToDictionary(
kv => kv.Key, kv => kv.Key,
kv => FieldLoader.GetValue<string[]>("(value)", kv.Value.Value)); kv => FieldLoader.GetValue<string[]>("(value)", kv.Value.Value));
} }

View File

@@ -21,6 +21,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This unit has access to build queues.")] [Desc("This unit has access to build queues.")]
public class ProductionInfo : ITraitInfo public class ProductionInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")] [Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")]
public readonly string[] Produces = { }; public readonly string[] Produces = { };

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Actor can capture ProximityCapturable actors.")] [Desc("Actor can capture ProximityCapturable actors.")]
public class ProximityCaptorInfo : ITraitInfo public class ProximityCaptorInfo : ITraitInfo
{ {
[FieldLoader.Require]
public readonly string[] Types = { }; public readonly string[] Types = { };
public object Create(ActorInitializer init) { return new ProximityCaptor(this); } public object Create(ActorInitializer init) { return new ProximityCaptor(this); }
} }

View File

@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Visualizes the remaining time for an upgrade.")] [Desc("Visualizes the remaining time for an upgrade.")]
class TimedUpgradeBarInfo : ITraitInfo, Requires<UpgradeManagerInfo> class TimedUpgradeBarInfo : ITraitInfo, Requires<UpgradeManagerInfo>
{ {
[FieldLoader.Require]
[Desc("Upgrade that this bar corresponds to")] [Desc("Upgrade that this bar corresponds to")]
public readonly string Upgrade = null; public readonly string Upgrade = null;

View File

@@ -15,6 +15,7 @@ namespace OpenRA.Mods.Common.Traits
[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 : ITraitInfo class AmbientSoundInfo : ITraitInfo
{ {
[FieldLoader.Require]
public readonly string SoundFile = null; public readonly string SoundFile = null;
public object Create(ActorInitializer init) { return new AmbientSound(init.Self, this); } public object Create(ActorInitializer init) { return new AmbientSound(init.Self, this); }

View File

@@ -18,9 +18,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Used for silos.")] [Desc("Used for silos.")]
class StoresResourcesInfo : ITraitInfo class StoresResourcesInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("Number of little squares used to display how filled unit is.")] [Desc("Number of little squares used to display how filled unit is.")]
public readonly int PipCount = 0; public readonly int PipCount = 0;
public readonly PipType PipColor = PipType.Yellow; public readonly PipType PipColor = PipType.Yellow;
[FieldLoader.Require]
public readonly int Capacity = 0; public readonly int Capacity = 0;
public object Create(ActorInitializer init) { return new StoresResources(init.Self, this); } public object Create(ActorInitializer init) { return new StoresResources(init.Self, this); }
} }

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
class GrantUpgradePowerInfo : SupportPowerInfo class GrantUpgradePowerInfo : SupportPowerInfo
{ {
[UpgradeGrantedReference] [UpgradeGrantedReference, FieldLoader.Require]
[Desc("The upgrades to apply.")] [Desc("The upgrades to apply.")]
public readonly string[] Upgrades = { }; public readonly string[] Upgrades = { };

View File

@@ -12,12 +12,14 @@ using OpenRA.Effects;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits namespace OpenRA.Mods.Common.Traits
{ {
[Desc("Spawns an actor that stays for a limited amount of time.")] [Desc("Spawns an actor that stays for a limited amount of time.")]
public class SpawnActorPowerInfo : SupportPowerInfo public class SpawnActorPowerInfo : SupportPowerInfo
{ {
[ActorReference, FieldLoader.Require]
[Desc("Actor to spawn.")] [Desc("Actor to spawn.")]
public readonly string Actor = null; public readonly string Actor = null;

View File

@@ -15,6 +15,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
class ThrowsParticleInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<IBodyOrientationInfo> class ThrowsParticleInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<IBodyOrientationInfo>
{ {
[FieldLoader.Require]
public readonly string Anim = null; public readonly string Anim = null;
[Desc("Initial position relative to body")] [Desc("Initial position relative to body")]

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Throws particles when the actor is destroyed that do damage on impact.")] [Desc("Throws particles when the actor is destroyed that do damage on impact.")]
public class ThrowsShrapnelInfo : ITraitInfo public class ThrowsShrapnelInfo : ITraitInfo
{ {
[WeaponReference] [WeaponReference, FieldLoader.Require]
public string[] Weapons = { }; public string[] Weapons = { };
public int[] Pieces = { 3, 10 }; public int[] Pieces = { 3, 10 };
public WDist[] Range = { WDist.FromCells(2), WDist.FromCells(5) }; public WDist[] Range = { WDist.FromCells(2), WDist.FromCells(5) };

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class TransformOnPassengerInfo : ITraitInfo public class TransformOnPassengerInfo : ITraitInfo
{ {
[ActorReference] public readonly string[] PassengerTypes = { }; [ActorReference, FieldLoader.Require] public readonly string[] PassengerTypes = { };
[ActorReference] public readonly string OnEnter = null; [ActorReference] public readonly string OnEnter = null;
[ActorReference] public readonly string OnExit = null; [ActorReference] public readonly string OnExit = null;
public readonly bool SkipMakeAnims = false; public readonly bool SkipMakeAnims = false;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Actor becomes a specified actor type when this trait is triggered.")] [Desc("Actor becomes a specified actor type when this trait is triggered.")]
public class TransformsInfo : ITraitInfo public class TransformsInfo : ITraitInfo
{ {
[Desc("Actor to transform into."), ActorReference] [Desc("Actor to transform into."), ActorReference, FieldLoader.Require]
public readonly string IntoActor = null; public readonly string IntoActor = null;
[Desc("Offset to spawn the transformed actor relative to the current cell.")] [Desc("Offset to spawn the transformed actor relative to the current cell.")]

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
public class DeployToUpgradeInfo : ITraitInfo, Requires<UpgradeManagerInfo> public class DeployToUpgradeInfo : ITraitInfo, Requires<UpgradeManagerInfo>
{ {
[UpgradeGrantedReference] [UpgradeGrantedReference, FieldLoader.Require]
[Desc("The upgrades to grant when deploying and revoke when undeploying.")] [Desc("The upgrades to grant when deploying and revoke when undeploying.")]
public readonly string[] Upgrades = { }; public readonly string[] Upgrades = { };

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Applies an upgrade to actors within a specified range.")] [Desc("Applies an upgrade to actors within a specified range.")]
public class UpgradeActorsNearInfo : ITraitInfo public class UpgradeActorsNearInfo : ITraitInfo
{ {
[UpgradeGrantedReference] [UpgradeGrantedReference, FieldLoader.Require]
[Desc("The upgrades to grant.")] [Desc("The upgrades to grant.")]
public readonly string[] Upgrades = { }; public readonly string[] Upgrades = { };

View File

@@ -15,6 +15,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("How much the unit is worth.")] [Desc("How much the unit is worth.")]
public class ValuedInfo : TraitInfo<Valued> public class ValuedInfo : TraitInfo<Valued>
{ {
[FieldLoader.Require]
[Desc("Used in production, but also for bounties so remember to set it > 0 even for NPCs.")] [Desc("Used in production, but also for bounties so remember to set it > 0 even for NPCs.")]
public readonly int Cost = 0; public readonly int Cost = 0;
} }

View File

@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Traits
"The icon change occurs when LevelupWhenCreated.Prerequisites are met.")] "The icon change occurs when LevelupWhenCreated.Prerequisites are met.")]
public class VeteranProductionIconOverlayInfo : ITraitInfo, Requires<TechTreeInfo> public class VeteranProductionIconOverlayInfo : ITraitInfo, Requires<TechTreeInfo>
{ {
[FieldLoader.Require]
[Desc("Image used for the overlay.")] [Desc("Image used for the overlay.")]
public readonly string Image = null; public readonly string Image = null;

View File

@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This actor has a voice.")] [Desc("This actor has a voice.")]
public class VoicedInfo : ITraitInfo public class VoicedInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("Which voice set to use.")] [Desc("Which voice set to use.")]
[VoiceSetReference] public readonly string VoiceSet = null; [VoiceSetReference] public readonly string VoiceSet = null;

View File

@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Loads the palette specified in the tileset definition")] [Desc("Loads the palette specified in the tileset definition")]
class PaletteFromCurrentTilesetInfo : ITraitInfo class PaletteFromCurrentTilesetInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("internal palette name")] [Desc("internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[Desc("Map listed indices to shadow. Ignores previous color.")] [Desc("Map listed indices to shadow. Ignores previous color.")]

View File

@@ -17,10 +17,12 @@ namespace OpenRA.Mods.Common.Traits
{ {
class PaletteFromFileInfo : ITraitInfo class PaletteFromFileInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("internal palette name")] [Desc("internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[Desc("If defined, load the palette only for this tileset.")] [Desc("If defined, load the palette only for this tileset.")]
public readonly string Tileset = null; public readonly string Tileset = null;
[FieldLoader.Require]
[Desc("filename to load")] [Desc("filename to load")]
public readonly string Filename = null; public readonly string Filename = null;
[Desc("Map listed indices to shadow. Ignores previous color.")] [Desc("Map listed indices to shadow. Ignores previous color.")]

View File

@@ -19,9 +19,11 @@ namespace OpenRA.Mods.D2k.Traits
[Desc("Create a palette by applying alpha transparency to another palette.")] [Desc("Create a palette by applying alpha transparency to another palette.")]
class PaletteFromPaletteWithAlphaInfo : ITraitInfo class PaletteFromPaletteWithAlphaInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("Internal palette name")] [Desc("Internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[FieldLoader.Require]
[Desc("The name of the palette to base off.")] [Desc("The name of the palette to base off.")]
public readonly string BasePalette = null; public readonly string BasePalette = null;

View File

@@ -19,9 +19,11 @@ namespace OpenRA.Mods.D2k.Traits
[Desc("Create player palettes by applying alpha transparency to another player palette.")] [Desc("Create player palettes by applying alpha transparency to another player palette.")]
class PaletteFromPlayerPaletteWithAlphaInfo : ITraitInfo class PaletteFromPlayerPaletteWithAlphaInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("The prefix for the resulting player palettes")] [Desc("The prefix for the resulting player palettes")]
public readonly string BaseName = null; public readonly string BaseName = null;
[FieldLoader.Require]
[Desc("The name of the player palette to base off.")] [Desc("The name of the player palette to base off.")]
public readonly string BasePalette = null; public readonly string BasePalette = null;

View File

@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Creates a single color palette without any base palette file.")] [Desc("Creates a single color palette without any base palette file.")]
class PaletteFromRGBAInfo : ITraitInfo class PaletteFromRGBAInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("internal palette name")] [Desc("internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[Desc("If defined, load the palette only for this tileset.")] [Desc("If defined, load the palette only for this tileset.")]

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
class PlayerPaletteFromCurrentTilesetInfo : ITraitInfo class PlayerPaletteFromCurrentTilesetInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("internal palette name")] [Desc("internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[Desc("Map listed indices to shadow.")] [Desc("Map listed indices to shadow.")]

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.D2k.Traits
"If you want more than one unit to be delivered, copy this section and assign IDs like FreeActorWithDelivery@2, ...")] "If you want more than one unit to be delivered, copy this section and assign IDs like FreeActorWithDelivery@2, ...")]
public class FreeActorWithDeliveryInfo : FreeActorInfo public class FreeActorWithDeliveryInfo : FreeActorInfo
{ {
[ActorReference] [ActorReference, FieldLoader.Require]
[Desc("Name of the delivering actor. This actor must have the `Carryall` trait")] [Desc("Name of the delivering actor. This actor must have the `Carryall` trait")]
public readonly string DeliveringActor = null; public readonly string DeliveringActor = null;
@@ -43,11 +43,6 @@ namespace OpenRA.Mods.D2k.Traits
public FreeActorWithDelivery(ActorInitializer init, FreeActorWithDeliveryInfo info) public FreeActorWithDelivery(ActorInitializer init, FreeActorWithDeliveryInfo info)
{ {
if (string.IsNullOrEmpty(info.Actor))
throw new InvalidDataException("Actor type was not specified!");
if (string.IsNullOrEmpty(info.DeliveringActor))
throw new InvalidDataException("Delivering actor type was not specified!");
self = init.Self; self = init.Self;
Info = info; Info = info;

View File

@@ -20,6 +20,7 @@ namespace OpenRA.Mods.D2k.Traits
"the actor footprint will be filled with this tile.")] "the actor footprint will be filled with this tile.")]
public readonly ushort Template = 0; public readonly ushort Template = 0;
[FieldLoader.Require]
[Desc("The terrain types that this template will be placed on")] [Desc("The terrain types that this template will be placed on")]
public readonly string[] TerrainTypes = { }; public readonly string[] TerrainTypes = { };

View File

@@ -17,6 +17,7 @@ namespace OpenRA.Mods.D2k.Traits
[Desc("Rendered together with an attack.")] [Desc("Rendered together with an attack.")]
public class WithAttackOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo> public class WithAttackOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
{ {
[FieldLoader.Require]
[Desc("Sequence name to use")] [Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = null; [SequenceReference] public readonly string Sequence = null;

View File

@@ -19,8 +19,10 @@ namespace OpenRA.Mods.D2k.Traits
{ {
class FogPaletteFromR8Info : ITraitInfo class FogPaletteFromR8Info : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("Internal palette name")] [Desc("Internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[FieldLoader.Require]
[Desc("Filename to load")] [Desc("Filename to load")]
public readonly string Filename = null; public readonly string Filename = null;
[Desc("Palette byte offset")] [Desc("Palette byte offset")]

View File

@@ -19,8 +19,10 @@ namespace OpenRA.Mods.D2k.Traits
{ {
class PaletteFromR8Info : ITraitInfo class PaletteFromR8Info : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("Internal palette name")] [Desc("Internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[FieldLoader.Require]
[Desc("Filename to load")] [Desc("Filename to load")]
public readonly string Filename = null; public readonly string Filename = null;
[Desc("Palette byte offset")] [Desc("Palette byte offset")]

View File

@@ -19,9 +19,11 @@ namespace OpenRA.Mods.D2k.Traits
[Desc("Create a palette by applying a scale and offset to the colors in another palette.")] [Desc("Create a palette by applying a scale and offset to the colors in another palette.")]
class PaletteFromScaledPaletteInfo : ITraitInfo class PaletteFromScaledPaletteInfo : ITraitInfo
{ {
[FieldLoader.Require]
[Desc("Internal palette name")] [Desc("Internal palette name")]
public readonly string Name = null; public readonly string Name = null;
[FieldLoader.Require]
[Desc("The name of the palette to base off.")] [Desc("The name of the palette to base off.")]
public readonly string BasePalette = null; public readonly string BasePalette = null;

View File

@@ -17,6 +17,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Creates a free duplicate of produced units.")] [Desc("Creates a free duplicate of produced units.")]
public class ClonesProducedUnitsInfo : ITraitInfo, Requires<ProductionInfo>, Requires<ExitInfo> public class ClonesProducedUnitsInfo : ITraitInfo, Requires<ProductionInfo>, Requires<ExitInfo>
{ {
[FieldLoader.Require]
[Desc("Uses the \"Cloneable\" trait to determine whether or not we should clone a produced unit.")] [Desc("Uses the \"Cloneable\" trait to determine whether or not we should clone a produced unit.")]
public readonly string[] CloneableTypes = { }; public readonly string[] CloneableTypes = { };

View File

@@ -16,6 +16,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Actors with the \"ClonesProducedUnits\" trait will produce a free duplicate of me.")] [Desc("Actors with the \"ClonesProducedUnits\" trait will produce a free duplicate of me.")]
public class CloneableInfo : TraitInfo<Cloneable> public class CloneableInfo : TraitInfo<Cloneable>
{ {
[FieldLoader.Require]
[Desc("This unit's cloneable type is:")] [Desc("This unit's cloneable type is:")]
public readonly string[] Types = { }; public readonly string[] Types = { };
} }

View File

@@ -15,7 +15,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
class InfiltrateForSupportPowerInfo : ITraitInfo class InfiltrateForSupportPowerInfo : ITraitInfo
{ {
[ActorReference] public readonly string Proxy = null; [ActorReference, FieldLoader.Require] public readonly string Proxy = null;
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); } public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
} }

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Traits
[Desc("Spawn another actor immediately upon death.")] [Desc("Spawn another actor immediately upon death.")]
public class LeavesHuskInfo : ITraitInfo public class LeavesHuskInfo : ITraitInfo
{ {
[ActorReference] [ActorReference, FieldLoader.Require]
public readonly string HuskActor = null; public readonly string HuskActor = null;
public object Create(ActorInitializer init) { return new LeavesHusk(init, this); } public object Create(ActorInitializer init) { return new LeavesHusk(init, this); }