diff --git a/OpenRA.FileFormats/FieldLoader.cs b/OpenRA.FileFormats/FieldLoader.cs index ab6259008b..beb76fca6f 100755 --- a/OpenRA.FileFormats/FieldLoader.cs +++ b/OpenRA.FileFormats/FieldLoader.cs @@ -219,26 +219,22 @@ namespace OpenRA.FileFormats foreach( var ff in type.GetFields() ) { var field = ff; - var load = field.GetCustomAttributes( false ); + var ignore = field.GetCustomAttributes( false ); var loadUsing = field.GetCustomAttributes( false ); var fromYamlKey = field.GetCustomAttributes( false ); if( loadUsing.Length != 0 ) ret[ field ] = ( _1, fieldType, yaml ) => loadUsing[ 0 ].LoaderFunc( field )( yaml ); else if( fromYamlKey.Length != 0 ) ret[ field ] = ( f, ft, yaml ) => GetValue( f, ft, yaml.Value ); - else if( load.Length != 0 ) + else if( ignore.Length == 0 ) ret[ field ] = null; } - if( ret.Count == 0 ) - foreach( var f in type.GetFields() ) - ret.Add( f, null ); - return ret; } [AttributeUsage( AttributeTargets.Field )] - public class LoadAttribute : Attribute { } + public class IgnoreAttribute : Attribute { } [AttributeUsage( AttributeTargets.Field )] public class LoadUsingAttribute : Attribute diff --git a/OpenRA.FileFormats/Map/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs index 26fec9b81d..59ad5bc27e 100644 --- a/OpenRA.FileFormats/Map/TileSet.cs +++ b/OpenRA.FileFormats/Map/TileSet.cs @@ -31,10 +31,10 @@ namespace OpenRA.FileFormats public class TileTemplate { - [FieldLoader.Load] public ushort Id; - [FieldLoader.Load] public string Image; - [FieldLoader.Load] public int2 Size; - [FieldLoader.Load] public bool PickAny; + public ushort Id; + public string Image; + public int2 Size; + public bool PickAny; [FieldLoader.LoadUsing( "LoadTiles" )] public Dictionary Tiles = new Dictionary(); diff --git a/OpenRA.Game/GameRules/VoiceInfo.cs b/OpenRA.Game/GameRules/VoiceInfo.cs index b14b9a8b1a..a136a77e4c 100644 --- a/OpenRA.Game/GameRules/VoiceInfo.cs +++ b/OpenRA.Game/GameRules/VoiceInfo.cs @@ -8,19 +8,19 @@ */ #endregion +using System; using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; -using System; namespace OpenRA.GameRules { public class VoiceInfo { - public readonly Dictionary Variants; - public readonly Dictionary Voices; + [FieldLoader.Ignore] public readonly Dictionary Variants; + [FieldLoader.Ignore] public readonly Dictionary Voices; public readonly string DefaultVariant = ".aud" ; - [FieldLoader.Load] public readonly string[] DisableVariants = { }; + public readonly string[] DisableVariants = { }; static Dictionary Load( MiniYaml y, string name ) { diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index cf386629bc..afeed0d561 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -18,21 +18,21 @@ namespace OpenRA.GameRules { public class WarheadInfo { - [FieldLoader.Load] public readonly int Spread = 1; // distance (in pixels) from the explosion center at which damage is 1/2. + public readonly int Spread = 1; // distance (in pixels) from the explosion center at which damage is 1/2. [FieldLoader.LoadUsing( "LoadVersus" )] - public readonly Dictionary Versus; // damage vs each armortype - [FieldLoader.Load] public readonly bool Ore = false; // can this damage ore? - [FieldLoader.Load] public readonly string Explosion = null; // explosion effect to use - [FieldLoader.Load] public readonly string WaterExplosion = null; // explosion effect on hitting water (usually a splash) - [FieldLoader.Load] public readonly string SmudgeType = null; // type of smudge to apply - [FieldLoader.Load] public readonly int[] Size = { 0, 0 }; // size of the explosion. provide 2 values for a ring effect (outer/inner) - [FieldLoader.Load] public readonly int InfDeath = 0; // infantry death animation to use - [FieldLoader.Load] public readonly string ImpactSound = null; // sound to play on impact - [FieldLoader.Load] public readonly string WaterImpactSound = null; // sound to play on impact with water - [FieldLoader.Load] public readonly int Damage = 0; // how much (raw) damage to deal - [FieldLoader.Load] public readonly int Delay = 0; // delay in ticks before dealing the damage. 0=instant (old model) - [FieldLoader.Load] public readonly DamageModel DamageModel = DamageModel.Normal; // which damage model to use - [FieldLoader.Load] public readonly bool PreventProne = false; // whether we should prevent prone response in infantry. + public readonly Dictionary Versus; // damage vs each armortype + public readonly bool Ore = false; // can this damage ore? + public readonly string Explosion = null; // explosion effect to use + public readonly string WaterExplosion = null; // explosion effect on hitting water (usually a splash) + public readonly string SmudgeType = null; // type of smudge to apply + public readonly int[] Size = { 0, 0 }; // size of the explosion. provide 2 values for a ring effect (outer/inner) + public readonly int InfDeath = 0; // infantry death animation to use + public readonly string ImpactSound = null; // sound to play on impact + public readonly string WaterImpactSound = null; // sound to play on impact with water + public readonly int Damage = 0; // how much (raw) damage to deal + public readonly int Delay = 0; // delay in ticks before dealing the damage. 0=instant (old model) + public readonly DamageModel DamageModel = DamageModel.Normal; // which damage model to use + public readonly bool PreventProne = false; // whether we should prevent prone response in infantry. public float EffectivenessAgainst(Actor self) { @@ -85,15 +85,15 @@ namespace OpenRA.GameRules public class WeaponInfo { - [FieldLoader.Load] public readonly float Range = 0; - [FieldLoader.Load] public readonly string Report = null; - [FieldLoader.Load] public readonly int ROF = 1; - [FieldLoader.Load] public readonly int Burst = 1; - [FieldLoader.Load] public readonly bool Charges = false; - [FieldLoader.Load] public readonly bool Underwater = false; - [FieldLoader.Load] public readonly string[] ValidTargets = { "Ground" }; - [FieldLoader.Load] public readonly int BurstDelay = 5; - [FieldLoader.Load] public readonly float MinRange = 0; + public readonly float Range = 0; + public readonly string Report = null; + public readonly int ROF = 1; + public readonly int Burst = 1; + public readonly bool Charges = false; + public readonly bool Underwater = false; + public readonly string[] ValidTargets = { "Ground" }; + public readonly int BurstDelay = 5; + public readonly float MinRange = 0; [FieldLoader.LoadUsing( "LoadProjectile" )] public IProjectileInfo Projectile; [FieldLoader.LoadUsing( "LoadWarheads" )] public List Warheads; diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 4e876d438e..7b0cbfde76 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -22,53 +22,52 @@ namespace OpenRA { public class Map { - protected IFolder Container; + [FieldLoader.Ignore] protected IFolder Container; public string Path {get; protected set;} // Yaml map data public string Uid { get; protected set; } - [FieldLoader.Load] public int MapFormat; - [FieldLoader.Load] public bool Selectable; - [FieldLoader.Load] public bool UseAsShellmap; - [FieldLoader.Load] public string RequiresMod; + public int MapFormat; + public bool Selectable; + public bool UseAsShellmap; + public string RequiresMod; - [FieldLoader.Load] public string Title; - [FieldLoader.Load] public string Type = "Conquest"; - [FieldLoader.Load] public string Description; - [FieldLoader.Load] public string Author; - [FieldLoader.Load] public string Tileset; + public string Title; + public string Type = "Conquest"; + public string Description; + public string Author; + public string Tileset; - public Lazy> Actors; + [FieldLoader.Ignore] public Lazy> Actors; public int PlayerCount { get { return Players.Count(p => p.Value.Playable); } } public IEnumerable SpawnPoints { get { return Actors.Value.Values.Where(a => a.Type == "mpspawn").Select(a => a.InitDict.Get().value); } } - [FieldLoader.Load] public Rectangle Bounds; + public Rectangle Bounds; - // Yaml map data - public Dictionary Players = new Dictionary(); - public Lazy> Smudges; + [FieldLoader.Ignore] public Dictionary Players = new Dictionary(); + [FieldLoader.Ignore] public Lazy> Smudges; // Rules overrides - public List Rules = new List(); + [FieldLoader.Ignore] public List Rules = new List(); // Sequences overrides - public List Sequences = new List(); + [FieldLoader.Ignore] public List Sequences = new List(); // Weapon overrides - public List Weapons = new List(); + [FieldLoader.Ignore] public List Weapons = new List(); // Voices overrides - public List Voices = new List(); + [FieldLoader.Ignore] public List Voices = new List(); // Binary map data - public byte TileFormat = 1; - [FieldLoader.Load] public int2 MapSize; + [FieldLoader.Ignore] public byte TileFormat = 1; + public int2 MapSize; - public Lazy[,]> MapTiles; - public Lazy[,]> MapResources; - public string [,] CustomTerrain; + [FieldLoader.Ignore] public Lazy[,]> MapTiles; + [FieldLoader.Ignore] public Lazy[,]> MapResources; + [FieldLoader.Ignore] public string [,] CustomTerrain; public Map() { diff --git a/OpenRA.Game/Network/Handshake.cs b/OpenRA.Game/Network/Handshake.cs index c5f7c32b67..3423be34af 100644 --- a/OpenRA.Game/Network/Handshake.cs +++ b/OpenRA.Game/Network/Handshake.cs @@ -17,8 +17,8 @@ namespace OpenRA.Network { public class HandshakeRequest { - [FieldLoader.Load] public string[] Mods; - [FieldLoader.Load] public string Map; + public string[] Mods; + public string Map; public string Serialize() { @@ -37,9 +37,9 @@ namespace OpenRA.Network public class HandshakeResponse { - [FieldLoader.Load] public string[] Mods; - [FieldLoader.Load] public string Password; - public Session.Client Client; + public string[] Mods; + public string Password; + [FieldLoader.Ignore] public Session.Client Client; public string Serialize() { @@ -70,4 +70,4 @@ namespace OpenRA.Network return handshake; } } -} \ No newline at end of file +} diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index c92c852ba0..fa072f24c0 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -35,11 +35,9 @@ namespace OpenRA.Mods.RA { class HackyAIInfo : IBotInfo, ITraitInfo { - [FieldLoader.Load] public readonly string Name = "Unnamed Bot"; - - [FieldLoader.Load] public readonly int SquadSize = 8; + public readonly int AssignRolesInterval = 20; string IBotInfo.Name { get { return this.Name; } } @@ -64,9 +62,6 @@ namespace OpenRA.Mods.RA ret.Add(t.Key, (float)FieldLoader.GetValue("units", typeof(float), t.Value.Value)); return ret; } - - [FieldLoader.Load] - public readonly int AssignRolesInterval = 20; public object Create(ActorInitializer init) { return new HackyAI(this); } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 47cab7ed25..869dae07df 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -23,21 +23,13 @@ namespace OpenRA.Mods.RA.Move { [FieldLoader.LoadUsing("LoadSpeeds")] public readonly Dictionary TerrainSpeeds; - [FieldLoader.Load] public readonly string[] Crushes; - [FieldLoader.Load] public readonly int WaitAverage = 60; - [FieldLoader.Load] public readonly int WaitSpread = 20; - [FieldLoader.Load] public readonly int InitialFacing = 128; - [FieldLoader.Load] public readonly int ROT = 255; - [FieldLoader.Load] public readonly int Speed = 1; - [FieldLoader.Load] public readonly bool OnRails = false; - [FieldLoader.Load] public readonly bool SharesCell = false; public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }