Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Sanity Mod v0.7.1
SanityMod.dll
Decompiled 7 months agousing System; using System.Collections; 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 TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.PostProcessing; using UnityEngine.SceneManagement; 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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SanityMod")] [assembly: AssemblyTitle("SanityMod")] [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.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; } } } namespace SanityMod { [BepInPlugin("Omniscye.SanityMod", "SanityMod", "1.0")] public class SanityMod : BaseUnityPlugin { internal static SanityMod Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } } namespace Empress.REPO.Insanity { [BepInPlugin("empress.repo.insanitymod", "Insanity & Hallucinations", "1.2.0")] public class InsanityMod : BaseUnityPlugin { internal sealed class InsanityController : MonoBehaviour { private sealed class ShadowFader : MonoBehaviour { public float Lifetime = 2f; private float _t; private readonly List<Renderer> _renders = new List<Renderer>(); private void Start() { ((Component)this).GetComponentsInChildren<Renderer>(_renders); } private void Update() { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) _t += Time.deltaTime; float num = Mathf.Clamp01(_t / Lifetime); float a = Mathf.SmoothStep(1f, 0f, num); foreach (Renderer render in _renders) { if (!((Object)(object)render == (Object)null) && !((Object)(object)render.material == (Object)null) && render.material.HasProperty("_Color")) { Color color = render.material.color; color.a = a; render.material.color = color; } } Transform transform = ((Component)this).transform; transform.position += new Vector3((Random.value - 0.5f) * 0.01f, 0f, (Random.value - 0.5f) * 0.01f); if (_t >= Lifetime) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private sealed class FlashLightFader : MonoBehaviour { private float _rise; private float _fall; private float _t; private Light _l; public void Init(float rise, float fall) { _rise = Mathf.Max(0.01f, rise); _fall = Mathf.Max(0.01f, fall); } private void Awake() { _l = ((Component)this).GetComponent<Light>(); } private void Update() { _t += Time.deltaTime; if ((Object)(object)_l == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (_t <= _rise) { _l.intensity = Mathf.Lerp(0f, 3.2f, _t / _rise); } else { float num = (_t - _rise) / _fall; _l.intensity = Mathf.Lerp(3.2f, 0f, num); } if (_t >= _rise + _fall) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } [CompilerGenerated] private sealed class <ArmWhenGameplayReady>d__66 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public InsanityController <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ArmWhenGameplayReady>d__66(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_005f; case 1: <>1__state = -1; goto IL_005f; case 2: <>1__state = -1; goto IL_009c; case 3: <>1__state = -1; goto IL_00c4; case 4: <>1__state = -1; goto IL_0102; case 5: { <>1__state = -1; <>4__this._armed = true; return false; } IL_005f: if ((Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2) { <>2__current = null; <>1__state = 1; return true; } goto IL_009c; IL_0102: if ((Object)(object)PlayerController.instance == (Object)null || (Object)(object)PlayerController.instance.playerAvatarScript == (Object)null) { <>2__current = null; <>1__state = 4; return true; } <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 5; return true; IL_009c: if ((Object)(object)LevelGenerator.Instance == (Object)null) { <>2__current = null; <>1__state = 2; return true; } goto IL_00c4; IL_00c4: if (GameDirector.instance.PlayerList == null || GameDirector.instance.PlayerList.Count == 0) { <>2__current = null; <>1__state = 3; return true; } goto IL_0102; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <CameraRollNudge>d__84 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public InsanityController <>4__this; private Camera <cam>5__1; private float <dur>5__2; private float <half>5__3; private float <t>5__4; private float <roll>5__5; private Vector3 <start>5__6; private float <n>5__7; private Vector3 <e>5__8; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CameraRollNudge>d__84(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <cam>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <cam>5__1 = <>4__this._cam ?? Camera.main; if ((Object)(object)<cam>5__1 == (Object)null) { return false; } <dur>5__2 = 0.25f; <half>5__3 = <dur>5__2 * 0.5f; <t>5__4 = 0f; <roll>5__5 = Random.Range(-3.5f, 3.5f); <start>5__6 = ((Component)<cam>5__1).transform.localEulerAngles; break; case 1: <>1__state = -1; break; } if (<t>5__4 < <dur>5__2) { <t>5__4 += Time.deltaTime; <n>5__7 = ((<t>5__4 < <half>5__3) ? (<t>5__4 / <half>5__3) : (1f - (<t>5__4 - <half>5__3) / <half>5__3)); <e>5__8 = <start>5__6; <e>5__8.z = <start>5__6.z + <roll>5__5 * <n>5__7; ((Component)<cam>5__1).transform.localEulerAngles = <e>5__8; <>2__current = null; <>1__state = 1; return true; } ((Component)<cam>5__1).transform.localEulerAngles = <start>5__6; 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(); } } [Header("Core")] public float MaxInsanity = 100f; public float AloneIncreasePerSecond = 1f; public float EnemySeenBurst = 20f; public float FriendDecayPerFriendPerSecond = 2f; [Header("Enemy Pressure (continuous)")] public float EnemyProximityRadius = 16f; public float EnemyProximityPerEnemyPerSecond = 1f; public int EnemyProximityMaxStack = 5; [Header("Solo Fairness (Truck calm)")] public float TruckCalmPerSecond = 3f; [Header("Proximity & Vision")] public float FriendRadius = 10f; public float EnemyMaxRange = 40f; public float EnemyFOVDegrees = 70f; public float EnemySeenCooldown = 1f; [Header("Panic Shader Limits (added on top of defaults)")] public float VignetteAdd = 0.35f; public float GrainIntensityAdd = 0.5f; public float ChromaticAberrationAdd = 0.6f; public float LensDistortionTarget = -35f; [Header("Color Grade")] public bool EnableDesaturate = true; public float DesaturateAt = 100f; [Header("Hallucinations")] public bool EnableHallucinations = true; public float HallucinationStartAt = 35f; public float StrongHallucinationsAt = 75f; public float ExtremeHallucinationsAt = 90f; public float MinShadowSpawnInterval = 8f; public float MaxShadowSpawnInterval = 18f; public float ShadowLifetime = 2.2f; public float ShadowMinDistance = 6f; public float ShadowMaxDistance = 12f; [Header("Arming")] public bool ResetInsanityOnLevelLoad = true; [Header("Debug UI")] public bool ShowIMGUI = false; [Header("Glitch Cooldowns (sec)")] public float TinyGlitchCooldown = 1.2f; public float ShortGlitchCooldown = 3f; private float _insanity; private float _enemySeenCD; private float _shadowSpawnTimer; private float _glitchTimer; private bool _armed; private Random _rng; private PostProcessVolume _ppVolume; private Vignette _ppVignette; private Grain _ppGrain; private ChromaticAberration _ppChromatic; private LensDistortion _ppDistortion; private ColorGrading _ppColor; private float _vignetteDefault; private float _grainDefault; private float _chromaticDefault; private float _distortionDefault; private float _saturationDefault; private Camera _cam; public static InsanityController Instance { get; private set; } public float EnemyPressure01 { get; private set; } public float CurrentInsanity => _insanity; public float NormalizedInsanity => (MaxInsanity <= 0f) ? 0f : (_insanity / MaxInsanity); private void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded_Disarm; } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded_Disarm; } private void OnSceneLoaded_Disarm(Scene scene, LoadSceneMode mode) { Disarm("scene load: " + ((Scene)(ref scene)).name); ((MonoBehaviour)this).StartCoroutine(ArmWhenGameplayReady()); } private void Start() { Instance = this; _rng = new Random(); TryBindCamera(); TryBindPostProcessing(); ResetShadowTimer(first: true); ((MonoBehaviour)this).StartCoroutine(ArmWhenGameplayReady()); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } [IteratorStateMachine(typeof(<ArmWhenGameplayReady>d__66))] private IEnumerator ArmWhenGameplayReady() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ArmWhenGameplayReady>d__66(0) { <>4__this = this }; } private void Disarm(string why) { _armed = false; if (ResetInsanityOnLevelLoad) { _insanity = 0f; } if ((Object)(object)_ppVignette != (Object)null) { ((ParameterOverride<float>)(object)_ppVignette.intensity).value = _vignetteDefault; } if ((Object)(object)_ppGrain != (Object)null) { ((ParameterOverride<float>)(object)_ppGrain.intensity).value = _grainDefault; } if ((Object)(object)_ppChromatic != (Object)null) { ((ParameterOverride<float>)(object)_ppChromatic.intensity).value = _chromaticDefault; } if ((Object)(object)_ppDistortion != (Object)null) { ((ParameterOverride<float>)(object)_ppDistortion.intensity).value = _distortionDefault; } if ((Object)(object)_ppColor != (Object)null) { ((ParameterOverride<float>)(object)_ppColor.saturation).value = _saturationDefault; } _enemySeenCD = 0f; _glitchTimer = 0f; EnemyPressure01 = 0f; ResetShadowTimer(first: true); } private void Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (!_armed) { return; } GameDirector instance = GameDirector.instance; if ((Object)(object)instance == (Object)null || (int)instance.currentState != 2) { return; } PlayerController instance2 = PlayerController.instance; PlayerAvatar val = instance2?.playerAvatarScript; if (!((Object)(object)instance2 == (Object)null) && !((Object)(object)val == (Object)null)) { if (_glitchTimer > 0f) { _glitchTimer -= Time.deltaTime; } if ((Object)(object)_cam == (Object)null) { TryBindCamera(); } int num = CountNearbyFriends(((Component)val).transform.position, val); int num2 = CountNearbyEnemies(((Component)val).transform.position); if (_enemySeenCD > 0f) { _enemySeenCD -= Time.deltaTime; } bool flag = _enemySeenCD <= 0f && EnemyVisible(_cam, val); if (flag) { AddInsanity(EnemySeenBurst); _enemySeenCD = EnemySeenCooldown; SafeGlitchTiny(); } float num3 = Mathf.Min(num2 + (flag ? 1 : 0), EnemyProximityMaxStack); EnemyPressure01 = Mathf.Clamp01(num3 / (float)Mathf.Max(1, EnemyProximityMaxStack)); float deltaTime = Time.deltaTime; float num4 = 0f; bool flag2 = false; try { flag2 = (Object)(object)val.RoomVolumeCheck != (Object)null && val.RoomVolumeCheck.inTruck; } catch { } num4 = ((num > 0) ? (num4 + (0f - FriendDecayPerFriendPerSecond) * (float)num * deltaTime) : ((!flag2) ? (num4 + AloneIncreasePerSecond * deltaTime) : (num4 + (0f - Mathf.Abs(TruckCalmPerSecond)) * deltaTime))); if (num2 > 0) { num4 += EnemyProximityPerEnemyPerSecond * (float)num2 * deltaTime; } AddInsanity(num4); ApplyPanicShader(); if (EnableHallucinations) { HallucinationTick(((Component)val).transform); } } } private void OnGUI() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (ShowIMGUI) { GUILayout.BeginArea(new Rect(20f, 20f, 300f, 100f), GUI.skin.box); GUILayout.Label($"Insanity: {Mathf.RoundToInt(_insanity)} / {Mathf.RoundToInt(MaxInsanity)}", Array.Empty<GUILayoutOption>()); GUILayout.Label($"EnemyPressure: {EnemyPressure01:0.00}", Array.Empty<GUILayoutOption>()); GUILayout.EndArea(); } } private void AddInsanity(float delta) { _insanity = Mathf.Clamp(_insanity + delta, 0f, MaxInsanity); } private void TryBindCamera() { _cam = (((Object)(object)CameraUtils.Instance != (Object)null) ? CameraUtils.Instance.MainCamera : Camera.main); } private void TryBindPostProcessing() { _ppVolume = (((Object)(object)PostProcessing.Instance != (Object)null) ? PostProcessing.Instance.volume : null); if (!((Object)(object)_ppVolume == (Object)null) && !((Object)(object)_ppVolume.profile == (Object)null)) { _ppVolume.profile.TryGetSettings<Vignette>(ref _ppVignette); _ppVolume.profile.TryGetSettings<Grain>(ref _ppGrain); _ppVolume.profile.TryGetSettings<ChromaticAberration>(ref _ppChromatic); _ppVolume.profile.TryGetSettings<LensDistortion>(ref _ppDistortion); _ppVolume.profile.TryGetSettings<ColorGrading>(ref _ppColor); if ((Object)(object)_ppVignette != (Object)null) { _vignetteDefault = ((ParameterOverride<float>)(object)_ppVignette.intensity).value; } if ((Object)(object)_ppGrain != (Object)null) { _grainDefault = ((ParameterOverride<float>)(object)_ppGrain.intensity).value; } if ((Object)(object)_ppChromatic != (Object)null) { _chromaticDefault = ((ParameterOverride<float>)(object)_ppChromatic.intensity).value; } if ((Object)(object)_ppDistortion != (Object)null) { _distortionDefault = ((ParameterOverride<float>)(object)_ppDistortion.intensity).value; } if ((Object)(object)_ppColor != (Object)null) { _saturationDefault = ((ParameterOverride<float>)(object)_ppColor.saturation).value; } } } private void ApplyPanicShader() { if ((Object)(object)_ppVolume == (Object)null) { TryBindPostProcessing(); } if (!((Object)(object)_ppVolume == (Object)null)) { float num = Mathf.InverseLerp(0f, MaxInsanity, _insanity); if ((Object)(object)_ppVignette != (Object)null) { ((ParameterOverride<float>)(object)_ppVignette.intensity).value = Mathf.Clamp01(_vignetteDefault + VignetteAdd * num); } if ((Object)(object)_ppGrain != (Object)null) { ((ParameterOverride<float>)(object)_ppGrain.intensity).value = Mathf.Clamp01(_grainDefault + GrainIntensityAdd * num); } if ((Object)(object)_ppChromatic != (Object)null) { ((ParameterOverride<float>)(object)_ppChromatic.intensity).value = Mathf.Clamp01(_chromaticDefault + ChromaticAberrationAdd * num); } if ((Object)(object)_ppDistortion != (Object)null) { ((ParameterOverride<float>)(object)_ppDistortion.intensity).value = Mathf.Lerp(_distortionDefault, LensDistortionTarget, num); } if (EnableDesaturate && (Object)(object)_ppColor != (Object)null) { float num2 = Mathf.Clamp01(_insanity / Mathf.Max(1f, DesaturateAt)); float value = Mathf.Lerp(_saturationDefault, -100f, num2); ((ParameterOverride<float>)(object)_ppColor.saturation).value = value; } } } private int CountNearbyFriends(Vector3 myPos, PlayerAvatar me) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) int num = 0; List<PlayerAvatar> playerList = GameDirector.instance.PlayerList; if (playerList == null) { return 0; } for (int i = 0; i < playerList.Count; i++) { PlayerAvatar val = playerList[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)me)) { float num2 = Vector3.Distance(myPos, ((Component)val).transform.position); if (num2 <= FriendRadius) { num++; } } } return num; } private int CountNearbyEnemies(Vector3 myPos) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) int num = 0; EnemyDirector instance = EnemyDirector.instance; if ((Object)(object)instance == (Object)null || instance.enemiesSpawned == null || instance.enemiesSpawned.Count == 0) { return 0; } float enemyProximityRadius = EnemyProximityRadius; float num2 = enemyProximityRadius * enemyProximityRadius; foreach (EnemyParent item in instance.enemiesSpawned) { if (!((Object)(object)item == (Object)null)) { Vector3 val = ((Component)item).transform.position - myPos; if (((Vector3)(ref val)).sqrMagnitude <= num2) { num++; } } } return num; } private bool EnemyVisible(Camera cam, PlayerAvatar me) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { return false; } EnemyDirector instance = EnemyDirector.instance; if ((Object)(object)instance == (Object)null || instance.enemiesSpawned == null || instance.enemiesSpawned.Count == 0) { return false; } Vector3 position = ((Component)cam).transform.position; Vector3 forward = ((Component)cam).transform.forward; float num = Mathf.Cos(EnemyFOVDegrees * (MathF.PI / 180f) * 0.5f); RaycastHit val4 = default(RaycastHit); RaycastHit val5 = default(RaycastHit); foreach (EnemyParent item in instance.enemiesSpawned) { if ((Object)(object)item == (Object)null) { continue; } Vector3 val = ((Component)item).transform.position + Vector3.up * 1.2f; Vector3 val2 = val - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude > EnemyMaxRange) { continue; } Vector3 val3 = val2 / ((magnitude > 0.0001f) ? magnitude : 1f); float num2 = Vector3.Dot(forward, val3); if (!(num2 < num)) { if (!Physics.Raycast(position, val3, ref val4, magnitude)) { return true; } if ((Object)(object)((RaycastHit)(ref val4)).transform != (Object)null && ((Component)((RaycastHit)(ref val4)).transform).CompareTag("Enemy")) { return true; } if (Physics.SphereCast(position, 0.15f, val3, ref val5, magnitude) && (Object)(object)((RaycastHit)(ref val5)).transform != (Object)null && ((Component)((RaycastHit)(ref val5)).transform).CompareTag("Enemy")) { return true; } } } return false; } private void SafeGlitchTiny() { if (_glitchTimer > 0f) { return; } CameraGlitch instance = CameraGlitch.Instance; if ((Object)(object)instance != (Object)null) { try { instance.PlayTiny(); } catch { } } _glitchTimer = TinyGlitchCooldown; } private void SafeGlitchShort() { if (_glitchTimer > 0f) { return; } CameraGlitch instance = CameraGlitch.Instance; if ((Object)(object)instance != (Object)null) { try { instance.PlayShort(); } catch { } } _glitchTimer = ShortGlitchCooldown; } private void HallucinationTick(Transform me) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) float insanity = _insanity; if (insanity >= StrongHallucinationsAt) { if (Random.value < 0.25f * Time.deltaTime) { SafeGlitchShort(); } } else if (insanity >= HallucinationStartAt && Random.value < 0.12f * Time.deltaTime) { SafeGlitchTiny(); } if (insanity >= HallucinationStartAt) { _shadowSpawnTimer -= Time.deltaTime; if (_shadowSpawnTimer <= 0f) { SpawnShadowHallucination(me); ResetShadowTimer(first: false); } } if (insanity >= StrongHallucinationsAt && Random.value < 0.1f * Time.deltaTime) { SpawnPeripheryFlicker(); } if (insanity >= ExtremeHallucinationsAt) { if (Random.value < 0.06f * Time.deltaTime) { SpawnFlashLight(me.position); } if (Random.value < 0.04f * Time.deltaTime) { ((MonoBehaviour)this).StartCoroutine(CameraRollNudge()); } } } private void ResetShadowTimer(bool first) { float num = Mathf.InverseLerp(HallucinationStartAt, MaxInsanity, _insanity); float num2 = Mathf.Lerp(MaxShadowSpawnInterval, MinShadowSpawnInterval, num * 0.5f); float num3 = Mathf.Lerp(MaxShadowSpawnInterval, MinShadowSpawnInterval, num); if (num3 < num2) { float num4 = num3; num3 = num2; num2 = num4; } _shadowSpawnTimer = Random.Range(num2, num3); } private void SpawnShadowHallucination(Transform me) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) try { Camera val = _cam ?? Camera.main; GameObject go; if (!((Object)(object)val == (Object)null)) { float num = Random.Range(ShadowMinDistance, ShadowMaxDistance); float num2 = Random.Range(-35f, 35f); Vector3 val2 = Quaternion.Euler(0f, num2, 0f) * ((Component)val).transform.forward; Vector3 val3 = ((Component)val).transform.position + ((Vector3)(ref val2)).normalized * num; val3.y = me.position.y; val3 += Vector3.up * 0.1f; go = new GameObject("HallucinationShadow"); ((Object)go).hideFlags = (HideFlags)52; go.transform.position = val3; go.transform.LookAt(new Vector3(((Component)val).transform.position.x, go.transform.position.y, ((Component)val).transform.position.z)); AddPrimitive((PrimitiveType)1, new Vector3(0f, 1f, 0f), new Vector3(0.35f, 1.5f, 0.35f)); AddPrimitive((PrimitiveType)0, new Vector3(0f, 2.3f, 0f), new Vector3(0.55f, 0.55f, 0.55f)); AddPrimitive((PrimitiveType)3, new Vector3(0.55f, 1.2f, 0f), new Vector3(0.6f, 0.15f, 0.15f)); AddPrimitive((PrimitiveType)3, new Vector3(-0.55f, 1.2f, 0f), new Vector3(0.6f, 0.15f, 0.15f)); ShadowFader shadowFader = go.AddComponent<ShadowFader>(); shadowFader.Lifetime = ShadowLifetime; } void AddPrimitive(PrimitiveType type, Vector3 localPos, Vector3 localScale) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) GameObject val4 = GameObject.CreatePrimitive(type); val4.transform.SetParent(go.transform, false); val4.transform.localPosition = localPos; val4.transform.localScale = localScale; Renderer component = val4.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.material = new Material(Shader.Find("Standard")); component.material.SetColor("_Color", new Color(0f, 0f, 0f, 1f)); component.shadowCastingMode = (ShadowCastingMode)0; component.receiveShadows = false; component.material.EnableKeyword("_EMISSION"); component.material.SetColor("_EmissionColor", Color.black); } Collider component2 = val4.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { component2.enabled = false; } } } catch (Exception arg) { ManualLogSource logS = LogS; if (logS != null) { logS.LogDebug((object)$"Hallucination spawn failed: {arg}"); } } } private void SpawnPeripheryFlicker() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0065: 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) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_012a: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) try { Camera val = _cam ?? Camera.main; if (!((Object)(object)val == (Object)null)) { float num = ((Random.value < 0.5f) ? (-1f) : 1f); float num2 = Random.Range(3f, 6f); Vector3 val2 = ((Component)val).transform.right * num; Vector3 val3 = ((Component)val).transform.position + ((Component)val).transform.forward * num2 + val2 * Random.Range(2f, 3.5f); GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val4).name = "HallucinationPeriphery"; ((Object)val4).hideFlags = (HideFlags)52; val4.transform.position = val3; Transform transform = val4.transform; Vector3 val5 = ((Component)val).transform.position - val3; transform.rotation = Quaternion.LookRotation(((Vector3)(ref val5)).normalized, Vector3.up); Renderer component = val4.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.material = new Material(Shader.Find("Unlit/Color")); component.material.color = new Color(0f, 0f, 0f, 0.85f); } Collider component2 = val4.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { component2.enabled = false; } ShadowFader shadowFader = val4.AddComponent<ShadowFader>(); shadowFader.Lifetime = Random.Range(0.15f, 0.35f); } } catch { } } private void SpawnFlashLight(Vector3 me) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_0059: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) try { Camera val = _cam ?? Camera.main; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = Quaternion.Euler(0f, Random.Range(-30f, 30f), 0f) * ((Component)val).transform.forward; Vector3 position = ((Component)val).transform.position + val2 * Random.Range(4f, 8f); position.y = me.y + Random.Range(0.5f, 1.6f); GameObject val3 = new GameObject("HallucinationFlashLight"); ((Object)val3).hideFlags = (HideFlags)52; Light val4 = val3.AddComponent<Light>(); val4.type = (LightType)2; val4.range = Random.Range(4f, 7f); val4.intensity = 0f; val4.color = new Color(1f, Random.Range(0.1f, 0.4f), 0.1f); val3.transform.position = position; val3.AddComponent<FlashLightFader>().Init(0.12f, 0.4f); } } catch { } } [IteratorStateMachine(typeof(<CameraRollNudge>d__84))] private IEnumerator CameraRollNudge() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CameraRollNudge>d__84(0) { <>4__this = this }; } } public const string GUID = "empress.repo.insanitymod"; public const string Name = "Insanity & Hallucinations"; public const string Version = "1.2.0"; internal static ManualLogSource LogS; private Harmony _harmony; internal static ConfigEntry<float> CfgUI_PosX; internal static ConfigEntry<float> CfgUI_PosY; internal static ConfigEntry<float> CfgUI_Width; internal static ConfigEntry<float> CfgUI_Height; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown LogS = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("empress.repo.insanitymod"); _harmony.PatchAll(); CfgUI_PosX = ((BaseUnityPlugin)this).Config.Bind<float>("SanityUI", "PosX", 0f, "anchoredPosition.x (anchor 0.5,0)"); CfgUI_PosY = ((BaseUnityPlugin)this).Config.Bind<float>("SanityUI", "PosY", 36f, "anchoredPosition.y (anchor 0.5,0)"); CfgUI_Width = ((BaseUnityPlugin)this).Config.Bind<float>("SanityUI", "Width", 190f, "sizeDelta.x (width)"); CfgUI_Height = ((BaseUnityPlugin)this).Config.Bind<float>("SanityUI", "Height", 14f, "sizeDelta.y (height)"); GameObject val = new GameObject("[InsanityControllerHost]"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; val.AddComponent<InsanityController>(); val.AddComponent<SanityUIBootstrap>(); LogS.LogInfo((object)"Insanity & Hallucinations 1.2.0 loaded."); } private void OnDestroy() { if (_harmony == null) { return; } try { _harmony.UnpatchSelf(); } catch (Exception arg) { ManualLogSource logS = LogS; if (logS != null) { logS.LogDebug((object)$"UnpatchSelf failed: {arg}"); } } _harmony = null; } } internal sealed class SanityUIBootstrap : MonoBehaviour { [CompilerGenerated] private sealed class <Watcher>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SanityUIBootstrap <>4__this; private WaitForSeconds <wait>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Watcher>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <wait>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <wait>5__1 = new WaitForSeconds(0.5f); break; case 1: <>1__state = -1; break; } <>4__this.TryEnsureUI(); <>2__current = <wait>5__1; <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private bool _spawned; private GameObject _uiRoot; private RectTransform _lastParent; private void Awake() { Object.DontDestroyOnLoad((Object)(object)this); } private void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(Watcher()); } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { KillUI(); _spawned = false; } [IteratorStateMachine(typeof(<Watcher>d__7))] private IEnumerator Watcher() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Watcher>d__7(0) { <>4__this = this }; } private void TryEnsureUI() { if (IsInMenuOrNotReady()) { if (_spawned) { KillUI(); _spawned = false; } } else { if ((Object)(object)InsanityMod.InsanityController.Instance == (Object)null) { return; } HUDCanvas instance = HUDCanvas.instance; if ((Object)(object)instance == (Object)null) { return; } RectTransform component = ((Component)instance).GetComponent<RectTransform>(); if ((Object)(object)component == (Object)null) { return; } if ((Object)(object)_uiRoot != (Object)null) { if ((Object)(object)_uiRoot.transform == (Object)null) { _uiRoot = null; _spawned = false; } else if ((Object)(object)_uiRoot.transform.parent != (Object)(object)component) { _uiRoot.transform.SetParent((Transform)(object)component, false); _lastParent = component; return; } } if (!_spawned || !((Object)(object)_uiRoot != (Object)null)) { _uiRoot = CreateSanityUI(component); _lastParent = component; _spawned = (Object)(object)_uiRoot != (Object)null; } } } private bool IsInMenuOrNotReady() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 try { if (SemiFunc.MenuLevel()) { return true; } } catch { } if ((Object)(object)LevelGenerator.Instance == (Object)null) { return true; } if ((Object)(object)GameDirector.instance == (Object)null) { return true; } if ((int)GameDirector.instance.currentState != 2) { return true; } return false; } private void KillUI() { try { if ((Object)(object)_uiRoot != (Object)null) { Object.Destroy((Object)(object)_uiRoot); } } catch { } _uiRoot = null; _lastParent = null; } private GameObject CreateSanityUI(RectTransform parent) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Expected O, but got Unknown //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Expected O, but got Unknown //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Expected O, but got Unknown //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SanityUI", new Type[2] { typeof(RectTransform), typeof(CanvasGroup) }); val.transform.SetParent((Transform)(object)parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 0f); val2.anchorMax = new Vector2(0.5f, 0f); val2.pivot = new Vector2(0.5f, 0f); val2.anchoredPosition = new Vector2(InsanityMod.CfgUI_PosX.Value, InsanityMod.CfgUI_PosY.Value); val2.sizeDelta = new Vector2(InsanityMod.CfgUI_Width.Value, InsanityMod.CfgUI_Height.Value); CanvasGroup component = val.GetComponent<CanvasGroup>(); component.alpha = 1f; component.interactable = false; component.blocksRaycasts = false; GameObject val3 = new GameObject("BG", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(val.transform, false); RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; Image component2 = val3.GetComponent<Image>(); ((Graphic)component2).raycastTarget = false; ((Graphic)component2).color = new Color(0f, 0f, 0f, 0.45f); GameObject val5 = new GameObject("Fill", new Type[2] { typeof(RectTransform), typeof(Image) }); val5.transform.SetParent(val.transform, false); RectTransform val6 = (RectTransform)val5.transform; val6.anchorMin = new Vector2(0f, 0f); val6.anchorMax = new Vector2(1f, 1f); val6.offsetMin = new Vector2(2f, 2f); val6.offsetMax = new Vector2(-2f, -2f); Image component3 = val5.GetComponent<Image>(); ((Graphic)component3).raycastTarget = false; component3.type = (Type)3; component3.fillMethod = (FillMethod)0; component3.fillOrigin = 0; component3.fillAmount = 0f; ((Graphic)component3).color = new Color(0.2f, 0.95f, 0.2f, 0.95f); GameObject val7 = new GameObject("Label", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val7.transform.SetParent(val.transform, false); RectTransform val8 = (RectTransform)val7.transform; val8.anchorMin = new Vector2(0f, 0f); val8.anchorMax = new Vector2(0f, 1f); val8.pivot = new Vector2(0f, 0.5f); val8.sizeDelta = new Vector2(90f, 0f); val8.anchoredPosition = new Vector2(-95f, 0f); TextMeshProUGUI component4 = val7.GetComponent<TextMeshProUGUI>(); ((Graphic)component4).raycastTarget = false; ((TMP_Text)component4).fontSize = 14f; ((TMP_Text)component4).text = "SANITY"; ((TMP_Text)component4).alignment = (TextAlignmentOptions)4100; ((Graphic)component4).color = Color.white; GameObject val9 = new GameObject("Percent", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val9.transform.SetParent(val.transform, false); RectTransform val10 = (RectTransform)val9.transform; val10.anchorMin = new Vector2(1f, 0f); val10.anchorMax = new Vector2(1f, 1f); val10.pivot = new Vector2(1f, 0.5f); val10.sizeDelta = new Vector2(40f, 0f); val10.anchoredPosition = new Vector2(50f, 0f); TextMeshProUGUI component5 = val9.GetComponent<TextMeshProUGUI>(); ((Graphic)component5).raycastTarget = false; ((TMP_Text)component5).fontSize = 12f; ((TMP_Text)component5).alignment = (TextAlignmentOptions)4097; ((Graphic)component5).color = Color.white; SanityBarUI sanityBarUI = val.AddComponent<SanityBarUI>(); sanityBarUI.group = component; sanityBarUI.fill = component3; sanityBarUI.percent = component5; return val; } } internal sealed class SanityBarUI : MonoBehaviour { public CanvasGroup group; public Image fill; public TextMeshProUGUI percent; private float _vis; private RectTransform _rt; private float _pulsePhase; private void Awake() { _rt = ((Component)this).GetComponent<RectTransform>(); } private void Update() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00f5: 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_0173: Unknown result type (might be due to invalid IL or missing references) InsanityMod.InsanityController instance = InsanityMod.InsanityController.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)fill == (Object)null) && !((Object)(object)percent == (Object)null)) { float num = Mathf.Clamp01(instance.NormalizedInsanity); fill.fillAmount = num; ((TMP_Text)percent).text = Mathf.RoundToInt(instance.CurrentInsanity).ToString(); Color val = Color.Lerp(new Color(0.2f, 0.95f, 0.2f), new Color(1f, 0.86f, 0.1f), Mathf.SmoothStep(0f, 1f, num * 1.2f)); Color color = Color.Lerp(val, new Color(0.95f, 0.15f, 0.15f), Mathf.SmoothStep(0f, 1f, Mathf.Max(0f, num - 0.5f) * 2f)); ((Graphic)fill).color = color; float num2 = Mathf.Clamp01(instance.EnemyPressure01); _pulsePhase += Time.deltaTime * Mathf.Lerp(1f, 6f, num2); float num3 = 1f + Mathf.Sin(_pulsePhase) * 0.03f * num; if ((Object)(object)_rt != (Object)null) { ((Transform)_rt).localScale = new Vector3(num3, 1f, 1f); } bool flag = (Object)(object)HUD.instance != (Object)null && HUD.instance.hidden; float num4 = (flag ? 0f : 1f); if (!flag && num <= 0.001f) { num4 = 0.35f; } _vis = Mathf.MoveTowards(_vis, num4, Time.deltaTime * 6f); if ((Object)(object)group != (Object)null) { group.alpha = _vis; } } } } }