/// <summary> /// Register a custom component /// </summary> /// <typeparam name="TComponent">Type implementing IComponent</typeparam> /// <param name="name"></param> public void RegisterComponent <TComponent>(string name) where TComponent : IComponent { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } CustomComponents.Add(name, typeof(TComponent)); }
/// <summary> /// Register a custom component /// </summary> /// <param name="name"></param> /// <param name="component"></param> public void RegisterComponent(string name, Type component) { if (!component.GetInterfaces().Contains(typeof(IComponent))) { throw new ArgumentException(nameof(component), $"Type must implement IComponent"); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } CustomComponents.Add(name, component); }
/// <summary> /// Loads the currently selected mod. /// </summary> protected virtual void LoadMod() { TypeManager.Load(); GameInfo.Load(); TextureManager.Load(); FontManager.Load(); GameScreenManager.Load(); GuiManager.Load(); ScriptManager.Load(); CustomComponents.Add(VariableManager.Id, VariableManager); // Load all the custom components - note that the instancing of the components occurs earlier, in GameInfo.Load CustomComponents.Load(); }