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 FirstPersonBow v1.0.0
plugins/FirstPersonBow.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("FirstPersonBow")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+bf93dcd2e5a12354508723a73216f6e978518628")] [assembly: AssemblyProduct("FirstPersonBow")] [assembly: AssemblyTitle("FirstPersonBow")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FirstPersonBow { [BepInPlugin("firstpersonbow", "FirstPersonBow", "1.0.0")] [BepInProcess("valheim.exe")] public class FirstPersonBowPlugin : BaseUnityPlugin { private static ConfigEntry<bool> modEnabled; private static float savedDistance; private static bool savedTilt; private static Player hiddenPlayer; private Harmony harmony; private void Awake() { modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Switch to first person while drawing a bow."); harmony = Harmony.CreateAndPatchAll(typeof(FirstPersonBowPlugin), ((BaseUnityPlugin)this).Info.Metadata.GUID); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } [HarmonyPatch(typeof(GameCamera), "GetCameraPosition")] [HarmonyPrefix] private static void ForceFirstPerson(GameCamera __instance, ref float ___m_distance, out bool __state) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; int num; if (modEnabled.Value && Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead() && ((Character)localPlayer).IsDrawingBow()) { ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon != null && (int)currentWeapon.m_shared.m_skillType == 8 && !Menu.IsVisible()) { num = ((!InventoryGui.IsVisible()) ? 1 : 0); goto IL_0059; } } num = 0; goto IL_0059; IL_0059: __state = (byte)num != 0; if (__state) { savedDistance = ___m_distance; savedTilt = __instance.m_smoothYTilt; ___m_distance = 0f; __instance.m_smoothYTilt = false; } } [HarmonyPatch(typeof(GameCamera), "GetCameraPosition")] [HarmonyFinalizer] private static void Restore(GameCamera __instance, ref float ___m_distance, bool __state) { if (__state) { ___m_distance = savedDistance; __instance.m_smoothYTilt = savedTilt; hiddenPlayer = Player.m_localPlayer; ((Character)hiddenPlayer).SetVisible(false); } else if (Object.op_Implicit((Object)(object)hiddenPlayer)) { ((Character)hiddenPlayer).SetVisible(true); hiddenPlayer = null; } else { hiddenPlayer = null; } } } }