/// <summary> /// Registers a daemon interface. /// </summary> /// <returns>The daemon's full id if added to the game, <c>null</c> otherwise.</returns> /// <param name="id">The daemon interface id to insert.</param> /// <param name="inter">The interface to add.</param> public static string RegisterDaemon(string id, Interface inter) { id = InternalUtility.Validate(id, "Daemon", inter.GetType().FullName, true); if (ModDaemons.ContainsKey(id)) { return(null); } ModDaemons.Add(id, inter); return(id); }
public static string RegisterPort(string id, Type port) { id = InternalUtility.Validate(id, "Port Type", $"[{port}]", true); if (PortTypes.ContainsKey(id)) { return(null); } port.PortId = id; PortTypes.Add(id, port); return(id); }
/// <summary> /// Adds an executable interface by id. /// </summary> /// <returns>The full mod id if added to the game, <c>null</c> otherwise.</returns> /// <param name="id">The Executable Identifier to try and add.</param> /// <param name="inter">The interface object.</param> public static string RegisterExecutable(string id, Interface inter) { id = InternalUtility.Validate(id, "Executable Interface", inter.GetType().FullName, true); if (ModExecutables.ContainsKey(id)) { return(null); } var type = inter.GetType(); var fileData = GenerateFileDataString(type.Assembly.GetName().Name, type.FullName, id); if (fileData.Length < 1 || ModExecutables.Any(pair => pair.Value.Item2 == fileData)) { throw new ArgumentException("created data for '" + id + "' is not unique"); } ModExecutables.Add(id, new Tuple <Interface, string>(inter, fileData)); return(id); }
public static string RegisterExtension(string id, Info extensionInfo) { id = InternalUtility.Validate(id, "Extension", extensionInfo.GetType().FullName, true, true); if (ModExtensions.ContainsKey(id)) { return(null); } extensionInfo.Id = id; Texture2D t = null; if (File.Exists(extensionInfo.LogoPath)) { using (var fs = File.OpenRead(extensionInfo.LogoPath)) t = Texture2D.FromStream(Game1.getSingleton().GraphicsDevice, fs); } ModExtensions.Add(id, new Tuple <Info, Texture2D, GUI.Button>(extensionInfo, t, new GUI.Button(-1, -1, 450, 50, Utility.ActiveModId + ": " + extensionInfo.Name, Color.White))); return(id); }