public static bool Prefix(GameScript __instance, ref Item ___holdingItem, ref bool ___holdingCombatChip, ref bool ___droppingItem)
        {
            Item item = ___holdingItem;

            ___holdingItem = __instance.EmptyItem();
            if (___holdingCombatChip)
            {
                Vector3    position   = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y, 0f);
                GameObject gameObject = (GameObject)Network.Instantiate(Resources.Load("i2"), position, Quaternion.identity, 0);
                gameObject.GetComponent <NetworkView>().RPC("Chip", RPCMode.AllBuffered, new object[]
                {
                    item.id
                });
                ___droppingItem      = false;
                ___holdingCombatChip = false;
            }
            else
            {
                int[]      array       = GadgetCoreAPI.ConstructIntArrayFromItem(item, true, false);
                Vector3    position2   = new Vector3(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y, 0f);
                GameObject gameObject2 = (GameObject)Network.Instantiate(Resources.Load("i2"), position2, Quaternion.identity, 0);
                gameObject2.GetComponent <NetworkView>().RPC("Init", RPCMode.AllBuffered, new object[]
                {
                    array
                });
                ___droppingItem = false;
            }
            __instance.RefreshHoldingSlot();
            return(false);
        }
 internal static void DisableQueuedGadgets()
 {
     Logger.Log("Unloading Gadgets...");
     foreach (GadgetInfo gadget in QueuedGadgets)
     {
         gadget.Gadget.Unload();
         LootTables.RemoveModEntries(gadget.Gadget.ModID);
         GadgetCoreAPI.RemoveModResources(gadget.Gadget.ModID);
         GadgetCoreAPI.UnregisterStatModifiers(gadget.Gadget.ModID);
         GadgetNetwork.UnregisterSyncVars(gadget.Gadget.ModID);
         PlanetRegistry.UnregisterGadget(gadget.Gadget.ModID);
         foreach (Registry reg in GameRegistry.ListAllRegistries())
         {
             reg.UnregisterGadget(gadget);
         }
     }
     Logger.Log("Done unloading Gadgets.");
     Logger.Log("Unpatching Gadgets...");
     foreach (GadgetInfo gadget in QueuedGadgets.ToList())
     {
         try
         {
             gadget.Gadget.HarmonyInstance.UnpatchAll(gadget.Mod.Name + "." + gadget.Attribute.Name + ".gadget");
         }
         catch (Exception e)
         {
             Logger.LogError("Exception Unpatching Gadget '" + gadget.Attribute.Name + "':" + Environment.NewLine + e.ToString());
         }
     }
     Logger.Log("Done patching Gadgets.");
     Logger.Log("Sorting Gadgets...");
     Gadgets.SortGadgets();
     Logger.Log("Done sorting Gadgets.");
     QueuedGadgets.Clear();
 }
Exemple #3
0
        internal void RPCSendConsoleMessage(string message, NetworkMessageInfo info)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }
            if (message.Length > 1 && message[0] == '/')
            {
                string command = GadgetConsole.ParseArgs(message.Substring(1))[0];
                if (GadgetConsole.IsCommandExecuteBlacklisted(command))
                {
                    GadgetConsole.Print($"{GadgetNetwork.GetNameByNetworkPlayer(info.sender) ?? GadgetCoreAPI.GetPlayerName()} attempted to force you to execute the blacklisted command: {message}", null, GadgetConsole.MessageSeverity.WARN);
                    return;
                }
            }
            bool isOperator = GadgetConsole.IsOperator(GadgetCoreAPI.GetPlayerName());

            if (isOperator)
            {
                if (message.Length > 1 && message[0] == '/')
                {
                    GadgetConsole.Print($"{GadgetNetwork.GetNameByNetworkPlayer(info.sender) ?? GadgetCoreAPI.GetPlayerName()} forced you to execute the command: {message}");
                }
                else
                {
                    GadgetConsole.Print($"{GadgetNetwork.GetNameByNetworkPlayer(info.sender) ?? GadgetCoreAPI.GetPlayerName()} forced you to say: {message}");
                }
            }
            GadgetConsole.SendConsoleMessage(message, GadgetCoreAPI.GetPlayerName(), isOperator, true);
        }
Exemple #4
0
 internal void ReloadButton()
 {
     if (gadgetIndex >= 0)
     {
         GadgetCoreAPI.DisplayYesNoDialog("Are you sure you want to perform a Gadget reload?\nThe following Gadgets will be reloaded:\n\n" + modEntries[modIndex].Gadgets[gadgetIndex].Dependents.Union(Gadgets.LoadOrderTree.Find(modEntries[modIndex].Gadgets[gadgetIndex]).FlattenUniqueByBreadth()).Select(x => x.Attribute.Name).Concat("\n"), () => {
             Gadgets.ReloadGadget(modEntries[modIndex].Gadgets[gadgetIndex]);
         });
     }
     else
     {
         if (modEntries[modIndex].Type == ModMenuEntryType.GADGET)
         {
             GadgetCoreAPI.DisplayYesNoDialog("<color=red>WARNING: This feature does not work! Unexpected consequences may occur from attempting to use it!</color>\n\nAre you sure you want to perform a mod reload?\nThe following mods will be reloaded:\n\n" + modEntries[modIndex].Gadgets.SelectMany(x => Gadgets.LoadOrderTree.Find(x).FlattenUniqueByBreadth()).Where(x => x != null).Select(x => x.Mod).Distinct().Select(x => x.Name).Concat("\n"), () => {
                 GadgetLoader.ReloadMod(modEntries[modIndex].Gadgets[0].Mod);
             });
         }
         else
         {
             GadgetCoreAPI.DisplayYesNoDialog("UMF mods can only have their configs reloaded at runtime.\nWould you like to reload " + modEntries[modIndex].Name + "'s config?", () => {
                 GadgetCore.UMFAPI.SendCommand("cfgReload " + modEntries[modIndex].Name);
             });
         }
     }
     Rebuild();
     UpdateRestartNeeded();
 }
 public void AddResource()
 {
     gameObject = Object.Instantiate(GadgetCoreAPI.GetProjectileResource("turret"));
     AddDroneBehavior();
     UpdateTexture();
     GadgetCoreAPI.AddCustomResource("MoreCombatChips/AttackerDrone", gameObject);
 }
Exemple #6
0
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___craft)
        {
            ItemInfo itemInfo        = ItemRegistry.Singleton.GetEntry(___holdingItem.id);
            ItemType holdingItemType = itemInfo != null ? (itemInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___holdingItem.id);

            if ((holdingItemType & ItemType.NONSTACKING) == ItemType.NONSTACKING && ___craft[slot].id == ___holdingItem.id)
            {
                return(false);
            }
            __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK2"), Menuu.soundLevel / 10f);
            if (___craft[slot].id == ___holdingItem.id)
            {
                ___craft[slot].q++;
            }
            else
            {
                ___craft[slot]   = GadgetCoreAPI.CopyItem(___holdingItem);
                ___craft[slot].q = 1;
            }
            ___holdingItem.q--;
            __instance.RefreshSlotCraft(slot);
            __instance.RefreshHoldingSlot();
            __instance.CraftCheck();
            return(false);
        }
Exemple #7
0
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___storage, ref int ___curStoragePage)
        {
            ItemInfo itemInfo        = ItemRegistry.Singleton.GetEntry(___holdingItem.id);
            ItemType holdingItemType = itemInfo != null ? (itemInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___holdingItem.id);

            if ((holdingItemType & ItemType.NONSTACKING) == ItemType.NONSTACKING)
            {
                __instance.SelectItemStorage(slot);
                return(false);
            }
            __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK2"), Menuu.soundLevel / 10f);
            int num = slot + 30 * ___curStoragePage;

            if (___storage[num].q > 1)
            {
                int q = ___storage[num].q;
                ___storage[num].q /= 2;
                int num2 = q - ___storage[num].q;
                ___holdingItem   = GadgetCoreAPI.CopyItem(___storage[num]);
                ___holdingItem.q = num2;
                __instance.RefreshSlotStorage(slot);
                __instance.RefreshHoldingSlot();
            }
            return(false);
        }
Exemple #8
0
        public static bool Prefix(ItemScript __instance, int[] stats, ref Item ___item, ref Package ___package)
        {
            ___item    = GadgetCoreAPI.ConstructItemFromIntArray(stats);
            ___package = new Package(___item, __instance.gameObject, __instance.localItem);
            __instance.b.GetComponent <Renderer>().material = (Material)Resources.Load("i/i" + ___item.id);
            AnimIcon animIcon = (AnimIcon)__instance.back.GetComponent("AnimIcon");

            if ((ItemRegistry.GetTypeByID(___item.id) & ItemType.LEVELING) != ItemType.LEVELING)
            {
                __instance.back.SetActive(false);
                animIcon.anim = 0;
            }
            else
            {
                __instance.back.GetComponent <Renderer>().material = (Material)Resources.Load("iBack" + ___item.tier);
                if (___item.tier == 3)
                {
                    animIcon.anim = 1;
                }
                else
                {
                    animIcon.anim = 0;
                }
                __instance.back.SetActive(true);
            }
            __instance.StartCoroutine(Burst.Invoke(__instance, new object[] { }) as IEnumerator);
            return(false);
        }
Exemple #9
0
 internal void RPCSetOp(string name, bool op)
 {
     if (op)
     {
         if (!GadgetConsole.operators.Contains(name))
         {
             GadgetConsole.operators.Add(name);
             if (name == GadgetCoreAPI.GetPlayerName())
             {
                 GadgetConsole.Print("You are now an operator!", null, GadgetConsole.MessageSeverity.INFO);
             }
         }
     }
     else
     {
         if (GadgetConsole.operators.Contains(name))
         {
             GadgetConsole.operators.Remove(name);
             if (name == GadgetCoreAPI.GetPlayerName())
             {
                 GadgetConsole.Print("You are no longer an operator!", null, GadgetConsole.MessageSeverity.WARN);
             }
         }
     }
 }
        public static bool Prefix(GameScript __instance, int slot, ref Item[] ___inventory, bool ___exitingcombatmode, ref bool ___usingItem)
        {
            if (GadgetCoreAPI.IsInputFrozen())
            {
                return(false);
            }
            ItemInfo item = ItemRegistry.Singleton.GetEntry(___inventory[slot].id);

            if (item != null && !GameScript.dead && !___exitingcombatmode && !___usingItem)
            {
                ___usingItem = item.InvokeOnUse(slot);
                if ((item.Type & ItemType.USABLE) == ItemType.USABLE || ___usingItem)
                {
                    if (!VanillaItemInfo.Using)
                    {
                        __instance.StartCoroutine(UseItemFinal(__instance, slot, item, ___inventory, ___usingItem));
                    }
                    VanillaItemInfo.Using = false;
                }
                else if ((item.Type & ItemType.EQUIPABLE) != ItemType.EQUIPABLE)
                {
                    __instance.StartCoroutine(UseItemFinal(__instance, slot, item, ___inventory, ___usingItem));
                }
                return(false);
            }
            return(true);
        }
 public static bool Prefix(Menuu __instance, Ray ___ray, RaycastHit ___hit, ref IEnumerator __result)
 {
     __result = GadgetCoreAPI.EmptyEnumerator();
     if (GadgetCoreAPI.IsInputFrozen())
     {
         return(false);
     }
     if (ModMenuController.RestartNeeded || ModBrowser.RestartNeeded)
     {
         foreach (System.Diagnostics.Process process in ModMenuController.ConfigHandles)
         {
             if (process != null && !process.HasExited)
             {
                 process.Kill();
             }
         }
         GadgetCoreAPI.Quit();
         return(false);
     }
     ModBrowser.CloseModBrowser();
     SceneInjector.ModMenuBeam.transform.localScale       = new Vector3(30f, 0f, 1f);
     SceneInjector.ModMenuButtonHolder.transform.position = new Vector3(-40f, 0f, 0f);
     SceneInjector.ModMenu.SetActive(false);
     SceneInjector.ModMenuCanvas.GetComponent <CanvasGroup>().alpha          = 0;
     SceneInjector.ModMenuCanvas.GetComponent <CanvasGroup>().interactable   = false;
     SceneInjector.ModMenuCanvas.GetComponent <CanvasGroup>().blocksRaycasts = false;
     GadgetModConfigs.CloseAllConfigMenus();
     __instance.StartCoroutine(AnimateModMenuButton(__instance));
     return(true);
 }
Exemple #12
0
        private static IEnumerator EXP(ObjectiveScript __instance)
        {
            int exp = Random.Range(10, 50) + GameScript.challengeLevel * 255;

            GadgetCoreAPI.SpawnExp(new Vector3(__instance.transform.position.x, __instance.transform.position.y, 0f), exp, 0.2f);
            yield break;
        }
        private static void ProcessUMFMod(string modName)
        {
            Logger.Log("Processing UMF mod '" + modName + "'");
            Type[]            gadgetTypes = GadgetCoreAPI.GetUMFAPI().GetModAssembly(modName).GetExportedTypes().Where(x => x.IsSubclassOf(typeof(Gadget)) && x.GetCustomAttributes(typeof(GadgetAttribute), true).FirstOrDefault() != null).ToArray();
            List <GadgetInfo> gadgets     = new List <GadgetInfo>();

            for (int i = 0; i < gadgetTypes.Length; i++)
            {
                Type            type      = gadgetTypes[i];
                GadgetAttribute attribute = (GadgetAttribute)type.GetCustomAttributes(typeof(GadgetAttribute), true).FirstOrDefault();
                if (gadgets.Any(x => x.Attribute.Name == attribute.Name))
                {
                    throw new InvalidOperationException("It is illegal for a mod to contain multiple Gadgets with the same name: " + attribute.Name);
                }
                int[] targetVersionNums = attribute.TargetGCVersion.Split('.').Select(x => int.Parse(x)).ToArray();
                if (targetVersionNums.Length != 4)
                {
                    Array.Resize(ref targetVersionNums, 4);
                }
                if ((attribute.GadgetCoreVersionSpecificity == VersionSpecificity.MAJOR && GadgetCoreAPI.currentVersionNums[0] == targetVersionNums[0] && (GadgetCoreAPI.currentVersionNums[1] > targetVersionNums[1] || (GadgetCoreAPI.currentVersionNums[1] == targetVersionNums[1] && (GadgetCoreAPI.currentVersionNums[2] > targetVersionNums[2] || (GadgetCoreAPI.currentVersionNums[2] == targetVersionNums[2] && GadgetCoreAPI.currentVersionNums[3] >= targetVersionNums[3]))))) ||
                    (attribute.GadgetCoreVersionSpecificity == VersionSpecificity.MINOR && GadgetCoreAPI.currentVersionNums[0] == targetVersionNums[0] && GadgetCoreAPI.currentVersionNums[1] == targetVersionNums[1] && (GadgetCoreAPI.currentVersionNums[2] > targetVersionNums[2] || (GadgetCoreAPI.currentVersionNums[2] == targetVersionNums[2] && GadgetCoreAPI.currentVersionNums[3] >= targetVersionNums[3]))) ||
                    (attribute.GadgetCoreVersionSpecificity == VersionSpecificity.NONBREAKING && GadgetCoreAPI.currentVersionNums[0] == targetVersionNums[0] && GadgetCoreAPI.currentVersionNums[1] == targetVersionNums[1] && GadgetCoreAPI.currentVersionNums[2] == targetVersionNums[2] && GadgetCoreAPI.currentVersionNums[3] >= targetVersionNums[3]) ||
                    (attribute.GadgetCoreVersionSpecificity == VersionSpecificity.BUGFIX && GadgetCoreAPI.currentVersionNums[0] == targetVersionNums[0] && GadgetCoreAPI.currentVersionNums[1] == targetVersionNums[1] && GadgetCoreAPI.currentVersionNums[2] == targetVersionNums[2] && GadgetCoreAPI.currentVersionNums[3] == targetVersionNums[3]))
                {
                    Gadget gadget = null;
                    try
                    {
                        gadget = Activator.CreateInstance(type) as Gadget;
                        if (gadget != null)
                        {
                            Logger.Log("Found Gadget to load: " + attribute.Name + ", in UMF mod: {" + modName + "}");
                            GadgetInfo info = new GadgetInfo(gadget, attribute, modName);
                            gadget.Logger = new GadgetLogger(modName, attribute.Name);
                            gadget.Config = new GadgetConfig(Path.Combine(GadgetPaths.ConfigsPath, modName + ".ini"), attribute.Name);
                            Gadgets.RegisterGadget(info);
                            gadgets.Add(info);
                            if (!BatchLoading)
                            {
                                QueuedGadgets.Add(info);
                                EnableQueuedGadgets();
                            }
                        }
                    }
                    catch (Exception) { }
                    finally
                    {
                        if (gadget == null)
                        {
                            Logger.LogWarning("Found Gadget that could not be constructed: " + attribute.Name + ", in UMF mod: {" + modName + "}");
                        }
                    }
                }
                else
                {
                    int rD = (int)attribute.GadgetCoreVersionSpecificity;
                    Logger.LogWarning("Found Gadget with an incompatible version: " + attribute.Name + ", in UMF mod: {" + modName + "}. Requires version: " + new string(attribute.TargetGCVersion.TakeWhile(x => (x == '.' ? --rD : rD) > 0).ToArray()));
                }
            }
        }
        private static IEnumerator QuestEXP(GameScript __instance, int tier)
        {
            int     exp = 100 + tier * 250;
            Vector3 pos = new Vector3(MenuScript.player.transform.position.x + 5f, MenuScript.player.transform.position.y, 0f);

            GadgetCoreAPI.SpawnExp(pos, exp, 0.1f);
            yield break;
        }
Exemple #15
0
 /// <summary>
 /// Checks whether the player has an item.
 /// </summary>
 public static Func <int, bool> HasItem(int itemID, int quantity = 1)
 {
     return((b) =>
     {
         int slot = InstanceTracker.GameScript.ItemExistsSlot(itemID);
         return slot != -1 && GadgetCoreAPI.GetInventory()[slot].q >= quantity;
     });
 }
Exemple #16
0
 public static bool Prefix(string path, ref UnityEngine.Object __result)
 {
     if (GadgetCoreAPI.IsCustomResourceRegistered(path))
     {
         __result = GadgetCoreAPI.resources[path];
         return(false);
     }
     return(true);
 }
        private void CreateClone(GameObject gameObjectToClone)
        {
            GameObject clone = Object.Instantiate(gameObjectToClone, gameObjectToClone.transform.position,
                                                  gameObjectToClone.transform.rotation, gameObjectToClone.transform.parent);
            MeshRenderer cloneMesh = clone.GetComponent <MeshRenderer>();

            cloneMesh.material.SetTexture("_MainTex", GadgetCoreAPI.LoadTexture2D("MessyOneBrown"));
            cloneMesh.sortingOrder = 0;
        }
 public static bool Prefix(ref Item[] ___craft, ref Item __result)
 {
     if (GadgetCoreAPI.alchemyStationRecipes.TryGetValue(Tuple.Create(___craft[0].id, ___craft[1].id, ___craft[2].id), out Tuple <Item, int> recipe))
     {
         __result    = GadgetCoreAPI.CopyItem(recipe.Item1);
         __result.q += Random.Range(0, recipe.Item2 + 1);
         return(false);
     }
     return(true);
 }
        protected override void Action(int slot)
        {
            float      cursorPosX = GadgetCoreAPI.GetCursorPos().x;
            Vector3    playerPos  = InstanceTracker.PlayerScript.gameObject.transform.position;
            int        xDirection = cursorPosX < playerPos.x ? -1 : 1;
            Vector3    spawnPos   = playerPos + new Vector3(2f * xDirection, 0f, 0f);
            GameObject gameObject = (GameObject)Network.Instantiate(Resources.Load("MoreCombatChips/AttackerDrone"), spawnPos, Quaternion.identity, 0);

            gameObject.GetComponent <AttackerDroneScript>().Set(Damage, xDirection);
        }
Exemple #20
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);
            }
        }
Exemple #21
0
 public static bool Prefix(Menuu __instance, ref int ___stuffSelecting, ref IEnumerator __result)
 {
     ___stuffSelecting = 0;
     __instance.stuffChosen.transform.position = new Vector3(__instance.box[Menuu.curRace % CharacterRaceRegistry.PageSize].transform.position.x, __instance.box[Menuu.curRace % CharacterRaceRegistry.PageSize].transform.position.y, -3f);
     __instance.menuStuffSelect.SetActive(true);
     CharacterRaceRegistry.CurrentPage = Menuu.curRace / CharacterRaceRegistry.PageSize + 1;
     __instance.RefreshStuffSelect(Menuu.curRace % CharacterRaceRegistry.PageSize);
     __result = GadgetCoreAPI.EmptyEnumerator();
     return(false);
 }
 public static bool Prefix(PlayerScript __instance, ref bool ___attacking, ref bool ___canAttack, ref GameScript ___gameScript, ref IEnumerator __result)
 {
     if (ItemRegistry.GetSingleton().HasEntry(GameScript.equippedIDs[0]) && !___attacking && ___canAttack && !___gameScript.combatSwitching && !PlayerScript.beaming && !VanillaItemInfo.Attacking)
     {
         ItemRegistry.GetSingleton().GetEntry(GameScript.equippedIDs[0]).InvokeOnAttack(__instance);
         __result = GadgetCoreAPI.EmptyEnumerator();
         return(false);
     }
     return(true);
 }
Exemple #23
0
 internal void GiveChip(Item item, NetworkPlayer player)
 {
     if (Network.player == player)
     {
         GadgetCoreAPI.SpawnItemLocal(InstanceTracker.PlayerScript.transform.position, item, true).gameObject.SendMessage("Request");
     }
     else
     {
         view.RPC("RPCGiveChip", player, GadgetCoreAPI.ConstructIntArrayFromItem(item, true, true));
     }
 }
Exemple #24
0
 public static bool Prefix(ref Item[] ___craft, ref Item __result)
 {
     if (GadgetCoreAPI.ultimateForgeRecipes.TryGetValue(Tuple.Create(___craft[0].id, ___craft[2].id), out int outputID))
     {
         __result     = GadgetCoreAPI.CopyItem(___craft[0]);
         __result.id  = outputID;
         __result.q   = 1;
         __result.exp = 0;
         return(false);
     }
     return(true);
 }
Exemple #25
0
 /// <summary>
 /// Takes an item from the player.
 /// </summary>
 public static Action TakeItem(int itemID, int quantity = 1)
 {
     return(() =>
     {
         int slot = InstanceTracker.GameScript.ItemExistsSlot(itemID);
         if (slot != -1 && GadgetCoreAPI.GetInventory()[slot].q >= quantity)
         {
             GadgetCoreAPI.GetInventory()[slot].q -= quantity;
             InstanceTracker.GameScript.RefreshSlot(slot);
         }
     });
 }
        //Add your config vars here.

        internal static void Load()
        {
            try
            {
                GadgetCoreAPI.UnregisterKeyDownListener(ConsoleKey, GadgetConsole.ShowConsole);

                cfg.Load();

                string fileVersion = cfg.ReadString("ConfigVersion", configVersion, comments: "The Config Version (not to be confused with mod version)");

                if (fileVersion != configVersion)
                {
                    cfg.Reset();
                    cfg.WriteString("ConfigVersion", configVersion, comments: "The Config Version (not to be confused with mod version)");
                }

                BetterDroidHover            = cfg.ReadBool("BetterDroidHover", true, false, false, "Whether to use the standard hover box for droids, rather than the text-based description.");
                MaxConnections              = cfg.ReadInt("MaxConnections", 4, 4, false, 1, int.MaxValue, "The maximum number of connections allowed when using host-and-play. This setting only matters on the host.");
                UseUPnP                     = cfg.ReadBool("UseUPnP", false, false, false, "If True, will attempt to use UPnP to bypass the need to port-forward to host-and-play over the internet. Not all routers support this. Disabled by default due to severe unresolved bugs that prevent the game from working at all sometimes.");
                GadgetNetwork.MatrixTimeout = cfg.ReadFloat("NetworkTimeout", 2.5f, comments: "How long to wait for the host's game to respond to Gadget Core's ID synchronization. If the host's game does not respond in time, it will be assumed that the host does not have Gadget Core installed.");
                ConsoleKey                  = cfg.ReadKeyCode("ConsoleKey", UnityEngine.KeyCode.BackQuote, comments: "The key to open the console.");
                GadgetConsole.Debug         = cfg.ReadBool("ConsoleDebug", false, comments: "If true, shows debug messages in the console.");
                MaxBackups                  = cfg.ReadInt("MaxBackups", 30, 0, false, 0, int.MaxValue, "The maximum number of save backups to have at any one time. Disables backups if set to 0");

                cfg.Save();

                GadgetCoreAPI.RegisterKeyDownListener(ConsoleKey, GadgetConsole.ShowConsole);

                string enabledModsString = PlayerPrefs.GetString("EnabledMods", "");
                try
                {
                    enabledMods = enabledModsString.Split(',').Select(x => x.Split(':')).ToDictionary(x => x[0], x => bool.Parse(x[1]));
                }
                catch (IndexOutOfRangeException)
                {
                    enabledMods = new Dictionary <string, bool>();
                }
                string enabledGadgetsString = PlayerPrefs.GetString("EnabledGadgets", "");
                try
                {
                    enabledGadgets = enabledGadgetsString.Split(',').Select(x => x.Split(':')).ToDictionary(x => x[0], x => bool.Parse(x[1]));
                }
                catch (IndexOutOfRangeException)
                {
                    enabledGadgets = new Dictionary <string, bool>();
                }
            }
            catch (Exception e)
            {
                GadgetCore.CoreLogger.LogError("Error loading config: " + e.ToString());
            }
        }
Exemple #27
0
 public static bool Prefix(string path, ref UnityEngine.Object __result)
 {
     if (GadgetCoreAPI.IsCustomResourceRegistered(path))
     {
         __result = GadgetCoreAPI.resources[path];
         if (__result is AudioClip au && !au.LoadAudioData())
         {
             GadgetCore.CoreLogger.LogWarning("Loading custom AudioClip resource \"" + path + "\" that is in loadState " + au.loadState);
         }
         return(false);
     }
     return(true);
 }
Exemple #28
0
        private static void VanillaRegistration()
        {
            Registry.gadgetRegistering  = -1;
            Registry.registeringVanilla = true;

            GameRegistry.RegisterRegistry(ItemRegistry.Singleton);
            GameRegistry.RegisterRegistry(ChipRegistry.Singleton);
            GameRegistry.RegisterRegistry(TileRegistry.Singleton);
            GameRegistry.RegisterRegistry(EntityRegistry.Singleton);
            GameRegistry.RegisterRegistry(MenuRegistry.Singleton);
            GameRegistry.RegisterRegistry(ObjectRegistry.Singleton);
            GameRegistry.RegisterRegistry(PlanetRegistry.Singleton);
            GameRegistry.RegisterRegistry(AllegianceRegistry.Singleton);
            GameRegistry.RegisterRegistry(AllegianceRegistry.Singleton);
            GameRegistry.RegisterRegistry(CharacterRaceRegistry.Singleton);
            GameRegistry.RegisterRegistry(CharacterAugmentRegistry.Singleton);
            GameRegistry.RegisterRegistry(CharacterUniformRegistry.Singleton);

            GadgetCoreAPI.MissingTexSprite = GadgetCoreAPI.AddTextureToSheet(GadgetCoreAPI.LoadTexture2D("missing_tex"));

            GameObject expCustom = Instantiate(Resources.Load <GameObject>("exp/exp7"));

            GadgetCoreAPI.AddCustomResource("exp/expCustom", expCustom);

            GadgetCoreAPI.AddCustomResource("mat/mRaceBack", new Material(Shader.Find("Unlit/Transparent"))
            {
                mainTexture = GadgetCoreAPI.LoadTexture2D("blank_race_select.png")
            });
            GadgetCoreAPI.AddCustomResource("mat/mRaceSlot", new Material(Shader.Find("Unlit/Transparent"))
            {
                mainTexture = GadgetCoreAPI.LoadTexture2D("blank_race_slot.png")
            });
            GadgetCoreAPI.AddCustomResource("mat/mUniformBack", new Material(Shader.Find("Unlit/Transparent"))
            {
                mainTexture = GadgetCoreAPI.LoadTexture2D("blank_uniform_select.png")
            });
            GadgetCoreAPI.AddCustomResource("mat/mUniformSlot", new Material(Shader.Find("Unlit/Transparent"))
            {
                mainTexture = GadgetCoreAPI.LoadTexture2D("blank_uniform_slot.png")
            });
            GadgetCoreAPI.AddCustomResource("mat/mAugmentBack", new Material(Shader.Find("Unlit/Transparent"))
            {
                mainTexture = GadgetCoreAPI.LoadTexture2D("blank_augment_select.png")
            });
            GadgetCoreAPI.AddCustomResource("mat/mAugmentSlot", new Material(Shader.Find("Unlit/Transparent"))
            {
                mainTexture = GadgetCoreAPI.LoadTexture2D("blank_augment_slot.png")
            });

            Registry.registeringVanilla = false;
        }
Exemple #29
0
        public static bool Prefix(ItemScript __instance, int[] stats, ref Item ___item, ref Package ___package)
        {
            if (stats[1] > 9999)
            {
                if (stats[0] == 52)
                {
                    int trophies = (stats[1] - 1) / 9999;
                    stats[1] -= trophies * 9999;
                    if (trophies > 0)
                    {
                        GadgetCoreAPI.SpawnItemLocal(__instance.transform.position, new Item(59, trophies, 0, 0, 0, new int[3], new int[3]));
                    }
                }
                else
                {
                    int extraStacks = (stats[1] - 1) / 9999;
                    stats[1] -= extraStacks * 9999;
                    int[] extraStackArray = stats;
                    extraStackArray[1] = 9999;
                    for (int i = 0; i < extraStacks; i++)
                    {
                        GadgetCoreAPI.SpawnItemLocal(__instance.transform.position, GadgetCoreAPI.ConstructItemFromIntArray(extraStackArray));
                    }
                }
            }
            ___item    = GadgetCoreAPI.ConstructItemFromIntArray(stats);
            ___package = new Package(___item, __instance.gameObject, __instance.localItem);
            __instance.b.GetComponent <Renderer>().material = (Material)Resources.Load("i/i" + ___item.id);
            AnimIcon animIcon = (AnimIcon)__instance.back.GetComponent("AnimIcon");

            if ((ItemRegistry.GetTypeByID(___item.id) & ItemType.LEVELING) != ItemType.LEVELING)
            {
                __instance.back.SetActive(false);
                animIcon.anim = 0;
            }
            else
            {
                __instance.back.GetComponent <Renderer>().material = (Material)Resources.Load("iBack" + ___item.tier);
                if (___item.tier == 3)
                {
                    animIcon.anim = 1;
                }
                else
                {
                    animIcon.anim = 0;
                }
                __instance.back.SetActive(true);
            }
            __instance.StartCoroutine(Burst.Invoke(__instance, new object[] { }) as IEnumerator);
            return(false);
        }
        public override void Initialize()
        {
            GadgetCoreAPI.AddCustomResource("mat/menuCrafter", Resources.Load("mat/menuForge"));
            GadgetCoreAPI.AddCustomResource("mat/barCrafter", Resources.Load("mat/barForge"));

            Texture crafterItemTex = GadgetCoreAPI.GetItemMaterial(2101).mainTexture;

            crafterItem = new ItemInfo(ItemType.GENERIC, "Crafter Block", "Used for crafting\nmodded items.", crafterItemTex).Register("Crafter Block");

            Material   crafterTileMat = GadgetCoreAPI.GetTileMaterial(2101);
            GameObject crafterProp    = GadgetCoreAPI.GetPropResource(2101);

            crafterTile = new TileInfo(TileType.INTERACTIVE, crafterTileMat, crafterProp, crafterItem).Register("Universal Crafter");
        }