|
|
@@ -0,0 +1,53 @@
|
|
|
+using GadgetCore.API;
|
|
|
+using HarmonyLib;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+namespace Ships.Patches
|
|
|
+{
|
|
|
+
|
|
|
+ [HarmonyPatch(typeof(GameScript))]
|
|
|
+ [HarmonyPatch("AddMod")]
|
|
|
+ [HarmonyGadget("Ships")]
|
|
|
+ public static class Patch_GameScript_AddMod
|
|
|
+ {
|
|
|
+
|
|
|
+ [HarmonyPrefix]
|
|
|
+ public static bool Prefix(GameScript __instance, int a, Item ___holdingItem, GameObject[] ___modObj, Item[] ___modSlot)
|
|
|
+ {
|
|
|
+ ItemInfo itemInfo = ItemRegistry.GetItem(___holdingItem.id);
|
|
|
+ if ((___holdingItem.id > 200 && ___holdingItem.id < 230) || (itemInfo != null && ((itemInfo.Type & ItemType.MOD) == (ItemType.MOD))))
|
|
|
+ {
|
|
|
+ if (___modSlot[0].id != 0)
|
|
|
+ {
|
|
|
+ if (___modSlot[0].aspectLvl[a] < 5)
|
|
|
+ {
|
|
|
+ if (___modSlot[0].aspect[a] == ___holdingItem.id || ___modSlot[0].aspect[a] == 0)
|
|
|
+ {
|
|
|
+ if (__instance.CanAddMod(a))
|
|
|
+ {
|
|
|
+ ___modSlot[0].aspectLvl[a]++;
|
|
|
+ ___modObj[a].GetComponent<Animation>().Play();
|
|
|
+ __instance.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/addmod"), Menuu.soundLevel / 10f);
|
|
|
+ ___modSlot[0].aspect[a] = ___holdingItem.id;
|
|
|
+ ___holdingItem.q--;
|
|
|
+ __instance.RefreshHoldingSlot();
|
|
|
+ __instance.RefreshGearMods();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (___modSlot[0].aspectLvl[a] == 0 && __instance.CanAddMod(a))
|
|
|
+ {
|
|
|
+ ___modSlot[0].aspectLvl[a]++;
|
|
|
+ ___modObj[a].GetComponent<Animation>().Play();
|
|
|
+ __instance.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/addmod"), Menuu.soundLevel / 10f);
|
|
|
+ ___modSlot[0].aspect[a] = ___holdingItem.id;
|
|
|
+ ___holdingItem.q--;
|
|
|
+ __instance.RefreshHoldingSlot();
|
|
|
+ __instance.RefreshGearMods();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|