using 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BlowgunEnhanced")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e2fc2576a986539ed321b56e932194c0a5465ff8")] [assembly: AssemblyProduct("BlowgunEnhanced")] [assembly: AssemblyTitle("BlowgunEnhanced")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 BlowgunEnhanced { [BepInPlugin("jill920.blowgunenhanced", "Blowgun Enhanced", "1.0.0")] public class BlowgunEnhancedPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.blowgunenhanced"; public const string MOD_NAME = "Blowgun Enhanced"; public const string MOD_VERSION = "1.0.0"; public static BlowgunEnhancedPlugin Instance; public static ManualLogSource Logger; public static bool IsDizzinessModInstalled; public static bool IsFatigueModInstalled; public static bool debugMode; private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; debugMode = ((BaseUnityPlugin)this).Config.Bind("Debug", "EnableLogs", false, "Enable debug logging").Value; CheckForInstalledMods(); try { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "jill920.blowgunenhanced"); Logger.LogInfo((object)"[Blowgun Enhanced 1.0.0] Loaded successfully!"); Logger.LogInfo((object)$" Dizziness Mod detected (initial): {IsDizzinessModInstalled}"); Logger.LogInfo((object)$" Fatigue Mod detected (initial): {IsFatigueModInstalled}"); } catch (Exception ex) { Logger.LogError((object)("Failed to load: " + ex.Message)); } } private void CheckForInstalledMods() { IsDizzinessModInstalled = false; IsFatigueModInstalled = false; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { try { if (assembly.GetType("DizzinessMod.DizzinessTracker") != null) { IsDizzinessModInstalled = true; } if (assembly.GetType("FatigueMod.FatigueTracker") != null) { IsFatigueModInstalled = true; } } catch { } } } } } namespace BlowgunEnhanced.Patches { [HarmonyPatch(typeof(Action_RaycastDart), "RPC_DartImpact")] internal static class Action_RaycastDart_Patch { private static bool _fatigueCheckDone; private static bool _fatigueAvailable; private static bool _dizzinessCheckDone; private static bool _dizzinessAvailable; private static bool IsFatigueModPresent() { if (_fatigueCheckDone) { return _fatigueAvailable; } _fatigueCheckDone = true; if (BlowgunEnhancedPlugin.IsFatigueModInstalled) { _fatigueAvailable = true; return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("FatigueMod.FatigueTracker") != null) { _fatigueAvailable = true; BlowgunEnhancedPlugin.IsFatigueModInstalled = true; BlowgunEnhancedPlugin.Logger.LogInfo((object)"Blowgun: Fatigue Mod detected at runtime!"); return true; } } } catch { } return false; } private static bool IsDizzinessModPresent() { if (_dizzinessCheckDone) { return _dizzinessAvailable; } _dizzinessCheckDone = true; if (BlowgunEnhancedPlugin.IsDizzinessModInstalled) { _dizzinessAvailable = true; return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("DizzinessMod.DizzinessTracker") != null) { _dizzinessAvailable = true; BlowgunEnhancedPlugin.IsDizzinessModInstalled = true; BlowgunEnhancedPlugin.Logger.LogInfo((object)"Blowgun: Dizziness Mod detected at runtime!"); return true; } } } catch { } return false; } [HarmonyPostfix] private static void Postfix(int characterID, Vector3 origin, Vector3 endpoint) { if (characterID == -1) { return; } try { PhotonView photonView = PhotonNetwork.GetPhotonView(characterID); if ((Object)(object)photonView == (Object)null) { return; } Character component = ((Component)photonView).GetComponent(); if ((Object)(object)component == (Object)null || !component.IsLocal) { return; } bool flag = IsDizzinessModPresent(); bool flag2 = IsFatigueModPresent(); if (flag || flag2) { if (flag) { ClearDizziness(component); } if (flag2) { ClearFatigue(component); } if (BlowgunEnhancedPlugin.debugMode) { BlowgunEnhancedPlugin.Logger.LogInfo((object)("Blowgun: Cleared Dizziness/Fatigue for " + component.characterName)); } } } catch (Exception ex) { BlowgunEnhancedPlugin.Logger.LogWarning((object)("Failed to process blowgun hit: " + ex.Message)); } } private static void ClearDizziness(Character character) { try { Component component = ((Component)character).GetComponent("DizzinessMod.DizzinessTracker"); if ((Object)(object)component == (Object)null) { return; } FieldInfo field = ((object)component).GetType().GetField("dizzinessValue", BindingFlags.Instance | BindingFlags.Public); if (field == null) { return; } float num = (float)field.GetValue(component); if (num > 0.01f) { field.SetValue(component, 0f); if (BlowgunEnhancedPlugin.debugMode) { BlowgunEnhancedPlugin.Logger.LogInfo((object)$"Blowgun: Cleared Dizziness: {num:F3} → 0"); } } } catch (Exception ex) { BlowgunEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Dizziness: " + ex.Message)); } } private static void ClearFatigue(Character character) { try { Component component = ((Component)character).GetComponent("FatigueMod.FatigueTracker"); if ((Object)(object)component == (Object)null) { return; } FieldInfo field = ((object)component).GetType().GetField("fatigueValue", BindingFlags.Instance | BindingFlags.Public); if (field == null) { return; } FieldInfo field2 = ((object)component).GetType().GetField("pendingStaminaFromActions", BindingFlags.Instance | BindingFlags.NonPublic); float num = (float)field.GetValue(component); field.SetValue(component, 0f); if (field2 != null) { float num2 = (float)field2.GetValue(component); if (num2 > 0.01f) { field2.SetValue(component, 0f); if (BlowgunEnhancedPlugin.debugMode) { BlowgunEnhancedPlugin.Logger.LogInfo((object)$"Blowgun: Cleared pending stamina: {num2:F3} → 0"); } } } if (BlowgunEnhancedPlugin.debugMode && num > 0.01f) { BlowgunEnhancedPlugin.Logger.LogInfo((object)$"Blowgun: Cleared Fatigue: {num:F3} → 0"); } } catch (Exception ex) { BlowgunEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Fatigue: " + ex.Message)); } } } }