using System; 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 Photon.Pun; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.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(BarAffliction), "ChangeAffliction")] internal static class BarAffliction_ChangeAffliction_Patch { [HarmonyPrefix] private static bool Prefix(BarAffliction __instance, StaminaBar bar) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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)(object)observedCharacter == (Object)null) { ((Component)__instance).gameObject.SetActive(false); return false; } DizzinessTracker component = ((Component)observedCharacter).GetComponent(); if ((Object)(object)component == (Object)null) { ((Component)__instance).gameObject.SetActive(false); return false; } if ((Object)(object)__instance.icon != (Object)null) { ((Component)__instance.icon).gameObject.SetActive(true); if ((Object)(object)DizzinessPlugin.DizzinessIconSprite != (Object)null) { __instance.icon.sprite = DizzinessPlugin.DizzinessIconSprite; ((Graphic)__instance.icon).color = Color.white; } } float dizzinessValue = component.dizzinessValue; float num = bar.fullBar.sizeDelta.x * dizzinessValue; if (dizzinessValue > 0.01f) { if (num < bar.minAfflictionWidth) { num = bar.minAfflictionWidth; } __instance.size = num; RectTransform component2 = ((Component)__instance).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.sizeDelta = new Vector2(num, component2.sizeDelta.y); } ((Component)__instance).gameObject.SetActive(true); } else { __instance.size = 0f; RectTransform component3 = ((Component)__instance).GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.sizeDelta = new Vector2(0f, component3.sizeDelta.y); } ((Component)__instance).gameObject.SetActive(false); } return false; } } [HarmonyPatch(typeof(CharacterAfflictions), "get_statusSum")] internal static class CharacterAfflictions_statusSum_Patch { [HarmonyPostfix] private static void Postfix(CharacterAfflictions __instance, ref float __result) { if ((Object)(object)__instance.character == (Object)null) { return; } DizzinessTracker component = ((Component)__instance.character).GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)__instance.character.data == (Object)null) { return; } if (__instance.character.data.fullyPassedOut) { component.statusSumSeenPassOut = true; __result += component.dizzinessValue; if (component.dizzinessValue >= 1f) { __result = Mathf.Max(__result, 1.01f); } return; } if (component.statusSumSeenPassOut) { component.statusSumSeenPassOut = false; component.recentlyPassedOut = true; try { float maxStamina = __instance.character.GetMaxStamina(); if (maxStamina > 0.001f) { __instance.character.data.currentStamina = maxStamina; } } catch { } } __result += component.dizzinessValue; } } [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(); } } } public static class DizzinessBarInjector { public static BarAffliction injectedBar; private static bool injectionFailed; public static void TryInjectBar() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)injectedBar != (Object)null || injectionFailed) { return; } try { if ((Object)(object)GUIManager.instance == (Object)null) { return; } StaminaBar bar = GUIManager.instance.bar; if ((Object)(object)bar == (Object)null || bar.afflictions == null || bar.afflictions.Length == 0) { return; } BarAffliction val = null; BarAffliction[] afflictions = bar.afflictions; foreach (BarAffliction val2 in afflictions) { if ((Object)(object)val2 != (Object)null && (int)val2.afflictionType == 4) { val = val2; break; } } if ((Object)(object)val == (Object)null) { DizzinessPlugin.Logger.LogWarning((object)"Crab template bar not found"); injectionFailed = true; return; } GameObject val3 = Object.Instantiate(((Component)val).gameObject, ((Component)val).transform.parent); ((Object)val3).name = "DizzinessCustomBar"; BarAffliction component = val3.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val3); injectionFailed = true; return; } if ((Object)(object)DizzinessPlugin.DizzinessIconSprite != (Object)null && (Object)(object)component.icon != (Object)null) { component.icon.sprite = DizzinessPlugin.DizzinessIconSprite; ((Graphic)component.icon).color = Color.white; } Image[] componentsInChildren = ((Component)component).GetComponentsInChildren(true); foreach (Image val4 in componentsInChildren) { if (!((Object)(object)component.icon != (Object)null) || !((Object)(object)val4 == (Object)(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) { Object.Destroy((Object)(object)val3); injectionFailed = true; return; } BarAffliction[] array = (BarAffliction[])field.GetValue(bar); BarAffliction[] array2 = (BarAffliction[])(object)new BarAffliction[array.Length + 1]; Array.Copy(array, array2, array.Length); array2[array.Length] = component; field.SetValue(bar, array2); injectedBar = component; DizzinessPlugin.Logger.LogInfo((object)$"Independent bar injected. New array size: {array2.Length}"); } catch (Exception arg) { DizzinessPlugin.Logger.LogError((object)$"Bar injection failed: {arg}"); injectionFailed = true; } } } public class DizzinessCameraEffect : MonoBehaviour { private Camera _cam; private float _swayPhase; private float _currentRoll; private float _currentFovDelta; private void Awake() { _cam = ((Component)this).GetComponent(); } private static float GetDizziness() { Character localCharacter = Character.localCharacter; DizzinessTracker dizzinessTracker = (((Object)(object)localCharacter != (Object)null) ? ((Component)localCharacter).GetComponent() : null); if (!((Object)(object)dizzinessTracker != (Object)null)) { return 0f; } return dizzinessTracker.dizzinessValue; } private void Update() { float dizziness = GetDizziness(); if (dizziness < 0.05f) { _currentRoll = Mathf.MoveTowards(_currentRoll, 0f, Time.deltaTime * 4f); _currentFovDelta = Mathf.MoveTowards(_currentFovDelta, 0f, Time.deltaTime * 4f); return; } _swayPhase += Time.deltaTime * (0.5f + dizziness * 1.5f); float num = dizziness * dizziness * 3f; _currentRoll = Mathf.Sin(_swayPhase * MathF.PI * 2f) * num; _currentFovDelta = Mathf.Sin(_swayPhase * MathF.PI * 1.7f) * dizziness * 1.5f; } private void OnPreCull() { if (!((Object)(object)_cam == (Object)null) && (!(Mathf.Abs(_currentRoll) < 0.001f) || !(Mathf.Abs(_currentFovDelta) < 0.001f))) { Camera cam = _cam; cam.fieldOfView += _currentFovDelta; ((Component)this).transform.Rotate(0f, 0f, _currentRoll, (Space)1); } } private void OnPostRender() { if (!((Object)(object)_cam == (Object)null) && (!(Mathf.Abs(_currentRoll) < 0.001f) || !(Mathf.Abs(_currentFovDelta) < 0.001f))) { ((Component)this).transform.Rotate(0f, 0f, 0f - _currentRoll, (Space)1); Camera cam = _cam; cam.fieldOfView -= _currentFovDelta; } } } [BepInPlugin("com.tambistudios.dizziness", "Dizziness From Speed", "1.3.0")] public class DizzinessPlugin : BaseUnityPlugin { public const string MOD_GUID = "com.tambistudios.dizziness"; public const string MOD_NAME = "Dizziness From Speed"; public const string MOD_VERSION = "1.3.0"; public static DizzinessPlugin Instance; public static ManualLogSource Logger; public static ConfigEntry debugMode; public const float MIN_SPEED_THRESHOLD = 7f; public const float REST_SPEED_THRESHOLD = 7f; public const float DIZZINESS_GAIN_BASE = 0.0012f; public const float MAX_GAIN_PER_SEC = 0.3f; public const float REST_DURATION = 12f; public const float RECOVERY_PER_SEC = 0.05f; public const float GROUND_CHECK_RAY_LENGTH = 1.5f; public const float BUGLE_RADIUS = 30f; public const float BUGLE_RECOVERY_PER_SEC = 0.05f; public const float DYNAMITE_CLOSE_RADIUS = 5f; public const float DYNAMITE_FAR_RADIUS = 20f; public const float PASSOUT_RECOVERY_THRESHOLD = 0.2f; public static readonly Color DizzinessColor = new Color(0f, 0.80784315f, 0.81960785f, 1f); public static Sprite DizzinessIconSprite; public const string CUSTOM_BAR_NAME = "DizzinessCustomBar"; private Texture2D _guiTex; private Texture2D _vignetteTex; private float _concussionFlash; private void Awake() { //IL_004b: 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 50%) and on-screen debug HUD."); LoadIconSprite(); _vignetteTex = GenerateVignette(128); try { new Harmony("com.tambistudios.dizziness").PatchAll(); IEnumerable allPatchedMethods = Harmony.GetAllPatchedMethods(); int num = 0; foreach (MethodBase item in allPatchedMethods) { _ = item; num++; } Logger.LogInfo((object)string.Format("[{0} {1}] Loaded. Harmony patches active: {2}", "Dizziness From Speed", "1.2.0", num)); } catch (Exception arg) { Logger.LogError((object)$"Harmony patch failed: {arg}"); } } private static void LoadIconSprite() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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}"); } else { Logger.LogWarning((object)"ImageConversion.LoadImage failed — icon will be missing."); } } 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 static Texture2D GenerateVignette(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; float num = (float)size * 0.5f; Color32[] array = (Color32[])(object)new Color32[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = Mathf.Clamp01((Mathf.Sqrt(num2 * num2 + num3 * num3) - 0.35f) / 0.65f); num4 *= num4; array[i * size + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)(num4 * 255f)); } } val.SetPixels32(array); val.Apply(false); return val; } internal void TriggerConcussionFlash(float strength) { _concussionFlash = Mathf.Max(_concussionFlash, 0.5f + strength * 0.7f); } private void Update() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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) if (_concussionFlash > 0f) { _concussionFlash = Mathf.Max(0f, _concussionFlash - Time.deltaTime * 1.4f); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null && (Object)(object)((Component)localCharacter).GetComponent() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent(); if ((Object)(object)((Component)localCharacter).GetComponent() == (Object)null) { ((Component)localCharacter).gameObject.AddComponent(); } Logger.LogInfo((object)"DizzinessTracker attached (fallback)."); } DizzinessBarInjector.TryInjectBar(); Camera main = Camera.main; if ((Object)(object)main != (Object)null && (Object)(object)((Component)main).GetComponent() == (Object)null) { ((Component)main).gameObject.AddComponent(); } if (!debugMode.Value || !((Object)(object)localCharacter != (Object)null)) { return; } if (Input.GetKeyDown((KeyCode)286)) { Rigidbody playerRigidbody = DizzinessTracker.GetPlayerRigidbody(localCharacter); if ((Object)(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)(object)component != (Object)null) { component.dizzinessValue = 0.5f; Logger.LogInfo((object)"[F7] Forced dizziness = 0.5"); } } } private void OnGUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type == 7) { if ((Object)(object)_guiTex == (Object)null) { _guiTex = new Texture2D(1, 1); _guiTex.SetPixel(0, 0, Color.white); _guiTex.Apply(); } Color color = GUI.color; Rect val = default(Rect); ((Rect)(ref val))..ctor(0f, 0f, (float)Screen.width, (float)Screen.height); Character localCharacter = Character.localCharacter; DizzinessTracker dizzinessTracker = (((Object)(object)localCharacter != (Object)null) ? ((Component)localCharacter).GetComponent() : null); float num = (((Object)(object)dizzinessTracker != (Object)null) ? dizzinessTracker.dizzinessValue : 0f); if (num > 0.05f && (Object)(object)_vignetteTex != (Object)null) { float num2 = num * num * 0.85f; GUI.color = new Color(0f, 0f, 0f, num2); GUI.DrawTexture(val, (Texture)(object)_vignetteTex, (ScaleMode)0, true); float num3 = num * num * 0.18f; GUI.color = new Color(1f, 1f, 1f, num3); GUI.DrawTexture(val, (Texture)(object)_guiTex); } if (_concussionFlash > 0f) { float num4 = _concussionFlash / 1.2f; GUI.color = new Color(1f, 0.95f, 0.85f, num4 * 0.75f); GUI.DrawTexture(val, (Texture)(object)_guiTex); } GUI.color = color; } if (!debugMode.Value) { return; } Character localCharacter2 = Character.localCharacter; if ((Object)(object)localCharacter2 == (Object)null) { return; } DizzinessTracker component = ((Component)localCharacter2).GetComponent(); if ((Object)(object)component != (Object)null) { GUIStyle val2 = new GUIStyle(); val2.fontSize = 18; val2.normal.textColor = Color.white; float num5 = 0f; Rigidbody playerRigidbody = DizzinessTracker.GetPlayerRigidbody(localCharacter2); if ((Object)(object)playerRigidbody != (Object)null) { Vector3 linearVelocity = playerRigidbody.linearVelocity; num5 = ((Vector3)(ref linearVelocity)).magnitude; } float etcDamageMultiplier = GetEtcDamageMultiplier(); float gainMultiplier = GetGainMultiplier(); string text = (IsDizzinessDisabled() ? "DISABLED" : $"x{gainMultiplier:F0}"); float statusSum = localCharacter2.refs.afflictions.statusSum; float maxStamina = localCharacter2.GetMaxStamina(); float currentStamina = localCharacter2.data.currentStamina; GUI.Label(new Rect(20f, 100f, 700f, 30f), $"Speed: {num5:F1} Dizziness: {component.dizzinessValue:F3} etcMult: {etcDamageMultiplier:F2} ({text})", val2); GUI.Label(new Rect(20f, 122f, 700f, 30f), $"Ground: {component.isGrounded} Climb: {component.isClimbing} Resting: {component.IsResting} RestTimer: {component.restTimer:F2}/{12f}", val2); GUI.Label(new Rect(20f, 144f, 700f, 30f), $"FullyOut: {localCharacter2.data.fullyPassedOut} Sum: {statusSum:F2} MaxStam: {maxStamina:F2} CurStam: {currentStamina:F2}", val2); } } } public class DizzinessRpcReceiver : MonoBehaviourPun { [PunRPC] public void Dizziness_RPC_Sync(float value) { DizzinessTracker component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.character != (Object)null && !component.character.IsLocal) { component.dizzinessValue = Mathf.Clamp01(value); } } } public class DizzinessTracker : MonoBehaviour { public Character character; public float dizzinessValue; public float restTimer; public bool isGrounded; public bool isClimbing; public bool recentlyPassedOut; public bool wasFullyPassedOut; public bool statusSumSeenPassOut; 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (isClimbing) { return false; } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if ((Object)(object)playerRigidbody == (Object)null) { return false; } Vector3 linearVelocity = playerRigidbody.linearVelocity; return ((Vector3)(ref linearVelocity)).magnitude < 7f; } } public static Rigidbody GetPlayerRigidbody(Character c) { if ((Object)(object)c == (Object)null) { return null; } DizzinessTracker component = ((Component)c).GetComponent(); if ((Object)(object)component != (Object)null) { if ((Object)(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 void Update() { if ((Object)(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}"); } recentlyPassedOut = true; } wasFullyPassedOut = fullyPassedOut; if (recentlyPassedOut && dizzinessValue < 0.1f) { recentlyPassedOut = false; } ApplyBugleEffect(); if (DizzinessPlugin.IsDizzinessDisabled()) { if (dizzinessValue > 0f) { dizzinessValue = Mathf.Max(0f, dizzinessValue - 0.05f * Time.deltaTime); MaybeSendSync(); } } else { UpdateLocalDizziness(); MaybeSendSync(); } } private void ApplyBugleEffect() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (dizzinessValue <= 0f) { return; } BugleSFX[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return; } Vector3 position = ((Component)this).transform.position; bool flag = false; BugleSFX[] array2 = array; foreach (BugleSFX val in array2) { if ((Object)(object)val != (Object)null && val.hold && Vector3.Distance(position, ((Component)val).transform.position) <= 30f) { flag = true; break; } } if (flag) { dizzinessValue = Mathf.Max(0f, dizzinessValue - 0.05f * Time.deltaTime); } } private bool DetectGrounded() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (!_groundedFieldSearched && (Object)(object)character.data != (Object)null) { _groundedFieldSearched = true; 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)(object)character.data != (Object)null) { try { return (bool)_groundedField.GetValue(character.data); } catch { } } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if ((Object)(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() { if (!_climbingFieldsSearched && (Object)(object)character.data != (Object)null) { _climbingFieldsSearched = true; Type type = ((object)character.data).GetType(); string[] obj = new string[3] { "isClimbing", "isRopeClimbing", "isVineClimbing" }; List list = new List(); string[] array = obj; foreach (string text in array) { 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)(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 void UpdateLocalDizziness() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (IsResting) { restTimer += Time.deltaTime; } else { restTimer = 0f; } Rigidbody playerRigidbody = GetPlayerRigidbody(character); if ((Object)(object)playerRigidbody != (Object)null) { Vector3 linearVelocity = playerRigidbody.linearVelocity; float magnitude = ((Vector3)(ref linearVelocity)).magnitude; if (!isGrounded && !character.data.fullyPassedOut && magnitude > 7f) { float gainMultiplier = DizzinessPlugin.GetGainMultiplier(); float num = magnitude - 7f; float num2 = num * num * 0.0012f * gainMultiplier; num2 = Mathf.Min(num2, 0.3f); dizzinessValue = Mathf.Min(1f, dizzinessValue + num2 * Time.deltaTime); } if (IsResting && restTimer >= 12f) { dizzinessValue = Mathf.Max(0f, dizzinessValue - 0.05f * Time.deltaTime); } } } public void AddFromExplosion(Vector3 explosionPos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (DizzinessPlugin.IsDizzinessDisabled()) { return; } float num = Vector3.Distance(((Component)this).transform.position, explosionPos); if (!(num >= 20f)) { float num2; if (num <= 5f) { num2 = 1f; } else { float num3 = (num - 5f) / 15f; num2 = 1f - num3; } float gainMultiplier = DizzinessPlugin.GetGainMultiplier(); num2 *= gainMultiplier * 0.3f; dizzinessValue = Mathf.Min(1f, dizzinessValue + num2); DizzinessPlugin.Logger.LogInfo((object)$"Dynamite at dist {num:F1}m → dizziness +{num2:F2} (now {dizzinessValue:F2})"); float strength = ((gainMultiplier > 0.001f) ? (num2 / (gainMultiplier * 0.3f)) : 0f); DizzinessPlugin.Instance?.TriggerConcussionFlash(strength); } } private void MaybeSendSync() { if (Time.time - lastSyncSent < 0.2f) { return; } lastSyncSent = Time.time; PhotonView component = ((Component)character).GetComponent(); if ((Object)(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] internal static class Dynamite_RPC_Explode_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Dynamite), "RPC_Explode", (Type[])null, (Type[])null); } [HarmonyPostfix] private static void Postfix(Dynamite __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null) { DizzinessTracker component = ((Component)localCharacter).GetComponent(); if ((Object)(object)component != (Object)null) { component.AddFromExplosion(((Component)__instance).transform.position); } } } catch (Exception ex) { DizzinessPlugin.Logger.LogWarning((object)("Dynamite explode patch failed: " + ex.Message)); } } } }