From 040dc2445c225b6c8d06998394b2950dd439767d Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 23 Jul 2019 21:34:13 +0200 Subject: [PATCH] Use new IDynamicTypeFactory extension method. --- Robust.Client/State/StateManager.cs | 2 +- Robust.Shared/GameObjects/ComponentFactory.cs | 6 +++--- Robust.Shared/GameObjects/EntitySystemManager.cs | 2 +- Robust.Shared/Prototypes/PrototypeManager.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Robust.Client/State/StateManager.cs b/Robust.Client/State/StateManager.cs index 34febd1d8..29c20faa5 100644 --- a/Robust.Client/State/StateManager.cs +++ b/Robust.Client/State/StateManager.cs @@ -49,7 +49,7 @@ namespace Robust.Client.State { Logger.Debug($"Switching to state {type}"); - var newState = (State)_typeFactory.CreateInstance(type); + var newState = _typeFactory.CreateInstance(type); var old = CurrentState; CurrentState?.Shutdown(); diff --git a/Robust.Shared/GameObjects/ComponentFactory.cs b/Robust.Shared/GameObjects/ComponentFactory.cs index d03fcb955..2ac4b4537 100644 --- a/Robust.Shared/GameObjects/ComponentFactory.cs +++ b/Robust.Shared/GameObjects/ComponentFactory.cs @@ -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(types[componentType].Type); } public T GetComponent() 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(types[typeof(T)].Type); } public IComponent GetComponent(string componentName) { - return (IComponent)_typeFactory.CreateInstance(GetRegistration(componentName).Type); + return _typeFactory.CreateInstance(GetRegistration(componentName).Type); } public IComponentRegistration GetRegistration(string componentName) diff --git a/Robust.Shared/GameObjects/EntitySystemManager.cs b/Robust.Shared/GameObjects/EntitySystemManager.cs index abacf5520..8bd01d70f 100644 --- a/Robust.Shared/GameObjects/EntitySystemManager.cs +++ b/Robust.Shared/GameObjects/EntitySystemManager.cs @@ -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(type); AddSystem(instance); instance.RegisterMessageTypes(); instance.SubscribeEvents(); diff --git a/Robust.Shared/Prototypes/PrototypeManager.cs b/Robust.Shared/Prototypes/PrototypeManager.cs index 691291c9a..bad57cc65 100644 --- a/Robust.Shared/Prototypes/PrototypeManager.cs +++ b/Robust.Shared/Prototypes/PrototypeManager.cs @@ -291,7 +291,7 @@ namespace Robust.Shared.Prototypes } var prototypeType = prototypeTypes[type]; - var prototype = (IPrototype)_dynamicTypeFactory.CreateInstance(prototypeType); + var prototype = _dynamicTypeFactory.CreateInstance(prototypeType); prototype.LoadFrom(node); prototypes[prototypeType].Add(prototype); var indexedPrototype = prototype as IIndexedPrototype;