Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CreatureCarry v1.3.0
CreatureCarry.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace CreatureCarry; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.claude.creaturecarry", "CreatureCarry", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CreatureCarryPlugin : BaseUnityPlugin { private static CreatureCarryPlugin _instance; private Harmony _harmony; public static ConfigEntry<string> PickupHotkey; public static ConfigEntry<float> PickupRange; public static ConfigEntry<float> CarrySpeedPenalty; public static ConfigEntry<bool> ShowCarryMessage; public static ConfigEntry<bool> RemoveEggFireRequirement; public static ConfigEntry<bool> ProtectTamedFromEnemies; public static ConfigEntry<string> NeckroGathererBlacklist; public static ConfigEntry<int> TrophiesRequired; public static ConfigEntry<float> ConversionDuration; private static ZDOID _carriedID; private static string _carriedPrefabName; private static string _carriedCreatureName; private static bool _isCarrying; private static List<Collider> _disabledColliders = new List<Collider>(); private static GameObject _dropIndicator; private static LineRenderer _dropCircle; private static HashSet<string> _blacklistCache = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static string _lastBlacklistValue = null; private void Awake() { _instance = this; PickupHotkey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PickupHotkey", "left alt + e", "Hotkey to pick up or release a tamed creature."); PickupRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PickupRange", 5f, "Maximum distance to pick up a creature."); CarrySpeedPenalty = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CarrySpeedPenalty", 0.8f, "Movement speed multiplier while carrying (1.0 = normal, 0.5 = half speed)."); ShowCarryMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowCarryMessage", true, "Show HUD messages when picking up and releasing creatures."); RemoveEggFireRequirement = ((BaseUnityPlugin)this).Config.Bind<bool>("Eggs", "RemoveEggFireRequirement", true, "Remove the requirement for eggs to be near a fire to hatch."); ProtectTamedFromEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Tamed", "ProtectTamedFromEnemies", true, "Enemies will not target tamed creatures."); NeckroGathererBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("NeckroGatherer", "ItemBlacklist", "", "Comma-separated list of item prefab names the NeckroGatherer should ignore. Example: Wood,Stone,Flint"); TrophiesRequired = ((BaseUnityPlugin)this).Config.Bind<int>("OdinMounts", "TrophiesRequired", 15, "Number of trophies required per Life Essence conversion (vanilla default: 30)."); ConversionDuration = ((BaseUnityPlugin)this).Config.Bind<float>("OdinMounts", "ConversionDurationSeconds", 150f, "Time in seconds for the Life Essence Collector to process trophies (vanilla default: 300)."); _harmony = Harmony.CreateAndPatchAll(typeof(CreatureCarryPatches), "com.claude.creaturecarry"); PatchNeckroGatherer(); PatchTrophyConverter(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CreatureCarry v1.3.0 loaded."); } public static HashSet<string> GetBlacklist() { string value = NeckroGathererBlacklist.Value; if (value != _lastBlacklistValue) { _lastBlacklistValue = value; _blacklistCache.Clear(); if (!string.IsNullOrEmpty(value)) { string[] array = value.Split(new char[1] { ',' }); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length > 0) { _blacklistCache.Add(text2); } } } } return _blacklistCache; } private void PatchNeckroGatherer() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name == "ChebsNecromancy") { type = assembly.GetType("ChebsNecromancy.Minions.NeckroGathererMinion"); break; } } if (type == null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ChebsNecromancy not found, skipping NeckroGatherer blacklist patch."); return; } MethodInfo method = type.GetMethod("LookForNearbyItems", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { HarmonyMethod val = new HarmonyMethod(typeof(NeckroGathererPatches).GetMethod("LookForNearbyItemsPostfix", BindingFlags.Static | BindingFlags.Public)); _harmony.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched NeckroGathererMinion.LookForNearbyItems for item blacklist."); } MethodInfo method2 = type.GetMethod("AttemptItemPickup", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method2 != null) { HarmonyMethod val2 = new HarmonyMethod(typeof(NeckroGathererPatches).GetMethod("AttemptItemPickupPrefix", BindingFlags.Static | BindingFlags.Public)); _harmony.Patch((MethodBase)method2, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched NeckroGathererMinion.AttemptItemPickup for item blacklist."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to patch NeckroGatherer: " + ex.Message)); } } private void PatchTrophyConverter() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown try { Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetName().Name == "OdinMounts") { type = assembly.GetType("OdinMounts.TrophyConverter"); break; } } if (type == null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"OdinMounts not found, skipping TrophyConverter patch."); return; } MethodInfo method = type.GetMethod("Awake", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { HarmonyMethod val = new HarmonyMethod(typeof(TrophyConverterPatches).GetMethod("AwakePostfix", BindingFlags.Static | BindingFlags.Public)); _harmony.Patch((MethodBase)method, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched TrophyConverter.Awake for configurable trophy requirements."); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to patch TrophyConverter: " + ex.Message)); } } private void Update() { if (!((Object)(object)Player.m_localPlayer == (Object)null) && ParseHotkey(PickupHotkey.Value)) { if (_isCarrying) { ReleaseCreature(); } else { TryPickupCreature(); } } } public static bool IsCarrying() { return _isCarrying; } public static float GetSpeedPenalty() { if (_isCarrying) { return CarrySpeedPenalty.Value; } return 1f; } private void TryPickupCreature() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 position = ((Component)GameCamera.instance).transform.position; Vector3 forward = ((Component)GameCamera.instance).transform.forward; Character val = null; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(position, forward, ref val2, PickupRange.Value)) { val = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Character>(); } if ((Object)(object)val != (Object)null && !val.IsPlayer()) { Tameable component = ((Component)val).GetComponent<Tameable>(); if ((Object)(object)component != (Object)null && val.IsTamed()) { DoPickup(val); return; } } Character val3 = FindNearestTamedCreature(((Component)localPlayer).transform.position); if ((Object)(object)val3 != (Object)null) { DoPickup(val3); } else { ShowMessage("No tamed creature in range."); } } private Character FindNearestTamedCreature(Vector3 pos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) Character result = null; float num = PickupRange.Value; List<Character> list = new List<Character>(); Character.GetCharactersInRange(pos, PickupRange.Value, list); foreach (Character item in list) { if (!((Object)(object)item == (Object)(object)Player.m_localPlayer) && !item.IsPlayer() && item.IsTamed()) { float num2 = Vector3.Distance(pos, ((Component)item).transform.position); if (num2 < num) { num = num2; result = item; } } } return result; } private void DoPickup(Character creature) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)creature).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { ShowMessage("Cannot pick up this creature."); return; } _carriedID = component.GetZDO().m_uid; _carriedPrefabName = Utils.GetPrefabName(((Component)creature).gameObject); _carriedCreatureName = creature.GetHoverName(); _isCarrying = true; component.GetZDO().Set("CreatureCarry_Carried", true); component.GetZDO().Set("CreatureCarry_Owner", Player.m_localPlayer.GetPlayerID()); MonsterAI component2 = ((Component)creature).GetComponent<MonsterAI>(); if ((Object)(object)component2 != (Object)null) { component2.SetFollowTarget((GameObject)null); ((Behaviour)component2).enabled = false; } AnimalAI component3 = ((Component)creature).GetComponent<AnimalAI>(); if ((Object)(object)component3 != (Object)null) { ((Behaviour)component3).enabled = false; } Rigidbody component4 = ((Component)creature).GetComponent<Rigidbody>(); if ((Object)(object)component4 != (Object)null) { component4.isKinematic = true; component4.useGravity = false; } ((Component)creature).transform.SetParent(((Component)Player.m_localPlayer).transform); ((Component)creature).transform.localPosition = new Vector3(0f, 2.2f, 0.2f); ((Component)creature).transform.localScale = Vector3.one * 0.25f; ((Component)creature).transform.localRotation = Quaternion.identity; _disabledColliders.Clear(); Collider[] componentsInChildren = ((Component)creature).GetComponentsInChildren<Collider>(); Collider[] array = componentsInChildren; foreach (Collider val in array) { if (val.enabled) { _disabledColliders.Add(val); val.enabled = false; } } CreateDropIndicator(); ShowMessage("Picked up " + _carriedCreatureName + "!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Picked up creature: " + _carriedPrefabName)); } private static Vector3 GetDropPosition(Player player) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = ((Component)player).transform.forward; Vector3 val = ((Component)player).transform.position + forward * 2f; Vector3 val2 = val + Vector3.up * 5f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, Vector3.down, ref val3, 10f)) { val = ((RaycastHit)(ref val3)).point; } else { float y = 0f; if (ZoneSystem.instance.GetGroundHeight(val, ref y)) { val.y = y; } } return val; } private void ReleaseCreature() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (!_isCarrying) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } GameObject val = ZNetScene.instance.FindInstance(_carriedID); if ((Object)(object)val == (Object)null) { ZNetView val2 = ZNetScene.instance.FindInstance(ZDOMan.instance.GetZDO(_carriedID)); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).gameObject; } } if ((Object)(object)val == (Object)null) { ShowMessage(_carriedCreatureName + " was lost!"); CleanupCarryState(); return; } Character component = val.GetComponent<Character>(); Vector3 dropPosition = GetDropPosition(localPlayer); ((Component)component).transform.SetParent((Transform)null); ((Component)component).transform.position = dropPosition; ((Component)component).transform.localScale = Vector3.one; ((Component)component).transform.rotation = ((Component)localPlayer).transform.rotation; foreach (Collider disabledCollider in _disabledColliders) { if ((Object)(object)disabledCollider != (Object)null) { disabledCollider.enabled = true; } } _disabledColliders.Clear(); Rigidbody component2 = ((Component)component).GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = false; component2.useGravity = true; } MonsterAI component3 = ((Component)component).GetComponent<MonsterAI>(); if ((Object)(object)component3 != (Object)null) { ((Behaviour)component3).enabled = true; } AnimalAI component4 = ((Component)component).GetComponent<AnimalAI>(); if ((Object)(object)component4 != (Object)null) { ((Behaviour)component4).enabled = true; } ZNetView component5 = ((Component)component).GetComponent<ZNetView>(); if ((Object)(object)component5 != (Object)null && component5.IsValid()) { component5.GetZDO().Set("CreatureCarry_Carried", false); } ShowMessage("Released " + _carriedCreatureName + "!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Released creature: " + _carriedPrefabName)); CleanupCarryState(); } private void CleanupCarryState() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) _carriedID = ZDOID.None; _carriedPrefabName = null; _carriedCreatureName = null; _isCarrying = false; _disabledColliders.Clear(); DestroyDropIndicator(); } private static void CreateDropIndicator() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown DestroyDropIndicator(); _dropIndicator = new GameObject("CreatureCarryDropIndicator"); _dropCircle = _dropIndicator.AddComponent<LineRenderer>(); _dropCircle.useWorldSpace = true; Shader val = Shader.Find("Particles/Standard Unlit"); if ((Object)(object)val != (Object)null) { ((Renderer)_dropCircle).material = new Material(val); } _dropCircle.startColor = new Color(0.2f, 1f, 0.3f, 0.7f); _dropCircle.endColor = new Color(0.2f, 1f, 0.3f, 0.7f); _dropCircle.startWidth = 0.05f; _dropCircle.endWidth = 0.05f; int num = 24; _dropCircle.positionCount = num + 1; _dropCircle.loop = false; } private static void DestroyDropIndicator() { if ((Object)(object)_dropIndicator != (Object)null) { Object.Destroy((Object)(object)_dropIndicator); _dropIndicator = null; _dropCircle = null; } } private static void UpdateDropIndicator() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_dropIndicator == (Object)null) && !((Object)(object)_dropCircle == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { Vector3 dropPosition = GetDropPosition(Player.m_localPlayer); dropPosition.y += 0.05f; float num = 0.6f; int num2 = 24; for (int i = 0; i <= num2; i++) { float num3 = (float)i / (float)num2 * (float)Math.PI * 2f; float num4 = Mathf.Cos(num3) * num; float num5 = Mathf.Sin(num3) * num; _dropCircle.SetPosition(i, dropPosition + new Vector3(num4, 0f, num5)); } } } private void LateUpdate() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (!_isCarrying || (Object)(object)Player.m_localPlayer == (Object)null) { return; } ZDO zDO = ZDOMan.instance.GetZDO(_carriedID); if (zDO == null || !zDO.IsValid()) { ShowMessage(_carriedCreatureName + " was lost!"); CleanupCarryState(); return; } GameObject val = ZNetScene.instance.FindInstance(_carriedID); if ((Object)(object)val == (Object)null) { ZNetView val2 = ZNetScene.instance.FindInstance(zDO); if ((Object)(object)val2 != (Object)null) { val = ((Component)val2).gameObject; } } if ((Object)(object)val == (Object)null) { zDO.SetPosition(((Component)Player.m_localPlayer).transform.position + Vector3.up * 2f); } else if ((Object)(object)val.transform.parent != (Object)(object)((Component)Player.m_localPlayer).transform) { val.transform.SetParent(((Component)Player.m_localPlayer).transform); val.transform.localPosition = new Vector3(0f, 2.2f, 0.2f); val.transform.localScale = Vector3.one * 0.25f; val.transform.localRotation = Quaternion.identity; } UpdateDropIndicator(); } private static void ShowMessage(string msg) { if (ShowCarryMessage.Value && (Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, msg, 0, (Sprite)null); } } private void OnDestroy() { if (_isCarrying) { ReleaseCreature(); } DestroyDropIndicator(); if (_harmony != null) { _harmony.UnpatchSelf(); } } public static bool ParseHotkey(string hotkey) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Invalid comparison between Unknown and I4 //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) string text = hotkey.ToLower().Replace(" ", ""); string[] array = text.Split(new char[1] { '+' }); bool flag = true; KeyCode val = (KeyCode)0; foreach (string text2 in array) { if (text2 == null) { continue; } KeyCode result; if (text2 == "leftshift" || text2 == "lshift") { if (!Input.GetKey((KeyCode)304)) { flag = false; } } else if (text2 == "rightshift" || text2 == "rshift") { if (!Input.GetKey((KeyCode)303)) { flag = false; } } else if (text2 == "leftcontrol" || text2 == "leftctrl" || text2 == "lctrl") { if (!Input.GetKey((KeyCode)306)) { flag = false; } } else if (text2 == "leftalt" || text2 == "lalt") { if (!Input.GetKey((KeyCode)308)) { flag = false; } } else if (text2 == "rightalt" || text2 == "ralt") { if (!Input.GetKey((KeyCode)307)) { flag = false; } } else if (Enum.TryParse<KeyCode>(text2, ignoreCase: true, out result)) { val = result; } } if (!flag) { return false; } if ((int)val == 0) { return false; } return Input.GetKeyDown(val); } } [HarmonyPatch] public static class CreatureCarryPatches { [HarmonyPatch(typeof(Character), "GetRunSpeedFactor")] [HarmonyPostfix] public static void OnGetRunSpeed(Character __instance, ref float __result) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && CreatureCarryPlugin.IsCarrying()) { __result *= CreatureCarryPlugin.GetSpeedPenalty(); } } [HarmonyPrefix] [HarmonyPatch(typeof(Character), "Damage")] public static bool OnDamage(Character __instance) { if ((Object)(object)__instance == (Object)null) { return true; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return true; } ZDO zDO = component.GetZDO(); if (zDO != null && zDO.GetBool("CreatureCarry_Carried", false)) { return false; } return true; } [HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[] { typeof(Character), typeof(Character) })] [HarmonyPostfix] public static void OnIsEnemy(Character a, Character b, ref bool __result) { if (__result && CreatureCarryPlugin.ProtectTamedFromEnemies.Value) { if ((Object)(object)b != (Object)null && b.IsTamed() && !b.IsPlayer()) { __result = false; } else if ((Object)(object)a != (Object)null && a.IsTamed() && !a.IsPlayer()) { __result = false; } } } [HarmonyPatch(typeof(EggGrow), "CanGrow")] [HarmonyPostfix] public static void OnCanGrow(EggGrow __instance, ref bool __result) { if (CreatureCarryPlugin.RemoveEggFireRequirement.Value && !__result) { __instance.m_requireNearbyFire = false; __instance.m_requireUnderRoof = false; __result = true; } } [HarmonyPrefix] [HarmonyPatch(typeof(EggGrow), "GrowUpdate")] public static void OnGrowUpdate(EggGrow __instance) { if (CreatureCarryPlugin.RemoveEggFireRequirement.Value) { __instance.m_requireNearbyFire = false; __instance.m_requireUnderRoof = false; } } [HarmonyPatch(typeof(Tameable), "GetHoverText")] [HarmonyPostfix] public static void OnGetHoverText(Tameable __instance, ref string __result) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.IsTamed() || (Object)(object)Player.m_localPlayer == (Object)null) { return; } float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)__instance).transform.position); if (num <= CreatureCarryPlugin.PickupRange.Value) { if (CreatureCarryPlugin.IsCarrying()) { __result = __result + "\n[<color=yellow>" + CreatureCarryPlugin.PickupHotkey.Value + "</color>] Release carried creature"; } else { __result = __result + "\n[<color=yellow>" + CreatureCarryPlugin.PickupHotkey.Value + "</color>] Pick up"; } } } } public static class TrophyConverterPatches { private static FieldInfo _trophiesRequiredField; private static FieldInfo _conversionDurationField; public static void AwakePostfix(object __instance) { if (_trophiesRequiredField == null) { _trophiesRequiredField = __instance.GetType().GetField("m_trophiesRequired", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_conversionDurationField == null) { _conversionDurationField = __instance.GetType().GetField("m_conversionDurationSeconds", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_trophiesRequiredField != null) { _trophiesRequiredField.SetValue(__instance, CreatureCarryPlugin.TrophiesRequired.Value); } if (_conversionDurationField != null) { _conversionDurationField.SetValue(__instance, CreatureCarryPlugin.ConversionDuration.Value); } } } public static class NeckroGathererPatches { private static FieldInfo _currentItemField; private static FieldInfo GetCurrentItemField(object instance) { if (_currentItemField == null) { _currentItemField = instance.GetType().GetField("_currentItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } return _currentItemField; } public static void LookForNearbyItemsPostfix(object __instance, ref bool __result) { if (!__result) { return; } HashSet<string> blacklist = CreatureCarryPlugin.GetBlacklist(); if (blacklist.Count == 0) { return; } FieldInfo currentItemField = GetCurrentItemField(__instance); if (currentItemField == null) { return; } object? value = currentItemField.GetValue(__instance); ItemDrop val = (ItemDrop)((value is ItemDrop) ? value : null); if (!((Object)(object)val == (Object)null)) { string prefabName = Utils.GetPrefabName(((Component)val).gameObject); string item = ((val.m_itemData != null && val.m_itemData.m_shared != null) ? val.m_itemData.m_shared.m_name : ""); if (blacklist.Contains(prefabName) || blacklist.Contains(item)) { currentItemField.SetValue(__instance, null); __result = false; } } } public static bool AttemptItemPickupPrefix(object __instance) { HashSet<string> blacklist = CreatureCarryPlugin.GetBlacklist(); if (blacklist.Count == 0) { return true; } FieldInfo currentItemField = GetCurrentItemField(__instance); if (currentItemField == null) { return true; } object? value = currentItemField.GetValue(__instance); ItemDrop val = (ItemDrop)((value is ItemDrop) ? value : null); if ((Object)(object)val == (Object)null) { return true; } string prefabName = Utils.GetPrefabName(((Component)val).gameObject); string item = ((val.m_itemData != null && val.m_itemData.m_shared != null) ? val.m_itemData.m_shared.m_name : ""); if (blacklist.Contains(prefabName) || blacklist.Contains(item)) { currentItemField.SetValue(__instance, null); return false; } return true; } }