public static bool Prefix(GameScript __instance, int slot, Item[] ___craft, Item ___holdingItem) { Item item = ___craft[slot]; if (!GadgetCoreAPI.CanItemsStack(item, ___holdingItem)) { SwapItemCraft.Invoke(__instance, new object[] { slot }); return(false); } if (ItemRegistry.Singleton.HasEntry(item.id)) { ItemInfo info = ItemRegistry.Singleton.GetEntry(item.id); if ((info.Type & ItemType.NONSTACKING) == ItemType.NONSTACKING) { SwapItemCraft.Invoke(__instance, new object[] { slot }); return(false); } } return(true); }
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); }
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); }
public static void Postfix(GameScript __instance, ref RaycastHit ___hit, ref int ___craftType, ref int ___slotID, ref bool ___shifting, ref Item[] ___inventory, ref Item[] ___craft, ref Item[] ___modSlot, ref int ___curBlockSlot, ref ChunkWorld ___chunkWorld, ref ChunkWorld ___chunkWorldWall, ref Item __state) { if (!GameScript.pausing && !GameScript.inventoryOpen && GameScript.buildMode && Input.GetMouseButtonDown(0) && ___inventory[___curBlockSlot].q > 0 && ItemRegistry.Singleton.HasEntry(___inventory[___curBlockSlot].id)) { int num4 = (int)__instance.hoverBuild.transform.position.x; int num5 = (int)__instance.hoverBuild.transform.position.y; int num6 = (num4 + 62) / 4; int num7 = (num5 + 62) / 4; if (num6 < 64 && num6 >= 0 && num7 < 64 && num7 >= 0) { ItemInfo item = ItemRegistry.Singleton.GetEntry(___inventory[___curBlockSlot].id); if (item.Tile != null && item.Tile.TryPlaceTile()) { if (item.Tile.Type == TileType.WALL) { if (___chunkWorldWall.grid[num6, num7] == 0) { int[] value = new int[] { num4, num5, GameScript.curBlockID }; __instance.WallManager.SendMessage("PlaceTile", value); __instance.hoverBuild.SendMessage("Refresh"); __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/emblem"), Menuu.soundLevel / 10f); ___inventory[___curBlockSlot].q--; RefreshSlot.Invoke(__instance, new object[] { ___curBlockSlot }); if (___inventory[___curBlockSlot].q <= 0 && GameScript.buildMode) { __instance.ExitBuildMode(); __instance.hoverSprite.GetComponent <Renderer>().material = (Material)Resources.Load("mat/trans"); GameScript.curBlockID = 0; } } } else if (item.Tile.Type == TileType.SOLID) { if (___chunkWorld.gridSpecial[num6, num7] == 0 && ___chunkWorld.grid[num6, num7] == 0) { int[] value3 = new int[] { num4, num5, GameScript.curBlockID }; __instance.TileManager.SendMessage("PlaceTile", value3); __instance.hoverBuild.SendMessage("Refresh"); __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/emblem"), Menuu.soundLevel / 10f); ___inventory[___curBlockSlot].q--; RefreshSlot.Invoke(__instance, new object[] { ___curBlockSlot }); if (___inventory[___curBlockSlot].q <= 0 && GameScript.buildMode) { __instance.ExitBuildMode(); __instance.hoverSprite.GetComponent <Renderer>().material = (Material)Resources.Load("mat/trans"); GameScript.curBlockID = 0; } } } else { if (___chunkWorld.gridSpecial[num6, num7] == 0 && ___chunkWorld.grid[num6, num7] == 0) { if (GameScript.curBlockID == 2107 && __instance.gatherer) { __instance.Error(11); } else { int[] value2 = new int[] { num4, num5, GameScript.curBlockID }; __instance.TileManager.SendMessage("PlaceTileSpecial", value2); __instance.hoverBuild.SendMessage("Refresh"); __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/emblem"), Menuu.soundLevel / 10f); ___inventory[___curBlockSlot].q--; RefreshSlot.Invoke(__instance, new object[] { ___curBlockSlot }); if (___inventory[___curBlockSlot].q <= 0 && GameScript.buildMode) { __instance.ExitBuildMode(); __instance.hoverSprite.GetComponent <Renderer>().material = (Material)Resources.Load("mat/trans"); GameScript.curBlockID = 0; } } } } } } } else if (MenuScript.player && !GameScript.pausing) { if (Input.GetMouseButtonDown(0) && GameScript.inventoryOpen && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out ___hit, 7f)) { if (___hit.transform.gameObject.layer == 16) { if (___hit.transform.gameObject.tag == "craft") { if (MenuRegistry.Singleton[___craftType] is CraftMenuInfo craftMenu) { ___slotID = int.Parse(___hit.transform.gameObject.name); if (__state.id != 0) { Item holdingItem = __state; Item[] craftItems = ___craft; int slotID = ___slotID; if (craftMenu.SlotValidators.Any(x => x(holdingItem, craftItems, slotID))) { if (___craft[___slotID].id == __state.id) { __instance.InvokeMethod("CombineItemCraft", ___slotID); } else if (___craft[___slotID].id == 0) { __instance.InvokeMethod("PlaceItemCraft", ___slotID); } } } else if (___craft[___slotID].id != 0) { if (!___shifting) { __instance.InvokeMethod("SelectItemCraft", ___slotID); } else if (___shifting && __instance.menuCraft.activeSelf) { __instance.StartCoroutine(__instance.InvokeMethod <IEnumerator>("ShiftClickCraft", ___slotID)); } } } else if (___craftType == 0) { ___slotID = int.Parse(___hit.transform.gameObject.name); if (__state.id != 0 && ___craft[___slotID].id != __state.id) { if ((__state.id <= 100 || __state.id >= 200) && __instance.InvokeMethod <bool>("CanPlaceCraft", __state.id)) { ItemType?itemType = ItemRegistry.GetItem(__state.id)?.Type; if (itemType.HasValue && (itemType.Value & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.EMBLEM) { if (___craft[___slotID].id == 0) { __instance.InvokeMethod("PlaceItemCraft", ___slotID); } else { __instance.InvokeMethod("SwapItemCraft", ___slotID); } } } } } else if (___craftType == 1) { ___slotID = int.Parse(___hit.transform.gameObject.name); if (__state.id != 0 && ___craft[___slotID].id != __state.id) { if ((__state.id <= 10 || __state.id >= 40) && __instance.InvokeMethod <bool>("CanPlaceCraft", __state.id)) { ItemType?itemType = ItemRegistry.GetItem(__state.id)?.Type; if (itemType.HasValue && (itemType.Value & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.LOOT && (itemType.Value & ItemType.ORGANIC) == ItemType.ORGANIC) { if (___craft[___slotID].id == 0) { __instance.InvokeMethod("PlaceItemCraft", ___slotID); } else { __instance.InvokeMethod("SwapItemCraft", ___slotID); } } } } } else if (___craftType == 2) { ___slotID = int.Parse(___hit.transform.gameObject.name); if (__state.id != 0) { if (___slotID == 0 && ___craft[___slotID].id != __state.id) { if (___craft[0].id == 0 && (__state.id < 1000 || __state.id >= 1006) && (__state.id < 450 || __state.id >= 456) && (__state.id < 500 || __state.id >= 506) && (__state.id < 600 || __state.id >= 612) && (__state.id < 550 || __state.id >= 562) && (__state.id < 350 || __state.id >= 362) && (__state.id < 400 || __state.id >= 412) && (__state.id < 300 || __state.id >= 312) && (__state.id < 700 || __state.id >= 712) && (__state.id < 800 || __state.id >= 812)) { Item holdingItem = __state; if (GadgetCoreAPI.ultimateForgeRecipes.Any(x => x.Key.Item1 == holdingItem.id)) { if (__instance.InvokeMethod <int>("GetItemLevel", holdingItem.exp) >= 10) { __instance.InvokeMethod("PlaceItemCraft", ___slotID); } else { __instance.InvokeMethod("Error", 12); } } } } else if (___slotID == 2) { if (___craft[2].id == 0 && (__state.id < 89 || __state.id >= 92)) { Item holdingItem = __state; if (GadgetCoreAPI.ultimateForgeRecipes.Any(x => x.Key.Item2 == holdingItem.id)) { __instance.InvokeMethod("PlaceItemCraft", ___slotID); } } } } } else if (___craftType == 3) { ___slotID = int.Parse(___hit.transform.gameObject.name); if (__state.id != 0 && ___craft[___slotID].id != __state.id) { if ((__state.id <= 103 || __state.id >= 107) && (__state.id <= 113 || __state.id >= 117) && (__state.id <= 123 || __state.id >= 127) && (__state.id <= 133 || __state.id >= 137) && __instance.InvokeMethod <bool>("CanPlaceCraft2", __state.id)) { Item holdingItem = __state; if (GadgetCoreAPI.creationMachineRecipes.Any(x => x.Key == holdingItem.id)) { if (___craft[___slotID].id == 0) { __instance.InvokeMethod("PlaceItemCraft", ___slotID); } else { __instance.InvokeMethod("SwapItemCraft", ___slotID); } } } } } } else if (___hit.transform.gameObject.tag == "planet") { ___slotID = int.Parse(___hit.transform.gameObject.name); if (___slotID >= 14) { while (___slotID >= 14) { ___slotID -= 14; PlanetRegistry.PlanetSelectorPage++; } PlanetRegistry.UpdatePlanetSelector(); } int planetIndex = (PlanetRegistry.PlanetSelectorPage - 2) * 14 + ___slotID; if (planetIndex >= 0 && planetIndex < PlanetRegistry.selectorPlanets.Length && PlanetRegistry.selectorPlanets[planetIndex] is PlanetInfo planet) { if (planet.PortalUses > 0 || planet.PortalUses == -1) { InstanceTracker.GameScript.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f); InstanceTracker.GameScript.planetSelector.transform.position = new Vector3(InstanceTracker.GameScript.planetGuard[___slotID].transform.position.x, InstanceTracker.GameScript.planetGuard[___slotID].transform.position.y, InstanceTracker.GameScript.planetSelector.transform.position.z); GameScript.curPlanet = ___slotID; InstanceTracker.GameScript.planetObj.GetComponent <Renderer>().material = (Material)Resources.Load("mat/planet" + planet.ID); InstanceTracker.GameScript.planetObj.GetComponent <Animation>().Play(); InstanceTracker.GameScript.txtPlanetName[0].text = planet.Name; InstanceTracker.GameScript.txtPlanetName[1].text = InstanceTracker.GameScript.txtPlanetName[0].text; InstanceTracker.GameScript.txtHostile[0].text = "Hostile Lv." + InstanceTracker.GameScript.InvokeMethod("GetPlanetHostile", planet.ID); InstanceTracker.GameScript.txtHostile[1].text = InstanceTracker.GameScript.txtHostile[0].text; if (planet.PortalUses > 0) { InstanceTracker.GameScript.txtPortalUses[0].text = "Portal Uses: " + planet.PortalUses; InstanceTracker.GameScript.txtPortalUses[1].text = InstanceTracker.GameScript.txtPortalUses[0].text; } else if (planet.PortalUses == -1) { InstanceTracker.GameScript.txtPortalUses[0].text = "Portal Uses: Infinite"; InstanceTracker.GameScript.txtPortalUses[1].text = InstanceTracker.GameScript.txtPortalUses[0].text; } } } } else if (___hit.transform.gameObject.tag == "mod") { ___slotID = int.Parse(___hit.transform.gameObject.name); Item holdingItem = __state; if (holdingItem.id != 0) { if ((holdingItem.id < 300 || holdingItem.id >= 1000) && (ItemRegistry.GetItem(holdingItem.id).Type & ItemType.MODABLE) == ItemType.MODABLE) { if (___modSlot[___slotID].id == 0) { __instance.PlaceItemMod(___slotID); } else { __instance.SwapItemMod(___slotID); } } } else if ((___modSlot[___slotID].id < 300 || ___modSlot[___slotID].id >= 1000) && (ItemRegistry.GetItem(___modSlot[___slotID].id).Type & ItemType.MODABLE) == ItemType.MODABLE) { __instance.SelectItemMod(___slotID); } } } else if (___hit.transform.gameObject.layer != 17) { switch (___hit.transform.gameObject.name) { case "bPlanetPageBack": __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f); if (PlanetRegistry.PlanetSelectorPage <= 1) { PlanetRegistry.PlanetSelectorPage = PlanetRegistry.PlanetSelectorPages; } else { PlanetRegistry.PlanetSelectorPage--; } PlanetRegistry.UpdatePlanetSelector(); break; case "bPlanetPageForward": __instance.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/confirm"), Menuu.soundLevel / 10f); if (PlanetRegistry.PlanetSelectorPage >= PlanetRegistry.PlanetSelectorPages) { PlanetRegistry.PlanetSelectorPage = 1; } else { PlanetRegistry.PlanetSelectorPage++; } PlanetRegistry.UpdatePlanetSelector(); break; } } } else if (Input.GetMouseButtonDown(1) && GameScript.inventoryOpen && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out ___hit, 7f)) { if (___hit.transform.gameObject.layer == 16) { if (___hit.transform.gameObject.tag == "craft") { if (MenuRegistry.Singleton.GetEntry(___craftType) is CraftMenuInfo craftMenu) { ___slotID = int.Parse(___hit.transform.gameObject.name); if (__state.id != 0) { Item holdingItem = __state; Item[] craftItems = ___craft; int slotID = ___slotID; if (craftMenu.SlotValidators.Any(x => x(holdingItem, craftItems, slotID))) { if (___craft[___slotID].id == 0 || (GadgetCoreAPI.CanItemsStack(___craft[___slotID], __state) && ___craft[___slotID].q < 9999)) { __instance.InvokeMethod("PlaceOneItemCraft", ___slotID); } else { __instance.InvokeMethod("SwapItemCraft", ___slotID); } } } } } else if (___hit.transform.gameObject.tag == "mod") { ___slotID = int.Parse(___hit.transform.gameObject.name); Item holdingItem = __state; if (holdingItem.id != 0) { if ((holdingItem.id < 300 || holdingItem.id >= 1000) && (ItemRegistry.GetItem(holdingItem.id).Type & ItemType.MODABLE) == ItemType.MODABLE) { if (___modSlot[___slotID].id == 0) { __instance.PlaceItemMod(___slotID); } else { __instance.SwapItemMod(___slotID); } } } else if ((___modSlot[___slotID].id < 300 || ___modSlot[___slotID].id >= 1000) && (ItemRegistry.GetItem(holdingItem.id).Type & ItemType.MODABLE) == ItemType.MODABLE) { __instance.SelectItemMod(___slotID); } } } } } }
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.GetItem(itemInSlot.id); ItemType slotItemTypeUnfiltered = slotInfo.Type; ItemType slotItemType = slotItemTypeUnfiltered & (ItemType.EQUIP_MASK | ItemType.TYPE_MASK); bool flag = false; int num = 0; if ((___craftType == 0 && (slotItemType & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.EMBLEM) || (___craftType == 1 && (slotItemType & (ItemType.EMBLEM | ItemType.EQUIPABLE)) == ItemType.LOOT && (slotItemTypeUnfiltered & ItemType.ORGANIC) == ItemType.ORGANIC)) { for (int i = 0; i < 3; i++) { if (GadgetCoreAPI.CanItemsStack(___craft[i], itemInSlot) && ___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]); __instance.RefreshSlot(slot); __instance.RefreshSlotCraft(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]); __instance.RefreshSlot(slot); __instance.RefreshSlotCraft(i); break; } } } } else if (MenuRegistry.Singleton.GetEntry(___craftType) is CraftMenuInfo craftMenu) { Item[] craftItems = ___craft; HashSet <int> acceptableSlots = new HashSet <int>(Enumerable.Range(0, ___craft.Length).Where(x => craftMenu.SlotValidators.Any(v => v(___inventory[slot], craftItems, x)))); foreach (int i in acceptableSlots) { if (GadgetCoreAPI.CanItemsStack(___craft[i], itemInSlot) && ___craft[i].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; if (___craft[num].q > 9999) { ___inventory[slot].q = ___craft[num].q - 9999; ___craft[num].q = 9999; } else { ___inventory[slot] = new Item(0, 0, 0, 0, 0, new int[3], new int[3]); } __instance.RefreshSlot(slot); __instance.RefreshSlotCraft(num); } else { foreach (int i in acceptableSlots) { 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]); __instance.RefreshSlot(slot); __instance.RefreshSlotCraft(i); break; } } } } ___shiftclicking = false; __instance.InvokeMethod("CraftCheck"); __result = FakeRoutine(); return(false); } return(true); }
private static IEnumerator AddItem(GameScript script, Package package) { bool flag = false; bool flag2 = false; bool localItem = package.localItem; Item[] inventory = Patch_GameScript_AddItem.inventory.GetValue(script) as Item[]; if (package.item.q == 0) { package.item.q = 1; } ItemType type = ItemRegistry.GetTypeByID(package.item.id); if ((type & ItemType.NONSTACKING) == ItemType.STACKING) { for (int i = 0; i < 36; i++) { if (GadgetCoreAPI.CanItemsStack(inventory[i], package.item) && inventory[i].q < 9999) { inventory[i].q += package.item.q; if (inventory[i].q > 9999) { Item item = new Item(package.item.id, inventory[i].q - 9999, 0, 0, 0, new int[3], new int[3]); item.SetAllExtraData(package.item.GetAllExtraData()); inventory[i].q = 9999; Package package2 = new Package(item, package.obj, localItem); script.AddItem(package2); } RefreshSlot.Invoke(script, new object[] { i }); flag2 = true; flag = true; break; } } } if (!flag) { for (int i = (type & ItemType.EQUIP_MASK) == ItemType.DROID ? 6 : 0; i < 36; i++) { if (inventory[i].id == 0) { inventory[i] = package.item; RefreshSlot.Invoke(script, new object[] { i }); flag2 = true; break; } } } if (flag2) { script.GetComponent <AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/pickup"), Menuu.soundLevel / 10f); Vector3 position = MenuScript.player.transform.position; GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("txtGet"), new Vector3(position.x, position.y + 1f, -3.2f), Quaternion.identity); Package1 value = new Package1(GetItemName.Invoke(script, new object[] { package.item.id }) as string, package.item.q); gameObject.SendMessage("Init", value); } if (localItem) { package.obj.SendMessage("FinalReply", flag2); } else if (Network.isServer) { package.obj.SendMessage("FinalReply", flag2); } else { package.obj.GetComponent <NetworkView>().RPC("FinalReply", RPCMode.Server, new object[] { flag2 }); } return(null); }