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 Paranoia v0.2.0
Paranoia.dll
Decompiled an hour agousing 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 TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Paranoia")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("Paranoia")] [assembly: AssemblyTitle("Paranoia")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 Paranoia { internal sealed class FakeFigure : MonoBehaviour { private enum Kind { Enemy, Teammate } private enum Phase { Waiting, Turning, Speaking, Attacking } private const float StareAngle = 12f; private const float StareSeconds = 0.2f; private const float RevealDistance = 4.5f; private const float TurnSeconds = 1.8f; private const float AttackSeconds = 0.9f; private Kind kind; private Phase phase; private float lifetime; private float born; private float stared; private float phaseTime; private Sound attackSound; private PlayerAvatar source; private TTSVoice voice; private Transform mouth; private Transform head; private Quaternion headRest; private float headMaxAngle = 45f; private readonly float[] spectrum = new float[256]; private Quaternion turnFrom; private Vector3 lungeFrom; private Vector3 lungeTo; private readonly List<Animator> animators = new List<Animator>(); private static readonly HashSet<string> loggedParameters = new HashSet<string>(); internal static FakeFigure FromPrefab(GameObject prefab, Vector3 position, Sound attack) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) FakeFigure fakeFigure = Create("Paranoia Enemy", position, Kind.Enemy, 10f); fakeFigure.attackSound = attack; if (!fakeFigure.CloneVisuals(prefab)) { Object.Destroy((Object)(object)((Component)fakeFigure).gameObject); return null; } fakeFigure.FaceCamera(1f); return fakeFigure; } internal static FakeFigure FromAvatar(PlayerAvatar source, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) FakeFigure fakeFigure = Create("Paranoia Teammate", position, Kind.Teammate, 20f); fakeFigure.source = source; if (fakeFigure.CopyPose(source.playerAvatarVisuals) == 0) { Object.Destroy((Object)(object)((Component)fakeFigure).gameObject); return null; } fakeFigure.FaceCamera(1f); Transform transform = ((Component)fakeFigure).transform; transform.rotation *= Quaternion.Euler(0f, (Random.value < 0.5f) ? 90f : (-90f), 0f); return fakeFigure; } private static FakeFigure Create(string name, Vector3 position, Kind kind, float lifetime) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.position = position; FakeFigure fakeFigure = val.AddComponent<FakeFigure>(); fakeFigure.kind = kind; fakeFigure.lifetime = lifetime; fakeFigure.born = Time.time; return fakeFigure; } private bool CloneVisuals(GameObject prefab) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Paranoia Holder"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(prefab, val.transform, false); val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; Strip(val2); int num = 0; Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].enabled) { num++; } } if (num == 0) { Object.Destroy((Object)(object)val); return false; } val2.transform.SetParent(((Component)this).transform, false); Object.Destroy((Object)(object)val); animators.AddRange(val2.GetComponentsInChildren<Animator>(true)); return true; } private static void Strip(GameObject root) { for (int i = 0; i < 8; i++) { bool flag = false; Component[] componentsInChildren = root.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !Keep(val) && !RequiredByOther(val)) { Object.DestroyImmediate((Object)(object)val); flag = true; } } if (!flag) { break; } } } private static bool RequiredByOther(Component c) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Component[] components = c.GetComponents<Component>(); foreach (Component val in components) { if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)c) { continue; } object[] customAttributes = ((object)val).GetType().GetCustomAttributes(typeof(RequireComponent), inherit: true); for (int j = 0; j < customAttributes.Length; j++) { RequireComponent val2 = (RequireComponent)customAttributes[j]; if (Matches(val2.m_Type0, c) || Matches(val2.m_Type1, c) || Matches(val2.m_Type2, c)) { return true; } } } return false; } private static bool Matches(Type type, Component c) { if (type != null) { return type.IsInstanceOfType(c); } return false; } private static bool Keep(Component c) { if (!(c is Transform) && !(c is MeshFilter) && !(c is MeshRenderer) && !(c is SkinnedMeshRenderer) && !(c is Animator) && !(c is Light)) { return c is LODGroup; } return true; } private int CopyPose(PlayerAvatarVisuals visuals) { //IL_000c: 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_00e9: 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_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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)visuals).transform; Transform transform2 = new GameObject("Model").transform; transform2.SetParent(((Component)this).transform, false); transform2.localScale = transform.lossyScale; int num = 0; PlayerAvatarTalkAnimation component = ((Component)visuals).GetComponent<PlayerAvatarTalkAnimation>(); Transform val = (((Object)(object)component != (Object)null && (Object)(object)component.objectToRotate != (Object)null) ? component.objectToRotate.transform : null); if ((Object)(object)val != (Object)null) { head = new GameObject("Head").transform; head.SetParent(transform2, false); head.localPosition = transform.InverseTransformPoint(val.position); head.localRotation = Quaternion.Inverse(transform.rotation) * val.rotation; headRest = head.localRotation; headMaxAngle = component.rotationMaxAngle; } mouth = new GameObject("Mouth").transform; mouth.SetParent(transform2, false); mouth.localPosition = (((Object)(object)visuals.TTSTransform != (Object)null) ? transform.InverseTransformPoint(visuals.TTSTransform.position) : (Vector3.up * 1.6f)); List<KeyValuePair<Transform, bool>> list = new List<KeyValuePair<Transform, bool>>(); Renderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Renderer>(true); foreach (Renderer val2 in componentsInChildren) { Mesh val3 = null; if (val2 is MeshRenderer) { MeshFilter component2 = ((Component)val2).GetComponent<MeshFilter>(); val3 = ((component2 != null) ? component2.sharedMesh : null); } else { SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null); if (val4 != null) { val3 = new Mesh(); val4.BakeMesh(val3); } } if (!((Object)(object)val3 == (Object)null) && val2.enabled && ((Component)val2).gameObject.activeInHierarchy) { GameObject val5 = new GameObject(((Object)val2).name); val5.transform.SetParent(transform2, false); val5.transform.localPosition = transform.InverseTransformPoint(((Component)val2).transform.position); val5.transform.localRotation = Quaternion.Inverse(transform.rotation) * ((Component)val2).transform.rotation; val5.transform.localScale = Divide(((Component)val2).transform.lossyScale, transform.lossyScale); val5.AddComponent<MeshFilter>().sharedMesh = val3; ((Renderer)val5.AddComponent<MeshRenderer>()).sharedMaterials = val2.sharedMaterials; list.Add(new KeyValuePair<Transform, bool>(val5.transform, (Object)(object)val != (Object)null && ((Component)val2).transform.IsChildOf(val))); num++; } } foreach (KeyValuePair<Transform, bool> item in list) { if (item.Value) { item.Key.SetParent(head, true); } } return num; } private void LateUpdate() { //IL_0021: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d8: 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) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Vector3 val = ((Component)this).transform.position + Vector3.up * 1f; Vector3 val2 = val - ((Component)main).transform.position; float magnitude = ((Vector3)(ref val2)).magnitude; phaseTime += Time.deltaTime; switch (phase) { case Phase.Waiting: { if (Time.time - born > lifetime) { Object.Destroy((Object)(object)((Component)this).gameObject); break; } if (kind == Kind.Enemy) { FaceCamera(1f); } bool flag = Vector3.Angle(((Component)main).transform.forward, val2) < 12f && !Physics.Linecast(((Component)main).transform.position, val, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); stared = (flag ? (stared + Time.deltaTime) : 0f); if (stared >= 0.2f || magnitude < 4.5f) { Reveal(main); } break; } case Phase.Attacking: { float num2 = Mathf.Clamp01(phaseTime / 0.35f); ((Component)this).transform.position = Vector3.Lerp(lungeFrom, lungeTo, num2 * num2 * (3f - 2f * num2)); FaceCamera(1f); if (phaseTime >= 0.9f) { Poof(3f); } break; } case Phase.Turning: { if (magnitude < 2f) { Poof(1.5f); break; } float num = Mathf.Clamp01(phaseTime / 1.8f); ((Component)this).transform.rotation = Quaternion.Slerp(turnFrom, CameraRotation(), num * num * (3f - 2f * num)); if (num >= 1f) { ScareEffect.Play(); voice = FakeVoice.Speak(((Object)(object)mouth != (Object)null) ? mouth : ((Component)this).transform, source); phase = Phase.Speaking; phaseTime = 0f; } break; } case Phase.Speaking: FaceCamera(Time.deltaTime * 3f); AnimateHead(); if ((phaseTime > 1.5f && ((Object)(object)voice == (Object)null || !voice.isSpeaking)) || phaseTime > 8f || magnitude < 2f) { Poof(1.5f); } break; } } private void AnimateHead() { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)head == (Object)null) { return; } float num = 0f; AudioSource val = (((Object)(object)voice != (Object)null) ? voice.audioSource : null); if ((Object)(object)val != (Object)null && val.isPlaying) { val.GetSpectrumData(spectrum, 0, (FFTWindow)5); float num2 = 0f; float[] array = spectrum; foreach (float num3 in array) { num2 = Mathf.Max(num2, num3); } num2 *= 2f; if (num2 > 0.005f) { num = Mathf.Lerp(0f, 0f - headMaxAngle, num2 * 4f); } } head.localRotation = Quaternion.Slerp(head.localRotation, headRest * Quaternion.Euler(num, 0f, 0f), 100f * Time.deltaTime); } private void Reveal(Camera cam) { //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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008d: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) phaseTime = 0f; if (kind == Kind.Teammate) { phase = Phase.Turning; turnFrom = ((Component)this).transform.rotation; return; } phase = Phase.Attacking; Attack(); if (attackSound != null) { Hallucinations.PlayAt(attackSound, ((Component)this).transform.position + Vector3.up * 1f); } ScareEffect.Play(); Vector3 val = ((Component)cam).transform.position - ((Component)this).transform.position; val.y = 0f; lungeFrom = ((Component)this).transform.position; lungeTo = ((Component)this).transform.position + ((Vector3)(ref val)).normalized * Mathf.Clamp(((Vector3)(ref val)).magnitude - 2.5f, 0f, 1.5f); } private void Attack() { //IL_00e5: 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_0176: Invalid comparison between Unknown and I4 //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Invalid comparison between Unknown and I4 string[] array = new string[12] { "attack", "bite", "lunge", "swing", "slash", "grab", "aggro", "chase", "scream", "open_mouth", "notice", "hastarget" }; foreach (Animator animator in animators) { if ((Object)(object)animator == (Object)null || (Object)(object)animator.runtimeAnimatorController == (Object)null) { continue; } AnimatorControllerParameter[] parameters = animator.parameters; if (loggedParameters.Add(((Object)animator.runtimeAnimatorController).name)) { List<string> list = new List<string>(); AnimatorControllerParameter[] array2 = parameters; foreach (AnimatorControllerParameter val in array2) { list.Add($"{val.name}:{val.type}"); } Plugin.Log.LogInfo((object)("Animator " + ((Object)animator.runtimeAnimatorController).name + ": " + string.Join(", ", list))); } string[] array3 = array; foreach (string value in array3) { bool flag = false; AnimatorControllerParameter[] array2 = parameters; foreach (AnimatorControllerParameter val2 in array2) { if (val2.name.ToLowerInvariant().Contains(value)) { if ((int)val2.type == 9) { animator.SetTrigger(val2.nameHash); flag = true; } else if ((int)val2.type == 4) { animator.SetBool(val2.nameHash, true); flag = true; } } } if (flag) { break; } } } } private void Poof(float scale) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //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) GameObject val = (((Object)(object)AssetManager.instance != (Object)null) ? AssetManager.instance.prefabTeleportEffect : null); if ((Object)(object)val != (Object)null) { Object.Instantiate<GameObject>(val, ((Component)this).transform.position + Vector3.up * 1f, Quaternion.identity).transform.localScale = Vector3.one * scale; } Object.Destroy((Object)(object)((Component)this).gameObject); } private Quaternion CameraRotation() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return ((Component)this).transform.rotation; } Vector3 val = ((Component)main).transform.position - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f)) { return ((Component)this).transform.rotation; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } private void FaceCamera(float amount) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, CameraRotation(), Mathf.Clamp01(amount)); } private static Vector3 Divide(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) return new Vector3(a.x / b.x, a.y / b.y, a.z / b.z); } } internal sealed class FakeSpeechText : MonoBehaviour { private static readonly Color Flash = Color.yellow; private TTSVoice voice; private Transform follow; private TextMeshProUGUI text; private RectTransform rect; private Vector3 position; private Color color = Flash; private float flashTimer = 0.1f; private float alpha; private float lastWordTime = -1f; private bool started; internal static void Create(TTSVoice voice, Transform follow) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) WorldSpaceUIParent instance = WorldSpaceUIParent.instance; if (!((Object)(object)voice == (Object)null) && !((Object)(object)follow == (Object)null) && !((Object)(object)instance == (Object)null) && !((Object)(object)instance.TTSPrefab == (Object)null)) { GameObject val = Object.Instantiate<GameObject>(instance.TTSPrefab, ((Component)instance).transform.position, ((Component)instance).transform.rotation, ((Component)instance).transform); WorldSpaceUITTS component = val.GetComponent<WorldSpaceUITTS>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>(); if ((Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val); return; } FakeSpeechText fakeSpeechText = val.AddComponent<FakeSpeechText>(); fakeSpeechText.voice = voice; fakeSpeechText.follow = follow; fakeSpeechText.text = component2; fakeSpeechText.rect = val.GetComponent<RectTransform>(); fakeSpeechText.position = follow.position; ((TMP_Text)component2).text = ""; ((Graphic)component2).color = new Color(Flash.r, Flash.g, Flash.b, 0f); } } private void LateUpdate() { //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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) //IL_00ff: 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) Camera main = Camera.main; if ((Object)(object)voice == (Object)null || (Object)(object)follow == (Object)null || (Object)(object)main == (Object)null) { FadeOut(); return; } if (voice.isSpeaking) { started = true; } if (started && !voice.isSpeaking) { FadeOut(); return; } if (voice.currentWordTime != lastWordTime && !string.IsNullOrEmpty(voice.voiceText)) { lastWordTime = voice.currentWordTime; ((TMP_Text)text).text = voice.voiceText; color = Flash; flashTimer = 0.1f; } flashTimer -= Time.deltaTime; if (flashTimer <= 0f) { color = Color.Lerp(color, Color.white, 20f * Time.deltaTime); } float num = Mathf.Clamp(Vector3.Distance(((Component)main).transform.position, follow.position), 5f, 20f); float num2 = (started ? (1f - (num - 5f) / 15f) : 0f); alpha = Mathf.Lerp(alpha, num2, 30f * Time.deltaTime); Apply(); } private void FadeOut() { alpha = Mathf.Lerp(alpha, 0f, 30f * Time.deltaTime); if (alpha < 0.01f) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Apply(); } } private void Apply() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)follow != (Object)null) { position = Vector3.Lerp(position, follow.position, 10f * Time.deltaTime); } rect.anchoredPosition = Vector2.op_Implicit(SemiFunc.UIWorldToCanvasPosition(position)); ((Graphic)text).color = new Color(color.r, color.g, color.b, alpha); } } internal static class FakeVoice { internal static readonly string[] Lines = new string[10] { "I'm not him.", "You've strayed too far off.", "Why did you leave me?", "They can't hear you down here.", "Come closer.", "Don't turn around.", "We're all still in the truck.", "You should have stayed with us.", "It's so quiet here.", "I've been waiting for you." }; private static GameObject ttsPrefab; private static bool missing; private static AudioMixerGroup mixer; internal static TTSVoice Speak(Transform mouth, PlayerAvatar source) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.TeammateVoice.Value || !Find()) { return null; } GameObject val = Object.Instantiate<GameObject>(ttsPrefab, mouth); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; TTSVoice component = val.GetComponent<TTSVoice>(); AudioSource component2 = val.GetComponent<AudioSource>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val); return null; } AudioLowPassLogic component3 = val.GetComponent<AudioLowPassLogic>(); if ((Object)(object)component3 != (Object)null) { component3.Fetch = true; component3.Setup(); } if ((Object)(object)mixer != (Object)null) { component2.outputAudioMixerGroup = mixer; } component2.spatialBlend = 1f; component2.volume = 1f; AudioSource val2 = (((Object)(object)source != (Object)null && (Object)(object)source.voiceChat != (Object)null) ? source.voiceChat.ttsAudioSource : null); if ((Object)(object)val2 != (Object)null) { component2.pitch = val2.pitch; } string text = Lines[Random.Range(0, Lines.Length)]; component.TTSSpeakNow(text, false, "en-US"); Plugin.Log.LogInfo((object)("Hallucination säger: \"" + text + "\"")); FakeSpeechText.Create(component, mouth); return component; } private static bool Find() { if ((Object)(object)ttsPrefab != (Object)null) { return true; } if (missing) { return false; } PlayerVoiceChat val = Object.FindAnyObjectByType<PlayerVoiceChat>(); if ((Object)(object)val == (Object)null) { GameObject val2 = Resources.Load<GameObject>("Voice"); val = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<PlayerVoiceChat>() : null); } if ((Object)(object)val == (Object)null || (Object)(object)val.TTSprefab == (Object)null) { Plugin.Log.LogWarning((object)"Hittade ingen TTS-röst; falska lagkamrater blir tysta."); missing = true; return false; } ttsPrefab = val.TTSprefab; mixer = val.mixerTTSSound; return true; } } internal static class Hallucinations { private static readonly string[] AttackWords = new string[10] { "attack", "bite", "lunge", "swing", "slash", "shoot", "grab", "scream", "aggro", "chase" }; private static readonly List<Sound> enemySounds = new List<Sound>(); private static readonly List<GameObject> enemyPrefabs = new List<GameObject>(); private static readonly Dictionary<GameObject, List<KeyValuePair<string, Sound>>> soundsByPrefab = new Dictionary<GameObject, List<KeyValuePair<string, Sound>>>(); private static bool loaded; internal static void Trigger(PlayerAvatar player, float severity) { Load(); List<Action> list = new List<Action>(); List<float> list2 = new List<float>(); if (Plugin.FakeSounds.Value && enemySounds.Count > 0) { list.Add(delegate { FakeSound(player); }); list2.Add(5f); } if (Plugin.FakeEnemies.Value && enemyPrefabs.Count > 0) { list.Add(delegate { FakeEnemy(player); }); list2.Add(1.5f + 2f * (1f - severity)); } if (Plugin.FakeTeammates.Value) { list.Add(delegate { FakeTeammate(player); }); list2.Add(1f + 1.5f * (1f - severity)); } if (list.Count == 0) { return; } float num = 0f; foreach (float item in list2) { num += item; } float num2 = Random.value * num; for (int num3 = 0; num3 < list.Count; num3++) { num2 -= list2[num3]; if (num2 <= 0f || num3 == list.Count - 1) { list[num3](); break; } } } internal static AudioSource PlayAt(Sound sound, Vector3 at) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) AudioSource source = sound.Source; sound.Source = null; try { float num = ((sound.OffscreenVolume > 0.05f) ? (1f / sound.OffscreenVolume) : 1f); float num2 = ((sound.OffscreenFalloff > 0.05f) ? (1f / sound.OffscreenFalloff) : 1f); return sound.Play(at, 1f, 1f, num, num2); } finally { sound.Source = source; } } private static void FakeSound(PlayerAvatar player) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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) Vector3 val = Placement.Behind(player, 5f, 12f); AudioSource val2 = PlayAt(enemySounds[Random.Range(0, enemySounds.Count)], val); ManualLogSource log = Plugin.Log; object obj; if (!((Object)(object)val2 != (Object)null)) { obj = "Hallucination: ljudet kunde inte spelas."; } else { AudioClip clip = val2.clip; obj = $"Hallucination: ljud ({((clip != null) ? ((Object)clip).name : null)}) vid {val}."; } log.LogInfo(obj); } private static void FakeEnemy(PlayerAvatar player) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) GameObject val = enemyPrefabs[Random.Range(0, enemyPrefabs.Count)]; if (!Placement.InCornerOfEye(player, 8f, 16f, out var position)) { Plugin.Log.LogInfo((object)"Hallucination: ingen plats för fiende, ljud i stället."); FakeSound(player); } else if ((Object)(object)FakeFigure.FromPrefab(val, position, AttackSound(val)) != (Object)null) { Plugin.Log.LogInfo((object)$"Hallucination: fiende ({((Object)val).name}) vid {position}."); } } private static void FakeTeammate(PlayerAvatar player) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (PlayerAvatar player2 in GameDirector.instance.PlayerList) { if ((Object)(object)player2 != (Object)null && (Object)(object)player2 != (Object)(object)player && !player2.isDisabled && !player2.deadSet) { list.Add(player2); } } PlayerAvatar val = ((list.Count > 0) ? list[Random.Range(0, list.Count)] : player); if ((Object)(object)val.playerAvatarVisuals == (Object)null || !Placement.InCornerOfEye(player, 7f, 14f, out var position)) { Plugin.Log.LogInfo((object)"Hallucination: ingen plats för lagkamrat, ljud i stället."); FakeSound(player); } else if ((Object)(object)FakeFigure.FromAvatar(val, position) != (Object)null) { Plugin.Log.LogInfo((object)string.Format("Hallucination: {0} vid {1}.", ((Object)(object)val == (Object)(object)player) ? "dubbelgångare" : val.playerName, position)); } } private static Sound AttackSound(GameObject prefab) { if (!soundsByPrefab.TryGetValue(prefab, out var value) || value.Count == 0) { return null; } string[] attackWords = AttackWords; foreach (string word in attackWords) { List<KeyValuePair<string, Sound>> list = value.FindAll((KeyValuePair<string, Sound> s) => s.Key.ToLowerInvariant().Contains(word)); if (list.Count > 0) { return list[Random.Range(0, list.Count)].Value; } } return value[Random.Range(0, value.Count)].Value; } private static void Load() { if (loaded || (Object)(object)EnemyDirector.instance == (Object)null) { return; } loaded = true; List<EnemySetup> list = new List<EnemySetup>(); list.AddRange(EnemyDirector.instance.enemiesDifficulty1 ?? new List<EnemySetup>()); list.AddRange(EnemyDirector.instance.enemiesDifficulty2 ?? new List<EnemySetup>()); list.AddRange(EnemyDirector.instance.enemiesDifficulty3 ?? new List<EnemySetup>()); HashSet<Sound> hashSet = new HashSet<Sound>(); foreach (EnemySetup item in list) { if ((Object)(object)item == (Object)null || item.spawnObjects == null) { continue; } foreach (PrefabRef spawnObject in item.spawnObjects) { GameObject val = ((spawnObject != null && ((PrefabRef<GameObject>)(object)spawnObject).IsValid()) ? ((PrefabRef<GameObject>)(object)spawnObject).Prefab : null); if ((Object)(object)val == (Object)null || enemyPrefabs.Contains(val)) { continue; } enemyPrefabs.Add(val); List<KeyValuePair<string, Sound>> list2 = new List<KeyValuePair<string, Sound>>(); soundsByPrefab[val] = list2; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if ((Object)(object)val2 == (Object)null) { continue; } FieldInfo[] fields = ((object)val2).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType != typeof(Sound)) { continue; } object? value = fieldInfo.GetValue(val2); Sound val3 = (Sound)((value is Sound) ? value : null); if (val3 != null && Usable(val3)) { list2.Add(new KeyValuePair<string, Sound>(fieldInfo.Name, val3)); if (hashSet.Add(val3)) { enemySounds.Add(val3); } } } } } } Plugin.Log.LogInfo((object)$"Material för hallucinationer: {enemySounds.Count} fiendeljud, {enemyPrefabs.Count} fiendemodeller."); } private static bool Usable(Sound sound) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 if (sound.Sounds == null || sound.Sounds.Length == 0 || sound.SpatialBlend < 0.5f) { return false; } if ((int)sound.Type == 7 || (int)sound.Type == 4) { return false; } AudioClip[] sounds = sound.Sounds; foreach (AudioClip val in sounds) { if ((Object)(object)val == (Object)null || val.length < 0.3f || val.length > 8f) { return false; } } return true; } } internal sealed class ParanoiaController : MonoBehaviour { private const float AloneDistance = 12f; private const float NearDistance = 6f; private float sanity = 100f; private float nextHallucination; private float nextLog; private void Update() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 PlayerAvatar instance = PlayerAvatar.instance; bool num = (Object)(object)instance != (Object)null && SemiFunc.RunIsLevel() && (int)GameDirector.instance.currentState == 2 && !instance.deadSet && !instance.isDisabled; bool flag = (Object)(object)MapToolController.instance != (Object)null && MapToolController.instance.Active; SanityBanner.Tick(num && flag, sanity, Plugin.Threshold.Value); if (num) { UpdateSanity(instance); if (Time.time >= nextLog) { nextLog = Time.time + 15f; Plugin.Log.LogInfo((object)$"Sinnesnärvaro: {sanity:0}"); } float value = Plugin.Threshold.Value; if (sanity >= value) { nextHallucination = 0f; } else if (nextHallucination <= 0f) { nextHallucination = Time.time + NextInterval(value); } else if (Time.time >= nextHallucination) { nextHallucination = Time.time + NextInterval(value); Hallucinations.Trigger(instance, sanity / value); } } } private void UpdateSanity(PlayerAvatar player) { //IL_008e: 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) if (Plugin.TestHallucinations.Value) { sanity = 0f; return; } if ((Object)(object)player.RoomVolumeCheck != (Object)null && player.RoomVolumeCheck.inTruck) { sanity = 100f; return; } float num = float.MaxValue; foreach (PlayerAvatar player2 in GameDirector.instance.PlayerList) { if ((Object)(object)player2 != (Object)null && (Object)(object)player2 != (Object)(object)player && !player2.isDisabled && !player2.deadSet) { num = Mathf.Min(num, Vector3.Distance(((Component)player2).transform.position, ((Component)player).transform.position)); } } float num2 = 0f; if (num <= 6f) { num2 += Plugin.RecoverNearFriends.Value; } else if (num > 12f) { num2 -= Plugin.DrainAlone.Value * (SemiFunc.IsMultiplayer() ? 1f : 0.5f); } if ((Object)(object)player.flashlightController != (Object)null && !player.flashlightController.LightActive) { num2 -= Plugin.DrainDark.Value; } PlayerHealth playerHealth = player.playerHealth; if ((Object)(object)playerHealth != (Object)null && playerHealth.maxHealth > 0 && playerHealth.health < playerHealth.maxHealth / 2) { num2 -= Plugin.DrainHurt.Value; } sanity = Mathf.Clamp(sanity + num2 * Time.deltaTime, 0f, 100f); } private void OnDestroy() { SanityBanner.Destroy(); } private float NextInterval(float threshold) { float num = Mathf.Clamp01(sanity / threshold); return Mathf.Lerp(Plugin.IntervalAtZero.Value, Plugin.IntervalAtThreshold.Value, num) * Random.Range(0.7f, 1.3f); } } internal static class Placement { private static readonly int WallMask = LayerMask.GetMask(new string[1] { "Default" }); internal static Vector3 Behind(PlayerAvatar player, float min, float max) { //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) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00dd: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : ((Component)player).transform); List<Vector3> list = new List<Vector3>(); foreach (Vector3 item in Points()) { Vector3 val2 = item - val.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude >= min && magnitude <= max && Vector3.Angle(val.forward, val2) > 100f) { list.Add(item + Vector3.up * 1f); } } if (list.Count > 0) { return list[Random.Range(0, list.Count)]; } Vector3 val3 = -val.forward; val3.y = 0f; return val.position + ((Vector3)(ref val3)).normalized * Random.Range(min, max); } internal static bool InCornerOfEye(PlayerAvatar player, float min, float max, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //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_002e: 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_0094: 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_009a: Unknown result type (might be due to invalid IL or missing references) //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_00aa: 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_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) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_010b: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0155: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return false; } Vector3 position2 = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref forward)).Normalize(); RaycastHit val2 = default(RaycastHit); RaycastHit val3 = default(RaycastHit); for (int i = 0; i < 30; i++) { float num = Random.Range(20f, 45f) * ((Random.value < 0.5f) ? (-1f) : 1f); Vector3 val = Quaternion.Euler(0f, num, 0f) * forward; float num2 = max; if (Physics.SphereCast(position2, 0.4f, val, ref val2, max, WallMask, (QueryTriggerInteraction)1)) { num2 = ((RaycastHit)(ref val2)).distance - 0.6f; } if (!(num2 < min) && Physics.Raycast(position2 + val * Random.Range(min, num2), Vector3.down, ref val3, 4f, WallMask, (QueryTriggerInteraction)1)) { Vector3 point = ((RaycastHit)(ref val3)).point; if (!Physics.Linecast(position2, point + Vector3.up * 1.2f, WallMask, (QueryTriggerInteraction)1) && !Physics.Linecast(position2, point + Vector3.up * 0.5f, WallMask, (QueryTriggerInteraction)1)) { position = point; return true; } } } return false; } private static IEnumerable<Vector3> Points() { List<LevelPoint> list = (((Object)(object)LevelGenerator.Instance != (Object)null) ? LevelGenerator.Instance.LevelPathPoints : null); if (list == null) { yield break; } foreach (LevelPoint item in list) { if ((Object)(object)item != (Object)null && !item.inStartRoom && !item.Truck) { yield return ((Component)item).transform.position; } } } } [BepInPlugin("kinglir.paranoia", "Paranoia", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "kinglir.paranoia"; public const string Name = "Paranoia"; public const string Version = "0.2.0"; internal static ManualLogSource Log; internal static ConfigEntry<float> DrainAlone; internal static ConfigEntry<float> DrainDark; internal static ConfigEntry<float> DrainHurt; internal static ConfigEntry<float> RecoverNearFriends; internal static ConfigEntry<float> Threshold; internal static ConfigEntry<float> IntervalAtThreshold; internal static ConfigEntry<float> IntervalAtZero; internal static ConfigEntry<bool> FakeSounds; internal static ConfigEntry<bool> FakeEnemies; internal static ConfigEntry<bool> FakeTeammates; internal static ConfigEntry<bool> ScareEffect; internal static ConfigEntry<float> ScareCooldown; internal static ConfigEntry<bool> TeammateVoice; internal static ConfigEntry<bool> TestHallucinations; private void Awake() { //IL_01f0: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; DrainAlone = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "DrainAlone", 0.6f, "Hur mycket sinnesnärvaron (0-100) sjunker per sekund när ingen lagkamrat är inom 12 m."); DrainDark = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "DrainDark", 0.3f, "Extra minskning per sekund när ficklampan är släckt."); DrainHurt = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "DrainHurt", 0.3f, "Extra minskning per sekund när hälsan är under hälften."); RecoverNearFriends = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "RecoverNearFriends", 1.5f, "Hur mycket den stiger per sekund med en lagkamrat inom 6 m (i lastbilen återställs den helt)."); Threshold = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "Threshold", 70f, "Under denna nivå börjar hallucinationerna."); IntervalAtThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "IntervalAtThreshold", 45f, "Ungefärlig tid (s) mellan hallucinationer precis under gränsen."); IntervalAtZero = ((BaseUnityPlugin)this).Config.Bind<float>("Sanity", "IntervalAtZero", 8f, "Ungefärlig tid (s) mellan hallucinationer vid noll."); FakeSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Hallucinations", "FakeSounds", true, "Fiendeljud bakom eller bredvid spelaren."); FakeEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Hallucinations", "FakeEnemies", true, "En fiende syns en kort stund och försvinner när man tittar på den eller går närmare."); FakeTeammates = ((BaseUnityPlugin)this).Config.Bind<bool>("Hallucinations", "FakeTeammates", true, "En kopia av en lagkamrat (eller av dig själv) står med sidan mot dig, vänder sig långsamt om när du tittar och säger något."); TeammateVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("Hallucinations", "TeammateVoice", true, "Den falska lagkamraten säger en slumpad replik med spelets TTS-röst."); ScareEffect = ((BaseUnityPlugin)this).Config.Bind<bool>("Hallucinations", "ScareEffect", true, "Spelets skräckeffekt (skak, vinjett, ljud) när en synlig hallucination avslöjar sig."); ScareCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Hallucinations", "ScareCooldown", 15f, "Minsta tid (s) mellan skräckeffekterna."); TestHallucinations = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "TestHallucinations", false, "Endast för test: sinnesnärvaron står på 0, så hallucinationerna kommer ofta."); new Harmony("kinglir.paranoia").PatchAll(); Log.LogInfo((object)"Paranoia 0.2.0 laddad."); } } [HarmonyPatch(typeof(RoundDirector), "Start")] internal static class RoundDirectorStartPatch { private static void Postfix(RoundDirector __instance) { if ((Object)(object)((Component)__instance).GetComponent<ParanoiaController>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<ParanoiaController>(); } } } internal static class SanityBanner { private const float Width = 420f; private const float FadeSpeed = 6f; private static readonly Color Green = new Color(0.45f, 1f, 0.45f); private static readonly Color Yellow = new Color(1f, 0.88f, 0.3f); private static readonly Color Red = new Color(1f, 0.3f, 0.28f); private static Texture2D frameTexture; private static Texture2D textTexture; private static GameObject canvasObject; private static CanvasGroup group; private static RawImage text; private static Color current = Green; internal static void Tick(bool show, float sanity, float threshold) { //IL_0043: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)canvasObject == (Object)null) { if (!show || !Create()) { return; } group.alpha = 0f; } Color val = ((sanity >= threshold) ? Green : ((sanity >= threshold * 0.5f) ? Yellow : Red)); current = Color.Lerp(current, val, Time.deltaTime * 4f); ((Graphic)text).color = current; group.alpha = Mathf.MoveTowards(group.alpha, show ? 1f : 0f, Time.deltaTime * 6f); } internal static void Destroy() { if ((Object)(object)canvasObject != (Object)null) { Object.Destroy((Object)(object)canvasObject); canvasObject = null; } } private static bool Create() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)frameTexture == (Object)null && (Object)(object)(frameTexture = Load("Paranoia.sanity_frame.png")) == (Object)null) { return false; } if ((Object)(object)textTexture == (Object)null && (Object)(object)(textTexture = Load("Paranoia.sanity_text.png")) == (Object)null) { return false; } canvasObject = new GameObject("Paranoia Sanity"); Canvas obj = canvasObject.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 40; CanvasScaler obj2 = canvasObject.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; group = canvasObject.AddComponent<CanvasGroup>(); group.interactable = false; group.blocksRaycasts = false; Image(frameTexture, "Frame"); text = Image(textTexture, "Text"); ((Graphic)text).color = current; return true; } private static RawImage Image(Texture2D texture, string name) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(canvasObject.transform, false); RawImage obj = val.AddComponent<RawImage>(); obj.texture = (Texture)(object)texture; ((Graphic)obj).raycastTarget = false; RectTransform rectTransform = ((Graphic)obj).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.anchoredPosition = new Vector2(40f, 0f); rectTransform.sizeDelta = new Vector2(420f, 420f * (float)((Texture)texture).height / (float)((Texture)texture).width); return obj; } private static Texture2D Load(string resource) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown using Stream stream = typeof(SanityBanner).Assembly.GetManifestResourceStream(resource); if (stream == null) { Plugin.Log.LogError((object)(resource + " saknas i DLL:en.")); return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, array)) { Plugin.Log.LogError((object)("Kunde inte läsa " + resource + ".")); return null; } ((Texture)val).wrapMode = (TextureWrapMode)1; Object.DontDestroyOnLoad((Object)(object)val); return val; } } internal sealed class ScareEffect : MonoBehaviour { private const float Duration = 2.5f; private static float lastScare = -999f; private float timer; internal static void Play() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (Plugin.ScareEffect.Value && !(Time.time - lastScare < Plugin.ScareCooldown.Value)) { lastScare = Time.time; GameDirector.instance.CameraImpact.Shake(2f, 0.5f); GameDirector.instance.CameraShake.Shake(2f, 1f); PlayerDeathHead val = (((Object)(object)PlayerAvatar.instance != (Object)null) ? PlayerAvatar.instance.playerDeathHead : null); if ((Object)(object)val != (Object)null && (Object)(object)val.seenSound != (Object)null && (Object)(object)AudioScare.instance != (Object)null) { AudioScare.instance.PlayCustom(val.seenSound, 0.3f, 60f); } new GameObject("Paranoia Scare").AddComponent<ScareEffect>().timer = 2.5f; } } private void Update() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) timer -= Time.deltaTime; if (timer <= 0f) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } CameraZoom.Instance.OverrideZoomSet(75f, 0.1f, 0.25f, 0.25f, ((Component)this).gameObject, 150); PostProcessing.Instance.VignetteOverride(Color.black, 0.4f, 1f, 1f, 0.5f, 0.1f, ((Component)this).gameObject, 999); PostProcessing.Instance.SaturationOverride(-50f, 1f, 0.5f, 0.1f, ((Component)this).gameObject, 999); PostProcessing.Instance.ContrastOverride(5f, 1f, 0.5f, 0.1f, ((Component)this).gameObject, 999); GameDirector.instance.CameraImpact.Shake(10f * Time.deltaTime, 0.1f); GameDirector.instance.CameraShake.Shake(10f * Time.deltaTime, 1f); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }