Decompiled source of SoundPropagation v1.4.0
plugins/SoundPropagation.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComputerysModdingUtilities; using FishNet.Object; using HarmonyLib; using HeathenEngineering.SteamworksIntegration; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Jobs; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: StraftatMod(false)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Goomageddon")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0+0ce41090d3b79f30a69ced6050b05536b2b990c9")] [assembly: AssemblyProduct("SoundPropagation")] [assembly: AssemblyTitle("SoundPropagation")] [assembly: AssemblyVersion("1.4.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 SoundPropagation { internal static class AudioTabDump { private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; public static string Write() { Transform val = AudioTab.Find(); if (!Object.op_Implicit((Object)(object)val)) { return "error: the Audio tab is not loaded yet"; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("# ancestors"); Transform val2 = val; while (Object.op_Implicit((Object)(object)val2)) { stringBuilder.AppendLine(Line(val2, 0)); val2 = val2.parent; } stringBuilder.AppendLine("# the tab's parent's children (other tabs?)"); if (Object.op_Implicit((Object)(object)val.parent)) { for (int i = 0; i < val.parent.childCount; i++) { stringBuilder.AppendLine(Line(val.parent.GetChild(i), 1)); } } stringBuilder.AppendLine("# the tab"); Walk(val, 0, stringBuilder); string text = Path.Combine(Paths.BepInExRootPath, "soundpropagation-audiotab.txt"); File.WriteAllText(text, stringBuilder.ToString()); return "ok " + text; } public static string Find(string what) { //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) StringBuilder stringBuilder = new StringBuilder(); int num = 0; TMP_Text[] array = Resources.FindObjectsOfTypeAll<TMP_Text>(); foreach (TMP_Text val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && val.text != null && val.text.IndexOf(what, StringComparison.OrdinalIgnoreCase) >= 0) { string text = ((Object)val.transform).name; Transform parent = val.transform.parent; while (Object.op_Implicit((Object)(object)parent)) { text = ((Object)parent).name + "/" + text; parent = parent.parent; } stringBuilder.Append(" || " + (((Component)val).gameObject.activeInHierarchy ? "+" : "-") + " " + text); num++; } } return $"ok {num}" + stringBuilder; } private static void Walk(Transform t, int depth, StringBuilder sb) { sb.AppendLine(Line(t, depth)); if (depth < 4) { for (int i = 0; i < t.childCount; i++) { Walk(t.GetChild(i), depth + 1, sb); } } } private static string Line(Transform t, int depth) { //IL_0058: 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_0078: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_010e: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(new string(' ', depth * 2)); stringBuilder.Append(((Component)t).gameObject.activeInHierarchy ? "+ " : (((Component)t).gameObject.activeSelf ? "~ " : "- ")); stringBuilder.Append(((Object)t).name); stringBuilder.Append($" local ({t.localPosition.x:0},{t.localPosition.y:0}) scale {t.localScale.x:0.##}"); RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); if (val != null) { val.GetWorldCorners(Corners); object[] array = new object[12]; Rect rect = val.rect; array[0] = ((Rect)(ref rect)).width; rect = val.rect; array[1] = ((Rect)(ref rect)).height; array[2] = val.anchorMin.x; array[3] = val.anchorMin.y; array[4] = val.anchorMax.x; array[5] = val.anchorMax.y; array[6] = val.pivot.x; array[7] = val.pivot.y; array[8] = Corners[0].x; array[9] = Corners[0].y; array[10] = Corners[2].x; array[11] = Corners[2].y; stringBuilder.Append(string.Format(" size {0:0}x{1:0} anchors ({2:0.##},{3:0.##})-({4:0.##},{5:0.##}) pivot ({6:0.##},{7:0.##}) screen ({8:0},{9:0})-({10:0},{11:0})", array)); } stringBuilder.Append(" {"); Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val2 in components) { if (Object.op_Implicit((Object)(object)val2) && !(val2 is Transform) && !(val2 is CanvasRenderer)) { stringBuilder.Append(((object)val2).GetType().Name + " "); } } stringBuilder.Append("}"); TMP_Text component = ((Component)t).GetComponent<TMP_Text>(); if (Object.op_Implicit((Object)(object)component)) { stringBuilder.Append(string.Format(" \"{0}\" size {1:0.#}{2} font {3}", component.text.Replace("\n", "\\n"), component.fontSize, component.enableAutoSizing ? " auto" : "", Object.op_Implicit((Object)(object)component.font) ? ((Object)component.font).name : "-")); } Image component2 = ((Component)t).GetComponent<Image>(); if (Object.op_Implicit((Object)(object)component2)) { stringBuilder.Append(string.Format(" img {0} color {1}", Object.op_Implicit((Object)(object)component2.sprite) ? ((Object)component2.sprite).name : "-", ((Graphic)component2).color)); } return stringBuilder.ToString(); } } internal static class AudioTab { public static Toggle VoiceToggle() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) DisplayLoadValues[] array = Resources.FindObjectsOfTypeAll<DisplayLoadValues>(); foreach (DisplayLoadValues val in array) { if (Object.op_Implicit((Object)(object)val)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && Object.op_Implicit((Object)(object)((Component)val).GetComponent<Toggle>()) && Traverse.Create((object)val).Field("enableVoiceChat").GetValue<bool>()) { return ((Component)val).GetComponent<Toggle>(); } } } return null; } public static Transform Find() { Toggle val = VoiceToggle(); if (!Object.op_Implicit((Object)(object)val)) { return null; } return ((Component)val).transform.parent; } } internal sealed class AudioTabSettings : MonoBehaviour { private sealed class Row { public string Name; public GameObject Go; public Func<bool> Shown; public Action Sync; public Func<string> Value; public Slider Slider; } private sealed class RightClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public Action OnRight; public void OnPointerClick(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)e.button == 1) { OnRight?.Invoke(); } } } private const float BoxLeft = -110f; private const float BoxRight = 870f; private const float BoxTop = 70f; private const float BoxBottom = -468f; private const float HelpLeft = 400f; private const float ToggleHeight = 46f; private const float SliderHeight = 62f; private const float HeadingHeight = 40f; private const float HelpSize = 17f; private ConfigFile _config; private GameObject _root; private ScrollRect _scroll; private RectTransform _content; private float _nextFind; private float _saveAt = -1f; private bool _wasShown; private bool _advanced; private readonly List<Row> _rows = new List<Row>(); private GameObject _toggleTemplate; private GameObject _sliderTemplate; private TMP_FontAsset _font; private Color _textColor; public static AudioTabSettings Instance { get; private set; } public static void Init(GameObject host, ConfigFile config) { Instance = host.AddComponent<AudioTabSettings>(); Instance._config = config; } private void Update() { if (!Object.op_Implicit((Object)(object)_root) && Time.unscaledTime >= _nextFind) { _nextFind = Time.unscaledTime + 1f; try { Build(); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Audio tab settings: could not add them: {arg}"); if (Object.op_Implicit((Object)(object)_root)) { Object.Destroy((Object)(object)_root); } _nextFind = float.MaxValue; } } bool flag = Object.op_Implicit((Object)(object)_root) && _root.activeInHierarchy; if (flag && !_wasShown) { SyncAll(); Canvas.ForceUpdateCanvases(); _scroll.verticalNormalizedPosition = 1f; } _wasShown = flag; if (_saveAt >= 0f && Time.unscaledTime >= _saveAt) { SaveNow(); } } private void OnApplicationQuit() { SaveNow(); } private void SaveNow() { if (_saveAt < 0f) { return; } _saveAt = -1f; try { _config.Save(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not save the settings: " + ex.Message)); } } private void Build() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007d: Expected O, but got Unknown Toggle val = AudioTab.VoiceToggle(); if (!Object.op_Implicit((Object)(object)val)) { return; } Transform parent = ((Component)val).transform.parent; Transform val2 = parent.Find("Disable Voice Chat Indicator UI"); Transform val3 = parent.Find("VoiceChatVolumeHolder"); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3)) { throw new InvalidOperationException("the indicator checkbox or VoiceChatVolumeHolder not found"); } TMP_Text componentInChildren = ((Component)val2).GetComponentInChildren<TMP_Text>(true); _font = componentInChildren.font; _textColor = ((Graphic)componentInChildren).color; GameObject val4 = new GameObject("SoundPropagationTemplates"); val4.SetActive(false); val4.transform.SetParent(((Component)this).transform, false); _toggleTemplate = Strip(Object.Instantiate<GameObject>(((Component)val2).gameObject, val4.transform)); _sliderTemplate = Strip(Object.Instantiate<GameObject>(((Component)val3).gameObject, val4.transform)); try { BuildBox(parent); } finally { Object.Destroy((Object)(object)val4); _toggleTemplate = (_sliderTemplate = null); } } private void BuildBox(Transform tab) { //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_000b: 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_002f: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //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_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_00a2: 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_00cf: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_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_0156: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) Vector2 anchoredPosition = ((RectTransform)tab).anchoredPosition; _root = new GameObject("SoundPropagationSettings", new Type[1] { typeof(RectTransform) }); RectTransform val = (RectTransform)_root.transform; ((Transform)val).SetParent(tab, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); val.anchorMax = val2; val.anchorMin = val2; val.pivot = new Vector2(0f, 1f); val.sizeDelta = new Vector2(980f, 538f); val.anchoredPosition = new Vector2(-110f, 70f) - anchoredPosition; TextMeshProUGUI obj = Text(val, "Title", "Sound Propagation", 26f, (TextAlignmentOptions)4097); ((TMP_Text)obj).fontStyle = (FontStyles)(((TMP_Text)obj).fontStyle | 4); Stretch(((TMP_Text)obj).rectTransform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(8f, -40f), new Vector2(-8f, 0f)); TextMeshProUGUI obj2 = Text(val, "Hint", "How sound travels in maps, and voice chat. Only you hear these changes.", 17f, (TextAlignmentOptions)4100); ((Graphic)obj2).color = Dim(_textColor); Stretch(((TMP_Text)obj2).rectTransform, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(260f, -40f), new Vector2(-20f, 0f)); BuildScroll(val); AddRows(); Refresh(); SyncAll(); Plugin.Log.LogInfo((object)$"Audio tab settings: {_rows.Count} rows added"); } private void BuildScroll(RectTransform root) { //IL_0018: 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_0040: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00d9: 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_0111: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) Image val = new GameObject("Back", new Type[1] { typeof(RectTransform) }).AddComponent<Image>(); ((Transform)((Graphic)val).rectTransform).SetParent((Transform)(object)root, false); Stretch(((Graphic)val).rectTransform, Vector2.zero, Vector2.one, Vector2.zero, new Vector2(0f, -44f)); ((Graphic)val).color = new Color(0f, 0f, 0f, 0.25f); RectTransform component = new GameObject("Viewport", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }).GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)((Graphic)val).rectTransform, false); Stretch(component, Vector2.zero, Vector2.one, new Vector2(0f, 4f), new Vector2(-18f, -4f)); ((Graphic)((Component)component).gameObject.AddComponent<Image>()).color = Color.clear; _content = new GameObject("Content", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)_content).SetParent((Transform)(object)component, false); _content.anchorMin = new Vector2(0f, 1f); _content.anchorMax = new Vector2(1f, 1f); _content.pivot = new Vector2(0.5f, 1f); _content.sizeDelta = Vector2.zero; VerticalLayoutGroup obj = ((Component)_content).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((LayoutGroup)obj).padding = new RectOffset(0, 0, 4, 12); ((Component)_content).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; _scroll = ((Component)val).gameObject.AddComponent<ScrollRect>(); _scroll.viewport = component; _scroll.content = _content; _scroll.horizontal = false; _scroll.movementType = (MovementType)2; _scroll.scrollSensitivity = 30f; Image val2 = ((IEnumerable<Image>)_sliderTemplate.GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)((Image i) => ((Object)i).name == "Background")); Image val3 = ((IEnumerable<Image>)_sliderTemplate.GetComponentsInChildren<Image>(true)).FirstOrDefault((Func<Image, bool>)((Image i) => ((Object)i).name == "Fill")); Image val4 = new GameObject("Scrollbar", new Type[1] { typeof(RectTransform) }).AddComponent<Image>(); ((Transform)((Graphic)val4).rectTransform).SetParent((Transform)(object)((Graphic)val).rectTransform, false); Stretch(((Graphic)val4).rectTransform, new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(-12f, 6f), new Vector2(-4f, -6f)); ((Graphic)val4).color = (Color)(Object.op_Implicit((Object)(object)val2) ? ((Graphic)val2).color : new Color(0.44f, 0.54f, 0.44f)); if (Object.op_Implicit((Object)(object)val2)) { val4.sprite = val2.sprite; } val4.type = (Type)1; RectTransform component2 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component2).SetParent((Transform)(object)((Graphic)val4).rectTransform, false); Stretch(component2, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero); Image val5 = new GameObject("Handle", new Type[1] { typeof(RectTransform) }).AddComponent<Image>(); ((Transform)((Graphic)val5).rectTransform).SetParent((Transform)(object)component2, false); Stretch(((Graphic)val5).rectTransform, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero); ((Graphic)val5).color = (Color)(Object.op_Implicit((Object)(object)val3) ? ((Graphic)val3).color : new Color(0.82f, 0.99f, 0.83f)); if (Object.op_Implicit((Object)(object)val3)) { val5.sprite = val3.sprite; } val5.type = (Type)1; Scrollbar val6 = ((Component)val4).gameObject.AddComponent<Scrollbar>(); val6.handleRect = ((Graphic)val5).rectTransform; ((Selectable)val6).targetGraphic = (Graphic)(object)val5; val6.direction = (Direction)2; _scroll.verticalScrollbar = val6; _scroll.verticalScrollbarVisibility = (ScrollbarVisibility)1; } private static GameObject Strip(GameObject go) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { string text = ((object)val).GetType().Namespace ?? ""; if (!text.StartsWith("UnityEngine") && !text.StartsWith("TMPro")) { Object.DestroyImmediate((Object)(object)val); } } Toggle[] componentsInChildren2 = go.GetComponentsInChildren<Toggle>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].onValueChanged = new ToggleEvent(); } Slider[] componentsInChildren3 = go.GetComponentsInChildren<Slider>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].onValueChanged = new SliderEvent(); } return go; } private void AddRows() { SoundSettings s = Plugin.Settings; bool portalGunInstalled = SoundLinks.PortalGunInstalled; AddToggle(s.Enabled, "Sound Propagation", "Sounds come round corners and through doorways, as in real life. Off: the game's own sound.", null); AddToggle(s.Echo, "Echo in rooms", "Voices echo in rooms and tunnels. Big rooms echo longer.", On); AddToggle(s.Far, "Far sounds", "Far sounds lose their treble and get a soft echo, so you can hear that they are far.", On); AddToggle(s.PlayerVolumes, "Player Volumes", "A volume slider beside each player in the player list and on the Tab screen. Right-click a slider to set it back to 100%.", null); AddToggle(s.VoiceFixes, "Voice chat fixes", "Fixes two game bugs: push-to-talk stopped after a death, and the mic stayed on after you turned voice chat off.", null); AddToggle(s.VoiceKeepSpeechOnDeath, "Finish words on death", "When a player dies while talking, you still hear the words already on their way.", null); AddSlider(s.VoiceRebufferMs, "Smooth choppy voices", "A short wait after each pause in speech, so late network data does not cut words. 0 = off.", null, (float v) => $"{v:0} ms", 5f); AddToggle(s.MicTest, "Mic test", "A microphone meter and a Test Mic box on this tab, below voice chat.", null); AddHeading("Sound in maps", On); AddToggle(s.ThroughWalls, "Through walls", "You hear sounds through walls: quiet, with only the bass.", On); AddToggle(s.Doors, "Shut doors", "A shut door muffles sound. Sound goes round by an open way when it can.", On); AddToggle(s.Direction, "Direction from doorways", "You hear a sound from the doorway or corner it comes through, not through the wall.", On); AddToggle(s.Portals, portalGunInstalled ? "Portals and teleporters" : "Through teleporters", portalGunInstalled ? "Sound goes through Portals, and through the map's teleporters one way, as players do." : "Sound goes through the map's teleporters, one way, as players do.", On); AddToggle(s.EchoLoud, "Gunshot echo", "Gunshots and blasts echo in rooms and halls too.", () => On() && s.Echo.Value); AddToggle(s.EchoOwn, "Echo on your own shots", "Your own gunshots echo in rooms too. The shot itself does not change.", () => On() && s.Echo.Value); AddToggle(s.Masking, "Blast deafness", "A gunshot or blast right next to you makes other sounds quieter and duller for a moment.", On); AddToggle(s.TravelTime, "Sound delay", "Far gunshots and blasts arrive a little late, because sound is slower than light.", On); AddToggle(s.ThinVoices, "Thin far voices", "Far voices sound thin, a little like a radio. They can be harder to understand.", () => On() && s.Far.Value); AddToggle(s.Diffraction, "Corners bend sound", "Round a corner, a sound loses more treble than bass, by how far it must go round.", On); AddToggle(s.SeveralRoutes, "More ways in", "When a sound can come in by two doorways, you hear both. Two open doorways are louder than one.", On); AddToggle(s.QuietFadeOut, "Quiet sounds fade out", "Quiet sounds, like steps, fade to nothing at the end of their range.", On); AddSlider(s.VoiceFullVolumeDistance, "Voice full volume distance", "Voices are at full volume up to this distance. Farther away, they get quieter.", On, (float v) => $"{v:0.#} m", 0.5f); AddSlider(s.EchoStrength, "Echo strength", "How loud the echo in rooms is. 0 = no echo.", () => On() && s.Echo.Value, Percent, 0.05f); AddSlider(s.DirectionStrength, "Direction strength", "0%: you hear a sound from where it really is. 100%: from the doorway or corner.", () => On() && s.Direction.Value, Percent, 0.05f); AddSlider(s.FloorVolume, "Across the map", "Voices and loud sounds never get quieter than this, so you hear them anywhere on the map. 0 = off.", On, Percent, 0.01f); AddSlider(s.VoiceDeathFadeSeconds, "Dead voice fade-in", "A dead player's voice is heard everywhere at full volume. It rises to full over this time. 0 = at once.", null, (float v) => $"{v:0.0} s", 0.1f); AddAdvancedSwitch(On); AddHeading("Voices", Adv); AddSlider(s.VoiceFalloff, "Voice fade speed", "How fast voices get quieter past the full volume distance. Bigger = faster.", Adv, Plain2, 0.05f); AddHeading("Corners", Adv); AddSlider(s.DiffractionVolume, "Corner volume loss", "How much quieter a sound gets round a corner.", () => Adv() && s.Diffraction.Value, Plain2, 0.01f); AddSlider(s.DiffractionTreble, "Corner treble loss", "How much treble a sound loses round a corner. Bigger = duller.", () => Adv() && s.Diffraction.Value, Plain2, 0.01f); AddSlider(s.CornerStrength, "Corner cost", "With Corners bend sound off: how much each turn costs. 0 = nothing.", () => Adv() && !s.Diffraction.Value, Plain2, 0.05f); AddHeading("More ways in", () => Adv() && s.SeveralRoutes.Value); AddSlider(s.MaxRoutes, "Ways in per sound", "The most ways in that you hear one sound by.", () => Adv() && s.SeveralRoutes.Value, (float v) => $"{v:0}"); AddSlider(s.MaxLengthRatio, "Longest other way", "Another way in counts only if it is at most this many times longer than the shortest.", () => Adv() && s.SeveralRoutes.Value, (float v) => $"{v:0.0}x", 0.1f); AddSlider(s.OpeningSeparation, "Ways in apart", "How far apart two openings must be to count as two ways in.", () => Adv() && s.SeveralRoutes.Value, (float v) => $"{v:0.#} m", 0.5f); AddSlider(s.DirectionCrossfadeDb, "Direction blend", "When two ways in are this close in loudness, the direction slides between them. 0 = no blend.", () => Adv() && s.SeveralRoutes.Value, Db, 0.5f); AddHeading("Walls and doors", () => Adv() && (s.ThroughWalls.Value || s.Doors.Value)); AddSlider(s.WallDb, "Loss per wall", "How much quieter a sound gets for each wall it goes through.", () => Adv() && s.ThroughWalls.Value, Db, 1f); AddSlider(s.WallDbPerMetre, "Loss per metre of wall", "More loss for each metre of wall thickness.", () => Adv() && s.ThroughWalls.Value, (float v) => $"{v:0} dB/m", 1f); AddSlider(s.DoorDb, "Loss per shut door", "How much quieter a sound gets for each shut door it goes through.", () => Adv() && s.Doors.Value, Db, 1f); AddSlider(s.DoorCutoffHz, "Shut door muffle", "How muffled a sound through a shut door is. Lower = more muffled.", () => Adv() && s.Doors.Value, Hz, 0f, log: true); AddSlider(s.DoorPenaltyMetres, "Way round a shut door", "Sound takes an open way round if it is at most this much longer than the way through the shut door.", () => Adv() && s.Doors.Value, Metres, 1f); AddHeading(portalGunInstalled ? "Portals and teleporters" : "Teleporters", () => Adv() && s.Portals.Value); AddSlider(s.PortalDb, portalGunInstalled ? "Loss per Portal" : "Loss per teleporter", "How much quieter a sound gets each time it goes through" + (portalGunInstalled ? " a Portal or teleporter." : " a teleporter."), () => Adv() && s.Portals.Value, Db, 0.5f); AddSlider(s.PortalCutoffHz, portalGunInstalled ? "Portal muffle" : "Teleporter muffle", "How dull a sound is after it goes through" + (portalGunInstalled ? " a Portal or teleporter." : " a teleporter.") + " Lower = duller.", () => Adv() && s.Portals.Value, Hz, 0f, log: true); AddHeading("Far sounds", () => Adv() && s.Far.Value); AddSlider(s.AirStartDistance, "Air starts at", "The distance where the air starts to take treble away.", () => Adv() && s.Far.Value, Metres, 1f); AddSlider(s.AirMetres, "Air strength", "Every this many metres, the air takes more treble away. Smaller = stronger.", () => Adv() && s.Far.Value, Metres, 1f); AddSlider(s.AirMinHz, "Air limit", "The air never makes a sound duller than this, so far voices stay clear.", () => Adv() && s.Far.Value, Hz, 0f, log: true); AddSlider(s.TailStartDistance, "Far echo starts at", "The distance where the far echo starts.", () => Adv() && s.Far.Value, Metres, 1f); AddSlider(s.TailFullDistance, "Far echo full at", "The distance where the far echo is at full strength.", () => Adv() && s.Far.Value, Metres, 1f); AddSlider(s.TailStrength, "Far echo strength", "How loud the far echo is in the open. Indoors it is a third of this.", () => Adv() && s.Far.Value, Percent, 0.05f); AddSlider(s.ThinHz, "Thin voice amount", "How much low tone far voices lose. Higher = thinner.", () => Adv() && s.Far.Value && s.ThinVoices.Value, Hz, 0f, log: true); AddHeading("Across the map", () => Adv() && s.FloorVolume.Value > 0f); AddSlider(s.FloorCutoffHz, "Across the map: clearness", "How clear voices and loud sounds are from across the map. Lower = duller.", () => Adv() && s.FloorVolume.Value > 0f, Hz, 0f, log: true); AddSlider(s.LoudMinRange, "Loud sound range", "A sound that the game lets carry at least this far counts as loud. You hear loud sounds across the map.", () => Adv() && s.FloorVolume.Value > 0f, Metres, 5f); AddHeading("Blast deafness", () => Adv() && s.Masking.Value); AddSlider(s.MaskDb, "Deafness amount", "How much quieter other sounds get after a blast next to you.", () => Adv() && s.Masking.Value, Db, 0.5f); AddSlider(s.MaskRange, "Deafness distance", "A blast this close deafens fully. Past twice this distance, it does nothing.", () => Adv() && s.Masking.Value, Metres, 0.5f); AddSlider(s.MaskRecoverySeconds, "Deafness recovery", "How long other sounds take to come back.", () => Adv() && s.Masking.Value, (float v) => $"{v:0.0} s", 0.1f); AddSlider(s.MaskCutoffHz, "Deafness muffle", "How dull other sounds get after a blast. Lower = duller.", () => Adv() && s.Masking.Value, Hz, 0f, log: true); AddHeading("Sound delay", () => Adv() && s.TravelTime.Value); AddSlider(s.SpeedOfSound, "Speed of sound", "How fast sound travels. Real air: 343 m/s.", () => Adv() && s.TravelTime.Value, (float v) => $"{v:0} m/s", 1f); AddSlider(s.MinDelayMs, "Smallest delay", "Delays shorter than this are not used.", () => Adv() && s.TravelTime.Value, (float v) => $"{v:0} ms", 5f); AddHeading("Frame rate cost", Adv); AddSlider(s.UpdatesPerSecond, "Updates per second", "How often each sound finds its way to you again. More costs more.", Adv, (float v) => $"{v:0.#} /s", 0.5f); AddSlider(s.MaxRouteLength, "Longest way", "Sound does not look for ways longer than this. Shorter costs less.", Adv, Metres, 5f); AddSlider(s.CellSize, "Map grid size", "Smaller finds narrow gaps but costs more. Takes effect on the next map.", Adv, (float v) => $"{v:0.0} m", 0.1f); bool Adv() { if (_advanced) { return On(); } return false; } bool On() { return s.Enabled.Value; } } private static string Percent(float v) { return $"{v * 100f:0}%"; } private static string Plain2(float v) { return $"{v:0.00}"; } private static string Db(float v) { return $"{v:0.#} dB"; } private static string Metres(float v) { return $"{v:0} m"; } private static string Hz(float v) { if (!(v >= 1000f)) { return $"{v:0} Hz"; } return $"{v / 1000f:0.#} kHz"; } private RectTransform NewRow(string name, float height) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) RectTransform component = new GameObject("SP " + name, new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)_content, false); LayoutElement obj = ((Component)component).gameObject.AddComponent<LayoutElement>(); float minHeight = (obj.preferredHeight = height); obj.minHeight = minHeight; return component; } private void AddHeading(string text, Func<bool> shown) { //IL_0030: 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_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_0055: 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) RectTransform val = NewRow("Heading " + text, 40f); TextMeshProUGUI obj = Text(val, "Text", text, 22f, (TextAlignmentOptions)1025); ((TMP_Text)obj).fontStyle = (FontStyles)(((TMP_Text)obj).fontStyle | 4); Stretch(((TMP_Text)obj).rectTransform, Vector2.zero, Vector2.one, new Vector2(10f, 2f), new Vector2(-10f, 0f)); _rows.Add(new Row { Name = "# " + text, Go = ((Component)val).gameObject, Shown = shown }); } private void AddHelp(RectTransform row, string help) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Text(row, "Help", help, 17f, (TextAlignmentOptions)4097); ((Graphic)obj).color = Dim(_textColor); ((TMP_Text)obj).enableWordWrapping = true; ((TMP_Text)obj).enableAutoSizing = true; ((TMP_Text)obj).fontSizeMin = 12f; ((TMP_Text)obj).fontSizeMax = 17f; Stretch(((TMP_Text)obj).rectTransform, Vector2.zero, Vector2.one, new Vector2(400f, 2f), new Vector2(-8f, -2f)); } private Toggle NewToggle(RectTransform row, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_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_0043: 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_0062: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(_toggleTemplate, (Transform)(object)row, false); ((Object)val).name = "Toggle"; RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0f, 0.5f); val2.anchoredPosition = new Vector2(18f, 0f); TMP_Text[] componentsInChildren = val.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text obj in componentsInChildren) { obj.text = name; obj.enableAutoSizing = true; obj.fontSizeMax = obj.fontSize; obj.fontSizeMin = obj.fontSize * 0.6f; obj.enableWordWrapping = false; } val.SetActive(true); return val.GetComponent<Toggle>(); } private void AddToggle(ConfigEntry<bool> entry, string name, string help, Func<bool> shown) { RectTransform val = NewRow(name, 46f); Toggle toggle = NewToggle(val, name); ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool on) { entry.Value = on; Refresh(); }); AddHelp(val, help); _rows.Add(new Row { Name = name, Go = ((Component)val).gameObject, Shown = shown, Sync = delegate { toggle.SetIsOnWithoutNotify(entry.Value); }, Value = () => (!entry.Value) ? "off" : "on" }); } private void AddAdvancedSwitch(Func<bool> shown) { RectTransform val = NewRow("Show fine tuning", 54f); Toggle toggle = NewToggle(val, "Show fine tuning"); toggle.SetIsOnWithoutNotify(_advanced); ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool on) { _advanced = on; Refresh(); }); AddHelp(val, "Exact numbers for each effect. The defaults are tested; right-click a slider to set it back to its default."); _rows.Add(new Row { Name = "Show fine tuning", Go = ((Component)val).gameObject, Shown = shown, Sync = delegate { toggle.SetIsOnWithoutNotify(_advanced); }, Value = () => (!_advanced) ? "off" : "on" }); } private void AddSlider(ConfigEntry<float> entry, string name, string help, Func<bool> shown, Func<float, string> format, float step, bool log = false) { AcceptableValueRange<float> val = (AcceptableValueRange<float>)(object)((ConfigEntryBase)entry).Description.AcceptableValues; AddSlider(name, help, shown, format, val.MinValue, val.MaxValue, (float)((ConfigEntryBase)entry).DefaultValue, log, whole: false, () => entry.Value, delegate(float v) { entry.Value = (log ? RoundHz(v) : RoundTo(v, step)); }); } private void AddSlider(ConfigEntry<int> entry, string name, string help, Func<bool> shown, Func<float, string> format) { AcceptableValueRange<int> val = (AcceptableValueRange<int>)(object)((ConfigEntryBase)entry).Description.AcceptableValues; AddSlider(name, help, shown, format, val.MinValue, val.MaxValue, (int)((ConfigEntryBase)entry).DefaultValue, log: false, whole: true, () => entry.Value, delegate(float v) { entry.Value = Mathf.RoundToInt(v); }); } private void AddSlider(string name, string help, Func<bool> shown, Func<float, string> format, float min, float max, float def, bool log, bool whole, Func<float> get, Action<float> set) { //IL_0071: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) RectTransform val = NewRow(name, 62f); GameObject val2 = Object.Instantiate<GameObject>(_sliderTemplate, (Transform)(object)val, false); ((Object)val2).name = "Slider"; RectTransform val3 = (RectTransform)val2.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0f, 0.5f); val3.anchorMax = val4; val3.anchorMin = val4; val3.anchoredPosition = new Vector2(186f, -12f); Slider slider = val2.GetComponentInChildren<Slider>(true); TMP_Text value = null; TMP_Text[] componentsInChildren = val2.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val5 in componentsInChildren) { if (((Object)((Component)val5).gameObject).name == "ValueDisplay") { value = val5; val5.enableWordWrapping = false; val5.alignment = (TextAlignmentOptions)4100; val5.rectTransform.sizeDelta = new Vector2(120f, val5.rectTransform.sizeDelta.y); RectTransform rectTransform = val5.rectTransform; rectTransform.anchoredPosition += new Vector2(-35f, 0f); } else { val5.text = name; val5.enableAutoSizing = true; val5.fontSizeMax = val5.fontSize; val5.fontSizeMin = val5.fontSize * 0.6f; val5.enableWordWrapping = false; } } slider.wholeNumbers = whole; slider.minValue = (log ? 0f : min); slider.maxValue = (log ? 1f : max); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float t) { bool saveOnConfigSet = _config.SaveOnConfigSet; _config.SaveOnConfigSet = false; try { set(FromSlider(t)); } finally { _config.SaveOnConfigSet = saveOnConfigSet; } _saveAt = Time.unscaledTime + 0.75f; Show(); Refresh(); }); ((Component)slider).gameObject.AddComponent<RightClick>().OnRight = delegate { slider.value = ToSlider(def); }; val2.SetActive(true); AddHelp(val, help); _rows.Add(new Row { Name = name, Go = ((Component)val).gameObject, Shown = shown, Slider = slider, Sync = delegate { slider.SetValueWithoutNotify(ToSlider(get())); Show(); }, Value = () => format(get()) }); float FromSlider(float t) { if (!log) { return t; } return min * Mathf.Pow(max / min, t); } void Show() { if (Object.op_Implicit((Object)(object)value)) { value.text = format(get()); } } float ToSlider(float v) { if (!log) { return v; } return Mathf.Log(Mathf.Max(v, min) / min) / Mathf.Log(max / min); } } private static float RoundTo(float v, float step) { if (!(step > 0f)) { return v; } return Mathf.Round(v / step) * step; } private static float RoundHz(float v) { if (!(v < 1000f)) { if (!(v < 5000f)) { return Mathf.Round(v / 100f) * 100f; } return Mathf.Round(v / 50f) * 50f; } return Mathf.Round(v / 10f) * 10f; } private void Refresh() { foreach (Row row in _rows) { bool flag = row.Shown == null || row.Shown(); if (row.Go.activeSelf != flag) { row.Go.SetActive(flag); } } } private void SyncAll() { foreach (Row row in _rows) { row.Sync?.Invoke(); } Refresh(); } private TextMeshProUGUI Text(RectTransform parent, string name, string text, float size, TextAlignmentOptions align) { //IL_0014: 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_004c: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = new GameObject(name, new Type[1] { typeof(RectTransform) }).AddComponent<TextMeshProUGUI>(); ((Transform)((TMP_Text)obj).rectTransform).SetParent((Transform)(object)parent, false); ((TMP_Text)obj).font = _font; ((Graphic)obj).color = _textColor; ((TMP_Text)obj).fontSize = size; ((TMP_Text)obj).alignment = align; ((TMP_Text)obj).text = text; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).enableWordWrapping = false; return obj; } private static Color Dim(Color c) { //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_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_001e: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, c.a * 0.75f); } private static void Stretch(RectTransform rt, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0024: 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) rt.anchorMin = anchorMin; rt.anchorMax = anchorMax; rt.pivot = new Vector2(0.5f, 0.5f); rt.offsetMin = offsetMin; rt.offsetMax = offsetMax; } public static string Debug(string[] parts) { AudioTabSettings instance = Instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance._root)) { return "error: not built (open the options menu's Audio tab once)"; } string text = ((parts.Length > 1) ? parts[1] : ""); float result; if (text == "advanced" && parts.Length > 2) { instance._advanced = parts[2] == "on"; instance.SyncAll(); } else if (text == "scroll" && parts.Length > 2 && float.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result)) { Canvas.ForceUpdateCanvases(); instance._scroll.verticalNormalizedPosition = 1f - Mathf.Clamp01(result); } else { if ((text == "slide" || text == "reset") && parts.Length > 2) { bool flag = text == "slide"; string name = string.Join(" ", parts.Skip(flag ? 3 : 2)); Row row = instance._rows.FirstOrDefault((Row r) => Object.op_Implicit((Object)(object)r.Slider) && string.Equals(r.Name, name, StringComparison.OrdinalIgnoreCase)); if (row == null) { return "error: no slider row '" + name + "'"; } if (flag) { if (!float.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { return "error: settings slide <0..1> <row name>"; } row.Slider.normalizedValue = Mathf.Clamp01(result2); } else { ((Component)row.Slider).GetComponent<RightClick>().OnRight(); } return "ok " + row.Name + " = " + row.Value(); } if (text != "") { return "error: settings | settings advanced on|off | settings scroll <0 top .. 1 bottom> | settings slide <0..1> <row> | settings reset <row>"; } } List<Row> list = instance._rows.Where((Row r) => r.Go.activeSelf).ToList(); return string.Concat(string.Format("ok {0}, {1} of {2} rows shown, advanced {3}", instance._root.activeInHierarchy ? "on screen" : "not on screen", list.Count, instance._rows.Count, instance._advanced ? "on" : "off"), string.Concat(list.Select((Row r) => " || " + r.Name + ((r.Value != null) ? (" = " + r.Value()) : "")))); } } internal sealed class DebugCommands : MonoBehaviour { private sealed class Result { public string Text; } private static string _cmdFile; private static string _logFile; private static string _dumpFile; public static void Init(ConfigFile config, GameObject host) { if (config.Bind<bool>("Debug", "DebugCommands", false, "Developer tool. Runs commands from BepInEx/soundpropagation-cmd.txt (test sounds, measurements) for tools/game.sh. Takes effect on the next game start.").Value) { _cmdFile = Path.Combine(Paths.BepInExRootPath, "soundpropagation-cmd.txt"); _logFile = Path.Combine(Paths.BepInExRootPath, "soundpropagation-cmd.log"); _dumpFile = Path.Combine(Paths.BepInExRootPath, "soundpropagation-sources.txt"); host.AddComponent<DebugCommands>(); Plugin.Log.LogInfo((object)("Debug commands on: polling '" + _cmdFile + "'")); } } private IEnumerator Start() { WaitForSecondsRealtime wait = new WaitForSecondsRealtime(0.25f); while (true) { yield return wait; string[] array = null; try { if (File.Exists(_cmdFile)) { array = File.ReadAllLines(_cmdFile); File.Delete(_cmdFile); } } catch (Exception ex) { Plugin.Log.LogInfo((object)("Debug commands: could not read the command file yet: " + ex.Message)); } if (array == null) { continue; } string[] array2 = array; foreach (string text in array2) { string line = text.Trim(); if (line.Length != 0 && !line.StartsWith("#")) { Result result = new Result(); yield return Run(line, result); string text2 = (result.Text ?? "ok").Replace('\n', ' '); try { File.AppendAllText(_logFile, line.Replace('\t', ' ') + "\t" + text2 + "\n"); } catch (Exception ex2) { Plugin.Log.LogInfo((object)("Debug commands: could not write the result log: " + ex2.Message)); } Plugin.Log.LogInfo((object)("Debug command '" + line + "': " + text2)); } } } } private static IEnumerator Run(string line, Result result) { string[] array = line.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string text = array[0]; if (text == "wait" || text == "fps") { if (array.Length < 2 || !Number(array[1], out var value) || value < 0f) { result.Text = "error: " + text + " needs a number of seconds"; yield break; } if (text == "wait") { yield return (object)new WaitForSecondsRealtime(value); yield break; } float until = Time.realtimeSinceStartup + value; float worst = 0f; float sum = 0f; int frames = 0; while (Time.realtimeSinceStartup < until) { yield return null; float unscaledDeltaTime = Time.unscaledDeltaTime; sum += unscaledDeltaTime; worst = Mathf.Max(worst, unscaledDeltaTime); frames++; } result.Text = $"ok {(float)frames / sum:0.0} fps (mean {sum / (float)frames * 1000f:0.00} ms, worst {worst * 1000f:0.0} ms, {frames} frames); {SoundRuntime.Instance.LastStats}"; yield break; } try { result.Text = Now(text, array); } catch (Exception ex) { result.Text = "error: " + ex.GetType().Name + ": " + ex.Message; Plugin.Log.LogWarning((object)$"Debug command '{line}' threw: {ex}"); } } private static string Now(string verb, string[] parts) { //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0c48: Unknown result type (might be due to invalid IL or missing references) //IL_0c4d: Unknown result type (might be due to invalid IL or missing references) //IL_0c3f: Unknown result type (might be due to invalid IL or missing references) //IL_0c2e: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_085c: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0c90: Unknown result type (might be due to invalid IL or missing references) //IL_0ca8: Unknown result type (might be due to invalid IL or missing references) //IL_0cb7: Unknown result type (might be due to invalid IL or missing references) //IL_0cc6: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a00: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_0a0e: Unknown result type (might be due to invalid IL or missing references) //IL_08c6: Unknown result type (might be due to invalid IL or missing references) //IL_08cd: Unknown result type (might be due to invalid IL or missing references) //IL_0cf8: Unknown result type (might be due to invalid IL or missing references) //IL_0cfd: Unknown result type (might be due to invalid IL or missing references) //IL_0cff: Unknown result type (might be due to invalid IL or missing references) //IL_0d01: Unknown result type (might be due to invalid IL or missing references) //IL_0d03: Unknown result type (might be due to invalid IL or missing references) //IL_0d08: Unknown result type (might be due to invalid IL or missing references) //IL_0d13: Unknown result type (might be due to invalid IL or missing references) //IL_0d15: Unknown result type (might be due to invalid IL or missing references) //IL_0d19: Unknown result type (might be due to invalid IL or missing references) //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0889: Unknown result type (might be due to invalid IL or missing references) //IL_088b: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Unknown result type (might be due to invalid IL or missing references) //IL_089b: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_081c: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) //IL_0d7d: Unknown result type (might be due to invalid IL or missing references) //IL_0d7f: Unknown result type (might be due to invalid IL or missing references) //IL_0d81: Unknown result type (might be due to invalid IL or missing references) //IL_0d88: Unknown result type (might be due to invalid IL or missing references) //IL_0ab7: Unknown result type (might be due to invalid IL or missing references) //IL_0abc: Unknown result type (might be due to invalid IL or missing references) //IL_0abf: Unknown result type (might be due to invalid IL or missing references) //IL_0ac1: Unknown result type (might be due to invalid IL or missing references) //IL_0b87: Unknown result type (might be due to invalid IL or missing references) //IL_0b96: Unknown result type (might be due to invalid IL or missing references) //IL_0ba5: Unknown result type (might be due to invalid IL or missing references) //IL_0dfe: Unknown result type (might be due to invalid IL or missing references) //IL_0e0d: Unknown result type (might be due to invalid IL or missing references) //IL_0e1c: Unknown result type (might be due to invalid IL or missing references) //IL_0e40: Unknown result type (might be due to invalid IL or missing references) //IL_0b09: Unknown result type (might be due to invalid IL or missing references) //IL_0b18: Unknown result type (might be due to invalid IL or missing references) //IL_0b27: Unknown result type (might be due to invalid IL or missing references) SoundRuntime instance = SoundRuntime.Instance; string text = ((parts.Length > 1) ? parts[1] : ""); switch (verb) { case "grid": if (instance.Grid != null) { return "ok " + (instance.Grid.Ready ? "ready" : "building") + ": " + instance.Grid.Stats; } return "ok no grid (not in a map, or the map has no colliders)"; case "stats": return "ok " + instance.LastStats; case "sounds": { List<string> list = instance.Emitters.Where((SoundRuntime.Emitter e) => e.WasPlaying && !e.OwnBody).Select(SoundRuntime.Line).ToList(); return string.Concat($"ok {list.Count} playing", string.Concat(list.Select((string l) => " || " + l))); } case "sources": return Sources(instance); case "speaker": return Speaker(parts); case "crowd": { if (text == "clear") { TestSounds.ClearCrowd(); return "ok"; } if (!int.TryParse(text, out var result) || result < 1 || result > 500) { return "error: crowd <1-500> [radius] | crowd clear"; } float value7 = 25f; if (parts.Length > 2 && !Number(parts[2], out value7)) { return "error: crowd <1-500> [radius] | crowd clear"; } if (!Object.op_Implicit((Object)(object)SoundRuntime.Listener)) { return "error: no listener (not in a map?)"; } TestSounds.PlaceCrowd(result, ((Component)SoundRuntime.Listener).transform.position, value7); return $"ok {result} test sounds within {value7:0.#} m"; } case "ear": { if (text == "off") { SoundRuntime.EarOverride = null; return "ok the ear is the camera"; } if (parts.Length < 4 || !Number(parts[1], out var value4) || !Number(parts[2], out var value5) || !Number(parts[3], out var value6)) { return "error: ear <x y z> | ear off"; } SoundRuntime.EarOverride = new Vector3(value4, value5, value6); return $"ok hearing from {value4:0.00} {value5:0.00} {value6:0.00} (this run only)"; } case "volumes": return PlayerVolumeRows.Debug(parts); case "voice": return VoiceFixes.Debug(parts); case "probe": return Probe(instance, parts); case "dispensers": { ItemDispenser[] array4 = Object.FindObjectsOfType<ItemDispenser>(); if (text == "play") { if (parts.Length < 3 || !int.TryParse(parts[2], out var result2) || result2 < 0 || result2 >= array4.Length) { return "error: dispensers play <index>"; } MethodInfo methodInfo = typeof(ItemDispenser).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name.StartsWith("RpcLogic___PlaySound") && m.GetParameters().Length == 0); if (methodInfo == null) { return "error: no PlaySound logic found"; } methodInfo.Invoke(array4[result2], null); return $"ok dispenser {result2} played its sound here"; } return string.Concat($"ok {array4.Length} dispensers", string.Concat(array4.Select(delegate(ItemDispenser d, int i) { //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_0049: Unknown result type (might be due to invalid IL or missing references) AudioSource component = ((Component)d).GetComponent<AudioSource>(); Vector3 p = ((Component)d).transform.position; string text4 = (Object.op_Implicit((Object)(object)component) ? $"blend {component.spatialBlend:0.00}, {component.rolloffMode} {component.minDistance:0.#}-{component.maxDistance:0.#} m, volume {component.volume:0.00}" : "no AudioSource"); string[] array6 = (from c in ((Component)d).GetComponentsInChildren<Collider>().Where(delegate(Collider c) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) if (!c.isTrigger) { Bounds bounds = c.bounds; return ((Bounds)(ref bounds)).Contains(p); } return false; }) select ((Object)c).name).ToArray(); return string.Format(" || {0} '{1}' at {2:0.00} {3:0.00} {4:0.00}, {5}, inside colliders: {6}", i, ((Object)d).name, p.x, p.y, p.z, text4, (array6.Length == 0) ? "none" : string.Join(",", array6)); }))); } case "doors": { Door[] array5 = Object.FindObjectsOfType<Door>(); switch (text) { case "penalty": { if (parts.Length < 3 || !Number(parts[2], out var value8)) { return "error: doors penalty <metres>"; } Plugin.Settings.DoorPenaltyMetres.Value = value8; return $"ok DoorPenaltyMetres = {Plugin.Settings.DoorPenaltyMetres.Value:0.#}"; } case "play": { if (parts.Length < 3 || !int.TryParse(parts[2], out var result3) || result3 < 0 || result3 >= array5.Length) { return "error: doors play <index>"; } Traverse obj = Traverse.Create((object)array5[result3]); AudioSource value9 = obj.Field("audio").GetValue<AudioSource>(); AudioClip value10 = obj.Field("openClip").GetValue<AudioClip>(); if (!Object.op_Implicit((Object)(object)value9) || !Object.op_Implicit((Object)(object)value10)) { return "error: door has no audio or open clip"; } value9.PlayOneShot(value10); return $"ok door {result3} played '{((Object)value10).name}' ({value10.length:0.00} s), {value9.rolloffMode} {value9.minDistance:0.#}-{value9.maxDistance:0.#} m"; } case "swing": { if (parts.Length < 4 || !int.TryParse(parts[2], out var result4) || result4 < 0 || result4 >= array5.Length || !Number(parts[3], out var value11)) { return "error: doors swing <index> <degrees> (0 = shut)"; } ((Component)array5[result4]).transform.localRotation = Quaternion.Euler(0f, value11, 0f); return $"ok door {result4} at {value11:0} deg"; } default: { string arg = ""; DoorLinks doors = instance.Doors; if (doors != null) { Vector3 val6 = Vector3.positiveInfinity; Vector3 val7 = Vector3.negativeInfinity; for (int num9 = 0; num9 < doors.Mask.Length; num9++) { if (doors.Mask[num9] != 0) { val6 = Vector3.Min(val6, doors.Grid.Centre(num9)); val7 = Vector3.Max(val7, doors.Grid.Centre(num9)); } } arg = $", {doors.Steps} steps tagged, cells {val6} .. {val7}"; } return string.Concat($"ok {array5.Length} doors{arg}", string.Concat(array5.Select((Door d, int i) => $" || {i} '{((Object)d).name}' at {((Component)d).transform.position.x:0.00} {((Component)d).transform.position.y:0.00} {((Component)d).transform.position.z:0.00}, " + $"{Quaternion.Angle(((Component)d).transform.localRotation, Quaternion.identity):0} deg from shut"))); } } } case "links": { SoundLinks links = instance.Links; Link[] current = links.Current; return string.Concat(string.Format("ok {0} links ({1} Portal, {2} teleporter; Portal Gun {3})", current.Length, links.Portals, links.Teleporters, links.PortalGunFound ? "found" : "not found"), string.Concat(current.Select((Link l) => $" || {l.Name}: {l.Entries.Length} entry cells at {l.From.x:0.0} {l.From.y:0.0} {l.From.z:0.0} -> {l.To.x:0.0} {l.To.y:0.0} {l.To.z:0.0}"))); } case "gun": return Gun(parts); case "spots": { AudioListener listener = SoundRuntime.Listener; if (!Object.op_Implicit((Object)(object)listener) || instance.Grid == null || !instance.Grid.Ready) { return "error: no listener or grid"; } Vector3 val = (Vector3)(((??)SoundRuntime.EarOverride) ?? ((Component)listener).transform.position); Vector3[] array = (from x in (from x in Object.FindObjectsOfType<SpawnPoint>() select ((Component)x).transform.position).Concat(from x in Object.FindObjectsOfType<ItemSpawner>() select ((Component)x).transform.position) select x + Vector3.up * 1.5f).ToArray(); int num = 0; int num2 = 0; int num3 = 0; StringBuilder stringBuilder = new StringBuilder(); List<float> spans = new List<float>(); Vector3[] array2 = array; foreach (Vector3 val2 in array2) { Vector3 mouth; Geometry geometry = instance.MeasurePoint(val2, val, spans, null, out mouth); if (geometry.Walls == 0) { num++; continue; } if (geometry.HasRoute) { num2++; continue; } num3++; stringBuilder.Append($" || no Route to {val2.x:0.0} {val2.y:0.0} {val2.z:0.0} ({geometry.Straight:0} m, {geometry.Walls} walls {geometry.WallMetres:0.0} m)"); } return $"ok from {val.x:0.0} {val.y:0.0} {val.z:0.0}: {array.Length} spots, {num} clear, {num2} by a Route, {num3} with neither" + stringBuilder; } case "seed": { NavGrid grid = instance.Grid; if (grid == null || !grid.Ready) { return "error: no grid"; } Vector3 val3 = (Vector3)(((??)SoundRuntime.EarOverride) ?? (Object.op_Implicit((Object)(object)SoundRuntime.Listener) ? ((Component)SoundRuntime.Listener).transform.position : Vector3.zero)); if (parts.Length >= 4 && Number(parts[1], out var value) && Number(parts[2], out var value2) && Number(parts[3], out var value3)) { ((Vector3)(ref val3))..ctor(value, value2, value3); } int[] array3 = new int[8]; int num5 = grid.Join(val3, array3); StringBuilder stringBuilder2 = new StringBuilder($"ok at {val3.x:0.00} {val3.y:0.00} {val3.z:0.00}, {num5} cells"); for (int num6 = 0; num6 < num5; num6++) { Vector3 val4 = grid.Centre(array3[num6]); Vector3 val5 = val4 - val3; float magnitude = ((Vector3)(ref val5)).magnitude; Collider hit; string text2 = ((LevelRays.FirstHit(val3, val5 / magnitude, magnitude, out hit) >= 0f) ? (((Object)hit).name + " (" + ((object)hit).GetType().Name + ", tag " + ((Component)hit).tag + ")") : "-"); Collider hit2; string text3 = ((LevelRays.FirstHit(val4, -val5 / magnitude, magnitude, out hit2) >= 0f) ? (((Object)hit2).name + " (" + ((object)hit2).GetType().Name + ")") : "-"); uint num7 = grid.Open[array3[num6]]; int num8 = 0; while (num7 != 0) { num8++; num7 &= num7 - 1; } stringBuilder2.Append($" || {val4.x:0.0} {val4.y:0.0} {val4.z:0.0}: out {text2}, back {text3}, {num8} free steps, reached {instance.ReachedNow(val4)}"); } return stringBuilder2.ToString(); } case "fire": if (!TestSounds.Fire()) { return "error: place one first: speaker shot [x y z]"; } return "ok the test shot plays once"; case "mask": return $"ok mask {instance.Mask:0.00}"; case "materials": return Materials(); case "view": return Switch(text, ref SoundRuntime.ViewOverride, Plugin.Settings.DebugView.Value); case "log": return Switch(text, ref SoundRuntime.LogOverride, Plugin.Settings.DebugLog.Value); case "enable": return Switch(text, ref SoundRuntime.EnabledOverride, Plugin.Settings.Enabled.Value); case "audio-tab": return AudioTabDump.Write(); case "settings": return AudioTabSettings.Debug(parts); case "ui-find": return AudioTabDump.Find(string.Join(" ", parts.Skip(1))); default: return "error: unknown command '" + verb + "'"; } } private static string Switch(string arg, ref bool? over, bool config) { switch (arg) { case "on": over = true; break; case "off": over = false; break; case "config": over = null; break; default: return "error: on | off | config"; } return "ok " + ((over ?? config) ? "on" : "off") + ((!over.HasValue) ? " (config)" : " (this run only)"); } private static string Gun(string[] parts) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Invalid comparison between Unknown and I4 SpawnerManager.PopulateAllWeapons(); GameObject[] source = SpawnerManager.AllWeapons.Where((GameObject w) => Object.op_Implicit((Object)(object)w) && Object.op_Implicit((Object)(object)w.GetComponent<Weapon>()) && Object.op_Implicit((Object)(object)w.GetComponent<Weapon>().fireClip)).ToArray(); if (parts.Length < 2) { return "ok guns: " + string.Join(", ", source.Select((GameObject w) => ((Object)w).name)); } GameObject val = ((IEnumerable<GameObject>)source).FirstOrDefault((Func<GameObject, bool>)((GameObject w) => string.Equals(((Object)w).name, parts[1], StringComparison.OrdinalIgnoreCase))); if (!Object.op_Implicit((Object)(object)val)) { return "error: no gun '" + parts[1] + "' (gun with no name lists them)"; } AudioListener listener = SoundRuntime.Listener; if (!Object.op_Implicit((Object)(object)listener)) { return "error: no listener (not in a map?)"; } Vector3 val2 = default(Vector3); if (parts.Length >= 5) { if (!Number(parts[2], out var value) || !Number(parts[3], out var value2) || !Number(parts[4], out var value3)) { return "error: gun <name> [x y z]"; } ((Vector3)(ref val2))..ctor(value, value2, value3); } else { Vector3 val3 = Vector3.ProjectOnPlane(((Component)listener).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val3)).normalized; val2 = ((Component)listener).transform.position + ((((Vector3)(ref normalized)).sqrMagnitude < 0.01f) ? Vector3.forward : normalized) * 6f; } Weapon component = val.GetComponent<Weapon>(); AudioSource val4 = (Object.op_Implicit((Object)(object)component.audio) ? component.audio : val.GetComponentInChildren<AudioSource>()); GameObject val5 = new GameObject("TestGun_" + ((Object)val).name); val5.transform.position = val2; AudioSource val6 = val5.AddComponent<AudioSource>(); val6.playOnAwake = false; val6.spatialBlend = 1f; if (Object.op_Implicit((Object)(object)val4)) { val6.rolloffMode = val4.rolloffMode; if ((int)val4.rolloffMode == 2) { val6.SetCustomCurve((AudioSourceCurveType)0, val4.GetCustomCurve((AudioSourceCurveType)0)); } val6.minDistance = val4.minDistance; val6.maxDistance = val4.maxDistance; val6.volume = val4.volume; val6.outputAudioMixerGroup = val4.outputAudioMixerGroup; val6.dopplerLevel = val4.dopplerLevel; } val6.PlayOneShot(component.fireClip); Sounds.Started(val6); Object.Destroy((Object)val5, component.fireClip.length + 3f); return $"ok {((Object)val).name} fired at {val2.x:0.00} {val2.y:0.00} {val2.z:0.00}, {val6.rolloffMode} {val6.minDistance:0.#}-{val6.maxDistance:0.#} m, clip {component.fireClip.length:0.00} s"; } private static string Speaker(string[] parts) { //IL_0091: 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_00a4: 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_00b1: 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_00c4: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (parts.Length < 2) { return "error: speaker voice|loud|quiet|shot [x y z] | speaker clear"; } if (parts[1] == "clear") { TestSounds.Clear(); return "ok"; } if (!Enum.TryParse<TestSounds.Kind>(parts[1], ignoreCase: true, out var result)) { return "error: speaker voice|loud|quiet|shot [x y z] | speaker clear"; } AudioListener listener = SoundRuntime.Listener; if (!Object.op_Implicit((Object)(object)listener)) { return "error: no listener (not in a map?)"; } Vector3 val = default(Vector3); if (parts.Length >= 5) { if (!Number(parts[2], out var value) || !Number(parts[3], out var value2) || !Number(parts[4], out var value3)) { return "error: speaker voice|loud|quiet|shot [x y z] | speaker clear"; } ((Vector3)(ref val))..ctor(value, value2, value3); } else { Vector3 val2 = Vector3.ProjectOnPlane(((Component)listener).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val2)).normalized; val = ((Component)listener).transform.position + ((((Vector3)(ref normalized)).sqrMagnitude < 0.01f) ? Vector3.forward : normalized) * 6f; } TestSounds.Place(result, val); return $"ok {result} test sound at {val.x:0.00} {val.y:0.00} {val.z:0.00} (ear at {((Component)listener).transform.position.x:0.00} {((Component)listener).transform.position.y:0.00} {((Component)listener).transform.position.z:0.00})"; } private static string Probe(SoundRuntime runtime, string[] parts) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00da: 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_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_0101: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) float value = 3f; float value2 = 24f; if (parts.Length > 1 && !Number(parts[1], out value)) { return "error: probe [minRise] [radius]"; } if (parts.Length > 2 && !Number(parts[2], out value2)) { return "error: probe [minRise] [radius]"; } AudioListener listener = SoundRuntime.Listener; if (!Object.op_Implicit((Object)(object)listener)) { return "error: no listener (not in a map?)"; } Vector3 val = (Vector3)(((??)SoundRuntime.EarOverride) ?? ((Component)listener).transform.position); List<(float, string)> list = new List<(float, string)>(); int num = 0; for (float num2 = -10f; num2 <= 10f; num2 += 1f) { if (Mathf.Abs(num2) < value) { continue; } for (float num3 = 0f - value2; num3 <= value2; num3 += 2f) { for (float num4 = 0f - value2; num4 <= value2; num4 += 2f) { Vector3 val2 = val + new Vector3(num3, num2, num4); if (!(LevelRays.FirstHit(val2, Vector3.down, 2f) < 0.8f) && LevelRays.Clear(val2, val2 + Vector3.up * 0.5f)) { num++; Vector3 mouth; Geometry geometry = runtime.MeasurePoint(val2, val, null, null, out mouth); if (geometry.Walls != 0 && geometry.HasRoute && !geometry.RouteIsGuess) { list.Add((geometry.R0.Length, $"{val2.x:0.0} {val2.y:0.0} {val2.z:0.0} (straight {geometry.Straight:0.0}, Route {geometry.R0.Length:0.0} turn {geometry.R0.Turn:0}, {geometry.Routes} Routes, walls {geometry.Walls}/{geometry.WallMetres:0.00} m)")); } } } } } list.Sort(((float score, string text) p, (float score, string text) q) => p.score.CompareTo(q.score)); return string.Concat($"ok {list.Count} of {num} standing places", string.Concat(from f in list.Take(8) select " || " + f.text)); } private static string Sources(SoundRuntime runtime) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); int num = 0; foreach (SoundRuntime.Emitter item in runtime.Emitters.OrderBy((SoundRuntime.Emitter e) => e.Name)) { if (!Object.op_Implicit((Object)(object)item.Go)) { continue; } foreach (SoundRuntime.Sound sound in item.Sounds) { if (Object.op_Implicit((Object)(object)sound.Source)) { num++; stringBuilder.Append($"{sound.Class,-6} {sound.Mode,-12} {sound.Min,6:0.#}-{sound.Max,-6:0.#} blend {sound.Source.spatialBlend:0.##} vol {sound.Source.volume:0.##} " + (sound.Source.isPlaying ? "PLAYING " : "") + (item.OwnBody ? "OWN " : "") + "clip '" + (Object.op_Implicit((Object)(object)sound.Source.clip) ? ((Object)sound.Source.clip).name : "") + "' " + SoundRuntime.Path(item.At) + "\n"); } } } File.WriteAllText(_dumpFile, stringBuilder.ToString()); return $"ok {num} sources written to {_dumpFile}"; } private static string Materials() { //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, float[]> dictionary = new Dictionary<string, float[]>(); Collider[] array = Object.FindObjectsOfType<Collider>(); foreach (Collider val in array) { if (val.enabled && ((Component)val).gameObject.activeInHierarchy && !LevelRays.IgnoredForGrid(val)) { Surface(val, out var total, out var wall); if (!dictionary.TryGetValue(((Component)val).tag, out var value)) { value = (dictionary[((Component)val).tag] = new float[3]); } value[0] += 1f; value[1] += total; value[2] += wall; } } float allWall = dictionary.Values.Sum((float[] v) => v[2]); float[] value2; float num = (dictionary.TryGetValue("Untagged", out value2) ? value2[2] : 0f); StringBuilder stringBuilder = new StringBuilder("tag\tcolliders\tarea m2\twall m2\twall share\n"); foreach (KeyValuePair<string, float[]> item in dictionary.OrderByDescending((KeyValuePair<string, float[]> kv) => kv.Value[2])) { stringBuilder.Append($"{item.Key}\t{item.Value[0]:0}\t{item.Value[1]:0}\t{item.Value[2]:0}\t{((allWall > 0f) ? (item.Value[2] / allWall) : 0f):P1}\n"); } string text = Path.Combine(Paths.BepInExRootPath, "soundpropagation-materials.txt"); Scene activeScene = SceneManager.GetActiveScene(); File.AppendAllText(text, "== " + ((Scene)(ref activeScene)).name + "\n" + stringBuilder); float num2 = ((allWall > 0f) ? (1f - num / allWall) : 0f); return string.Concat($"ok {dictionary.Count} tags, wall area {allWall:0} m2, {num2:P0} of it tagged; written to {text}", string.Concat(from kv in dictionary.OrderByDescending((KeyValuePair<string, float[]> kv) => kv.Value[2]).Take(6) select $" || {kv.Key} {((allWall > 0f) ? (kv.Value[2] / allWall) : 0f):P0}")); } private static void Surface(Collider c, out float total, out float wall) { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0082: 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_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_00a2: 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_00a9: 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_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_00b7: 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) total = (wall = 0f); Transform transform = ((Component)c).transform; MeshCollider val = (MeshCollider)(object)((c is MeshCollider) ? c : null); if (val != null && Object.op_Implicit((Object)(object)val.sharedMesh) && val.sharedMesh.isReadable) { Vector3[] vertices = val.sharedMesh.vertices; int[] triangles = val.sharedMesh.triangles; for (int i = 0; i + 2 < triangles.Length; i += 3) { Vector3 val2 = transform.TransformPoint(vertices[triangles[i]]); Vector3 val3 = transform.TransformPoint(vertices[triangles[i + 1]]); Vector3 val4 = transform.TransformPoint(vertices[triangles[i + 2]]); Vector3 val5 = Vector3.Cross(val3 - val2, val4 - val2); float num = ((Vector3)(ref val5)).magnitude * 0.5f; total += num; if (num > 0f && Mathf.Abs(val5.y / (2f * num)) < 0.5f) { wall += num; } } return; } BoxCollider val6 = (BoxCollider)(object)((c is BoxCollider) ? c : null); Vector3 val7; if (val6 != null) { val7 = Vector3.Scale(val6.size, transform.lossyScale); } else { Bounds bounds = c.bounds; val7 = ((Bounds)(ref bounds)).size; } ((Vector3)(ref val7))..ctor(Mathf.Abs(val7.x), Mathf.Abs(val7.y), Mathf.Abs(val7.z)); Vector3[] array = (Vector3[])(object)((!(c is BoxCollider)) ? new Vector3[3] { Vector3.right, Vector3.up, Vector3.forward } : new Vector3[3] { transform.right, transform.up, transform.forward }); float[] array2 = new float[3] { val7.y * val7.z, val7.x * val7.z, val7.x * val7.y }; for (int j = 0; j < 3; j++) { total += 2f * array2[j]; if (Mathf.Abs(array[j].y) < 0.5f) { wall += 2f * array2[j]; } } } private static bool Number(string text, out float value) { return float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out value); } } internal static class DebugView { private static readonly List<LineRenderer> Lines = new List<LineRenderer>(); private static readonly Vector3[] Two = (Vector3[])(object)new Vector3[2]; private static Transform _holder; private static Material _material; private static int _used; private static bool _hidden = true; private static readonly Color[] RouteColours = (Color[])(object)new Color[3] { Color.yellow, new Color(1f, 0.5f, 0f), Color.magenta }; public static void Draw(IReadOnlyList<SoundRuntime.Emitter> emitters, Vector3? ear) { //IL_0051: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_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_0081: 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_0091: 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_00a5: 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_00b0: 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_00ba: 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_00ca: 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_00d9: 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_00df: 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_00f3: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) _used = 0; _hidden = false; AudioListener listener = SoundRuntime.Listener; Vector3 val; if (ear.HasValue) { if (Object.op_Implicit((Object)(object)listener)) { val = ((Component)listener).transform.position - ear.Value; if (!(((Vector3)(ref val)).sqrMagnitude > 4f)) { goto IL_0102; } } Vector3 value = ear.Value; Segment(value - Vector3.up * 0.5f, value + Vector3.up * 0.5f, Color.cyan, 0.1f); Segment(value - Vector3.right * 0.5f, value + Vector3.right * 0.5f, Color.cyan, 0.1f); Segment(value - Vector3.forward * 0.5f, value + Vector3.forward * 0.5f, Color.cyan, 0.1f); } goto IL_0102; IL_0102: foreach (SoundRuntime.Emitter emitter in emitters) { if (!emitter.WasPlaying || emitter.OwnBody || !Object.op_Implicit((Object)(object)emitter.Go)) { continue; } Geometry geo = emitter.Geo; for (int i = 0; i < geo.Routes && i < emitter.Routes.Length; i++) { DrawRoute(emitter.Routes[i], (i == 0) ? (geo.R0.Straight ? Color.green : Color.yellow) : RouteColours[i], (i == 0) ? 0.07f : 0.05f); } if (geo.Walls != 0) { val = emitter.Mouth - emitter.Ear; Vector3 normalized = ((Vector3)(ref val)).normalized; Segment(emitter.Ear, emitter.Mouth, new Color(0.75f, 0.75f, 0.75f), 0.025f); for (int j = 0; j + 1 < emitter.WallSpans.Count; j += 2) { Segment(emitter.Ear + normalized * emitter.WallSpans[j], emitter.Ear + normalized * emitter.WallSpans[j + 1], Color.red, 0.16f); } } } for (int k = _used; k < Lines.Count; k++) { if (((Renderer)Lines[k]).enabled) { ((Renderer)Lines[k]).enabled = false; } } } private static void DrawRoute(List<Vector3> points, Color colour, float width) { //IL_0014: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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) int num = 0; for (int i = 0; i <= points.Count; i++) { if (i < points.Count && !float.IsNaN(points[i].x)) { continue; } int num2 = i - num; if (num2 >= 2) { LineRenderer val = Next(colour, width); val.positionCount = num2; for (int j = 0; j < num2; j++) { val.SetPosition(j, points[num + j]); } } if (i < points.Count && i > 0 && i + 1 < points.Count) { Segment(points[i - 1], points[i + 1], Color.cyan, 0.03f); } num = i + 1; } } public static void Hide() { if (_hidden) { return; } _hidden = true; foreach (LineRenderer line in Lines) { if (Object.op_Implicit((Object)(object)line)) { ((Renderer)line).enabled = false; } } } private static void Segment(Vector3 a, Vector3 b, Color colour, float width) { //IL_0000: 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_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references) LineRenderer obj = Next(colour, width); Two[0] = a; Two[1] = b; obj.positionCount = 2; obj.SetPositions(Two); } private static LineRenderer Next(Color colour, float width) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0031: Expected O, but got Unknown //IL_0127: 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_0129: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_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_006c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_holder)) { Lines.Clear(); GameObject val = new GameObject("SoundPropagationDebugView") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); _holder = val.transform; Shader val2 = Shader.Find("Hidden/Internal-Colored"); if (!Object.op_Implicit((Object)(object)val2)) { val2 = Shader.Find("Sprites/Default"); } _material = new Material(val2) { hideFlags = (HideFlags)61 }; _material.SetInt("_ZTest", 8); _material.SetInt("_ZWrite", 0); _material.renderQueue = 4000; } if (_used == Lines.Count) { GameObject val3 = new GameObject("line") { hideFlags = (HideFlags)61 }; val3.transform.SetParent(_holder, false); LineRenderer val4 = val3.AddComponent<LineRenderer>(); ((Renderer)val4).sharedMaterial = _material; val4.useWorldSpace = true; ((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val4).receiveS