Exemplo n.º 1
0
        internal void EnableButton()
        {
            ModMenuEntry entry = modEntries[modIndex];

            if (gadgetIndex >= 0)
            {
                bool enabled = !entry.Gadgets[gadgetIndex].Gadget.Enabled;
                Gadgets.SetEnabled(entry.Gadgets[gadgetIndex], enabled);
            }
            else if (entry.Type == ModMenuEntryType.GADGET)
            {
                bool enabled = !GadgetMods.GetModByName(entry.Name).Enabled;
                GadgetMods.SetEnabled(entry.Name, enabled);
            }
            else
            {
                if (!File.Exists(GadgetCoreAPI.GetUMFAPI().GetDisabledModsFile()))
                {
                    File.Create(GadgetCoreAPI.GetUMFAPI().GetDisabledModsFile()).Dispose();
                }
                string   fileText  = File.ReadAllText(GadgetCoreAPI.GetUMFAPI().GetDisabledModsFile());
                string[] fileLines = File.ReadAllLines(GadgetCoreAPI.GetUMFAPI().GetDisabledModsFile());
                if (fileLines.Any(x => x.Equals(entry.Name)))
                {
                    File.WriteAllLines(GadgetCoreAPI.GetUMFAPI().GetDisabledModsFile(), fileLines.Where(x => !x.Equals(entry.Name)).ToArray());
                }
                else
                {
                    File.WriteAllText(GadgetCoreAPI.GetUMFAPI().GetDisabledModsFile(), fileText + Environment.NewLine + entry.Name);
                }
                if (modsToToggle.Contains(entry.Name))
                {
                    modsToToggle.Remove(entry.Name);
                }
                else
                {
                    modsToToggle.Add(entry.Name);
                }
            }
            Rebuild();
            UpdateRestartNeeded();
        }
Exemplo n.º 2
0
        public static void Prefix(PlayerScript __instance)
        {
            if (__instance.GetComponent <NetworkView>().isMine)
            {
                InstanceTracker.PlayerScript  = __instance;
                InstanceTracker.SpawnerScript = Camera.main.gameObject.GetComponent <SpawnerScript>();

                __instance.GetComponentInChildren <AudioSource>().PlayOneShot(GadgetCoreAPI.LoadAudioClipInternal("Sounds/particleacc.wav", GadgetMods.GetModByName("Tiers+")), 1);
            }
        }