Beispiel #1
0
        void Awake()
        {
            Log("SRRandomizer v" + UMFMod.GetModVersion().ToString(), true);
            UMFGUI.RegisterPauseHandler(Pause);
            SRRandomizerConfig.Load();

            randomSeed = new System.Random().Next(); //get an initial seed
            seedInput  = randomSeed.ToString();

            //Register Commands
            UMFGUI.RegisterCommand("srr_listslimes", "srr_listslimes", new string[] { "listslimes" }, 0, "Test command, prints all slime types.", CommandListSlimes);
            UMFGUI.RegisterCommand("srr_printslimemap", "srr_printslimemap", new string[] { "printslimemap" }, 0, "Prints the current random slime map.", CommandPrintSlimeMap);
            UMFGUI.RegisterCommand("srr_printproducemap", "srr_printproducemap", new string[] { "printproducemap" }, 0, "Prints the current random produce map.", CommandPrintProduceMap);
            UMFGUI.RegisterCommand("srr_loadprefabs", "srr_loadprefabs", new string[] { "loadprefabs" }, 0, "Temp command, load prefab table", CommandLoadPrefabs);
        }
        public static void Start()
        {
            Log("Slime Rancher Cube Slime Mod v" + UMFMod.GetModVersion().ToString(), true);
            UMFGUI.RegisterPauseHandler(Pause);

            //Load the Mesh
            replaceMesh = UMFAsset.LoadMesh(meshFile);
            if (replaceMesh == null)
            {
                Log("Error: Failed to load the mesh.");
            }
            else
            {
                Log("Successfully loaded the mesh.");
            }
        }
Beispiel #3
0
 [UMFHarmony(4)]         //Set this to the number of harmony patches in your mod.
 public static void Start()
 {
     Log("DysonsGalaxy v" + UMFMod.GetModVersion(), true);
 }
 public static void Start()
 {
     //This is the first log entry for your mod, you use the additional true parameter to tell the logger to clean the log file here.
     Log("Plort Market v" + UMFMod.GetModVersion().ToString(), true);
 }
Beispiel #5
0
 public static void Start()
 {
     Log("Creativerse Mod v" + UMFMod.GetModVersion(), true);
 }
 void Awake()
 {
     Log("CEOverlordCheatMenu v" + UMFMod.GetModVersion().ToString(), true);
 }
 public static void Start()
 {
     Log("Slime Rancher Weather Mod v" + UMFMod.GetModVersion().ToString(), true);
     UMFGUI.RegisterPauseHandler(Pause);
 }
Beispiel #8
0
 public Version GetModVersion(string modName)
 {
     return(UMFMod.GetModVersion(modName));
 }
Beispiel #9
0
 public Assembly GetModAssembly(string modName)
 {
     return(UMFMod.GetMod(modName));
 }
 void Awake()
 {
     Log("CENoIntroVideoMod v" + UMFMod.GetModVersion().ToString(), true);
 }
Beispiel #11
0
 public string GetModDescription(string modName, bool caseInsensitive = false)
 {
     return(UMFMod.GetModDescription(modName, caseInsensitive));
 }
Beispiel #12
0
 public void UpdateInfo(Toggle toggle, int modIndex)
 {
     try
     {
         if (GadgetModConfigs.IsConfigMenuOpen(this.modIndex))
         {
             GadgetModConfigs.CloseConfigMenu(this.modIndex);
         }
         if (!File.Exists(UMFData.DisabledModsFile))
         {
             File.Create(UMFData.DisabledModsFile).Dispose();
         }
         this.toggle   = toggle;
         this.modIndex = modIndex;
         string[] disabledMods = File.ReadAllLines(UMFData.DisabledModsFile).Where(x => !string.IsNullOrEmpty(x)).ToArray();
         if (modIndex < GadgetMods.CountMods())
         {
             GadgetModInfo mod = GadgetMods.GetModInfo(modIndex);
             unpackButton.gameObject.SetActive(Directory.GetFiles(UMFData.ModsPath, mod.UMFName + "*.zip").Length > 0);
             enableUMFButton.interactable = !GadgetCore.dependencies.Any(x => !disabledMods.Contains(x.Key) && x.Value.Any(d => { string[] split = d.Split(' '); return(split[split.Length - 2].Equals(mod.UMFName)); }));
             if (mod.Attribute.Dependencies.All(x => GadgetMods.ListAllModInfos().Where(y => y.Mod.Enabled).Select(y => y.Attribute.Name).Contains(x) || GadgetMods.ListAllModInfos().Where(y => y.Mod.Enabled).Select(y => y.Mod.GetPreviousModNames()).Any(y => y.Contains(x))))
             {
                 enableButton.interactable = true;
                 string[][]      splitDependencies = mod.Attribute.Dependencies.Select(x => x.Split(' ')).Where(x => x.Length == 2).ToArray();
                 GadgetModInfo[] dependencies      = splitDependencies.Select(x => GadgetMods.ListAllModInfos().Where(y => y.Mod.Enabled).FirstOrDefault(y => y.Attribute.Name.Equals(x[0])) ?? GadgetMods.ListAllModInfos().Where(y => y.Mod.Enabled).First(y => y.Mod.GetPreviousModNames().Contains(x[0]))).ToArray();
                 for (int i = 0; i < dependencies.Length; i++)
                 {
                     int[] currentVersionNums = dependencies[i].Mod.GetModVersionString().Split('.').Select(x => int.Parse(x)).ToArray();
                     int[] targetVersionNums  = splitDependencies[i][1].TrimStart('v').Split('.').Select(x => int.Parse(x)).ToArray();
                     VersionSpecificity versionSpecificity = (VersionSpecificity)targetVersionNums.Length;
                     if (!((versionSpecificity == VersionSpecificity.MAJOR && currentVersionNums[0] == targetVersionNums[0] && (currentVersionNums[1] > targetVersionNums[1] || (currentVersionNums[1] == targetVersionNums[1] && (currentVersionNums[2] > targetVersionNums[2] || (currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] >= targetVersionNums[3]))))) ||
                           (versionSpecificity == VersionSpecificity.MINOR && currentVersionNums[0] == targetVersionNums[0] && currentVersionNums[1] == targetVersionNums[1] && (currentVersionNums[2] > targetVersionNums[2] || (currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] >= targetVersionNums[3]))) ||
                           (versionSpecificity == VersionSpecificity.NONBREAKING && currentVersionNums[0] == targetVersionNums[0] && currentVersionNums[1] == targetVersionNums[1] && currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] >= targetVersionNums[3]) ||
                           (versionSpecificity == VersionSpecificity.BUGFIX && currentVersionNums[0] == targetVersionNums[0] && currentVersionNums[1] == targetVersionNums[1] && currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] == targetVersionNums[3])))
                     {
                         enableButton.interactable = false;
                         break;
                     }
                 }
             }
             else
             {
                 enableButton.interactable = false;
             }
             configButton.interactable = GadgetModConfigs.GetConfigMenuObject(modIndex) != null;
             enableButton.GetComponentInChildren <Text>().text    = mod.Mod.Enabled ? "Disable Gadget" : "Enable Gadget";
             enableUMFButton.GetComponentInChildren <Text>().text = File.ReadAllLines(UMFData.DisabledModsFile).Any(x => x.Equals(mod.UMFName)) ? "Enable Mod" : "Disable Mod";
             string desc       = mod.Mod.GetModDescription();
             bool   isDescNull = desc == null;
             bool   isModInfo  = false;
             if (string.IsNullOrEmpty(desc))
             {
                 try
                 {
                     desc = File.ReadAllText(UMFData.ModInfosPath + "/" + mod.UMFName + "_v" + UMFMod.GetModVersion(mod.UMFName) + "_ModInfo.txt");
                 }
                 catch (Exception) { }
                 finally
                 {
                     if (string.IsNullOrEmpty(desc) || desc == "A UMF Mod(umodframework.com) for Roguelands")
                     {
                         desc = "This mod does not have a description, or a ModInfo file." + Environment.NewLine + (isDescNull ? "You should suggest to the mod author that they add a description." : "");
                     }
                     else
                     {
                         isModInfo = true;
                     }
                 }
             }
             descText.text =
                 mod.Attribute.Name + " v" + UMFMod.GetModVersion(mod.UMFName).ToString() + (mod.Mod.Enabled ? " (Enabled)" : " (Disabled)") + Environment.NewLine +
                 "UMF Mod: " + mod.UMFName + Environment.NewLine +
                 (GadgetCore.dependencies.ContainsKey(mod.UMFName) ? ("Dependencies: " + GadgetCore.dependencies[mod.UMFName].Aggregate((x, y) => x + ", " + y) + Environment.NewLine) : "") +
                 "Required on clients: " + (mod.Attribute.RequiredOnClients ? "Yes" : "No") + Environment.NewLine +
                 (isModInfo ? "UMF Mod Info: " : "Description: ") + UMFMod.GetModDescription(mod.UMFName) + Environment.NewLine + Environment.NewLine + desc;
         }
         else if (modIndex < GadgetMods.CountMods() + GadgetCore.nonGadgetMods.Count + GadgetCore.disabledMods.Count + GadgetCore.incompatibleMods.Count)
         {
             bool enabled = !File.ReadAllLines(UMFData.DisabledModsFile).Any(x => x.Equals(modIndex - GadgetMods.CountMods() < GadgetCore.nonGadgetMods.Count ? GadgetCore.nonGadgetMods[modIndex - GadgetMods.CountMods()] : modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count < GadgetCore.disabledMods.Count ? GadgetCore.disabledMods[modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count] : GadgetCore.incompatibleMods[modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count - GadgetCore.disabledMods.Count]));
             enableButton.GetComponentInChildren <Text>().text    = modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count >= 0 && modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count < GadgetCore.disabledMods.Count ? "Disabled" : "Not Gadget";
             enableUMFButton.GetComponentInChildren <Text>().text = enabled ? "Disable Mod" : "Enable Mod";
             string mod = modIndex - GadgetMods.CountMods() < GadgetCore.nonGadgetMods.Count ? GadgetCore.nonGadgetMods[modIndex - GadgetMods.CountMods()] : modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count < GadgetCore.disabledMods.Count ? GadgetCore.disabledMods[modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count] : GadgetCore.incompatibleMods[modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count - GadgetCore.disabledMods.Count];
             unpackButton.gameObject.SetActive(Directory.GetFiles(UMFData.ModsPath, mod + "*.zip").Length > 0);
             if (modIndex - GadgetMods.CountMods() < GadgetCore.nonGadgetMods.Count && GadgetCore.nonGadgetMods[modIndex - GadgetMods.CountMods()].Equals("GadgetCore"))
             {
                 enableUMFButton.interactable = false;
             }
             else
             {
                 enableUMFButton.interactable = !GadgetCore.dependencies.Any(x => !disabledMods.Contains(x.Key) && x.Value.Any(d => { string[] split = d.Split(' '); return(split[split.Length - 2].Equals(mod)); }));
             }
             enableButton.interactable = false;
             configButton.interactable = GadgetModConfigs.GetConfigMenuObject(modIndex) != null;
             string desc = null;
             try
             {
                 desc = File.ReadAllText(UMFData.ModInfosPath + "/" + mod + "_v" + UMFMod.GetModVersion(mod) + "_ModInfo.txt");
             }
             catch (Exception) { }
             finally
             {
                 if (string.IsNullOrEmpty(desc) || desc == "A UMF Mod(umodframework.com) for Roguelands")
                 {
                     desc = "This mod does not have a ModInfo file.";
                 }
                 descText.text =
                     mod + " v" + UMFMod.GetModVersion(mod).ToString() + (enabled ? " (Enabled)" : " (Disabled)") + Environment.NewLine +
                     (GadgetCore.dependencies.ContainsKey(mod) ? ("Dependencies: " + GadgetCore.dependencies[mod].Aggregate((x, y) => x + ", " + y) + Environment.NewLine) : "") +
                     "UMF Mod Info: " + UMFMod.GetModDescription(mod) + Environment.NewLine + Environment.NewLine + desc;
             }
         }
         else
         {
             string mod = GadgetCore.packedMods[modIndex - GadgetMods.CountMods() - GadgetCore.nonGadgetMods.Count - GadgetCore.disabledMods.Count - GadgetCore.incompatibleMods.Count];
             enableButton.interactable    = false;
             enableUMFButton.interactable = false;
             configButton.interactable    = false;
             unpackButton.interactable    = !unpackedMods.Contains(mod);
             unpackButton.gameObject.SetActive(true);
             descText.text = Path.GetFileName(mod) + Environment.NewLine + Environment.NewLine + "This mod is still packed in its .zip, and needs to be unpacked to run!";
         }
     }
     catch (Exception e)
     {
         descText.text = "An error occured while populating the info panel for this mod! Check GadgetCore.log for details.";
         GadgetCore.Log("An error occured while populating the info panel for the mod with the index " + modIndex + ": " + e.ToString());
     }
 }
 void Awake()
 {
     Log("PrepperMod v" + UMFMod.GetModVersion().ToString(), true);
 }
 void Awake()
 {
     Log("SRAirNetUpgrade v" + UMFMod.GetModVersion().ToString(), true);
     UMFGUI.RegisterPauseHandler(Pause);
 }
Beispiel #15
0
 public static void Start()
 {
     Loader.Log("My First Mod v" + UMFMod.GetModVersion().ToString(), true);
 }
Beispiel #16
0
        private static void LoadModAssemblies()
        {
            Log("Identifying Gadget Mods");
            nonGadgetMods    = new List <string>();
            disabledMods     = new List <string>();
            incompatibleMods = new List <string>();
            List <string> libNames     = Directory.GetFiles(UMFData.LibrariesPath).Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
            List <string> verifiedMods = new List <string>();
            List <string> verifiedLibs = new List <string>();

            foreach (string modName in UMFData.ModNames)
            {
                if (libNames.Contains(modName))
                {
                    verifiedLibs.Add(modName);
                }
                else
                {
                    verifiedMods.Add(modName);
                }
            }
            GadgetCoreAPI.ModNames = new System.Collections.ObjectModel.ReadOnlyCollection <string>(verifiedMods);
            GadgetCoreAPI.LibNames = new System.Collections.ObjectModel.ReadOnlyCollection <string>(verifiedLibs);
            List <string> modNames = verifiedMods;

            int[] currentVersionNums = GadgetCoreAPI.VERSION.Split('.').Select(x => int.Parse(x)).ToArray();
            if (currentVersionNums.Length != 4)
            {
                Array.Resize(ref currentVersionNums, 4);
            }
            for (int i = 0; i < modNames.Count; i++)
            {
                Assembly assembly = UMFMod.GetMod(modNames[i]);
                if (assembly != null)
                {
                    bool foundGadgetMod = false;
                    foreach (Type type in assembly.GetTypes())
                    {
                        GadgetModAttribute attribute = (GadgetModAttribute)type.GetCustomAttributes(typeof(GadgetModAttribute), true).FirstOrDefault();
                        if (attribute != null && type.IsSubclassOf(typeof(GadgetMod)))
                        {
                            foundGadgetMod = true;
                            int[] targetVersionNums = attribute.TargetGCVersion.Split('.').Select(x => int.Parse(x)).ToArray();
                            if (targetVersionNums.Length != 4)
                            {
                                Array.Resize(ref targetVersionNums, 4);
                            }
                            if ((attribute.GadgetVersionSpecificity == VersionSpecificity.MAJOR && currentVersionNums[0] == targetVersionNums[0] && (currentVersionNums[1] > targetVersionNums[1] || (currentVersionNums[1] == targetVersionNums[1] && (currentVersionNums[2] > targetVersionNums[2] || (currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] >= targetVersionNums[3]))))) ||
                                (attribute.GadgetVersionSpecificity == VersionSpecificity.MINOR && currentVersionNums[0] == targetVersionNums[0] && currentVersionNums[1] == targetVersionNums[1] && (currentVersionNums[2] > targetVersionNums[2] || (currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] >= targetVersionNums[3]))) ||
                                (attribute.GadgetVersionSpecificity == VersionSpecificity.NONBREAKING && currentVersionNums[0] == targetVersionNums[0] && currentVersionNums[1] == targetVersionNums[1] && currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] >= targetVersionNums[3]) ||
                                (attribute.GadgetVersionSpecificity == VersionSpecificity.BUGFIX && currentVersionNums[0] == targetVersionNums[0] && currentVersionNums[1] == targetVersionNums[1] && currentVersionNums[2] == targetVersionNums[2] && currentVersionNums[3] == targetVersionNums[3]))
                            {
                                GadgetMod mod = null;
                                try
                                {
                                    mod = Activator.CreateInstance(type) as GadgetMod;
                                    if (mod != null)
                                    {
                                        Log("Found Gadget Mod to load: " + attribute.Name + ", in assembly: {" + assembly.FullName + "}");
                                        GadgetMods.RegisterMod(new GadgetModInfo(mod, assembly, attribute, modNames[i]));
                                    }
                                }
                                catch (Exception) { }
                                finally
                                {
                                    if (mod == null)
                                    {
                                        Log("Found Gadget Mod without a parameterless constructor: " + attribute.Name + ", in assembly: {" + assembly.FullName + "}");
                                    }
                                }
                            }
                            else
                            {
                                incompatibleMods.Add(assembly.GetName().Name);
                                int rD = (int)attribute.GadgetVersionSpecificity;
                                Log("Found Gadget Mod with an incompatible version: " + attribute.Name + ", in assembly: {" + assembly.FullName + "}. Requires version: " + new string(attribute.TargetGCVersion.TakeWhile(x => (x == '.' ? --rD : rD) > 0).ToArray()));
                            }
                        }
                    }
                    if (!foundGadgetMod)
                    {
                        nonGadgetMods.Add(modNames[i]);
                    }
                }
                else
                {
                    disabledMods.Add(modNames[i]);
                }
            }
            GadgetMods.SortMods();
            if (!Directory.Exists(Path.Combine(UMFData.ModsPath, "PackedMods")))
            {
                Directory.CreateDirectory(Path.Combine(UMFData.ModsPath, "PackedMods"));
            }
            packedMods = Directory.GetFiles(UMFData.ModsPath, "*.zip").Where(x => !UMFData.Mods.Select(y => y.GetName().Name).Any(y => y == Path.GetFileNameWithoutExtension(x).Split('_')[0])).Union(Directory.GetFiles(Path.Combine(UMFData.ModsPath, "PackedMods"), "*.zip").Where(x => !UMFData.Mods.Select(y => y.GetName().Name).Any(y => y == Path.GetFileNameWithoutExtension(x).Split('_')[0]))).ToList();

            dependencies = new Dictionary <string, List <string> >();
            Assembly[] allMods = GadgetMods.ListAllModInfos().Select(x => x.Assembly).Concat(nonGadgetMods.Select(x => UMFMod.GetMod(x))).Concat(incompatibleMods.Select(x => UMFMod.GetMod(x))).ToArray();
            for (int i = 0; i < allMods.Length; i++)
            {
                Assembly      mod          = allMods[i];
                List <string> dependencies = new List <string>();
                if (i < GadgetMods.CountMods())
                {
                    GadgetModInfo gadgetMod = GadgetMods.GetModInfo(i);
                    int           rD        = (int)gadgetMod.Attribute.GadgetVersionSpecificity;
                    dependencies.Add("GadgetCore v" + new string(gadgetMod.Attribute.TargetGCVersion.TakeWhile(x => (x == '.' ? --rD : rD) > 0).ToArray()));
                }
                dependencies.AddRange(mod.GetReferencedAssemblies().Where(x => !x.Name.Equals("GadgetCore") && allMods.Select(a => a.GetName().Name).Contains(x.Name)).Select(x => x.Name + " v" + x.Version));
                if (dependencies.Count > 0)
                {
                    GadgetCore.dependencies.Add(mod.GetName().Name, dependencies.ToList());
                }
            }
            foreach (GadgetModInfo mod in GadgetMods.ListAllModInfos())
            {
                foreach (string dependency in mod.Attribute.Dependencies)
                {
                    string[] splitDependency = dependency.Split(' ');
                    if (!dependencies[mod.UMFName].Select(x => { string[] split = x.Split(' '); return(string.Join("", split.Take(split.Length - 1).ToArray())); }).Contains(string.Join("", splitDependency.Take(splitDependency.Length - 1).ToArray())))
                    {
                        dependencies[mod.UMFName].Add(dependency);
                    }
                }
            }

            Log("Finished Identifying Gadget Mods, to load: " + GadgetMods.CountMods());
        }