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 Tame Anywhere v1.0.0
Tame_Anywhere.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Tame_Anywhere")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Tame_Anywhere")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("60aa0b68-4f27-4312-8351-4ad9d1f80c67")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace TameAnywhere; [BepInPlugin("local.tameanywhere", "Tame Anywhere", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "local.tameanywhere"; public const string ModName = "Tame Anywhere"; public const string Version = "1.0.0"; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("local.tameanywhere"); _harmony.PatchAll(typeof(TamingPatch)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(Tameable), "TamingUpdate")] internal static class TamingPatch { private const string LastTickKey = "TA_LastTick"; private const double MinGapSeconds = 4.0; private static bool _errorLogged; private static readonly MethodInfo TameMethod = AccessTools.Method(typeof(Tameable), "Tame", Type.EmptyTypes, (Type[])null); [HarmonyPrefix] private static void Prefix(Tameable __instance) { try { CatchUp(__instance); } catch (Exception ex) { if (!_errorLogged) { _errorLogged = true; Plugin.Log.LogError((object)("Catch-up fehlgeschlagen (wird nur einmal geloggt): " + ex)); } } } private static void FinishTaming(Tameable tameable, Character character) { if (TameMethod != null) { TameMethod.Invoke(tameable, null); } else { character.SetTamed(true); } } private static void CatchUp(Tameable tameable) { if ((Object)(object)ZNet.instance == (Object)null) { return; } ZNetView component = ((Component)tameable).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || !component.IsOwner()) { return; } Character component2 = ((Component)tameable).GetComponent<Character>(); if ((Object)(object)component2 == (Object)null || component2.IsTamed()) { return; } ZDO zDO = component.GetZDO(); long num = zDO.GetLong(ZDOVars.s_tameLastFeeding, 0L); if (num == 0) { return; } DateTime time = ZNet.instance.GetTime(); DateTime dateTime = new DateTime(num).AddSeconds(tameable.m_fedDuration); bool flag = time > dateTime; long val = zDO.GetLong("TA_LastTick", 0L); DateTime dateTime2 = new DateTime(Math.Max(num, val)); DateTime dateTime3 = (flag ? dateTime : time); double totalSeconds = (dateTime3 - dateTime2).TotalSeconds; if (totalSeconds > 4.0) { float num2 = zDO.GetFloat(ZDOVars.s_tameTimeLeft, tameable.m_tamingTime) - (float)totalSeconds; zDO.Set(ZDOVars.s_tameTimeLeft, num2); zDO.Set("TA_LastTick", time.Ticks); if (num2 <= 0f) { FinishTaming(tameable, component2); } } else if (!flag) { zDO.Set("TA_LastTick", time.Ticks); } } }