add mechanism for traits to export the *Inits they can use
This commit is contained in:
@@ -118,5 +118,20 @@ namespace OpenRA
|
||||
.Select( t => t.GetGenericArguments()[ 0 ] )
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<string, Type>> GetInitKeys()
|
||||
{
|
||||
var inits = Traits.WithInterface<ITraitInfo>().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] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Network;
|
||||
|
||||
|
||||
@@ -184,6 +184,7 @@ namespace OpenRA.Traits
|
||||
public class TraitInfo<T> : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } }
|
||||
|
||||
public interface Requires<T> where T : class { }
|
||||
public interface UsesInit<T> where T : IActorInit { }
|
||||
|
||||
public interface INotifySelection { void SelectionChanged(); }
|
||||
public interface IWorldLoaded { void WorldLoaded(World w); }
|
||||
|
||||
Reference in New Issue
Block a user