예제 #1
0
        internal void LoadMod(string file, Assembly assembly, Mod mod, ModInfoAttribute modInfo)
        {
            try
            {
                if (modInfo == null || modInfo.name == null)
                {
                    var name = Path.GetFileNameWithoutExtension(file);
                    Debug.LogError("Entry point class of '" + name + "' assembly requires a [ModInfo(name=?)] attribute. Skipping mod.");
                    return;
                }

                if (modInfo.id == null)
                {
                    string id;
                    if (modInfo.author != null)
                    {
                        id = FormatID(modInfo.author) + "." + FormatID(modInfo.name);
                    }
                    else
                    {
                        id = FormatID(modInfo.name);
                    }
                    modInfo.id = id;

                    Debug.LogWarning(
                        "No ID specified for '" + modInfo.name + "' mod. Assumed '" + id + "'. " +
                        "It is recommended to specify an ID manually for compatibility reasons but this should NOT break the mod."
                        );
                }
                else
                {
                    var id          = modInfo.id;
                    var formattedId = FormatID(id);

                    if (formattedId != id)
                    {
                        Debug.LogError("Invalid mod id: " + id + " - use something like this: " + formattedId + "! Skipping mod.");
                        return;
                    }
                }

                if (mods.ContainsKey(modInfo.id))
                {
                    Debug.LogError("Another mod exists with the name '" + modInfo.id + "'! Skipping mod.");
                    return;
                }

                var semlInfo = new SemlInfo(file, assembly, mod, modInfo);

                mods.Add(modInfo.id, semlInfo);
                Debug.Log("Loaded '" + semlInfo.id + "' mod.");

                // Mod setup should be done at the end
                mod.Setup();
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }
예제 #2
0
 internal SemlInfo(string file, Assembly assembly, Mod mod, ModInfoAttribute info)
 {
     this.file     = file;
     this.assembly = assembly;
     this.mod      = mod;
     this.info     = info;
 }