Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalReplay v0.4.3
BepInEx/plugins/LethalReplay/LethalReplay.dll
Decompiled an hour 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.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dissonance; using Dissonance.Audio.Capture; using Dissonance.Audio.Playback; using DunGen; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using LethalReplay.Compat; using LethalReplay.Format; using LethalReplay.Playback; using LethalReplay.Recording; using LethalReplay.UI; using LethalReplay.Util; using Microsoft.CodeAnalysis; using NAudio.Wave; using Steamworks; using TMPro; using Unity.Netcode; using Unity.Netcode.Transports.UTP; using UnityEngine; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalReplay")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("LethalReplay")] [assembly: AssemblyTitle("LethalReplay")] [assembly: AssemblyVersion("0.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LethalReplay { internal static class Patches { [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] private static class LevelReadyPatch { private static void Postfix(RoundManager __instance) { ((MonoBehaviour)__instance).StartCoroutine(Notify()); } private static IEnumerator Notify() { float giveUp = Time.realtimeSinceStartup + 15f; yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance == (Object)null || !StartOfRound.Instance.inShipPhase || Time.realtimeSinceStartup > giveUp)); StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance == (Object)null) && !instance.inShipPhase) { ReplayTheater.Instance?.OnLevelReady(); ReplayRecorder.Instance?.OnLevelReady(); } } } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] private static class ShipLeftPatch { private static void Postfix() { ReplayRecorder.Instance?.OnShipLeft(); } } [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] private static class DisconnectPatch { private static void Prefix() { ReplayRecorder.Instance?.StopRecording("disconnected"); ReplayTheater instance = ReplayTheater.Instance; if ((Object)(object)instance != (Object)null && instance.Busy && instance.State != TheaterState.Leaving) { instance.Exit(); } } } [HarmonyPatch] private static class NoSavingPatch { private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[6] { "SaveGame", "SaveGameValues", "SaveItemsInShip", "SaveLocalPlayerValues", "ResetSavedGameValues", "ConvertUnsellableItemsToCredits" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(typeof(GameNetworkManager), text, (Type[])null, (Type[])null); if (methodInfo != null) { yield return methodInfo; } } MethodInfo methodInfo2 = AccessTools.Method(typeof(StartOfRound), "OnShipLandedMiscEvents", (Type[])null, (Type[])null); if (methodInfo2 != null) { yield return methodInfo2; } } private static bool Prefix() { return !ReplayTheater.ViewerSession; } } [HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")] private static class NoJoinPatch { [HarmonyPriority(800)] private static bool Prefix(ConnectionApprovalRequest request, ConnectionApprovalResponse response) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!ReplayTheater.ViewerSession) { return true; } if ((Object)(object)NetworkManager.Singleton != (Object)null && request.ClientNetworkId == NetworkManager.Singleton.LocalClientId) { return true; } response.Approved = false; response.Pending = false; response.Reason = "This player is watching a replay."; return false; } } [HarmonyPatch] private static class NoSpawnsPatch { private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[6] { "SpawnScrapInLevel", "SpawnEnemiesOutside", "SpawnDaytimeEnemiesOutside", "SpawnEnemyFromVent", "PlotOutEnemiesForNextHour", "BeginEnemySpawning" }; string[] array2 = array; foreach (string text in array2) { MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), text, (Type[])null, (Type[])null); if (methodInfo != null) { yield return methodInfo; } } } private static bool Prefix() { return !TheaterSuppressing; } } [HarmonyPatch(typeof(TimeOfDay), "MoveGlobalTime")] private static class TimePatch { private static bool Prefix() { if ((Object)(object)ReplayTheater.Instance != (Object)null) { return !ReplayTheater.Instance.Playing; } return true; } } [HarmonyPatch(typeof(StartOfRound), "ShipLeaveAutomatically")] private static class NoAutoLeavePatch { private static bool Prefix() { return !TheaterSuppressing; } } [HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")] private static class NoDamagePatch { private static bool Prefix(PlayerControllerB __instance) { if (TheaterSuppressing) { return !IsLocal(__instance); } return true; } } [HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")] private static class NoDeathPatch { private static bool Prefix(PlayerControllerB __instance) { if (TheaterSuppressing) { return !IsLocal(__instance); } return true; } } [HarmonyPatch] private static class NoHoldInteractPatch { private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[2] { "ClickHoldInteraction", "SetHoverTipAndCurrentInteractTrigger" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(typeof(PlayerControllerB), text, (Type[])null, (Type[])null); if (methodInfo != null) { yield return methodInfo; } } } private static bool Prefix(PlayerControllerB __instance) { if ((Object)(object)ReplayTheater.Instance != (Object)null && ReplayTheater.Instance.Playing) { return !IsLocal(__instance); } return true; } } [HarmonyPatch] private static class NoPlayerInputPatch { private static IEnumerable<MethodBase> TargetMethods() { return from m in typeof(PlayerControllerB).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.Name.EndsWith("_performed") && m.ReturnType == typeof(void) && !m.IsGenericMethod select m; } private static bool Prefix(PlayerControllerB __instance) { if ((Object)(object)ReplayTheater.Instance != (Object)null && ReplayTheater.Instance.Playing) { return !IsLocal(__instance); } return true; } } private static bool TheaterSuppressing { get { if ((Object)(object)ReplayTheater.Instance != (Object)null) { return ReplayTheater.Instance.SuppressWorld; } return false; } } private static bool IsLocal(PlayerControllerB p) { if ((Object)(object)GameNetworkManager.Instance != (Object)null) { return (Object)(object)p == (Object)(object)GameNetworkManager.Instance.localPlayerController; } return false; } } [BepInPlugin("lethalreplay.replaymod", "LethalReplay", "0.4.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "lethalreplay.replaymod"; public const string Name = "LethalReplay"; public const string Version = "0.4.3"; internal static ManualLogSource Log; internal static Plugin Instance; internal static ConfigEntry<bool> AutoRecord; internal static ConfigEntry<int> TickRate; internal static ConfigEntry<bool> RecordVoice; internal static ConfigEntry<bool> RecordOwnMic; internal static ConfigEntry<bool> RecordMirage; internal static ConfigEntry<bool> RecordSounds; internal static ConfigEntry<int> VoiceSampleRate; internal static ConfigEntry<string> ReplayFolder; internal static ConfigEntry<bool> ShowRecordingIndicator; internal static ConfigEntry<bool> HearDeadPlayers; internal static ConfigEntry<float> NightVision; internal static ConfigEntry<bool> NightVisionOutside; internal static ConfigEntry<bool> ShowNames; internal static ConfigEntry<float> VoiceVolume; internal static ConfigEntry<float> SoundVolume; internal static ConfigEntry<float> CameraSpeed; internal static ConfigEntry<float> MouseSensitivity; internal static ConfigEntry<Key> MenuKey; internal static ConfigEntry<Key> ToggleRecordKey; internal static ConfigEntry<Key> CursorKey; internal static string ReplayDirectory { get { string text = ReplayFolder.Value; if (string.IsNullOrWhiteSpace(text)) { text = Path.Combine(Application.persistentDataPath, "Replays"); } Directory.CreateDirectory(text); return text; } } private void Awake() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Expected O, but got Unknown //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; AutoRecord = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "AutoRecord", true, "Start recording automatically every time the ship lands on a moon."); TickRate = ((BaseUnityPlugin)this).Config.Bind<int>("Recording", "TickRate", 20, new ConfigDescription("Snapshots per second. Higher = smoother replays and bigger files.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 60), Array.Empty<object>())); RecordVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "RecordVoice", true, "Record other players' voice chat (positional, per player)."); RecordOwnMic = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "RecordOwnMic", true, "Also record your own microphone while you are transmitting."); RecordMirage = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "RecordMirage", true, "Record voices played back by Mirage mimics (masked enemies etc.) when Mirage is installed."); RecordSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "RecordSounds", true, "Record sound effects (footsteps, items, doors, enemies, the ship...)."); VoiceSampleRate = ((BaseUnityPlugin)this).Config.Bind<int>("Recording", "VoiceSampleRate", 24000, new ConfigDescription("Sample rate voice is stored at. 16000 is phone quality, 48000 is full quality.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[4] { 16000, 24000, 32000, 48000 }), Array.Empty<object>())); ReplayFolder = ((BaseUnityPlugin)this).Config.Bind<string>("Recording", "ReplayFolder", "", "Folder replays are saved to. Empty = <game save folder>/Replays (shared by all mod profiles)."); ShowRecordingIndicator = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "ShowRecordingIndicator", true, "Show a small REC indicator while recording."); NightVision = ((BaseUnityPlugin)this).Config.Bind<float>("Theater", "NightVisionStrength", 1f, new ConfigDescription("Brightness of the replay camera's night vision. 0 = off, 1 = the game's own, higher = brighter. Change it while watching with [ and ] (N toggles).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); ShowNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Theater", "ShowPlayerNames", true, "Show player names above their heads while watching (toggle with T)."); NightVisionOutside = ((BaseUnityPlugin)this).Config.Bind<bool>("Theater", "NightVisionOutside", false, "Also use night vision outside (the game only uses it indoors). Handy for night-time replays."); HearDeadPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Theater", "HearDeadPlayers", false, "Play the voices of dead (spectating) players during replays."); VoiceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Theater", "VoiceVolume", 1f, new ConfigDescription("Volume of recorded voices.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); SoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Theater", "SoundVolume", 1f, new ConfigDescription("Volume of recorded sound effects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); CameraSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Theater", "CameraSpeed", 8f, "Free camera speed in meters per second (hold Shift for x4, Ctrl for x0.25)."); CursorKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "ShowCursor", (Key)53, "While watching: show the mouse cursor to use the controls (press again to go back to mouse-look)."); MouseSensitivity = ((BaseUnityPlugin)this).Config.Bind<float>("Theater", "MouseSensitivity", 0.12f, "Free camera mouse sensitivity."); MenuKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "ReplayMenu", (Key)101, "Opens the replay browser (main menu) / hides the controls while watching."); ToggleRecordKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keys", "ToggleRecording", (Key)102, "Start / stop recording manually."); new Harmony("lethalreplay.replaymod").PatchAll(typeof(Plugin).Assembly); GameObject val = new GameObject("LethalReplay") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); val.AddComponent<ReplayRecorder>(); val.AddComponent<ReplayTheater>(); val.AddComponent<ReplayUI>(); Log.LogInfo((object)("LethalReplay 0.4.3 loaded. Replays folder: " + ReplayDirectory)); } } } namespace LethalReplay.Util { internal static class Hierarchy { public static string Segment(Transform t) { Transform parent = t.parent; string name = ((Object)t).name; if ((Object)(object)parent == (Object)null) { return name; } int num = 0; int siblingIndex = t.GetSiblingIndex(); for (int i = 0; i < siblingIndex; i++) { if (((Object)parent.GetChild(i)).name == name) { num++; } } if (num != 0) { return name + "#" + num; } return name; } public static string PathOf(Transform root, Transform t) { if ((Object)(object)t == (Object)(object)root) { return ""; } List<string> list = new List<string>(); Transform val = t; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { list.Add(Segment(val)); val = val.parent; } if ((Object)(object)val == (Object)null) { return null; } list.Reverse(); return string.Join("/", list); } public static Dictionary<string, Transform> BuildMap(Transform root) { Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); dictionary[""] = root; Walk(root, "", dictionary); return dictionary; } private static void Walk(Transform t, string prefix, Dictionary<string, Transform> map) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); for (int i = 0; i < t.childCount; i++) { Transform child = t.GetChild(i); dictionary.TryGetValue(((Object)child).name, out var value); dictionary[((Object)child).name] = value + 1; string text = ((value == 0) ? ((Object)child).name : (((Object)child).name + "#" + value)); string text2 = ((prefix.Length == 0) ? text : (prefix + "/" + text)); if (!map.ContainsKey(text2)) { map[text2] = child; } Walk(child, text2, map); } } public static Transform FindDeep(Transform root, string name) { if (((Object)root).name == name) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindDeep(root.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static string CleanName(string name) { if (name == null) { return ""; } return name.Replace("(Clone)", "").Trim(); } public static void SetLayerRecursive(GameObject go, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) go.layer = layer; foreach (Transform item in go.transform) { SetLayerRecursive(((Component)item).gameObject, layer); } } } internal sealed class RefComparer<T> : IEqualityComparer<T> where T : class { public static readonly RefComparer<T> Instance = new RefComparer<T>(); public bool Equals(T x, T y) { return x == y; } public int GetHashCode(T obj) { return RuntimeHelpers.GetHashCode(obj); } } internal static class SceneProps { public struct Prop { public Component Source; public Transform Root; } public static List<Prop> FindAll() { List<Prop> list = new List<Prop>(); MineshaftElevatorController[] array = Object.FindObjectsOfType<MineshaftElevatorController>(); foreach (MineshaftElevatorController val in array) { Add(list, (Component)(object)val, ((Component)val).transform, ((Object)(object)val.elevatorAnimator != (Object)null) ? ((Component)val.elevatorAnimator).transform : null); } Turret[] array2 = Object.FindObjectsOfType<Turret>(); foreach (Turret val2 in array2) { Add(list, (Component)(object)val2, ((Component)val2).transform, ((Object)(object)val2.turretAnimator != (Object)null) ? ((Component)val2.turretAnimator).transform : null, val2.turretRod); } ItemDropship[] array3 = Object.FindObjectsOfType<ItemDropship>(); foreach (ItemDropship val3 in array3) { Add(list, (Component)(object)val3, ((Component)val3).transform, ((Object)(object)val3.shipAnimator != (Object)null) ? ((Component)val3.shipAnimator).transform : null); } SpikeRoofTrap[] array4 = Object.FindObjectsOfType<SpikeRoofTrap>(); foreach (SpikeRoofTrap val4 in array4) { Add(list, (Component)(object)val4, ((Component)val4).transform, ((Object)(object)val4.spikeTrapAnimator != (Object)null) ? ((Component)val4.spikeTrapAnimator).transform : null); } return list; } public static IEnumerable<Behaviour> DrivenBehaviours(Component source) { Behaviour val = (Behaviour)(object)((source is Behaviour) ? source : null); if (val != null) { yield return val; } MineshaftElevatorController val2 = (MineshaftElevatorController)(object)((source is MineshaftElevatorController) ? source : null); if (val2 == null) { Turret val3 = (Turret)(object)((source is Turret) ? source : null); if (val3 == null) { SpikeRoofTrap val4 = (SpikeRoofTrap)(object)((source is SpikeRoofTrap) ? source : null); if (val4 == null) { ItemDropship val5 = (ItemDropship)(object)((source is ItemDropship) ? source : null); if (val5 != null && (Object)(object)val5.shipAnimator != (Object)null) { yield return (Behaviour)(object)val5.shipAnimator; } } else if ((Object)(object)val4.spikeTrapAnimator != (Object)null) { yield return (Behaviour)(object)val4.spikeTrapAnimator; } } else if ((Object)(object)val3.turretAnimator != (Object)null) { yield return (Behaviour)(object)val3.turretAnimator; } } else if ((Object)(object)val2.elevatorAnimator != (Object)null) { yield return (Behaviour)(object)val2.elevatorAnimator; } } private static void Add(List<Prop> list, Component source, params Transform[] parts) { Transform val = null; foreach (Transform val2 in parts) { if (!((Object)(object)val2 == (Object)null)) { val = (((Object)(object)val == (Object)null) ? val2 : CommonAncestor(val, val2)); } } if ((Object)(object)val != (Object)null) { list.Add(new Prop { Source = source, Root = val }); } } private static Transform CommonAncestor(Transform a, Transform b) { HashSet<Transform> hashSet = new HashSet<Transform>(); Transform val = a; while ((Object)(object)val != (Object)null) { hashSet.Add(val); val = val.parent; } Transform val2 = b; while ((Object)(object)val2 != (Object)null) { if (hashSet.Contains(val2)) { return val2; } val2 = val2.parent; } return a; } } } namespace LethalReplay.UI { [DefaultExecutionOrder(32100)] internal sealed class ReplayUI : MonoBehaviour { private readonly UiKit _ui = new UiKit(); private bool _browserOpen; private bool _hideHud; private bool _showHelp = true; private int _scrollIndex; private List<(string path, ReplayMeta meta, long size)> _replays = new List<(string, ReplayMeta, long)>(); private string _confirmDelete; private float _confirmUntil; private bool _frozeLook; private bool _draggingTimeline; private MenuManager _menu; private float _menuCheckAt; private ReplayTheater Theater => ReplayTheater.Instance; private ReplayRecorder Recorder => ReplayRecorder.Instance; private bool AtMainMenu { get { if ((Object)(object)StartOfRound.Instance != (Object)null || ((Object)(object)Theater != (Object)null && Theater.Busy)) { return false; } if ((Object)(object)_menu == (Object)null && Time.unscaledTime >= _menuCheckAt) { _menuCheckAt = Time.unscaledTime + 1f; _menu = Object.FindObjectOfType<MenuManager>(); } if ((Object)(object)_menu != (Object)null && ((Behaviour)_menu).isActiveAndEnabled && !_menu.isInitScene) { if ((Object)(object)_menu.loadingScreen != (Object)null) { return !_menu.loadingScreen.activeSelf; } return true; } return false; } } private static string Hex(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGB(c); } private void Update() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null) { return; } if (((ButtonControl)current[Plugin.MenuKey.Value]).wasPressedThisFrame) { if ((Object)(object)Theater != (Object)null && Theater.Playing) { _hideHud = !_hideHud; } else if (_browserOpen || AtMainMenu || (Object)(object)StartOfRound.Instance != (Object)null) { SetBrowser(!_browserOpen); } } if ((Object)(object)Theater != (Object)null && Theater.Playing) { if (_browserOpen) { SetBrowser(open: false); } if (((ButtonControl)current.hKey).wasPressedThisFrame) { _hideHud = !_hideHud; } if (((ButtonControl)current.f1Key).wasPressedThisFrame) { _showHelp = !_showHelp; } if (((ButtonControl)current.tKey).wasPressedThisFrame) { Plugin.ShowNames.Value = !Plugin.ShowNames.Value; } } if (_browserOpen) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (((ButtonControl)current.escapeKey).wasPressedThisFrame) { SetBrowser(open: false); } } } private void SetBrowser(bool open) { _browserOpen = open; PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (open) { Refresh(); _scrollIndex = 0; if ((Object)(object)val != (Object)null && !val.disableLookInput) { val.disableLookInput = true; _frozeLook = true; } return; } if ((Object)(object)val != (Object)null && _frozeLook) { ReplayTheater theater = Theater; if (theater == null || !theater.Playing) { val.disableLookInput = false; } } _frozeLook = false; if ((Object)(object)val != (Object)null) { ReplayTheater theater2 = Theater; if ((theater2 == null || !theater2.Playing) && !val.quickMenuManager.isMenuOpen) { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } } private void Refresh() { _replays.Clear(); try { string[] files = Directory.GetFiles(Plugin.ReplayDirectory, "*.lcreplay"); foreach (string text in files) { ReplayMeta replayMeta = ReplayData.ReadMetaOrHeader(text); if (replayMeta != null) { _replays.Add((text, replayMeta, new FileInfo(text).Length)); } } _replays = _replays.OrderByDescending(((string path, ReplayMeta meta, long size) r) => r.meta.createdUtcTicks).ToList(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not list replays: " + ex.Message)); } } private void LateUpdate() { try { Draw(); } catch (Exception ex) { Plugin.Log.LogError((object)("UI error: " + ex)); _ui.Hide(); } } private void Draw() { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b8: Unknown result type (might be due to invalid IL or missing references) ReplaySession replaySession = (((Object)(object)Theater != (Object)null && Theater.Playing) ? Theater.Session : null); _ui.Interactive = replaySession?.CursorFree ?? true; _ui.Begin(((Component)this).transform); float w = _ui.W; float h = _ui.H; if ((Object)(object)Theater != (Object)null && Theater.Curtain) { DrawCurtain(w, h); _ui.End(); return; } DrawRecIndicator(w, replaySession != null && _hideHud); if ((Object)(object)Theater != (Object)null && Theater.State == TheaterState.Loading) { Rect r = default(Rect); ((Rect)(ref r))..ctor(w / 2f - 320f, h * 0.14f, 640f, 64f); _ui.Box(r, UiKit.Panel, UiKit.Orange); _ui.Text(r, Theater.Status, 22f, UiKit.Orange, (TextAlignmentOptions)514); } if (replaySession != null) { DrawNameplates(replaySession); if (!_hideHud) { DrawPlayback(replaySession, w, h); } replaySession.UiCapturesMouse = replaySession.CursorFree && _ui.MouseOverUi; } else if (_browserOpen) { DrawBrowser(w, h); } else if (AtMainMenu && _ui.Button(new Rect(w - 264f, 28f, 236f, 52f), "> REPLAYS [" + ((object)Plugin.MenuKey.Value/*cast due to .constrained prefix*/).ToString() + "]", enabled: true, selected: false, 22f)) { SetBrowser(open: true); } _ui.End(); } private void DrawCurtain(float w, float h) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) _ui.Box(new Rect(-10f, -10f, w + 20f, h + 20f), UiKit.Black); float a = 0.55f + 0.45f * Mathf.Abs(Mathf.Sin(Time.unscaledTime * 2.2f)); _ui.Text(new Rect(0f, h / 2f - 70f, w, 60f), "LETHAL REPLAY", 46f, UiKit.Orange, (TextAlignmentOptions)514); _ui.Rect(new Rect(w / 2f - 220f, h / 2f - 4f, 440f, 2f), UiKit.OrangeDim); Color orange = UiKit.Orange; orange.a = a; _ui.Text(new Rect(0f, h / 2f + 10f, w, 40f), Theater.Status.ToUpperInvariant(), 22f, orange, (TextAlignmentOptions)514); } private void DrawRecIndicator(float w, bool hidden) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) ReplayRecorder recorder = Recorder; if ((Object)(object)recorder == (Object)null) { return; } if (recorder.IsRecording && Plugin.ShowRecordingIndicator.Value && !hidden) { if (Time.unscaledTime % 1.2f < 0.8f) { _ui.Rect(new Rect(w - 214f, 22f, 14f, 14f), UiKit.Red); } _ui.Text(new Rect(w - 192f, 12f, 180f, 34f), "REC " + ReplayRecorder.FormatTime(recorder.Elapsed), 22f, UiKit.Red, (TextAlignmentOptions)4097); } if (!string.IsNullOrEmpty(recorder.LastMessage) && Time.unscaledTime - recorder.LastMessageTime < 6f) { Rect r = default(Rect); ((Rect)(ref r))..ctor(w - 640f, 52f, 626f, 58f); _ui.Box(r, UiKit.Panel, UiKit.OrangeDim, blocksClicks: false); _ui.Text(new Rect(((Rect)(ref r)).x + 12f, ((Rect)(ref r)).y + 4f, ((Rect)(ref r)).width - 24f, ((Rect)(ref r)).height - 8f), recorder.LastMessage, 18f, UiKit.Orange, (TextAlignmentOptions)4097, wrap: true); } } private void DrawBrowser(float w, float h) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_09f0: Unknown result type (might be due to invalid IL or missing references) //IL_09f2: Unknown result type (might be due to invalid IL or missing references) //IL_0a58: Unknown result type (might be due to invalid IL or missing references) //IL_0a5d: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_06b2: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_07a8: Unknown result type (might be due to invalid IL or missing references) //IL_0827: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) //IL_0890: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) Rect r = default(Rect); ((Rect)(ref r))..ctor(w / 2f - 560f, 70f, 1120f, h - 140f); _ui.Box(r, UiKit.Panel, UiKit.Orange); float num = ((Rect)(ref r)).x + 28f; float num2 = ((Rect)(ref r)).xMax - 28f; float num3 = ((Rect)(ref r)).y + 20f; _ui.Text(new Rect(num, num3, 600f, 50f), "LETHAL REPLAY", 40f, null, (TextAlignmentOptions)4097); if (_ui.Button(new Rect(num2 - 110f, num3 + 6f, 110f, 38f), "CLOSE")) { SetBrowser(open: false); } if (_ui.Button(new Rect(num2 - 240f, num3 + 6f, 120f, 38f), "REFRESH")) { Refresh(); } if (_ui.Button(new Rect(num2 - 410f, num3 + 6f, 160f, 38f), "OPEN FOLDER")) { Application.OpenURL("file:///" + Plugin.ReplayDirectory.Replace('\\', '/')); } num3 += 58f; _ui.Rect(new Rect(num, num3, num2 - num, 2f), UiKit.OrangeDim); num3 += 12f; ReplayRecorder recorder = Recorder; if ((Object)(object)recorder != (Object)null && recorder.IsRecording) { _ui.Rect(new Rect(num, num3 + 12f, 12f, 12f), UiKit.Red); _ui.Text(new Rect(num + 22f, num3, 500f, 36f), "RECORDING " + ReplayRecorder.FormatTime(recorder.Elapsed), 22f, UiKit.Red, (TextAlignmentOptions)4097); if (_ui.Button(new Rect(num2 - 220f, num3, 220f, 36f), "STOP RECORDING")) { recorder.StopRecording("stopped manually"); } } else if ((Object)(object)StartOfRound.Instance != (Object)null) { _ui.Text(new Rect(num, num3, 600f, 36f), Plugin.AutoRecord.Value ? "Auto-record is on: every landing is recorded." : "Auto-record is off.", 20f, null, (TextAlignmentOptions)4097); string reason; bool flag = ReplayRecorder.CanRecordNow(out reason); if (_ui.Button(new Rect(num2 - 220f, num3, 220f, 36f), "RECORD NOW", flag)) { recorder?.StartRecording(); } if (!flag) { _ui.Text(new Rect(num + 600f, num3, num2 - num - 830f, 36f), reason, 16f, UiKit.OrangeDim, (TextAlignmentOptions)4100, wrap: true); } } else { _ui.Text(new Rect(num, num3, num2 - num, 36f), Plugin.AutoRecord.Value ? "Every round you play is recorded automatically." : ("Auto-record is off (press " + ((object)Plugin.ToggleRecordKey.Value/*cast due to .constrained prefix*/).ToString() + " in a round to record)."), 20f, null, (TextAlignmentOptions)4097); } num3 += 42f; string reason2; bool flag2 = ReplayTheater.CanOpen(out reason2); string s = (flag2 ? "Replays play in a private offline session: nobody can join, and none of your saves are touched." : reason2); _ui.Text(new Rect(num, num3, num2 - num, 30f), s, 17f, flag2 ? UiKit.OrangeDim : UiKit.Yellow, (TextAlignmentOptions)4097); num3 += 32f; if ((Object)(object)Theater != (Object)null && !Theater.Busy && !string.IsNullOrEmpty(Theater.Status)) { _ui.Text(new Rect(num, num3, num2 - num, 30f), Theater.Status, 17f, UiKit.Yellow, (TextAlignmentOptions)4097); num3 += 32f; } num3 += 6f; float num4 = ((Rect)(ref r)).yMax - 20f; int num5 = Mathf.Max(1, (int)((num4 - num3) / 106f)); int num6 = Mathf.Max(0, _replays.Count - num5); if (Mathf.Abs(_ui.Scroll) > 0.01f) { Rect val = new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, num4 - num3); if (((Rect)(ref val)).Contains(_ui.Mouse)) { _scrollIndex -= (int)Mathf.Sign(_ui.Scroll); } } _scrollIndex = Mathf.Clamp(_scrollIndex, 0, num6); if (_replays.Count == 0) { _ui.Text(new Rect(num, num3 + 20f, num2 - num, 40f), "NO REPLAYS YET. LAND ON A MOON TO RECORD ONE.", 22f, UiKit.OrangeDim, (TextAlignmentOptions)514); } string text = null; Rect r2 = default(Rect); for (int i = _scrollIndex; i < _replays.Count && i < _scrollIndex + num5; i++) { var (text2, replayMeta, num7) = _replays[i]; ((Rect)(ref r2))..ctor(num, num3, num2 - num - (float)((num6 > 0) ? 18 : 0), 96f); bool flag3 = _ui.Hover(r2); _ui.Box(r2, (Color)(flag3 ? UiKit.OrangeFaint : new Color(0f, 0f, 0f, 0.35f)), flag3 ? UiKit.Orange : UiKit.OrangeDim); DateTime dateTime = new DateTime(replayMeta.createdUtcTicks, DateTimeKind.Utc).ToLocalTime(); string s2 = ((replayMeta.players != null && replayMeta.players.Length != 0) ? string.Join(", ", replayMeta.players) : "-"); string text3 = ((replayMeta.duration >= 0f) ? ReplayRecorder.FormatTime(replayMeta.duration) : "?"); string text4 = (replayMeta.finished ? "" : (" <color=" + Hex(UiKit.Yellow) + ">UNFINISHED</color>")); float num8 = ((Rect)(ref r2)).x + 18f; float num9 = ((Rect)(ref r2)).width - 300f; _ui.Text(new Rect(num8, ((Rect)(ref r2)).y + 8f, num9, 32f), (replayMeta.planet ?? "?").ToUpperInvariant() + " <size=17><color=" + Hex(UiKit.OrangeDim) + ">" + replayMeta.weather + " " + replayMeta.interior + "</color></size>", 26f, null, (TextAlignmentOptions)4097); _ui.Text(new Rect(num8, ((Rect)(ref r2)).y + 40f, num9, 26f), $"{dateTime:yyyy-MM-dd HH:mm} {text3} {(float)num7 / 1048576f:0.0} MB DEATHS: {replayMeta.deaths}{text4}", 18f, null, (TextAlignmentOptions)4097); _ui.Text(new Rect(num8, ((Rect)(ref r2)).y + 64f, num9, 24f), s2, 16f, UiKit.OrangeDim, (TextAlignmentOptions)4097); bool enabled = flag2 && !(Theater?.Busy ?? false); if (_ui.Button(new Rect(((Rect)(ref r2)).xMax - 270f, ((Rect)(ref r2)).y + 22f, 140f, 52f), "WATCH", enabled, selected: false, 24f)) { Theater.Open(text2); SetBrowser(open: false); } bool flag4 = (Object)(object)Recorder != (Object)null && Recorder.IsRecording && Recorder.CurrentPath == text2; bool flag5 = _confirmDelete == text2 && Time.unscaledTime < _confirmUntil; if (_ui.Button(new Rect(((Rect)(ref r2)).xMax - 120f, ((Rect)(ref r2)).y + 22f, 104f, 52f), flag5 ? "SURE?" : "DELETE", !flag4, flag5)) { if (flag5) { text = text2; } else { _confirmDelete = text2; _confirmUntil = Time.unscaledTime + 3f; } } num3 += 106f; } if (num6 > 0) { Rect r3 = default(Rect); ((Rect)(ref r3))..ctor(num2 - 8f, ((Rect)(ref r)).y + 200f, 6f, num4 - ((Rect)(ref r)).y - 200f); _ui.Rect(r3, UiKit.OrangeFaint); float num10 = (float)_scrollIndex / (float)num6; float num11 = Mathf.Max(30f, ((Rect)(ref r3)).height * (float)num5 / (float)_replays.Count); _ui.Rect(new Rect(((Rect)(ref r3)).x, ((Rect)(ref r3)).y + (((Rect)(ref r3)).height - num11) * num10, ((Rect)(ref r3)).width, num11), UiKit.Orange); } if (text == null) { return; } try { File.Delete(text); string path = Path.ChangeExtension(text, ".json"); if (File.Exists(path)) { File.Delete(path); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Delete failed: " + ex.Message)); } _confirmDelete = null; Refresh(); } private void DrawPlayback(ReplaySession s, float w, float h) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0320: 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) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_0635: Unknown result type (might be due to invalid IL or missing references) //IL_06f3: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_09f9: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) //IL_0abf: Unknown result type (might be due to invalid IL or missing references) //IL_0b01: Unknown result type (might be due to invalid IL or missing references) //IL_0b42: Unknown result type (might be due to invalid IL or missing references) //IL_0b6d: Unknown result type (might be due to invalid IL or missing references) //IL_0ba0: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_0be7: Unknown result type (might be due to invalid IL or missing references) //IL_0c5f: Unknown result type (might be due to invalid IL or missing references) //IL_0c61: Unknown result type (might be due to invalid IL or missing references) //IL_0c66: Unknown result type (might be due to invalid IL or missing references) //IL_0cb0: Unknown result type (might be due to invalid IL or missing references) //IL_0cc5: Unknown result type (might be due to invalid IL or missing references) //IL_0d06: Unknown result type (might be due to invalid IL or missing references) //IL_0d08: Unknown result type (might be due to invalid IL or missing references) //IL_0d0d: Unknown result type (might be due to invalid IL or missing references) //IL_0d37: Unknown result type (might be due to invalid IL or missing references) //IL_0d75: Unknown result type (might be due to invalid IL or missing references) //IL_0d84: Unknown result type (might be due to invalid IL or missing references) //IL_0db3: Unknown result type (might be due to invalid IL or missing references) //IL_0db8: Unknown result type (might be due to invalid IL or missing references) //IL_0dec: Unknown result type (might be due to invalid IL or missing references) //IL_0df1: Unknown result type (might be due to invalid IL or missing references) //IL_0f34: Unknown result type (might be due to invalid IL or missing references) //IL_0f39: Unknown result type (might be due to invalid IL or missing references) //IL_0f8c: Unknown result type (might be due to invalid IL or missing references) //IL_0fa0: Unknown result type (might be due to invalid IL or missing references) //IL_0fcc: Unknown result type (might be due to invalid IL or missing references) //IL_0fe0: Unknown result type (might be due to invalid IL or missing references) ReplayData data = s.Data; float num = 168f; Rect r = default(Rect); ((Rect)(ref r))..ctor(-4f, h - num, w + 8f, num + 4f); _ui.Box(r, UiKit.Panel, UiKit.OrangeDim); if (!s.CursorFree) { Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(w / 2f - 280f, h - num - 40f, 560f, 32f); _ui.Box(r2, UiKit.Panel, null, blocksClicks: false); _ui.Text(r2, $"PRESS [{Plugin.CursorKey.Value}] OR [ESC] TO USE THE CONTROLS", 17f, UiKit.OrangeDim, (TextAlignmentOptions)514); } float num2 = h - num + 20f; Rect r3 = default(Rect); ((Rect)(ref r3))..ctor(150f, num2, w - 300f, 20f); _ui.Text(new Rect(18f, num2 - 8f, 128f, 36f), ReplayRecorder.FormatTime(s.Clock.Time), 24f, null, (TextAlignmentOptions)4097); _ui.Text(new Rect(w - 142f, num2 - 8f, 128f, 36f), ReplayRecorder.FormatTime(data.Duration), 24f, UiKit.OrangeDim, (TextAlignmentOptions)4100); float num3 = Mathf.Max(0.01f, data.Duration); float num4 = _ui.Slider(r3, s.Clock.Time, 0f, num3, ref _draggingTimeline); if (_draggingTimeline && Mathf.Abs(num4 - s.Clock.Time) > 0.001f) { s.Seek(num4); } string text = null; foreach (Marker marker in data.Markers) { float num5 = ((Rect)(ref r3)).x + ((Rect)(ref r3)).width * (marker.Time / num3); _ui.Rect(new Rect(num5 - 2f, ((Rect)(ref r3)).y - 10f, 4f, 10f), UiKit.Red); Rect val = new Rect(num5 - 7f, ((Rect)(ref r3)).y - 14f, 14f, 18f); if (((Rect)(ref val)).Contains(_ui.Mouse)) { text = ReplayRecorder.FormatTime(marker.Time) + " " + marker.Text; } } foreach (CamKey pathKey in s.PathKeys) { float num6 = ((Rect)(ref r3)).x + ((Rect)(ref r3)).width * (pathKey.Time / num3); _ui.Rect(new Rect(num6 - 2f, ((Rect)(ref r3)).yMax, 4f, 10f), UiKit.Yellow); } if (text != null) { Rect r4 = default(Rect); ((Rect)(ref r4))..ctor(Mathf.Clamp(_ui.Mouse.x - 200f, 8f, w - 408f), ((Rect)(ref r3)).y - 50f, 400f, 34f); _ui.Box(r4, UiKit.Panel, UiKit.Red, blocksClicks: false); _ui.Text(r4, text, 17f, UiKit.Orange, (TextAlignmentOptions)514); } float y = h - num + 58f; float x0 = 18f; if (_ui.Button(Next(48f), "|<")) { s.Seek(0f); } if (_ui.Button(Next(60f), "-5S")) { s.Seek(s.Clock.Time - 5f); } if (_ui.Button(Next(100f), s.Clock.Playing ? "PAUSE" : "PLAY", enabled: true, !s.Clock.Playing)) { if (!s.Clock.Playing && s.Clock.Time >= data.Duration - 0.01f) { s.Seek(0f); } s.Clock.Playing = !s.Clock.Playing; } if (_ui.Button(Next(60f), "+5S")) { s.Seek(s.Clock.Time + 5f); } if (_ui.Button(Next(48f), "<!")) { s.Seek(s.NextMarker(s.Clock.Time, -1)); } if (_ui.Button(Next(48f), "!>")) { s.Seek(s.NextMarker(s.Clock.Time, 1)); } x0 += 8f; if (_ui.Button(Next(40f), "-")) { s.StepSpeed(-1); } _ui.Text(Next(70f), $"{s.Clock.Speed:0.##}X", 22f, UiKit.Orange, (TextAlignmentOptions)514); if (_ui.Button(Next(40f), "+")) { s.StepSpeed(1); } x0 += 18f; string text2 = ((s.Mode == CamMode.Free) ? "FREE CAM" : ((s.Mode == CamMode.Path) ? "CAMERA PATH" : (((s.Target >= 0 && s.Target < data.Players.Count) ? data.Players[s.Target].NameAt(s.Clock.Time) : "?") + ((s.Mode == CamMode.FirstPerson) ? " (1ST)" : " (3RD)")))); _ui.Text(Next(250f), "CAM: " + text2, 20f, null, (TextAlignmentOptions)4097); if (_ui.Button(Next(100f), "FREE [F]", enabled: true, s.Mode == CamMode.Free)) { s.FreeCam(); } if (_ui.Button(Next(140f), "KEYFRAME [K]")) { s.AddKeyframe(); } if (_ui.Button(Next(110f), (s.Mode == CamMode.Path) ? "PATH: ON" : "PATH [P]", s.PathKeys.Count >= 2, s.Mode == CamMode.Path)) { s.Mode = ((s.Mode != CamMode.Path) ? CamMode.Path : CamMode.Free); } if (_ui.Button(Next(80f), "CLEAR", s.PathKeys.Count > 0)) { s.PathKeys.Clear(); if (s.Mode == CamMode.Path) { s.Mode = CamMode.Free; } } if (_ui.Button(new Rect(w - 198f, y, 180f, 40f), "BACK TO MENU")) { Theater.Exit(); } y = h - num + 112f; x0 = 18f; _ui.Text(Next(100f), "PLAYERS:", 20f, null, (TextAlignmentOptions)4097); float num7 = w - 850f; for (int i = 0; i < data.Players.Count; i++) { EntityTimeline entityTimeline = data.Players[i]; string text3 = entityTimeline.NameAt(s.Clock.Time); if (!string.IsNullOrEmpty(text3)) { bool flag = entityTimeline.PresentAt(s.Clock.Time); float num8 = Mathf.Clamp(text3.Length * 12 + 40, 90, 220); if (x0 + num8 > num7 - 10f) { break; } bool selected = s.Target == i && (s.Mode == CamMode.FirstPerson || s.Mode == CamMode.ThirdPerson); string label = (flag ? text3 : ("<s>" + text3 + "</s>")); if (_ui.Button(Next(num8), label, enabled: true, selected, 19f)) { bool flag2 = Keyboard.current != null && Keyboard.current.shiftKey.isPressed; s.FollowPlayer(i, !flag2); } } } bool flag3 = _ui.Toggle(new Rect(num7, y + 4f, 120f, 32f), Plugin.ShowNames.Value, "NAMES"); if (flag3 != Plugin.ShowNames.Value) { Plugin.ShowNames.Value = flag3; } bool flag4 = _ui.Toggle(new Rect(num7 + 130f, y + 4f, 190f, 32f), Plugin.HearDeadPlayers.Value, "HEAR THE DEAD"); if (flag4 != Plugin.HearDeadPlayers.Value) { Plugin.HearDeadPlayers.Value = flag4; } float value = Plugin.NightVision.Value; float num9 = num7 + 336f; _ui.Text(new Rect(num9, y, 140f, 40f), "NIGHT VISION", 19f, null, (TextAlignmentOptions)4097); if (_ui.Button(new Rect(num9 + 140f, y, 40f, 40f), "-")) { s.StepNightVision(-0.25f); } _ui.Text(new Rect(num9 + 182f, y, 66f, 40f), (value > 0.001f) ? $"{value:0.##}X" : "OFF", 20f, UiKit.Orange, (TextAlignmentOptions)514); if (_ui.Button(new Rect(num9 + 250f, y, 40f, 40f), "+")) { s.StepNightVision(0.25f); } bool flag5 = _ui.Toggle(new Rect(num9 + 302f, y + 4f, 200f, 32f), Plugin.NightVisionOutside.Value, "ALSO OUTSIDE"); if (flag5 != Plugin.NightVisionOutside.Value) { Plugin.NightVisionOutside.Value = flag5; } if (!string.IsNullOrEmpty(Theater.Warning)) { Rect r5 = default(Rect); ((Rect)(ref r5))..ctor(w / 2f - 470f, 14f, 940f, 58f); _ui.Box(r5, UiKit.Panel, UiKit.Yellow, blocksClicks: false); _ui.Text(new Rect(((Rect)(ref r5)).x + 14f, ((Rect)(ref r5)).y + 4f, ((Rect)(ref r5)).width - 28f, ((Rect)(ref r5)).height - 8f), Theater.Warning, 17f, UiKit.Yellow, (TextAlignmentOptions)4097, wrap: true); } if (_showHelp) { Rect r6 = default(Rect); ((Rect)(ref r6))..ctor(14f, 14f, 520f, 419f); _ui.Box(r6, UiKit.Panel, UiKit.OrangeDim); _ui.Text(new Rect(30f, 22f, 480f, 32f), "REPLAY CONTROLS", 26f, null, (TextAlignmentOptions)4097); _ui.Text(new Rect(30f, 26f, 488f, 26f), "[F1] HIDE", 15f, UiKit.OrangeDim, (TextAlignmentOptions)4100); _ui.Rect(new Rect(30f, 58f, 488f, 2f), UiKit.OrangeDim); string[,] array = new string[13, 2] { { "MOUSE", "look" }, { ((object)Plugin.CursorKey.Value/*cast due to .constrained prefix*/).ToString() + " / ESC", "show cursor" }, { "W A S D / E Q", "move / up, down" }, { "SHIFT / CTRL", "fast / slow" }, { "WHEEL", "zoom (3rd person: distance)" }, { "SPACE", "play / pause" }, { "LEFT / RIGHT", "-5s / +5s" }, { "UP / DOWN", "playback speed" }, { "TAB / V", "next player / 1st, 3rd person" }, { "N / [ ]", "night vision / strength" }, { "T", "player names on / off" }, { "K / P", "keyframe / play camera path" }, { "H / " + ((object)Plugin.MenuKey.Value/*cast due to .constrained prefix*/).ToString(), "hide interface" } }; for (int j = 0; j < array.GetLength(0); j++) { float num10 = 66 + j * 27; _ui.Text(new Rect(30f, num10, 200f, 26f), array[j, 0], 17f, UiKit.Orange, (TextAlignmentOptions)4097); _ui.Text(new Rect(232f, num10, 290f, 26f), array[j, 1], 17f, UiKit.OrangeDim, (TextAlignmentOptions)4097); } } Rect Next(float width) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) Rect result = new Rect(x0, y, width, 40f); x0 += width + 6f; return result; } } private void DrawNameplates(ReplaySession s) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s.Camera == (Object)null || _hideHud || !Plugin.ShowNames.Value) { return; } Camera camera = s.Camera; float num = (float)Screen.height / 1080f; Rect r = default(Rect); foreach (EntityTimeline player in s.Data.Players) { if (!player.PresentAt(s.Clock.Time) || (s.Mode == CamMode.FirstPerson && s.Target >= 0 && s.Data.Players[s.Target] == player)) { continue; } Puppet puppet = s.PuppetFor(player); if (puppet != null && puppet.Go.activeInHierarchy) { Vector3 val = camera.WorldToViewportPoint(puppet.HeadPosition); if (!(val.z <= 0f) && !(val.z > 60f)) { float num2 = val.x * (float)Screen.width / num; float num3 = (1f - val.y) * (float)Screen.height / num; string text = player.NameAt(s.Clock.Time); float num4 = Mathf.Clamp((float)text.Length * 11f + 20f, 60f, 260f); ((Rect)(ref r))..ctor(num2 - num4 / 2f, num3 - 30f, num4, 26f); _ui.Box(r, new Color(0f, 0f, 0f, 0.55f), null, blocksClicks: false); _ui.Text(r, text, 18f, Color.white, (TextAlignmentOptions)514); } } } } } internal sealed class UiKit { private sealed class Elem { public GameObject Go; public RectTransform Rt; public Image Img; public TextMeshProUGUI Text; } public const float RefHeight = 1080f; public static readonly Color Orange = new Color(0.99f, 0.44f, 0.13f, 1f); public static readonly Color OrangeDim = new Color(0.99f, 0.44f, 0.13f, 0.45f); public static readonly Color OrangeFaint = new Color(0.99f, 0.44f, 0.13f, 0.14f); public static readonly Color Panel = new Color(0.02f, 0.01f, 0f, 0.86f); public static readonly Color Black = Color.black; public static readonly Color Red = new Color(0.95f, 0.16f, 0.1f, 1f); public static readonly Color Yellow = new Color(1f, 0.82f, 0.25f, 1f); public bool Interactive = true; private GameObject _canvasGo; private RectTransform _root; private readonly List<Elem> _pool = new List<Elem>(); private int _used; private float _scale = 1f; private bool _pressed; private bool _held; private TMP_FontAsset _font; private float _fontSearchAt; private Sprite _solid; private Sprite _frame; public float W { get; private set; } public float H => 1080f; public Vector2 Mouse { get; private set; } public bool MouseOverUi { get; private set; } public float Scroll { get; private set; } public void Begin(Transform parent) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) EnsureCanvas(parent); _scale = (float)Screen.height / 1080f; W = (float)Screen.width / _scale; _used = 0; MouseOverUi = false; Mouse current = Mouse.current; if (current != null) { Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(); Mouse = new Vector2(val.x / _scale, ((float)Screen.height - val.y) / _scale); _pressed = current.leftButton.wasPressedThisFrame; _held = current.leftButton.isPressed; Scroll = ((InputControl<Vector2>)(object)current.scroll).ReadValue().y; } else { _pressed = (_held = false); Scroll = 0f; } if ((Object)(object)_font == (Object)null && Time.unscaledTime >= _fontSearchAt) { FindFont(); } } public void End() { for (int i = _used; i < _pool.Count; i++) { if (_pool[i].Go.activeSelf) { _pool[i].Go.SetActive(false); } } } public void Hide() { _used = 0; End(); } private void EnsureCanvas(Transform parent) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown if (!((Object)(object)_canvasGo != (Object)null)) { _canvasGo = new GameObject("LethalReplay UI"); _canvasGo.transform.SetParent(parent, false); Canvas obj = _canvasGo.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 2000; CanvasScaler obj2 = _canvasGo.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 1f; _canvasGo.AddComponent<GraphicRaycaster>(); _root = (RectTransform)_canvasGo.transform; _solid = MakeSprite(frame: false); _frame = MakeSprite(frame: true); } } private static Sprite MakeSprite(bool frame) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false) { filterMode = (FilterMode)0, hideFlags = (HideFlags)61 }; Color32[] array = (Color32[])(object)new Color32[256]; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { bool flag = j < 2 || i < 2 || j >= 14 || i >= 14; array[i * 16 + j] = ((!frame || flag) ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue) : new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0)); } } val.SetPixels32(array); val.Apply(); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 16f, 16f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(3f, 3f, 3f, 3f)); ((Object)obj).hideFlags = (HideFlags)61; return obj; } private void FindFont() { _fontSearchAt = Time.unscaledTime + 2f; TMP_FontAsset val = null; TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); foreach (TMP_FontAsset val2 in array) { if (!((Object)(object)val2 == (Object)null)) { if (((Object)val2).name.StartsWith("3270")) { _font = val2; break; } if ((Object)(object)val == (Object)null && !((Object)val2).name.StartsWith("LiberationSans")) { val = val2; } } } if ((Object)(object)_font == (Object)null && (Object)(object)val != (Object)null) { _font = val; } if (!((Object)(object)_font != (Object)null)) { return; } foreach (Elem item in _pool) { if ((Object)(object)item.Text != (Object)null) { ((TMP_Text)item.Text).font = _font; } } } private Elem Next(Rect r) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) Elem elem; if (_used < _pool.Count) { elem = _pool[_used]; } else { elem = new Elem { Go = new GameObject("el") }; elem.Rt = elem.Go.AddComponent<RectTransform>(); elem.Go.transform.SetParent((Transform)(object)_root, false); RectTransform rt = elem.Rt; RectTransform rt2 = elem.Rt; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rt2.anchorMax = val; rt.anchorMin = val; elem.Rt.pivot = new Vector2(0f, 1f); elem.Img = elem.Go.AddComponent<Image>(); GameObject val2 = new GameObject("t", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(elem.Go.transform, false); RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val = (val3.offsetMin = (val3.offsetMax = Vector2.zero)); elem.Text = val2.AddComponent<TextMeshProUGUI>(); if ((Object)(object)_font != (Object)null) { ((TMP_Text)elem.Text).font = _font; } ((TMP_Text)elem.Text).richText = true; ((Graphic)elem.Text).raycastTarget = false; ((TMP_Text)elem.Text).overflowMode = (TextOverflowModes)1; _pool.Add(elem); } _used++; if (!elem.Go.activeSelf) { elem.Go.SetActive(true); } elem.Go.transform.SetSiblingIndex(_used - 1); elem.Rt.anchoredPosition = new Vector2(((Rect)(ref r)).x, 0f - ((Rect)(ref r)).y); elem.Rt.sizeDelta = new Vector2(((Rect)(ref r)).width, ((Rect)(ref r)).height); return elem; } private static void NoText(Elem e) { if (!string.IsNullOrEmpty(((TMP_Text)e.Text).text)) { ((TMP_Text)e.Text).text = ""; } } private void SetImage(Elem e, Sprite sprite, Color color, bool blocksClicks) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) ((Behaviour)e.Img).enabled = color.a > 0.001f; e.Img.sprite = sprite; e.Img.type = (Type)(((Object)(object)sprite == (Object)(object)_frame) ? 1 : 0); ((Graphic)e.Img).color = color; ((Graphic)e.Img).raycastTarget = blocksClicks; } private void SetText(Elem e, string s, float size, Color color, TextAlignmentOptions align, bool wrap, float pad) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)e.Text).text = s ?? ""; ((TMP_Text)e.Text).fontSize = size; ((Graphic)e.Text).color = color; ((TMP_Text)e.Text).alignment = align; ((TMP_Text)e.Text).enableWordWrapping = wrap; ((TMP_Text)e.Text).margin = new Vector4(pad, 0f, pad, 0f); } public bool Hover(Rect r) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return ((Rect)(ref r)).Contains(Mouse); } public void Box(Rect r, Color fill, Color? frame = null, bool blocksClicks = true) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (blocksClicks && ((Rect)(ref r)).Contains(Mouse)) { MouseOverUi = true; } Elem e = Next(r); SetImage(e, _solid, fill, blocksClicks); NoText(e); if (frame.HasValue) { Elem e2 = Next(r); SetImage(e2, _frame, frame.Value, blocksClicks: false); NoText(e2); } } public void Text(Rect r, string s, float size = 20f, Color? color = null, TextAlignmentOptions align = (TextAlignmentOptions)4097, bool wrap = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Elem e = Next(r); SetImage(e, _solid, Color.clear, blocksClicks: false); SetText(e, s, size, (Color)(((??)color) ?? Orange), align, wrap, 0f); } public bool Button(Rect r, string label, bool enabled = true, bool selected = false, float size = 20f) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) bool flag = enabled && Interactive && ((Rect)(ref r)).Contains(Mouse); if (((Rect)(ref r)).Contains(Mouse)) { MouseOverUi = true; } Elem e = Next(r); Color color = ((!enabled) ? Color.clear : ((!(flag || selected)) ? OrangeFaint : (flag ? Orange : OrangeDim))); SetImage(e, _solid, color, blocksClicks: true); NoText(e); Elem e2 = Next(r); SetImage(e2, _frame, enabled ? Orange : OrangeDim, blocksClicks: false); Color color2 = ((!enabled) ? OrangeDim : ((flag || selected) ? Black : Orange)); SetText(e2, label, size, color2, (TextAlignmentOptions)514, wrap: false, 4f); if (flag) { return _pressed; } return false; } public bool Toggle(Rect r, bool value, string label, float size = 19f) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) bool flag = Interactive && ((Rect)(ref r)).Contains(Mouse); if (flag) { MouseOverUi = true; } Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref r)).x, ((Rect)(ref r)).y + (((Rect)(ref r)).height - 22f) / 2f, 22f, 22f); Elem e = Next(r2); SetImage(e, _solid, value ? Orange : (flag ? OrangeFaint : Color.clear), blocksClicks: true); NoText(e); Elem e2 = Next(r2); SetImage(e2, _frame, Orange, blocksClicks: false); NoText(e2); Text(new Rect(((Rect)(ref r)).x + 30f, ((Rect)(ref r)).y, ((Rect)(ref r)).width - 30f, ((Rect)(ref r)).height), label, size, flag ? Color.white : Orange, (TextAlignmentOptions)4097); if (!flag || !_pressed) { return value; } return !value; } public float Slider(Rect r, float value, float min, float max, ref bool dragging) { //IL_004d: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.0001f, max - min); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x - 6f, ((Rect)(ref r)).y - 8f, ((Rect)(ref r)).width + 12f, ((Rect)(ref r)).height + 16f); if (((Rect)(ref val)).Contains(Mouse)) { MouseOverUi = true; } if (Interactive && _pressed && ((Rect)(ref val)).Contains(Mouse)) { dragging = true; } if (!_held || !Interactive) { dragging = false; } if (dragging) { value = min + Mathf.Clamp01((Mouse.x - ((Rect)(ref r)).x) / ((Rect)(ref r)).width) * num; } float num2 = Mathf.Clamp01((value - min) / num); Box(r, OrangeFaint, OrangeDim); Elem e = Next(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, Mathf.Max(0f, (((Rect)(ref r)).width - 4f) * num2), ((Rect)(ref r)).height - 4f)); SetImage(e, _solid, OrangeDim, blocksClicks: false); NoText(e); Elem e2 = Next(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width * num2 - 4f, ((Rect)(ref r)).y - 5f, 8f, ((Rect)(ref r)).height + 10f)); SetImage(e2, _solid, (dragging || ((Rect)(ref val)).Contains(Mouse)) ? Color.white : Orange, blocksClicks: false); NoText(e2); return value; } public void Rect(Rect r, Color c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Elem e = Next(r); SetImage(e, _solid, c, blocksClicks: false); NoText(e); } public bool Clicked(Rect r) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Interactive && _pressed) { return ((Rect)(ref r)).Contains(Mouse); } return false; } public void Destroy() { if ((Object)(object)_canvasGo != (Object)null) { Object.Destroy((Object)(object)_canvasGo); } _canvasGo = null; _pool.Clear(); } } } namespace LethalReplay.Recording { internal sealed class ReplayRecorder : MonoBehaviour { private sealed class AudioSourceState { public double LastEnd = double.NegativeInfinity; } private static readonly FieldRef<TerminalAccessibleObject, bool> BigDoorOpen = AccessTools.FieldRefAccess<TerminalAccessibleObject, bool>("isDoorOpen"); private FileStream _file; private GZipStream _gzip; private BinaryWriter _writer; private string _path; private ReplayMeta _meta; private readonly Dictionary<Component, TrackedEntity> _entities = new Dictionary<Component, TrackedEntity>(); private readonly Dictionary<Transform, TrackedEntity> _byRoot = new Dictionary<Transform, TrackedEntity>(); private readonly Dictionary<AudioSource, int> _soundIds = new Dictionary<AudioSource, int>(RefComparer<AudioSource>.Instance); private int _nextSoundId; private readonly Dictionary<int, int> _playerIndexToEntity = new Dictionary<int, int>(); private readonly Dictionary<long, AudioSourceState> _audioStates = new Dictionary<long, AudioSourceState>(); private readonly HashSet<string> _playerNames = new HashSet<string>(); private int _nextId; private float _nextTick; private float _nextScan; private float _nextSlow; private float _nextFlush; private float _nextDoorRefresh; private float _stopAt = -1f; private int _deaths; private readonly List<(AnimatedObjectTrigger trigger, long key)> _triggers = new List<(AnimatedObjectTrigger, long)>(); private readonly Dictionary<long, bool> _lastTrigger = new Dictionary<long, bool>(); private readonly List<(TerminalAccessibleObject door, long key)> _bigDoors = new List<(TerminalAccessibleObject, long)>(); private readonly Dictionary<long, bool> _lastBigDoor = new Dictionary<long, bool>(); private string _lastWorld; public static ReplayRecorder Instance { get; private set; } public bool IsRecording => _writer != null; public string CurrentPath => _path; public float Elapsed { get { if (!IsRecording) { return 0f; } return (float)AudioClock.Now; } } public string LastMessage { get; private set; } public float LastMessageTime { get; private set; } private void Awake() { Instance = this; } private void OnApplicationQuit() { StopRecording("game closed"); } private void Notify(string msg) { LastMessage = msg; LastMessageTime = Time.unscaledTime; Plugin.Log.LogInfo((object)msg); } public void OnLevelReady() { if ((!((Object)(object)ReplayTheater.Instance != (Object)null) || !ReplayTheater.Instance.Busy) && Plugin.AutoRecord.Value && !IsRecording) { StartRecording(); } } public void OnShipLeft() { if (IsRecording && _stopAt < 0f) { _stopAt = Time.unscaledTime + 4f; } } public static bool CanRecordNow(out string reason) { reason = null; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { reason = "Join a game first."; return false; } RoundManager instance2 = RoundManager.Instance; bool flag = (Object)(object)instance2 != (Object)null && (instance2.dungeonCompletedGenerating || instance2.dungeonFinishedGeneratingForAllPlayers || instance.shipHasLanded); if (instance.inShipPhase || !flag) { reason = "Recording starts once the ship has landed on a moon."; return false; } if ((Object)(object)ReplayTheater.Instance != (Object)null && ReplayTheater.Instance.Busy) { reason = "Can't record while watching a replay."; return false; } return true; } public void StartRecording() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (IsRecording) { return; } if (!CanRecordNow(out var reason)) { Notify(reason); return; } try { StartOfRound instance = StartOfRound.Instance; RoundManager instance2 = RoundManager.Instance; SelectableLevel currentLevel = instance.currentLevel; PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; ReplayHeader replayHeader = new ReplayHeader { CreatedUtcTicks = DateTime.UtcNow.Ticks, TickRate = Mathf.Clamp(Plugin.TickRate.Value, 5, 60), GameVersion = GameNetworkManager.Instance.gameVersionNum.ToString(), LevelId = instance.currentLevelID, PlanetName = (((Object)(object)currentLevel != (Object)null) ? currentLevel.PlanetName : ""), SceneName = (((Object)(object)currentLevel != (Object)null) ? currentLevel.sceneName : ""), Seed = instance.randomMapSeed, Weather = ((!((Object)(object)currentLevel != (Object)null)) ? (-1) : ((int)currentLevel.currentWeather)), InteriorName = InteriorName(), DungeonType = instance2.currentDungeonType, RecordedBy = localPlayerController.playerUsername, RecordedAsHost = ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsHost), Mods = (from p in Chainloader.PluginInfos.Values select p.Metadata.GUID + "@" + p.Metadata.Version into s orderby s select s).ToList() }; string text = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"); string text2 = new string((replayHeader.PlanetName ?? "moon").Where((char c) => char.IsLetterOrDigit(c) || c == '-' || c == '_').ToArray()); _path = Path.Combine(Plugin.ReplayDirectory, text + "_" + text2 + ".lcreplay"); _file = new FileStream(_path, FileMode.Create, FileAccess.Write, FileShare.Read); _gzip = new GZipStream(_file, CompressionLevel.Fastest); _writer = new BinaryWriter(new BufferedStream(_gzip, 65536)); replayHeader.Write(_writer); _meta = new ReplayMeta { file = Path.GetFileName(_path), planet = replayHeader.PlanetName, interior = replayHeader.InteriorName, weather = (((Object)(object)currentLevel != (Object)null) ? ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref currentLevel.currentWeather)/*cast due to .constrained prefix*/).ToString() : ""), seed = replayHeader.Seed, createdUtcTicks = replayHeader.CreatedUtcTicks, recordedBy = replayHeader.RecordedBy }; WriteMeta(final: false); _entities.Clear(); _byRoot.Clear(); _soundIds.Clear(); _nextSoundId = 1; _playerIndexToEntity.Clear(); _audioStates.Clear(); _playerNames.Clear(); _triggers.Clear(); _lastTrigger.Clear(); _bigDoors.Clear(); _lastBigDoor.Clear(); _lastWorld = null; _nextId = 1; _deaths = 0; _stopAt = -1f; _nextTick = (_nextScan = (_nextSlow = (_nextDoorRefresh = 0f))); _nextFlush = 5f; AudioClock.Reset(); VoiceCapture.OutputSampleRate = AudioSettings.outputSampleRate; if (Plugin.RecordVoice.Value || Plugin.RecordMirage.Value) { VoiceCapture.Start(); } SoundCapture.Active = Plugin.RecordSounds.Value; Notify($"Recording started on {replayHeader.PlanetName} (seed {replayHeader.Seed})."); } catch (Exception ex) { Plugin.Log.LogError((object)("Could not start recording: " + ex)); CloseStreams(); Notify("Could not start recording: " + ex.Message); } } public void StopRecording(string why = null) { if (!IsRecording) { return; } VoiceCapture.Stop(); SoundCapture.Active = false; float num = (float)AudioClock.Now; try { _writer.Write((byte)1); _writer.Write(num); _writer.Write(byte.MaxValue); _writer.Flush(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Error finishing replay: " + ex.Message)); } foreach (TrackedEntity value in _entities.Values) { value.Dispose(); } _entities.Clear(); _byRoot.Clear(); _soundIds.Clear(); CloseStreams(); _meta.duration = num; _meta.players = _playerNames.ToArray(); _meta.deaths = _deaths; _meta.finished = true; WriteMeta(final: true); Notify("Replay saved (" + FormatTime(num) + ")" + ((why != null) ? (" - " + why) : "") + ": " + Path.GetFileName(_path)); } private void CloseStreams() { try { _writer?.Dispose(); } catch { } try { _gzip?.Dispose(); } catch { } try { _file?.Dispose(); } catch { } _writer = null; _gzip = null; _file = null; } private void WriteMeta(bool final) { try { File.WriteAllText(Path.ChangeExtension(_path, ".json"), JsonUtility.ToJson((object)_meta, true)); } catch (Exception ex) { if (final) { Plugin.Log.LogWarning((object)("Could not write replay info file: " + ex.Message)); } } } public static string FormatTime(float s) { if (s < 0f) { s = 0f; } int num = (int)(s / 60f); return $"{num}:{s - (float)num * 60f:00.0}"; } private static string InteriorName() { try { DungeonFlow val = RoundManager.Instance.dungeonGenerator?.Generator?.DungeonFlow; return ((Object)(object)val != (Object)null) ? ((Object)val).name : ""; } catch { return ""; } } private void Update() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current[Plugin.ToggleRecordKey.Value]).wasPressedThisFrame) { ReplayTheater instance = ReplayTheater.Instance; if (instance == null || !instance.Busy) { if (IsRecording) { StopRecording("stopped manually"); } else { StartRecording(); } } } if (!IsRecording) { return; } if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) { StopRecording("left the game"); return; } if (_stopAt > 0f && Time.unscaledTime >= _stopAt) { StopRecording("ship left"); return; } try { VoiceCapture.RefreshLocalTransmitting(); float num = (float)AudioClock.Now; if (num >= _nextTick) { _nextTick = num + 1f / (float)Mathf.Clamp(Plugin.TickRate.Value, 5, 60); Tick(num); } DrainAudio(); if (num >= _nextFlush) { _nextFlush = num + 5f; _writer.Flush(); _gzip.Flush(); _meta.duration = num; _meta.players = _playerNames.ToArray(); _meta.deaths = _deaths; WriteMeta(final: false); } } catch (Exception ex) { Plugin.Log.LogError((object)("Recording error, stopping: " + ex)); StopRecording("error"); } } private void Tick(float t) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) BinaryWriter writer = _writer; writer.Write((byte)1); writer.Write(t); if (t >= _nextScan) { _nextScan = t + 0.5f; Scan(); VoiceCapture.RefreshMappings(); } bool flag = t >= _nextSlow; if (flag) { _nextSlow = t + 0.5f; } foreach (TrackedEntity value in _entities.Values) { if (!value.IsAlive) { continue; } value.CaptureState(writer); if (value.Kind == EntityKind.Player) { value.CapturePlayer(writer); PlayerControllerB val = (PlayerControllerB)value.Source; if (val.isPlayerDead && !value.WasDead) { _deaths++; writer.Write((byte)13); writer.Write($"{val.playerUsername} died ({val.causeOfDeath})"); } value.WasDead = val.isPlayerDead; if (!string.IsNullOrEmpty(val.playerUsername) && (val.isPlayerControlled || val.isPlayerDead)) { _playerNames.Add(val.playerUsername); } } if (flag) { value.CaptureSlow(writer, t); } } WriteWorld(writer); if (flag) { WriteDoors(writer, t); } } private void Track(Component c, Func<int, TrackedEntity> factory = null) { if ((Object)(object)c == (Object)null || _entities.ContainsKey(c)) { return; } TrackedEntity trackedEntity = ((factory != null) ? factory(_nextId) : TrackedEntity.Create(_nextId, c)); if (trackedEntity != null) { _nextId++; _entities[c] = trackedEntity; if ((Object)(object)trackedEntity.Root != (Object)null) { _byRoot[trackedEntity.Root] = trackedEntity; } if (trackedEntity.Kind == EntityKind.Player && trackedEntity.PlayerIndex >= 0) { _playerIndexToEntity[trackedEntity.PlayerIndex] = trackedEntity.Id; } trackedEntity.WriteSpawn(_writer); } } private void Scan() { List<Component> list = null; foreach (KeyValuePair<Component, TrackedEntity> entity in _entities) { if ((Object)(object)entity.Key == (Object)null || !entity.Value.IsAlive) { (list ?? (list = new List<Component>())).Add(entity.Key); } } if (list != null) { foreach (Component item in list) { TrackedEntity trackedEntity = _entities[item]; trackedEntity.Dispose(); _writer.Write((byte)3); _writer.Write(trackedEntity.Id); _entities.Remove(item); if ((Object)(object)trackedEntity.Root != (Object)null) { _byRoot.Remove(trackedEntity.Root); } } } StartOfRound instance = StartOfRound.Instance; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && (val.isPlayerControlled || val.isPlayerDead)) { Track((Component)(object)val); } } if ((Object)(object)RoundManager.Instance != (Object)null) { foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies) { if ((Object)(object)spawnedEnemy != (Object)null) { Track((Component)(object)spawnedEnemy); } } } EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>(); foreach (EnemyAI c in array) { Track((Component)(object)c); } GrabbableObject[] array2 = Object.FindObjectsOfType<GrabbableObject>(); foreach (GrabbableObject c2 in array2) { Track((Component)(object)c2); } DeadBodyInfo[] array3 = Object.FindObjectsOfType<DeadBodyInfo>(); foreach (DeadBodyInfo c3 in array3) { Track((Component)(object)c3); } VehicleController[] array4 = Object.FindObjectsOfType<VehicleController>(); foreach (VehicleController c4 in array4) { Track((Component)(object)c4); } AutoParentToShip[] array5 = Object.FindObjectsOfType<AutoParentToShip>(); foreach (AutoParentToShip c5 in array5) { Track((Component)(object)c5); } Transform ship = (((Object)(object)instance.shipAnimator != (Object)null) ? ((Component)instance.shipAnimator).transform : instance.elevatorTransform); if ((Object)(object)ship != (Object)null) { Track((Component)(object)ship, (int id) => TrackedEntity.CreateShip(id, ship)); } foreach (SceneProps.Prop item2 in SceneProps.FindAll()) { SceneProps.Prop p = item2; Track(p.Source, (int id) => TrackedEntity.CreateScene(id, p.Source, p.Root, IO.PositionKey(p.Source.transform.position))); } } public void OnSound(AudioSource src, AudioClip clip, SoundAction action, float volumeScale) { if (!IsRecording || (Object)(object)src == (Object)null) { return; } try { if (!_soundIds.TryGetValue(src, out var value)) { if (action == SoundAction.Stop) { return; } value = DefineSoundSource(src); _soundIds[src] = value; } if (value != 0 && (action == SoundAction.Stop || (!((Object)(object)clip == (Object)null) && !string.IsNullOrEmpty(((Object)clip).name) && !(((Object)clip).name == "AudioReceiver")))) { string value2 = ((action != SoundAction.Stop) ? ((Object)clip).name : null); float value3 = ((action == SoundAction.OneShot) ? (volumeScale * src.volume) : src.volume); float pitch = src.pitch; bool loop = src.loop; _writer.Write((byte)15); _writer.Write(value); _writer.Write((byte)action); if (action != SoundAction.Stop) { _writer.Write(value2); _writer.Write(value3); _writer.Write(pitch); _writer.Write(loop); } } } catch (Exception ex) { Plugin.Log.LogDebug((object)("Sound capture skipped: " + ex.Message)); } } private TrackedEntity OwnerOf(Transform t) { Transform val = t; while ((Object)(object)val != (Object)null) { if (_byRoot.TryGetValue(val, out var value)) { return value; } val = val.parent; } return null; } private int DefineSoundSource(AudioSource src) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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) if ((Object)(object)((Component)src).GetComponent<SamplePlaybackComponent>() != (Object)null) { return 0; } TrackedEntity trackedEntity = OwnerOf(((Component)src).transform); if (trackedEntity == null) { Component val = (Component)(((Component)src).GetComponentInParent<EnemyAI>() ?? ((Component)src).GetComponentInParent<GrabbableObject>() ?? ((Component)src).GetComponentInParent<PlayerControllerB>() ?? ((object)((Component)src).GetComponentInParent<DeadBodyInfo>()) ?? ((object)((Component)src).GetComponentInParent<VehicleController>())); if ((Object)(object)val != (Object)null) { Track(val); trackedEntity = OwnerOf(((Component)src).transform); } } if (trackedEntity == null) { if (src.spatialBlend < 0.5f) { return 0; } if ((Object)(object)((Component)src).GetComponentInParent<AnimatedObjectTrigger>() != (Object)null) { return 0; } } string value = ((trackedEntity != null) ? (Hierarchy.PathOf(trackedEntity.Root, ((Component)src).transform) ?? "") : ""); AudioSource[] components = ((Component)src).GetComponents<AudioSource>(); int val2 = Math.Max(0, Array.IndexOf(components, src)); Vector3 position = ((Component)src).transform.position; float spatialBlend = src.spatialBlend; float minDistance = src.minDistance; float maxDistance = src.maxDistance; byte value2 = (byte)src.rolloffMode; string value3 = (((Object)(object)src.outputAudioMixerGroup != (Object)null) ? ((Object)src.outputAudioMixerGroup).name : ""); int num = _nextSoundId++; _writer.Write((byte)14); _writer.Write(num); _writer.Write(trackedEntity?.Id ?? (-1)); _writer.Write(value); _writer.Write((byte)Math.Min(val2, 255)); _writer.Write(position); _writer.Write(spatialBlend); _writer.Write(minDistance); _writer.Write(maxDistance); _writer.Write(value2); _writer.Write(value3); return num; } private void WriteWorld(BinaryWriter w) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; TimeOfDay instance2 = TimeOfDay.Instance; Transform val = (((Object)(object)instance.shipAnimator != (Object)null) ? ((Component)instance.shipAnimator).transform : instance.elevatorTransform); bool flag = (Object)(object)instance.shipDoorsAnimator != (Object)null && instance.shipDoorsAnimator.GetBool("Closed"); bool flag2 = (Object)(object)instance.shipRoomLights != (Object)null && instance.shipRoomLights.areLightsOn; float num = (((Object)(object)instance2 != (Object)null) ? instance2.globalTime : 0f); float value = (((Object)(object)instance2 != (Object)null) ? instance2.normalizedTimeOfDay : 0f); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : Vector3.zero); Quaternion val3 = (((Object)(object)val != (Object)null) ? val.rotation : Quaternion.identity); string text = $"{num:F2}|{val2.x:F3},{val2.y:F3},{val2.z:F3}|{val3.x:F4},{val3.y:F4},{val3.z:F4},{val3.w:F4}|{flag}|{flag2}"; if (!(text == _lastWorld)) { _lastWorld = text; w.Write((byte)10); w.Write(num); w.Write(value); w.Write(val2); w.Write(val3); w.Write(flag); w.Write(flag2); } } private void WriteDoors(BinaryWriter w, float t) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) if (t >= _nextDoorRefresh) { _nextDoorRefresh = t + 10f; HashSet<AnimatedObjectTrigger> hashSet = new HashSet<AnimatedObjectTrigger>(_triggers.Select(((AnimatedObjectTrigger trigger, long key) x) => x.trigger)); Transform val = (((Object)(object)StartOfRound.Instance.shipAnimator != (Object)null) ? ((Component)StartOfRound.Instance.shipAnimator).transform : null); AnimatedObjectTrigger[] array = Object.FindObjectsOfType<AnimatedObjectTrigger>(); TerminalAccessibleObject val3 = default(TerminalAccessibleObject); foreach (AnimatedObjectTrigger val2 in array) { if (((Object)(object)val == (Object)null || !((Component)val2).transform.IsChildOf(val)) && !hashSet.Contains(val2) && (!((Component)val2).TryGetComponent<TerminalAccessibleObject>(ref val3) || !val3.isBigDoor)) { _triggers.Add((val2, IO.PositionKey(((Component)val2).transform.position))); } } HashSet<TerminalAccessibleObject> hashSet2 = new HashSet<TerminalAccessibleObject>(_bigDoors.Select(((TerminalAccessibleObject door, long key) x) => x.door)); TerminalAccessibleObject[] array2 = Object.FindObjectsOfType<TerminalAccessibleObject>(); foreach (TerminalAccessibleObject val4 in array2) { if (val4.isBigDoor && !hashSet2.Contains(val4)) { _bigDoors.Add((val4, IO.PositionKey(((Component)val4).transform.position))); }