Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
 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);
 }
Ejemplo n.º 4
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);
 }
 public static bool Prefix(GameScript __instance, Item[] ___craft, ref bool ___canCraft, ref int ___craftType)
 {
     if (MenuRegistry.Singleton.GetEntry(___craftType) is CraftMenuInfo craftMenu)
     {
         bool validated = false;
         for (int i = craftMenu.CraftValidators.Count - 1; i >= 0; i--)
         {
             if (craftMenu.CraftValidators[i](___craft))
             {
                 validated = true;
                 craftMenu.activePerformer = i;
                 craftMenu.craftResult     = ___craft.Select(x => GadgetCoreAPI.CopyItem(x)).ToArray();
                 craftMenu.CraftPerformers[i](craftMenu.craftResult);
                 ___canCraft = true;
                 __instance.buttonCraft.SendMessage("CanCraft", ___craftType, SendMessageOptions.DontRequireReceiver);
                 if (___craft[___craft.Length - 1].q == 0 && craftMenu.IsRecipeUnlocked(craftMenu.craftResult[craftMenu.craftResult.Length - 1].id))
                 {
                     __instance.previewObj.GetComponent <Renderer>().material = (Material)Resources.Load("i/i" + craftMenu.craftResult[craftMenu.craftResult.Length - 1].id);
                     __instance.previewObj.SetActive(true);
                 }
                 else
                 {
                     __instance.previewObj.SetActive(false);
                 }
                 break;
             }
         }
         if (!validated)
         {
             __instance.previewObj.SetActive(false);
             ___canCraft = false;
             __instance.buttonCraft.SendMessage("CantCraft", ___craftType, SendMessageOptions.DontRequireReceiver);
         }
         return(false);
     }
     return(true);
 }
Ejemplo n.º 6
0
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, bool ___emblemAgain)
        {
            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)
            {
                SwapItem.Invoke(__instance, new object[] { slot });
                return(false);
            }
            if ((slot == 36 && (holdingItemType & ItemType.EQUIP_MASK) != ItemType.WEAPON) || (slot == 37 && ((holdingItemType & ItemType.EQUIP_MASK) != ItemType.OFFHAND)) || (slot == 38 && ((holdingItemType & ItemType.EQUIP_MASK) != ItemType.HELMET)) || (slot == 39 && ((holdingItemType & ItemType.EQUIP_MASK) != ItemType.ARMOR)) || ((slot == 40 || slot == 41) && ((holdingItemType & ItemType.EQUIP_MASK) != ItemType.RING)) || (slot > 41 && ((holdingItemType & ItemType.EQUIP_MASK) != ItemType.DROID)))
            {
                MonoBehaviour.print("CANNOT PUT THAT THERE!");
            }
            else
            {
                MonoBehaviour.print("PLACING ONE ITEM");
                if (___emblemAgain)
                {
                    EmblemForging.Invoke(__instance, new object[] { });
                }
                bool newItem = false;
                if (___inventory[slot].id == ___holdingItem.id)
                {
                    ___inventory[slot].q++;
                }
                else
                {
                    newItem              = true;
                    ___inventory[slot]   = GadgetCoreAPI.CopyItem(___holdingItem);
                    ___inventory[slot].q = 1;
                }
                ___holdingItem.q--;
                MonoBehaviour.print(string.Concat(new object[]
                {
                    "holding Item ",
                    ___holdingItem.id,
                    " x",
                    ___holdingItem.q
                }));
                RefreshSlot.Invoke(__instance, new object[] { slot });
                RefreshHoldingSlot.Invoke(__instance, new object[] { });
                if (slot > 35)
                {
                    if (slot > 41)
                    {
                        __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/placeD"), Menuu.soundLevel / 10f);
                    }
                    else
                    {
                        __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/bling"), Menuu.soundLevel / 10f);
                    }
                    if (newItem)
                    {
                        if (slot == 36)
                        {
                            GameScript.equippedIDs[0] = ___inventory[slot].id;
                        }
                        else if (slot == 37)
                        {
                            GameScript.equippedIDs[1] = ___inventory[slot].id;
                        }
                        else if (slot == 38)
                        {
                            GameScript.equippedIDs[2] = ___inventory[slot].id;
                        }
                        else if (slot == 39)
                        {
                            GameScript.equippedIDs[3] = ___inventory[slot].id;
                        }
                        int[] gearStats = GadgetCoreAPI.GetGearStats(___inventory[slot]).GetStatArray();
                        for (int i = 0; i < 6; i++)
                        {
                            if (gearStats[i] > 0)
                            {
                                GameScript.GEARSTAT[i] += gearStats[i];
                                __instance.txtPlayerStat[i].GetComponent <Animation>().Play();
                            }
                        }
                        GadgetCoreAPI.equippedGearStats[slot - 36] = gearStats;
                        RefreshStats.Invoke(__instance, new object[] { });
                        Network.RemoveRPCs(MenuScript.playerAppearance.GetComponent <NetworkView>().viewID);
                        int[] convertedIDs = new int[]
                        {
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, GameScript.equippedIDs[0]),
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, GameScript.equippedIDs[1]),
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, GameScript.equippedIDs[2]),
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, GameScript.equippedIDs[3]),
                            GadgetNetwork.ConvertIDToHost(null /* RaceRegistry */, GameScript.equippedIDs[4]),
                            GameScript.equippedIDs[5],
                            GadgetNetwork.ConvertIDToHost(null /* UniformRegistry */, GameScript.equippedIDs[6]),
                            GadgetNetwork.ConvertIDToHost(null /* AugmentRegistry */, GameScript.equippedIDs[7])
                        };
                        MenuScript.playerAppearance.GetComponent <NetworkView>().RPC("UA", RPCMode.AllBuffered, new object[]
                        {
                            convertedIDs,
                            0,
                            GameScript.dead
                        });
                        RefreshMODS.Invoke(__instance, new object[] { });
                        __instance.UpdateHP();
                        __instance.UpdateEnergy();
                        __instance.UpdateMana();
                    }
                    if (itemInfo != null)
                    {
                        itemInfo.InvokeOnEquip(slot);
                    }
                }
                else
                {
                    __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK2"), Menuu.soundLevel / 10f);
                }
            }
            return(false);
        }
Ejemplo n.º 7
0
 public static void Prefix(ref Item ___holdingItem, ref Item __state)
 {
     __state = GadgetCoreAPI.CopyItem(___holdingItem);
 }
        public static bool Prefix(GameScript __instance, ref Item[] ___craft, ref Item __result)
        {
            int num  = Random.Range(0, 100);
            int num2 = 0;
            int num3;

            if (num < 5)
            {
                num3 = 0;
            }
            else if (num < 10)
            {
                num3 = 1;
            }
            else if (num < 15)
            {
                num3 = 2;
            }
            else
            {
                num3 = 99;
            }
            int id4 = 0;
            int q   = 1;

            if (num3 != 99)
            {
                int id5 = ___craft[num3].id;
                if (GadgetCoreAPI.creationMachineRecipes.TryGetValue(id5, out Tuple <Item, int> recipe))
                {
                    __result    = GadgetCoreAPI.CopyItem(recipe.Item1);
                    __result.q += Random.Range(0, recipe.Item2 + 1);
                }
                else
                {
                    switch (id5)
                    {
                    case 104:
                        id4 = 495;
                        break;

                    case 105:
                        id4 = 41;
                        break;

                    case 106:
                        id4  = 599;
                        num2 = 3;
                        break;

                    case 114:
                        id4 = 906;
                        break;

                    case 115:
                        id4 = 886;
                        break;

                    case 116:
                        id4  = 647;
                        num2 = 3;
                        break;

                    case 124:
                        id4 = 596;
                        break;

                    case 125:
                        id4 = 646;
                        break;

                    case 126:
                        id4  = 549;
                        num2 = 3;
                        break;

                    case 134:
                        id4 = 907;
                        break;

                    case 135:
                        id4 = 786;
                        break;

                    case 136:
                        id4  = 499;
                        num2 = 3;
                        break;
                    }
                    if (num2 == 0)
                    {
                        num2 = __instance.InvokeMethod <int>("GetRandomTier");
                    }
                    __result = new Item(id4, q, 0, num2, 0, new int[3], new int[3]);
                }
            }
            else
            {
                __result = GenerateRandomJunk(__instance);
            }
            return(false);
        }
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, bool ___emblemAgain)
        {
            ItemInfo itemInfo        = ItemRegistry.GetSingleton().GetEntry(___holdingItem.id);
            ItemType holdingItemType = itemInfo != null ? (itemInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___holdingItem.id);

            if ((holdingItemType & ItemType.NONSTACKING) == ItemType.NONSTACKING)
            {
                SwapItem.Invoke(__instance, new object[] { slot });
                return(false);
            }
            if ((slot == 36 && (holdingItemType & ItemType.BASIC_MASK) != ItemType.WEAPON) || (slot == 37 && ((holdingItemType & ItemType.BASIC_MASK) != ItemType.OFFHAND)) || (slot == 38 && ((holdingItemType & ItemType.BASIC_MASK) != ItemType.HELMET)) || (slot == 39 && ((holdingItemType & ItemType.BASIC_MASK) != ItemType.ARMOR)) || ((slot == 40 || slot == 41) && ((holdingItemType & ItemType.BASIC_MASK) != ItemType.RING)) || (slot > 41 && ((holdingItemType & ItemType.BASIC_MASK) != ItemType.DROID)))
            {
                MonoBehaviour.print("CANNOT PUT THAT THERE!");
            }
            else
            {
                MonoBehaviour.print("PLACING ONE ITEM");
                if (___emblemAgain)
                {
                    EmblemForging.Invoke(__instance, new object[] { });
                }
                bool newItem = false;
                if (___inventory[slot].id == ___holdingItem.id)
                {
                    ___inventory[slot].q++;
                }
                else
                {
                    newItem              = true;
                    ___inventory[slot]   = GadgetCoreAPI.CopyItem(___holdingItem);
                    ___inventory[slot].q = 1;
                }
                ___holdingItem.q--;
                MonoBehaviour.print(string.Concat(new object[]
                {
                    "holding Item ",
                    ___holdingItem.id,
                    " x",
                    ___holdingItem.q
                }));
                RefreshSlot.Invoke(__instance, new object[] { slot });
                RefreshHoldingSlot.Invoke(__instance, new object[] { });
                if (slot > 35)
                {
                    if (slot > 41)
                    {
                        __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/placeD"), Menuu.soundLevel / 10f);
                    }
                    else
                    {
                        __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/bling"), Menuu.soundLevel / 10f);
                    }
                    if (newItem)
                    {
                        if (slot == 36)
                        {
                            GameScript.equippedIDs[0] = ___inventory[slot].id;
                        }
                        else if (slot == 37)
                        {
                            GameScript.equippedIDs[1] = ___inventory[slot].id;
                        }
                        else if (slot == 38)
                        {
                            GameScript.equippedIDs[2] = ___inventory[slot].id;
                        }
                        else if (slot == 39)
                        {
                            GameScript.equippedIDs[3] = ___inventory[slot].id;
                        }
                        int[] gearBaseStats = (int[])GetGearBaseStats.Invoke(__instance, new object[] { ___inventory[slot].id });
                        int   num           = (int)GetItemLevel.Invoke(__instance, new object[] { ___inventory[slot].exp });
                        if (slot > 41)
                        {
                            for (int i = 0; i < 6; i++)
                            {
                                if (gearBaseStats[i] > 0)
                                {
                                    GameScript.GEARSTAT[i] += gearBaseStats[i];
                                    __instance.txtPlayerStat[i].GetComponent <Animation>().Play();
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < 6; i++)
                            {
                                if (gearBaseStats[i] > 0)
                                {
                                    GameScript.GEARSTAT[i] += ___inventory[slot].tier * 3 + gearBaseStats[i] * num;
                                    __instance.txtPlayerStat[i].GetComponent <Animation>().Play();
                                }
                            }
                            for (int j = 0; j < 3; j++)
                            {
                                ItemInfo slotAspect = ItemRegistry.GetSingleton().GetEntry(___inventory[slot].aspect[j]);
                                for (int i = 0; i < 6; i++)
                                {
                                    if (slotAspect != null)
                                    {
                                        GameScript.GEARSTAT[i] += slotAspect.Stats.GetByIndex(i);
                                    }
                                    else if (___inventory[slot].aspect[j] - 200 == i + 1)
                                    {
                                        GameScript.GEARSTAT[i] += ___inventory[slot].aspectLvl[j];
                                    }
                                }
                            }
                        }
                        RefreshStats.Invoke(__instance, new object[] { });
                        Network.RemoveRPCs(MenuScript.playerAppearance.GetComponent <NetworkView>().viewID);
                        MenuScript.playerAppearance.GetComponent <NetworkView>().RPC("UA", RPCMode.AllBuffered, new object[]
                        {
                            GameScript.equippedIDs,
                            0,
                            GameScript.dead
                        });
                        RefreshMODS.Invoke(__instance, new object[] { });
                        __instance.UpdateHP();
                        __instance.UpdateEnergy();
                        __instance.UpdateMana();
                    }
                    if (itemInfo != null)
                    {
                        itemInfo.InvokeOnEquip(slot);
                    }
                }
                else
                {
                    __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK2"), Menuu.soundLevel / 10f);
                }
            }
            return(false);
        }