| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using HarmonyLib;
- using GadgetCore.API;
- using UnityEngine;
- using System.Collections;
- using System.Reflection;
- using System.Collections.Generic;
- namespace RecipeMenuCore.Patches
- {
- [HarmonyPatch(typeof(GameScript))]
- [HarmonyPatch("HoverRecipeSelect")]
- [HarmonyGadget("RecipeMenuCore")]
- public static class Patch_GameScript_HoverRecipeSelect
- {
- [HarmonyPrefix]
- public static bool Prefix(GameScript __instance, int id, int ___craftType, ref int ___curRecipePage, GameObject ___itemexpbar, Item[] ___storage, GameObject[] ___aspectObj, TextMesh ___itemName,
- GameObject ___hoverItem, TextMesh[] ___itemStat, GameObject ___txtStats, TextMesh ___itemDesc, Material ___hoverItemMat2, Material ___hoverItemMat1, GameObject ___hoverDroid,
- TextMesh[] ___txtHoverStat, TextMesh ___txtHoverStatInfo, TextMesh[] ___itemAspect, TextMesh ___itemLevel)
- {
- var item = new Item(GetItemId(id, ___craftType, ___curRecipePage), 1, 0, 0, 0, new int[3], new int[3]);
- var itemInfo = ItemRegistry.GetItem(item.id);
- ___txtHoverStat[0].text = string.Empty;
- ___txtHoverStat[1].text = ___txtHoverStat[0].text;
- ___txtHoverStatInfo.text = string.Empty;
- ___aspectObj[0].SetActive(false);
- ___aspectObj[1].SetActive(false);
- ___aspectObj[2].SetActive(false);
- ___itemAspect[0].text = string.Empty;
- ___itemAspect[1].text = string.Empty;
- ___itemAspect[2].text = string.Empty;
- ___itemLevel.text = string.Empty;
- if (Camera.main.ScreenToWorldPoint(Input.mousePosition).y < MenuScript.player.transform.position.y - 4.5f)
- ___hoverItem.transform.localPosition = new Vector3(5f, 0f, -4.55f);
- else
- ___hoverItem.transform.localPosition = new Vector3(5f, -4f, -4.55f);
- ___hoverDroid.SetActive(false);
- ___itemexpbar.SetActive(false);
- if (item.id > 0)
- {
- ___itemName.text = itemInfo.Name;
- ___itemName.color = Color.white;
- ___itemDesc.text = itemInfo.Desc;
- bool hasStats = false;
- int[] gearBaseStats = ItemRegistry.GetItem(item.id).Stats.GetStatArray();
- for (int i = 0; i < 6; i++)
- {
- if (gearBaseStats[i] > 0)
- {
- ___itemStat[i].text = "+" + gearBaseStats[i];
- hasStats = true;
- }
- else
- ___itemStat[i].text = string.Empty;
- }
- ___txtStats.SetActive(hasStats);
- ___hoverItem.SetActive(true);
- if (hasStats)
- ___hoverItem.GetComponent<Renderer>().material = hoverItem;
- else
- ___hoverItem.GetComponent<Renderer>().material = ___hoverItemMat1;
- }
- else
- {
- ___hoverItem.SetActive(false);
- }
- return false;
- }
- private static Material hoverItem = new Material(Shader.Find("Unlit/Transparent"))
- {
- mainTexture = GadgetCoreAPI.LoadTexture2D("hoverItem.png")
- };
- private static int GetItemId(int index, int craftType, int curRecipePage)
- {
- if (craftType == 0 && curRecipePage >= 6)
- {
- return Core.pageGearForgeInfoList[curRecipePage - 6].GetRecipePageEntries()[index].ItemIdBase;
- }
- else if (craftType == 1 && curRecipePage >= 2)
- {
- return Core.pageAlchemyStationInfoList[curRecipePage - 2].GetRecipePageEntries()[index].ItemIdBase;
- }
- else if (craftType == 2 && curRecipePage >= 6)
- {
- return Core.pageUltimateForgeInfoList[curRecipePage - 6].GetRecipePageEntries()[index].ItemIdBase;
- }
- return 1;
- }
- }
- }
|