private static void BreakIntoResources_Patch(BreakableResource __instance) { __instance.SendMessage("OnBreakResource", null, SendMessageOptions.DontRequireReceiver); if (__instance.gameObject.GetComponent <VFXBurstModel>()) { __instance.gameObject.BroadcastMessage("OnKill"); } else { UnityEngine.Object.Destroy(__instance.gameObject); } if (__instance.customGoalText != "") { GoalManager.main.OnCustomGoalEvent(__instance.customGoalText); } bool flag = false; for (int i = 0; i < __instance.numChances; i++) { GameObject gameObject = __instance.ChooseRandomResource(); if (gameObject) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "1 - Random Resouce is called"); if (Player.main.GetVehicle() is Exosuit exosuit) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "2 - Start AddToPrawn over randomress"); AddtoPrawn(__instance, exosuit, gameObject); } else { if ((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands.MetalHandsMK2TechType) | (MetalHands.Config.Config_fastcollect == true)) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "3 - Player has glove - randomress"); Vector2int size = CraftData.GetItemSize(CraftData.GetTechType(gameObject)); Inventory inventory = Inventory.Get(); if (inventory.HasRoomFor(size.x, size.y)) { CraftData.AddToInventory(CraftData.GetTechType(gameObject)); } else { __instance.SpawnResourceFromPrefab(gameObject); } } else { __instance.SpawnResourceFromPrefab(gameObject); } } flag = true; } } if (!flag) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "5 - default resouce is called"); if (Player.main.GetVehicle() is Exosuit exosuit) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "6 - Start AddToPrawn over defaultress"); AddtoPrawn(__instance, exosuit, __instance.defaultPrefab); } else if ((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands.MetalHandsMK2TechType) | (MetalHands.Config.Config_fastcollect == true)) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "7 - Player has glove - defaultress"); Vector2int size = CraftData.GetItemSize(CraftData.GetTechType(__instance.defaultPrefab)); Inventory inventory = Inventory.Get(); if (inventory.HasRoomFor(size.x, size.y)) { CraftData.AddToInventory(CraftData.GetTechType(__instance.defaultPrefab)); } else { __instance.SpawnResourceFromPrefab(__instance.defaultPrefab); } } else { __instance.SpawnResourceFromPrefab(__instance.defaultPrefab); } } FMODUWE.PlayOneShot(__instance.breakSound, __instance.transform.position, 1f); if (__instance.hitFX) { Utils.PlayOneShotPS(__instance.breakFX, __instance.transform.position, Quaternion.Euler(new Vector3(270f, 0f, 0f)), null); } QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "9 - Original Methode ending"); }
private static void BreakIntoResources_Patch(BreakableResource __instance) { __instance.SendMessage("OnBreakResource", null, SendMessageOptions.DontRequireReceiver); if (__instance.gameObject.GetComponent <VFXBurstModel>()) { __instance.gameObject.BroadcastMessage("OnKill"); } else { UnityEngine.Object.Destroy(__instance.gameObject); } if (__instance.customGoalText != "") { GoalManager.main.OnCustomGoalEvent(__instance.customGoalText); } bool flag = false; for (int i = 0; i < __instance.numChances; i++) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-01 - start choose random ress"); AssetReferenceGameObject assetReferenceGameObject = __instance.ChooseRandomResource(); if (assetReferenceGameObject != null) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-02 - Random Resouce is called"); if (Player.main.GetVehicle() is Exosuit exosuit) { var installedmodule = exosuit.modules.GetCount(MetalHands_BZ.MetalHandsClawModuleTechType); if (((installedmodule > 0) | (MetalHands_BZ.Config.Config_fastcollect == true)) & exosuit.storageContainer.container.HasRoomFor(1, 1)) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-10 - Start AddToPrawn over randomress"); CoroutineHost.StartCoroutine(AddtoPrawn(__instance, exosuit, assetReferenceGameObject)); } else { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-11 - Spawn original way randomress"); __instance.SpawnResourceFromPrefab(assetReferenceGameObject); } } else { Inventory inventory = Inventory.Get(); if (((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands_BZ.MetalHandsMK2TechType) | (MetalHands_BZ.Config.Config_fastcollect == true)) & inventory.HasRoomFor(1, 1)) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-20 - Player has glove - randomress"); CoroutineHost.StartCoroutine(AddbrokenRestoPlayerInv(__instance, assetReferenceGameObject)); } else { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-04 - Spawn original way - defaultress"); __instance.SpawnResourceFromPrefab(assetReferenceGameObject); } } flag = true; } } if (!flag) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-01 - default resouce is called"); if (Player.main.GetVehicle() is Exosuit exosuit) { var installedmodule = exosuit.modules.GetCount(MetalHands_BZ.MetalHandsClawModuleTechType); if (((installedmodule > 0) | (MetalHands_BZ.Config.Config_fastcollect == true)) && exosuit.storageContainer.container.HasRoomFor(1, 1)) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-02 - Start AddToPrawn over defaultress"); CoroutineHost.StartCoroutine(AddtoPrawn(__instance, exosuit, __instance.defaultPrefabReference)); } else { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "01-11 - Spawn original way randomress"); __instance.SpawnResourceFromPrefab(__instance.defaultPrefabReference); } } else { Inventory inventory = Inventory.Get(); if (((Inventory.main.equipment.GetTechTypeInSlot("Gloves") == MetalHands_BZ.MetalHandsMK2TechType) | (MetalHands_BZ.Config.Config_fastcollect == true)) & inventory.HasRoomFor(1, 1)) { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-03 - Player has glove - defaultress"); CoroutineHost.StartCoroutine(AddbrokenRestoPlayerInv(__instance, __instance.defaultPrefabReference)); } else { QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "03-04 - Spawn original way - defaultress"); __instance.SpawnResourceFromPrefab(__instance.defaultPrefabReference); } } } FMODUWE.PlayOneShot(__instance.breakSound, __instance.transform.position, 1f); if (__instance.hitFX) { global::Utils.PlayOneShotPS(__instance.breakFX, __instance.transform.position, Quaternion.Euler(new Vector3(270f, 0f, 0f)), null); } }