Fix and enable SA1133, SA1134 style rules.

This commit is contained in:
Paul Chote
2019-05-23 18:43:21 +00:00
committed by abcdefg30
parent fbf9461890
commit 78a70be0d4
214 changed files with 1012 additions and 432 deletions

View File

@@ -49,7 +49,9 @@ namespace OpenRA
public class LocationInit : IActorInit<CPos>
{
[FieldFromYamlKey] readonly CPos value = CPos.Zero;
[FieldFromYamlKey]
readonly CPos value = CPos.Zero;
public LocationInit() { }
public LocationInit(CPos init) { value = init; }
public CPos Value(World world) { return value; }
@@ -57,7 +59,9 @@ namespace OpenRA
public class OwnerInit : IActorInit<Player>
{
[FieldFromYamlKey] public readonly string PlayerName = "Neutral";
[FieldFromYamlKey]
public readonly string PlayerName = "Neutral";
Player player;
public OwnerInit() { }

View File

@@ -21,7 +21,8 @@ namespace OpenRA.Network
{
public class GeoIP2Record
{
[MaxMind.Db.Constructor] public GeoIP2Record(GeoIP2Country country)
[Constructor]
public GeoIP2Record(GeoIP2Country country)
{
Country = country;
}
@@ -31,7 +32,8 @@ namespace OpenRA.Network
public class GeoIP2Country
{
[MaxMind.Db.Constructor] public GeoIP2Country(GeoIP2CountryNames names)
[Constructor]
public GeoIP2Country(GeoIP2CountryNames names)
{
Names = names;
}
@@ -41,7 +43,8 @@ namespace OpenRA.Network
public class GeoIP2CountryNames
{
[MaxMind.Db.Constructor] public GeoIP2CountryNames(string en)
[Constructor]
public GeoIP2CountryNames(string en)
{
English = en;
}

View File

@@ -46,7 +46,8 @@ namespace OpenRA.Network
public string Fingerprint;
public string AuthSignature;
[FieldLoader.Ignore] public Session.Client Client;
[FieldLoader.Ignore]
public Session.Client Client;
public static HandshakeResponse Deserialize(string data)
{

View File

@@ -20,7 +20,8 @@ namespace OpenRA.Traits
public class DebugPauseState : ISync
{
readonly World world;
[Sync] public bool Paused { get { return world.Paused; } }
[Sync]
public bool Paused { get { return world.Paused; } }
public DebugPauseState(World world) { this.world = world; }
}
}

View File

@@ -17,11 +17,13 @@ namespace OpenRA.Traits
[Desc("Add this to the World actor definition.")]
public class FixedColorPaletteInfo : ITraitInfo
{
[PaletteReference]
[Desc("The name of the palette to base off.")]
[PaletteReference] public readonly string Base = TileSet.TerrainPaletteInternalName;
public readonly string Base = TileSet.TerrainPaletteInternalName;
[PaletteDefinition]
[Desc("The name of the resulting palette")]
[PaletteDefinition] public readonly string Name = "resources";
public readonly string Name = "resources";
[Desc("Remap these indices to pre-defined colors.")]
public readonly int[] RemapIndex = { };

View File

@@ -204,8 +204,11 @@ namespace OpenRA.Traits
public class FrozenActorLayer : IRender, ITick, ISync
{
[Sync] public int VisibilityHash;
[Sync] public int FrozenHash;
[Sync]
public int VisibilityHash;
[Sync]
public int FrozenHash;
readonly int binSize;
readonly World world;

View File

@@ -19,11 +19,13 @@ namespace OpenRA.Traits
[Desc("Define a player palette by swapping palette indices.")]
public class IndexedPlayerPaletteInfo : ITraitInfo, IRulesetLoaded
{
[PaletteReference]
[Desc("The name of the palette to base off.")]
[PaletteReference] public readonly string BasePalette = null;
public readonly string BasePalette = null;
[PaletteDefinition(true)]
[Desc("The prefix for the resulting player palettes")]
[PaletteDefinition(true)] public readonly string BaseName = "player";
public readonly string BaseName = "player";
[Desc("Remap these indices to player colors.")]
public readonly int[] RemapIndex = { };

View File

@@ -17,11 +17,13 @@ namespace OpenRA.Traits
[Desc("Add this to the Player actor definition.")]
public class PlayerColorPaletteInfo : ITraitInfo
{
[PaletteReference]
[Desc("The name of the palette to base off.")]
[PaletteReference] public readonly string BasePalette = null;
public readonly string BasePalette = null;
[PaletteDefinition(true)]
[Desc("The prefix for the resulting player palettes")]
[PaletteDefinition(true)] public readonly string BaseName = "player";
public readonly string BaseName = "player";
[Desc("Remap these indices to player colors.")]
public readonly int[] RemapIndex = { };

View File

@@ -18,8 +18,9 @@ namespace OpenRA.Traits
[Desc("Add this to the Player actor definition.")]
public class PlayerHighlightPaletteInfo : ITraitInfo
{
[PaletteDefinition(true)]
[Desc("The prefix for the resulting player palettes")]
[PaletteDefinition(true)] public readonly string BaseName = "highlight";
public readonly string BaseName = "highlight";
public object Create(ActorInitializer init) { return new PlayerHighlightPalette(this); }
}

View File

@@ -102,7 +102,8 @@ namespace OpenRA.Traits
// Per-cell cache of the resolved cell type (shroud/fog/visible)
readonly CellLayer<ShroudCellType> resolvedType;
[Sync] bool disabled;
[Sync]
bool disabled;
public bool Disabled
{
get

View File

@@ -20,7 +20,8 @@ namespace OpenRA.Traits
+ "Defaults to the actor name when not defined or inherited.")]
public readonly string Class = null;
[VoiceReference] public readonly string Voice = "Select";
[VoiceReference]
public readonly string Voice = "Select";
public override object Create(ActorInitializer init) { return new Selectable(init.Self, this); }
}

View File

@@ -154,7 +154,8 @@ namespace OpenRA.Traits
Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued);
}
[Flags] public enum TargetModifiers { None = 0, ForceAttack = 1, ForceQueue = 2, ForceMove = 4 }
[Flags]
public enum TargetModifiers { None = 0, ForceAttack = 1, ForceQueue = 2, ForceMove = 4 }
public static class TargetModifiersExts
{

View File

@@ -21,10 +21,14 @@ namespace OpenRA.Mods.Cnc.Projectiles
{
public readonly string Image = "litning";
[SequenceReference("Image")] public readonly string BrightSequence = "bright";
[SequenceReference("Image")] public readonly string DimSequence = "dim";
[SequenceReference("Image")]
public readonly string BrightSequence = "bright";
[PaletteReference] public readonly string Palette = "effect";
[SequenceReference("Image")]
public readonly string DimSequence = "dim";
[PaletteReference]
public readonly string Palette = "effect";
public readonly int BrightZaps = 1;
public readonly int DimZaps = 2;
@@ -45,7 +49,9 @@ namespace OpenRA.Mods.Cnc.Projectiles
TeslaZapRenderable zap;
int ticksUntilRemove;
int damageDuration;
[Sync] WPos target;
[Sync]
WPos target;
public TeslaZap(TeslaZapInfo info, ProjectileArgs args)
{

View File

@@ -28,14 +28,17 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("The percentage of damage that is received while this actor is closed.")]
public readonly int ClosedDamageMultiplier = 50;
[SequenceReference]
[Desc("Sequence to play when opening.")]
[SequenceReference] public readonly string OpeningSequence = "opening";
public readonly string OpeningSequence = "opening";
[SequenceReference]
[Desc("Sequence to play when closing.")]
[SequenceReference] public readonly string ClosingSequence = "closing";
public readonly string ClosingSequence = "closing";
[SequenceReference]
[Desc("Idle sequence to play when closed.")]
[SequenceReference] public readonly string ClosedIdleSequence = "closed-idle";
public readonly string ClosedIdleSequence = "closed-idle";
[Desc("Which sprite body to play the animation on.")]
public readonly string Body = "body";

View File

@@ -41,8 +41,11 @@ namespace OpenRA.Mods.Cnc.Traits
{
readonly AttackTeslaInfo info;
[Sync] int charges;
[Sync] int timeToRecharge;
[Sync]
int charges;
[Sync]
int timeToRecharge;
public AttackTesla(Actor self, AttackTeslaInfo info)
: base(self, info)

View File

@@ -25,8 +25,9 @@ namespace OpenRA.Mods.Cnc.Traits
[NotificationReference("Speech")]
public readonly string ReadyAudio = "Reinforce";
[ActorReference(typeof(AircraftInfo))]
[Desc("Cargo aircraft used for delivery. Must have the `Aircraft` trait.")]
[ActorReference(typeof(AircraftInfo))] public readonly string ActorType = "c17";
public readonly string ActorType = "c17";
public override object Create(ActorInitializer init) { return new ProductionAirdrop(init, this); }
}

View File

@@ -48,8 +48,11 @@ namespace OpenRA.Mods.Cnc.Traits
IPositionable iPositionable;
// Return-to-origin logic
[Sync] public CPos Origin;
[Sync] public int ReturnTicks = 0;
[Sync]
public CPos Origin;
[Sync]
public int ReturnTicks = 0;
public Chronoshiftable(ActorInitializer init, ChronoshiftableInfo info)
: base(info)
@@ -180,7 +183,9 @@ namespace OpenRA.Mods.Cnc.Traits
public class ChronoshiftReturnInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value = 0;
[FieldFromYamlKey]
readonly int value = 0;
public ChronoshiftReturnInit() { }
public ChronoshiftReturnInit(int init) { value = init; }
public int Value(World world) { return value; }
@@ -188,7 +193,9 @@ namespace OpenRA.Mods.Cnc.Traits
public class ChronoshiftDurationInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value = 0;
[FieldFromYamlKey]
readonly int value = 0;
public ChronoshiftDurationInit() { }
public ChronoshiftDurationInit(int init) { value = init; }
public int Value(World world) { return value; }
@@ -196,7 +203,9 @@ namespace OpenRA.Mods.Cnc.Traits
public class ChronoshiftOriginInit : IActorInit<CPos>
{
[FieldFromYamlKey] readonly CPos value;
[FieldFromYamlKey]
readonly CPos value;
public ChronoshiftOriginInit(CPos init) { value = init; }
public CPos Value(World world) { return value; }
}

View File

@@ -25,7 +25,8 @@ namespace OpenRA.Mods.Cnc.Traits
"Otherwise, a vortex animation is played and damage is dealt each tick, ignoring modifiers.")]
public class ConyardChronoReturnInfo : IObservesVariablesInfo, Requires<HealthInfo>, Requires<WithSpriteBodyInfo>
{
[Desc("Sequence name with the baked-in vortex animation"), SequenceReference]
[SequenceReference]
[Desc("Sequence name with the baked-in vortex animation")]
public readonly string Sequence = "pdox";
[Desc("Sprite body to play the vortex animation on.")]

View File

@@ -73,7 +73,8 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Provides access to the disguise command, which makes the actor appear to be another player's actor.")]
class DisguiseInfo : ITraitInfo
{
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
[GrantedConditionReference]
[Desc("The condition to grant to self while disguised.")]

View File

@@ -20,10 +20,12 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sprite collection for symbols.")]
public readonly string Image = "gpsdot";
[SequenceReference("Image")]
[Desc("Sprite used for this actor.")]
[SequenceReference("Image")] public readonly string String = "Infantry";
public readonly string String = "Infantry";
[PaletteReference(true)] public readonly string IndicatorPalettePrefix = "player";
[PaletteReference(true)]
public readonly string IndicatorPalettePrefix = "player";
public object Create(ActorInitializer init) { return new GpsDot(this); }
}

View File

@@ -26,12 +26,18 @@ namespace OpenRA.Mods.Cnc.Traits
class GpsWatcher : ISync, IPreventsShroudReset
{
[Sync] public bool Launched { get; private set; }
[Sync] public bool GrantedAllies { get; private set; }
[Sync] public bool Granted { get; private set; }
[Sync]
public bool Launched { get; private set; }
[Sync]
public bool GrantedAllies { get; private set; }
[Sync]
public bool Granted { get; private set; }
// Whether this watcher has explored the terrain (by becoming Launched, or an ally becoming Launched)
[Sync] bool explored;
[Sync]
bool explored;
readonly Player owner;

View File

@@ -17,7 +17,9 @@ namespace OpenRA.Mods.Cnc.Traits
{
class InfiltrateForSupportPowerInfo : ITraitInfo
{
[ActorReference, FieldLoader.Require] public readonly string Proxy = null;
[ActorReference]
[FieldLoader.Require]
public readonly string Proxy = null;
public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>);

View File

@@ -21,7 +21,8 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Transform into a different actor type.")]
class InfiltrateForTransformInfo : ITraitInfo
{
[ActorReference, FieldLoader.Require]
[ActorReference]
[FieldLoader.Require]
public readonly string IntoActor = null;
public readonly int ForceHealthPercentage = 0;

View File

@@ -25,40 +25,52 @@ namespace OpenRA.Mods.Cnc.Traits
{
class MadTankInfo : ITraitInfo, IRulesetLoaded, Requires<ExplodesInfo>, Requires<WithFacingSpriteBodyInfo>
{
[SequenceReference] public readonly string ThumpSequence = "piston";
[SequenceReference]
public readonly string ThumpSequence = "piston";
public readonly int ThumpInterval = 8;
[WeaponReference]
public readonly string ThumpDamageWeapon = "MADTankThump";
public readonly int ThumpShakeIntensity = 3;
public readonly float2 ThumpShakeMultiplier = new float2(1, 0);
public readonly int ThumpShakeTime = 10;
[Desc("Measured in ticks.")]
public readonly int ChargeDelay = 96;
public readonly string ChargeSound = "madchrg2.aud";
[Desc("Measured in ticks.")]
public readonly int DetonationDelay = 42;
public readonly string DetonationSound = "madexplo.aud";
[WeaponReference]
public readonly string DetonationWeapon = "MADTankDetonate";
[ActorReference]
public readonly string DriverActor = "e1";
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
[GrantedConditionReference]
[Desc("The condition to grant to self while deployed.")]
public readonly string DeployedCondition = null;
public WeaponInfo ThumpDamageWeaponInfo { get; private set; }
public WeaponInfo DetonationWeaponInfo { get; private set; }
[Desc("Types of damage that this trait causes to self while self-destructing. Leave empty for no damage types.")]
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
public object Create(ActorInitializer init) { return new MadTank(init.Self, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
WeaponInfo thumpDamageWeapon;

View File

@@ -23,14 +23,16 @@ namespace OpenRA.Mods.Cnc.Traits
{
public class MinelayerInfo : ITraitInfo, Requires<RearmableInfo>
{
[ActorReference] public readonly string Mine = "minv";
[ActorReference]
public readonly string Mine = "minv";
public readonly string AmmoPoolName = "primary";
public readonly WDist MinefieldDepth = new WDist(1536);
[VoiceReference]
[Desc("Voice to use when ordered to lay a minefield.")]
[VoiceReference] public readonly string Voice = "Action";
public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new Minelayer(init.Self, this); }
}
@@ -39,10 +41,13 @@ namespace OpenRA.Mods.Cnc.Traits
{
readonly MinelayerInfo info;
/* TODO: [Sync] when sync can cope with arrays! */
// TODO: [Sync] when sync can cope with arrays!
public CPos[] Minefield = null;
readonly Sprite tile;
[Sync] CPos minefieldStart;
[Sync]
CPos minefieldStart;
public Minelayer(Actor self, MinelayerInfo info)
{

View File

@@ -52,7 +52,8 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Flash the screen on teleporting.")]
public readonly bool FlashScreen = false;
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new PortableChrono(init.Self, this); }
}
@@ -61,7 +62,8 @@ namespace OpenRA.Mods.Cnc.Traits
{
public readonly PortableChronoInfo Info;
readonly IMove move;
[Sync] int chargeTick = 0;
[Sync]
int chargeTick = 0;
public PortableChrono(Actor self, PortableChronoInfo info)
{

View File

@@ -20,9 +20,11 @@ namespace OpenRA.Mods.Cnc.Traits
{
public class WithBuildingBibInfo : ITraitInfo, Requires<BuildingInfo>, IRenderActorPreviewSpritesInfo, IActorPreviewInitInfo, Requires<RenderSpritesInfo>
{
[SequenceReference] public readonly string Sequence = "bib";
[SequenceReference]
public readonly string Sequence = "bib";
[PaletteReference] public readonly string Palette = TileSet.TerrainPaletteInternalName;
[PaletteReference]
public readonly string Palette = TileSet.TerrainPaletteInternalName;
public readonly bool HasMinibib = false;
@@ -130,7 +132,9 @@ namespace OpenRA.Mods.Cnc.Traits
class HideBibPreviewInit : IActorInit<bool>, ISuppressInitExport
{
[FieldFromYamlKey] readonly bool value = true;
[FieldFromYamlKey]
readonly bool value = true;
public HideBibPreviewInit() { }
public HideBibPreviewInit(bool init) { value = init; }
public bool Value(World world) { return value; }

View File

@@ -19,7 +19,8 @@ namespace OpenRA.Mods.Cnc.Traits.Render
[Desc("Building animation to play when ProductionAirdrop is used to deliver units.")]
public class WithDeliveryAnimationInfo : ConditionalTraitInfo, Requires<WithSpriteBodyInfo>
{
[SequenceReference] public readonly string ActiveSequence = "active";
[SequenceReference]
public readonly string ActiveSequence = "active";
[Desc("Which sprite body to play the animation on.")]
public readonly string Body = "body";

View File

@@ -19,14 +19,16 @@ namespace OpenRA.Mods.Cnc.Traits.Render
[Desc("Rendered on the refinery when a voxel harvester is docking and undocking.")]
public class WithDockingOverlayInfo : PausableConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{
[SequenceReference]
[Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "unload-overlay";
public readonly string Sequence = "unload-overlay";
[Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero;
[PaletteReference("IsPlayerPalette")]
[Desc("Custom palette name")]
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
public readonly string Palette = null;
[Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;

View File

@@ -23,10 +23,17 @@ namespace OpenRA.Mods.Cnc.Traits.Render
[Desc("Turreted 'Turret' key to display")]
public readonly string Turret = "primary";
[SequenceReference] public readonly string LeftSequence = "left";
[SequenceReference] public readonly string RightSequence = "right";
[SequenceReference] public readonly string WakeLeftSequence = "wake-left";
[SequenceReference] public readonly string WakeRightSequence = "wake-right";
[SequenceReference]
public readonly string LeftSequence = "left";
[SequenceReference]
public readonly string RightSequence = "right";
[SequenceReference]
public readonly string WakeLeftSequence = "wake-left";
[SequenceReference]
public readonly string WakeRightSequence = "wake-right";
public override object Create(ActorInitializer init) { return new WithGunboatBody(init, this); }
}

View File

@@ -20,9 +20,15 @@ namespace OpenRA.Mods.Cnc.Traits.Render
public class WithLandingCraftAnimationInfo : ITraitInfo, Requires<IMoveInfo>, Requires<WithSpriteBodyInfo>, Requires<CargoInfo>
{
public readonly HashSet<string> OpenTerrainTypes = new HashSet<string> { "Clear" };
[SequenceReference] public readonly string OpenSequence = "open";
[SequenceReference] public readonly string CloseSequence = "close";
[SequenceReference] public readonly string UnloadSequence = "unload";
[SequenceReference]
public readonly string OpenSequence = "open";
[SequenceReference]
public readonly string CloseSequence = "close";
[SequenceReference]
public readonly string UnloadSequence = "unload";
[Desc("Which sprite body to play the animation on.")]
public readonly string Body = "body";

View File

@@ -18,7 +18,8 @@ namespace OpenRA.Mods.Cnc.Traits.Render
[Desc("Provides an overlay for the Tiberian Dawn hover craft.")]
public class WithRoofInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
[SequenceReference] public readonly string Sequence = "roof";
[SequenceReference]
public readonly string Sequence = "roof";
public object Create(ActorInitializer init) { return new WithRoof(init.Self, this); }
}

View File

@@ -18,8 +18,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render
[Desc("This actor displays a charge-up animation before firing.")]
public class WithTeslaChargeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<RenderSpritesInfo>
{
[SequenceReference]
[Desc("Sequence to use for charge animation.")]
[SequenceReference] public readonly string ChargeSequence = "active";
public readonly string ChargeSequence = "active";
[Desc("Which sprite body to play the animation on.")]
public readonly string Body = "body";

View File

@@ -19,11 +19,13 @@ namespace OpenRA.Mods.Cnc.Traits.Render
[Desc("Rendered together with AttackCharge.")]
public class WithTeslaChargeOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
{
[SequenceReference]
[Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "active";
public readonly string Sequence = "active";
[PaletteReference("IsPlayerPalette")]
[Desc("Custom palette name")]
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
public readonly string Palette = null;
[Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;

View File

@@ -97,7 +97,9 @@ namespace OpenRA.Mods.Cnc.Traits.Render
public class BodyAnimationFrameInit : IActorInit<uint>
{
[FieldFromYamlKey] readonly uint value = 0;
[FieldFromYamlKey]
readonly uint value = 0;
public BodyAnimationFrameInit() { }
public BodyAnimationFrameInit(uint init) { value = init; }
public uint Value(World world) { return value; }

View File

@@ -28,12 +28,19 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Ticks until returning after teleportation.")]
public readonly int Duration = 750;
[PaletteReference] public readonly string TargetOverlayPalette = TileSet.TerrainPaletteInternalName;
[PaletteReference]
public readonly string TargetOverlayPalette = TileSet.TerrainPaletteInternalName;
public readonly string OverlaySpriteGroup = "overlay";
[SequenceReference("OverlaySpriteGroup", true)] public readonly string ValidTileSequencePrefix = "target-valid-";
[SequenceReference("OverlaySpriteGroup")] public readonly string InvalidTileSequence = "target-invalid";
[SequenceReference("OverlaySpriteGroup")] public readonly string SourceTileSequence = "target-select";
[SequenceReference("OverlaySpriteGroup", true)]
public readonly string ValidTileSequencePrefix = "target-valid-";
[SequenceReference("OverlaySpriteGroup")]
public readonly string InvalidTileSequence = "target-invalid";
[SequenceReference("OverlaySpriteGroup")]
public readonly string SourceTileSequence = "target-select";
public readonly bool KillCargo = true;

View File

@@ -24,19 +24,25 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly int RevealDelay = 0;
public readonly string DoorImage = "atek";
[SequenceReference("DoorImage")] public readonly string DoorSequence = "active";
[SequenceReference("DoorImage")]
public readonly string DoorSequence = "active";
[PaletteReference("DoorPaletteIsPlayerPalette")]
[Desc("Palette to use for rendering the launch animation")]
[PaletteReference("DoorPaletteIsPlayerPalette")] public readonly string DoorPalette = "player";
public readonly string DoorPalette = "player";
[Desc("Custom palette is a player palette BaseName")]
public readonly bool DoorPaletteIsPlayerPalette = true;
public readonly string SatelliteImage = "sputnik";
[SequenceReference("SatelliteImage")] public readonly string SatelliteSequence = "idle";
[SequenceReference("SatelliteImage")]
public readonly string SatelliteSequence = "idle";
[PaletteReference("SatellitePaletteIsPlayerPalette")]
[Desc("Palette to use for rendering the satellite projectile")]
[PaletteReference("SatellitePaletteIsPlayerPalette")] public readonly string SatellitePalette = "player";
public readonly string SatellitePalette = "player";
[Desc("Custom palette is a player palette BaseName")]
public readonly bool SatellitePaletteIsPlayerPalette = true;

View File

@@ -30,12 +30,15 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Effect sequence sprite image")]
public readonly string Effect = "ionsfx";
[SequenceReference("Effect")]
[Desc("Effect sequence to display")]
[SequenceReference("Effect")] public readonly string EffectSequence = "idle";
public readonly string EffectSequence = "idle";
[PaletteReference] public readonly string EffectPalette = "effect";
[PaletteReference]
public readonly string EffectPalette = "effect";
[Desc("Which weapon to fire"), WeaponReference]
[WeaponReference]
[Desc("Which weapon to fire")]
public readonly string Weapon = "IonCannon";
public WeaponInfo WeaponInfo { get; private set; }

View File

@@ -64,8 +64,12 @@ namespace OpenRA.Mods.Cnc.Traits
IEnumerable<int> speedModifiers;
[Sync] public int Facing { get; set; }
[Sync] public WPos CenterPosition { get; private set; }
[Sync]
public int Facing { get; set; }
[Sync]
public WPos CenterPosition { get; private set; }
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
// Isn't used anyway

View File

@@ -21,7 +21,8 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Adds the hard-coded shroud palette to the game")]
class TSShroudPaletteInfo : ITraitInfo
{
[FieldLoader.Require, PaletteDefinition]
[PaletteDefinition]
[FieldLoader.Require]
[Desc("Internal palette name")]
public readonly string Name = "shroud";

View File

@@ -16,7 +16,9 @@ namespace OpenRA.Mods.Common
{
public class FacingInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value = 128;
[FieldFromYamlKey]
readonly int value = 128;
public FacingInit() { }
public FacingInit(int init) { value = init; }
public int Value(World world) { return value; }
@@ -25,13 +27,16 @@ namespace OpenRA.Mods.Common
public class DynamicFacingInit : IActorInit<Func<int>>
{
readonly Func<int> func;
public DynamicFacingInit(Func<int> func) { this.func = func; }
public Func<int> Value(World world) { return func; }
}
public class SubCellInit : IActorInit<SubCell>
{
[FieldFromYamlKey] readonly byte value = (byte)SubCell.FullCell;
[FieldFromYamlKey]
readonly byte value = (byte)SubCell.FullCell;
public SubCellInit() { }
public SubCellInit(byte init) { value = init; }
public SubCellInit(SubCell init) { value = (byte)init; }
@@ -40,7 +45,9 @@ namespace OpenRA.Mods.Common
public class CenterPositionInit : IActorInit<WPos>
{
[FieldFromYamlKey] readonly WPos value = WPos.Zero;
[FieldFromYamlKey]
readonly WPos value = WPos.Zero;
public CenterPositionInit() { }
public CenterPositionInit(WPos init) { value = init; }
public WPos Value(World world) { return value; }
@@ -49,7 +56,8 @@ namespace OpenRA.Mods.Common
// Allows maps / transformations to specify the faction variant of an actor.
public class FactionInit : IActorInit<string>
{
[FieldFromYamlKey] public readonly string Faction;
[FieldFromYamlKey]
public readonly string Faction;
public FactionInit() { }
public FactionInit(string faction) { Faction = faction; }
@@ -58,7 +66,8 @@ namespace OpenRA.Mods.Common
public class EffectiveOwnerInit : IActorInit<Player>
{
[FieldFromYamlKey] readonly Player value = null;
[FieldFromYamlKey]
readonly Player value = null;
public EffectiveOwnerInit() { }
public EffectiveOwnerInit(Player owner) { value = owner; }

View File

@@ -49,8 +49,11 @@ namespace OpenRA
public readonly string Title;
[FieldLoader.Ignore] public readonly MiniYaml IDFiles;
[FieldLoader.Ignore] public readonly List<MiniYamlNode> Install;
[FieldLoader.Ignore]
public readonly MiniYaml IDFiles;
[FieldLoader.Ignore]
public readonly List<MiniYamlNode> Install;
public ModSource(MiniYaml yaml)
{

View File

@@ -82,9 +82,15 @@ namespace OpenRA.Mods.Common.Projectiles
readonly Color color;
readonly WDist speed;
[Sync] WPos headPos;
[Sync] WPos tailPos;
[Sync] WPos target;
[Sync]
WPos headPos;
[Sync]
WPos tailPos;
[Sync]
WPos target;
int length;
int towardsTargetFacing;
int headTicks;

View File

@@ -33,11 +33,13 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Image to display.")]
public readonly string Image = null;
[SequenceReference("Image")]
[Desc("Loop a randomly chosen sequence of Image from this list while this projectile is moving.")]
[SequenceReference("Image")] public readonly string[] Sequences = { "idle" };
public readonly string[] Sequences = { "idle" };
[PaletteReference]
[Desc("The palette used to draw this projectile.")]
[PaletteReference] public readonly string Palette = "effect";
public readonly string Palette = "effect";
[Desc("Palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;
@@ -45,14 +47,16 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Does this projectile have a shadow?")]
public readonly bool Shadow = false;
[PaletteReference]
[Desc("Palette to use for this projectile's shadow if Shadow is true.")]
[PaletteReference] public readonly string ShadowPalette = "shadow";
public readonly string ShadowPalette = "shadow";
[Desc("Trail animation.")]
public readonly string TrailImage = null;
[SequenceReference("TrailImage")]
[Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")]
[SequenceReference("TrailImage")] public readonly string[] TrailSequences = { "idle" };
public readonly string[] TrailSequences = { "idle" };
[Desc("Interval in ticks between each spawned Trail animation.")]
public readonly int TrailInterval = 2;
@@ -60,8 +64,9 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Delay in ticks until trail animation is spawned.")]
public readonly int TrailDelay = 1;
[PaletteReference("TrailUsePlayerPalette")]
[Desc("Palette used to render the trail sequence.")]
[PaletteReference("TrailUsePlayerPalette")] public readonly string TrailPalette = "effect";
public readonly string TrailPalette = "effect";
[Desc("Use the Player Palette to render the trail sequence.")]
public readonly bool TrailUsePlayerPalette = false;

View File

@@ -20,21 +20,25 @@ namespace OpenRA.Mods.Common.Projectiles
{
public readonly string Image = null;
[SequenceReference("Image")]
[Desc("Loop a randomly chosen sequence of Image from this list while falling.")]
[SequenceReference("Image")] public readonly string[] Sequences = { "idle" };
public readonly string[] Sequences = { "idle" };
[SequenceReference("Image")]
[Desc("Sequence to play when launched. Skipped if null or empty.")]
[SequenceReference("Image")] public readonly string OpenSequence = null;
public readonly string OpenSequence = null;
[PaletteReference]
[Desc("The palette used to draw this projectile.")]
[PaletteReference] public readonly string Palette = "effect";
public readonly string Palette = "effect";
[Desc("Palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;
public readonly bool Shadow = false;
[PaletteReference] public readonly string ShadowPalette = "shadow";
[PaletteReference]
public readonly string ShadowPalette = "shadow";
[Desc("Projectile movement vector per tick (forward, right, up), use negative values for opposite directions.")]
public readonly WVec Velocity = WVec.Zero;

View File

@@ -75,19 +75,23 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Impact animation.")]
public readonly string HitAnim = null;
[SequenceReference("HitAnim")]
[Desc("Sequence of impact animation to use.")]
[SequenceReference("HitAnim")] public readonly string HitAnimSequence = "idle";
public readonly string HitAnimSequence = "idle";
[PaletteReference] public readonly string HitAnimPalette = "effect";
[PaletteReference]
public readonly string HitAnimPalette = "effect";
[Desc("Image containing launch effect sequence.")]
public readonly string LaunchEffectImage = null;
[SequenceReference("LaunchEffectImage")]
[Desc("Launch effect sequence to play.")]
[SequenceReference("LaunchEffectImage")] public readonly string LaunchEffectSequence = null;
public readonly string LaunchEffectSequence = null;
[PaletteReference]
[Desc("Palette to use for launch effect.")]
[PaletteReference] public readonly string LaunchEffectPalette = "effect";
public readonly string LaunchEffectPalette = "effect";
public IProjectile Create(ProjectileArgs args)
{

View File

@@ -26,11 +26,13 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Name of the image containing the projectile sequence.")]
public readonly string Image = null;
[SequenceReference("Image")]
[Desc("Loop a randomly chosen sequence of Image from this list while this projectile is moving.")]
[SequenceReference("Image")] public readonly string[] Sequences = { "idle" };
public readonly string[] Sequences = { "idle" };
[PaletteReference]
[Desc("Palette used to render the projectile sequence.")]
[PaletteReference] public readonly string Palette = "effect";
public readonly string Palette = "effect";
[Desc("Palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;
@@ -101,11 +103,13 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Image that contains the trail animation.")]
public readonly string TrailImage = null;
[SequenceReference("TrailImage")]
[Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")]
[SequenceReference("TrailImage")] public readonly string[] TrailSequences = { "idle" };
public readonly string[] TrailSequences = { "idle" };
[PaletteReference("TrailUsePlayerPalette")]
[Desc("Palette used to render the trail sequence.")]
[PaletteReference("TrailUsePlayerPalette")] public readonly string TrailPalette = "effect";
public readonly string TrailPalette = "effect";
[Desc("Use the Player Palette to render the trail sequence.")]
public readonly bool TrailUsePlayerPalette = false;

View File

@@ -19,7 +19,8 @@ namespace OpenRA.Mods.Common.SpriteLoaders
{
public class ShpD2Loader : ISpriteLoader
{
[Flags] enum FormatFlags : int
[Flags]
enum FormatFlags : int
{
PaletteTable = 1,
NotLCWCompressed = 2,

View File

@@ -33,9 +33,14 @@ namespace OpenRA.Mods.Common.Traits
readonly HashSet<PPos> footprint;
[Sync] CPos cachedLocation;
[Sync] WDist cachedRange;
[Sync] protected bool CachedTraitDisabled { get; private set; }
[Sync]
CPos cachedLocation;
[Sync]
WDist cachedRange;
[Sync]
protected bool CachedTraitDisabled { get; private set; }
protected abstract void AddCellsToPlayerShroud(Actor self, Player player, PPos[] uv);
protected abstract void RemoveCellsFromPlayerShroud(Actor self, Player player);

View File

@@ -58,7 +58,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Types of damage that are caused while crushing. Leave empty for no damage types.")]
public readonly BitSet<DamageType> CrushDamageTypes = default(BitSet<DamageType>);
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
[GrantedConditionReference]
[Desc("The condition to grant to self while airborne.")]
@@ -184,8 +185,12 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<int> speedModifiers;
INotifyMoving[] notifyMoving;
[Sync] public int Facing { get; set; }
[Sync] public WPos CenterPosition { get; private set; }
[Sync]
public int Facing { get; set; }
[Sync]
public WPos CenterPosition { get; private set; }
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
public int TurnSpeed { get { return Info.TurnSpeed; } }
public Actor ReservedActor { get; private set; }

View File

@@ -27,9 +27,15 @@ namespace OpenRA.Mods.Common.Traits
public class AttackBomber : AttackBase, ITick, ISync, INotifyRemovedFromWorld
{
readonly AttackBomberInfo info;
[Sync] Target target;
[Sync] bool inAttackRange;
[Sync] bool facingTarget = true;
[Sync]
Target target;
[Sync]
bool inAttackRange;
[Sync]
bool facingTarget = true;
public event Action<Actor> OnRemovedFromWorld = self => { };
public event Action<Actor> OnEnteredAttackRange = self => { };

View File

@@ -63,9 +63,11 @@ namespace OpenRA.Mods.Common.Traits
ConditionManager conditionManager;
// HACK: Temporarily needed until Rearm activity is gone for good
[Sync] public int RemainingTicks;
[Sync]
public int RemainingTicks;
[Sync] int currentAmmo;
[Sync]
int currentAmmo;
public AmmoPool(Actor self, AmmoPoolInfo info)
{

View File

@@ -29,7 +29,8 @@ namespace OpenRA.Mods.Common.Traits
{
public readonly string Name = "primary";
[WeaponReference, FieldLoader.Require]
[WeaponReference]
[FieldLoader.Require]
[Desc("Has to be defined in weapons.yaml as well.")]
public readonly string Weapon = null;
@@ -55,8 +56,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Muzzle flash sequence to render")]
public readonly string MuzzleSequence = null;
[PaletteReference]
[Desc("Palette to render Muzzle flash sequence in")]
[PaletteReference] public readonly string MuzzlePalette = "effect";
public readonly string MuzzlePalette = "effect";
[Desc("Use multiple muzzle images if non-zero")]
public readonly int MuzzleSplitFacings = 0;

View File

@@ -37,7 +37,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Force-fire mode ignores actors and targets the ground instead.")]
public readonly bool ForceFireIgnoresActors = false;
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
[Desc("Tolerance for attack angle. Range [0, 128], 128 covers 360 degrees.")]
public readonly int FacingTolerance = 128;
@@ -58,7 +59,9 @@ namespace OpenRA.Mods.Common.Traits
readonly string attackOrderName = "Attack";
readonly string forceAttackOrderName = "ForceAttack";
[Sync] public bool IsAiming { get; set; }
[Sync]
public bool IsAiming { get; set; }
public IEnumerable<Armament> Armaments { get { return getArmaments(); } }
protected IFacing facing;

View File

@@ -44,7 +44,8 @@ namespace OpenRA.Mods.Common.Traits
public FirePort[] Ports { get; private set; }
[PaletteReference] public readonly string MuzzlePalette = "effect";
[PaletteReference]
public readonly string MuzzlePalette = "effect";
public override object Create(ActorInitializer init) { return new AttackGarrisoned(init.Self, this); }
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)

View File

@@ -22,7 +22,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Provides access to the attack-move command, which will make the actor automatically engage viable targets while moving to the destination.")]
class AttackMoveInfo : ITraitInfo, Requires<IMoveInfo>
{
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
[GrantedConditionReference]
[Desc("The condition to grant to self while an attack-move is active.")]

View File

@@ -127,11 +127,13 @@ namespace OpenRA.Mods.Common.Traits
public class AutoTarget : ConditionalTrait<AutoTargetInfo>, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyCreated, INotifyOwnerChanged
{
public readonly IEnumerable<AttackBase> ActiveAttackBases;
[Sync] int nextScanTime = 0;
[Sync]
int nextScanTime = 0;
public UnitStance Stance { get { return stance; } }
[Sync] public Actor Aggressor;
[Sync]
public Actor Aggressor;
// NOT SYNCED: do not refer to this anywhere other than UI code
public UnitStance PredictedStance;
@@ -441,7 +443,9 @@ namespace OpenRA.Mods.Common.Traits
public class StanceInit : IActorInit<UnitStance>
{
[FieldFromYamlKey] readonly UnitStance value = UnitStance.AttackAnything;
[FieldFromYamlKey]
readonly UnitStance value = UnitStance.AttackAnything;
public StanceInit() { }
public StanceInit(UnitStance init) { value = init; }
public UnitStance Value(World world) { return value; }

View File

@@ -66,7 +66,8 @@ namespace OpenRA.Mods.Common.Traits
readonly BodyOrientationInfo info;
readonly Lazy<int> quantizedFacings;
[Sync] public int QuantizedFacings { get { return quantizedFacings.Value; } }
[Sync]
public int QuantizedFacings { get { return quantizedFacings.Value; } }
public BodyOrientation(ActorInitializer init, BodyOrientationInfo info)
{

View File

@@ -34,11 +34,13 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Force a specific faction variant, overriding the faction of the producing actor.")]
public readonly string ForceFaction = null;
[SequenceReference]
[Desc("Sequence of the actor that contains the icon.")]
[SequenceReference] public readonly string Icon = "icon";
public readonly string Icon = "icon";
[PaletteReference]
[Desc("Palette used for the production icon.")]
[PaletteReference] public readonly string IconPalette = "chrome";
public readonly string IconPalette = "chrome";
[Desc("Base build time in frames (-1 indicates to use the unit's Value).")]
public readonly int BuildDuration = -1;
@@ -49,8 +51,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sort order for the production palette. Smaller numbers are presented earlier.")]
public readonly int BuildPaletteOrder = 9999;
[Translate]
[Desc("Text shown in the production tooltip.")]
[Translate] public readonly string Description = "";
public readonly string Description = "";
public static string GetInitialFaction(ActorInfo ai, string defaultFaction)
{

View File

@@ -40,8 +40,9 @@ namespace OpenRA.Mods.Common.Traits
public readonly int[] NorthOffset = null;
public readonly int[] SouthOffset = null;
[WeaponReference]
[Desc("The name of the weapon to use when demolishing the bridge")]
[WeaponReference] public readonly string DemolishWeapon = "Demolish";
public readonly string DemolishWeapon = "Demolish";
public WeaponInfo DemolishWeaponInfo { get; private set; }

View File

@@ -21,8 +21,9 @@ namespace OpenRA.Mods.Common.Traits
public readonly DamageState DamageState = DamageState.Undamaged;
[ActorReference]
[Desc("Actor type to replace with on repair.")]
[ActorReference] public readonly string ReplaceWithActor = null;
public readonly string ReplaceWithActor = null;
public readonly CVec[] NeighbourOffsets = { };

View File

@@ -247,7 +247,9 @@ namespace OpenRA.Mods.Common.Traits
{
public readonly BuildingInfo Info;
[Sync] readonly CPos topLeft;
[Sync]
readonly CPos topLeft;
readonly Actor self;
readonly BuildingInfluence influence;

View File

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

View File

@@ -19,7 +19,8 @@ namespace OpenRA.Mods.Common.Traits
"If you want more than one unit to be delivered, copy this section and assign IDs like FreeActorWithDelivery@2, ...")]
public class FreeActorWithDeliveryInfo : FreeActorInfo
{
[ActorReference, FieldLoader.Require]
[ActorReference]
[FieldLoader.Require]
[Desc("Name of the delivering actor. This actor must have the `Carryall` trait")]
public readonly string DeliveringActor = null;

View File

@@ -42,7 +42,10 @@ namespace OpenRA.Mods.Common.Traits
public readonly IEnumerable<CPos> Footprint;
public readonly int OpenPosition;
[Sync] public int Position { get; private set; }
[Sync]
public int Position { get; private set; }
int desiredPosition;
int remainingOpenTime;

View File

@@ -26,8 +26,9 @@ namespace OpenRA.Mods.Common.Traits
public readonly CVec[] NeighbourOffsets = { };
[WeaponReference]
[Desc("The name of the weapon to use when demolishing the bridge")]
[WeaponReference] public readonly string DemolishWeapon = "Demolish";
public readonly string DemolishWeapon = "Demolish";
public WeaponInfo DemolishWeaponInfo { get; private set; }

View File

@@ -18,7 +18,9 @@ namespace OpenRA.Mods.Common.Traits
public enum LineBuildDirection { Unset, X, Y }
public class LineBuildDirectionInit : IActorInit<LineBuildDirection>
{
[FieldFromYamlKey] readonly LineBuildDirection value = LineBuildDirection.Unset;
[FieldFromYamlKey]
readonly LineBuildDirection value = LineBuildDirection.Unset;
public LineBuildDirectionInit() { }
public LineBuildDirectionInit(LineBuildDirection init) { value = init; }
public LineBuildDirection Value(World world) { return value; }
@@ -26,7 +28,9 @@ namespace OpenRA.Mods.Common.Traits
public class LineBuildParentInit : IActorInit<Actor[]>
{
[FieldFromYamlKey] public readonly string[] ParentNames = new string[0];
[FieldFromYamlKey]
public readonly string[] ParentNames = new string[0];
readonly Actor[] parents = null;
public LineBuildParentInit() { }

View File

@@ -20,13 +20,18 @@ namespace OpenRA.Mods.Common.Traits
public class RallyPointInfo : ITraitInfo
{
public readonly string Image = "rallypoint";
[SequenceReference("Image")] public readonly string FlagSequence = "flag";
[SequenceReference("Image")] public readonly string CirclesSequence = "circles";
[SequenceReference("Image")]
public readonly string FlagSequence = "flag";
[SequenceReference("Image")]
public readonly string CirclesSequence = "circles";
public readonly string Cursor = "ability";
[PaletteReference("IsPlayerPalette")]
[Desc("Custom indicator palette name")]
[PaletteReference("IsPlayerPalette")] public readonly string Palette = "player";
public readonly string Palette = "player";
[Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = true;
@@ -40,7 +45,9 @@ namespace OpenRA.Mods.Common.Traits
{
const string OrderID = "SetRallyPoint";
[Sync] public CPos Location;
[Sync]
public CPos Location;
public RallyPointInfo Info;
public string PaletteName { get; private set; }

View File

@@ -63,8 +63,11 @@ namespace OpenRA.Mods.Common.Traits
int currentDisplayTick = 0;
int currentDisplayValue = 0;
[Sync] Actor dockedHarv = null;
[Sync] bool preventDock = false;
[Sync]
Actor dockedHarv = null;
[Sync]
bool preventDock = false;
public bool AllowDocking { get { return !preventDock; } }
public CVec DeliveryOffset { get { return info.DockOffset; } }

View File

@@ -28,7 +28,8 @@ namespace OpenRA.Mods.Common.Traits
class Burns : ITick, ISync
{
readonly BurnsInfo info;
[Sync] int ticks;
[Sync]
int ticks;
public Burns(Actor self, BurnsInfo info)
{

View File

@@ -50,7 +50,8 @@ namespace OpenRA.Mods.Common.Traits
public readonly string EnterCursor = "enter";
public readonly string EnterBlockedCursor = "enter-blocked";
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public override object Create(ActorInitializer init) { return new Captures(init.Self, this); }
}

View File

@@ -43,8 +43,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Terrain types that this actor is allowed to eject actors onto. Leave empty for all terrain types.")]
public readonly HashSet<string> UnloadTerrainTypes = new HashSet<string>();
[VoiceReference]
[Desc("Voice to play when ordered to unload the passengers.")]
[VoiceReference] public readonly string UnloadVoice = "Action";
public readonly string UnloadVoice = "Action";
[Desc("Which direction the passenger will face (relative to the transport) when unloading.")]
public readonly int PassengerFacing = 128;

View File

@@ -75,7 +75,8 @@ namespace OpenRA.Mods.Common.Traits
readonly Actor self;
// The actor we are currently carrying.
[Sync] public Actor Carryable { get; private set; }
[Sync]
public Actor Carryable { get; private set; }
public CarryallState State { get; private set; }
int cachedFacing;

View File

@@ -40,7 +40,8 @@ namespace OpenRA.Mods.Common.Traits
{
readonly CashTricklerInfo info;
PlayerResources resources;
[Sync] public int Ticks { get; private set; }
[Sync]
public int Ticks { get; private set; }
public CashTrickler(CashTricklerInfo info)
: base(info)

View File

@@ -16,7 +16,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Modifies the terrain type underneath the actors location.")]
class ChangesTerrainInfo : ITraitInfo, Requires<ImmobileInfo>
{
[FieldLoader.Require] public readonly string TerrainType = null;
[FieldLoader.Require]
public readonly string TerrainType = null;
public object Create(ActorInitializer init) { return new ChangesTerrain(this); }
}

View File

@@ -53,7 +53,8 @@ namespace OpenRA.Mods.Common.Traits
public readonly string CloakSound = null;
public readonly string UncloakSound = null;
[PaletteReference("IsPlayerPalette")] public readonly string Palette = "cloak";
[PaletteReference("IsPlayerPalette")]
public readonly string Palette = "cloak";
public readonly bool IsPlayerPalette = false;
public readonly BitSet<CloakType> CloakTypes = new BitSet<CloakType>("Cloak");
@@ -68,7 +69,9 @@ namespace OpenRA.Mods.Common.Traits
public class Cloak : PausableConditionalTrait<CloakInfo>, IRenderModifier, INotifyDamage, INotifyUnload, INotifyDemolition, INotifyInfiltration,
INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, INotifyCreated, INotifyHarvesterAction
{
[Sync] int remainingTime;
[Sync]
int remainingTime;
bool isDocking;
ConditionManager conditionManager;
Cloak[] otherCloaks;

View File

@@ -51,7 +51,8 @@ namespace OpenRA.Mods.Common.Traits
yield return new VariableObserver(RequiredConditionsChanged, Info.RequiresCondition.Variables);
}
[Sync] public bool IsTraitDisabled { get; private set; }
[Sync]
public bool IsTraitDisabled { get; private set; }
public ConditionalTrait(InfoType info)
{

View File

@@ -54,7 +54,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Skip make/deploy animation?")]
public readonly bool SkipMakeAnimation = false;
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public override object Create(ActorInitializer init) { return new GrantConditionOnDeploy(init, this); }
}

View File

@@ -44,7 +44,9 @@ namespace OpenRA.Mods.Common.Traits
ConditionManager conditionManager;
int token = ConditionManager.InvalidConditionToken;
[Sync] int ticks;
[Sync]
int ticks;
public GrantConditionOnProduction(Actor self, GrantConditionOnProductionInfo info)
{

View File

@@ -38,7 +38,8 @@ namespace OpenRA.Mods.Common.Traits
/// </summary>
public abstract class PausableConditionalTrait<InfoType> : ConditionalTrait<InfoType> where InfoType : PausableConditionalTraitInfo
{
[Sync] public bool IsTraitPaused { get; private set; }
[Sync]
public bool IsTraitPaused { get; private set; }
protected PausableConditionalTrait(InfoType info) : base(info) { IsTraitPaused = info.PausedByDefault; }

View File

@@ -46,7 +46,8 @@ namespace OpenRA.Mods.Common.Traits
int conditionToken = ConditionManager.InvalidConditionToken;
// If the trait is paused this may be true with no condition granted
[Sync] bool enabled = false;
[Sync]
bool enabled = false;
public ToggleConditionOnOrder(Actor self, ToggleConditionOnOrderInfo info)
: base(info) { }

View File

@@ -79,8 +79,11 @@ namespace OpenRA.Mods.Common.Traits
readonly CrateInfo info;
bool collected;
[Sync] int ticks;
[Sync] public CPos Location;
[Sync]
int ticks;
[Sync]
public CPos Location;
public Crate(ActorInitializer init, CrateInfo info)
{

View File

@@ -23,17 +23,20 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Image containing the crate effect animation sequence.")]
public readonly string Image = "crate-effects";
[SequenceReference("Image")]
[Desc("Animation sequence played when collected. Leave empty for no effect.")]
[SequenceReference("Image")] public readonly string Sequence = null;
public readonly string Sequence = null;
[PaletteReference]
[Desc("Palette to draw the animation in.")]
[PaletteReference] public readonly string Palette = "effect";
public readonly string Palette = "effect";
[Desc("Audio clip to play when the crate is collected.")]
public readonly string Sound = null;
[NotificationReference("Speech")]
[Desc("Notification to play when the crate is collected.")]
[NotificationReference("Speech")] public readonly string Notification = null;
public readonly string Notification = null;
[Desc("The earliest time (in ticks) that this crate action can occur on.")]
public readonly int TimeDelay = 0;
@@ -41,8 +44,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Only allow this crate action when the collector has these prerequisites")]
public readonly string[] Prerequisites = { };
[ActorReference]
[Desc("Actor types that this crate action will not occur for.")]
[ActorReference] public string[] ExcludedActorTypes = { };
public string[] ExcludedActorTypes = { };
public override object Create(ActorInitializer init) { return new CrateAction(init.Self, this); }
}

View File

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

View File

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

View File

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

View File

@@ -18,8 +18,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This actor receives damage from the given weapon when on the specified terrain type.")]
class DamagedByTerrainInfo : ConditionalTraitInfo, Requires<IHealthInfo>
{
[FieldLoader.Require]
[Desc("Amount of damage received per DamageInterval ticks.")]
[FieldLoader.Require] public readonly int Damage = 0;
public readonly int Damage = 0;
[Desc("Delay between receiving damage.")]
public readonly int DamageInterval = 0;
@@ -27,8 +28,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Apply the damage using these damagetypes.")]
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
[FieldLoader.Require]
[Desc("Terrain types where the actor will take damage.")]
[FieldLoader.Require] public readonly string[] Terrain = { };
public readonly string[] Terrain = { };
[Desc("Percentage health below which the actor will not receive further damage.")]
public readonly int DamageThreshold = 0;
@@ -43,8 +45,11 @@ namespace OpenRA.Mods.Common.Traits
{
readonly IHealth health;
[Sync] int damageTicks;
[Sync] int damageThreshold;
[Sync]
int damageTicks;
[Sync]
int damageThreshold;
public DamagedByTerrain(Actor self, DamagedByTerrainInfo info) : base(info)
{

View File

@@ -32,7 +32,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Sound to play when delivering cash")]
public readonly string[] Sounds = { };
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new DeliversCash(this); }
}

View File

@@ -26,7 +26,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Identifier checked against AcceptsDeliveredExperience.ValidTypes. Only needed if the latter is not empty.")]
public readonly string Type = null;
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new DeliversExperience(init, this); }
}

View File

@@ -37,8 +37,9 @@ namespace OpenRA.Mods.Common.Traits
"Possible values are Exit, Suicide, Dispose.")]
public readonly EnterBehaviour EnterBehaviour = EnterBehaviour.Exit;
[VoiceReference]
[Desc("Voice string when planting explosive charges.")]
[VoiceReference] public readonly string Voice = "Action";
public readonly string Voice = "Action";
public readonly Stance TargetStances = Stance.Enemy | Stance.Neutral;
public readonly Stance ForceTargetStances = Stance.Enemy | Stance.Neutral | Stance.Ally;

View File

@@ -24,7 +24,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Uses the \"EngineerRepairable\" trait to determine repairability.")]
public readonly BitSet<EngineerRepairType> Types = default(BitSet<EngineerRepairType>);
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
[Desc("Behaviour when entering the structure.",
"Possible values are Exit, Suicide, Dispose.")]

View File

@@ -23,7 +23,8 @@ namespace OpenRA.Mods.Common.Traits
public readonly string EnterCursor = "enter";
public readonly string EnterBlockedCursor = "enter-blocked";
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new EntersTunnels(init.Self, this); }
}

View File

@@ -32,7 +32,9 @@ namespace OpenRA.Mods.Common.Traits
{
readonly ExperienceTricklerInfo info;
GainsExperience gainsExperience;
[Sync] int ticks;
[Sync]
int ticks;
public ExperienceTrickler(Actor self, ExperienceTricklerInfo info)
: base(info)

View File

@@ -23,10 +23,13 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This actor explodes when killed.")]
public class ExplodesInfo : ConditionalTraitInfo, Requires<IHealthInfo>
{
[WeaponReference, FieldLoader.Require, Desc("Default weapon to use for explosion if ammo/payload is loaded.")]
[WeaponReference]
[FieldLoader.Require]
[Desc("Default weapon to use for explosion if ammo/payload is loaded.")]
public readonly string Weapon = null;
[WeaponReference, Desc("Fallback weapon to use for explosion if empty (no ammo/payload).")]
[WeaponReference]
[Desc("Fallback weapon to use for explosion if empty (no ammo/payload).")]
public readonly string EmptyWeapon = "UnitExplode";
[Desc("Chance that the explosion will use Weapon instead of EmptyWeapon when exploding, provided the actor has ammo/payload.")]

View File

@@ -18,7 +18,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This actor triggers an explosion on itself when transitioning to a specific damage state.")]
public class ExplosionOnDamageTransitionInfo : ITraitInfo, IRulesetLoaded, Requires<IHealthInfo>
{
[WeaponReference, FieldLoader.Require, Desc("Weapon to use for explosion.")]
[WeaponReference]
[FieldLoader.Require]
[Desc("Weapon to use for explosion.")]
public readonly string Weapon = null;
[Desc("At which damage state explosion will trigger.")]

View File

@@ -32,11 +32,13 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Image for the level up sprite.")]
public readonly string LevelUpImage = null;
[SequenceReference("Image")]
[Desc("Sequence for the level up sprite. Needs to be present on Image.")]
[SequenceReference("Image")] public readonly string LevelUpSequence = "levelup";
public readonly string LevelUpSequence = "levelup";
[PaletteReference]
[Desc("Palette for the level up sprite.")]
[PaletteReference] public readonly string LevelUpPalette = "effect";
public readonly string LevelUpPalette = "effect";
[Desc("Multiplier to apply to the Conditions keys. Defaults to the actor's value.")]
public readonly int ExperienceModifier = -1;
@@ -60,9 +62,11 @@ namespace OpenRA.Mods.Common.Traits
ConditionManager conditionManager;
// Stored as a percentage of our value
[Sync] int experience = 0;
[Sync]
int experience = 0;
[Sync] public int Level { get; private set; }
[Sync]
public int Level { get; private set; }
public readonly int MaxLevel;
public GainsExperience(ActorInitializer init, GainsExperienceInfo info)
@@ -137,7 +141,9 @@ namespace OpenRA.Mods.Common.Traits
class ExperienceInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value;
[FieldFromYamlKey]
readonly int value;
public ExperienceInit() { }
public ExperienceInit(int init) { value = init; }
public int Value(World world) { return value; }

View File

@@ -18,7 +18,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The player can give this unit the order to follow and protect friendly units with the Guardable trait.")]
public class GuardInfo : ITraitInfo, Requires<IMoveInfo>
{
[VoiceReference] public readonly string Voice = "Action";
[VoiceReference]
public readonly string Voice = "Action";
public object Create(ActorInitializer init) { return new Guard(this); }
}

View File

@@ -78,8 +78,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Condition to grant while empty.")]
public readonly string EmptyCondition = null;
[VoiceReference] public readonly string HarvestVoice = "Action";
[VoiceReference] public readonly string DeliverVoice = "Action";
[VoiceReference]
public readonly string HarvestVoice = "Action";
[VoiceReference]
public readonly string DeliverVoice = "Action";
public object Create(ActorInitializer init) { return new Harvester(init.Self, this); }
}
@@ -97,11 +100,20 @@ namespace OpenRA.Mods.Common.Traits
int conditionToken = ConditionManager.InvalidConditionToken;
HarvesterResourceMultiplier[] resourceMultipliers;
[Sync] public bool LastSearchFailed;
[Sync] public Actor OwnerLinkedProc = null;
[Sync] public Actor LastLinkedProc = null;
[Sync] public Actor LinkedProc = null;
[Sync] int currentUnloadTicks;
[Sync]
public bool LastSearchFailed;
[Sync]
public Actor OwnerLinkedProc = null;
[Sync]
public Actor LastLinkedProc = null;
[Sync]
public Actor LinkedProc = null;
[Sync]
int currentUnloadTicks;
[Sync]
public int ContentValue

View File

@@ -60,7 +60,8 @@ namespace OpenRA.Mods.Common.Traits
INotifyKilled[] notifyKilled;
INotifyKilled[] notifyKilledPlayer;
[Sync] int hp;
[Sync]
int hp;
public int DisplayHP { get; private set; }
@@ -232,7 +233,9 @@ namespace OpenRA.Mods.Common.Traits
public class HealthInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value = 100;
[FieldFromYamlKey]
readonly int value = 100;
readonly bool allowZero;
public HealthInit() { }
public HealthInit(int init)

View File

@@ -60,9 +60,14 @@ namespace OpenRA.Mods.Common.Traits
readonly int dragSpeed;
readonly WPos finalPosition;
[Sync] public CPos TopLeft { get; private set; }
[Sync] public WPos CenterPosition { get; private set; }
[Sync] public int Facing { get; set; }
[Sync]
public CPos TopLeft { get; private set; }
[Sync]
public WPos CenterPosition { get; private set; }
[Sync]
public int Facing { get; set; }
public int TurnSpeed { get { return 0; } }
@@ -159,7 +164,9 @@ namespace OpenRA.Mods.Common.Traits
public class HuskSpeedInit : IActorInit<int>
{
[FieldFromYamlKey] readonly int value = 0;
[FieldFromYamlKey]
readonly int value = 0;
public HuskSpeedInit() { }
public HuskSpeedInit(int init) { value = init; }
public int Value(World world) { return value; }

Some files were not shown because too many files have changed in this diff Show More