Decompiled source of Examination Quest v0.2.1
Mods\Examination.dll
Decompiled 20 minutes 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.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.Json; using System.Threading.Tasks; using BoneLib; using BoneLib.BoneMenu; using Examination; using Examination.Medical; using HarmonyLib; using Il2Cpp; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.VFX; using Il2CppSLZ.Marrow.Warehouse; using MelonLoader; using MelonLoader.Utils; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Main), "Examination", "0.2.0", "syrup", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyVersion("0.0.0.0")] namespace Examination { public static class BootAudio { private static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>(); private static bool _scanned; private static AudioSource _rapidSource; private static AudioSource _voiceSource; private static AudioSource _ostSource; public static void Reset() { try { if ((Object)(object)_rapidSource != (Object)null) { Object.Destroy((Object)(object)((Component)_rapidSource).gameObject); _rapidSource = null; } if ((Object)(object)_voiceSource != (Object)null) { Object.Destroy((Object)(object)((Component)_voiceSource).gameObject); _voiceSource = null; } if ((Object)(object)_ostSource != (Object)null) { Object.Destroy((Object)(object)((Component)_ostSource).gameObject); _ostSource = null; } foreach (AudioClip value in Clips.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } Clips.Clear(); _scanned = false; } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: boot audio reset failed: " + ex.Message); } } } public static void Play(string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown try { AudioClip clip = GetClip(name); if (!((Object)(object)clip == (Object)null)) { GameObject val = new GameObject("[Examination] BootAudio"); ((Object)val).hideFlags = (HideFlags)61; AudioSource val2 = val.AddComponent<AudioSource>(); val2.spatialBlend = 0f; val2.playOnAwake = false; val2.loop = false; val2.clip = clip; val2.Play(); Object.Destroy((Object)(object)val, clip.length + 0.5f); } } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: boot audio playback failed: " + ex.Message); } } } public static void PlayType() { string[] array = new string[3] { "type", "type2", "type3" }; int num = Random.Range(0, array.Length); for (int i = 0; i < array.Length; i++) { string name = array[(num + i) % array.Length]; if ((Object)(object)GetClip(name) != (Object)null) { Play(name); break; } } } public static void PlayTypeRapid() { string[] array = new string[3] { "type", "type2", "type3" }; int num = Random.Range(0, array.Length); for (int i = 0; i < array.Length; i++) { string name = array[(num + i) % array.Length]; if ((Object)(object)GetClip(name) != (Object)null) { PlayRapid(name); break; } } } public static void PlayAny(params string[] names) { if (names.Length == 0) { return; } int num = Random.Range(0, names.Length); for (int i = 0; i < names.Length; i++) { string name = names[(num + i) % names.Length]; if ((Object)(object)GetClip(name) != (Object)null) { Play(name); break; } } } public static void PlayTreatment(string treatmentName) { if (string.IsNullOrEmpty(treatmentName)) { PlayAny("select"); return; } string text = "treat_" + treatmentName.ToLowerInvariant(); AudioClip clip = GetClip(text); if ((Object)(object)clip != (Object)null) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination: treatment sound '" + text + "' (" + clip.length.ToString("0.0") + "s)."); } Play(text); } else { Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Msg("Examination: treatment sound '" + text + "' missing - falling back to select."); } PlayAny("select"); } } public static float LengthOf(string name) { AudioClip clip = GetClip(name); return ((Object)(object)clip != (Object)null) ? clip.length : 0f; } private static string FindFile(string name) { try { string path = Path.Combine(Data.Dir, "sounds"); if (!Directory.Exists(path)) { return null; } string[] files = Directory.GetFiles(path, "*.wav"); foreach (string text in files) { if (string.Equals(Path.GetFileNameWithoutExtension(text), name, StringComparison.OrdinalIgnoreCase)) { return text; } } } catch { } return null; } public static bool HasUrgent(string name) { return FindFile("urgent" + name) != null; } public static AudioClip GetVoice(string name, bool urgentIntent, out bool urgent) { urgent = false; string key = "!u!" + name; if (Clips.TryGetValue(key, out var value)) { if ((Object)(object)value != (Object)null) { urgent = true; return value; } Clips.Remove(key); } if (!urgentIntent && Clips.TryGetValue(name, out var value2)) { if ((Object)(object)value2 != (Object)null) { return value2; } Clips.Remove(name); } string text = FindFile("urgent" + name); string text2 = FindFile(name); AudioClip val = null; if (urgentIntent) { if (text != null) { val = LoadWav(name, text); if ((Object)(object)val != (Object)null) { Clips[key] = val; urgent = true; return val; } } if (text2 != null) { val = LoadWav(name, text2); if ((Object)(object)val != (Object)null) { Clips[name] = val; return val; } } } else { if (text2 != null) { val = LoadWav(name, text2); if ((Object)(object)val != (Object)null) { Clips[name] = val; return val; } } if (text != null) { val = LoadWav(name, text); if ((Object)(object)val != (Object)null) { Clips[key] = val; urgent = true; return val; } } } return null; } public static float VoiceLength(string name, bool urgentIntent, out bool urgent) { AudioClip voice = GetVoice(name, urgentIntent, out urgent); return ((Object)(object)voice != (Object)null) ? voice.length : 0f; } public static void PlayVoice(string name, bool urgentIntent) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown bool urgent; AudioClip voice = GetVoice(name, urgentIntent, out urgent); if ((Object)(object)voice == (Object)null) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: voiceline '" + name + "' not found (urgentIntent=" + urgentIntent + ") — dropping the file into UserData/Examination/sounds/."); } return; } Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Msg("Examination: playing voiceline '" + name + "' (" + voice.length.ToString("0.0") + "s, urgent=" + urgent + ")."); } StopVoice(); try { GameObject val = new GameObject("[Examination] VoiceLine"); ((Object)val).hideFlags = (HideFlags)61; _voiceSource = val.AddComponent<AudioSource>(); _voiceSource.spatialBlend = 0f; _voiceSource.playOnAwake = false; _voiceSource.loop = false; _voiceSource.clip = voice; _voiceSource.Play(); Object.Destroy((Object)(object)val, voice.length + 0.5f); } catch (Exception ex) { Main instance3 = Main.Instance; if (instance3 != null) { ((MelonBase)instance3).LoggerInstance.Warning("Examination: voiceline playback failed: " + ex.Message); } } } public static void StopVoice() { try { if ((Object)(object)_voiceSource != (Object)null) { _voiceSource.Stop(); Object.Destroy((Object)(object)((Component)_voiceSource).gameObject); _voiceSource = null; } } catch { _voiceSource = null; } } public static List<string> ListOst() { List<string> list = new List<string>(); try { string path = Path.Combine(Data.Dir, "sounds"); if (!Directory.Exists(path)) { return list; } string[] files = Directory.GetFiles(path, "*.wav"); foreach (string path2 in files) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path2); if (fileNameWithoutExtension.IndexOf("ost", StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(fileNameWithoutExtension); } } list.Sort(StringComparer.OrdinalIgnoreCase); } catch { } return list; } public static void PlayOst(string name) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown AudioClip clip = GetClip(name); if ((Object)(object)clip == (Object)null) { return; } StopOst(); try { GameObject val = new GameObject("[Examination] Ost"); ((Object)val).hideFlags = (HideFlags)61; _ostSource = val.AddComponent<AudioSource>(); _ostSource.spatialBlend = 0f; _ostSource.playOnAwake = false; _ostSource.loop = false; _ostSource.clip = clip; _ostSource.Play(); Object.Destroy((Object)(object)val, clip.length + 0.5f); } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: ost playback failed: " + ex.Message); } } } public static void StopOst() { try { if ((Object)(object)_ostSource != (Object)null) { _ostSource.Stop(); Object.Destroy((Object)(object)((Component)_ostSource).gameObject); _ostSource = null; } } catch { _ostSource = null; } } public static void PlayRapid(string name) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown try { AudioClip clip = GetClip(name); if (!((Object)(object)clip == (Object)null)) { if ((Object)(object)_rapidSource == (Object)null) { GameObject val = new GameObject("[Examination] BootAudioRapid"); ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); _rapidSource = val.AddComponent<AudioSource>(); _rapidSource.spatialBlend = 0f; _rapidSource.playOnAwake = false; _rapidSource.loop = false; } _rapidSource.clip = clip; _rapidSource.Play(); } } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: rapid audio playback failed: " + ex.Message); } } } public static void PlayRapidAny(params string[] names) { for (int i = 0; i < names.Length; i++) { AudioClip clip = GetClip(names[i]); if ((Object)(object)clip != (Object)null) { PlayRapid(names[i]); break; } } } private static AudioClip GetClip(string name) { if (Clips.TryGetValue(name, out var value)) { if ((Object)(object)value != (Object)null) { return value; } Clips.Remove(name); } if (!_scanned) { _scanned = true; Scan(); } Clips.TryGetValue(name, out value); if ((Object)(object)value == (Object)null) { string text = FindFile(name); if (text != null) { value = LoadWav(name, text); if ((Object)(object)value != (Object)null) { Clips[name] = value; } } } return value; } private static void Scan() { try { string text = Path.Combine(Data.Dir, "sounds"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination: created sounds folder " + text + " (drop in: off.wav, type.wav, power_on.wav, activated.wav)"); } return; } string[] array = new string[43] { "off", "type", "type2", "type3", "power_on", "activated", "select", "error", "hover", "panel_off", "select_region", "select_patient", "treat_bandage", "treat_splint", "treat_medkit", "treat_morphine", "treat_saline", "success", "interrupted", "cpr_start", "cpr_compression", "cpr_complete", "injury", "nvgdie", "nvgdie2", "nvguplink", "nvgtick", "nvgcharge", "nvgcritical", "rebooting", "radio_on", "radio_off", "tocappear", "tocappear2", "voiceline1", "voiceline2", "voiceline3", "voiceline4", "voiceline5", "voiceline6", "voiceline7", "voiceline8", "voiceline9" }; for (int i = 0; i < array.Length; i++) { string path = Path.Combine(text, array[i] + ".wav"); if (File.Exists(path)) { AudioClip val = LoadWav(array[i], path); if ((Object)(object)val != (Object)null) { Clips[array[i]] = val; } } } Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Msg("Examination: boot sounds loaded (" + Clips.Count + " of 4)."); } } catch (Exception ex) { Main instance3 = Main.Instance; if (instance3 != null) { ((MelonBase)instance3).LoggerInstance.Warning("Examination: boot audio scan failed: " + ex.Message); } } } private static AudioClip LoadWav(string name, string path) { try { byte[] array = File.ReadAllBytes(path); if (array.Length < 44 || array[0] != 82 || array[1] != 73 || array[2] != 70 || array[3] != 70 || array[8] != 87 || array[9] != 65 || array[10] != 86 || array[11] != 69) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: " + name + ".wav is not a RIFF WAV file."); } return null; } int num = 1; int num2 = 44100; int num3 = 16; int num4 = -1; int num5 = 0; int num6; for (int i = 12; i + 8 <= array.Length; i += 8 + num6 + (num6 & 1)) { string text = new string(new char[4] { (char)array[i], (char)array[i + 1], (char)array[i + 2], (char)array[i + 3] }); num6 = array[i + 4] | (array[i + 5] << 8) | (array[i + 6] << 16) | (array[i + 7] << 24); if (text == "fmt " && num6 >= 16) { int num7 = array[i + 8] | (array[i + 9] << 8); num = array[i + 10] | (array[i + 11] << 8); num2 = array[i + 12] | (array[i + 13] << 8) | (array[i + 14] << 16) | (array[i + 15] << 24); num3 = array[i + 22] | (array[i + 23] << 8); if (num7 != 1 && num7 != 65534) { Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Warning("Examination: " + name + ".wav is not PCM (compressed formats unsupported)."); } return null; } } else if (text == "data") { num4 = i + 8; num5 = num6; break; } } if (num4 < 0 || num5 <= 0 || num < 1 || num > 2 || (num3 != 8 && num3 != 16 && num3 != 24 && num3 != 32)) { Main instance3 = Main.Instance; if (instance3 != null) { ((MelonBase)instance3).LoggerInstance.Warning("Examination: " + name + ".wav must be 8/16/24/32-bit PCM mono or stereo."); } return null; } int num8 = num3 / 8; int num9 = num5 / num8; int num10 = num9 / num; if (num10 <= 0) { return null; } float[] array2 = new float[num9]; for (int j = 0; j < num9; j++) { int num11 = num4 + j * num8; switch (num3) { case 8: array2[j] = (float)(array[num11] - 128) / 128f; break; case 16: { short num14 = (short)(array[num11] | (array[num11 + 1] << 8)); array2[j] = (float)num14 / 32768f; break; } case 24: { int num13 = array[num11] | (array[num11 + 1] << 8) | (array[num11 + 2] << 16); if ((num13 & 0x800000) != 0) { num13 |= -16777216; } array2[j] = (float)num13 / 8388608f; break; } default: { int num12 = array[num11] | (array[num11 + 1] << 8) | (array[num11 + 2] << 16) | (array[num11 + 3] << 24); array2[j] = (float)num12 / 2.1474836E+09f; break; } } } AudioClip val = AudioClip.Create(name, num10, num, num2, false); val.SetData(Il2CppStructArray<float>.op_Implicit(array2), 0); return val; } catch (Exception ex) { Main instance4 = Main.Instance; if (instance4 != null) { ((MelonBase)instance4).LoggerInstance.Warning("Examination: failed to load " + name + ".wav: " + ex.Message); } return null; } } } public static class ClassApplier { private enum PhaseKind { Clear, Avatar, Item } private class Phase { public PhaseKind Kind; public string Title; } private static readonly Queue<Phase> _phases = new Queue<Phase>(); private static readonly List<GameObject> _spawned = new List<GameObject>(); private static int _generation; private static float _nextPhaseAt; private static float _applyAt; public static void Apply(ClassDef cls) { if (cls != null) { _generation++; _phases.Clear(); _nextPhaseAt = Time.unscaledTime + 0.15f; _applyAt = Time.unscaledTime; _phases.Enqueue(new Phase { Kind = PhaseKind.Clear, Title = null }); _phases.Enqueue(new Phase { Kind = PhaseKind.Avatar, Title = cls.Avatar }); Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination: applying " + cls.Id); } } } public static void Tick() { if (_phases.Count == 0 || Time.unscaledTime < _nextPhaseAt) { return; } Phase phase = _phases.Peek(); if (phase.Kind == PhaseKind.Item && !PalletIndex.Ready && Time.unscaledTime - _applyAt < 20f) { _nextPhaseAt = Time.unscaledTime + 0.25f; return; } _phases.Dequeue(); _nextPhaseAt = Time.unscaledTime + ((phase.Kind == PhaseKind.Item) ? 0.9f : 0.35f); switch (phase.Kind) { case PhaseKind.Clear: ClearKit(); break; case PhaseKind.Avatar: SwapAvatar(phase.Title); break; case PhaseKind.Item: Give(phase.Title); break; } } private static void ClearKit() { for (int i = 0; i < _spawned.Count; i++) { if ((Object)(object)_spawned[i] != (Object)null) { DespawnObject(_spawned[i]); } } _spawned.Clear(); ClearHolsters(); } private static void DespawnObject(GameObject go) { try { Poolee val = go.GetComponentInParent<Poolee>(); if ((Object)(object)val == (Object)null) { val = go.GetComponentInChildren<Poolee>(true); } MarrowEntity val2 = go.GetComponentInParent<MarrowEntity>(); if ((Object)(object)val2 == (Object)null) { val2 = go.GetComponentInChildren<MarrowEntity>(true); } if ((Object)(object)val != (Object)null) { if ((Object)(object)val2 != (Object)null) { SpawnEffects.CallDespawnEffect(val2); } val.Despawn(); } } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: kit cleanup failed: " + ex.Message); } } } private static void ClearHolsters() { RigManager rigManager = LocalPlayer.RigManager; if ((Object)(object)rigManager == (Object)null) { return; } InventorySlotReceiver[] array = Il2CppArrayBase<InventorySlotReceiver>.op_Implicit(((Component)rigManager).GetComponentsInChildren<InventorySlotReceiver>(true)); foreach (InventorySlotReceiver val in array) { IGrippable host = val.GetHost(); if (host == null) { continue; } GameObject val2 = null; try { val2 = host.GetHostGameObject(); } catch { continue; } if ((Object)(object)val2 == (Object)null) { continue; } Poolee val3 = val2.GetComponentInParent<Poolee>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.GetComponentInChildren<Poolee>(true); } MarrowEntity val4 = val2.GetComponentInParent<MarrowEntity>(); if ((Object)(object)val4 == (Object)null) { val4 = val2.GetComponentInChildren<MarrowEntity>(true); } if (!((Object)(object)val3 != (Object)null)) { continue; } try { if ((Object)(object)val4 != (Object)null) { SpawnEffects.CallDespawnEffect(val4); } val3.Despawn(); } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: holster clear failed: " + ex.Message); } } } } private static void Give(string title) { //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01fd: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(title)) { return; } SpawnableCrate crate = Crates.FindSpawnable(title); if ((Object)(object)crate == (Object)null) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: no loaded spawnable matches \"" + title + "\". Is the pack installed and its pallet loaded?"); } return; } string text = PalletIndex.FindSpawnableBarcode(title); if (string.IsNullOrEmpty(text)) { try { text = ((((Scannable)crate).Barcode != (Barcode)null) ? ((Scannable)crate).Barcode.ID : null); } catch { text = null; } } if (string.IsNullOrEmpty(text)) { Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Warning("Examination: no barcode for \"" + title + "\" - skipping."); } return; } Transform head = LocalPlayer.Head; Vector3 val = (((Object)(object)head != (Object)null) ? head.forward : Vector3.forward); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { val = Vector3.forward; } ((Vector3)(ref val)).Normalize(); Vector3 val2 = (((Object)(object)head != (Object)null) ? head.position : (((Component)LocalPlayer.RigManager).transform.position + Vector3.up * 1.2f)) + val * 1.25f + Vector3.down * 0.12f; Quaternion val3 = Quaternion.LookRotation(val, Vector3.up); int gen = _generation; Action<GameObject> action = delegate(GameObject go) { if (gen != _generation || (Object)(object)go == (Object)null) { if ((Object)(object)go != (Object)null) { DespawnObject(go); } } else { _spawned.Add(go); Main instance6 = Main.Instance; if (instance6 != null) { ((MelonBase)instance6).LoggerInstance.Msg("Examination: " + ((Scannable)crate).Title + " spawned at the player."); } } }; try { if (FusionBridge.SpawnNetworked(text, val2, val3)) { Main instance3 = Main.Instance; if (instance3 != null) { ((MelonBase)instance3).LoggerInstance.Msg("Examination: " + ((Scannable)crate).Title + " spawned (networked)."); } return; } Spawnable val4 = new Spawnable(); val4.crateRef = new SpawnableCrateReference(text); val4.policyData = null; AssetSpawner.Register(val4); MethodInfo method = typeof(AssetSpawner).GetMethod("Spawn"); if (method != null) { method.Invoke(null, new object[9] { val4, val2, val3, null, null, false, null, null, null }); return; } throw new MissingMethodException("AssetSpawner.Spawn"); } catch (Exception ex) { Main instance4 = Main.Instance; if (instance4 != null) { ((MelonBase)instance4).LoggerInstance.Warning("Examination: AssetSpawner failed for \"" + title + "\" (" + ex.Message + ") - falling back to the warehouse spawn."); } try { HelperMethods.SpawnCrate(text, val2, val3, Vector3.one, false, action, (Action<GameObject>)null); } catch (Exception ex2) { Main instance5 = Main.Instance; if (instance5 != null) { ((MelonBase)instance5).LoggerInstance.Warning("Examination: spawn failed for \"" + title + "\": " + ex2.Message); } } } } private static void SwapAvatar(string match) { if (string.IsNullOrEmpty(match)) { return; } AvatarCrate val = Crates.FindAvatar(match); if ((Object)(object)val == (Object)null) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: no loaded avatar matches \"" + match + "\". Is the Mintys Soldiers pack installed and its pallet loaded?"); } return; } try { RigManager rigManager = LocalPlayer.RigManager; MethodInfo method = typeof(RigManager).GetMethod("SwapAvatarCrate"); if (method != null) { method.Invoke(rigManager, new object[3] { ((Scannable)val).Barcode, true, null }); Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Msg("Examination: avatar swapped to " + ((Scannable)val).Title + "."); } } else { Main instance3 = Main.Instance; if (instance3 != null) { ((MelonBase)instance3).LoggerInstance.Warning("Examination: SwapAvatarCrate missing - avatar swap skipped."); } } } catch (Exception ex) { Main instance4 = Main.Instance; if (instance4 != null) { ((MelonBase)instance4).LoggerInstance.Warning("Examination: avatar swap failed: " + ex.Message); } } } } public static class ClassSelection { private static readonly Color Accent = new Color(0.72f, 0.1f, 0.16f, 1f); private static readonly Color Sub = new Color(0.9f, 0.9f, 0.9f, 1f); private static readonly Color Rasonia = new Color(0.88f, 0.22f, 0.2f, 1f); private static readonly Color Menlo = new Color(0.28f, 0.72f, 0.34f, 1f); private static Page _classPage; private static Page _rasoniaSection; private static Page _menloSection; private static Page _rootPage; private static Element _nvgEnableOption; private static Page _nvgColorPage; private static bool _nvgOptionsShown; public static string LockedClass { get; private set; } public static void SetNvgOption(bool available) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_015e: Unknown result type (might be due to invalid IL or missing references) if (_rootPage == null || available == _nvgOptionsShown) { return; } _nvgOptionsShown = available; if (available) { _nvgEnableOption = (Element)(object)_rootPage.CreateBool("NVG Enabled", Sub, Minimap.NvgEnabled, (Action<bool>)delegate(bool value) { Minimap.NvgEnabled = value; }); _nvgColorPage = _rootPage.CreatePage("NVG Color", Sub, 6, true); _nvgColorPage.CreateFunction("White", Sub, (Action)delegate { Minimap.NvgColor = Nvg.ColorMode.White; }); _nvgColorPage.CreateFunction("Green", Sub, (Action)delegate { Minimap.NvgColor = Nvg.ColorMode.Green; }); _nvgColorPage.CreateFunction("Red", Sub, (Action)delegate { Minimap.NvgColor = Nvg.ColorMode.Red; }); _nvgColorPage.CreateFunction("Blue", Sub, (Action)delegate { Minimap.NvgColor = Nvg.ColorMode.Blue; }); _nvgColorPage.CreateFunction("Amber", Sub, (Action)delegate { Minimap.NvgColor = Nvg.ColorMode.Amber; }); } else { if (_nvgEnableOption != null) { _rootPage.Remove(_nvgEnableOption); _nvgEnableOption = null; } if (_nvgColorPage != null) { _rootPage.RemovePage(_nvgColorPage); _nvgColorPage = null; } if (Minimap.NvgEnabled) { Minimap.NvgEnabled = false; } } } private static void PickClass(ClassDef cls) { if (LockedClass != null) { BootAudio.Play("error"); Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: class locked as " + LockedClass + " - rejoin the server to pick again."); } return; } if (Teams.PlayerTeam != Faction.None) { bool flag = cls.Faction == "RASONIA"; if ((Teams.PlayerTeam == Faction.Rasonia && !flag) || (Teams.PlayerTeam == Faction.Menlo && flag)) { BootAudio.Play("error"); Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Warning("Examination: " + cls.Faction + " classes are locked - you are on team " + Teams.Name(Teams.PlayerTeam) + "."); } return; } } LockedClass = cls.Id; BootAudio.Play("select"); ClassApplier.Apply(cls); } public static void RefreshSections() { //IL_0084: 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) if (_classPage == null) { return; } try { if (_rasoniaSection != null) { _classPage.RemovePage(_rasoniaSection); _rasoniaSection = null; } if (_menloSection != null) { _classPage.RemovePage(_menloSection); _menloSection = null; } } catch { } if (Teams.PlayerTeam != Faction.Menlo) { _rasoniaSection = BuildSection(_classPage, "RASONIAN FORCES", "RASONIA", Rasonia); } if (Teams.PlayerTeam != Faction.Rasonia) { _menloSection = BuildSection(_classPage, "MENLONIAN FORCES", "MENLO", Menlo); } } public static void Build() { //IL_000b: 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_004f: 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_007f: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) Page val = Page.Root.CreatePage("Examination", Accent, 7, true); _classPage = val.CreatePage("Class Selection", Sub, 6, true); RefreshSections(); Page val2 = val.CreatePage("Team", new Color(0.55f, 0.55f, 0.55f, 1f), 7, true); val2.CreateFunction("Join RASONIAN FORCES", Rasonia, (Action)Teams.JoinRasonia); val2.CreateFunction("Join MENLONIAN FORCES", Menlo, (Action)Teams.JoinMenlo); val2.CreateFunction("Leave Team", Sub, (Action)Teams.Leave); FunctionElement val3 = val2.CreateFunction("Assign Nearest NPC: RASONIA", Rasonia, (Action)Teams.AssignGrabbedRasonia); ((Element)val3).SetTooltip("Assigns the NPC nearest to you. The name is remembered."); FunctionElement val4 = val2.CreateFunction("Assign Nearest NPC: MENLO", Menlo, (Action)Teams.AssignGrabbedMenlo); ((Element)val4).SetTooltip("Assigns the NPC nearest to you. The name is remembered."); val2.CreateFunction("Clear Nearest NPC", Sub, (Action)Teams.ClearGrabbed); Page val5 = val2.CreatePage("Assign NPC Class", Sub, 8, true); for (int i = 0; i < Data.Classes.Count; i++) { ClassDef classDef = Data.Classes[i]; string id = classDef.Id; Color val6 = ((classDef.Faction == "RASONIA") ? Rasonia : Menlo); FunctionElement val7 = val5.CreateFunction(classDef.Name, val6, (Action)delegate { Teams.AssignNearestClass(id); }); ((Element)val7).SetTooltip(string.IsNullOrEmpty(classDef.Tag) ? "Assigns this class to the nearest NPC (no nametag yet)." : ("Assigns this class to the nearest NPC; their nametag shows [" + classDef.Tag + "].")); } val.CreateBool("Minimap", Sub, Minimap.Enabled, (Action<bool>)delegate(bool value) { Minimap.Enabled = value; }); Page val8 = val.CreatePage("Attachment", Sub, 7, true); val8.CreateFunction("Wrist", Sub, (Action)delegate { Minimap.Anchor = Minimap.MapAnchor.Wrist; }); val8.CreateFunction("Unit-Styled", Sub, (Action)delegate { Minimap.Anchor = Minimap.MapAnchor.UnitStyled; }); val.CreateFloat("Radar Range", Sub, Minimap.RadarMetres, 10f, 30f, 300f, (Action<float>)delegate(float value) { Minimap.RadarMetres = value; }); BoolElement val9 = val.CreateBool("RADIO", Sub, Radio.Active, (Action<bool>)Radio.SetActive); ((Element)val9).SetTooltip("RADIO ACTIVE / RADIO INACTIVE — boots the radio net with radio_on.wav and shuts it down with radio_off.wav."); Toc.BuildMenu(val); _rootPage = val; FunctionElement val10 = val.CreateFunction("ACTIVATE MAPPING HUD.", Sub, (Action)Minimap.RenderMap); ((Element)val10).SetTooltip("Powers on the minimap: snapshots the current level and plays the boot sequence."); try { Hooking.OnLevelLoaded += delegate { LockedClass = null; }; } catch { } } private static Page BuildSection(Page parent, string title, string faction, Color color) { //IL_0010: 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_00c1: Unknown result type (might be due to invalid IL or missing references) Page val = parent.CreatePage(title, color, 8, true); bool flag = false; for (int i = 0; i < Data.Classes.Count; i++) { ClassDef cls = Data.Classes[i]; if (!(cls.Faction != faction)) { FunctionElement val2 = val.CreateFunction(cls.Name, Sub, (Action)delegate { PickClass(cls); }); ((Element)val2).SetTooltip(TooltipOf(cls)); flag = true; } } if (!flag) { FunctionElement val3 = val.CreateFunction("NO CLASSES DEPLOYED", Sub, (Action)delegate { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination: no " + faction + " classes in classes.json yet."); } }); ((Element)val3).SetTooltip("Add classes to UserData/Examination/classes.json with \"Faction\": \"" + faction + "\"."); } return val; } private static string TooltipOf(ClassDef cls) { string text = string.Empty; if (!string.IsNullOrEmpty(cls.Primary)) { text = text + "\nPRIMARY (back): " + cls.Primary; } if (!string.IsNullOrEmpty(cls.Secondary)) { text = text + "\nSECONDARY (front): " + cls.Secondary; } if (!string.IsNullOrEmpty(cls.Avatar)) { text = text + "\nAVATAR: " + cls.Avatar; } return (string.IsNullOrEmpty(cls.Description) ? cls.Name : cls.Description) + text; } } public static class Crates { private static readonly Dictionary<string, AvatarCrate> _avatars = new Dictionary<string, AvatarCrate>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, SpawnableCrate> _spawnables = new Dictionary<string, SpawnableCrate>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, AvatarCrate> _avatarCache = new Dictionary<string, AvatarCrate>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, SpawnableCrate> _spawnCache = new Dictionary<string, SpawnableCrate>(StringComparer.OrdinalIgnoreCase); private static bool _subscribed; private static bool _scanned; private static bool _hotLoadTried; public static void Ensure() { if (!_subscribed) { _subscribed = true; } } private static void OnCrateAdded(Barcode barcode) { try { AssetWarehouse instance = AssetWarehouse.Instance; AvatarCrate val = default(AvatarCrate); if (instance.TryGetCrate<AvatarCrate>(barcode, ref val) && (Object)(object)val != (Object)null) { _avatars[Title((Crate)(object)val)] = val; } SpawnableCrate val2 = default(SpawnableCrate); if (instance.TryGetCrate<SpawnableCrate>(barcode, ref val2) && (Object)(object)val2 != (Object)null) { _spawnables[Title((Crate)(object)val2)] = val2; } } catch { } } private static void ScanOnce() { if (!_scanned) { _scanned = true; } } public static AvatarCrate FindAvatar(string match) { if (_avatarCache.TryGetValue(match ?? "", out var value) && (Object)(object)value != (Object)null) { return value; } ScanOnce(); string text = PalletIndex.FindAvatarBarcode(match); if (text != null) { AvatarCrate val = TryGetAvatar(text); if ((Object)(object)val != (Object)null) { _avatarCache[match] = val; return val; } } PalletIndex.Scan(); text = PalletIndex.FindAvatarBarcode(match); if (text != null) { AvatarCrate val2 = TryGetAvatar(text); if ((Object)(object)val2 != (Object)null) { _avatarCache[match] = val2; return val2; } } AvatarCrate val3 = FindIn(_avatars, match); if ((Object)(object)val3 == (Object)null) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: no avatar matches \"" + match + "\" on disk or in memory. Is the pack installed? (Pallet index: " + PalletIndex.FindAvatarBarcode(match) + ")"); } } else { _avatarCache[match] = val3; } return val3; } public static SpawnableCrate FindSpawnable(string match) { if (_spawnCache.TryGetValue(match ?? "", out var value) && (Object)(object)value != (Object)null) { return value; } ScanOnce(); string text = PalletIndex.FindSpawnableBarcode(match); if (text != null) { SpawnableCrate val = TryGetSpawnable(text); if ((Object)(object)val != (Object)null) { _spawnCache[match] = val; return val; } } PalletIndex.Scan(); text = PalletIndex.FindSpawnableBarcode(match); if (text != null) { SpawnableCrate val2 = TryGetSpawnable(text); if ((Object)(object)val2 != (Object)null) { _spawnCache[match] = val2; return val2; } } SpawnableCrate val3 = FindIn(_spawnables, match); if ((Object)(object)val3 == (Object)null) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: no spawnable matches \"" + match + "\" on disk or in memory. Is the pack installed?"); } } else { _spawnCache[match] = val3; } return val3; } public static void DumpLoaded() { PalletIndex.Scan(); PalletIndex.Dump(); } private static AvatarCrate TryGetAvatar(string barcode) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown try { AvatarCrate val = default(AvatarCrate); if (AssetWarehouse.Instance.TryGetCrate<AvatarCrate>(new Barcode(barcode), ref val) && (Object)(object)val != (Object)null) { return val; } } catch { } return null; } private static SpawnableCrate TryGetSpawnable(string barcode) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown try { SpawnableCrate val = default(SpawnableCrate); if (AssetWarehouse.Instance.TryGetCrate<SpawnableCrate>(new Barcode(barcode), ref val) && (Object)(object)val != (Object)null) { return val; } } catch { } return null; } private static void HotLoadPallets() { if (_hotLoadTried) { return; } _hotLoadTried = true; try { AssetWarehouse.Instance.LoadPalletsFromModsFolder(); Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination: hot-loaded pallets from the Mods folder."); } } catch (Exception ex) { Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Warning("Examination: hot pallet load failed: " + ex.Message); } } } public static void Tick() { if (_hotLoadTried) { return; } try { if (AssetWarehouse.Instance != null && !HelperMethods.IsLoading()) { HotLoadPallets(); } } catch { } } private static T FindIn<T>(Dictionary<string, T> map, string match) where T : class { if (string.IsNullOrEmpty(match)) { return null; } if (map.TryGetValue(match, out var value)) { return value; } string text = PalletIndex.Plain(match); if (!string.IsNullOrEmpty(text) && map.TryGetValue(text, out value)) { return value; } foreach (KeyValuePair<string, T> item in map) { string text2 = PalletIndex.Plain(item.Key); if (string.IsNullOrEmpty(text2) || (!text2.Contains(text, StringComparison.OrdinalIgnoreCase) && !text2.Contains(match, StringComparison.OrdinalIgnoreCase))) { continue; } return item.Value; } return null; } private static string Title(Crate crate) { try { return ((Scannable)crate).Title ?? string.Empty; } catch { return string.Empty; } } } public class ClassDef { public string Id { get; set; } = string.Empty; public string Faction { get; set; } = "MENLO"; public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public string Tier { get; set; } = "standard"; public string RankRequired { get; set; } public string Avatar { get; set; } public string Primary { get; set; } public string Secondary { get; set; } public string PrimaryHolster { get; set; } = "back"; public string Item1 { get; set; } public string Item2 { get; set; } public string Tag { get; set; } public string TagColor { get; set; } } public class RankDef { public string Id { get; set; } = string.Empty; public int Badges { get; set; } public string Sidearm { get; set; } public string NameTag { get; set; } = string.Empty; } public static class Data { public static List<ClassDef> Classes { get; private set; } = new List<ClassDef>(); public static List<RankDef> Ranks { get; private set; } = new List<RankDef>(); public static string Dir => Path.Combine(MelonEnvironment.UserDataDirectory, "Examination"); public static void Load() { try { Directory.CreateDirectory(Dir); Seed(); Classes = Read<List<ClassDef>>("classes.json") ?? new List<ClassDef>(); Ranks = Read<List<RankDef>>("ranks.json") ?? new List<RankDef>(); bool patched = false; PatchTag("rif_infantryman", "R.I.F", "#F72828"); PatchTag("rif_medic", "R.I.F - M", "#DB8181"); PatchTag("rif_arrowhead", "R.I.F - A", "#BD2626"); PatchTag("rif_shotgunner", "R.I.F - S", "#FF0000"); PatchTag("mgf_standard", "M.G.F", "#00FF4C"); PatchTag("mgf_breacher", "M.G.F - B", "#07AB38"); PatchTag("mgf_medic", "M.G.F - M", "#6DC789"); PatchTag("mgf_enforcer", "M.G.F - E", "#38E8D3"); if (patched) { try { File.WriteAllText(Path.Combine(Dir, "classes.json"), JsonSerializer.Serialize(Classes, new JsonSerializerOptions { WriteIndented = true })); Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination data: patched classes.json with class tags."); } } catch (Exception ex) { Main instance2 = Main.Instance; if (instance2 != null) { ((MelonBase)instance2).LoggerInstance.Warning("Examination data: tag patch failed: " + ex.Message); } } } Main instance3 = Main.Instance; if (instance3 != null) { ((MelonBase)instance3).LoggerInstance.Msg("Examination data: " + Classes.Count + " classes, " + Ranks.Count + " ranks."); } void PatchTag(string id, string tag, string color) { for (int i = 0; i < Classes.Count; i++) { if (Classes[i].Id == id && (Classes[i].Tag != tag || Classes[i].TagColor != color)) { Classes[i].Tag = tag; Classes[i].TagColor = color; patched = true; } } } } catch (Exception ex2) { Main instance4 = Main.Instance; if (instance4 != null) { ((MelonBase)instance4).LoggerInstance.Error("Examination data load failed: " + ex2.Message); } } } public static void ReloadClasses() { Classes = Read<List<ClassDef>>("classes.json") ?? new List<ClassDef>(); Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Msg("Examination classes reloaded: " + Classes.Count); } } private static T Read<T>(string file) where T : class { string path = Path.Combine(Dir, file); if (!File.Exists(path)) { return null; } return JsonSerializer.Deserialize<T>(File.ReadAllText(path)); } private static void WriteIfMissing(string file, string content) { string path = Path.Combine(Dir, file); if (!File.Exists(path)) { File.WriteAllText(path, content); } } private static void Seed() { WriteIfMissing("ranks.json", "[\n { \"Id\": \"CONSCRIPT\", \"Badges\": 0, \"Sidearm\": null, \"NameTag\": \"CST\" },\n { \"Id\": \"PVT\", \"Badges\": 1, \"Sidearm\": null, \"NameTag\": \"PVT\" },\n { \"Id\": \"SPEC\", \"Badges\": 3, \"Sidearm\": null, \"NameTag\": \"SPEC\" },\n { \"Id\": \"CPL\", \"Badges\": 4, \"Sidearm\": null, \"NameTag\": \"CPL\" },\n { \"Id\": \"SGT\", \"Badges\": 5, \"Sidearm\": \"LOCK-17 (F)\", \"NameTag\": \"SGT\" },\n { \"Id\": \"SSGT\", \"Badges\": 6, \"Sidearm\": null, \"NameTag\": \"SSGT\" },\n { \"Id\": \"FA\", \"Badges\": 8, \"Sidearm\": null, \"NameTag\": \"FA\" },\n { \"Id\": \"FO\", \"Badges\": 9, \"Sidearm\": null, \"NameTag\": \"FO\" },\n { \"Id\": \"FS\", \"Badges\": 10, \"Sidearm\": null, \"NameTag\": \"FS\" },\n { \"Id\": \"OFC\", \"Badges\": 11, \"Sidearm\": \"AOP-9\", \"NameTag\": \"OFC\" },\n { \"Id\": \"XFC\", \"Badges\": 12, \"Sidearm\": null, \"NameTag\": \"XFC\" },\n { \"Id\": \"LT\", \"Badges\": 13, \"Sidearm\": null, \"NameTag\": \"LT\" }\n]"); WriteIfMissing("classes.json", "[\n {\n \"Id\": \"rif_infantryman\",\n \"Faction\": \"RASONIA\",\n \"Name\": \"☬┊CLASS #1 — RIF INFANTRYMAN\",\n \"Description\": \"Standard Rasonian infantry. Reliable, aggressive, and everywhere at once.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(S) Soldier A\",\n \"Primary\": \"<color=#b80000>AK-47\",\n \"Secondary\": \"<color=#b80000>MK23\",\n \"Tag\": \"R.I.F\",\n \"TagColor\": \"#F72828\"\n },\n {\n \"Id\": \"rif_medic\",\n \"Faction\": \"RASONIA\",\n \"Name\": \"☬┊CLASS #2 — RIF MEDIC\",\n \"Description\": \"Keeps the squad alive under fire.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(GD) Mortician Royal\",\n \"Secondary\": \"<color=#b80000>MK23\",\n \"Item1\": \"<color=#ff3100>Auto Injector\",\n \"Tag\": \"R.I.F - M\",\n \"TagColor\": \"#DB8181\"\n },\n {\n \"Id\": \"rif_arrowhead\",\n \"Faction\": \"RASONIA\",\n \"Name\": \"☬┊CLASS #3 — RIF ARROWHEAD\",\n \"Description\": \"The RIF's long-range specialists and secondary stealth units. They support Infantrymen by providing overwatch and engaging distant threats. Patience, accuracy, and coordination.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(GD) Shocktrooper Royal\",\n \"Primary\": \"<color=#b80000>Lee-Enfield No.1 Mk III\",\n \"Secondary\": \"<color=#b80000>MK23\",\n \"Tag\": \"R.I.F - A\",\n \"TagColor\": \"#BD2626\"\n },\n {\n \"Id\": \"rif_shotgunner\",\n \"Faction\": \"RASONIA\",\n \"Name\": \"☬┊CLASS #4 — RIF SHOTGUNNER\",\n \"Description\": \"Breaching specialists. The shotgun does the talking.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(GD) Rook Royal\",\n \"Primary\": \"<color=#b80000>Remington 870\",\n \"PrimaryHolster\": \"front\",\n \"Secondary\": \"<color=#b80000>MK23\",\n \"Tag\": \"R.I.F - S\",\n \"TagColor\": \"#FF0000\"\n },\n {\n \"Id\": \"mgf_standard\",\n \"Faction\": \"MENLO\",\n \"Name\": \"☬┊CLASS #1 — MGF STANDARD\",\n \"Description\": \"Menlonian Ground Forces rifleman, standard issue.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(S) Olive B\",\n \"Primary\": \"<color=#b80000>MP5A2\",\n \"PrimaryHolster\": \"front\",\n \"Secondary\": \"<color=#b80000>M1911A1\",\n \"Tag\": \"M.G.F\",\n \"TagColor\": \"#00FF4C\"\n },\n {\n \"Id\": \"mgf_breacher\",\n \"Faction\": \"MENLO\",\n \"Name\": \"☬┊CLASS #2 — MGF BREACHER\",\n \"Description\": \"First through the door. Loud, fast, decisive.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(S) Olive A\",\n \"Primary\": \"<color=#b80000>Model 80\",\n \"PrimaryHolster\": \"front\",\n \"Secondary\": \"<color=#b80000>M1911A1\",\n \"Tag\": \"M.G.F - B\",\n \"TagColor\": \"#07AB38\"\n },\n {\n \"Id\": \"mgf_medic\",\n \"Faction\": \"MENLO\",\n \"Name\": \"☬┊CLASS #3 — MGF MEDIC\",\n \"Description\": \"Combat medic. Keeps the push moving.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(S) Nameless G\",\n \"Secondary\": \"<color=#b80000>P345\",\n \"Item1\": \"<color=#ff3100>Auto Injector\",\n \"Tag\": \"M.G.F - M\",\n \"TagColor\": \"#6DC789\"\n },\n {\n \"Id\": \"mgf_enforcer\",\n \"Faction\": \"MENLO\",\n \"Name\": \"☬┊CLASS #4 — MGF ENFORCER\",\n \"Description\": \"Heavy armour, heavier firepower. The Enforcer holds the line.\",\n \"Tier\": \"standard\",\n \"Avatar\": \"(S) Blue B\",\n \"Primary\": \"<color=#00ffffff>R870\",\n \"PrimaryHolster\": \"front\",\n \"Secondary\": \"<color=yellow>M6C/SOCOM Pistol\",\n \"Item2\": \"GIGN Shield\",\n \"Tag\": \"M.G.F - E\",\n \"TagColor\": \"#38E8D3\"\n }\n]"); } } public static class FusionBridge { private static bool _probed; private static MethodInfo _init; private static MethodInfo _tick; private static MethodInfo _factionOf; private static MethodInfo _classOf; private static MethodInfo _spawnNetworked; private static MethodInfo _isPlayerRig; private static MethodInfo _broadcastToc; private static MethodInfo _pollToc; private static MethodInfo _localPlatformId; private static MethodInfo _broadcastOst; private static MethodInfo _pollOst; private static MethodInfo _medicalStateOf; private static MethodInfo _vitalsOf; private static MethodInfo _playerNameOf; private static MethodInfo _rigPlatformIdOf; private static MethodInfo _tryGetRigOfPlatform; private static MethodInfo _sendMedical; private static MethodInfo _pollMedical; public static bool Available { get { Probe(); return _init != null; } } public static void Init() { Probe(); if (!(_init != null)) { return; } try { _init.Invoke(null, null); } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion bridge init failed: " + ex.Message); } } } public static void Tick() { Probe(); if (!(_tick != null)) { return; } try { _tick.Invoke(null, new object[4] { (int)Teams.PlayerTeam, ClassSelection.LockedClass ?? "", MedicalSystem.LocalStateString, MedicalSystem.LocalVitalsString }); } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion bridge tick failed: " + ex.Message); } } } public static int FactionOf(GameObject rig) { Probe(); if (_factionOf == null || (Object)(object)rig == (Object)null) { return 0; } try { return (int)_factionOf.Invoke(null, new object[1] { rig }); } catch { return 0; } } public static string ClassOf(GameObject rig) { Probe(); if (_classOf == null || (Object)(object)rig == (Object)null) { return null; } try { return (string)_classOf.Invoke(null, new object[1] { rig }); } catch { return null; } } public static bool IsPlayerRig(GameObject rig) { Probe(); if (_isPlayerRig == null || (Object)(object)rig == (Object)null) { return false; } try { return (bool)_isPlayerRig.Invoke(null, new object[1] { rig }); } catch { return false; } } public static string MyPlatformId() { Probe(); if (_localPlatformId == null) { return ""; } try { return ((string)_localPlatformId.Invoke(null, null)) ?? ""; } catch { return ""; } } public static string VitalsOf(GameObject rig) { Probe(); if (_vitalsOf == null || (Object)(object)rig == (Object)null) { return ""; } try { return ((string)_vitalsOf.Invoke(null, new object[1] { rig })) ?? ""; } catch { return ""; } } public static string PlayerNameOf(GameObject rig) { Probe(); if (_playerNameOf == null || (Object)(object)rig == (Object)null) { return null; } try { return (string)_playerNameOf.Invoke(null, new object[1] { rig }); } catch { return null; } } public static string RigPlatformIdOf(GameObject rig) { Probe(); if (_rigPlatformIdOf == null || (Object)(object)rig == (Object)null) { return null; } try { return (string)_rigPlatformIdOf.Invoke(null, new object[1] { rig }); } catch { return null; } } public static bool TryGetRigOfPlatform(string platformId, out GameObject rig) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) rig = null; Probe(); if (_tryGetRigOfPlatform == null || string.IsNullOrEmpty(platformId)) { return false; } try { object[] array = new object[2] { platformId, null }; bool flag = (bool)_tryGetRigOfPlatform.Invoke(null, array); rig = ((!flag) ? ((GameObject)null) : ((GameObject)array[1])); return flag && (Object)(object)rig != (Object)null; } catch { rig = null; return false; } } public static bool SendToc(string text, string voiceName = null) { Probe(); if (_broadcastToc == null || string.IsNullOrEmpty(text)) { return false; } try { return (bool)_broadcastToc.Invoke(null, new object[2] { text, voiceName ?? "" }); } catch { return false; } } public static string PollToc() { Probe(); if (_pollToc == null) { return null; } try { return (string)_pollToc.Invoke(null, null); } catch { return null; } } public static bool SendOst(string name) { Probe(); if (_broadcastOst == null || name == null) { return false; } try { return (bool)_broadcastOst.Invoke(null, new object[1] { name }); } catch { return false; } } public static string PollOst() { Probe(); if (_pollOst == null) { return null; } try { return (string)_pollOst.Invoke(null, null); } catch { return null; } } public static string MedicalStateOf(GameObject rig) { Probe(); if (_medicalStateOf == null || (Object)(object)rig == (Object)null) { return ""; } try { return ((string)_medicalStateOf.Invoke(null, new object[1] { rig })) ?? ""; } catch { return ""; } } public static bool SendMedical(string treatment, string region, GameObject targetRig) { Probe(); if (_sendMedical == null) { return false; } try { return (bool)_sendMedical.Invoke(null, new object[3] { treatment, region, targetRig }); } catch { return false; } } public static string PollMedical() { Probe(); if (_pollMedical == null) { return null; } try { return (string)_pollMedical.Invoke(null, null); } catch { return null; } } public static bool SpawnNetworked(string barcode, Vector3 position, Quaternion rotation) { //IL_003a: 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) Probe(); if (_spawnNetworked == null || string.IsNullOrEmpty(barcode)) { return false; } try { return (bool)_spawnNetworked.Invoke(null, new object[3] { barcode, position, rotation }); } catch { return false; } } private static void Probe() { if (_probed) { return; } _probed = true; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { if (!(assembly.GetName().Name != "ExaminationFusion")) { Type type = assembly.GetType("Examination.FusionSync"); if (!(type == null)) { _init = type.GetMethod("Init", BindingFlags.Static | BindingFlags.Public); _tick = type.GetMethod("Tick", BindingFlags.Static | BindingFlags.Public); _factionOf = type.GetMethod("FactionOf", BindingFlags.Static | BindingFlags.Public); _classOf = type.GetMethod("ClassOf", BindingFlags.Static | BindingFlags.Public); _spawnNetworked = type.GetMethod("SpawnNetworked", BindingFlags.Static | BindingFlags.Public); _isPlayerRig = type.GetMethod("IsPlayerRig", BindingFlags.Static | BindingFlags.Public); _broadcastToc = type.GetMethod("BroadcastToc", BindingFlags.Static | BindingFlags.Public); _pollToc = type.GetMethod("PollToc", BindingFlags.Static | BindingFlags.Public); _localPlatformId = type.GetMethod("LocalPlatformId", BindingFlags.Static | BindingFlags.Public); _broadcastOst = type.GetMethod("BroadcastOst", BindingFlags.Static | BindingFlags.Public); _pollOst = type.GetMethod("PollOst", BindingFlags.Static | BindingFlags.Public); _medicalStateOf = type.GetMethod("MedicalStateOf", BindingFlags.Static | BindingFlags.Public); _vitalsOf = type.GetMethod("VitalsOf", BindingFlags.Static | BindingFlags.Public); _playerNameOf = type.GetMethod("PlayerNameOf", BindingFlags.Static | BindingFlags.Public); _rigPlatformIdOf = type.GetMethod("RigPlatformIdOf", BindingFlags.Static | BindingFlags.Public); _tryGetRigOfPlatform = type.GetMethod("TryGetRigOfPlatform", BindingFlags.Static | BindingFlags.Public); _sendMedical = type.GetMethod("BroadcastMedical", BindingFlags.Static | BindingFlags.Public); _pollMedical = type.GetMethod("PollMedical", BindingFlags.Static | BindingFlags.Public); } break; } } } catch { } } } public class Main : MelonMod { private static float _nextUpdateErrorLogAt; private static float _nextLateUpdateErrorLogAt; public static Main Instance { get; private set; } public override void OnInitializeMelon() { Instance = this; Step("data", Data.Load); Step("teams", Teams.Load); Step("crates", Crates.Ensure); Step("classes", ClassSelection.Build); Step("minimap", Minimap.Init); Step("fusion", FusionBridge.Init); Step("toc", Toc.LoadConfig); Step("medical", delegate { MedicalSystem.Init(((MelonBase)this).HarmonyInstance); }); Step("pallet", PalletIndex.Scan); ((MelonBase)this).LoggerInstance.Msg("Examination ready. BoneMenu -> Examination -> Class Selection."); } public override void OnUpdate() { try { Minimap.Update(); Nametags.Update(); FusionBridge.Tick(); ClassApplier.Tick(); Crates.Tick(); Toc.Update(); MedicalSystem.Update(); } catch (Exception ex) { if (Time.unscaledTime >= _nextUpdateErrorLogAt) { _nextUpdateErrorLogAt = Time.unscaledTime + 3f; ((MelonBase)this).LoggerInstance.Warning("Examination: update failed: " + ex.Message); } } } public override void OnLateUpdate() { try { Minimap.LateUpdate(); } catch (Exception ex) { if (Time.unscaledTime >= _nextLateUpdateErrorLogAt) { _nextLateUpdateErrorLogAt = Time.unscaledTime + 3f; ((MelonBase)this).LoggerInstance.Warning("Examination: late update failed: " + ex.Message); } } } private static void Step(string name, Action action) { try { action(); } catch (Exception ex) { Main instance = Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: init step '" + name + "' failed: " + ex.Message); } } } } public static class Minimap { private enum SnapStage { Idle, Bounds, Bake, Probe, Render, Pixels, Final } public enum MapAnchor { Wrist, UnitStyled } private enum BootPhase { Off, Activating, Activated, Fading, On } private struct BootLine { public string Text; public int Color; public BootLine(string text, int color) { Text = text; Color = color; } } private const float Unit = 0.0111f; private const float Design = 300f; private const float Edge = 150f; private const int Tex = 512; private const int Coarse = 224; private const int BakePerFrame = 256; private const int NavGrid = 48; private const float RevealR = 36f; private const float StampR = 42f; private const float PeekTime = 0.12f; private static GameObject _root; private static Transform _mapT; private static Transform _ticksT; private static Transform _reliefT; private static Mesh _reliefMesh; private static Transform _arrowT; private static Transform _wedgeT; private static Mesh _letters; private static Transform _readoutT; private static Mesh _readoutMesh; private static string _lastReadout; private static float _nextReadout; private static Material _mapMat; private static Mesh _mapMesh; private static Vector2[] _planeBaseUv; private static Vector2[] _planeUv; private static readonly List<Material> _tinted = new List<Material>(); private static Texture2D _map; private static byte[] _explored; private static byte[] _snap; private static byte[] _walkable; private static Color32[] _ilPixels; private static float[] _radial; private static Camera _eye; private static float _nextEye; private static Vector2 _worldCenter; private static float _worldHalf; private static float _peek = 1f; private static bool _built; private static bool _hooked; private static bool _mapReady; private static int _lastTx = int.MinValue; private static int _lastTz = int.MinValue; private static SnapStage _job = SnapStage.Idle; private static int _jobCursor; private static byte[] _jobCoarse; private static Vector3 _jobCenter; private static float _jobHalf; private static GameObject _jobCamGo; private static Camera _jobCam; private static RenderTexture _jobRt; private static bool _jobFlipU; private static bool _jobFlipV; private static bool _jobProbed; private static float _displayAz; private static float _scrollX; private static float _scrollZ; private static float _winX; private static float _winZ; private static float _uvScale = 1f; private static float _smoothScale = 1f; private static Vector3 _smoothPos; private static BootPhase _boot = BootPhase.Off; private static float _bootAt; private static Transform _bootScreenT; private static Material _bootScreenMat; private static Transform _bootTextT; private static Mesh _bootTextMesh; private static Material _bootTextMat; private static Transform _bootHeaderT; private static Mesh _bootHeaderMesh; private static Material _bootHeaderMat; private static Transform _bootLineT; private static Material _bootLineMat; private static string _bootTextShown; private static int _bootVisible = -1; private static BootLine[] _bootLines; private static int[] _lineTyped; private static float[] _lineNextAt; private static float[] _lineStartAt; private static int _bootLinesStarted; private static float _bootSoundAt; private static float _bootTypeAt; private static float _bootDoneAt; private static readonly List<GameObject> _npcs = new List<GameObject>(); private static readonly List<Transform> _npcMarkers = new List<Transform>(); private static readonly List<Transform> _npcArrows = new List<Transform>(); private static readonly List<Transform> _npcCones = new List<Transform>(); private static readonly List<Transform> _npcHeads = new List<Transform>(); private static readonly List<Vector3> _npcPrev = new List<Vector3>(); private static readonly List<float> _npcPrevT = new List<float>(); private static readonly List<AIBrain> _npcBrains = new List<AIBrain>(); private static readonly List<Transform> _npcSkulls = new List<Transform>(); private static readonly List<bool> _npcIsPlayer = new List<bool>(); private static float _nextNpcScan; private static readonly List<GameObject> _lootObjs = new List<GameObject>(); private static readonly List<Transform> _lootMarkers = new List<Transform>(); private static readonly List<Material> _lootMats = new List<Material>(); private static float _nextLootScan; private static GameObject _nvgGroup; private static MeshFilter _nvgStatusF; private static int _nvgStatusOn = -1; private static MeshFilter _nvgPctF; private static int _nvgPctShown = -1; private static Mesh _nvgBarsMesh; private static Color[] _nvgBarColors; private static float _nvgBlinkT; private static bool _nvgBlinkOn; private static float _nvgPct = 100f; private static float _nvgTickT; private static float _nvgCooldownUntil; private static bool _nvgRecharging; private static float _nvgRechargeAt; private static bool _nvgOn; private const string FontOrder = "0123456789[] ,-+"; private static readonly string[][] FontRows = new string[16][] { new string[7] { "01110", "10001", "10011", "10101", "11001", "10001", "01110" }, new string[7] { "00100", "01100", "00100", "00100", "00100", "00100", "01110" }, new string[7] { "01110", "10001", "00001", "00010", "00100", "01000", "11111" }, new string[7] { "11111", "00010", "00100", "00010", "00001", "10001", "01110" }, new string[7] { "00010", "00110", "01010", "10010", "11111", "00010", "00010" }, new string[7] { "11111", "10000", "11110", "00001", "00001", "10001", "01110" }, new string[7] { "00110", "01000", "10000", "11110", "10001", "10001", "01110" }, new string[7] { "11111", "00001", "00010", "00100", "01000", "01000", "01000" }, new string[7] { "01110", "10001", "10001", "01110", "10001", "10001", "01110" }, new string[7] { "01110", "10001", "10001", "01111", "00001", "00010", "01100" }, new string[7] { "00110", "00100", "00100", "00100", "00100", "00100", "00110" }, new string[7] { "01100", "00100", "00100", "00100", "00100", "00100", "01100" }, new string[7] { "00000", "00000", "00000", "00000", "00000", "00000", "00000" }, new string[7] { "00000", "00000", "00000", "00000", "00100", "00100", "01000" }, new string[7] { "00000", "00000", "00000", "11111", "00000", "00000", "00000" }, new string[7] { "00000", "00100", "00100", "11111", "00100", "00100", "00000" } }; internal const string BootOrder = "ABCDEFGHIKLMNOPRSTUVWXY0123456789[]-/>:%!,._ ╔═╗║╚╝"; internal static readonly string[][] BootRows = new string[51][] { new string[7] { "00100", "01010", "10001", "11111", "10001", "10001", "10001" }, new string[7] { "11110", "10001", "10001", "11110", "10001", "10001", "11110" }, new string[7] { "01111", "10000", "10000", "10000", "10000", "10000", "01111" }, new string[7] { "11110", "10001", "10001", "10001", "10001", "10001", "11110" }, new string[7] { "11111", "10000", "10000", "11110", "10000", "10000", "11111" }, new string[7] { "11111", "10000", "10000", "11110", "10000", "10000", "10000" }, new string[7] { "01111", "10000", "10000", "10111", "10001", "10001", "01111" }, new string[7] { "10001", "10001", "10001", "11111", "10001", "10001", "10001" }, new string[7] { "11111", "00100", "00100", "00100", "00100", "00100", "11111" }, new string[7] { "10001", "10010", "10100", "11000", "10100", "10010", "10001" }, new string[7] { "10000", "10000", "10000", "10000", "10000", "10000", "11111" }, new string[7] { "10001", "11011", "10101", "10101", "10001", "10001", "10001" }, new string[7] { "10001", "11001", "10101", "10011", "10001", "10001", "10001" }, new string[7] { "01110", "10001", "10001", "10001", "10001", "10001", "01110" }, new string[7] { "11110", "10001", "10001", "11110", "10000", "10000", "10000" }, new string[7] { "11110", "10001", "10001", "11110", "10100", "10010", "10001" }, new string[7] { "01111", "10000", "10000", "01110", "00001", "00001", "11110" }, new string[7] { "11111", "00100", "00100", "00100", "00100", "00100", "00100" }, new string[7] { "10001", "10001", "10001", "10001", "10001", "10001", "01110" }, new string[7] { "10001", "10001", "10001", "10001", "10001", "01010", "00100" }, new string[7] { "10001", "10001", "10001", "10101", "10101", "11011", "10001" }, new string[7] { "10001", "10001", "01010", "00100", "01010", "10001", "10001" }, new string[7] { "10001", "10001", "01010", "00100", "00100", "00100", "00100" }, new string[7] { "01110", "10001", "10001", "10001", "10001", "10001", "01110" }, new string[7] { "00100", "01100", "00100", "00100", "00100", "00100", "11111" }, new string[7] { "01110", "10001", "00001", "00110", "01000", "10000", "11111" }, new string[7] { "01110", "10001", "00001", "00110", "00001", "10001", "01110" }, new string[7] { "00010", "00110", "01010", "10010", "11111", "00010", "00010" }, new string[7] { "11111", "10000", "11110", "00001", "00001", "10001", "01110" }, new string[7] { "01110", "10000", "10000", "11110", "10001", "10001", "01110" }, new string[7] { "11111", "00001", "00010", "00100", "00100", "01000", "01000" }, new string[7] { "01110", "10001", "10001", "01110", "10001", "10001", "01110" }, new string[7] { "01110", "10001", "10001", "01111", "00001", "00001", "01110" }, new string[7] { "01110", "01000", "01000", "01000", "01000", "01000", "01110" }, new string[7] { "01110", "00010", "00010", "00010", "00010", "00010", "01110" }, new string[7] { "00000", "00000", "00000", "11111", "00000", "00000", "00000" }, new string[7] { "00001", "00010", "00010", "00100", "01000", "01000", "10000" }, new string[7] { "10000", "01000", "00100", "00010", "00100", "01000", "10000" }, new string[7] { "00000", "01100", "01100", "00000", "01100", "01100", "00000" }, new string[7] { "11001", "11001", "00010", "00100", "01000", "10011", "10011" }, new string[7] { "00100", "00100", "00100", "00100", "00100", "00000", "00100" }, new string[7] { "00000", "00000", "00000", "00000", "00100", "00100", "01000" }, new string[7] { "00000", "00000", "00000", "00000", "00000", "01100", "01100" }, new string[7] { "00000", "00000", "00000", "00000", "00000", "00000", "11111" }, new string[7] { "00000", "00000", "00000", "00000", "00000", "00000", "00000" }, new string[7] { "00111", "00100", "00100", "00100", "00100", "00100", "00100" }, new string[7] { "00000", "00000", "11111", "00000", "00000", "00000", "00000" }, new string[7] { "11100", "00100", "00100", "00100", "00100", "00100", "00100" }, new string[7] { "00100", "00100", "00100", "00100", "00100", "00100", "00100" }, new string[7] { "00100", "00100", "00100", "00100", "00100", "00100", "00111" }, new string[7] { "00100", "00100", "00100", "00100", "00100", "00100", "11100" } }; private static readonly BootLine[][] BootScripts = new BootLine[7][] { new BootLine[17] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] INITIALIZING...", 0), new BootLine("[ OK ] MEMORY BANKS SYNCED", 0), new BootLine("[ OK ] SENSOR ARRAY READY", 0), new BootLine("[ OK ] ENVIRO FILTERS...", 0), new BootLine("[ OK ] AIR: ACCEPTABLE", 0), new BootLine("[ OK ] MAPPING TERRAIN...", 0), new BootLine("[ OK ] TERRAIN SCANNED", 0), new BootLine("[WARN] STAY SHARP, SOLDIER", 2), new BootLine("[ ??? ] TARGET SIGNATURE", 3), new BootLine("[ OK ] SIGNATURE ADDED", 0), new BootLine("[INFO] MOTION TRACKER...", 0), new BootLine("[ OK ] TRACKER ONLINE", 4), new BootLine("", 0), new BootLine("> SYSTEM READY", 0), new BootLine("> LETS GET TO WORK", 0) }, new BootLine[17] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] POWERING FIELD HUD", 0), new BootLine("[ OK ] MEMORY BANKS SYNCED", 0), new BootLine("[ OK ] SENSORS RESPONDING", 0), new BootLine("[ OK ] SUIT INTEGRITY OK", 0), new BootLine("[ OK ] ARMOR: STABLE", 0), new BootLine("[ OK ] SCANNING TERRAIN", 0), new BootLine("[ OK ] MAP DATA RECEIVED", 0), new BootLine("[WARN] STAY SHARP, SOLDIER", 0), new BootLine("[ ??? ] SEARCHING HOSTILES", 3), new BootLine("[ OK ] TARGET SIGNATURE", 0), new BootLine("[INFO] MOTION TRACKER...", 5), new BootLine("[ OK ] TRACKER ONLINE", 4), new BootLine("", 0), new BootLine("> SYSTEM READY", 0), new BootLine("> CLEARED TO MOVE", 0) }, new BootLine[16] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] EXPLORATION MODE", 0), new BootLine("[ OK ] NAV MODULE ONLINE", 0), new BootLine("[ OK ] SENSORS ACTIVE", 5), new BootLine("[ OK ] CHECKING AIR...", 0), new BootLine("[ OK ] AIR: BREATHABLE", 0), new BootLine("[ OK ] MAPPING AREA...", 0), new BootLine("[ OK ] TERRAIN SCANNED", 0), new BootLine("[WARN] UNCHARTED REGION", 0), new BootLine("[ ??? ] UNKNOWN STRUCTURES", 3), new BootLine("[INFO] NO MATCHING RECORDS", 2), new BootLine("[ OK ] LOCATIONS MAPPED", 4), new BootLine("", 0), new BootLine("> SYSTEM READY", 0), new BootLine("> WATCH YOUR STEP", 0) }, new BootLine[14] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] COMMS UPLINK...", 0), new BootLine("[ OK ] ENCRYPTION: SECURE", 0), new BootLine("[ OK ] SATELLITE LOCK", 5), new BootLine("[ ] SYNCING NAV GRID", 0), new BootLine("[ OK ] NAV GRID: SYNCED", 0), new BootLine("[WARN] JAMMING DETECTED", 2), new BootLine("[ ??? ] TRACING SIGNAL...", 3), new BootLine("[INFO] SIGNAL: LOCAL", 0), new BootLine("[ OK ] COMMS: GREEN", 4), new BootLine("", 0), new BootLine("> UPLINK STABLE", 0), new BootLine("> KEEP YOUR HEAD DOWN", 0) }, new BootLine[14] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] ARMORY CHECK...", 0), new BootLine("[ OK ] MAGAZINES: LOADED", 0), new BootLine("[ OK ] AMMO SUPPLY: FULL", 0), new BootLine("[ OK ] WEAPON RACKS LOCKED", 0), new BootLine("[WARN] UNACCOUNTED ROUNDS", 2), new BootLine("[ ??? ] TRACKING SERIAL...", 3), new BootLine("[ OK ] SERIAL: REGISTERED", 0), new BootLine("[INFO] AUDIT: COMPLETE", 5), new BootLine("[ OK ] ARMORY: SECURE", 4), new BootLine("", 0), new BootLine("> ALL ACCOUNTED FOR", 0), new BootLine("> LOCK AND LOAD", 0) }, new BootLine[14] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] RECON DRONE LINK", 0), new BootLine("[ OK ] DRONE: AIRBORNE", 0), new BootLine("[ OK ] CAMERAS: LIVE", 5), new BootLine("[ OK ] FEED UPLINK: CLEAN", 0), new BootLine("[ ] SCANNING PERIMETER", 0), new BootLine("[WARN] MOTION IN SECTOR 4", 2), new BootLine("[ ??? ] IDENTIFYING TARGET", 3), new BootLine("[INFO] TARGET: UNKNOWN", 2), new BootLine("[ OK ] PERIMETER: HELD", 4), new BootLine("", 0), new BootLine("> RECON COMPLETE", 0), new BootLine("> EYES OPEN, OPERATOR", 0) }, new BootLine[13] { new BootLine("[EXAMWORKS]", 0), new BootLine("", 0), new BootLine("[BOOT] MEDBAY SYSTEMS...", 0), new BootLine("[ OK ] BLOOD TYPE: ON FILE", 0), new BootLine("[ OK ] STIM PACKS: FULL", 0), new BootLine("[ OK ] AUTO-INJECTORS READY", 0), new BootLine("[WARN] LOW MORPHINE STOCK", 2), new BootLine("[ ??? ] VITALS UNKNOWN...", 3), new BootLine("[INFO] MEDBAY: STANDBY", 5), new BootLine("[ OK ] TRAUMA KIT: PACKED", 4), new BootLine("", 0), new BootLine("> MEDICAL READY", 0), new BootLine("> DONT GET SHOT", 0) } }; public static bool SnapshotDone => _job == SnapStage.Idle && _mapReady; public static bool Enabled { get; set; } = true; internal static GameObject Root => _root; public static bool DebugDump { get; set; } = false; public static MapAnchor Anchor { get; set; } = MapAnchor.Wrist; public static bool FogOfWar { get; set; } = false; public static float RadarMetres { get; set; } = 80f; public static bool NvgEnabled { get { return _nvgOn; } set { SetNvg(value); } } public static Nvg.ColorMode NvgColor { get { return Nvg.Mode; } set { Nvg.Mode = value; Nvg.ApplyTint(); } } public static bool MappingActive => (Object)(object)_root != (Object)null && _built && _boot != BootPhase.Off && _boot != BootPhase.Activating; public static void SetNvg(bool value) { if (value == _nvgOn) { return; } if (value && !MappingActive) { BootAudio.Play("error"); } else if (value && (_nvgRecharging || (_nvgCooldownUntil > 0f && Time.unscaledTime < _nvgCooldownUntil))) { BootAudio.Play("error"); } else if (Nvg.SetEnabled(value)) { _nvgOn = value; if (!value) { if (_nvgPct >= 100f) { _nvgCooldownUntil = 0f; _nvgRecharging = false; } else { _nvgCooldownUntil = Time.unscaledTime + 20f; _nvgRecharging = true; _nvgRechargeAt = Time.unscaledTime + 2.5f; } } BootAudio.Play(value ? "power_on" : "off"); } else { BootAudio.Play("error"); } } public static void Init() { if (_hooked) { return; } _hooked = true; try { Hooking.OnLevelLoaded += delegate { ResetForLevel(); }; } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: minimap level hook failed: " + ex.Message); } } } private static void ResetForLevel() { try { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _built = false; if ((Object)(object)_map != (Object)null) { Object.Destroy((Object)(object)_map); } _map = null; _mapReady = false; } catch (Exception ex) { Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: level reset failed: " + ex.Message); } } if (_nvgOn) { Nvg.SetEnabled(value: false); _nvgOn = false; } BootAudio.Reset(); } public static void Update() { if (!Enabled) { Hide(); if (_nvgOn) { Nvg.SetEnabled(value: false); _nvgOn = false; } ClassSelection.SetNvgOption(available: false); } else if (!((Object)(object)LocalPlayer.RigManager == (Object)null) && !((Object)(object)LocalPlayer.Head == (Object)null)) { ClassSelection.SetNvgOption(MappingActive); Nvg.Tick(); RenderMapTick(); EnsureBuilt(); EnsureMap(); if ((Object)(object)_root != (Object)null) { _root.SetActive(true); } Heading(); Fog(); Peek(); Readout(); BootSequence(); NpcMarkers(); LootMarkers(); NvgBar(); } } public static void LateUpdate() { if (Enabled && !((Object)(object)LocalPlayer.RigManager == (Object)null) && !((Object)(object)LocalPlayer.Head == (Object)null)) { EnsureBuilt(); FollowAnchor(); Scale(); } } private static void EnsureBuilt() { //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: 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_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0790: Unknown result type (might be due to invalid IL or missing references) //IL_07b7: Unknown result type (might be due to invalid IL or missing references) //IL_0809: Unknown result type (might be due to invalid IL or missing references) //IL_0844: 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_08b5: Unknown result type (might be due to invalid IL or missing references) //IL_0908: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0938: Unknown result type (might be due to invalid IL or missing references) //IL_0942: Unknown result type (might be due to invalid IL or missing references) //IL_0947: Unknown result type (might be due to invalid IL or missing references) //IL_097d: Unknown result type (might be due to invalid IL or missing references) //IL_09bc: Unknown result type (might be due to invalid IL or missing references) //IL_09e7: Unknown result type (might be due to invalid IL or missing references) //IL_09ec: Unknown result type (might be due to invalid IL or missing references) //IL_09f6: Unknown result type (might be due to invalid IL or missing references) //IL_09fb: Unknown result type (might be due to invalid IL or missing references) if (_built && (Object)(object)_root != (Object)null) { return; } _built = false; if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); _root = null; } _tinted.Clear(); _mapT = null; _ticksT = null; _reliefT = null; _reliefMesh = null; _mapMat = null; _mapMesh = null; _planeBaseUv = null; _planeUv = null; _arrowT = null; _wedgeT = null; _readoutT = null; _readoutMesh = null; _lastReadout = null; _letters = null; _eye = null; _boot = BootPhase.Off; _bootScreenT = null; _bootScreenMat = null; _bootTextT = null; _bootTextMesh = null; _bootTextMat = null; _bootHeaderT = null; _bootHeaderMesh = null; _bootHeaderMat = null; _bootLineT = null; _bootLineMat = null; _bootTextShown = null; _bootVisible = -1; _bootLines = null; _lineTyped = null; _lineNextAt = null; _lineStartAt = null; _bootLinesStarted = 0; _bootSoundAt = 0f; _bootDoneAt = 0f; _npcs.Clear(); _npcMarkers.Clear(); _npcArrows.Clear(); _npcCones.Clear(); _npcHeads.Clear(); _npcPrev.Clear(); _npcPrevT.Clear(); _npcBrains.Clear(); _npcSkulls.Clear(); _npcIsPlayer.Clear(); _lootObjs.Clear(); _lootMarkers.Clear(); _lootMats.Clear(); _job = SnapStage.Idle; _jobCoarse = null; _jobCamGo = null; _jobCam = null; _jobRt = null; _nvgGroup = null; _nvgStatusF = null; _nvgStatusOn = -1; _nvgPctF = null; _nvgPctShown = -1; _nvgBarsMesh = null; _nvgBarColors = null; _nvgBlinkOn = false; _nvgPct = 100f; _nvgCooldownUntil = 0f; _nvgRecharging = false; _built = true; try { _root = new GameObject("[Examination] Minimap"); ((Object)_root).hideFlags = (HideFlags)61; Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Transparent"); } if ((Object)(object)val == (Object)null) { _built = false; return; } _mapT = AddMesh(_root.transform, "MapPlane", val, out _mapMat); _mapMat.renderQueue = 3001; _tinted.Add(_mapMat); _mapMesh = ((Component)_mapT).GetComponent<MeshFilter>().mesh; Vector3[] array = (Vector3[])(object)new Vector3[49]; Vector2[] array2 = (Vector2[])(object)new Vector2[49]; int[] array3 = new int[144]; array[0] = Vector3.zero; array2[0] = new Vector2(0.5f, 0.5f); for (int i = 1; i <= 48; i++) { float num = (float)(i - 1) / 48f * (float)Math.PI * 2f; array[i] = new Vector3(Mathf.Sin(num) * 150f, Mathf.Cos(num) * 150f, 0f); array2[i] = new Vector2(0.5f - Mathf.Sin(num) * 0.5f, 0.5f - Mathf.Cos(num) * 0.5f); int num2 = (i - 1) * 3; int num3 = i % 48 + 1; array3[num2] = 0; array3[num2 + 1] = i; array3[num2 + 2] = num3; } _planeBaseUv = array2; _planeUv = (Vector2[])(object)new Vector2[array2.Length]; for (int j = 0; j < array2.Length; j++) { _planeUv[j] = array2[j]; } _mapMesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(array); _mapMesh.uv = Il2CppStructArray<Vector2>.op_Implicit(array2); Color[] array4 = (Color[])(object)new Color[array.Length]; for (int k = 0; k < array.Length; k++) { array4[k] = Color.white; } _mapMesh.colors = Il2CppStructArray<Color>.op_Implicit(array4); _mapMesh.triangles = Il2CppStructArray<int>.op_Implicit(array3); _mapMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 1000f); _reliefT = AddMesh(_root.transform, "Relief", val, out var material); material.renderQueue = 3001; _tinted.Add(material); _reliefMesh = ((Component)_reliefT).GetComponent<MeshFilter>().mesh; _reliefT.localPosition = Vector3.zero; ((Component)_reliefT).gameObject.SetActive(false); Material material2; Transform val2 = AddMesh(_root.transform, "Vignette", val, out material2); material2.renderQueue = 3002; _tinted.Add(material2); ((Component)val2).GetComponent<MeshFilter>().mesh = VignetteMesh(); _ticksT = AddMesh(_root.transform, "Ticks", val, out var material3); material3.renderQueue = 3010; _tinted.Add(material3); ((Component)_ticksT).GetComponent<MeshFilter>().mesh = TickMesh(); Material material4; Transform val3 = AddMesh(_root.transform, "Letters", val, out material4); material4.renderQueue = 3010; _tinted.Add(material4); material4.mainTexture = (Texture)(object)LetterAtlas(); _letters = ((Component)val3).GetComponent<MeshFilter>().mesh; BuildLetterQuads(); _readoutT = AddMesh(_root.transform, "Readout", val, out var material5); material5.renderQueue = 3010; _tinted.Add(material5); material5.mainTexture = (Texture)(object)BuildFontAtlas("0123456789[] ,-+", FontRows, 48, 0.85f, 0f); _readoutMesh = ((Component)_readoutT).GetComponent<MeshFilter>().mesh; _readoutT.localPosition = new Vector3(0f, -174f, -0.003f); BuildReadout("[+0, +0, 0]"); _arrowT = AddMesh(_root.transform, "Arrow", val, out var material6); material6.renderQueue = 3012; _tinted.Add(material6); ((Component)_arrowT).GetComponent<MeshFilter>().mesh = ArrowMesh(); _wedgeT = AddMesh(_root.transform, "Wedge", val, out var material7); material7.renderQueue = 3012; _tinted.Add(material7); _wedgeT.SetParent(_arrowT, false); _wedgeT.localPosition = Vector3.zero; ((Component)_wedgeT).GetComponent<MeshFilter>().mesh = WedgeMesh(); _bootScreenT = AddMesh(_root.transform, "BootScreen", val, out var material8); _bootScreenT.localPosition = new Vector3(0f, 0f, -0.006f); material8.renderQueue = 3020; material8.mainTexture = (Texture)(object)BootBackdrop(); material8.color = Color.white; _bootScreenMat = material8; ((Component)_bootScreenT).GetComponent<MeshFilter>().mesh = BootDiscMesh(); _bootLineT = AddMesh(_bootScreenT, "BootLine", val, out var material9); _bootLineT.localPosition = new Vector3(0f, 0f, -0.0015f); material9.renderQueue = 3025; material9.mainTexture = (Texture)(object)Texture2D.whiteTexture; material9.color = new Color(1f, 1f, 1f, 0f); _bootLineMat = material9; ((Component)_bootLineT).GetComponent<MeshFilter>().mesh = BootLineMesh(); _bootLineT.localScale = new Vector3(0.02f, 0.02f, 1f); _bootTextT = AddMesh(_bootScreenT, "BootText", val, out var material10); _bootTextT.localPosition = new Vector3(0f, 0f, -0.0025f); material10.renderQueue = 3025; material10.mainTexture = (Texture)(object)BuildFontAtlas("ABCDEFGHIKLMNOPRSTUVWXY0123456789[]-/>:%!,._ ╔═╗║╚╝", BootRows, 64, 2.4f, 1.05f, invert: true); material10.color = new Color(1f, 1f, 1f, 1f); _bootTextMat = material10; _bootTextMesh = ((Component)_bootTextT).GetComponent<MeshFilter>().mesh; _bootTextMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 1000f); _bootHeaderT = AddMesh(_bootScreenT, "BootHeader", val, out var material11); _bootHeaderT.localPosition = new Vector3(0f, 62f, -0.0025f); material11.renderQueue = 3025; material11.mainTexture = (Texture)(object)BuildFontAtlas("ABCDEFGHIKLMNOPRSTUVWXY0123456789[]-/>:%!,._ ╔═╗║╚╝", BootRows, 64, 2.6f, 1.05f, invert: true); material11.color = Color.white; _bootHeaderMat = material11; _bootHeaderMesh = ((Component)_bootHeaderT).GetComponent<MeshFilter>().mesh; _bootHeaderMesh.bounds = new Bounds(Vector3.zero, Vector3.one * 1000f); StartTyping(new BootLine("MAPPING DISABLED.", 0)); BuildNvg(); _explored = new byte[262144]; _snap = new byte[786432]; _walkable = new byte[262144]; _radial = new float[262144]; } catch (Exception ex) { _built = false; Main instance = Main.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: minimap build failed: " + ex); } } } private static Transform AddMesh(Transform parent, string name, Shader shader, out Material material) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0055: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown GameObject val = new GameObject(name); ((Object)val).hideFlags = (HideFlags)61; val.transform.SetParent(parent, false); MeshFilter val2 = val.AddComponent<MeshFilter>(); MeshRenderer val3 = val.AddComponent<MeshRenderer>(); ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; Mesh val4 = new Mesh(); ((Object)val4).name = name; ((Object)val4).hideFlags = (HideFlags)61; val4.bounds = new Bounds(Vector3.zero, Vector3.one * 1000f); val2.mesh = val4; material = new Material(shader); ((Object)material).hideFlags = (HideFlags)61; ((Renderer)val3).material = material; return val.transform; } private static Mesh VignetteMesh() { //IL_007c: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_0124: 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_0133: 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) List<Vector3> verts = new List<Vector3>(); List<Color> colors = new List<Color>(); List<int> tris = new List<int>(); for (int i = 0; i < 8; i++) { float num = (float)i / 8f; float num2 = (float)(i + 1) / 8f; float r = 93f + 57f * num; float r2 = 93f + 57f * num2; Band(r, r2, new Color(0f, 0f, 0f, (num + num2) * 0.5f)); } Band(148.5f, 149.6f, new Color(0.22f, 0.22f, 0.22f, 0.55f)); Mesh val = new Mesh(); ((Object)val).name = "MinimapVignette"; ((Object)val).hideFlags = (HideFlags)61; val.vertices = Il2CppStructArray<Vector3>.op_Implicit(verts.ToArray()); val.colors = Il2CppStructArray<Color>.op_Implicit(colors.ToArray()); val.triangles = Il2CppStructArray<int>.op_Implicit(tris.ToArray()); val.bounds = new Bounds(Vector3.zero, Vector3.one * 1000f); return val; void Band(float num4, float num5, Color color) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0089: Unknown result type (might be due to invalid IL or missing references) int count = verts.Count; for (int j = 0; j <= 48; j++) { float num3 = (float)j / 48f * (float)Math.PI * 2f; verts.Add(new Vector3(Mathf.Sin(num3) * num4, Mathf.Cos(num3) * num4, 0f)); verts.Add(new Vector3(Mathf.Sin(num3) * num5, Mathf.Cos(num3) * num5, 0f)); colors.Add(color); colors.Add(color); } for (int k = 0; k < 48; k++) { int num6 = count + k * 2; tris.Add(num6); tris.Add(num6 + 2); tris.Add(num6 + 1); tris.Add(num6 + 2); tris.Add(num6 + 3); tris.Add(num6 + 1); } } } private static Mesh TickMesh() { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: 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_0231: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a3: Unknown result type (might be due to invalid IL or m
Mods\ExaminationFusion.dll
Decompiled 20 minutes agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Examination; using Il2CppSLZ.Marrow; using LabFusion.Entities; using LabFusion.Network; using LabFusion.Network.Serialization; using LabFusion.Player; using LabFusion.SDK.Modules; using MelonLoader; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(FusionMain), "ExaminationFusion", "1.0.0", "EXAMWORKS", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyVersion("0.0.0.0")] namespace Examination; public class FusionMain : MelonMod { public static FusionMain Instance { get; private set; } public override void OnInitializeMelon() { Instance = this; FusionSync.Init(); ((MelonBase)this).LoggerInstance.Msg("ExaminationFusion ready (LabFusion team/class sync)."); } } public static class FusionSync { private struct RemoteInfo { public int Faction; public string ClassId; public string MedicalState; public string Vitals; } private static readonly Dictionary<byte, RemoteInfo> _players = new Dictionary<byte, RemoteInfo>(); private static float _nextBroadcast; private static bool _initialized; private static readonly List<string> _tocQueue = new List<string>(); private static readonly object _tocLock = new object(); private static readonly List<string> _ostQueue = new List<string>(); private static readonly List<string> _medicalQueue = new List<string>(); private static MethodInfo _tryGetPlayer; private static PropertyInfo _rigRefsProp; private static PropertyInfo _rigManagerProp; private static PropertyInfo _hasRigProp; private static PropertyInfo _usernameProp; public static void Init() { if (_initialized) { return; } _initialized = true; try { ModuleManager.LoadModules(Assembly.GetExecutingAssembly()); } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion module load failed: " + ex.Message); } } } public static void Tick(int faction, string classId, string medicalState, string vitals) { try { if (NetworkInfo.HasServer && Time.unscaledTime >= _nextBroadcast) { _nextBroadcast = Time.unscaledTime + 0.5f; BroadcastLocal(faction, classId, medicalState, vitals); } } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion sync tick failed: " + ex.Message); } } } public static int FactionOf(GameObject rig) { if ((Object)(object)rig == (Object)null) { return 0; } try { if (!NetworkInfo.HasServer) { return 0; } } catch { return 0; } return FactionOfInternal(rig); } public static string ClassOf(GameObject rig) { if ((Object)(object)rig == (Object)null) { return null; } try { if (!NetworkInfo.HasServer) { return null; } } catch { return null; } return ClassOfInternal(rig); } private static void BroadcastLocal(int faction, string classId, string medicalState, string vitals) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) try { ExamPlayerInfoData examPlayerInfoData = new ExamPlayerInfoData { PlayerId = PlayerIDManager.LocalSmallID, Faction = (byte)faction, ClassId = (classId ?? ""), MedicalState = (medicalState ?? ""), Vitals = (vitals ?? "") }; MessageRelay.RelayModule<ExamPlayerInfoMessage, ExamPlayerInfoData>(examPlayerInfoData, CommonMessageRoutes.ReliableToServer); } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion broadcast failed: " + ex.Message); } } } public static void ApplyRemote(byte smallId, int faction, string classId, string medicalState, string vitals) { _players[smallId] = new RemoteInfo { Faction = faction, ClassId = (classId ?? ""), MedicalState = (medicalState ?? ""), Vitals = (vitals ?? "") }; } public static string MedicalStateOf(GameObject rig) { if ((Object)(object)rig == (Object)null) { return ""; } try { if (!NetworkInfo.HasServer) { return ""; } } catch { return ""; } foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)rig) { return player.Value.MedicalState; } } return ""; } public static string VitalsOf(GameObject rig) { if ((Object)(object)rig == (Object)null) { return ""; } try { if (!NetworkInfo.HasServer) { return ""; } } catch { return ""; } foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)rig) { return player.Value.Vitals; } } return ""; } public static string PlayerNameOf(GameObject rig) { if ((Object)(object)rig == (Object)null) { return null; } try { if (!NetworkInfo.HasServer) { return null; } } catch { return null; } foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)rig) { return PlayerNameOfSmall(player.Key); } } return null; } private static string PlayerNameOfSmall(byte smallId) { try { if (!TryGetRig(smallId, out var _)) { return null; } object[] array = new object[2] { smallId, null }; if (!(bool)_tryGetPlayer.Invoke(null, array) || array[1] == null) { return null; } if (_usernameProp == null) { _usernameProp = array[1].GetType().GetProperty("Username"); } object obj = ((_usernameProp != null) ? _usernameProp.GetValue(array[1]) : null); string text = obj as string; return string.IsNullOrEmpty(text) ? null : text; } catch { return null; } } public static string RigPlatformIdOf(GameObject rig) { if ((Object)(object)rig == (Object)null) { return null; } try { if (!NetworkInfo.HasServer) { return null; } } catch { return null; } foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)rig) { try { PlayerID playerID = PlayerIDManager.GetPlayerID(player.Key); return (playerID != null) ? playerID.PlatformID : null; } catch { return null; } } } return null; } public static bool TryGetRigOfPlatform(string platformId, out GameObject rig) { rig = null; if (string.IsNullOrEmpty(platformId)) { return false; } try { if (!NetworkInfo.HasServer) { return false; } } catch { return false; } foreach (KeyValuePair<byte, RemoteInfo> player in _players) { try { PlayerID playerID = PlayerIDManager.GetPlayerID(player.Key); if (playerID != null && playerID.PlatformID == platformId && TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null) { rig = ((Component)rigManager).gameObject; return true; } } catch { } } return false; } public static string LocalPlatformId() { try { return PlayerIDManager.LocalPlatformID ?? ""; } catch { return ""; } } public static bool BroadcastToc(string text, string voiceName) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkInfo.HasServer) { return false; } ExamTocData examTocData = new ExamTocData { SenderId = LocalPlatformId(), VoiceName = (voiceName ?? ""), Text = (text ?? "") }; MessageRelay.RelayModule<ExamTocMessage, ExamTocData>(examTocData, CommonMessageRoutes.ReliableToServer); return true; } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: TOC broadcast failed: " + ex.Message); } return false; } } public static string PollToc() { lock (_tocLock) { if (_tocQueue.Count == 0) { return null; } string result = string.Join("\u0001", _tocQueue); _tocQueue.Clear(); return result; } } public static void ApplyTocRemote(string senderId, string voiceName, string text) { lock (_tocLock) { while (_tocQueue.Count >= 16) { _tocQueue.RemoveAt(0); } _tocQueue.Add(senderId + "\u0002" + voiceName + "\u0002" + text); } } public static bool BroadcastOst(string name) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkInfo.HasServer) { return false; } ExamOstData examOstData = new ExamOstData { SenderId = LocalPlatformId(), Name = (name ?? "") }; MessageRelay.RelayModule<ExamOstMessage, ExamOstData>(examOstData, CommonMessageRoutes.ReliableToServer); return true; } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: OST broadcast failed: " + ex.Message); } return false; } } public static string PollOst() { lock (_tocLock) { if (_ostQueue.Count == 0) { return null; } string result = string.Join("\u0001", _ostQueue); _ostQueue.Clear(); return result; } } public static void ApplyOstRemote(string senderId, string name) { lock (_tocLock) { while (_ostQueue.Count >= 16) { _ostQueue.RemoveAt(0); } _ostQueue.Add(senderId + "\u0002" + name); } } public static bool BroadcastMedical(string treatment, string region, GameObject targetRig) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) try { if (!NetworkInfo.HasServer) { return false; } string targetId = ""; if ((Object)(object)targetRig != (Object)null) { foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)targetRig) { PlayerID playerID = PlayerIDManager.GetPlayerID(player.Key); targetId = ((playerID != null) ? playerID.PlatformID : null) ?? ""; break; } } } ExamMedicalData examMedicalData = new ExamMedicalData { CaregiverId = LocalPlatformId(), TargetId = targetId, Treatment = (treatment ?? ""), Region = (region ?? "") }; MessageRelay.RelayModule<ExamMedicalMessage, ExamMedicalData>(examMedicalData, CommonMessageRoutes.ReliableToServer); return true; } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: medical broadcast failed: " + ex.Message); } return false; } } public static string PollMedical() { lock (_tocLock) { if (_medicalQueue.Count == 0) { return null; } string result = string.Join("\u0001", _medicalQueue); _medicalQueue.Clear(); return result; } } public static void ApplyMedicalRemote(string caregiverId, string targetId, string treatment, string region) { lock (_tocLock) { while (_medicalQueue.Count >= 16) { _medicalQueue.RemoveAt(0); } _medicalQueue.Add(caregiverId + "\u0002" + targetId + "\u0002" + treatment + "\u0002" + region); } } public static bool SpawnNetworked(string barcode, Vector3 position, Quaternion rotation) { //IL_015a: 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) try { PropertyInfo propertyInfo = typeof(NetworkInfo).Assembly.GetType("LabFusion.Scene.NetworkSceneManager")?.GetProperty("IsLevelNetworked", BindingFlags.Static | BindingFlags.Public); if (propertyInfo == null || !(bool)propertyInfo.GetValue(null)) { return false; } Assembly assembly = typeof(NetworkInfo).Assembly; object obj = (assembly.GetType("LabFusion.Marrow.Pool.LocalAssetSpawner")?.GetMethod("CreateSpawnable", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(string) }, null))?.Invoke(null, new object[1] { barcode }); if (obj == null) { return false; } Type type = assembly.GetType("LabFusion.RPC.NetworkAssetSpawner"); Type type2 = type?.GetNestedType("SpawnRequestInfo", BindingFlags.Public); MethodInfo methodInfo = type?.GetMethod("Spawn", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { type2 }, null); if (type2 == null || methodInfo == null) { return false; } object obj2 = Activator.CreateInstance(type2); SetField(obj2, "Spawnable", obj); SetField(obj2, "Position", position); SetField(obj2, "Rotation", rotation); SetField(obj2, "SpawnEffect", true); FieldInfo field = type2.GetField("SpawnSource", BindingFlags.Instance | BindingFlags.Public); if (field != null && field.FieldType.IsEnum && Enum.IsDefined(field.FieldType, "Player")) { field.SetValue(obj2, Enum.Parse(field.FieldType, "Player")); } methodInfo.Invoke(null, new object[1] { obj2 }); return true; } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: networked spawn failed: " + ex.Message); } return false; } } public static bool IsPlayerRig(GameObject rig) { if ((Object)(object)rig == (Object)null) { return false; } try { if (!NetworkInfo.HasServer) { return false; } RigManager val = rig.GetComponentInParent<RigManager>(); if ((Object)(object)val == (Object)null) { val = rig.GetComponentInChildren<RigManager>(true); } return (Object)(object)val != (Object)null && NetworkPlayerManager.HasPlayer(val); } catch { return false; } } private static void SetField(object instance, string name, object value) { FieldInfo field = instance.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public); if (field != null) { field.SetValue(instance, value); } } private static int FactionOfInternal(GameObject rig) { foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)rig) { return player.Value.Faction; } } return 0; } private static string ClassOfInternal(GameObject rig) { foreach (KeyValuePair<byte, RemoteInfo> player in _players) { if (TryGetRig(player.Key, out var rigManager) && (Object)(object)rigManager != (Object)null && (Object)(object)((Component)rigManager).gameObject == (Object)(object)rig) { return string.IsNullOrEmpty(player.Value.ClassId) ? null : player.Value.ClassId; } } return null; } private static bool TryGetRig(byte smallId, out RigManager rigManager) { //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown rigManager = null; try { if (_tryGetPlayer == null) { MethodInfo[] methods = typeof(NetworkPlayerManager).GetMethods(); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name != "TryGetPlayer") { continue; } ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length != 2) { continue; } try { if (parameters[0].ParameterType == typeof(byte)) { _tryGetPlayer = methodInfo; break; } } catch { } } } if (_tryGetPlayer == null) { return false; } object[] array = new object[2] { smallId, null }; if (!(bool)_tryGetPlayer.Invoke(null, array) || array[1] == null) { return false; } object obj2 = array[1]; Type type = obj2.GetType(); if (_hasRigProp == null) { _hasRigProp = type.GetProperty("HasRig"); _rigRefsProp = type.GetProperty("RigRefs"); } if (_hasRigProp != null && !(bool)_hasRigProp.GetValue(obj2)) { return false; } object obj3 = ((_rigRefsProp != null) ? _rigRefsProp.GetValue(obj2) : null); if (obj3 == null) { return false; } if (_rigManagerProp == null) { _rigManagerProp = obj3.GetType().GetProperty("RigManager"); } object obj4 = ((_rigManagerProp != null) ? _rigManagerProp.GetValue(obj3) : null); if (obj4 == null) { return false; } rigManager = (RigManager)obj4; return true; } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion rig lookup failed: " + ex.Message); } } return false; } } public class ExamPlayerInfoData : INetSerializable { public byte PlayerId; public byte Faction; public string ClassId; public string MedicalState; public string Vitals; public int? GetSize() { return null; } public void Serialize(INetSerializer serializer) { serializer.SerializeValue(ref PlayerId); serializer.SerializeValue(ref Faction); serializer.SerializeValue(ref ClassId); serializer.SerializeValue(ref MedicalState); serializer.SerializeValue(ref Vitals); } } public class ExamTocData : INetSerializable { public string SenderId; public string VoiceName; public string Text; public int? GetSize() { return null; } public void Serialize(INetSerializer serializer) { serializer.SerializeValue(ref SenderId); serializer.SerializeValue(ref VoiceName); serializer.SerializeValue(ref Text); } } public class ExamTocMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ExamTocData examTocData = ((ReceivedMessage)(ref received)).ReadData<ExamTocData>(); if (NetworkInfo.IsHost) { try { MessageRelay.RelayModule<ExamTocMessage, ExamTocData>(examTocData, CommonMessageRoutes.ReliableToOtherClients); } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: TOC relay failed: " + ex.Message); } } } FusionSync.ApplyTocRemote(examTocData.SenderId, examTocData.VoiceName, examTocData.Text); } } public class ExamPlayerInfoMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ExamPlayerInfoData examPlayerInfoData = ((ReceivedMessage)(ref received)).ReadData<ExamPlayerInfoData>(); if (NetworkInfo.IsHost) { try { MessageRelay.RelayModule<ExamPlayerInfoMessage, ExamPlayerInfoData>(examPlayerInfoData, CommonMessageRoutes.ReliableToOtherClients); } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: fusion relay failed: " + ex.Message); } } } FusionSync.ApplyRemote(examPlayerInfoData.PlayerId, examPlayerInfoData.Faction, examPlayerInfoData.ClassId, examPlayerInfoData.MedicalState, examPlayerInfoData.Vitals); } } public class ExamMedicalData : INetSerializable { public string CaregiverId; public string TargetId; public string Treatment; public string Region; public int? GetSize() { return null; } public void Serialize(INetSerializer serializer) { serializer.SerializeValue(ref CaregiverId); serializer.SerializeValue(ref TargetId); serializer.SerializeValue(ref Treatment); serializer.SerializeValue(ref Region); } } public class ExamMedicalMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ExamMedicalData examMedicalData = ((ReceivedMessage)(ref received)).ReadData<ExamMedicalData>(); if (NetworkInfo.IsHost) { try { MessageRelay.RelayModule<ExamMedicalMessage, ExamMedicalData>(examMedicalData, CommonMessageRoutes.ReliableToOtherClients); } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: medical relay failed: " + ex.Message); } } } FusionSync.ApplyMedicalRemote(examMedicalData.CaregiverId, examMedicalData.TargetId, examMedicalData.Treatment, examMedicalData.Region); } } public class ExamOstData : INetSerializable { public string SenderId; public string Name; public int? GetSize() { return null; } public void Serialize(INetSerializer serializer) { serializer.SerializeValue(ref SenderId); serializer.SerializeValue(ref Name); } } public class ExamOstMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ExamOstData examOstData = ((ReceivedMessage)(ref received)).ReadData<ExamOstData>(); if (NetworkInfo.IsHost) { try { MessageRelay.RelayModule<ExamOstMessage, ExamOstData>(examOstData, CommonMessageRoutes.ReliableToOtherClients); } catch (Exception ex) { FusionMain instance = FusionMain.Instance; if (instance != null) { ((MelonBase)instance).LoggerInstance.Warning("Examination: OST relay failed: " + ex.Message); } } } FusionSync.ApplyOstRemote(examOstData.SenderId, examOstData.Name); } } public class ExaminationFusionModule : Module { public override string Name => "Examination"; public override string Author => "EXAMWORKS"; public override Version Version => new Version(1, 0, 0); public override ConsoleColor Color => ConsoleColor.Magenta; protected override void OnModuleRegistered() { try { ModuleMessageManager.LoadHandlers(Assembly.GetExecutingAssembly()); ModuleLogger loggerInstance = ((Module)this).LoggerInstance; if (loggerInstance != null) { loggerInstance.Log("Examination team sync online.", ConsoleColor.White); } } catch (Exception ex) { ModuleLogger loggerInstance2 = ((Module)this).LoggerInstance; if (loggerInstance2 != null) { loggerInstance2.LogException("registering Examination module", ex); } } } protected override void OnModuleUnregistered() { } }