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 TenSecondTaming v1.0.0
plugins/TenSecondTaming/TenSecondTaming.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: AssemblyTitle("Ten Second Taming")] [assembly: AssemblyDescription("Sets the base taming duration to ten seconds for all standard tameables.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace Fai.TenSecondTaming; [BepInPlugin("fai.valheim.tensecondtaming", "Ten Second Taming", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "fai.valheim.tensecondtaming"; public const string PluginName = "Ten Second Taming"; public const string PluginVersion = "1.0.0"; internal const float Duration = 10f; internal const float TickSeconds = 1f; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Harmony val = new Harmony("fai.valheim.tensecondtaming"); try { val.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Ten Second Taming 1.0.0 loaded: 10 second base duration, 1 second progress checks."); } catch (Exception ex) { val.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)("Ten Second Taming could not apply its patches and was disabled. " + ex)); } } } [HarmonyPatch(typeof(Tameable), "Awake")] internal static class AwakePatch { [HarmonyPostfix] [HarmonyPriority(0)] private static void Postfix(Tameable __instance) { __instance.m_tamingTime = 10f; } [HarmonyTranspiler] [HarmonyPriority(0)] internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; for (int i = 0; i + 3 < list.Count; i++) { MethodInfo methodInfo = list[i + 3].operand as MethodInfo; if (list[i].opcode == OpCodes.Ldstr && (string)list[i].operand == "TamingUpdate" && list[i + 1].opcode == OpCodes.Ldc_R4 && list[i + 2].opcode == OpCodes.Ldc_R4 && (list[i + 3].opcode == OpCodes.Call || list[i + 3].opcode == OpCodes.Callvirt) && methodInfo != null && methodInfo.Name == "InvokeRepeating") { list[i + 1].operand = 1f; list[i + 2].operand = 1f; num++; } } if (num != 1) { throw new InvalidOperationException("Expected exactly one Tameable.Awake taming schedule; found " + num + "."); } return list; } } [HarmonyPatch(typeof(Tameable), "TamingUpdate")] internal static class TamingUpdatePatch { [HarmonyTranspiler] [HarmonyPriority(0)] internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; for (int i = 1; i < list.Count; i++) { MethodInfo methodInfo = list[i].operand as MethodInfo; if ((list[i].opcode == OpCodes.Call || list[i].opcode == OpCodes.Callvirt) && methodInfo != null && methodInfo.DeclaringType == typeof(Tameable) && methodInfo.Name == "DecreaseRemainingTime" && list[i - 1].opcode == OpCodes.Ldc_R4) { list[i - 1].operand = 1f; num++; } } if (num != 1) { throw new InvalidOperationException("Expected exactly one Tameable.TamingUpdate progress decrement; found " + num + "."); } return list; } } [HarmonyPatch(typeof(Tameable), "GetRemainingTime")] internal static class RemainingTimePatch { [HarmonyPrefix] [HarmonyPriority(0)] private static void Prefix(Tameable __instance, ZNetView ___m_nview) { __instance.m_tamingTime = 10f; if (Object.op_Implicit((Object)(object)___m_nview) && ___m_nview.IsValid() && ___m_nview.IsOwner() && !__instance.IsTamed()) { ZDO zDO = ___m_nview.GetZDO(); float num = zDO.GetFloat(ZDOVars.s_tameTimeLeft, 10f); if (num > 10f) { zDO.Set(ZDOVars.s_tameTimeLeft, 10f); } } } }