diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index 1f4013150b..b72cf437e8 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; using OpenRA.FileFormats; -using OpenRA.Support; using OpenRA.Traits; using Tao.OpenAl; diff --git a/OpenRA.Game/Traits/Buildable.cs b/OpenRA.Game/Traits/Buildable.cs index d84862d0ac..fe0f92d223 100755 --- a/OpenRA.Game/Traits/Buildable.cs +++ b/OpenRA.Game/Traits/Buildable.cs @@ -30,9 +30,9 @@ namespace OpenRA.Traits public virtual object Create(ActorInitializer init) { return new Valued(); } } - class BuildableInfo : ValuedInfo + public class BuildableInfo : ValuedInfo { - public readonly string[] Prerequisites = { }; + [ActorReference]public readonly string[] Prerequisites = { }; [ActorReference] public readonly string[] BuiltAt = { }; public readonly string Icon = null; diff --git a/OpenRA.Game/Traits/LintAttributes.cs b/OpenRA.Game/Traits/LintAttributes.cs index b0aeac5a92..3ddca8fc3a 100644 --- a/OpenRA.Game/Traits/LintAttributes.cs +++ b/OpenRA.Game/Traits/LintAttributes.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace OpenRA.Traits { @@ -12,4 +9,7 @@ namespace OpenRA.Traits [AttributeUsage(AttributeTargets.Field)] public class WeaponReferenceAttribute : Attribute { } + + [AttributeUsage(AttributeTargets.Field)] + public class VoiceReferenceAttribute : Attribute { } } diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index 131f32fe85..ae95badc8a 100755 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -24,6 +24,7 @@ namespace OpenRA.Traits { public readonly int Priority = 10; public readonly int[] Bounds = null; + [VoiceReference] public readonly string Voice = null; public readonly float Radius = 10; } diff --git a/OpenRA.Game/Traits/SupportPower.cs b/OpenRA.Game/Traits/SupportPower.cs index de2808a1d6..b20e7c0217 100644 --- a/OpenRA.Game/Traits/SupportPower.cs +++ b/OpenRA.Game/Traits/SupportPower.cs @@ -30,6 +30,7 @@ namespace OpenRA.Traits public readonly string Image = null; public readonly string Description = ""; public readonly string LongDesc = ""; + [ActorReference] public readonly string[] Prerequisites = { }; public readonly int TechLevel = -1; public readonly bool GivenAuto = true; diff --git a/OpenRA.Game/Traits/TransformsOnDeploy.cs b/OpenRA.Game/Traits/TransformsOnDeploy.cs index 85a20016b9..2de9ba5d71 100644 --- a/OpenRA.Game/Traits/TransformsOnDeploy.cs +++ b/OpenRA.Game/Traits/TransformsOnDeploy.cs @@ -24,6 +24,7 @@ namespace OpenRA.Traits { class TransformsOnDeployInfo : TraitInfo { + [ActorReference] public readonly string TransformsInto = null; public readonly int[] Offset = null; public readonly int[] DeployDirections = new int[] {96}; diff --git a/OpenRA.Game/Traits/World/HazardLayer.cs b/OpenRA.Game/Traits/World/HazardLayer.cs index e00f526aa0..062deaf063 100644 --- a/OpenRA.Game/Traits/World/HazardLayer.cs +++ b/OpenRA.Game/Traits/World/HazardLayer.cs @@ -16,11 +16,9 @@ * You should have received a copy of the GNU General Public License * along with OpenRA. If not, see . */ -#endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; +#endregion + +using System.Collections.Generic; using System.Linq; using OpenRA.FileFormats; @@ -34,7 +32,6 @@ namespace OpenRA.Traits public class HazardLayer : ITerrainCost { List>[,] hazards; - Map map; public HazardLayer( World world ) { diff --git a/RALint/Program.cs b/RALint/RALint.cs similarity index 76% rename from RALint/Program.cs rename to RALint/RALint.cs index 02953b8f53..5b4edc0518 100644 --- a/RALint/Program.cs +++ b/RALint/RALint.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Linq; using OpenRA; using OpenRA.FileFormats; using OpenRA.GameRules; @@ -8,7 +9,7 @@ using OpenRA.Traits; namespace RALint { - static class Program + static class RALint { /* todo: move this into the engine? dpstool, seqed, editor, etc all need it (or something similar) */ static void InitializeEngineWithMods(string[] mods) @@ -32,10 +33,18 @@ namespace RALint ++errors; } + static Dictionary ValidPrereqs; + static int Main(string[] args) { InitializeEngineWithMods(args); + // all the @something names which actually EXIST. + var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null) + .Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct(); + + ValidPrereqs = Rules.Info.Keys.Concat(psuedoPrereqs).ToDictionary(a => a, a => 0); + foreach (var actorInfo in Rules.Info) foreach (var traitInfo in actorInfo.Value.Traits.WithInterface()) CheckTrait(actorInfo.Value, traitInfo); @@ -55,9 +64,11 @@ namespace RALint foreach (var field in actualType.GetFields()) { if (field.HasAttribute()) - CheckReference(actorInfo, traitInfo, field, Rules.Info, "actor"); + CheckReference(actorInfo, traitInfo, field, ValidPrereqs, "actor"); if (field.HasAttribute()) CheckReference(actorInfo, traitInfo, field, Rules.Weapons, "weapon"); + if (field.HasAttribute()) + CheckReference(actorInfo, traitInfo, field, Rules.Voices, "voice"); } } diff --git a/RALint/RALint.csproj b/RALint/RALint.csproj index 4cc79d0a91..28e66e2928 100644 --- a/RALint/RALint.csproj +++ b/RALint/RALint.csproj @@ -47,7 +47,7 @@ - +