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 LethalPoppers v1.0.0
LethalPoppers.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalPoppers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ae19e939927d767c65ad7d45bae9448cdefc3edb")] [assembly: AssemblyProduct("LethalPoppers")] [assembly: AssemblyTitle("LethalPoppers")] [assembly: AssemblyVersion("1.0.0.0")] [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 LethalPoppers { internal static class BottleModel { private const int Segments = 20; private const float SmoothAngle = 46f; private const float Bottom = -0.07f; private const float Top = 0.07f; private const float BodyRadius = 0.0325f; private const float ShoulderStart = 0.022f; private const float NeckRadius = 0.012f; private const float NeckBase = 0.042f; private const float NeckTop = 0.052f; private const float CapRadius = 0.0155f; private const float CapBottom = 0.044f; private const float LabelRadius = 0.033099998f; private const float LabelBottom = -0.05f; private const float LabelTop = 0.012f; private static readonly Dictionary<char, string[]> Glyphs = new Dictionary<char, string[]> { ['P'] = new string[7] { "####.", "#...#", "#...#", "####.", "#....", "#....", "#...." }, ['O'] = new string[7] { ".###.", "#...#", "#...#", "#...#", "#...#", "#...#", ".###." }, ['E'] = new string[7] { "#####", "#....", "#....", "####.", "#....", "#....", "#####" }, ['R'] = new string[7] { "####.", "#...#", "#...#", "####.", "#.#..", "#..#.", "#...#" }, ['S'] = new string[7] { ".####", "#....", "#....", ".###.", "....#", "....#", "####." } }; internal static Mesh Body() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00ca: Unknown result type (might be due to invalid IL or missing references) List<Vector2> list = new List<Vector2> { new Vector2(0f, -0.07f), new Vector2(0.028499998f, -0.07f), new Vector2(0.0325f, -0.066f), new Vector2(0.0325f, 0.022f) }; for (int i = 1; i <= 5; i++) { float num = (float)i * MathF.PI * 0.5f / 5f; list.Add(new Vector2(0.012f + 0.020499999f * Mathf.Cos(num), 0.022f + 0.02f * Mathf.Sin(num))); } list.Add(new Vector2(0.012f, 0.052f)); list.Add(new Vector2(0f, 0.052f)); return Lathe("PoppersBody", list.ToArray(), unitV: false); } internal static Mesh Cap() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0054: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Vector2[] profile = (Vector2[])(object)new Vector2[5] { new Vector2(0.012f, 0.044f), new Vector2(0.0155f, 0.044f), new Vector2(0.0155f, 0.068f), new Vector2(0.013499999f, 0.07f), new Vector2(0f, 0.07f) }; return Lathe("PoppersCap", profile, unitV: false); } internal static Mesh Label() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector2[] profile = (Vector2[])(object)new Vector2[2] { new Vector2(0.033099998f, -0.05f), new Vector2(0.033099998f, 0.012f) }; return Lathe("PoppersLabel", profile, unitV: true); } internal static Texture2D LabelTexture() { //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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_00df: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Color32 val = default(Color32); ((Color32)(ref val))..ctor(byte.MaxValue, (byte)212, (byte)0, byte.MaxValue); Color32 val2 = default(Color32); ((Color32)(ref val2))..ctor((byte)200, (byte)24, (byte)24, byte.MaxValue); Color32 ink = default(Color32); ((Color32)(ref ink))..ctor((byte)20, (byte)16, (byte)12, byte.MaxValue); Color32[] array = (Color32[])(object)new Color32[2304]; for (int i = 0; i < 24; i++) { bool flag = i < 3 || i >= 21; for (int j = 0; j < 96; j++) { array[i * 96 + j] = (flag ? val2 : val); } } int num = "POPPERS".Length * 6 - 1; for (int k = 0; k < 2; k++) { int num2 = k * 48 + (48 - num) / 2; for (int l = 0; l < "POPPERS".Length; l++) { DrawGlyph(array, 96, Glyphs["POPPERS"[l]], num2 + l * 6, 19, ink); } } Texture2D val3 = new Texture2D(96, 24, (TextureFormat)4, false) { name = "PoppersLabel", filterMode = (FilterMode)0, wrapModeU = (TextureWrapMode)0, wrapModeV = (TextureWrapMode)1, hideFlags = (HideFlags)32 }; val3.SetPixels32(array); val3.Apply(false, true); return val3; } private static void DrawGlyph(Color32[] pixels, int width, string[] rows, int left, int top, Color32 ink) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < rows.Length; i++) { for (int j = 0; j < rows[i].Length; j++) { if (rows[i][j] == '#') { for (int k = 0; k < 2; k++) { pixels[(top - i * 2 - k) * width + left + j] = ink; } } } } } private static Mesh Lathe(string name, Vector2[] profile, bool unitV) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004b: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) int num = profile.Length - 1; Vector2[] array = (Vector2[])(object)new Vector2[num]; float[] array2 = new float[profile.Length]; for (int i = 0; i < num; i++) { Vector2 val = profile[i + 1] - profile[i]; int num2 = i; Vector2 val2 = new Vector2(val.y, 0f - val.x); array[num2] = ((Vector2)(ref val2)).normalized; array2[i + 1] = array2[i] + ((Vector2)(ref val)).magnitude; } float num3 = Mathf.Max(array2[num], 1E-06f); List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int> list4 = new List<int>(); for (int j = 0; j < num; j++) { int count = list.Count; for (int k = 0; k < 2; k++) { Vector2 val3 = profile[j + k]; Vector2 val4 = SharedNormal(array, j, (k == 0) ? (j - 1) : (j + 1)); float num4 = (unitV ? ((float)k) : (array2[j + k] / num3)); for (int l = 0; l <= 20; l++) { float num5 = (float)l * MathF.PI * 2f / 20f; float num6 = Mathf.Cos(num5); float num7 = Mathf.Sin(num5); list.Add(new Vector3(val3.x * num6, val3.y, val3.x * num7)); list2.Add(new Vector3(val4.x * num6, val4.y, val4.x * num7)); list3.Add(new Vector2((float)l / 20f, num4)); } } for (int m = 0; m < 20; m++) { int num8 = count + m; int item = num8 + 1; int num9 = count + 21 + m; int item2 = num9 + 1; list4.Add(num8); list4.Add(num9); list4.Add(item2); list4.Add(num8); list4.Add(item2); list4.Add(item); } } Mesh val5 = new Mesh { name = name, hideFlags = (HideFlags)32 }; val5.SetVertices(list); val5.SetNormals(list2); val5.SetUVs(0, list3); val5.SetTriangles(list4, 0); val5.RecalculateBounds(); val5.RecalculateTangents(); return val5; } private static Vector2 SharedNormal(Vector2[] bandNormals, int band, int neighbour) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0016: 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_001c: 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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = bandNormals[band]; if (neighbour < 0 || neighbour >= bandNormals.Length) { return val; } Vector2 val2 = bandNormals[neighbour]; if (!(Vector2.Angle(val, val2) <= 46f)) { return val; } Vector2 val3 = val + val2; return ((Vector2)(ref val3)).normalized; } } internal static class Dizziness { private static float target; private static float level; private static float hold; private static float clock; private static int lastTickedFrame = -1; private static bool disabled; internal static void AddDose() { if (!disabled) { float value = Plugin.Duration.Value; target = Mathf.Min(1f, target + Plugin.DosePerSniff.Value); hold = Mathf.Min(hold + value, Mathf.Max(value, Plugin.MaxDuration.Value)); if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.ShakeCamera((ScreenShakeType)0); } } } internal static void Tick() { if (disabled || lastTickedFrame == Time.frameCount) { return; } lastTickedFrame = Time.frameCount; try { Run(Time.deltaTime); } catch (Exception arg) { disabled = true; Plugin.Log.LogError((object)$"Unexpected error, disabling the dizzy effect for this session: {arg}"); try { Clear(); } catch { } } } private static void Run(float dt) { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val == (Object)null || val.isPlayerDead) { if (target > 0f || level > 0f) { Clear(); } } else if (!(target <= 0f) || !(level <= 0f)) { clock += dt; if (hold > 0f) { hold = Mathf.Max(0f, hold - dt); } else { target = Mathf.Max(0f, target - dt / Plugin.FadeOutSeconds.Value); } level = ((level < target) ? Mathf.MoveTowards(level, target, dt / Plugin.RampUpSeconds.Value) : target); ScreenFx.Apply(level, clock); EarFx.Apply(level, dt); if (level <= 0f && target <= 0f) { Clear(); } } } internal static void Clear() { target = (level = (hold = 0f)); ScreenFx.Teardown(); EarFx.Teardown(); } internal static void Reset() { clock = 0f; Clear(); } } internal static class EarFx { private const int GhostGirlSnapshot = 1; private const float MuffleOn = 0.15f; private const float MuffleOff = 0.05f; private static bool muffled; private static GameObject host; private static AudioSource ghostLoop; private static AudioSource earsRinging; private static AudioClip fallbackTone; internal static void Apply(float level, float dt) { SoundManager instance = SoundManager.Instance; if (!((Object)(object)instance == (Object)null)) { if ((Object)(object)host == (Object)null) { CreateSources(instance); } float num = Plugin.RingingVolume.Value * level; RingingSoundMode value = Plugin.RingingSound.Value; Drive(ghostLoop, (value != RingingSoundMode.EarsRinging) ? num : 0f, dt); Drive(earsRinging, (value != RingingSoundMode.GhostGirl) ? num : 0f, dt); UpdateMuffle(instance, level); } } internal static void Teardown() { Release(SoundManager.Instance); Silence(ghostLoop); Silence(earsRinging); } internal static void RedirectSnapshot(ref int snapshotID) { if (muffled && snapshotID == 0) { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!((Object)(object)val == (Object)null) && !val.isPlayerDead) { snapshotID = 1; } } } private static void UpdateMuffle(SoundManager sound, float level) { bool flag = Plugin.MuffleWorldAudio.Value && level > (muffled ? 0.05f : 0.15f); if (flag == muffled) { return; } if (!flag) { Release(sound); } else if (!(sound.earsRingingTimer > 0f)) { muffled = true; if (sound.currentMixerSnapshotID == 0) { sound.SetDiageticMixerSnapshot(1, 0.5f); } } } private static void Release(SoundManager sound) { if (muffled) { muffled = false; if ((Object)(object)sound != (Object)null && sound.currentMixerSnapshotID == 1) { sound.SetDiageticMixerSnapshot(0, 2f); } } } private static void Drive(AudioSource source, float target, float dt) { if (!((Object)(object)source == (Object)null) && !((Object)(object)source.clip == (Object)null)) { source.volume = Mathf.Lerp(source.volume, target, 3f * dt); if (target > 0f && !source.isPlaying) { source.Play(); } else if (target <= 0f && source.isPlaying && source.volume < 0.01f) { source.Stop(); } } } private static void Silence(AudioSource source) { if (!((Object)(object)source == (Object)null)) { source.Stop(); source.volume = 0f; } } private static void CreateSources(SoundManager sound) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown host = new GameObject("PoppersEarFx"); host.transform.SetParent(((Component)sound).transform, false); AudioSource val = FindGhostGirlLoop(); AudioSource ringingEarsAudio = sound.ringingEarsAudio; if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Could not find the ghost girl's loop; using the ear-ringing sound instead."); } AudioSource original = (((Object)(object)val != (Object)null) ? val : ringingEarsAudio); AudioSource original2 = (((Object)(object)ringingEarsAudio != (Object)null && (Object)(object)ringingEarsAudio.clip != (Object)null) ? ringingEarsAudio : val); ghostLoop = CreateSource(original); earsRinging = CreateSource(original2); Plugin.Log.LogInfo((object)("Ringing sounds: ghost girl '" + Describe(ghostLoop) + "', ears ringing '" + Describe(earsRinging) + "'.")); } private static AudioSource CreateSource(AudioSource original) { AudioSource obj = host.AddComponent<AudioSource>(); obj.clip = (((Object)(object)original != (Object)null && (Object)(object)original.clip != (Object)null) ? original.clip : FallbackTone()); obj.outputAudioMixerGroup = (((Object)(object)original != (Object)null) ? original.outputAudioMixerGroup : null); obj.loop = true; obj.playOnAwake = false; obj.spatialBlend = 0f; obj.dopplerLevel = 0f; obj.bypassReverbZones = true; obj.volume = 0f; return obj; } private static string Describe(AudioSource source) { if ((Object)(object)source == (Object)null || (Object)(object)source.clip == (Object)null) { return "none"; } AudioMixerGroup outputAudioMixerGroup = source.outputAudioMixerGroup; return ((Object)source.clip).name + "' via '" + (((Object)(object)outputAudioMixerGroup != (Object)null) ? ((Object)outputAudioMixerGroup).name : "no mixer group"); } private static AudioSource FindGhostGirlLoop() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && instance.levels != null) { SelectableLevel[] levels = instance.levels; foreach (SelectableLevel val in levels) { if (!((Object)(object)val == (Object)null)) { AudioSource val2 = Search(val.Enemies) ?? Search(val.OutsideEnemies) ?? Search(val.DaytimeEnemies); if ((Object)(object)val2 != (Object)null) { return val2; } } } } DressGirlAI[] array = Resources.FindObjectsOfTypeAll<DressGirlAI>(); foreach (DressGirlAI val3 in array) { if ((Object)(object)val3 != (Object)null && (Object)(object)val3.heartbeatMusic != (Object)null && (Object)(object)val3.heartbeatMusic.clip != (Object)null) { return val3.heartbeatMusic; } } return null; } private static AudioSource Search(List<SpawnableEnemyWithRarity> enemies) { if (enemies == null) { return null; } foreach (SpawnableEnemyWithRarity enemy in enemies) { if (enemy != null && !((Object)(object)enemy.enemyType == (Object)null) && !((Object)(object)enemy.enemyType.enemyPrefab == (Object)null)) { DressGirlAI componentInChildren = enemy.enemyType.enemyPrefab.GetComponentInChildren<DressGirlAI>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.heartbeatMusic != (Object)null && (Object)(object)componentInChildren.heartbeatMusic.clip != (Object)null) { return componentInChildren.heartbeatMusic; } } } return null; } private static AudioClip FallbackTone() { //IL_009e: 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) if ((Object)(object)fallbackTone != (Object)null) { return fallbackTone; } float[] array = new float[88200]; for (int i = 0; i < array.Length; i++) { float num = (float)i / 44100f; float num2 = 0.75f + 0.25f * Mathf.Sin(MathF.PI * num); array[i] = 0.12f * num2 * (Mathf.Sin(MathF.PI * 10400f * num) + Mathf.Sin(MathF.PI * 10500f * num)); } fallbackTone = AudioClip.Create("PoppersRinging", array.Length, 1, 44100, false); fallbackTone.SetData(array, 0); AudioClip obj = fallbackTone; ((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x20); return fallbackTone; } } [HarmonyPatch(typeof(StartOfRound), "Awake")] internal static class StartOfRoundAwakePatch { private static void Postfix(StartOfRound __instance) { PoppersRegistry.Graft(__instance); Dizziness.Reset(); } } [HarmonyPatch(typeof(StartOfRound), "LateUpdate")] internal static class StartOfRoundLateUpdatePatch { private static void Postfix() { TestKeys.Tick(); Dizziness.Tick(); } } [HarmonyPatch(typeof(SoundManager), "SetDiageticMixerSnapshot")] internal static class SetDiageticMixerSnapshotPatch { private static void Prefix(ref int snapshotID) { EarFx.RedirectSnapshot(ref snapshotID); } } public enum RingingSoundMode { GhostGirl, EarsRinging, Both } [BepInPlugin("kjelpw.LethalPoppers", "LethalPoppers", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "kjelpw.LethalPoppers"; public const string Name = "LethalPoppers"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static string PluginDirectory; internal static ConfigEntry<int> MinValue; internal static ConfigEntry<int> MaxValue; internal static ConfigEntry<float> WeightPounds; internal static ConfigEntry<int> SpawnRarity; internal static ConfigEntry<string> Moons; internal static ConfigEntry<float> ModelScale; internal static ConfigEntry<float> Duration; internal static ConfigEntry<float> MaxDuration; internal static ConfigEntry<float> DosePerSniff; internal static ConfigEntry<float> RampUpSeconds; internal static ConfigEntry<float> FadeOutSeconds; internal static ConfigEntry<float> BlurStrength; internal static ConfigEntry<float> DoubleVision; internal static ConfigEntry<float> Sway; internal static ConfigEntry<bool> PostProcessing; internal static ConfigEntry<RingingSoundMode> RingingSound; internal static ConfigEntry<float> RingingVolume; internal static ConfigEntry<bool> MuffleWorldAudio; internal static ConfigEntry<bool> EnableTestHotkey; internal static ConfigEntry<bool> FlipModel; private void Awake() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; PluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty; BindConfig(); try { SniffSound.Build(); PoppersRegistry.RegisterShell(); new Harmony("kjelpw.LethalPoppers").PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"LethalPoppers 1.0.0 loaded. Sniff responsibly."); } catch (Exception arg) { Log.LogError((object)string.Format("{0} failed to start and will stay dormant: {1}", "LethalPoppers", arg)); } } private void BindConfig() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Expected O, but got Unknown //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Expected O, but got Unknown //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Expected O, but got Unknown MinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Item", "MinValue", 50, new ConfigDescription("Lowest scrap value. This is before the game's scrap multiplier, which is about 0.4 in vanilla, so 50 sells for roughly $20. Only the host's value matters.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 2000), Array.Empty<object>())); MaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Item", "MaxValue", 120, new ConfigDescription("Highest scrap value, on the same scale as MinValue. Only the host's value matters.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 2000), Array.Empty<object>())); WeightPounds = ((BaseUnityPlugin)this).Config.Bind<float>("Item", "WeightPounds", 1f, new ConfigDescription("How heavy the bottle is, in pounds as shown in game. Each player's own setting applies to what they carry.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>())); SpawnRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Item", "SpawnRarity", 50, new ConfigDescription("Spawn weight against the other scrap on a moon; higher is more common. Vanilla scrap sits roughly between 1 and 100. Only the host's value matters.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); Moons = ((BaseUnityPlugin)this).Config.Bind<string>("Item", "Moons", "All", "Where it spawns: 'All', 'Vanilla', 'Modded', or a comma-separated list of LethalLib level names such as 'ExperimentationLevel, RendLevel'."); ModelScale = ((BaseUnityPlugin)this).Config.Bind<float>("Item", "ModelScale", 1f, new ConfigDescription("Size of the bottle model.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f), Array.Empty<object>())); Duration = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "Duration", 5f, new ConfigDescription("Seconds one sniff keeps you dizzy before it starts to wear off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 300f), Array.Empty<object>())); MaxDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "MaxDuration", 15f, new ConfigDescription("Sniffing again adds Duration on top of what's left, up to this many seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 600f), Array.Empty<object>())); DosePerSniff = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "DosePerSniff", 0.6f, new ConfigDescription("How much one sniff adds to the effect's strength. Strength is capped at 1, so with the default the second sniff takes you all the way.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>())); RampUpSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "RampUpSeconds", 1.5f, new ConfigDescription("How long the rush takes to hit after a sniff.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 30f), Array.Empty<object>())); FadeOutSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "FadeOutSeconds", 8f, new ConfigDescription("How long a full-strength effect takes to wear off once Duration is up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 120f), Array.Empty<object>())); BlurStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "BlurStrength", 1f, new ConfigDescription("How blurry your vision gets. 0 turns the blur off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); DoubleVision = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "DoubleVision", 1f, new ConfigDescription("Strength of the drifting second image. 0 turns it off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); Sway = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "Sway", 1f, new ConfigDescription("How much your view rolls and swims. 0 turns it off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); PostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect", "PostProcessing", true, "Also blur the distance and add colour fringing and a lens wobble through the game's own post-processing. Turn off if it misbehaves with a graphics mod."); RingingSound = ((BaseUnityPlugin)this).Config.Bind<RingingSoundMode>("Effect", "RingingSound", RingingSoundMode.GhostGirl, "What rings in your ears: GhostGirl (the loop that plays when she appears), EarsRinging (stun grenade tinnitus) or Both."); RingingVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Effect", "RingingVolume", 0.8f, new ConfigDescription("Volume of the ringing at full strength.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MuffleWorldAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("Effect", "MuffleWorldAudio", true, "Muffle everything around you the way the ghost girl does while you're dizzy."); EnableTestHotkey = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableTestHotkey", false, "Test keys: F9 takes a sniff without a bottle, F10 (host only) drops a bottle in front of you. Also logs where each bottle spawns."); FlipModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "FlipModel", false, "Turn the bottle the other way up, in case it is held upside down. Takes effect after a restart."); } } public class PoppersItem : GrabbableObject { private const float DoseTime = 0.7f; private const float SniffLength = 1.1f; private static readonly int UseTZPItem = Animator.StringToHash("useTZPItem"); private PlayerControllerB sniffer; private float sniffTime = -1f; private bool dosed; private bool Sniffing => sniffTime >= 0f; public override void Start() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).Start(); if (Plugin.EnableTestHotkey.Value) { Plugin.Log.LogInfo((object)$"A Poppers bottle spawned at {((Component)this).transform.position}."); } } public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (!buttonDown) { return; } try { if (Sniffing) { EndSniff(); } sniffer = base.playerHeldBy; sniffTime = 0f; dosed = false; AudioSource component = ((Component)this).GetComponent<AudioSource>(); AudioClip clip = SniffSound.Clip; if ((Object)(object)component != (Object)null && (Object)(object)clip != (Object)null) { component.PlayOneShot(clip); WalkieTalkie.TransmitOneShotAudio(component, clip, 1f); } if (IsLocal(sniffer)) { sniffer.activatingItem = true; sniffer.playerBodyAnimator.SetBool(UseTZPItem, true); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Sniff failed: {arg}"); } } public override void Update() { ((GrabbableObject)this).Update(); if (!Sniffing) { return; } try { if ((Object)(object)sniffer == (Object)null || (Object)(object)base.playerHeldBy != (Object)(object)sniffer || base.isPocketed || sniffer.isPlayerDead) { EndSniff(); return; } sniffTime += Time.deltaTime; if (!dosed && sniffTime >= 0.7f) { dosed = true; if (IsLocal(sniffer)) { Dizziness.AddDose(); } } if (sniffTime >= 1.1f) { EndSniff(); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Sniff update failed: {arg}"); sniffTime = -1f; } } public override void DiscardItem() { SafeEndSniff(); ((GrabbableObject)this).DiscardItem(); } public override void PocketItem() { SafeEndSniff(); ((GrabbableObject)this).PocketItem(); } public override void OnDestroy() { SafeEndSniff(); ((GrabbableObject)this).OnDestroy(); } private void SafeEndSniff() { if (!Sniffing) { return; } try { EndSniff(); } catch (Exception arg) { Plugin.Log.LogError((object)$"Ending sniff failed: {arg}"); sniffTime = -1f; } } private void EndSniff() { PlayerControllerB val = sniffer; sniffer = null; sniffTime = -1f; if (IsLocal(val)) { val.activatingItem = false; val.playerBodyAnimator.SetBool(UseTZPItem, false); } } private static bool IsLocal(PlayerControllerB player) { if ((Object)(object)player != (Object)null && (Object)(object)GameNetworkManager.Instance != (Object)null) { return (Object)(object)player == (Object)(object)GameNetworkManager.Instance.localPlayerController; } return false; } } internal static class PoppersRegistry { internal const string ItemName = "Poppers"; private const string HoldDonor = "TZP-Inhalant"; private static readonly string[] GlassDonors = new string[3] { "Pill bottle", "Perfume bottle", "Flask" }; internal static Item Item; internal static GameObject Prefab; private static Transform model; private static MeshRenderer body; private static MeshRenderer label; private static MeshRenderer cap; private static BoxCollider grabCollider; private static Transform scanNode; private static bool grafted; internal static void RegisterShell() { //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) Item = ScriptableObject.CreateInstance<Item>(); ((Object)Item).name = "Poppers"; Item.itemName = "Poppers"; Item.isScrap = true; Item.minValue = Mathf.Min(Plugin.MinValue.Value, Plugin.MaxValue.Value); Item.maxValue = Mathf.Max(Plugin.MinValue.Value, Plugin.MaxValue.Value); Item.weight = 1f + Plugin.WeightPounds.Value / 105f; Item.twoHanded = false; Item.twoHandedAnimation = false; Item.requiresBattery = false; Item.automaticallySetUsingPower = false; Item.holdButtonUse = false; Item.syncUseFunction = true; Item.canBeGrabbedBeforeGameStart = true; Item.isConductiveMetal = false; Item.toolTips = new string[1] { "Sniff : [LMB]" }; Item.restingRotation = Vector3.zero; Item.verticalOffset = 0.03f; Item.meshVariants = (Mesh[])(object)new Mesh[0]; Item.materialVariants = (Material[])(object)new Material[0]; Item.clinkAudios = (AudioClip[])(object)new AudioClip[0]; ((Object)Item).hideFlags = (HideFlags)32; Prefab = NetworkPrefabs.CreateNetworkPrefab("Poppers"); Prefab.GetComponent<NetworkObject>().AutoObjectParentSync = false; int num = LayerMask.NameToLayer("Props"); Prefab.layer = ((num >= 0) ? num : 6); Prefab.tag = "PhysicsProp"; grabCollider = Prefab.AddComponent<BoxCollider>(); grabCollider.size = new Vector3(0.09f, 0.18f, 0.09f); AudioSource obj = Prefab.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1f; obj.maxDistance = 20f; BuildModel(); PoppersItem poppersItem = Prefab.AddComponent<PoppersItem>(); ((GrabbableObject)poppersItem).itemProperties = Item; ((GrabbableObject)poppersItem).grabbable = true; ((GrabbableObject)poppersItem).grabbableToEnemies = true; ((GrabbableObject)poppersItem).useCooldown = 1.5f; ((GrabbableObject)poppersItem).insertedBattery = new Battery(true, 0f); ((GrabbableObject)poppersItem).mainObjectRenderer = body; scanNode = BuildScanNode().transform; Item.spawnPrefab = Prefab; LevelTypes val = ParseMoons(Plugin.Moons.Value); Items.RegisterScrap(Item, Plugin.SpawnRarity.Value, val); Plugin.Log.LogInfo((object)(string.Format("Registered scrap '{0}': value {1}-{2} ", "Poppers", Item.minValue, Item.maxValue) + $"(before the game's multiplier), rarity {Plugin.SpawnRarity.Value}, moons {val}.")); } internal static void Graft(StartOfRound round) { //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (grafted || (Object)(object)Prefab == (Object)null || (Object)(object)round == (Object)null) { return; } try { List<Item> items = (((Object)(object)round.allItemsList != (Object)null) ? round.allItemsList.itemsList : null); Item val = FindItem(items, "TZP-Inhalant"); Item val2 = GlassDonors.Select((string name) => FindItem(items, name)).FirstOrDefault((Func<Item, bool>)((Item found) => (Object)(object)found != (Object)null)); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"'TZP-Inhalant' not found; holding the bottle in a generic upright pose."); } if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)"No small glass item found to borrow sounds from; the bottle may be silent when dropped."); } ApplyMaterials(val, val2); AlignToHoldDonor(val); CopySoundsAndIcon(((Object)(object)val2 != (Object)null) ? val2 : val); CopyAudioSettings(((Object)(object)val != (Object)null) ? val : val2); AdoptVanillaScanNode(((Object)(object)val2 != (Object)null) ? val2 : val); FitToModel(); grafted = true; Plugin.Log.LogInfo((object)("Poppers bottle finished: sounds and icon from '" + (((Object)(object)val2 != (Object)null) ? val2.itemName : "none") + "', " + $"collider {grabCollider.size}, verticalOffset {Item.verticalOffset:0.000}, " + $"{Item.spawnPositionTypes.Count} spawn group(s).")); } catch (Exception arg) { Plugin.Log.LogError((object)$"Finishing the Poppers bottle failed; will retry when the next game starts: {arg}"); } } private static void BuildModel() { //IL_0005: 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_0056: Unknown result type (might be due to invalid IL or missing references) model = new GameObject("Model").transform; ((Component)model).gameObject.layer = Prefab.layer; model.SetParent(Prefab.transform, false); model.localScale = Vector3.one * Plugin.ModelScale.Value; body = AddPart("Body", BottleModel.Body()); label = AddPart("Label", BottleModel.Label()); cap = AddPart("Cap", BottleModel.Cap()); } private static MeshRenderer AddPart(string name, Mesh mesh) { //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_0016: 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) GameObject val = new GameObject(name) { layer = Prefab.layer }; val.transform.SetParent(model, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; return val.AddComponent<MeshRenderer>(); } private static GameObject BuildScanNode() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) GameObject val; if ((Object)(object)Items.scanNodePrefab != (Object)null) { val = Object.Instantiate<GameObject>(Items.scanNodePrefab, Prefab.transform); } else { val = new GameObject(); int num = LayerMask.NameToLayer("ScanNode"); val.layer = ((num >= 0) ? num : 22); val.transform.SetParent(Prefab.transform, false); val.AddComponent<BoxCollider>(); } ((Object)val).name = "ScanNode"; val.transform.localPosition = Vector3.zero; ScanNodeProperties val2 = val.GetComponent<ScanNodeProperties>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<ScanNodeProperties>(); } ConfigureScanNode(val2); val2.minRange = 1; val2.maxRange = 13; val2.requiresLineOfSight = true; return val; } private static void AdoptVanillaScanNode(Item donor) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) ScanNodeProperties val = (((Object)(object)donor != (Object)null) ? donor.spawnPrefab.GetComponentInChildren<ScanNodeProperties>(true) : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("No vanilla scan node to copy; keeping LethalLib's (" + Describe(((Component)scanNode).gameObject) + ").")); return; } Plugin.Log.LogInfo((object)("Scan node: replacing LethalLib's (" + Describe(((Component)scanNode).gameObject) + ") " + $"with {donor.itemName}'s ({Describe(((Component)val).gameObject)}, range {val.minRange}-{val.maxRange}, " + $"line of sight {val.requiresLineOfSight}; donor root Rigidbody: " + (((Object)(object)donor.spawnPrefab.GetComponent<Rigidbody>() != (Object)null) ? "yes" : "no") + ").")); GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, Prefab.transform); ((Object)obj).name = "ScanNode"; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = ((Component)val).transform.lossyScale; ConfigureScanNode(obj.GetComponent<ScanNodeProperties>()); Object.DestroyImmediate((Object)(object)((Component)scanNode).gameObject); scanNode = obj.transform; } private static void ConfigureScanNode(ScanNodeProperties properties) { properties.headerText = "Poppers"; properties.subText = "Value: "; properties.scrapValue = 0; properties.nodeType = 2; properties.creatureScanID = -1; } private static string Describe(GameObject node) { //IL_00ab: 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) Collider component = node.GetComponent<Collider>(); object obj; if (!((Object)(object)component == (Object)null)) { string text = $"{((object)component).GetType().Name} enabled={component.enabled} trigger={component.isTrigger}"; BoxCollider val = (BoxCollider)(object)((component is BoxCollider) ? component : null); obj = text + ((val != null) ? $" size={val.size}" : ""); } else { obj = "no collider"; } string arg = (string)obj; return $"layer {node.layer} '{LayerMask.LayerToName(node.layer)}', tag '{node.tag}', " + $"active={node.activeSelf}, {arg}, scale {node.transform.lossyScale}"; } private static Item FindItem(List<Item> items, string name) { if (items == null) { return null; } foreach (Item item in items) { if ((Object)(object)item != (Object)null && (Object)(object)item.spawnPrefab != (Object)null && string.Equals(item.itemName, name, StringComparison.OrdinalIgnoreCase)) { return item; } } return null; } private static void ApplyMaterials(params Item[] donors) { //IL_0099: 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_00f0: Unknown result type (might be due to invalid IL or missing references) Material val = PickTemplate(donors); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"No HDRP/Lit material found to build the bottle from; it will render untextured."); return; } Plugin.Log.LogInfo((object)("Bottle materials cloned from '" + ((Object)val).name + "' (shader " + ((Object)val.shader).name + ", keywords: " + string.Join(" ", val.shaderKeywords) + ").")); ((Renderer)body).sharedMaterial = MakeMaterial(val, "PoppersGlass", new Color(0.3f, 0.13f, 0.03f), (Texture)(object)Texture2D.whiteTexture, 0.9f); ((Renderer)cap).sharedMaterial = MakeMaterial(val, "PoppersCap", new Color(0.06f, 0.06f, 0.06f), (Texture)(object)Texture2D.whiteTexture, 0.45f); ((Renderer)label).sharedMaterial = MakeMaterial(val, "PoppersLabel", Color.white, (Texture)(object)BottleModel.LabelTexture(), 0.25f); } private static Material PickTemplate(Item[] donors) { //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown Material val = null; foreach (Item val2 in donors) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.spawnPrefab == (Object)null) { continue; } Renderer[] componentsInChildren = val2.spawnPrefab.GetComponentsInChildren<Renderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { Material[] sharedMaterials = componentsInChildren[j].sharedMaterials; foreach (Material val3 in sharedMaterials) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.shader == (Object)null) && !(((Object)val3.shader).name != "HDRP/Lit") && (!val3.HasProperty("_SurfaceType") || val3.GetFloat("_SurfaceType") == 0f)) { if (!val3.IsKeywordEnabled("_MASKMAP") && !val3.IsKeywordEnabled("_NORMALMAP")) { return val3; } if ((Object)(object)val == (Object)null) { val = val3; } } } } } if ((Object)(object)val != (Object)null) { return val; } Shader val4 = Shader.Find("HDRP/Lit"); if (!((Object)(object)val4 != (Object)null)) { return null; } return new Material(val4); } private static Material MakeMaterial(Material template, string name, Color color, Texture texture, float smoothness) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_001c: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(template) { name = name, hideFlags = (HideFlags)32 }; SetColor(val, "_BaseColor", color); SetTexture(val, "_BaseColorMap", texture); if (val.HasProperty("_BaseColorMap")) { val.SetTextureScale("_BaseColorMap", Vector2.one); val.SetTextureOffset("_BaseColorMap", Vector2.zero); } SetTexture(val, "_NormalMap", null); SetTexture(val, "_MaskMap", null); SetTexture(val, "_DetailMap", null); SetTexture(val, "_EmissiveColorMap", null); SetColor(val, "_EmissiveColor", Color.black); SetFloat(val, "_Smoothness", smoothness); SetFloat(val, "_SmoothnessRemapMin", smoothness); SetFloat(val, "_SmoothnessRemapMax", smoothness); SetFloat(val, "_Metallic", 0f); SetFloat(val, "_MetallicRemapMin", 0f); SetFloat(val, "_MetallicRemapMax", 0f); return val; } private static void SetColor(Material material, string property, Color value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(property)) { material.SetColor(property, value); } } private static void SetTexture(Material material, string property, Texture value) { if (material.HasProperty(property)) { material.SetTexture(property, value); } } private static void SetFloat(Material material, string property, float value) { if (material.HasProperty(property)) { material.SetFloat(property, value); } } private static void AlignToHoldDonor(Item donor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_006f: 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_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_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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00db: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00b7: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.up; Vector3 val2 = Vector3.zero; if ((Object)(object)donor != (Object)null && TryGetBounds(donor.spawnPrefab.transform, out var bounds)) { Vector3 size = ((Bounds)(ref bounds)).size; val = ((size.x >= size.y && size.x >= size.z) ? Vector3.right : ((size.y >= size.z) ? Vector3.up : Vector3.forward)); if (Vector3.Dot(Quaternion.Inverse(Quaternion.Euler(donor.restingRotation.x, 0f, donor.restingRotation.z)) * Vector3.up, val) < -0.5f) { val = -val; } val2 = ((Bounds)(ref bounds)).center; Item.rotationOffset = donor.rotationOffset; Item.positionOffset = donor.positionOffset; Item.restingRotation = donor.restingRotation; Item.floorYOffset = donor.floorYOffset; Item.grabAnim = donor.grabAnim; Item.grabAnimationTime = donor.grabAnimationTime; } if (Plugin.FlipModel.Value) { val = -val; } model.localRotation = Quaternion.FromToRotation(Vector3.up, val); model.localPosition = val2; Plugin.Log.LogInfo((object)($"Bottle aligned along {val} at {val2}, hold pose from " + "'" + (((Object)(object)donor != (Object)null) ? donor.itemName : "defaults") + "' " + $"(rotationOffset {Item.rotationOffset}, restingRotation {Item.restingRotation}).")); } private static void CopySoundsAndIcon(Item donor) { if (!((Object)(object)donor == (Object)null)) { Item.itemIcon = donor.itemIcon; Item.grabSFX = donor.grabSFX; Item.dropSFX = donor.dropSFX; Item.pocketSFX = donor.pocketSFX; Item.throwSFX = donor.throwSFX; if (donor.spawnPositionTypes != null && donor.spawnPositionTypes.Count > 0) { Item.spawnPositionTypes = new List<ItemGroup>(donor.spawnPositionTypes); } } } private static void CopyAudioSettings(Item donor) { //IL_0047: 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_00a0: Invalid comparison between Unknown and I4 AudioSource val = (((Object)(object)donor != (Object)null) ? donor.spawnPrefab.GetComponent<AudioSource>() : null); if (!((Object)(object)val == (Object)null)) { AudioSource component = Prefab.GetComponent<AudioSource>(); component.outputAudioMixerGroup = val.outputAudioMixerGroup; component.spatialBlend = val.spatialBlend; component.rolloffMode = val.rolloffMode; component.minDistance = val.minDistance; component.maxDistance = val.maxDistance; component.spread = val.spread; component.dopplerLevel = val.dopplerLevel; component.priority = val.priority; component.reverbZoneMix = val.reverbZoneMix; if ((int)val.rolloffMode == 2) { component.SetCustomCurve((AudioSourceCurveType)0, val.GetCustomCurve((AudioSourceCurveType)0)); } } } private static void FitToModel() { //IL_001b: 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_0036: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_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) //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_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_00a0: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00cf: 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) if (!TryGetBounds(Prefab.transform, out var bounds)) { return; } grabCollider.center = ((Bounds)(ref bounds)).center; grabCollider.size = Vector3.Max(((Bounds)(ref bounds)).size * 1.3f, Vector3.one * 0.06f); Quaternion val = Quaternion.Euler(Item.restingRotation.x, 0f, Item.restingRotation.z); Vector3 val2 = Quaternion.Inverse(val) * Vector3.up; scanNode.localPosition = ((Bounds)(ref bounds)).center + val2 * 0.08f; float num = float.MaxValue; foreach (Vector3 item in Corners(bounds)) { num = Mathf.Min(num, (val * item).y); } Item.verticalOffset = 0f - num - 0.04f; } private static bool TryGetBounds(Transform root, out Bounds bounds) { //IL_0001: 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_001b: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00d4: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; int num = LayerMask.NameToLayer("ScanNode"); Matrix4x4 val = Matrix4x4.TRS(root.position, root.rotation, Vector3.one); Matrix4x4 inverse = ((Matrix4x4)(ref val)).inverse; MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val2 in componentsInChildren) { MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>(); if ((Object)(object)val2.sharedMesh == (Object)null || (Object)(object)component == (Object)null || !((Renderer)component).enabled || ((Component)val2).gameObject.layer == num) { continue; } Matrix4x4 val3 = inverse * ((Component)val2).transform.localToWorldMatrix; foreach (Vector3 item in Corners(val2.sharedMesh.bounds)) { Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(item); if (flag) { ((Bounds)(ref bounds)).Encapsulate(val4); continue; } bounds = new Bounds(val4, Vector3.zero); flag = true; } } return flag; } private static IEnumerable<Vector3> Corners(Bounds bounds) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; for (int i = 0; i < 8; i++) { yield return new Vector3(((i & 1) == 0) ? min.x : max.x, ((i & 2) == 0) ? min.y : max.y, ((i & 4) == 0) ? min.z : max.z); } } private static LevelTypes ParseMoons(string value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(value) || value.Trim().Equals("All", StringComparison.OrdinalIgnoreCase)) { return (LevelTypes)(-1); } if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out LevelTypes result)) { return result; } Plugin.Log.LogWarning((object)("Could not read Moons value '" + value + "'; spawning on all moons.")); return (LevelTypes)(-1); } } internal static class ScreenFx { private const int RingCopies = 8; private static RawImage source; private static RawImage[] layers; private static bool layersShown; private static Volume volume; private static LensDistortion lens; internal static void Apply(float level, float t) { HUDManager instance = HUDManager.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.playerScreenTexture == (Object)null)) { EnsureLayers(instance.playerScreenTexture); UpdateLayers(level, t); UpdateVolume(instance, level, t); } } internal static void Teardown() { ShowLayers(show: false); if ((Object)(object)volume != (Object)null) { volume.weight = 0f; } } private static void EnsureLayers(RawImage screen) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)(object)screen && layers != null && Array.TrueForAll(layers, (RawImage layer) => (Object)(object)layer != (Object)null)) { ShowLayers(show: true); return; } DestroyLayers(); source = screen; Transform parent = ((Component)screen).transform.parent; int siblingIndex = ((Component)screen).transform.GetSiblingIndex(); layers = (RawImage[])(object)new RawImage[10]; for (int num = 0; num < layers.Length; num++) { GameObject val = new GameObject($"PoppersScreenLayer{num}", new Type[1] { typeof(RectTransform) }) { layer = ((Component)screen).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.SetSiblingIndex(siblingIndex + 1 + num); RawImage val2 = val.AddComponent<RawImage>(); ((Graphic)val2).raycastTarget = false; layers[num] = val2; } layersShown = true; } private static void UpdateLayers(float level, float t) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_016e: 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) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: 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_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)source).rectTransform; Rect rect = rectTransform.rect; Vector2 size = ((Rect)(ref rect)).size; float num = Mathf.Max(1f, size.x); float num2 = Mathf.Max(1f, size.y); float num3 = Plugin.Sway.Value * level; float num4 = (Mathf.Sin(t * 0.55f) * 2.5f + (Mathf.PerlinNoise(t * 0.3f, 7.1f) - 0.5f) * 1.5f) * num3; float num5 = Mathf.Abs(num4) * (MathF.PI / 180f); float num6 = Mathf.Max(num / num2, num2 / num); float num7 = Mathf.Max(1f, Mathf.Cos(num5) + num6 * Mathf.Sin(num5)); float num8 = 1f + 0.015f * num3 * (0.5f + 0.5f * Mathf.Sin(t * 1.3f)); float num9 = Plugin.BlurStrength.Value * level * 0.012f * num; float num10 = 1f + 2f * num9 / num; float num11 = num7 * num8 * num10; Quaternion val = Quaternion.Euler(0f, 0f, num4); float num12 = Mathf.Clamp(Plugin.DoubleVision.Value * level, 0f, 3f); Vector2 val2 = new Vector2(Mathf.Sin(t * 0.8f), 0.3f * Mathf.Cos(t * 0.6f)) * (0.03f * num * num12); rect = rectTransform.rect; Vector3 position = ((Transform)rectTransform).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)); for (int i = 0; i < layers.Length; i++) { RawImage obj = layers[i]; Vector2 val3 = Vector2.zero; float num13 = 1f; if (i >= 1 && i <= 8) { float num14 = t * 0.6f + (float)(i - 1) * (MathF.PI / 4f); float num15 = ((i % 2 == 1) ? num9 : (num9 * 0.55f)); val3 = new Vector2(Mathf.Cos(num14), Mathf.Sin(num14)) * num15; num13 = 1f / (float)(i + 1); } else if (i == 9) { val3 = val2; num13 = 0.35f * Mathf.Clamp01(num12); } obj.texture = source.texture; obj.uvRect = source.uvRect; ((Graphic)obj).material = ((Graphic)source).material; Color color = ((Graphic)source).color; color.a *= num13; ((Graphic)obj).color = color; ((Behaviour)obj).enabled = num13 > 0.003f; RectTransform rectTransform2 = ((Graphic)obj).rectTransform; rectTransform2.anchorMin = rectTransform.anchorMin; rectTransform2.anchorMax = rectTransform.anchorMax; rectTransform2.sizeDelta = rectTransform.sizeDelta; rectTransform2.pivot = new Vector2(0.5f, 0.5f); ((Transform)rectTransform2).position = position; ((Transform)rectTransform2).localPosition = ((Transform)rectTransform2).localPosition + Vector2.op_Implicit(val3); ((Transform)rectTransform2).localRotation = ((Transform)rectTransform).localRotation * val; ((Transform)rectTransform2).localScale = ((Transform)rectTransform).localScale * num11; } } private static void ShowLayers(bool show) { if (layers == null || layersShown == show) { return; } RawImage[] array = layers; foreach (RawImage val in array) { if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(show); } } layersShown = show; } private static void DestroyLayers() { if (layers == null) { return; } RawImage[] array = layers; foreach (RawImage val in array) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } layers = null; } private static void UpdateVolume(HUDManager hud, float level, float t) { if (!Plugin.PostProcessing.Value) { if ((Object)(object)volume != (Object)null) { volume.weight = 0f; } return; } if ((Object)(object)volume == (Object)null) { CreateVolume(hud); } if (!((Object)(object)volume == (Object)null)) { volume.weight = level; ((VolumeParameter<float>)(object)lens.intensity).value = (Mathf.PerlinNoise(t * 0.7f, 3.3f) - 0.5f) * 0.5f; } } private static void CreateVolume(HUDManager hud) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Invalid comparison between Unknown and I4 //IL_01f5: Unknown result type (might be due to invalid IL or missing references) Volume playerGraphicsVolume = hud.playerGraphicsVolume; GameObject val = new GameObject("PoppersDizzyVolume"); val.SetActive(false); val.layer = (((Object)(object)playerGraphicsVolume != (Object)null) ? ((Component)playerGraphicsVolume).gameObject.layer : 0); val.transform.SetParent(((Object)(object)playerGraphicsVolume != (Object)null) ? ((Component)playerGraphicsVolume).transform.parent : ((Component)hud).transform, false); VolumeProfile val2 = ScriptableObject.CreateInstance<VolumeProfile>(); ((Object)val2).name = "PoppersDizzyProfile"; DepthOfField val3 = val2.Add<DepthOfField>(false); DepthOfField val4 = null; if (!((Object)(object)playerGraphicsVolume != (Object)null) || !((Object)(object)playerGraphicsVolume.sharedProfile != (Object)null) || !playerGraphicsVolume.sharedProfile.TryGet<DepthOfField>(ref val4) || !((VolumeParameter)val4.focusMode).overrideState || (int)((VolumeParameter<DepthOfFieldMode>)(object)val4.focusMode).value != 2) { ((VolumeParameter<DepthOfFieldMode>)(object)val3.focusMode).Override((DepthOfFieldMode)2); ((VolumeParameter<float>)(object)val3.nearFocusStart).Override(0f); ((VolumeParameter<float>)(object)val3.nearFocusEnd).Override(0.2f); } ((VolumeParameter<float>)(object)val3.farFocusStart).Override(0.5f); ((VolumeParameter<float>)(object)val3.farFocusEnd).Override(3f); ((VolumeParameter<float>)(object)val2.Add<ChromaticAberration>(false).intensity).Override(0.6f); lens = val2.Add<LensDistortion>(false); ((VolumeParameter<float>)(object)lens.intensity).Override(0f); volume = val.AddComponent<Volume>(); volume.isGlobal = true; volume.priority = (((Object)(object)playerGraphicsVolume != (Object)null) ? playerGraphicsVolume.priority : 0f) + 1f; volume.weight = 0f; volume.sharedProfile = val2; val.SetActive(true); Plugin.Log.LogInfo((object)($"Dizzy volume on layer {val.layer} at priority {volume.priority}. Vanilla depth of field: " + (((Object)(object)val4 != (Object)null) ? ($"mode {((VolumeParameter<DepthOfFieldMode>)(object)val4.focusMode).value} (overridden {((VolumeParameter)val4.focusMode).overrideState}), " + $"near {((VolumeParameter<float>)(object)val4.nearFocusStart).value}-{((VolumeParameter<float>)(object)val4.nearFocusEnd).value}, far {((VolumeParameter<float>)(object)val4.farFocusStart).value}-{((VolumeParameter<float>)(object)val4.farFocusEnd).value}") : "none found") + ". Screen texture: " + (((Object)(object)source != (Object)null && (Object)(object)source.texture != (Object)null) ? $"{((Object)source.texture).name} {source.texture.width}x{source.texture.height}" : "none") + ".")); } } internal static class SniffSound { internal static AudioClip Clip; internal static void Build() { //IL_0019: 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) Clip = LoadOverride() ?? Synthesize(); AudioClip clip = Clip; ((Object)clip).hideFlags = (HideFlags)(((Object)clip).hideFlags | 0x20); } private static AudioClip Synthesize() { int num = 24255; float[] array = new float[num]; Random random = new Random(24301); float num2 = 2.2675737E-05f; float num3 = 0.00017683883f / (0.00017683883f + num2); float num4 = 0f; float num5 = 0f; float num6 = 0f; float num7 = 0f; for (int i = 0; i < num; i++) { float num8 = (float)i * num2; float num9 = 0.75f * Burst(num8, 0f, 0.012f, 0.13f) + Burst(num8, 0.17f, 0.045f, 0.34f); float num10 = ((num8 < 0.17f) ? 3800f : Mathf.Lerp(2600f, 6500f, Mathf.Clamp01((num8 - 0.17f) / 0.3f))); float num11 = (float)(random.NextDouble() * 2.0 - 1.0); num4 += (1f - Mathf.Exp(MathF.PI * -2f * num10 * num2)) * (num11 - num4); num6 = num3 * (num6 + num4 - num5); num5 = num4; float num12 = 0.85f + 0.15f * Mathf.Sin(MathF.PI * 62f * num8); num7 = Mathf.Max(num7, Mathf.Abs(array[i] = num6 * num9 * num12)); } if (num7 > 0f) { float num13 = 0.8f / num7; for (int j = 0; j < num; j++) { array[j] *= num13; } } AudioClip obj = AudioClip.Create("PoppersSniff", num, 1, 44100, false); obj.SetData(array, 0); return obj; } private static float Burst(float t, float start, float attack, float length) { float num = t - start; if (num < 0f || num > length) { return 0f; } if (num < attack) { return num / attack; } float num2 = 1f - (num - attack) / (length - attack); return num2 * num2; } private static AudioClip LoadOverride() { string text = null; try { text = Directory.GetFiles(Plugin.PluginDirectory, "sniff.wav", SearchOption.AllDirectories).FirstOrDefault(); if (text == null) { return null; } AudioClip val = DecodeWav(File.ReadAllBytes(text), "PoppersSniff"); if ((Object)(object)val != (Object)null) { Plugin.Log.LogInfo((object)$"Using custom sniff sound {text} ({val.length:0.00}s)."); } return val; } catch (Exception arg) { Plugin.Log.LogError((object)string.Format("Could not load {0}, using the built-in sniff: {1}", text ?? "sniff.wav", arg)); return null; } } private static AudioClip DecodeWav(byte[] wav, string name) { if (wav.Length < 12 || Tag(wav, 0) != "RIFF" || Tag(wav, 8) != "WAVE") { Plugin.Log.LogError((object)"sniff.wav is not a RIFF/WAVE file."); return null; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = -1; int num6 = 0; int num7 = 12; while (num7 + 8 <= wav.Length) { string text = Tag(wav, num7); int num8 = BitConverter.ToInt32(wav, num7 + 4); int num9 = num7 + 8; if (num8 < 0 || num9 + num8 > wav.Length) { num8 = wav.Length - num9; } if (text == "fmt ") { num = BitConverter.ToInt16(wav, num9); num2 = BitConverter.ToInt16(wav, num9 + 2); num3 = BitConverter.ToInt32(wav, num9 + 4); num4 = BitConverter.ToInt16(wav, num9 + 14); } else if (text == "data") { num5 = num9; num6 = num8; } num7 = num9 + num8 + num8 % 2; } if (num5 < 0 || num2 <= 0 || num3 <= 0 || num4 <= 0) { Plugin.Log.LogError((object)"sniff.wav is missing a fmt or data chunk."); return null; } int num10 = num4 / 8; int num11 = num6 / num10; float[] array = new float[num11]; for (int i = 0; i < num11; i++) { int num12 = num5 + i * num10; switch (num4) { case 8: array[i] = (float)(wav[num12] - 128) / 128f; break; case 16: array[i] = (float)BitConverter.ToInt16(wav, num12) / 32768f; break; case 24: { int num13 = wav[num12] | (wav[num12 + 1] << 8) | (wav[num12 + 2] << 16); if ((num13 & 0x800000) != 0) { num13 |= -16777216; } array[i] = (float)num13 / 8388608f; break; } case 32: array[i] = ((num == 3) ? BitConverter.ToSingle(wav, num12) : ((float)BitConverter.ToInt32(wav, num12) / 2.1474836E+09f)); break; default: Plugin.Log.LogError((object)$"Unsupported WAV bit depth: {num4}"); return null; } } AudioClip obj = AudioClip.Create(name, num11 / num2, num2, num3, false); obj.SetData(array, 0); return obj; } private static string Tag(byte[] bytes, int offset) { return Encoding.ASCII.GetString(bytes, offset, 4); } } internal static class TestKeys { private static readonly Random Rng = new Random(); private static int lastTickedFrame = -1; internal static void Tick() { if (!Plugin.EnableTestHotkey.Value || lastTickedFrame == Time.frameCount) { return; } lastTickedFrame = Time.frameCount; Keyboard current = Keyboard.current; if (current == null) { return; } try { if (((ButtonControl)current.f9Key).wasPressedThisFrame) { Plugin.Log.LogInfo((object)"F9 pressed - taking a test sniff."); Dizziness.AddDose(); } if (((ButtonControl)current.f10Key).wasPressedThisFrame) { SpawnBottle(); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Test key failed: {arg}"); } } private static void SpawnBottle() { //IL_00c2: 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_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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00fb: 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) PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && !((Object)(object)PoppersRegistry.Prefab == (Object)null) && !((Object)(object)StartOfRound.Instance == (Object)null)) { if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer) { Plugin.Log.LogWarning((object)"F10 only works for the host."); return; } bool isInHangarShipRoom = val.isInHangarShipRoom; Transform val2 = (isInHangarShipRoom ? StartOfRound.Instance.elevatorTransform : (((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.spawnedScrapContainer != (Object)null) ? RoundManager.Instance.spawnedScrapContainer : StartOfRound.Instance.propsContainer)); Vector3 val3 = ((Component)val).transform.position + ((Component)val).transform.forward * 1.6f + Vector3.up * 0.6f; GameObject obj = Object.Instantiate<GameObject>(PoppersRegistry.Prefab, val3, Quaternion.identity, val2); GrabbableObject component = obj.GetComponent<GrabbableObject>(); component.fallTime = 0f; component.isInShipRoom = isInHangarShipRoom; component.isInElevator = isInHangarShipRoom; component.isInFactory = val.isInsideFactory; obj.GetComponent<NetworkObject>().Spawn(false); float num = (((Object)(object)RoundManager.Instance != (Object)null) ? RoundManager.Instance.scrapValueMultiplier : 0.4f); int num2 = (int)((float)Rng.Next(PoppersRegistry.Item.minValue, PoppersRegistry.Item.maxValue + 1) * num); component.SetScrapValue(num2); Plugin.Log.LogInfo((object)$"F10 pressed - spawned a Poppers bottle worth {num2} in front of you."); } } } }