using 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 healingItemIDs = new HashSet { 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(); 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(); 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(); 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(); 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() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } if ((Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } [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(); 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(); 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(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val3).name = "DizzinessCustomBar"; BarAffliction component = val3.GetComponent(); 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(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(); tracker = ((Component)this).GetComponent(); 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(); if ((Object)(object)component == (Object)null) { return; } DizzinessTracker component2 = ((Component)component).GetComponent(); 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(); if ((Object)(object)component == (Object)null) { return; } DizzinessTracker component2 = ((Component)component).GetComponent(); 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.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 item in instance.itemLookup.OrderBy((KeyValuePair 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(); 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 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("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() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent(); if ((Object)((Component)localCharacter).GetComponent() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent(); } 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(); 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(); 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(); 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(); if ((Object)component != (Object)null) { if ((Object)component._cachedRb != (Object)null) { return component._cachedRb; } component._cachedRb = ((Component)c).GetComponentInChildren(); return component._cachedRb; } return ((Component)c).GetComponentInChildren(); } private void Awake() { character = ((Component)this).GetComponent(); } 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 list = new List(); 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(); 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})"); } } }