mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Use new IDynamicTypeFactory extension method.
This commit is contained in:
@@ -49,7 +49,7 @@ namespace Robust.Client.State
|
||||
{
|
||||
Logger.Debug($"Switching to state {type}");
|
||||
|
||||
var newState = (State)_typeFactory.CreateInstance(type);
|
||||
var newState = _typeFactory.CreateInstance<State>(type);
|
||||
|
||||
var old = CurrentState;
|
||||
CurrentState?.Shutdown();
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
throw new InvalidOperationException($"{componentType} is not a registered component.");
|
||||
}
|
||||
return (IComponent)_typeFactory.CreateInstance(types[componentType].Type);
|
||||
return _typeFactory.CreateInstance<IComponent>(types[componentType].Type);
|
||||
}
|
||||
|
||||
public T GetComponent<T>() where T : IComponent, new()
|
||||
@@ -191,12 +191,12 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
throw new InvalidOperationException($"{typeof(T)} is not a registered component.");
|
||||
}
|
||||
return (T)_typeFactory.CreateInstance(types[typeof(T)].Type);
|
||||
return _typeFactory.CreateInstance<T>(types[typeof(T)].Type);
|
||||
}
|
||||
|
||||
public IComponent GetComponent(string componentName)
|
||||
{
|
||||
return (IComponent)_typeFactory.CreateInstance(GetRegistration(componentName).Type);
|
||||
return _typeFactory.CreateInstance<IComponent>(GetRegistration(componentName).Type);
|
||||
}
|
||||
|
||||
public IComponentRegistration GetRegistration(string componentName)
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
Logger.DebugS("go.sys", "Initializing entity system {0}", type);
|
||||
//Force initialization of all systems
|
||||
var instance = (IEntitySystem)_typeFactory.CreateInstance(type);
|
||||
var instance = _typeFactory.CreateInstance<IEntitySystem>(type);
|
||||
AddSystem(instance);
|
||||
instance.RegisterMessageTypes();
|
||||
instance.SubscribeEvents();
|
||||
|
||||
@@ -291,7 +291,7 @@ namespace Robust.Shared.Prototypes
|
||||
}
|
||||
|
||||
var prototypeType = prototypeTypes[type];
|
||||
var prototype = (IPrototype)_dynamicTypeFactory.CreateInstance(prototypeType);
|
||||
var prototype = _dynamicTypeFactory.CreateInstance<IPrototype>(prototypeType);
|
||||
prototype.LoadFrom(node);
|
||||
prototypes[prototypeType].Add(prototype);
|
||||
var indexedPrototype = prototype as IIndexedPrototype;
|
||||
|
||||
Reference in New Issue
Block a user