Exemple #1
0
 public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item[] ___inventory, ref Item[] ___gatherStorage, int slot, int ___curStoragePage, ref IEnumerator __result)
 {
     itemInSlot = ___gatherStorage[slot];
     if (!___shiftclicking)
     {
         ItemInfo slotInfo     = ItemRegistry.Singleton.GetEntry(itemInSlot.id);
         ItemType slotItemType = slotInfo != null ? (slotInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(itemInSlot.id);
         int      num          = 0;
         if ((slotItemType & ItemType.NONSTACKING) == ItemType.STACKING)
         {
             bool flag1 = false, flag2 = false;
             for (int i = 0; i < 36; i++)
             {
                 if (GadgetCoreAPI.CanItemsStack(___inventory[i], itemInSlot) && ___inventory[i].q < 9999)
                 {
                     if (___inventory[i].q + ___gatherStorage[slot].q <= 9999)
                     {
                         flag1 = true;
                         num   = i;
                         break;
                     }
                     else
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___gatherStorage[slot].q -= 9999 - ___inventory[i].q;
                         ___inventory[i].q         = 9999;
                         __instance.RefreshSlot(i);
                         flag2 = true;
                     }
                 }
             }
             if (flag1)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___inventory[num].q   += ___gatherStorage[slot].q;
                 ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                 __instance.RefreshSlot(num);
             }
             else
             {
                 for (int i = 0; i < 36; i++)
                 {
                     if (___inventory[i].id == 0)
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___inventory[i]        = ___gatherStorage[slot];
                         ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         __instance.RefreshSlot(i);
                         break;
                     }
                     else if (GadgetCoreAPI.CanItemsStack(___inventory[i], itemInSlot) && ___inventory[i].q < 9999)
                     {
                         if (___inventory[i].q + ___gatherStorage[slot].q <= 9999)
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___inventory[i].q     += ___gatherStorage[slot].q;
                             ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                             __instance.RefreshSlot(i);
                             break;
                         }
                         else
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___gatherStorage[slot].q -= 9999 - ___inventory[i].q;
                             ___inventory[i].q         = 9999;
                             __instance.RefreshSlot(i);
                         }
                         flag2 = true;
                     }
                 }
             }
             __instance.RefreshSlotGather(slot);
             ___shiftclicking = false;
             __result         = FakeRoutine();
             return(false);
         }
         else
         {
             for (int i = 0; i < 36; i++)
             {
                 if (___inventory[i].id == 0)
                 {
                     __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                     ___inventory[i]        = ___gatherStorage[slot];
                     ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                     __instance.RefreshSlot(i);
                     __instance.RefreshSlotGather(slot);
                     break;
                 }
             }
         }
     }
     return(true);
 }
Exemple #2
0
 public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item[] ___inventory, ref Item[] ___storage, int slot, int ___curStoragePage, ref int ___droidCount, ref IEnumerator __result)
 {
     if (!___shiftclicking)
     {
         itemInSlot = ___inventory[slot];
         ItemInfo slotInfo     = ItemRegistry.Singleton.GetEntry(itemInSlot.id);
         ItemType slotItemType = slotInfo != null ? (slotInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(itemInSlot.id);
         int      num          = 0;
         int      num2         = ___curStoragePage * 30;
         int      num3         = num2 + 30;
         if ((slotItemType & ItemType.NONSTACKING) == ItemType.STACKING)
         {
             bool flag1 = false, flag2 = false;
             for (int i = num2; i < num3; i++)
             {
                 if (GadgetCoreAPI.CanItemsStack(___storage[i], itemInSlot) && ___storage[i].q < 9999)
                 {
                     if (___storage[i].q + ___inventory[slot].q <= 9999)
                     {
                         flag1 = true;
                         num   = i;
                     }
                     else
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___inventory[slot].q -= 9999 - ___storage[i].q;
                         ___storage[i].q       = 9999;
                         flag2 = true;
                     }
                     break;
                 }
             }
             if (flag1)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___storage[num].q += ___inventory[slot].q;
                 ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
             }
             else
             {
                 for (int i = num2; i < num3; i++)
                 {
                     if (___storage[i].id == 0)
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___storage[i]      = ___inventory[slot];
                         ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         break;
                     }
                     else if (GadgetCoreAPI.CanItemsStack(___storage[i], itemInSlot) && ___storage[i].q < 9999)
                     {
                         if (___storage[i].q + ___inventory[slot].q <= 9999)
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___storage[i].q   += ___inventory[slot].q;
                             ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                             break;
                         }
                         else
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___inventory[slot].q -= 9999 - ___storage[i].q;
                             ___storage[i].q       = 9999;
                         }
                         flag2 = true;
                     }
                 }
             }
             __instance.RefreshSlot(slot);
             __instance.StartCoroutine(__instance.RefreshStoragePage(___curStoragePage));
         }
         else
         {
             for (int i = num2; i < num3; i++)
             {
                 if (___storage[i].id == 0)
                 {
                     if (slot > 35)
                     {
                         if (slot == 36)
                         {
                             GameScript.equippedIDs[0] = 0;
                         }
                         else if (slot == 37)
                         {
                             GameScript.equippedIDs[1] = 0;
                         }
                         else if (slot == 38)
                         {
                             GameScript.equippedIDs[2] = 0;
                         }
                         else if (slot == 39)
                         {
                             GameScript.equippedIDs[3] = 0;
                         }
                         else if (slot == 40)
                         {
                             GameScript.equippedIDs[4] = 0;
                         }
                         else if (slot == 41)
                         {
                             GameScript.equippedIDs[5] = 0;
                         }
                         int[] stats = GadgetCoreAPI.equippedGearStats[slot - 36];
                         for (int s = 0; s < 6; s++)
                         {
                             if (stats[s] > 0)
                             {
                                 GameScript.GEARSTAT[s] -= stats[s];
                                 __instance.txtPlayerStat[s].GetComponent <Animation>().Play();
                             }
                         }
                         GadgetCoreAPI.equippedGearStats[slot - 36] = new int[] { 0, 0, 0, 0, 0, 0 };
                         __instance.RefreshStats();
                         Network.RemoveRPCs(MenuScript.playerAppearance.GetComponent <NetworkView>().viewID);
                         MenuScript.playerAppearance.GetComponent <NetworkView>().RPC("UA", RPCMode.AllBuffered, new object[]
                         {
                             GameScript.equippedIDs,
                             0,
                             GameScript.dead
                         });
                         __instance.UpdateHP();
                         __instance.UpdateEnergy();
                         __instance.UpdateMana();
                     }
                     __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                     ___storage[i]      = ___inventory[slot];
                     ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                     __instance.RefreshSlot(slot);
                     __instance.StartCoroutine(__instance.RefreshStoragePage(___curStoragePage));
                     if (slotItemType == ItemType.DROID && slot > 41)
                     {
                         ___droidCount--;
                         __instance.UpdateDroids();
                     }
                     if (slotInfo != null)
                     {
                         slotInfo.InvokeOnDequip(slot);
                     }
                     break;
                 }
             }
         }
         ___shiftclicking = false;
         __result         = FakeRoutine();
         return(false);
     }
     return(true);
 }
Exemple #3
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);
        }
 public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item[] ___inventory, ref Item[] ___gatherStorage, int slot, int ___curStoragePage, ref IEnumerator __result)
 {
     itemInSlot = ___gatherStorage[slot];
     if (!___shiftclicking)
     {
         ItemInfo slotInfo     = ItemRegistry.GetSingleton().GetEntry(itemInSlot.id);
         ItemType slotItemType = slotInfo != null ? (slotInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(itemInSlot.id);
         int      num          = 0;
         if ((slotItemType & ItemType.NONSTACKING) == ItemType.STACKING)
         {
             bool flag1 = false, flag2 = false;
             for (int i = 0; i < 36; i++)
             {
                 if (___inventory[i].id == itemInSlot.id && ___inventory[i].q < 9999)
                 {
                     if (___inventory[i].q + ___gatherStorage[slot].q <= 9999)
                     {
                         flag1 = true;
                         num   = i;
                         break;
                     }
                     else
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___gatherStorage[slot].q -= 9999 - ___inventory[i].q;
                         ___inventory[i].q         = 9999;
                         typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                         flag2 = true;
                     }
                 }
             }
             if (flag1)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___inventory[num].q   += ___gatherStorage[slot].q;
                 ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                 typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { num });
             }
             else
             {
                 for (int i = 0; i < 36; i++)
                 {
                     if (___inventory[i].id == 0)
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___inventory[i]        = ___gatherStorage[slot];
                         ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                         break;
                     }
                     else if (___inventory[i].id == itemInSlot.id && ___inventory[i].q < 9999)
                     {
                         if (___inventory[i].q + ___gatherStorage[slot].q <= 9999)
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___inventory[i].q     += ___gatherStorage[slot].q;
                             ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                             typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                             break;
                         }
                         else
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___gatherStorage[slot].q -= 9999 - ___inventory[i].q;
                             ___inventory[i].q         = 9999;
                             typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                         }
                         flag2 = true;
                     }
                 }
             }
             typeof(GameScript).GetMethod("RefreshSlotGather", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
             ___shiftclicking = false;
             __result         = FakeRoutine();
             return(false);
         }
         else
         {
             for (int i = 0; i < 36; i++)
             {
                 if (___inventory[i].id == 0)
                 {
                     __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                     ___inventory[i]        = ___gatherStorage[slot];
                     ___gatherStorage[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                     typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                     typeof(GameScript).GetMethod("RefreshSlotGather", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
                     break;
                 }
             }
         }
     }
     return(true);
 }
Exemple #5
0
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, ref int ___droidCount)
        {
            ItemInfo itemInfo     = ItemRegistry.Singleton.GetEntry(___inventory[slot].id);
            ItemType slotItemType = itemInfo != null ? (itemInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___inventory[slot].id);

            __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK1"), Menuu.soundLevel / 10f);
            ___holdingItem     = ___inventory[slot];
            ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
            RefreshSlot.Invoke(__instance, new object[] { slot });
            RefreshHoldingSlot.Invoke(__instance, new object[] { });
            if (slotItemType == ItemType.DROID && slot > 41 && slot < 45)
            {
                ___droidCount--;
                __instance.activated[slot - 42] = false;
                __instance.droid[slot - 42].SendMessage("Deactivate", SendMessageOptions.DontRequireReceiver);
                UpdateDroids.Invoke(__instance, new object[] { });
            }
            if (slot > 35)
            {
                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[] stats = GadgetCoreAPI.equippedGearStats[slot - 36];
                for (int i = 0; i < 6; i++)
                {
                    if (stats[i] > 0)
                    {
                        GameScript.GEARSTAT[i] -= stats[i];
                        __instance.txtPlayerStat[i].GetComponent <Animation>().Play();
                    }
                }
                GadgetCoreAPI.equippedGearStats[slot - 36] = new int[] { 0, 0, 0, 0, 0, 0 };
                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.InvokeOnDequip(slot);
                }
            }
            return(false);
        }
Exemple #6
0
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem)
        {
            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)
            {
                SelectItemStorage.Invoke(__instance, new object[] { slot });
                return(false);
            }
            return(true);
        }
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);
        }
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, ref int ___droidCount, 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 ((slot == 36 && (holdingItemType & ItemType.EQUIP_MASK) != (ItemType.WEAPON & ItemType.EQUIP_MASK)) || (slot == 37 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.OFFHAND & ItemType.EQUIP_MASK))) || (slot == 38 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.HELMET & ItemType.EQUIP_MASK))) || (slot == 39 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.ARMOR & ItemType.EQUIP_MASK))) || ((slot == 40 || slot == 41) && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.RING & ItemType.EQUIP_MASK))) || (slot > 41 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.DROID & ItemType.EQUIP_MASK))))
            {
                __instance.Error(2);
            }
            else
            {
                if (___emblemAgain)
                {
                    EmblemForging.Invoke(__instance, new object[] { });
                }
                ___inventory[slot] = ___holdingItem;
                ___holdingItem     = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                ItemType slotItemType = holdingItemType;
                RefreshSlot.Invoke(__instance, new object[] { slot });
                RefreshHoldingSlot.Invoke(__instance, new object[] { });
                if (slotItemType == ItemType.DROID && slot > 41 && slot < 45)
                {
                    ___droidCount++;
                    UpdateDroids.Invoke(__instance, new object[] { });
                    __instance.droid[slot - 42].SendMessage("SetStats", ___inventory[slot].id);
                }
                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);
                    }
                    Object.Instantiate(Resources.Load("clickBurst"), new Vector3(__instance.invIcon[slot].transform.position.x, __instance.invIcon[slot].transform.position.y, 0f), Quaternion.identity);
                    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.equipedGearStats[slot - 36] = gearStats;
                    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/CLICK1"), Menuu.soundLevel / 10f);
                }
            }
            return(false);
        }
Exemple #9
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 #10
0
 public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item[] ___inventory, ref Item[] ___craft, ref int ___craftType, int slot, ref IEnumerator __result)
 {
     itemInSlot = ___inventory[slot];
     if (!___shiftclicking)
     {
         ItemInfo slotInfo               = ItemRegistry.GetSingleton().GetEntry(itemInSlot.id);
         ItemType slotItemType           = slotInfo != null ? (slotInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(itemInSlot.id);
         ItemType slotItemTypeUnfiltered = slotInfo != null ? slotInfo.Type : ItemRegistry.GetDefaultTypeByID(itemInSlot.id);
         bool     flag = false;
         int      num  = 0;
         if (___craftType == 0)
         {
             if (slotItemType == ItemType.EMBLEM)
             {
                 for (int i = 0; i < 3; i++)
                 {
                     if (___craft[i].id == itemInSlot.id && ___craft[i].q + ___inventory[slot].q <= 9999)
                     {
                         flag = true;
                         num  = i;
                         break;
                     }
                 }
                 if (flag)
                 {
                     __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                     ___craft[num].q   += ___inventory[slot].q;
                     ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                     typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
                     typeof(GameScript).GetMethod("RefreshSlotCraft", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { num });
                 }
                 else
                 {
                     for (int i = 0; i < 3; i++)
                     {
                         if (___craft[i].id == 0)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             ___craft[i]        = ___inventory[slot];
                             ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                             typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
                             typeof(GameScript).GetMethod("RefreshSlotCraft", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                             break;
                         }
                     }
                 }
             }
         }
         else if (___craftType == 1 && (slotItemType & ItemType.EMBLEM) == ItemType.LOOT && (slotItemTypeUnfiltered & ItemType.ORGANIC) == ItemType.ORGANIC)
         {
             for (int i = 0; i < 3; i++)
             {
                 if (___craft[i].id == itemInSlot.id && ___craft[i].q + ___inventory[slot].q <= 9999)
                 {
                     __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                     flag = true;
                     num  = i;
                     break;
                 }
             }
             if (flag)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___craft[num].q   += ___inventory[slot].q;
                 ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                 typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
                 typeof(GameScript).GetMethod("RefreshSlotCraft", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { num });
             }
             else
             {
                 for (int i = 0; i < 3; i++)
                 {
                     if (___craft[i].id == 0)
                     {
                         __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         ___craft[i]        = ___inventory[slot];
                         ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
                         typeof(GameScript).GetMethod("RefreshSlotCraft", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { i });
                         break;
                     }
                 }
             }
         }
         ___shiftclicking = false;
         typeof(GameScript).GetMethod("CraftCheck", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
         __result = FakeRoutine();
         return(false);
     }
     return(true);
 }
 public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, ref int ___droidCount)
 {
     if (ItemRegistry.GetSingleton().HasEntry(___holdingItem.id) || ItemRegistry.GetSingleton().HasEntry(___inventory[slot].id))
     {
         ItemInfo itemInfo        = ItemRegistry.GetSingleton().GetEntry(___holdingItem.id);
         ItemInfo slotInfo        = ItemRegistry.GetSingleton().GetEntry(___inventory[slot].id);
         ItemType holdingItemType = itemInfo != null ? (itemInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___holdingItem.id);
         ItemType slotItemType    = slotInfo != null ? (slotInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___inventory[slot].id);
         if ((slot == 36 && (holdingItemType & ItemType.BASIC_MASK) != (ItemType.WEAPON & ItemType.BASIC_MASK)) || (slot == 37 && ((holdingItemType & ItemType.BASIC_MASK) != (ItemType.OFFHAND & ItemType.BASIC_MASK))) || (slot == 38 && ((holdingItemType & ItemType.BASIC_MASK) != (ItemType.HELMET & ItemType.BASIC_MASK))) || (slot == 39 && ((holdingItemType & ItemType.BASIC_MASK) != (ItemType.ARMOR & ItemType.BASIC_MASK))) || ((slot == 40 || slot == 41) && ((holdingItemType & ItemType.BASIC_MASK) != (ItemType.RING & ItemType.BASIC_MASK))) || (slot > 41 && ((holdingItemType & ItemType.BASIC_MASK) != (ItemType.DROID & ItemType.BASIC_MASK))))
         {
             __instance.Error(2);
         }
         else
         {
             Item item = ___holdingItem;
             ___holdingItem     = ___inventory[slot];
             ___inventory[slot] = item;
             ItemType typeHolder = holdingItemType;
             holdingItemType = slotItemType;
             slotItemType    = typeHolder;
             RefreshSlot.Invoke(__instance, new object[] { slot });
             RefreshHoldingSlot.Invoke(__instance, new object[] { });
             if (slot > 41 && slot < 45 && slotItemType == ItemType.DROID)
             {
                 if (holdingItemType == ItemType.DROID)
                 {
                     MonoBehaviour.print("swapped droids");
                     UpdateDroids.Invoke(__instance, new object[] { });
                     __instance.droid[slot - 42].SendMessage("SetStats", ___inventory[slot].id);
                 }
                 else
                 {
                     ___droidCount++;
                     UpdateDroids.Invoke(__instance, new object[] { });
                     __instance.droid[slot - 42].SendMessage("SetStats", ___inventory[slot].id);
                 }
             }
             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);
                 }
                 UnityEngine.Object.Instantiate(Resources.Load("clickBurst"), new Vector3(__instance.invIcon[slot].transform.position.x, __instance.invIcon[slot].transform.position.y, 0f), Quaternion.identity);
                 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[] gearBaseStats2 = (int[])GetGearBaseStats.Invoke(__instance, new object[] { ___holdingItem.id });
                 int   num            = (int)GetItemLevel.Invoke(__instance, new object[] { ___inventory[slot].exp });
                 int   num2           = (int)GetItemLevel.Invoke(__instance, new object[] { ___holdingItem.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();
                         }
                         if (gearBaseStats2[i] > 0)
                         {
                             GameScript.GEARSTAT[i] -= gearBaseStats2[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();
                         }
                         if (gearBaseStats2[i] > 0)
                         {
                             GameScript.GEARSTAT[i] -= ___holdingItem.tier * 3 + gearBaseStats2[i] * num2;
                             __instance.txtPlayerStat[i].GetComponent <Animation>().Play();
                         }
                     }
                     for (int j = 0; j < 3; j++)
                     {
                         ItemInfo slotAspect = ItemRegistry.GetSingleton().GetEntry(___inventory[slot].aspect[j]);
                         ItemInfo heldAspect = ItemRegistry.GetSingleton().GetEntry(___holdingItem.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];
                             }
                             if (heldAspect != null)
                             {
                                 GameScript.GEARSTAT[i] -= heldAspect.Stats.GetByIndex(i);
                             }
                             if (___holdingItem.aspect[j] - 200 == i + 1)
                             {
                                 GameScript.GEARSTAT[i] -= ___holdingItem.aspectLvl[j];
                             }
                         }
                     }
                 }
                 RefreshStats.Invoke(__instance, new object[] { });
                 RefreshMODS.Invoke(__instance, new object[] { });
                 __instance.UpdateHP();
                 __instance.UpdateEnergy();
                 __instance.UpdateMana();
                 Network.RemoveRPCs(MenuScript.playerAppearance.GetComponent <NetworkView>().viewID);
                 MenuScript.playerAppearance.GetComponent <NetworkView>().RPC("UA", RPCMode.AllBuffered, new object[]
                 {
                     GameScript.equippedIDs,
                     0,
                     GameScript.dead
                 });
                 if (slotInfo != null)
                 {
                     slotInfo.InvokeOnDequip(slot);
                 }
                 if (itemInfo != null)
                 {
                     itemInfo.InvokeOnEquip(slot);
                 }
             }
             else
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK1"), Menuu.soundLevel / 10f);
             }
         }
         return(false);
     }
     return(true);
 }
        public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, ref int ___droidCount)
        {
            ItemInfo itemInfo        = ItemRegistry.Singleton.GetEntry(___holdingItem.id);
            ItemInfo slotInfo        = ItemRegistry.Singleton.GetEntry(___inventory[slot].id);
            ItemType holdingItemType = itemInfo != null ? (itemInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___holdingItem.id);
            ItemType slotItemType    = slotInfo != null ? (slotInfo.Type & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___inventory[slot].id);

            if ((slot == 36 && (holdingItemType & ItemType.EQUIP_MASK) != (ItemType.WEAPON & ItemType.EQUIP_MASK)) || (slot == 37 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.OFFHAND & ItemType.EQUIP_MASK))) || (slot == 38 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.HELMET & ItemType.EQUIP_MASK))) || (slot == 39 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.ARMOR & ItemType.EQUIP_MASK))) || ((slot == 40 || slot == 41) && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.RING & ItemType.EQUIP_MASK))) || (slot > 41 && ((holdingItemType & ItemType.EQUIP_MASK) != (ItemType.DROID & ItemType.EQUIP_MASK))))
            {
                __instance.Error(2);
            }
            else
            {
                Item item = ___holdingItem;
                ___holdingItem     = ___inventory[slot];
                ___inventory[slot] = item;
                ItemType typeHolder = holdingItemType;
                holdingItemType = slotItemType;
                slotItemType    = typeHolder;
                RefreshSlot.Invoke(__instance, new object[] { slot });
                RefreshHoldingSlot.Invoke(__instance, new object[] { });
                if (slot > 41 && slot < 45 && slotItemType == ItemType.DROID)
                {
                    if (holdingItemType == ItemType.DROID)
                    {
                        MonoBehaviour.print("swapped droids");
                        UpdateDroids.Invoke(__instance, new object[] { });
                        __instance.droid[slot - 42].SendMessage("SetStats", ___inventory[slot].id);
                    }
                    else
                    {
                        ___droidCount++;
                        UpdateDroids.Invoke(__instance, new object[] { });
                        __instance.droid[slot - 42].SendMessage("SetStats", ___inventory[slot].id);
                    }
                }
                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);
                    }
                    Object.Instantiate(Resources.Load("clickBurst"), new Vector3(__instance.invIcon[slot].transform.position.x, __instance.invIcon[slot].transform.position.y, 0f), Quaternion.identity);
                    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();
                    int[] oldStats  = GadgetCoreAPI.equippedGearStats[slot - 36];
                    for (int s = 0; s < 6; s++)
                    {
                        if (oldStats[s] > 0)
                        {
                            GameScript.GEARSTAT[s] -= oldStats[s];
                            if (gearStats[s] > 0)
                            {
                                GameScript.GEARSTAT[s] += gearStats[s];
                            }
                            __instance.txtPlayerStat[s].GetComponent <Animation>().Play();
                        }
                        else if (gearStats[s] > 0)
                        {
                            GameScript.GEARSTAT[s] += gearStats[s];
                            __instance.txtPlayerStat[s].GetComponent <Animation>().Play();
                        }
                    }
                    GadgetCoreAPI.equippedGearStats[slot - 36] = gearStats;
                    RefreshStats.Invoke(__instance, new object[] { });
                    RefreshMODS.Invoke(__instance, new object[] { });
                    __instance.UpdateHP();
                    __instance.UpdateEnergy();
                    __instance.UpdateMana();
                    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
                    });
                    if (slotInfo != null)
                    {
                        slotInfo.InvokeOnDequip(slot);
                    }
                    if (itemInfo != null)
                    {
                        itemInfo.InvokeOnEquip(slot);
                    }
                }
                else
                {
                    __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK1"), Menuu.soundLevel / 10f);
                }
            }
            return(false);
        }
        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);
            }
            return(true);
        }
        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);
        }
Exemple #15
0
 public static bool Prefix(GameScript __instance, int slot, ref Item ___holdingItem, ref Item[] ___inventory, ref int ___droidCount)
 {
     if (ItemRegistry.GetSingleton().HasEntry(___inventory[slot].id))
     {
         ItemInfo itemInfo     = ItemRegistry.GetSingleton().GetEntry(___inventory[slot].id);
         ItemType slotItemType = itemInfo != null ? (itemInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(___inventory[slot].id);
         __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK1"), Menuu.soundLevel / 10f);
         ___holdingItem     = ___inventory[slot];
         ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
         RefreshSlot.Invoke(__instance, new object[] { slot });
         RefreshHoldingSlot.Invoke(__instance, new object[] { });
         if (slotItemType == ItemType.DROID && slot > 41 && slot < 45)
         {
             ___droidCount--;
             __instance.activated[slot - 42] = false;
             __instance.droid[slot - 42].SendMessage("Deactivate", SendMessageOptions.DontRequireReceiver);
             UpdateDroids.Invoke(__instance, new object[] { });
         }
         if (slot > 35)
         {
             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[] { ___holdingItem.id });
             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
             {
                 int num = (int)GetItemLevel.Invoke(__instance, new object[] { ___holdingItem.exp });
                 for (int i = 0; i < 6; i++)
                 {
                     if (gearBaseStats[i] > 0)
                     {
                         GameScript.GEARSTAT[i] -= ___holdingItem.tier * 3 + gearBaseStats[i] * num;
                         __instance.txtPlayerStat[i].GetComponent <Animation>().Play();
                     }
                 }
                 for (int j = 0; j < 3; j++)
                 {
                     ItemInfo heldAspect = ItemRegistry.GetSingleton().GetEntry(___holdingItem.aspect[j]);
                     for (int i = 0; i < 6; i++)
                     {
                         if (heldAspect != null)
                         {
                             GameScript.GEARSTAT[i] -= heldAspect.Stats.GetByIndex(i);
                         }
                         if (___holdingItem.aspect[j] - 200 == i + 1)
                         {
                             GameScript.GEARSTAT[i] -= ___holdingItem.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.InvokeOnDequip(slot);
             }
         }
         return(false);
     }
     return(true);
 }
Exemple #16
0
 public static bool Prefix(GameScript __instance, ref bool ___shiftclicking, Item[] ___inventory, ref Item[] ___storage, int slot, int ___curStoragePage, ref int ___droidCount, ref IEnumerator __result)
 {
     itemInSlot = ___inventory[slot];
     if (!___shiftclicking)
     {
         ItemInfo slotInfo     = ItemRegistry.GetSingleton().GetEntry(itemInSlot.id);
         ItemType slotItemType = slotInfo != null ? (slotInfo.Type & (ItemType.BASIC_MASK | ItemType.TYPE_MASK)) : ItemRegistry.GetDefaultTypeByID(itemInSlot.id);
         int      num          = 0;
         int      num2         = ___curStoragePage * 30;
         int      num3         = num2 + 30;
         if ((slotItemType & ItemType.NONSTACKING) == ItemType.STACKING)
         {
             bool flag1 = false, flag2 = false;
             for (int i = num2; i < num3; i++)
             {
                 if (___storage[i].id == itemInSlot.id && ___storage[i].q < 9999)
                 {
                     if (___storage[i].q + ___inventory[slot].q <= 9999)
                     {
                         flag1 = true;
                         num   = i;
                     }
                     else
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___inventory[slot].q -= 9999 - ___storage[i].q;
                         ___storage[i].q       = 9999;
                         flag2 = true;
                     }
                     break;
                 }
             }
             if (flag1)
             {
                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                 ___storage[num].q += ___inventory[slot].q;
                 ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
             }
             else
             {
                 for (int i = num2; i < num3; i++)
                 {
                     if (___storage[i].id == 0)
                     {
                         if (!flag2)
                         {
                             __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                         }
                         ___storage[i]      = ___inventory[slot];
                         ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                         break;
                     }
                     else if (___storage[i].id == itemInSlot.id && ___storage[i].q < 9999)
                     {
                         if (___storage[i].q + ___inventory[slot].q <= 9999)
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___storage[i].q   += ___inventory[slot].q;
                             ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                             break;
                         }
                         else
                         {
                             if (!flag2)
                             {
                                 __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                             }
                             ___inventory[slot].q -= 9999 - ___storage[i].q;
                             ___storage[i].q       = 9999;
                         }
                         flag2 = true;
                     }
                 }
             }
             typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
             __instance.StartCoroutine((IEnumerator)typeof(GameScript).GetMethod("RefreshStoragePage", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ___curStoragePage }));
         }
         else
         {
             for (int i = num2; i < num3; i++)
             {
                 if (___storage[i].id == 0)
                 {
                     if (slot > 35)
                     {
                         if (slot == 36)
                         {
                             GameScript.equippedIDs[0] = 0;
                         }
                         else if (slot == 37)
                         {
                             GameScript.equippedIDs[1] = 0;
                         }
                         else if (slot == 38)
                         {
                             GameScript.equippedIDs[2] = 0;
                         }
                         else if (slot == 39)
                         {
                             GameScript.equippedIDs[3] = 0;
                         }
                         else if (slot == 40)
                         {
                             GameScript.equippedIDs[4] = 0;
                         }
                         else if (slot == 41)
                         {
                             GameScript.equippedIDs[5] = 0;
                         }
                         int[] gearBaseStats = (int[])typeof(GameScript).GetMethod("GetGearBaseStats", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ___inventory[slot].id });
                         int   num4          = (int)typeof(GameScript).GetMethod("GetItemLevel", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ___inventory[slot].exp });
                         for (int j = 0; j < 6; j++)
                         {
                             if (gearBaseStats[j] > 0)
                             {
                                 GameScript.GEARSTAT[j] -= ___inventory[slot].tier * 3 + gearBaseStats[j] * num4;
                                 __instance.txtPlayerStat[j].GetComponent <Animation>().Play();
                             }
                         }
                         typeof(GameScript).GetMethod("RefreshStats", BindingFlags.NonPublic | BindingFlags.Instance).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
                         });
                         __instance.UpdateHP();
                         __instance.UpdateEnergy();
                         __instance.UpdateMana();
                     }
                     __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/CLICK3"), Menuu.soundLevel / 10f);
                     ___storage[i]      = ___inventory[slot];
                     ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]);
                     typeof(GameScript).GetMethod("RefreshSlot", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { slot });
                     __instance.StartCoroutine((IEnumerator)typeof(GameScript).GetMethod("RefreshStoragePage", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ___curStoragePage }));
                     if (slotItemType == ItemType.DROID && slot > 41)
                     {
                         ___droidCount--;
                         typeof(GameScript).GetMethod("UpdateDroids", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { });
                     }
                     if (slotInfo != null)
                     {
                         slotInfo.InvokeOnDequip(slot);
                     }
                     break;
                 }
             }
         }
         ___shiftclicking = false;
         __result         = FakeRoutine();
         return(false);
     }
     return(true);
 }