diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs index c937af2af5..525c0900f4 100644 --- a/OpenRA.Game/GameRules/ActorInfo.cs +++ b/OpenRA.Game/GameRules/ActorInfo.cs @@ -109,7 +109,7 @@ namespace OpenRA return ret; } - static List PrerequisitesOf( ITraitInfo info ) + static List PrerequisitesOf(ITraitInfo info) { return info .GetType() @@ -118,5 +118,20 @@ namespace OpenRA .Select( t => t.GetGenericArguments()[ 0 ] ) .ToList(); } + + public IEnumerable> GetInitKeys() + { + var inits = Traits.WithInterface().SelectMany( + t => t.GetType().GetInterfaces() + .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(UsesInit<>)) + .Select(i => i.GetGenericArguments()[0])).ToList(); + + inits.Add( typeof(OwnerInit) ); /* not exposed by a trait; this is used by the Actor itself */ + + return inits.Select( + i => Pair.New( + i.GetType().Name.Replace( "Init", "" ), + i.GetType().GetInterfaces()[0].GetGenericArguments()[0] ) ); + } } } diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 5174b2aa2e..557cb07fc7 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -102,14 +102,6 @@ namespace OpenRA return map; } - class Format2ActorReference - { - public string Id = null; - public string Type = null; - public int2 Location = int2.Zero; - public string Owner = null; - } - void AssertExists(string filename) { using(var s = Container.GetContent(filename)) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index b42d05fc6f..54863fdc1d 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -46,10 +46,7 @@ namespace OpenRA.Server public Map Map; volatile bool shutdown = false; - public void Shutdown() - { - shutdown = true; - } + public void Shutdown() { shutdown = true; } public Server(IPEndPoint endpoint, string[] mods, ServerSettings settings, ModData modData) { diff --git a/OpenRA.Game/Server/TraitInterfaces.cs b/OpenRA.Game/Server/TraitInterfaces.cs index 87be6475c9..03477e0955 100644 --- a/OpenRA.Game/Server/TraitInterfaces.cs +++ b/OpenRA.Game/Server/TraitInterfaces.cs @@ -7,6 +7,7 @@ * see COPYING. */ #endregion + using System; using OpenRA.Network; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 9203956146..4f8184a8c2 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -184,6 +184,7 @@ namespace OpenRA.Traits public class TraitInfo : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } } public interface Requires where T : class { } + public interface UsesInit where T : IActorInit { } public interface INotifySelection { void SelectionChanged(); } public interface IWorldLoaded { void WorldLoaded(World w); }