add mechanism for traits to export the *Inits they can use
This commit is contained in:
@@ -109,7 +109,7 @@ namespace OpenRA
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<Type> PrerequisitesOf( ITraitInfo info )
|
static List<Type> PrerequisitesOf(ITraitInfo info)
|
||||||
{
|
{
|
||||||
return info
|
return info
|
||||||
.GetType()
|
.GetType()
|
||||||
@@ -118,5 +118,20 @@ namespace OpenRA
|
|||||||
.Select( t => t.GetGenericArguments()[ 0 ] )
|
.Select( t => t.GetGenericArguments()[ 0 ] )
|
||||||
.ToList();
|
.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;
|
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)
|
void AssertExists(string filename)
|
||||||
{
|
{
|
||||||
using(var s = Container.GetContent(filename))
|
using(var s = Container.GetContent(filename))
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ namespace OpenRA.Server
|
|||||||
public Map Map;
|
public Map Map;
|
||||||
|
|
||||||
volatile bool shutdown = false;
|
volatile bool shutdown = false;
|
||||||
public void Shutdown()
|
public void Shutdown() { shutdown = true; }
|
||||||
{
|
|
||||||
shutdown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Server(IPEndPoint endpoint, string[] mods, ServerSettings settings, ModData modData)
|
public Server(IPEndPoint endpoint, string[] mods, ServerSettings settings, ModData modData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
* see COPYING.
|
* see COPYING.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using OpenRA.Network;
|
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 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 Requires<T> where T : class { }
|
||||||
|
public interface UsesInit<T> where T : IActorInit { }
|
||||||
|
|
||||||
public interface INotifySelection { void SelectionChanged(); }
|
public interface INotifySelection { void SelectionChanged(); }
|
||||||
public interface IWorldLoaded { void WorldLoaded(World w); }
|
public interface IWorldLoaded { void WorldLoaded(World w); }
|
||||||
|
|||||||
Reference in New Issue
Block a user