Decompiled source of coopPlus v1.0.7
BetterFriendJump.dll
Decompiled 19 hours 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace BetterFriendJump { [HarmonyPatch(typeof(CharacterMovement), "JumpRpc")] public static class PatchJumpRpc { private const float FRIEND_JUMP_FORCE = 2050f; [HarmonyPostfix] private static void Postfix(CharacterMovement __instance, bool isPalJump) { //IL_0044: 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) if (!isPalJump) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null) { return; } foreach (Bodypart part in component.refs.ragdoll.partList) { part.AddForce(Vector3.up * 2050f, (ForceMode)5); } } } [BepInPlugin("jill920.BetterFriendJump", "BetterFriendJump", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.BetterFriendJump"; public const string MOD_NAME = "BetterFriendJump"; public const string MOD_VERSION = "1.0.1"; public static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "jill920.BetterFriendJump"); Log.LogInfo((object)"[BetterFriendJump 1.0.1] Loaded! Friend jump force: 2000"); } } }
BetterFriendPull.dll
Decompiled 19 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; 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("BetterFriendPull")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+21ed1f20f1f85c010fe6758e26953fb81c50997d")] [assembly: AssemblyProduct("BetterFriendPull")] [assembly: AssemblyTitle("BetterFriendPull")] [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 BetterFriendPull { [HarmonyPatch(typeof(CharacterGrabbing), "Reach")] public static class PatchReachRange { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)list[i].operand, 4f)) { Debug.Log((object)$"[BetterFriendPull] Replacing 4f range with {Plugin.PullRange.Value}f"); list[i] = new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.PullRange.Value); } if (list[i].opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)list[i].operand, 60f)) { Debug.Log((object)$"[BetterFriendPull] Replacing 60f angle with {Plugin.PullAngle.Value}f"); list[i] = new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.PullAngle.Value); } } return list; } } [HarmonyPatch(typeof(CharacterGrabbing), "TargetCanBeHelped")] public static class PatchVerticalLimit { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode == OpCodes.Ldc_R4) || !Mathf.Approximately((float)list[i].operand, 1f)) { continue; } bool flag = false; for (int j = Mathf.Max(0, i - 8); j < i; j++) { if (list[j].opcode == OpCodes.Callvirt && list[j].operand.ToString().Contains("get_isClimbing")) { flag = true; break; } } if (flag) { Debug.Log((object)$"[BetterFriendPull] Replacing vertical limit 1f with {Plugin.PullVerticalLimit.Value}f"); list[i] = new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.PullVerticalLimit.Value); } } return list; } } [HarmonyPatch(typeof(Character), "DragTowards")] public static class PatchPullForce { [HarmonyPrefix] private static void Prefix(Character __instance, Vector3 target, ref float force) { if (!Mathf.Approximately(Plugin.PullForceMultiplier.Value, 1f)) { force *= Plugin.PullForceMultiplier.Value; if (Plugin.PullForceMultiplier.Value != 1f) { Debug.Log((object)$"[BetterFriendPull] Pull force multiplied: {force / Plugin.PullForceMultiplier.Value:F0} → {force:F0}"); } } } } public static class StaminaFreezeManager { private static HashSet<Character> _protectedChars = new HashSet<Character>(); private static Dictionary<Character, float> _protectUntil = new Dictionary<Character, float>(); public static void ProtectCharacter(Character c) { if (Plugin.EnableStaminaFreeze.Value) { _protectedChars.Add(c); _protectUntil[c] = Time.time + Plugin.StaminaFreezeCooldown.Value; } } public static bool IsProtected(Character c) { if (!Plugin.EnableStaminaFreeze.Value) { return false; } float time = Time.time; List<Character> list = new List<Character>(); foreach (KeyValuePair<Character, float> item in _protectUntil) { if (time > item.Value) { list.Add(item.Key); } } foreach (Character item2 in list) { _protectedChars.Remove(item2); _protectUntil.Remove(item2); } return _protectedChars.Contains(c); } } [HarmonyPatch(typeof(Character), "DragTowards")] public static class PatchTrackPullSimple { [HarmonyPrefix] private static void Prefix(Character __instance) { StaminaFreezeManager.ProtectCharacter(__instance); if (((MonoBehaviourPun)__instance).photonView.IsMine && Plugin.EnableStaminaFreeze.Value) { Debug.Log((object)("[BetterFriendPull] Stamina frozen for " + __instance.characterName)); } } } [HarmonyPatch(typeof(Character), "UseStamina")] public static class PatchBlockStamina { [HarmonyPrefix] private static bool Prefix(Character __instance) { if (StaminaFreezeManager.IsProtected(__instance)) { return false; } return true; } } [BepInPlugin("jill920.BetterFriendPull", "BetterFriendPull", "1.0.1")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static ConfigEntry<float> PullRange; public static ConfigEntry<float> PullAngle; public static ConfigEntry<float> PullVerticalLimit; public static ConfigEntry<float> PullForceMultiplier; public static ConfigEntry<bool> EnableStaminaFreeze; public static ConfigEntry<float> StaminaFreezeCooldown; public static HashSet<Character> PullProtectedCharacters = new HashSet<Character>(); public static Dictionary<Character, float> PullProtectionEndTime = new Dictionary<Character, float>(); private void Awake() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PullRange = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Pull Range", 6f, "Max distance to detect climbing friends (vanilla: 4)"); PullAngle = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Pull Angle", 60f, "Cone angle in degrees (vanilla: 60)"); PullVerticalLimit = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Vertical Pull Limit", 1f, "Max height difference to pull (vanilla: 1)"); PullForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Pull Force Multiplier", 1f, "Multiply pull force (vanilla: 1)"); EnableStaminaFreeze = ((BaseUnityPlugin)this).Config.Bind<bool>("Stamina", "Enable Stamina Freeze", true, "Prevent stamina drain while being pulled"); StaminaFreezeCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Stamina Freeze Cooldown", 0.65f, "Seconds after pull ends to keep stamina frozen (prevents instant drain)"); Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); val.PatchAll(); Log.LogInfo((object)$"BetterFriendPull loaded. Range: {PullRange.Value}m, Stamina Freeze: {EnableStaminaFreeze.Value}, Cooldown: {StaminaFreezeCooldown.Value}s"); } private void Update() { float time = Time.time; List<Character> list = new List<Character>(); foreach (KeyValuePair<Character, float> item in PullProtectionEndTime) { if (time > item.Value) { list.Add(item.Key); } } foreach (Character item2 in list) { PullProtectedCharacters.Remove(item2); PullProtectionEndTime.Remove(item2); if ((Object)(object)item2 != (Object)null && ((MonoBehaviourPun)item2).photonView.IsMine) { Log.LogDebug((object)("Stamina freeze expired for " + item2.characterName)); } } if (!Application.isFocused || (Object)(object)Character.localCharacter == (Object)null || (!Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305))) { return; } if (Input.GetKeyDown((KeyCode)273)) { ConfigEntry<float> pullRange = PullRange; pullRange.Value += 0.5f; Log.LogInfo((object)$"↑ Pull Range increased to {PullRange.Value}m"); } if (Input.GetKeyDown((KeyCode)274)) { ConfigEntry<float> pullRange2 = PullRange; pullRange2.Value -= 0.5f; Log.LogInfo((object)$"↓ Pull Range decreased to {PullRange.Value}m"); } if (Input.GetKeyDown((KeyCode)275)) { ConfigEntry<float> pullAngle = PullAngle; pullAngle.Value += 5f; Log.LogInfo((object)$"→ Pull Angle increased to {PullAngle.Value}°"); } if (Input.GetKeyDown((KeyCode)276)) { ConfigEntry<float> pullAngle2 = PullAngle; pullAngle2.Value -= 5f; Log.LogInfo((object)$"← Pull Angle decreased to {PullAngle.Value}°"); } if (Input.GetKeyDown((KeyCode)280)) { ConfigEntry<float> pullVerticalLimit = PullVerticalLimit; pullVerticalLimit.Value += 0.5f; Log.LogInfo((object)$"PgUp Vertical Limit increased to {PullVerticalLimit.Value}m"); } if (Input.GetKeyDown((KeyCode)281)) { ConfigEntry<float> pullVerticalLimit2 = PullVerticalLimit; pullVerticalLimit2.Value -= 0.5f; Log.LogInfo((object)$"PgDn Vertical Limit decreased to {PullVerticalLimit.Value}m"); } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { if (Input.GetKeyDown((KeyCode)273)) { ConfigEntry<float> pullForceMultiplier = PullForceMultiplier; pullForceMultiplier.Value += 0.25f; Log.LogInfo((object)$"↑ Pull Force increased to {PullForceMultiplier.Value}x"); } if (Input.GetKeyDown((KeyCode)274)) { ConfigEntry<float> pullForceMultiplier2 = PullForceMultiplier; pullForceMultiplier2.Value -= 0.25f; Log.LogInfo((object)$"↓ Pull Force decreased to {PullForceMultiplier.Value}x"); } } if (Input.GetKeyDown((KeyCode)115)) { EnableStaminaFreeze.Value = !EnableStaminaFreeze.Value; Log.LogInfo((object)("Stamina Freeze: " + (EnableStaminaFreeze.Value ? "ENABLED" : "DISABLED"))); } } } }
BlowgunEnhanced.dll
Decompiled 19 hours 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.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<bool>("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<Character>(); 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)); } } } }
com.zsdm15.StamConsumeFix.dll
Decompiled 19 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyCompany("com.zsdm15.StamConsumeFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.1")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("com.zsdm15.StamConsumeFix")] [assembly: AssemblyTitle("StamConsumeFix")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.1")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace StamConsumeFix { [BepInPlugin("com.zsdm15.StamConsumeFix", "StamConsumeFix", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { Harmony.CreateAndPatchAll(typeof(StartClimbRpcPatch), (string)null); } } [HarmonyPatch(typeof(CharacterClimbing))] internal class StartClimbRpcPatch { [CompilerGenerated] private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private IEnumerator<CodeInstruction> <>s__1; private CodeInstruction <code>5__2; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Transpiler>d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = null; <code>5__2 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <code>5__2 = null; break; } if (<>s__1.MoveNext()) { <code>5__2 = <>s__1.Current; if (<code>5__2.opcode == OpCodes.Ldc_R4 && Mathf.Approximately((float)<code>5__2.operand, 0.15f)) { <code>5__2.operand = 1.33f; } <>2__current = <code>5__2; <>1__state = 1; return true; } <>m__Finally1(); <>s__1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__1 != null) { <>s__1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <Transpiler>d__0 <Transpiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <Transpiler>d__ = this; } else { <Transpiler>d__ = new <Transpiler>d__0(0); } <Transpiler>d__.instructions = <>3__instructions; return <Transpiler>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [IteratorStateMachine(typeof(<Transpiler>d__0))] [HarmonyPatch("StartClimbRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Transpiler>d__0(-2) { <>3__instructions = instructions }; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } }
CursedSkullEnhanced.dll
Decompiled 19 hours 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak.Afflictions; 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("CursedSkullEnhanced")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4ae62c83b75fb9dfd6ceece03fabe4a630bf3840")] [assembly: AssemblyProduct("CursedSkullEnhanced")] [assembly: AssemblyTitle("CursedSkullEnhanced")] [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 CursedSkullEnhanced { [BepInPlugin("jill920.cursedskullenhanced", "Cursed Skull Enhanced", "1.0.0")] public class CursedSkullEnhancedPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.cursedskullenhanced"; public const string MOD_NAME = "Cursed Skull Enhanced"; public const string MOD_VERSION = "1.0.0"; public static CursedSkullEnhancedPlugin 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<bool>("Debug", "EnableLogs", false, "Enable debug logging").Value; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "jill920.cursedskullenhanced"); CheckForInstalledMods(); Logger.LogInfo((object)"[Cursed Skull Enhanced 1.0.0] Loaded successfully!"); Logger.LogInfo((object)$" Dizziness Mod detected: {IsDizzinessModInstalled}"); Logger.LogInfo((object)$" Fatigue Mod detected: {IsFatigueModInstalled}"); } 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 CursedSkullEnhanced.Patches { [HarmonyPatch(typeof(Action_ApplyMassAffliction), "TryAddAfflictionToLocalCharacter")] internal static class Action_ApplyMassAffliction_Patch { [HarmonyPostfix] private static void Postfix(Action_ApplyMassAffliction __instance) { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && ((Action_ApplyAffliction)__instance).affliction is Affliction_ClearAllStatus) { ClearDizzinessAndFatigue(localCharacter); if (CursedSkullEnhancedPlugin.debugMode) { CursedSkullEnhancedPlugin.Logger.LogInfo((object)("Cursed Skull: Cleared Dizziness/Fatigue for " + localCharacter.characterName)); } } } private static void ClearDizzinessAndFatigue(Character character) { if (IsDizzinessModPresent()) { ClearDizziness(character); } if (IsFatigueModPresent()) { ClearFatigue(character); } } private static bool IsDizzinessModPresent() { if (CursedSkullEnhancedPlugin.IsDizzinessModInstalled) { return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("DizzinessMod.DizzinessTracker") != null) { CursedSkullEnhancedPlugin.IsDizzinessModInstalled = true; return true; } } } catch { } return false; } private static bool IsFatigueModPresent() { if (CursedSkullEnhancedPlugin.IsFatigueModInstalled) { return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("FatigueMod.FatigueTracker") != null) { CursedSkullEnhancedPlugin.IsFatigueModInstalled = true; return true; } } } catch { } return false; } 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 (CursedSkullEnhancedPlugin.debugMode) { CursedSkullEnhancedPlugin.Logger.LogInfo((object)$"Cleared Dizziness: {num:F3} → 0"); } } } catch (Exception ex) { CursedSkullEnhancedPlugin.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 (CursedSkullEnhancedPlugin.debugMode) { CursedSkullEnhancedPlugin.Logger.LogInfo((object)$"Cleared pending stamina: {num2:F3} → 0"); } } } if (CursedSkullEnhancedPlugin.debugMode && num > 0.01f) { CursedSkullEnhancedPlugin.Logger.LogInfo((object)$"Cleared Fatigue: {num:F3} → 0"); } } catch (Exception ex) { CursedSkullEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Fatigue: " + ex.Message)); } } } [HarmonyPatch(typeof(ItemCooking), "RPC_CookingExplode")] internal static class ItemCooking_Explode_Patch { private const float CURSED_SKULL_RADIUS = 900f; private const int CURSED_SKULL_ITEM_ID = 25; [HarmonyPrefix] private static void Prefix(ItemCooking __instance) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Item item = ((ItemComponent)__instance).item; if ((Object)(object)item == (Object)null || item.itemID != 25) { return; } Vector3 position = ((Component)__instance).transform.position; foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null)) { float num = Vector3.Distance(position, allCharacter.Center); if (!(num > 900f)) { ClearDizzinessAndFatigue(allCharacter); } } } CursedSkullEnhancedPlugin.Logger.LogInfo((object)$"Cursed Skull explosion: Cleared Dizziness/Fatigue for players within {900f} units"); } private static void ClearDizzinessAndFatigue(Character character) { if (CursedSkullEnhancedPlugin.IsDizzinessModInstalled) { ClearDizziness(character); } if (CursedSkullEnhancedPlugin.IsFatigueModInstalled) { ClearFatigue(character); } } 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 (CursedSkullEnhancedPlugin.debugMode) { CursedSkullEnhancedPlugin.Logger.LogInfo((object)$"Cleared Dizziness for {character.characterName}: {num:F3} → 0"); } } } catch (Exception ex) { CursedSkullEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Dizziness: " + ex.Message)); } } private static bool IsFatigueModPresent() { if (CursedSkullEnhancedPlugin.IsFatigueModInstalled) { return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("FatigueMod.FatigueTracker") != null) { CursedSkullEnhancedPlugin.IsFatigueModInstalled = true; return true; } } } catch { } return false; } private static void ClearFatigue(Character character) { if (!IsFatigueModPresent()) { return; } 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)) { FieldInfo field2 = ((object)component).GetType().GetField("pendingStaminaFromActions", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(component, 0f); if (field2 != null) { field2.SetValue(component, 0f); } if (CursedSkullEnhancedPlugin.debugMode) { CursedSkullEnhancedPlugin.Logger.LogInfo((object)("Cleared Fatigue for " + character.characterName)); } } } catch (Exception ex) { CursedSkullEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Fatigue: " + ex.Message)); } } } }
DizzinessMod.dll
Decompiled 19 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak.Afflictions; using Photon.Pun; using UnityEngine; using UnityEngine.UI; using Zorro.Core; using Zorro.Core.CLI; [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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 DizzinessMod { [HarmonyPatch(typeof(Action_ModifyStatus), "RunAction")] internal static class Action_ModifyStatus_Patch { private static readonly HashSet<ushort> healingItemIDs = new HashSet<ushort> { 24 }; private static FieldInfo itemField; private static FieldInfo characterField; private static PropertyInfo characterProperty; [HarmonyPostfix] private static void Postfix(Action_ModifyStatus __instance) { //IL_01a3: Unknown result type (might be due to invalid IL or missing references) if (itemField == null) { itemField = typeof(ItemActionBase).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic); } object? obj = itemField?.GetValue(__instance); Item val = (Item)((obj is Item) ? obj : null); if ((Object)(object)val == (Object)null || __instance.changeAmount >= 0f || !healingItemIDs.Contains(val.itemID)) { return; } if (characterProperty == null) { characterProperty = typeof(ItemActionBase).GetProperty("character", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } Character val2 = null; if (characterProperty != null) { object? value = characterProperty.GetValue(__instance); val2 = (Character)((value is Character) ? value : null); } if ((Object)(object)val2 == (Object)null) { if (characterField == null) { characterField = typeof(ItemActionBase).GetField("character", BindingFlags.Instance | BindingFlags.NonPublic); } object? obj2 = characterField?.GetValue(__instance); val2 = (Character)((obj2 is Character) ? obj2 : null); } if ((Object)(object)val2 == (Object)null) { DizzinessPlugin.Logger.LogWarning((object)$"Target character is null for item {((Object)val).name} (ID:{val.itemID})"); return; } DizzinessPlugin.Logger.LogInfo((object)$"Healing item used - Item: {((Object)val).name} (ID:{val.itemID}), Target: {val2.characterName}, Status: {__instance.statusType}, Amount: {__instance.changeAmount}"); if (val2.IsLocal) { if (val2.data.isSkeleton && !val2.data.dead && !val2.data.fullyPassedOut) { DizzinessPlugin.Logger.LogInfo((object)"Skipping dizziness reduction - target is a living skeleton"); return; } DizzinessTracker component = ((Component)val2).GetComponent<DizzinessTracker>(); if ((Object)(object)component != (Object)null) { float num = Mathf.Abs(__instance.changeAmount) * 0.1f; float dizzinessValue = component.dizzinessValue; component.dizzinessValue = Mathf.Max(0f, component.dizzinessValue - num); DizzinessPlugin.Logger.LogInfo((object)$"Reduced dizziness by {num:F3} (from {dizzinessValue:F3} to {component.dizzinessValue:F3})"); } else { DizzinessPlugin.Logger.LogWarning((object)("No DizzinessTracker found on " + val2.characterName)); } } else { DizzinessPlugin.Logger.LogInfo((object)("Skipping dizziness reduction - target is not local player: " + val2.characterName)); } } } [HarmonyPatch(typeof(CharacterData), "set_isSkeleton")] internal static class CharacterData_SetSkeleton_Patch { [HarmonyPostfix] private static void Postfix(CharacterData __instance, bool value) { if (!value) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.IsLocal) { return; } Component component2 = ((Component)component).GetComponent("DizzinessMod.DizzinessTracker"); if ((Object)(object)component2 != (Object)null) { FieldInfo field = ((object)component2).GetType().GetField("dizzinessValue", BindingFlags.Instance | BindingFlags.Public); if (field != null) { field.SetValue(component2, 0f); DizzinessPlugin.Logger.LogInfo((object)"Cleared dizziness on skeleton transformation"); } } } } [HarmonyPatch(typeof(BarAffliction), "ChangeAffliction")] internal static class BarAffliction_ChangeAffliction_Patch { [HarmonyPrefix] private static bool Prefix(BarAffliction __instance, StaminaBar bar) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)__instance).gameObject).name != "DizzinessCustomBar") { return true; } Character observedCharacter = Character.observedCharacter; if ((Object)observedCharacter == (Object)null) { return false; } DizzinessTracker component = ((Component)observedCharacter).GetComponent<DizzinessTracker>(); if ((Object)component == (Object)null) { return false; } float dizzinessValue = component.dizzinessValue; __instance.size = bar.fullBar.sizeDelta.x * dizzinessValue; if (dizzinessValue > 0.01f) { if (__instance.size < bar.minAfflictionWidth) { __instance.size = bar.minAfflictionWidth; } ((Component)__instance).gameObject.SetActive(true); } else { ((Component)__instance).gameObject.SetActive(false); } return false; } } [HarmonyPatch(typeof(CharacterAfflictions))] [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class CharacterAfflictions_statusSum_Patch { [HarmonyPostfix] private static void Postfix(CharacterAfflictions __instance, ref float __result) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if ((Object)__instance.character == (Object)null) { return; } DizzinessTracker component = ((Component)__instance.character).GetComponent<DizzinessTracker>(); if (!((Object)component == (Object)null) && !((Object)__instance.character.data == (Object)null)) { __result += component.dizzinessValue; if (__instance.character.data.fullyPassedOut && !component.isGrounded) { __result = Mathf.Max(__result, 1.01f); } } } } [HarmonyPatch(typeof(Character), "Awake")] internal static class Character_Awake_Patch { [HarmonyPostfix] private static void Postfix(Character __instance) { if ((Object)(object)((Component)__instance).GetComponent<DizzinessTracker>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<DizzinessTracker>(); } if ((Object)(object)((Component)__instance).GetComponent<DizzinessRpcReceiver>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<DizzinessRpcReceiver>(); } if ((Object)(object)((Component)__instance).GetComponent<DizzinessControlModifier>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<DizzinessControlModifier>(); } } } [HarmonyPatch(typeof(Character), "CheckJump")] internal static class Character_CheckJump_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, ref bool __result) { if (!__result) { return; } DizzinessTracker component = ((Component)__instance).GetComponent<DizzinessTracker>(); if (!((Object)(object)component == (Object)null)) { float dizzinessValue = component.dizzinessValue; if (dizzinessValue > 0.7f) { __result = false; } } } } [HarmonyPatch(typeof(Character), "HasMeaningfulTempStatuses")] internal static class Character_HasMeaningfulTempStatuses_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, ref bool __result) { DizzinessTracker component = ((Component)__instance).GetComponent<DizzinessTracker>(); if (!((Object)(object)component == (Object)null) && !__result && component.dizzinessValue > 0.05f) { __result = true; } } } [HarmonyPatch(typeof(ItemAction), "RunAction")] internal static class DebugItemPatch { private static FieldInfo itemField; [HarmonyPostfix] private static void Postfix(ItemAction __instance) { if (itemField == null) { itemField = typeof(ItemActionBase).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic); } object? obj = itemField?.GetValue(__instance); Item val = (Item)((obj is Item) ? obj : null); if ((Object)(object)val != (Object)null) { DizzinessPlugin.Logger.LogInfo((object)$"ItemAction.RunAction - Item: {((Object)val).name} (ID:{val.itemID}), Type: {((object)__instance).GetType().Name}"); } else { DizzinessPlugin.Logger.LogInfo((object)("ItemAction.RunAction - Item: NULL, Type: " + ((object)__instance).GetType().Name)); } } } public static class DizzinessBarInjector { public static BarAffliction injectedBar; private static bool injectionFailed; public static void TryInjectBar() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Invalid comparison between Unknown and I4 //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_0201: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) if ((Object)injectedBar != (Object)null || injectionFailed) { return; } try { if ((Object)GUIManager.instance == (Object)null) { return; } StaminaBar bar = GUIManager.instance.bar; if ((Object)bar == (Object)null || bar.afflictions == null || bar.afflictions.Length == 0) { return; } BarAffliction val = null; BarAffliction[] afflictions = bar.afflictions; BarAffliction[] array = afflictions; foreach (BarAffliction val2 in array) { if (!((Object)val2 == (Object)null) && (int)val2.afflictionType == 4) { val = val2; break; } } if ((Object)val == (Object)null) { DizzinessPlugin.Logger.LogWarning((object)"Crab template bar not found in StaminaBar.afflictions"); injectionFailed = true; return; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val3).name = "DizzinessCustomBar"; BarAffliction component = val3.GetComponent<BarAffliction>(); if ((Object)component == (Object)null) { DizzinessPlugin.Logger.LogError((object)"Cloned GameObject has no BarAffliction component"); Object.Destroy((Object)val3); injectionFailed = true; return; } if ((Object)DizzinessPlugin.DizzinessIconSprite != (Object)null && (Object)component.icon != (Object)null) { component.icon.sprite = DizzinessPlugin.DizzinessIconSprite; ((Graphic)component.icon).color = Color.white; } Image[] componentsInChildren = ((Component)component).GetComponentsInChildren<Image>(true); Image[] array2 = componentsInChildren; foreach (Image val4 in array2) { if (!((Object)component.icon != (Object)null) || !((Object)val4 == (Object)component.icon)) { Color dizzinessColor = DizzinessPlugin.DizzinessColor; dizzinessColor.a = ((Graphic)val4).color.a; ((Graphic)val4).color = dizzinessColor; } } component.size = 0f; val3.SetActive(false); FieldInfo field = typeof(StaminaBar).GetField("afflictions", BindingFlags.Instance | BindingFlags.Public); if (field == null) { DizzinessPlugin.Logger.LogError((object)"StaminaBar.afflictions field not found"); Object.Destroy((Object)val3); injectionFailed = true; return; } BarAffliction[] array3 = (BarAffliction[])field.GetValue(bar); BarAffliction[] array4 = (BarAffliction[])(object)new BarAffliction[array3.Length + 1]; Array.Copy(array3, array4, array3.Length); array4[array3.Length] = component; field.SetValue(bar, array4); injectedBar = component; DizzinessPlugin.Logger.LogInfo((object)$"Independent bar injected. New array size: {array4.Length}"); } catch (Exception arg) { DizzinessPlugin.Logger.LogError((object)$"Bar injection failed: {arg}"); injectionFailed = true; } } } public class DizzinessControlModifier : MonoBehaviour { private Character character; private DizzinessTracker tracker; private float originalMovementModifier; private bool wasPassedOut; [Header("Control Loss Settings")] [Tooltip("Curve mapping dizziness (0-1) to control (0-1). X-axis = dizziness, Y-axis = control")] public AnimationCurve controlReductionCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f); [Header("Thresholds")] [Range(0f, 1f)] public float wobbleStartThreshold = 0.3f; [Range(0f, 1f)] public float collapseThreshold = 0.9f; [Range(0f, 1f)] public float maxMovementReduction = 0.5f; private void Awake() { character = ((Component)this).GetComponent<Character>(); tracker = ((Component)this).GetComponent<DizzinessTracker>(); if ((Object)(object)character != (Object)null && (Object)(object)character.refs.movement != (Object)null) { originalMovementModifier = character.refs.movement.movementModifier; } } private void Update() { if (!((Object)(object)character == (Object)null) && !((Object)(object)tracker == (Object)null) && character.IsLocal) { float dizzinessValue = tracker.dizzinessValue; float num = RemapDizzinessToCurve(dizzinessValue); float num2 = controlReductionCurve.Evaluate(num); character.data.ragdollControlClamp = Mathf.Clamp01(num2); float num3 = 1f; if (dizzinessValue > wobbleStartThreshold) { float num4 = (dizzinessValue - wobbleStartThreshold) / (collapseThreshold - wobbleStartThreshold); num4 = Mathf.Clamp01(num4); num3 = Mathf.Lerp(1f, maxMovementReduction, num4); } character.refs.movement.movementModifier = originalMovementModifier * num3; } } private float RemapDizzinessToCurve(float dizziness) { if (dizziness <= wobbleStartThreshold) { return 0f; } if (dizziness >= collapseThreshold) { return 1f; } float num = (dizziness - wobbleStartThreshold) / (collapseThreshold - wobbleStartThreshold); return Mathf.Clamp01(num); } } [HarmonyPatch(typeof(CharacterMovement), "GetMovementForce")] internal static class CharacterMovement_GetMovementForce_Patch { [HarmonyPostfix] private static void Postfix(CharacterMovement __instance, ref float __result) { Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null) { return; } DizzinessTracker component2 = ((Component)component).GetComponent<DizzinessTracker>(); if (!((Object)(object)component2 == (Object)null)) { float dizzinessValue = component2.dizzinessValue; if (!(dizzinessValue <= 0.3f)) { float num = Mathf.Lerp(1f, 0.4f, (dizzinessValue - 0.3f) / 0.7f); __result *= num; } } } } [HarmonyPatch(typeof(CharacterInput), "Sample")] internal static class CharacterInput_Sample_Patch { private static Vector2 lastMovementInput; private static float lastInputTime; [HarmonyPrefix] private static void Prefix(CharacterInput __instance, bool playerMovementActive) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (!playerMovementActive) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null) { return; } DizzinessTracker component2 = ((Component)component).GetComponent<DizzinessTracker>(); if ((Object)(object)component2 == (Object)null) { return; } float dizzinessValue = component2.dizzinessValue; if (!(dizzinessValue <= 0.2f)) { float num = Mathf.Lerp(0f, 0.15f, dizzinessValue); if (Time.time - lastInputTime > num) { lastMovementInput = __instance.movementInput; lastInputTime = Time.time; } else { __instance.movementInput = lastMovementInput; } if (dizzinessValue > 0.6f) { float num2 = Mathf.Lerp(0f, 0.3f, (dizzinessValue - 0.6f) / 0.4f); __instance.movementInput += new Vector2(Random.Range(0f - num2, num2), Random.Range(0f - num2, num2)); __instance.movementInput = Vector2.ClampMagnitude(__instance.movementInput, 1f); } } } } public static class DizzinessDebugCommands { [ConsoleCommand] public static void ListAllItemsWithIDs() { try { ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance; if (instance?.itemLookup == null) { DizzinessPlugin.Logger.LogError((object)"ItemDatabase not found!"); return; } DizzinessPlugin.Logger.LogInfo((object)$"=== ITEM DATABASE ({instance.itemLookup.Count} items) ==="); foreach (KeyValuePair<ushort, Item> item in instance.itemLookup.OrderBy((KeyValuePair<ushort, Item> x) => ((Object)x.Value).name)) { DizzinessPlugin.Logger.LogInfo((object)$"ID: {item.Key} | Name: {((Object)item.Value).name}"); } DizzinessPlugin.Logger.LogInfo((object)$"=== END OF ITEM DATABASE ({instance.itemLookup.Count} items) ==="); } catch (Exception ex) { DizzinessPlugin.Logger.LogError((object)("ListAllItemsWithIDs failed: " + ex.Message)); } } public static void TestDizzinessReduction() { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { DizzinessPlugin.Logger.LogError((object)"No local character!"); return; } DizzinessTracker component = ((Component)localCharacter).GetComponent<DizzinessTracker>(); if ((Object)(object)component == (Object)null) { DizzinessPlugin.Logger.LogError((object)"No DizzinessTracker!"); return; } float dizzinessValue = component.dizzinessValue; component.dizzinessValue = Mathf.Max(0f, component.dizzinessValue - 0.5f); DizzinessPlugin.Logger.LogInfo((object)$"Test: Reduced dizziness from {dizzinessValue:F3} to {component.dizzinessValue:F3}"); } } [BepInPlugin("com.tambistudios.dizziness", "Dizziness Mod", "1.2.0")] public class DizzinessPlugin : BaseUnityPlugin { public const string MOD_GUID = "com.tambistudios.dizziness"; public const string MOD_NAME = "Dizziness Mod"; public const string MOD_VERSION = "1.2.0"; public static DizzinessPlugin Instance; public static ManualLogSource Logger; public static ConfigEntry<bool> debugMode; public const float SPEED_THRESHOLD = 7f; public const float DIZZINESS_GAIN_BASE = 0.0012f; public const float RECOVERY_PER_SEC = 0.05f; public const float REST_REQUIRED = 6f; public const float SUSTAINED_VELOCITY_DELAY = 0.25f; public const float DIZZINESS_REDUCTION_MULTIPLIER = 0.1f; public static readonly Color DizzinessColor = new Color(0.25f, 0.88f, 0.82f, 1f); public static Sprite DizzinessIconSprite; public const string CUSTOM_BAR_NAME = "DizzinessCustomBar"; private void Awake() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) Instance = this; Logger = ((BaseUnityPlugin)this).Logger; debugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugKeys", false, "Enables F5 (teleport 100m up), F7 (set dizziness 100%) and on-screen debug HUD."); LoadIconSprite(); try { new Harmony("com.tambistudios.dizziness").PatchAll(); Logger.LogInfo((object)"[Dizziness From Speed 1.2.0] Loaded."); } catch (Exception arg) { Logger.LogError((object)$"Harmony patch failed: {arg}"); } } private static void LoadIconSprite() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DizzinessMod.Assets.dizziness_icon.png"); if (stream == null) { Logger.LogWarning((object)"Embedded icon not found in resources!"); return; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; if (ImageConversion.LoadImage(val, memoryStream.ToArray())) { DizzinessIconSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); Logger.LogInfo((object)$"Icon loaded: {((Texture)val).width}x{((Texture)val).height}"); } } catch (Exception arg) { Logger.LogError((object)$"LoadIconSprite failed: {arg}"); } } public static float GetEtcDamageMultiplier() { try { return Ascents.etcDamageMultiplier; } catch { return 1f; } } public static bool IsDizzinessDisabled() { return GetEtcDamageMultiplier() <= 0.001f; } public static float GetGainMultiplier() { float etcDamageMultiplier = GetEtcDamageMultiplier(); if (etcDamageMultiplier <= 0.001f) { return 0f; } if (etcDamageMultiplier <= 0.6f) { return 1f; } if (etcDamageMultiplier <= 1.5f) { return 3f; } return 5f; } private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if ((Object)localCharacter != (Object)null && (Object)((Component)localCharacter).GetComponent<DizzinessTracker>() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent<DizzinessTracker>(); if ((Object)((Component)localCharacter).GetComponent<DizzinessRpcReceiver>() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent<DizzinessRpcReceiver>(); } Logger.LogInfo((object)"DizzinessTracker attached (fallback)."); } DizzinessBarInjector.TryInjectBar(); if (!debugMode.Value || !((Object)localCharacter != (Object)null)) { return; } if (Input.GetKeyDown((KeyCode)286)) { Rigidbody playerRigidbody = DizzinessTracker.GetPlayerRigidbody(localCharacter); if ((Object)playerRigidbody != (Object)null) { Transform transform = ((Component)playerRigidbody).transform; transform.position += Vector3.up * 100f; Logger.LogInfo((object)"[F5] Teleported +100m up."); } } if (Input.GetKeyDown((KeyCode)288)) { DizzinessTracker component = ((Component)localCharacter).GetComponent<DizzinessTracker>(); if ((Object)component != (Object)null) { component.dizzinessValue = 1f; Logger.LogInfo((object)"[F7] Forced dizziness = 1.0"); } } } private void OnGUI() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown if (!debugMode.Value) { return; } Character localCharacter = Character.localCharacter; if ((Object)localCharacter == (Object)null) { return; } DizzinessTracker component = ((Component)localCharacter).GetComponent<DizzinessTracker>(); if (!((Object)component == (Object)null)) { GUIStyle val = new GUIStyle(); val.fontSize = 18; val.normal.textColor = Color.white; float num = 0f; Rigidbody playerRigidbody = DizzinessTracker.GetPlayerRigidbody(localCharacter); if ((Object)playerRigidbody != (Object)null) { Vector3 linearVelocity = playerRigidbody.linearVelocity; num = ((Vector3)(ref linearVelocity)).magnitude; } float etcDamageMultiplier = GetEtcDamageMultiplier(); float gainMultiplier = GetGainMultiplier(); string text = (IsDizzinessDisabled() ? "DISABLED" : $"x{gainMultiplier:F0}"); float statusSum = localCharacter.refs.afflictions.statusSum; float maxStamina = localCharacter.GetMaxStamina(); float currentStamina = localCharacter.data.currentStamina; GUI.Label(new Rect(20f, 100f, 700f, 30f), $"Speed: {num:F1} Dizziness: {component.dizzinessValue:F3} etcMult: {etcDamageMultiplier:F2} ({text})", val); GUI.Label(new Rect(20f, 122f, 700f, 30f), $"Ground: {component.isGrounded} Climb: {component.isClimbing} Resting: {component.IsResting} RestTimer: {component.restTimer:F2}/{6f}", val); GUI.Label(new Rect(20f, 144f, 700f, 30f), $"FullyOut: {localCharacter.data.fullyPassedOut} Sum: {statusSum:F2} MaxStam: {maxStamina:F2} CurStam: {currentStamina:F2}", val); GUI.Label(new Rect(20f, 166f, 700f, 30f), "CustomBar: " + (((Object)DizzinessBarInjector.injectedBar != (Object)null) ? "OK" : "missing"), val); } } } public class DizzinessRpcReceiver : MonoBehaviourPun { [PunRPC] public void Dizziness_RPC_Sync(float value) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown DizzinessTracker component = ((Component)this).GetComponent<DizzinessTracker>(); if ((Object)component != (Object)null && !component.character.IsLocal) { component.dizzinessValue = Mathf.Clamp01(value); } } } public class DizzinessTracker : MonoBehaviour { private float sustainedVelocityTimer; private float lastHighVelocityTime; public Character character; public float dizzinessValue; public float restTimer; public bool isGrounded; public bool isClimbing; private bool wasFullyPassedOut; private float lastSyncSent; private const float SYNC_INTERVAL = 0.2f; private Rigidbody _cachedRb; private static FieldInfo _groundedField; private static bool _groundedFieldSearched; private static FieldInfo[] _climbingFields; private static bool _climbingFieldsSearched; public bool IsResting { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //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) if (isClimbing) { return false; } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if ((Object)playerRigidbody == (Object)null) { return false; } Vector3 linearVelocity = playerRigidbody.linearVelocity; return ((Vector3)(ref linearVelocity)).magnitude < 7f; } } public static Rigidbody GetPlayerRigidbody(Character c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if ((Object)c == (Object)null) { return null; } DizzinessTracker component = ((Component)c).GetComponent<DizzinessTracker>(); if ((Object)component != (Object)null) { if ((Object)component._cachedRb != (Object)null) { return component._cachedRb; } component._cachedRb = ((Component)c).GetComponentInChildren<Rigidbody>(); return component._cachedRb; } return ((Component)c).GetComponentInChildren<Rigidbody>(); } private void Awake() { character = ((Component)this).GetComponent<Character>(); } private bool IsSkeleton() { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return false; } if (character.data.isSkeleton && !character.data.dead && !character.data.fullyPassedOut) { return true; } return false; } private void Update() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown if ((Object)character == (Object)null || !character.IsLocal) { return; } isGrounded = DetectGrounded(); isClimbing = DetectClimbing(); bool fullyPassedOut = character.data.fullyPassedOut; if (wasFullyPassedOut && !fullyPassedOut) { float maxStamina = character.GetMaxStamina(); if (maxStamina > 0.001f) { character.data.currentStamina = maxStamina; DizzinessPlugin.Logger.LogInfo((object)$"Recovered from pass-out: stamina restored to {maxStamina:F2}"); } } wasFullyPassedOut = fullyPassedOut; if (DizzinessPlugin.IsDizzinessDisabled()) { if (dizzinessValue > 0f) { dizzinessValue = Mathf.Max(0f, dizzinessValue - 0.05f * Time.deltaTime); MaybeSendSync(); } } else { UpdateLocalDizziness(); MaybeSendSync(); } character.ClampStamina(); } private bool DetectGrounded() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (!_groundedFieldSearched) { _groundedFieldSearched = true; if ((Object)character.data != (Object)null) { FieldInfo field = ((object)character.data).GetType().GetField("isGrounded", BindingFlags.Instance | BindingFlags.Public); if (field != null && field.FieldType == typeof(bool)) { _groundedField = field; DizzinessPlugin.Logger.LogInfo((object)"Ground detect: using character.data.isGrounded"); } } } if (_groundedField != null && (Object)character.data != (Object)null) { try { return (bool)_groundedField.GetValue(character.data); } catch { } } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if ((Object)playerRigidbody == (Object)null) { return false; } return Physics.Raycast(((Component)playerRigidbody).transform.position + Vector3.up * 0.5f, Vector3.down, 1.5f, -1, (QueryTriggerInteraction)1); } private bool DetectClimbing() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown if (!_climbingFieldsSearched) { _climbingFieldsSearched = true; if ((Object)character.data != (Object)null) { Type type = ((object)character.data).GetType(); string[] array = new string[3] { "isClimbing", "isRopeClimbing", "isVineClimbing" }; List<FieldInfo> list = new List<FieldInfo>(); string[] array2 = array; string[] array3 = array2; foreach (string text in array3) { FieldInfo field = type.GetField(text, BindingFlags.Instance | BindingFlags.Public); if (field != null && field.FieldType == typeof(bool)) { list.Add(field); DizzinessPlugin.Logger.LogInfo((object)("Climb detect: found character.data." + text)); } } _climbingFields = list.ToArray(); } } if (_climbingFields == null || (Object)character.data == (Object)null) { return false; } try { FieldInfo[] climbingFields = _climbingFields; for (int j = 0; j < climbingFields.Length; j++) { if ((bool)climbingFields[j].GetValue(character.data)) { return true; } } } catch { } return false; } private bool IsInvincible() { if ((Object)(object)character == (Object)null || character.refs == null || (Object)(object)character.refs.afflictions == (Object)null) { return false; } Affliction val = default(Affliction); if (character.refs.afflictions.HasAfflictionType((AfflictionType)14, ref val)) { return true; } if (character.refs.afflictions.HasAfflictionType((AfflictionType)16, ref val)) { return true; } return false; } private void UpdateLocalDizziness() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006a: 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) if (IsResting && !character.data.fullyPassedOut) { restTimer += Time.deltaTime; } else { restTimer = 0f; } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if (!((Object)playerRigidbody == (Object)null)) { Vector3 linearVelocity = playerRigidbody.linearVelocity; float magnitude = ((Vector3)(ref linearVelocity)).magnitude; if (magnitude > 7f) { sustainedVelocityTimer += Time.deltaTime; lastHighVelocityTime = Time.time; } else { sustainedVelocityTimer = Mathf.Max(0f, sustainedVelocityTimer - Time.deltaTime * 2f); } if (!IsInvincible() && !IsSkeleton() && magnitude > 7f && sustainedVelocityTimer >= 0.25f) { float gainMultiplier = DizzinessPlugin.GetGainMultiplier(); float num = magnitude - 7f; float num2 = num * num * 0.0012f * gainMultiplier; float num3 = Mathf.Lerp(1f, 0.1f, dizzinessValue / 0.8f); num2 *= num3; dizzinessValue = Mathf.Min(1f, dizzinessValue + num2 * Time.deltaTime); } if (!IsSkeleton() && ((IsResting && restTimer >= 6f) || character.data.fullyPassedOut)) { dizzinessValue = Mathf.Max(0f, dizzinessValue - 0.05f * Time.deltaTime); } } } private void MaybeSendSync() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if (Time.time - lastSyncSent < 0.2f) { return; } lastSyncSent = Time.time; PhotonView component = ((Component)character).GetComponent<PhotonView>(); if ((Object)component == (Object)null || !PhotonNetwork.InRoom) { return; } try { component.RPC("Dizziness_RPC_Sync", (RpcTarget)1, new object[1] { dizzinessValue }); } catch (Exception ex) { DizzinessPlugin.Logger.LogWarning((object)("RPC send failed: " + ex.Message)); } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class Item_OnConsumed_Patch { [HarmonyPostfix] private static void Postfix(Item __instance, ref Action __result) { DizzinessPlugin.Logger.LogInfo((object)$"Item.OnConsumed accessed for: {((Object)__instance).name} (ID:{__instance.itemID})"); } } }
FaerieLanternEnhanced.dll
Decompiled 19 hours 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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("FaerieLanternEnhanced")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b0ca20efa02412f153573223d64426edebafe134")] [assembly: AssemblyProduct("FaerieLanternEnhanced")] [assembly: AssemblyTitle("FaerieLanternEnhanced")] [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 FaerieLanternEnhanced { [BepInPlugin("jill920.faerielanternenhanced", "Faerie Lantern Enhanced", "1.0.1")] public class FaerieLanternEnhancedPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.faerielanternenhanced"; public const string MOD_NAME = "Faerie Lantern Enhanced"; public const string MOD_VERSION = "1.0.1"; public static FaerieLanternEnhancedPlugin Instance; public static ManualLogSource Logger; public static bool IsDizzinessModInstalled = false; public static bool IsFatigueModInstalled = false; public static bool debugMode = false; public static float dizzinessHealRate = 0.025f; public static float fatigueHealRate = 0.025f; public static float effectRadius = 7.2f; private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; debugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableLogs", false, "Enable debug logging").Value; dizzinessHealRate = ((BaseUnityPlugin)this).Config.Bind<float>("Healing", "DizzinessHealRate", 0.025f, "Dizziness reduction per second while near lit Faerie Lantern").Value; fatigueHealRate = ((BaseUnityPlugin)this).Config.Bind<float>("Healing", "FatigueHealRate", 0.025f, "Fatigue reduction per second while near lit Faerie Lantern").Value; effectRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Healing", "EffectRadius", 7.2f, "Radius in meters for lantern healing effects").Value; CheckForInstalledMods(); try { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "jill920.faerielanternenhanced"); Logger.LogInfo((object)"[Faerie Lantern Enhanced 1.0.1] Loaded successfully!"); Logger.LogInfo((object)$" Dizziness Mod detected: {IsDizzinessModInstalled}"); Logger.LogInfo((object)$" Fatigue Mod detected: {IsFatigueModInstalled}"); Logger.LogInfo((object)$" Dizziness heal rate: {dizzinessHealRate}/s"); Logger.LogInfo((object)$" Fatigue heal rate: {fatigueHealRate}/s"); Logger.LogInfo((object)$" Effect radius: {effectRadius}m"); } 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 { } } if (!IsFatigueModInstalled) { try { IsFatigueModInstalled = Type.GetType("FatigueMod.FatigueTracker, Assembly-CSharp") != null; } catch { } } if (!IsDizzinessModInstalled) { try { IsDizzinessModInstalled = Type.GetType("DizzinessMod.DizzinessTracker, Assembly-CSharp") != null; } catch { } } } } } namespace FaerieLanternEnhanced.Patches { [HarmonyPatch(typeof(ItemCooking), "RPC_CookingExplode")] internal static class ItemCooking_Explode_Patch { private const int FAERIE_LANTERN_ID = 43; private const float EXPLOSION_RADIUS = 4.8f; 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 (FaerieLanternEnhancedPlugin.IsFatigueModInstalled) { _fatigueAvailable = true; return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("FatigueMod.FatigueTracker") != null) { _fatigueAvailable = true; FaerieLanternEnhancedPlugin.IsFatigueModInstalled = true; FaerieLanternEnhancedPlugin.Logger.LogInfo((object)"Faerie Lantern Explosion: Fatigue Mod detected at runtime!"); return true; } } } catch { } return false; } private static bool IsDizzinessModPresent() { if (_dizzinessCheckDone) { return _dizzinessAvailable; } _dizzinessCheckDone = true; if (FaerieLanternEnhancedPlugin.IsDizzinessModInstalled) { _dizzinessAvailable = true; return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("DizzinessMod.DizzinessTracker") != null) { _dizzinessAvailable = true; FaerieLanternEnhancedPlugin.IsDizzinessModInstalled = true; FaerieLanternEnhancedPlugin.Logger.LogInfo((object)"Faerie Lantern Explosion: Dizziness Mod detected at runtime!"); return true; } } } catch { } return false; } [HarmonyPrefix] private static void Prefix(ItemCooking __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Item item = ((ItemComponent)__instance).item; if ((Object)(object)item == (Object)null || item.itemID != 43) { return; } Vector3 position = ((Component)__instance).transform.position; bool flag = IsDizzinessModPresent(); bool flag2 = IsFatigueModPresent(); foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter == (Object)null) { continue; } float num = Vector3.Distance(position, allCharacter.Center); if (!(num > 4.8f)) { float num2 = 1f - num / 4.8f; float amount = -0.25f * num2; if (flag) { AddDizziness(allCharacter, amount); } if (flag2) { AddFatigue(allCharacter, amount); } } } FaerieLanternEnhancedPlugin.Logger.LogInfo((object)$"Faerie Lantern explosion: Applied status restoration within {4.8f}m"); } private static void AddDizziness(Character character, float amount) { 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)) { float num = (float)field.GetValue(component); float num2 = Mathf.Clamp01(num + amount); field.SetValue(component, num2); if (FaerieLanternEnhancedPlugin.debugMode) { FaerieLanternEnhancedPlugin.Logger.LogInfo((object)$"Explosion changed Dizziness: {num:F3} → {num2:F3} ({amount:F3})"); } } } catch (Exception ex) { FaerieLanternEnhancedPlugin.Logger.LogWarning((object)("Failed to modify Dizziness: " + ex.Message)); } } private static void AddFatigue(Character character, float amount) { 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; } float num = (float)field.GetValue(component); float num2 = Mathf.Clamp01(num + amount); field.SetValue(component, num2); if (amount < 0f && num2 < num) { FieldInfo field2 = ((object)component).GetType().GetField("pendingStaminaFromActions", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(component, 0f); } } if (FaerieLanternEnhancedPlugin.debugMode) { FaerieLanternEnhancedPlugin.Logger.LogInfo((object)$"Explosion changed Fatigue: {num:F3} → {num2:F3} ({amount:F3})"); } } catch (Exception ex) { FaerieLanternEnhancedPlugin.Logger.LogWarning((object)("Failed to modify Fatigue: " + ex.Message)); } } } [HarmonyPatch(typeof(Lantern), "Update")] internal static class Lantern_Update_Patch { private const int FAERIE_LANTERN_ID = 43; private static FieldInfo _litField; private static bool _fatigueCheckDone; private static bool _fatigueAvailable; private static bool IsLit(Lantern lantern) { if (_litField == null) { _litField = typeof(Lantern).GetField("lit", BindingFlags.Instance | BindingFlags.NonPublic); } return _litField != null && (bool)_litField.GetValue(lantern); } private static bool IsFatigueModPresent() { if (_fatigueCheckDone) { return _fatigueAvailable; } _fatigueCheckDone = true; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("FatigueMod.FatigueTracker") != null) { _fatigueAvailable = true; FaerieLanternEnhancedPlugin.IsFatigueModInstalled = true; FaerieLanternEnhancedPlugin.Logger.LogInfo((object)"Fatigue Mod detected at runtime!"); return true; } } } catch { } return false; } private static bool IsDizzinessModPresent() { if (FaerieLanternEnhancedPlugin.IsDizzinessModInstalled) { return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("DizzinessMod.DizzinessTracker") != null) { FaerieLanternEnhancedPlugin.IsDizzinessModInstalled = true; return true; } } } catch { } return false; } [HarmonyPostfix] private static void Postfix(Lantern __instance) { //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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((ItemComponent)__instance).item == (Object)null || ((ItemComponent)__instance).item.itemID != 43 || !IsLit(__instance)) { return; } Vector3 position = ((Component)__instance).transform.position; float effectRadius = FaerieLanternEnhancedPlugin.effectRadius; float deltaTime = Time.deltaTime; bool flag = IsDizzinessModPresent(); bool flag2 = IsFatigueModPresent(); if (!flag && !flag2) { return; } foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter == (Object)null) { continue; } float num = Vector3.Distance(position, allCharacter.Center); if (!(num > effectRadius)) { if (flag) { ReduceDizziness(allCharacter, FaerieLanternEnhancedPlugin.dizzinessHealRate * deltaTime); } if (flag2) { ReduceFatigue(allCharacter, FaerieLanternEnhancedPlugin.fatigueHealRate * deltaTime); } if (FaerieLanternEnhancedPlugin.debugMode) { FaerieLanternEnhancedPlugin.Logger.LogInfo((object)$"Faerie Lantern healing {allCharacter.characterName} (dist={num:F2}m)"); } } } } private static void ReduceDizziness(Character character, float amount) { 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)) { float num = (float)field.GetValue(component); float num2 = Mathf.Max(0f, num - amount); field.SetValue(component, num2); if (FaerieLanternEnhancedPlugin.debugMode && amount > 0.001f) { FaerieLanternEnhancedPlugin.Logger.LogInfo((object)$"Reduced Dizziness: {num:F3} → {num2:F3} (-{amount:F3})"); } } } catch (Exception ex) { FaerieLanternEnhancedPlugin.Logger.LogWarning((object)("Failed to reduce Dizziness: " + ex.Message)); } } private static void ReduceFatigue(Character character, float amount) { 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); float num2 = Mathf.Max(0f, num - amount); field.SetValue(component, num2); if (field2 != null && amount > 0.001f && num > 0.001f) { float num3 = (float)field2.GetValue(component); if (num3 > 0f) { float num4 = num3 * (amount / num); field2.SetValue(component, Mathf.Max(0f, num3 - num4)); } } if (FaerieLanternEnhancedPlugin.debugMode && amount > 0.001f) { FaerieLanternEnhancedPlugin.Logger.LogInfo((object)$"Reduced Fatigue: {num:F3} → {num2:F3} (-{amount:F3})"); } } catch (Exception ex) { FaerieLanternEnhancedPlugin.Logger.LogWarning((object)("Failed to reduce Fatigue: " + ex.Message)); } } } }
FatigueMod.dll
Decompiled 19 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak.Afflictions; using Photon.Pun; using UnityEngine; using UnityEngine.UI; [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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 FatigueMod { [HarmonyPatch(typeof(Action_GiveExtraStamina), "RunAction")] internal static class Action_GiveExtraStamina_Patch { private static FieldInfo characterField; [HarmonyPostfix] private static void Postfix(Action_GiveExtraStamina __instance) { if (characterField == null) { characterField = typeof(ItemActionBase).GetField("character", BindingFlags.Instance | BindingFlags.NonPublic); } object? obj = characterField?.GetValue(__instance); Character val = (Character)((obj is Character) ? obj : null); if ((Object)(object)val == (Object)null || !val.IsLocal) { return; } FatigueTracker component = ((Component)val).GetComponent<FatigueTracker>(); if ((Object)(object)component == (Object)null) { return; } if (val.data.isSkeleton && !val.data.dead && !val.data.fullyPassedOut) { if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)"Skipping fatigue reduction - target is a living skeleton"); } return; } float amount = __instance.amount; float num = amount * FatiguePlugin.extraStaminaFatigueReductionRatio.Value; float fatigueValue = component.fatigueValue; component.fatigueValue = Mathf.Max(0f, component.fatigueValue - num); if (FatiguePlugin.debugMode.Value && num > 0.001f) { FatiguePlugin.Logger.LogInfo((object)($"Extra stamina ({amount:F2}) reduced fatigue by {num:F3} " + $"(from {fatigueValue:F3} to {component.fatigueValue:F3})")); } } } [HarmonyPatch(typeof(Action_ModifyStatus), "RunAction")] internal static class Action_ModifyStatus_Patch { private static readonly HashSet<ushort> healingItemIDs = new HashSet<ushort> { 24 }; private static FieldInfo itemField; private static FieldInfo characterField; private static PropertyInfo characterProperty; [HarmonyPostfix] private static void Postfix(Action_ModifyStatus __instance) { if (itemField == null) { itemField = typeof(ItemActionBase).GetField("item", BindingFlags.Instance | BindingFlags.NonPublic); } object? obj = itemField?.GetValue(__instance); Item val = (Item)((obj is Item) ? obj : null); if ((Object)(object)val == (Object)null || __instance.changeAmount >= 0f || !healingItemIDs.Contains(val.itemID)) { return; } if (characterProperty == null) { characterProperty = typeof(ItemActionBase).GetProperty("character", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } Character val2 = null; if (characterProperty != null) { object? value = characterProperty.GetValue(__instance); val2 = (Character)((value is Character) ? value : null); } if (val2.data.isSkeleton && !val2.data.dead && !val2.data.fullyPassedOut) { if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)"Skipping fatigue reduction - target is a living skeleton"); } return; } if ((Object)(object)val2 == (Object)null) { if (characterField == null) { characterField = typeof(ItemActionBase).GetField("character", BindingFlags.Instance | BindingFlags.NonPublic); } object? obj2 = characterField?.GetValue(__instance); val2 = (Character)((obj2 is Character) ? obj2 : null); } if (!((Object)(object)val2 == (Object)null) && val2.IsLocal) { FatigueTracker component = ((Component)val2).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null)) { float num = Mathf.Abs(__instance.changeAmount) * FatiguePlugin.fatigueReductionMultiplier.Value; component.fatigueValue = Mathf.Max(0f, component.fatigueValue - num); } } } } [HarmonyPatch(typeof(CharacterData), "set_isSkeleton")] internal static class CharacterData_SetSkeleton_Patch { [HarmonyPostfix] private static void Postfix(CharacterData __instance, bool value) { if (!value) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.IsLocal) { return; } Component component2 = ((Component)component).GetComponent("FatigueMod.FatigueTracker"); if ((Object)(object)component2 != (Object)null) { FieldInfo field = ((object)component2).GetType().GetField("fatigueValue", BindingFlags.Instance | BindingFlags.Public); if (field != null) { field.SetValue(component2, 0f); FatiguePlugin.Logger.LogInfo((object)"Cleared fatigue on skeleton transformation"); } } } } [HarmonyPatch(typeof(BarAffliction), "ChangeAffliction")] internal static class BarAffliction_ChangeAffliction_Patch { [HarmonyPrefix] private static bool Prefix(BarAffliction __instance, StaminaBar bar) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)__instance).gameObject).name != "FatigueCustomBar") { return true; } Character observedCharacter = Character.observedCharacter; if ((Object)observedCharacter == (Object)null) { return false; } FatigueTracker component = ((Component)observedCharacter).GetComponent<FatigueTracker>(); if ((Object)component == (Object)null) { return false; } float fatigueValue = component.fatigueValue; __instance.size = bar.fullBar.sizeDelta.x * fatigueValue; if (fatigueValue > 0.01f) { if (__instance.size < bar.minAfflictionWidth) { __instance.size = bar.minAfflictionWidth; } ((Component)__instance).gameObject.SetActive(true); } else { ((Component)__instance).gameObject.SetActive(false); } if (FatiguePlugin.debugMode.Value && Mathf.Abs(fatigueValue - FatiguePlugin._lastLoggedFatigue) > 0.05f) { FatiguePlugin._lastLoggedFatigue = fatigueValue; FatiguePlugin.Logger.LogInfo((object)$"Fatigue bar updated: value={fatigueValue:F3}, size={__instance.size:F1}"); } return false; } } [HarmonyPatch(typeof(BarAffliction), "UpdateAffliction")] internal static class BarAffliction_UpdateAffliction_Patch { [HarmonyPrefix] private static bool Prefix(BarAffliction __instance, StaminaBar bar) { if (((Object)((Component)__instance).gameObject).name != "FatigueCustomBar") { return true; } __instance.width = Mathf.Lerp(__instance.width, __instance.size, Mathf.Min(Time.deltaTime * 10f, 0.1f)); return false; } } [HarmonyPatch(typeof(CharacterAfflictions))] [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class CharacterAfflictions_statusSum_Patch { [HarmonyPostfix] private static void Postfix(CharacterAfflictions __instance, ref float __result) { if (!((Object)(object)__instance.character == (Object)null)) { FatigueTracker component = ((Component)__instance.character).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null)) { __result += component.fatigueValue; } } } } [HarmonyPatch(typeof(Character), "AddExtraStamina")] internal static class Character_AddExtraStamina_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, float add) { if (!__instance.IsLocal || add <= 0f) { return; } FatigueTracker component = ((Component)__instance).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null)) { float num = add / 5f; float fatigueValue = component.fatigueValue; component.fatigueValue = Mathf.Max(0f, component.fatigueValue - num); if (FatiguePlugin.debugMode.Value && num > 0.001f) { FatiguePlugin.Logger.LogInfo((object)($"AddExtraStamina ({add:F2}) reduced fatigue by {num:F3} " + $"(from {fatigueValue:F3} to {component.fatigueValue:F3})")); } } } } [HarmonyPatch(typeof(Character), "Awake")] internal static class Character_Awake_Patch { [HarmonyPostfix] private static void Postfix(Character __instance) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if ((Object)((Component)__instance).GetComponent<FatigueTracker>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<FatigueTracker>(); } if ((Object)((Component)__instance).GetComponent<FatigueRpcReceiver>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<FatigueRpcReceiver>(); } } } [HarmonyPatch(typeof(Character), "HasMeaningfulTempStatuses")] internal static class Character_HasMeaningfulTempStatuses_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, ref bool __result) { FatigueTracker component = ((Component)__instance).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null) && !__result && component.fatigueValue > 0.05f) { __result = true; } } } [HarmonyPatch(typeof(Character), "UseStamina")] public static class Character_UseStamina_Patch { [HarmonyPostfix] public static void Postfix(Character __instance, float usage, bool useBonusStamina, ref bool __result) { if (__result && !(usage <= 0f) && !FatiguePlugin.IsFatigueDisabled()) { FatigueTracker component = ((Component)__instance).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null)) { component.OnStaminaUsed(usage); } } } } public static class FatigueBarInjector { public static BarAffliction injectedBar; private static bool injectionFailed; public static void TryInjectBar() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Invalid comparison between Unknown and I4 //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Expected O, but got Unknown //IL_0201: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) if ((Object)injectedBar != (Object)null || injectionFailed) { return; } try { if ((Object)GUIManager.instance == (Object)null) { return; } StaminaBar bar = GUIManager.instance.bar; if ((Object)bar == (Object)null || bar.afflictions == null || bar.afflictions.Length == 0) { return; } BarAffliction val = null; BarAffliction[] afflictions = bar.afflictions; BarAffliction[] array = afflictions; foreach (BarAffliction val2 in array) { if (!((Object)val2 == (Object)null) && (int)val2.afflictionType == 4) { val = val2; break; } } if ((Object)val == (Object)null) { FatiguePlugin.Logger.LogWarning((object)"Crab template bar not found in StaminaBar.afflictions"); injectionFailed = true; return; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val3).name = "FatigueCustomBar"; BarAffliction component = val3.GetComponent<BarAffliction>(); if ((Object)component == (Object)null) { FatiguePlugin.Logger.LogError((object)"Cloned GameObject has no BarAffliction component"); Object.Destroy((Object)val3); injectionFailed = true; return; } if ((Object)FatiguePlugin.FatigueIconSprite != (Object)null && (Object)component.icon != (Object)null) { component.icon.sprite = FatiguePlugin.FatigueIconSprite; ((Graphic)component.icon).color = Color.white; } Image[] componentsInChildren = ((Component)component).GetComponentsInChildren<Image>(true); Image[] array2 = componentsInChildren; foreach (Image val4 in array2) { if (!((Object)component.icon != (Object)null) || !((Object)val4 == (Object)component.icon)) { Color fatigueColor = FatiguePlugin.FatigueColor; fatigueColor.a = ((Graphic)val4).color.a; ((Graphic)val4).color = fatigueColor; } } component.size = 0f; val3.SetActive(false); FieldInfo field = typeof(StaminaBar).GetField("afflictions", BindingFlags.Instance | BindingFlags.Public); if (field == null) { FatiguePlugin.Logger.LogError((object)"StaminaBar.afflictions field not found"); Object.Destroy((Object)val3); injectionFailed = true; return; } BarAffliction[] array3 = (BarAffliction[])field.GetValue(bar); BarAffliction[] array4 = (BarAffliction[])(object)new BarAffliction[array3.Length + 1]; Array.Copy(array3, array4, array3.Length); array4[array3.Length] = component; field.SetValue(bar, array4); injectedBar = component; if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)$"Independent bar injected. New array size: {array4.Length}"); } } catch (Exception arg) { FatiguePlugin.Logger.LogError((object)$"Bar injection failed: {arg}"); injectionFailed = true; } } } [BepInPlugin("jill920.fatiguefromstamina", "Fatigue Mod", "1.0.1")] public class FatiguePlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.fatiguefromstamina"; public static float _lastLoggedFatigue = -1f; public const string MOD_NAME = "Fatigue Mod"; public const string MOD_VERSION = "1.0.1"; public static FatiguePlugin Instance; public static ManualLogSource Logger; public static ConfigEntry<bool> debugMode; public const float FATIGUE_PER_STAMINA = 0.04f; public static readonly Color FatigueColor = new Color(1f, 0.5f, 0f, 1f); public static Sprite FatigueIconSprite; public const string CUSTOM_BAR_NAME = "FatigueCustomBar"; public static ConfigEntry<float> fatigueReductionMultiplier; public static ConfigEntry<string> healingItemsConfig; public static ConfigEntry<float> extraStaminaFatigueReductionRatio; public const float RECOVERY_START_DELAY = 6f; public const float RECOVERY_RAMP_UP_DURATION = 32f; public const float RECOVERY_POWER = 1.8f; public const float MAX_RECOVERY_RATE = 0.012f; public const float MIN_RECOVERY_RATE = 0.001f; public const float PLAY_DEAD_RECOVERY_MULTIPLIER = 2f; private void Awake() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown fatigueReductionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Healing", "FatigueReductionMultiplier", 0.07f, "Multiplier for fatigue reduction when using healing items.\n1.0 = remove same amount as status (e.g., 0.35 fatigue for 0.35 status removed)\n0.5 = remove half\n0 = disable"); healingItemsConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Healing", "HealingItemIDs", "24", "Comma-separated list of item IDs that reduce fatigue when used"); extraStaminaFatigueReductionRatio = ((BaseUnityPlugin)this).Config.Bind<float>("Recovery", "ExtraStaminaFatigueReductionRatio", 0.4f, "Amount of fatigue removed per unit of extra stamina given.\nExample: 0.2 = remove 0.2 fatigue for every 1.0 extra stamina"); Instance = this; Logger = ((BaseUnityPlugin)this).Logger; debugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugKeys", false, "..."); LoadIconSprite(); try { Harmony val = new Harmony("jill920.fatiguefromstamina"); val.PatchAll(Assembly.GetExecutingAssembly()); IEnumerable<MethodBase> patchedMethods = val.GetPatchedMethods(); foreach (MethodBase item in patchedMethods) { Logger.LogInfo((object)("Patched: " + item.DeclaringType?.Name + "." + item.Name)); } Logger.LogInfo((object)"[Fatigue From Stamina 1.0.1] Loaded."); } catch (Exception arg) { Logger.LogError((object)$"Harmony patch failed: {arg}"); } } private static void LoadIconSprite() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FatigueMod.Assets.fatigue_icon.png"); if (stream == null) { Logger.LogWarning((object)"Embedded icon not found in resources!"); return; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)1; if (ImageConversion.LoadImage(val, memoryStream.ToArray())) { FatigueIconSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); Logger.LogInfo((object)$"Icon loaded: {((Texture)val).width}x{((Texture)val).height}"); } } catch (Exception arg) { Logger.LogError((object)$"LoadIconSprite failed: {arg}"); } } public static float GetEtcDamageMultiplier() { try { return Ascents.etcDamageMultiplier; } catch { return 1f; } } public static bool IsFatigueDisabled() { return GetEtcDamageMultiplier() <= 0.001f; } public static float GetGainMultiplier() { float etcDamageMultiplier = GetEtcDamageMultiplier(); if (etcDamageMultiplier <= 0.001f) { return 0f; } if (etcDamageMultiplier <= 0.6f) { return 1f; } if (etcDamageMultiplier <= 1.5f) { return 3f; } return 5f; } private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown Character localCharacter = Character.localCharacter; if ((Object)localCharacter != (Object)null && (Object)((Component)localCharacter).GetComponent<FatigueTracker>() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent<FatigueTracker>(); if ((Object)((Component)localCharacter).GetComponent<FatigueRpcReceiver>() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent<FatigueRpcReceiver>(); } Logger.LogInfo((object)"FatigueTracker attached (fallback)."); } FatigueBarInjector.TryInjectBar(); if (debugMode.Value && (Object)localCharacter != (Object)null && Input.GetKeyDown((KeyCode)288)) { FatigueTracker component = ((Component)localCharacter).GetComponent<FatigueTracker>(); if ((Object)component != (Object)null) { component.fatigueValue = 0.5f; Logger.LogInfo((object)"[F7] Forced fatigue = 0.5"); } } } private void OnGUI() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Expected O, but got Unknown if (!debugMode.Value) { return; } Character localCharacter = Character.localCharacter; if ((Object)localCharacter == (Object)null) { return; } FatigueTracker component = ((Component)localCharacter).GetComponent<FatigueTracker>(); if (!((Object)component == (Object)null)) { GUIStyle val = new GUIStyle(); val.fontSize = 18; val.normal.textColor = Color.white; float num = 0f; Rigidbody playerRigidbody = FatigueTracker.GetPlayerRigidbody(localCharacter); if ((Object)playerRigidbody != (Object)null) { Vector3 linearVelocity = playerRigidbody.linearVelocity; num = ((Vector3)(ref linearVelocity)).magnitude; } float etcDamageMultiplier = GetEtcDamageMultiplier(); float gainMultiplier = GetGainMultiplier(); string text = (IsFatigueDisabled() ? "DISABLED" : $"x{gainMultiplier:F0}"); float statusSum = localCharacter.refs.afflictions.statusSum; float maxStamina = localCharacter.GetMaxStamina(); float currentStamina = localCharacter.data.currentStamina; GUI.Label(new Rect(20f, 100f, 700f, 30f), $"Speed: {num:F1} Fatigue: {component.fatigueValue:F3} etcMult: {etcDamageMultiplier:F2} ({text})", val); GUI.Label(new Rect(20f, 122f, 700f, 30f), $"Ground: {component.isGrounded} Climb: {component.isClimbing} Resting: {component.IsResting} RestTimer: {component.restTimer:F2}/{12f}", val); GUI.Label(new Rect(20f, 144f, 700f, 30f), $"FullyOut: {localCharacter.data.fullyPassedOut} Sum: {statusSum:F2} MaxStam: {maxStamina:F2} CurStam: {currentStamina:F2}", val); GUI.Label(new Rect(20f, 166f, 700f, 30f), "CustomBar: " + (((Object)FatigueBarInjector.injectedBar != (Object)null) ? "OK" : "missing"), val); } } } public class FatigueRpcReceiver : MonoBehaviourPun { [PunRPC] public void Fatigue_RPC_Sync(float value) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown FatigueTracker component = ((Component)this).GetComponent<FatigueTracker>(); if ((Object)component != (Object)null && !component.character.IsLocal) { component.fatigueValue = Mathf.Clamp01(value); } } } public class FatigueTracker : MonoBehaviour { public Character character; public float fatigueValue; public float restTimer; public bool isGrounded; public bool isClimbing; private float _playDeadEndTime = 0f; private const float PLAY_DEAD_DURATION = 4f; private float lastActionStaminaUseTime; private float pendingStaminaFromActions; private float lastSyncSent; private const float SYNC_INTERVAL = 0.2f; public bool IsPlayingDead => Time.time < _playDeadEndTime; public bool IsResting { get { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (isClimbing) { return false; } if (character.data.isSprinting) { return false; } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if ((Object)(object)playerRigidbody == (Object)null) { return false; } Vector3 linearVelocity = playerRigidbody.linearVelocity; return ((Vector3)(ref linearVelocity)).magnitude < 4.7f; } } private bool IsInvincible() { if ((Object)(object)character == (Object)null || character.refs == null || (Object)(object)character.refs.afflictions == (Object)null) { return false; } Affliction val = default(Affliction); if (character.refs.afflictions.HasAfflictionType((AfflictionType)14, ref val)) { return true; } if (character.refs.afflictions.HasAfflictionType((AfflictionType)16, ref val)) { return true; } return false; } private bool IsSkeleton() { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return false; } if (character.data.isSkeleton && !character.data.dead && !character.data.fullyPassedOut) { return true; } return false; } private float GetCurrentRecoveryRate() { float num = Time.time - lastActionStaminaUseTime - 6f; if (num <= 0f) { return 0f; } float num2 = num / 32f; num2 = Mathf.Clamp01(num2); float num3 = Mathf.Pow(num2, 1.8f); float num4 = Mathf.Lerp(0.001f, 0.012f, num3); if (Time.time < _playDeadEndTime) { float num5 = num4 * 2f; if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)$"Play Dead active - recovery rate: {num4:F4} → {num5:F4} (x{2f:F1})"); } return num5; } return num4; } private void Awake() { character = ((Component)this).GetComponent<Character>(); } public static Rigidbody GetPlayerRigidbody(Character c) { if ((Object)(object)c == (Object)null) { return null; } return ((Component)c).GetComponentInChildren<Rigidbody>(); } public void OnStaminaUsed(float usage) { lastActionStaminaUseTime = Time.time; if (!IsInvincible()) { pendingStaminaFromActions += usage; } restTimer = 0f; } public void SetPlayingDead(bool playing) { if (playing) { _playDeadEndTime = Time.time + 4f; if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)$"Play Dead emote started - Fatigue recovery boosted for {4f} seconds"); } } } private void Update() { if ((Object)(object)character == (Object)null || !character.IsLocal) { return; } isGrounded = character.data.isGrounded; isClimbing = character.data.isClimbing || character.data.isRopeClimbing || character.data.isVineClimbing; if (IsResting) { restTimer += Time.deltaTime; } else { restTimer = 0f; } if (!IsInvincible() && !IsSkeleton() && pendingStaminaFromActions >= 0.025f) { int num = Mathf.FloorToInt(pendingStaminaFromActions / 0.025f); float num2 = (float)num * 0.025f * 0.04f; fatigueValue = Mathf.Min(1f, fatigueValue + num2); pendingStaminaFromActions -= (float)num * 0.025f; } if (!IsSkeleton() && fatigueValue > 0f && Time.time - lastActionStaminaUseTime > 6f) { float currentRecoveryRate = GetCurrentRecoveryRate(); if (currentRecoveryRate > 0f) { fatigueValue = Mathf.Max(0f, fatigueValue - currentRecoveryRate * Time.deltaTime); } } MaybeSendSync(); } private void MaybeSendSync() { if (Time.time - lastSyncSent < 0.2f) { return; } lastSyncSent = Time.time; PhotonView component = ((Component)character).GetComponent<PhotonView>(); if ((Object)(object)component == (Object)null || !PhotonNetwork.InRoom) { return; } try { component.RPC("Fatigue_RPC_Sync", (RpcTarget)1, new object[1] { fatigueValue }); } catch (Exception ex) { FatiguePlugin.Logger.LogWarning((object)("RPC send failed: " + ex.Message)); } } } } namespace FatigueMod.Patches { [HarmonyPatch(typeof(CharacterAnimations), "PlayEmote")] internal static class CharacterAnimations_PlayEmote_Patch { [CompilerGenerated] private sealed class <ResetPlayDeadAfterDelay>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public FatigueTracker tracker; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetPlayDeadAfterDelay>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)tracker != (Object)null && tracker.IsPlayingDead) { tracker.SetPlayingDead(playing: false); if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)"Play Dead emote timeout - resetting recovery rate"); } } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] private static void Prefix(CharacterAnimations __instance, string emoteName) { Character component = ((Component)__instance).GetComponent<Character>(); if (!((Object)(object)component == (Object)null) && component.IsLocal) { FatigueTracker component2 = ((Component)component).GetComponent<FatigueTracker>(); if (!((Object)(object)component2 == (Object)null) && emoteName == "A_Scout_Emote_PlayDead") { component2.SetPlayingDead(playing: true); ((MonoBehaviour)__instance).StartCoroutine(ResetPlayDeadAfterDelay(component2, 5f)); } } } [IteratorStateMachine(typeof(<ResetPlayDeadAfterDelay>d__1))] private static IEnumerator ResetPlayDeadAfterDelay(FatigueTracker tracker, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetPlayDeadAfterDelay>d__1(0) { tracker = tracker, delay = delay }; } } [HarmonyPatch(typeof(CharacterAnimations), "Update")] internal static class CharacterAnimations_Update_Patch { [HarmonyPostfix] private static void Postfix(CharacterAnimations __instance) { //IL_0058: 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) Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.IsLocal) { return; } FatigueTracker component2 = ((Component)component).GetComponent<FatigueTracker>(); if ((Object)(object)component2 == (Object)null) { return; } Animator animator = component.refs.animator; if (!((Object)(object)animator != (Object)null)) { return; } AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); bool flag = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("A_Scout_Emote_PlayDead"); if (component2.IsPlayingDead != flag) { component2.SetPlayingDead(flag); if (FatiguePlugin.debugMode.Value && flag) { FatiguePlugin.Logger.LogInfo((object)"Play Dead emote detected via animator"); } } } } [HarmonyPatch(typeof(EmoteWheel), "Choose")] internal static class EmoteWheel_Choose_Patch { [CompilerGenerated] private sealed class <ResetPlayDeadAfterDelay>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public FatigueTracker tracker; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ResetPlayDeadAfterDelay>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)tracker != (Object)null && tracker.IsPlayingDead) { tracker.SetPlayingDead(playing: false); if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)"Play Dead emote timeout - resetting recovery rate"); } } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [HarmonyPrefix] private static void Prefix(EmoteWheel __instance) { FieldInfo field = typeof(EmoteWheel).GetField("chosenEmoteData", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return; } object? value = field.GetValue(__instance); EmoteWheelData val = (EmoteWheelData)((value is EmoteWheelData) ? value : null); if ((Object)(object)val == (Object)null || !(val.anim == "A_Scout_Emote_PlayDead")) { return; } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return; } FatigueTracker component = ((Component)localCharacter).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null)) { component.SetPlayingDead(playing: true); ((MonoBehaviour)__instance).StartCoroutine(ResetPlayDeadAfterDelay(component, 5f)); if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)"Play Dead emote detected via EmoteWheel.Choose()"); } } } [IteratorStateMachine(typeof(<ResetPlayDeadAfterDelay>d__1))] private static IEnumerator ResetPlayDeadAfterDelay(FatigueTracker tracker, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ResetPlayDeadAfterDelay>d__1(0) { tracker = tracker, delay = delay }; } } [HarmonyPatch(typeof(EmoteWheel), "OnDisable")] internal static class EmoteWheel_OnDisable_Patch { [HarmonyPrefix] private static void Prefix(EmoteWheel __instance) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return; } FatigueTracker component = ((Component)localCharacter).GetComponent<FatigueTracker>(); if (!((Object)(object)component == (Object)null) && component.IsPlayingDead) { component.SetPlayingDead(playing: false); if (FatiguePlugin.debugMode.Value) { FatiguePlugin.Logger.LogInfo((object)"Play Dead reset - emote wheel closed"); } } } } }
FeedingFrenzy.dll
Decompiled 19 hours agousing System; using System.Collections.Generic; 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 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("FeedingFrenzy")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+79a7584893ecdf26256e75b2a3192d3a2048d25b")] [assembly: AssemblyProduct("FeedingFrenzy")] [assembly: AssemblyTitle("FeedingFrenzy")] [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 FeedingFrenzy { [HarmonyPatch(typeof(Character), "AddExtraStamina")] internal static class AddExtraStamina_Multiplier_Patch { private static Dictionary<int, float> feedTimes = new Dictionary<int, float>(); private const float FED_WINDOW = 3f; public static void MarkAsFed(int characterID) { feedTimes[characterID] = Time.time; if (FeedingFrenzyPlugin.debugMode.Value) { FeedingFrenzyPlugin.Log.LogInfo((object)$"[FeedingFrenzy] Marked character {characterID} as fed"); } } [HarmonyPrefix] private static void Prefix(Character __instance, ref float add) { if (add <= 0f) { return; } int ownerActorNr = ((MonoBehaviourPun)__instance).photonView.OwnerActorNr; if (feedTimes.TryGetValue(ownerActorNr, out var value)) { if (Time.time - value <= 3f) { float num = add; add = num * FeedingFrenzyPlugin.extraStaminaMultiplier.Value; feedTimes.Remove(ownerActorNr); FeedingFrenzyPlugin.Log.LogInfo((object)("[FeedingFrenzy] " + __instance.characterName + " fed! " + $"Extra stamina: {num:F2} → {add:F2}")); } else { feedTimes.Remove(ownerActorNr); } } } } [BepInPlugin("jill920.FeedingFrenzy", "Feeding Frenzy", "1.0.1")] public class FeedingFrenzyPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.FeedingFrenzy"; public const string MOD_NAME = "Feeding Frenzy"; public const string MOD_VERSION = "1.0.1"; public static ConfigEntry<float> extraStaminaMultiplier; public static ConfigEntry<bool> debugMode; public static ManualLogSource Log { get; private set; } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; extraStaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ExtraStaminaMultiplier", 1.5f, "Multiplier applied to extra stamina when feeding another player."); debugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugLogs", false, "Enable debug logging"); Harmony.CreateAndPatchAll(typeof(GameUtils_StartFeed_Patch), "jill920.FeedingFrenzy"); Harmony.CreateAndPatchAll(typeof(AddExtraStamina_Multiplier_Patch), "jill920.FeedingFrenzy"); Log.LogInfo((object)"[Feeding Frenzy 1.0.1] Loaded successfully!"); } } [HarmonyPatch(typeof(GameUtils), "StartFeed")] internal static class GameUtils_StartFeed_Patch { [HarmonyPrefix] private static void Prefix(int giverID, int receiverID, ushort itemID, float totalItemTime) { Character val = default(Character); Character val2 = default(Character); if (Character.GetCharacterWithPhotonID(giverID, ref val) && Character.GetCharacterWithPhotonID(receiverID, ref val2)) { AddExtraStamina_Multiplier_Patch.MarkAsFed(((MonoBehaviourPun)val2).photonView.OwnerActorNr); FeedingFrenzyPlugin.Log.LogInfo((object)$"[FeedingFrenzy] Native feed detected: {val.characterName} -> {val2.characterName} (Item ID: {itemID})"); } } } }
NapberryEnhanced.dll
Decompiled 19 hours 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.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("NapberryEnhanced")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NapberryEnhanced")] [assembly: AssemblyTitle("NapberryEnhanced")] [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 NapberryEnhanced { [BepInPlugin("jill920.napberryenhanced", "Napberry Enhanced", "1.0.0")] public class NapberryEnhancedPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.napberryenhanced"; public const string MOD_NAME = "Napberry Enhanced"; public const string MOD_VERSION = "1.0.0"; public static NapberryEnhancedPlugin 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<bool>("Debug", "EnableLogs", false, "Enable debug logging").Value; CheckForInstalledMods(); try { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "jill920.napberryenhanced"); Logger.LogInfo((object)"[Napberry Enhanced 1.0.0] Loaded successfully!"); Logger.LogInfo((object)$" Dizziness Mod detected: {IsDizzinessModInstalled}"); Logger.LogInfo((object)$" Fatigue Mod detected: {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 NapberryEnhanced.Patches { [HarmonyPatch(typeof(Item), "Consume")] internal static class Item_Consume_Patch { private const int NAPBERRY_ITEM_ID = 110; 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 (NapberryEnhancedPlugin.IsFatigueModInstalled) { _fatigueAvailable = true; return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("FatigueMod.FatigueTracker") != null) { _fatigueAvailable = true; NapberryEnhancedPlugin.IsFatigueModInstalled = true; NapberryEnhancedPlugin.Logger.LogInfo((object)"Napberry: Fatigue Mod detected at runtime!"); return true; } } } catch { } return false; } private static bool IsDizzinessModPresent() { if (_dizzinessCheckDone) { return _dizzinessAvailable; } _dizzinessCheckDone = true; if (NapberryEnhancedPlugin.IsDizzinessModInstalled) { _dizzinessAvailable = true; return true; } try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (assembly.GetType("DizzinessMod.DizzinessTracker") != null) { _dizzinessAvailable = true; NapberryEnhancedPlugin.IsDizzinessModInstalled = true; NapberryEnhancedPlugin.Logger.LogInfo((object)"Napberry: Dizziness Mod detected at runtime!"); return true; } } } catch { } return false; } [HarmonyPostfix] private static void Postfix(Item __instance, int consumerID) { if (__instance.itemID != 110) { return; } PhotonView photonView = PhotonNetwork.GetPhotonView(consumerID); if ((Object)(object)photonView == (Object)null) { return; } Character component = ((Component)photonView).GetComponent<Character>(); 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 (NapberryEnhancedPlugin.debugMode) { NapberryEnhancedPlugin.Logger.LogInfo((object)("Napberry: Cleared Dizziness/Fatigue for " + component.characterName)); } } } 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)) { float num = (float)field.GetValue(component); field.SetValue(component, 0f); if (NapberryEnhancedPlugin.debugMode && num > 0.01f) { NapberryEnhancedPlugin.Logger.LogInfo((object)$"Napberry: Cleared Dizziness: {num:F3} → 0"); } } } catch (Exception ex) { NapberryEnhancedPlugin.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 (NapberryEnhancedPlugin.debugMode) { NapberryEnhancedPlugin.Logger.LogInfo((object)$"Napberry: Cleared pending stamina: {num2:F3} → 0"); } } } if (NapberryEnhancedPlugin.debugMode && num > 0.01f) { NapberryEnhancedPlugin.Logger.LogInfo((object)$"Napberry: Cleared Fatigue: {num:F3} → 0"); } } catch (Exception ex) { NapberryEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Fatigue: " + ex.Message)); } } } }
PandoraEnhanced.dll
Decompiled 19 hours 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Peak.Afflictions; using Photon.Realtime; 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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.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 PandoraEnhanced { [BepInPlugin("jill920.pandoraenhanced", "Pandora Enhanced", "1.0.0")] public class PandoraEnhancedPlugin : BaseUnityPlugin { public const string MOD_GUID = "jill920.pandoraenhanced"; public const string MOD_NAME = "Pandora Enhanced"; public const string MOD_VERSION = "1.0.0"; public static PandoraEnhancedPlugin Instance; public static ManualLogSource Logger; public static bool IsDizzinessModInstalled { get; private set; } public static bool IsFatigueModInstalled { get; private set; } private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; CheckForInstalledMods(); try { Harmony val = new Harmony("jill920.pandoraenhanced"); val.PatchAll(); Logger.LogInfo((object)"[Pandora Enhanced 1.0.0] Loaded successfully!"); Logger.LogInfo((object)$" Dizziness Mod detected: {IsDizzinessModInstalled}"); Logger.LogInfo((object)$" Fatigue Mod detected: {IsFatigueModInstalled}"); } catch (Exception ex) { Logger.LogError((object)("Failed to load: " + ex.Message)); } } private void CheckForInstalledMods() { 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 PandoraEnhanced.Patches { [HarmonyPatch(typeof(Affliction_Chaos), "OnApplied")] internal static class Affliction_Chaos_Patch_PreserveTotal { private static FieldInfo _isInvincibleField; private static bool IsInvincible(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return false; } try { if (_isInvincibleField == null) { _isInvincibleField = typeof(CharacterData).GetField("isInvincible", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_isInvincibleField != null) { return (bool)_isInvincibleField.GetValue(character.data); } } catch (Exception ex) { PandoraEnhancedPlugin.Logger.LogWarning((object)("Failed to check invincibility: " + ex.Message)); } return false; } private static void ClearDizziness(Character character) { try { PandoraEnhancedPlugin.Logger.LogInfo((object)"ClearDizziness: Looking for tracker..."); Component component = ((Component)character).GetComponent("DizzinessMod.DizzinessTracker"); if ((Object)(object)component == (Object)null) { PandoraEnhancedPlugin.Logger.LogWarning((object)"ClearDizziness: Tracker not found!"); return; } PandoraEnhancedPlugin.Logger.LogInfo((object)"ClearDizziness: Tracker found, getting field..."); FieldInfo field = ((object)component).GetType().GetField("dizzinessValue", BindingFlags.Instance | BindingFlags.Public); if (field == null) { PandoraEnhancedPlugin.Logger.LogWarning((object)"ClearDizziness: dizzinessValue field not found!"); return; } float num = (float)field.GetValue(component); PandoraEnhancedPlugin.Logger.LogInfo((object)$"ClearDizziness: Current value = {num:F3}"); if (num > 0.01f) { field.SetValue(component, 0f); PandoraEnhancedPlugin.Logger.LogInfo((object)$"Cleared Dizziness: {num:F3} → 0"); } else { PandoraEnhancedPlugin.Logger.LogInfo((object)"ClearDizziness: Value already near 0, nothing to clear"); } } catch (Exception ex) { PandoraEnhancedPlugin.Logger.LogError((object)("ClearDizziness failed: " + ex.Message + "\n" + ex.StackTrace)); } } private static bool IsLivingSkeleton(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)character.data == (Object)null) { return false; } if (character.data.isSkeleton && !character.data.dead && !character.data.fullyPassedOut) { return true; } return false; } 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)) { float num = (float)field.GetValue(component); if (num > 0.01f) { field.SetValue(component, 0f); PandoraEnhancedPlugin.Logger.LogInfo((object)$"Cleared Fatigue: {num:F3} → 0"); } } } catch (Exception ex) { PandoraEnhancedPlugin.Logger.LogWarning((object)("Failed to clear Fatigue: " + ex.Message)); } } [HarmonyPrefix] private static void Prefix(Affliction_Chaos __instance) { Character character = ((Affliction)__instance).character; if ((Object)(object)character == (Object)null || !character.IsLocal) { return; } if (IsLivingSkeleton(character)) { if (PandoraEnhancedPlugin.IsDizzinessModInstalled) { ClearDizziness(character); } if (PandoraEnhancedPlugin.IsFatigueModInstalled) { ClearFatigue(character); } return; } PandoraEnhancedPlugin.Logger.LogInfo((object)"Pandora Prefix - Starting clear"); bool flag = IsInvincible(character); PandoraEnhancedPlugin.Logger.LogInfo((object)$"Pandora Prefix - Invincible: {flag}"); PandoraEnhancedPlugin.Logger.LogInfo((object)$"Pandora Prefix - Dizziness mod installed: {PandoraEnhancedPlugin.IsDizzinessModInstalled}"); PandoraEnhancedPlugin.Logger.LogInfo((object)$"Pandora Prefix - Fatigue mod installed: {PandoraEnhancedPlugin.IsFatigueModInstalled}"); if (PandoraEnhancedPlugin.IsDizzinessModInstalled) { PandoraEnhancedPlugin.Logger.LogInfo((object)"Attempting to clear Dizziness..."); ClearDizziness(character); } if (PandoraEnhancedPlugin.IsFatigueModInstalled) { PandoraEnhancedPlugin.Logger.LogInfo((object)"Attempting to clear Fatigue..."); ClearFatigue(character); } if (flag) { PandoraEnhancedPlugin.Logger.LogInfo((object)"Pandora's Chaos: Invincible active - skipping Dizziness/Fatigue addition after clear"); } } [HarmonyPostfix] private static void Postfix(Affliction_Chaos __instance) { Character character = ((Affliction)__instance).character; if ((Object)(object)character == (Object)null || !character.IsLocal) { return; } if (IsLivingSkeleton(character)) { PandoraEnhancedPlugin.Logger.LogInfo((object)"Pandora's Chaos: Living skeleton - skipping Dizziness/Fatigue entirely"); return; } if (IsInvincible(character)) { PandoraEnhancedPlugin.Logger.LogInfo((object)"Pandora's Chaos: Invincible active - no Dizziness/Fatigue added"); return; } bool isDizzinessModInstalled = PandoraEnhancedPlugin.IsDizzinessModInstalled; bool isFatigueModInstalled = PandoraEnhancedPlugin.IsFatigueModInstalled; if (!isDizzinessModInstalled && !isFatigueModInstalled) { return; } float statusSum = character.refs.afflictions.statusSum; float num = 1f - statusSum; if (num <= 0.01f) { PandoraEnhancedPlugin.Logger.LogInfo((object)$"Pandora's Chaos: No space for Dizziness/Fatigue (total={statusSum:F3})"); return; } float num2 = 0f; float num3 = 0f; if (isDizzinessModInstalled && isFatigueModInstalled) { num2 = num * Random.Range(0f, 0.35f); float num4 = num - num2; num3 = num4 * Random.Range(0f, 0.5f); } else if (isDizzinessModInstalled) { num2 = num * Random.Range(0f, 0.35f); } else if (isFatigueModInstalled) { num3 = num * Random.Range(0f, 0.35f); } float num5 = num2 + num3; if (num5 > 0.01f) { if (isDizzinessModInstalled && num2 > 0.01f) { AddDizziness(character, num2); } if (isFatigueModInstalled && num3 > 0.01f) { AddFatigue(character, num3); } character.refs.afflictions.PushStatuses((Player)null); GUIManager.instance.bar.ChangeBar(); PandoraEnhancedPlugin.Logger.LogInfo((object)($"Pandora's Chaos: Total={statusSum:F3}, " + $"Added Dizziness={num2:F3}, Fatigue={num3:F3}")); } } private static void AddDizziness(Character character, float amount) { try { if (IsInvincible(character)) { return; } Component component = ((Component)character).GetComponent("DizzinessMod.DizzinessTracker"); if (!((Object)(object)component == (Object)null)) { FieldInfo field = ((object)component).GetType().GetField("dizzinessValue", BindingFlags.Instance | BindingFlags.Public); if (!(field == null)) { float num = (float)field.GetValue(component); field.SetValue(component, Mathf.Clamp01(num + amount)); } } } catch (Exception ex) { PandoraEnhancedPlugin.Logger.LogWarning((object)("Dizziness failed: " + ex.Message)); } } private static void AddFatigue(Character character, float amount) { try { if (IsInvincible(character)) { return; } Component component = ((Component)character).GetComponent("FatigueMod.FatigueTracker"); if (!((Object)(object)component == (Object)null)) { FieldInfo field = ((object)component).GetType().GetField("fatigueValue", BindingFlags.Instance | BindingFlags.Public); if (!(field == null)) { float num = (float)field.GetValue(component); field.SetValue(component, Mathf.Clamp01(num + amount)); } } } catch (Exception ex) { PandoraEnhancedPlugin.Logger.LogWarning((object)("Fatigue failed: " + ex.Message)); } } } }
StaminaAdjuster.dll
Decompiled 19 hours 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyCompany("StaminaAdjuster")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+45474b8f820e22b4b62e4177fd48df206621e63c")] [assembly: AssemblyProduct("Allows all stamina values to be changed from a config.")] [assembly: AssemblyTitle("StaminaAdjuster")] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")] [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 StaminaAdjuster { [HarmonyPatch(typeof(CharacterClimbing), "Start")] internal class Patch2 { private static void Postfix(CharacterClimbing __instance) { __instance.maxStaminaUsage = 0.2f; __instance.minStaminaUsage = 0.04f; } } [BepInPlugin("StaminaAdjuster", "Stamina Adjuster", "1.0.1")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; public const string MOD_GUID = "StaminaAdjuster"; public const string MOD_NAME = "Stamina Adjuster"; public const string MOD_VERSION = "1.0.1"; public const float MAX_CLIMB_STAMINA_USAGE = 0.2f; public const float MIN_CLIMB_STAMINA_USAGE = 0.04f; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "StaminaAdjuster"); Log.LogInfo((object)"[Stamina Adjuster 1.0.1] Loaded!"); Log.LogInfo((object)$" MaxClimbStaminaUsage: {0.2f}"); Log.LogInfo((object)$" MinClimbStaminaUsage: {0.04f}"); } } }