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 RepoEnemyWatch v0.7.3
RepoEnemyWatch.dll
Decompiled 6 hours agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace RepoEnemyWatch; internal static class DespawnProgress { internal static float Remaining(float active, float pause, bool close, float elapsed) { if (active <= 0f) { return 0f; } elapsed = Math.Max(0f, elapsed); pause = Math.Max(0f, pause); float num = Math.Max(0f, pause - elapsed); float num2 = (close ? 0f : Math.Max(0f, elapsed - pause)); return Math.Max(0f, active - num2) + num; } internal static bool Paused(float pause, bool close, float elapsed) { if (close) { return Math.Max(0f, pause - Math.Max(0f, elapsed)) <= 0f; } return false; } internal static float Fraction(float active, float pause, bool close, float elapsed, float budget) { if (!(budget <= 0f)) { return Math.Max(0f, Math.Min(1f, Remaining(active, pause, close, elapsed) / budget)); } return 0f; } } public static class DisplayNames { private static readonly Dictionary<string, ConfigEntry<string>> Settings = new Dictionary<string, ConfigEntry<string>>(); private static readonly HashSet<string> BehaviourAliases = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "animal", "apexpredator", "duck", "banger", "bangers", "bang", "bella", "tricycle", "birthdayboy", "bowtie", "chef", "tumbler", "cleanupcrew", "bombthrower", "clown", "beamer", "elsa", "gambit", "spinny", "gnome", "headgrab", "headgrabber", "headman", "head", "hearthugger", "hidden", "huntsman", "hunter", "loom", "shadow", "mentalist", "floater", "oogly", "oogley", "peeper", "ceilingeye", "reaper", "runner", "robe", "rugrat", "valuablethrower", "shadowchild", "thinman", "spewer", "slowmouth", "tick", "trudge", "slowwalker", "upscream", "pony", "snatcher", "whispral" }; internal static void Bind(ConfigFile config) { BindName(config, "animal", "Ползун"); BindName(config, "apexpredator", "Утка"); BindName(config, "banger", "Криперы"); BindName(config, "bella", "Велик"); BindName(config, "birthdayboy", "Туберкулезник"); BindName(config, "bowtie", "Воздухан"); BindName(config, "chef", "Жаба клава"); BindName(config, "cleanupcrew", "Многолиций"); BindName(config, "clown", "Клоун"); BindName(config, "elsa", "Псина"); BindName(config, "gambit", "Казик"); BindName(config, "gnome", "Террористы"); BindName(config, "headgrab", "Маскеровищик"); BindName(config, "headman", "Голова"); BindName(config, "hearthugger", "Сердцеедка"); BindName(config, "hidden", "Неведимка"); BindName(config, "huntsman", "Дед"); BindName(config, "loom", "Милфа"); BindName(config, "mentalist", "Патрик Джейн"); BindName(config, "oogly", "Муха"); BindName(config, "peeper", "Глаз"); BindName(config, "reaper", "Руки ножницы"); BindName(config, "robe", "Монашка"); BindName(config, "rugrat", "Пупс"); BindName(config, "shadowchild", "Ребенок"); BindName(config, "spewer", "Блевота"); BindName(config, "tick", "Клещ"); BindName(config, "trudge", "Танк"); BindName(config, "upscream", "Крикун"); BindName(config, "pony", "Хоббихорсинг"); BindName(config, "whispral", "Глюк"); } private static void BindName(ConfigFile config, string key, string defaultName) { Settings[key] = config.Bind<string>("Enemy Names", key, defaultName, "Your nickname for " + key + ". Leave blank to use " + defaultName + ". Changes only apply on your screen."); } internal static void MigrateSettings(ConfigFile config, ConfigEntry<string> aliveStatus) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; try { ConfigEntry<bool> val = config.Bind<bool>("Internal", "MigratedEnglishSettings", false, new ConfigDescription("Whether settings from the original menu have been migrated.", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); if (val.Value) { return; } foreach (KeyValuePair<string, ConfigEntry<string>> setting in Settings) { string oldDefault = null; switch (setting.Key) { case "cleanupcrew": oldDefault = "Пидор"; break; case "huntsman": oldDefault = "Гитлер"; break; case "rugrat": oldDefault = "Пиздюк"; break; } MigrateText(config, "Имена мобов", setting.Key, setting.Value, oldDefault); } MigrateText(config, "Статусы", "Живой моб", aliveStatus, null); val.Value = true; if (saveOnConfigSet) { config.Save(); } } finally { config.SaveOnConfigSet = saveOnConfigSet; } } private static void MigrateText(ConfigFile config, string oldSection, string oldKey, ConfigEntry<string> setting, string oldDefault) { ConfigEntry<string> val = config.Bind<string>(oldSection, oldKey, (string)null, (ConfigDescription)null); string value = val.Value; config.Remove(((ConfigEntryBase)val).Definition); if (value != null && !string.Equals(value, oldDefault, StringComparison.Ordinal) && string.Equals(setting.Value, (string)((ConfigEntryBase)setting).DefaultValue, StringComparison.Ordinal)) { setting.Value = value; } } private static string Name(string key, string defaultName) { if (!Settings.TryGetValue(key, out var value) || string.IsNullOrWhiteSpace(value.Value)) { return defaultName; } return value.Value.Trim(); } public static string GetDisplayName(string original) { if (string.IsNullOrEmpty(original)) { return "?"; } string text = original.Replace("(Clone)", "").Trim().ToLowerInvariant(); if (text.StartsWith("enemy - ")) { text = text.Substring(8); } if (text.StartsWith("enemy.")) { text = text.Substring(6); } switch (text.Replace("_", "").Replace(" ", "")) { case "animal": return Name("animal", "Ползун"); case "apexpredator": case "duck": return Name("apexpredator", "Утка"); case "banger": case "bangers": case "bang": return Name("banger", "Криперы"); case "bella": case "tricycle": return Name("bella", "Велик"); case "birthdayboy": return Name("birthdayboy", "Туберкулезник"); case "bowtie": return Name("bowtie", "Воздухан"); case "chef": case "tumbler": return Name("chef", "Жаба клава"); case "cleanupcrew": case "bombthrower": return Name("cleanupcrew", "Многолиций"); case "clown": case "beamer": return Name("clown", "Клоун"); case "elsa": return Name("elsa", "Псина"); case "gambit": case "spinny": return Name("gambit", "Казик"); case "gnome": return Name("gnome", "Террористы"); case "headgrab": case "headgrabber": return Name("headgrab", "Маскеровищик"); case "headman": case "head": return Name("headman", "Голова"); case "hearthugger": return Name("hearthugger", "Сердцеедка"); case "hidden": return Name("hidden", "Неведимка"); case "huntsman": case "hunter": return Name("huntsman", "Дед"); case "loom": case "shadow": return Name("loom", "Милфа"); case "mentalist": case "floater": return Name("mentalist", "Патрик Джейн"); case "oogly": case "oogley": return Name("oogly", "Муха"); case "peeper": case "ceilingeye": return Name("peeper", "Глаз"); case "reaper": case "runner": return Name("reaper", "Руки ножницы"); case "robe": return Name("robe", "Монашка"); case "rugrat": case "valuablethrower": return Name("rugrat", "Пупс"); case "shadowchild": case "thinman": return Name("shadowchild", "Ребенок"); case "spewer": case "slowmouth": return Name("spewer", "Блевота"); case "tick": return Name("tick", "Клещ"); case "trudge": case "slowwalker": return Name("trudge", "Танк"); case "upscream": return Name("upscream", "Крикун"); case "pony": case "snatcher": return Name("pony", "Хоббихорсинг"); case "whispral": return Name("whispral", "Глюк"); default: return original; } } internal static bool TryGetBehaviourName(string typeName, out string display) { display = null; if (string.IsNullOrEmpty(typeName) || !typeName.StartsWith("Enemy", StringComparison.Ordinal) || typeName.Length <= 5) { return false; } string text = typeName.Substring(5); string displayName = GetDisplayName(text); if (!BehaviourAliases.Contains(text.Replace("_", "").Replace(" ", ""))) { return false; } display = displayName; return true; } } [BepInPlugin("local.repo.enemywatch", "Enemy Watch", "0.7.3")] public sealed class Plugin : BaseUnityPlugin { private sealed class Row { internal EnemyParent Parent; internal string Name; internal bool Spawned; internal bool Dead; internal bool TimerKnown; internal float Remaining; internal int ViewId; internal bool BarKnown; internal bool PlayerClose; internal float ActiveRemaining; internal float InitialPause; internal float ActiveBudget; internal float SampleRate; internal double SampleAt; internal RowSortKey SortKey; } private const string Capability = "local.repo.enemywatch.protocol"; public const string Id = "local.repo.enemywatch"; private const string DefaultAliveStatus = "ЖИВЧИК"; private const string DeadStatus = "ПОМЕР"; private readonly MissionClock levelClock = new MissionClock(); private double levelClockSentAt = double.NegativeInfinity; private double levelClockAtSend; private float levelClockRate; private readonly Dictionary<int, string> subscribers = new Dictionary<int, string>(); private readonly Dictionary<int, TimerSample> remote = new Dictionary<int, TimerSample>(); private string nonce = Guid.NewGuid().ToString("N"); private Room syncRoom; private int syncMaster; private double remoteSentAt = double.NegativeInfinity; private float remoteRate; private float helloAt; private float sendAt; private float lastNetworkError; internal static readonly HashSet<int> Deaths = new HashSet<int>(); internal static readonly Dictionary<int, float> LiveBudgets = new Dictionary<int, float>(); private readonly Dictionary<int, Row> rows = new Dictionary<int, Row>(); private readonly List<Row> ordered = new List<Row>(); private Harmony harmony; private ConfigEntry<KeyCode> toggle; private ConfigEntry<KeyCode> next; private ConfigEntry<KeyCode> previous; private ConfigEntry<bool> show; private ConfigEntry<string> aliveStatus; private float scanAt; private int page; private GUIStyle label; private GUIStyle aliveStatusLabel; private Font displayFont; private GUIStyle clockLabel; private Font clockFont; private string error; private bool reportedError; private void UpdateLevelClock() { bool flag = InMission(); if (levelClock.Tick(flag, flag ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0, PhotonNetwork.CurrentRoom, Time.deltaTime)) { ResetSync(); } if (!flag) { levelClockSentAt = double.NegativeInfinity; } else if (RemoteLevelClockFresh()) { levelClock.Synchronize(LevelClockProtocol.Project(levelClockAtSend, levelClockSentAt, PhotonNetwork.Time, levelClockRate)); } } private bool RemoteLevelClockFresh() { if (!SemiFunc.IsMasterClientOrSingleplayer() && PhotonNetwork.InRoom && object.ReferenceEquals(syncRoom, PhotonNetwork.CurrentRoom) && PhotonNetwork.MasterClient != null && PhotonNetwork.MasterClient.ActorNumber == syncMaster && HasMod(PhotonNetwork.MasterClient)) { return PhotonNetwork.Time - levelClockSentAt <= 4.0; } return false; } private double LevelSeconds() { if (!RemoteLevelClockFresh()) { return levelClock.Elapsed; } return LevelClockProtocol.Project(levelClockAtSend, levelClockSentAt, PhotonNetwork.Time, levelClockRate); } private void ResetSync() { subscribers.Clear(); remote.Clear(); nonce = Guid.NewGuid().ToString("N"); remoteSentAt = double.NegativeInfinity; levelClockSentAt = double.NegativeInfinity; helloAt = 0f; sendAt = 0f; } private static bool HasMod(Player player) { if (player != null) { return object.Equals(player.CustomProperties[(object)"local.repo.enemywatch.protocol"], 2); } return false; } private static string SceneKey() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name; } private void NetworkTick() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) Room currentRoom = PhotonNetwork.CurrentRoom; int num = ((PhotonNetwork.MasterClient != null) ? PhotonNetwork.MasterClient.ActorNumber : 0); if (!object.ReferenceEquals(currentRoom, syncRoom) || num != syncMaster) { ResetSync(); syncRoom = currentRoom; syncMaster = num; } if (PhotonNetwork.InRoom) { if (!HasMod(PhotonNetwork.LocalPlayer)) { Player localPlayer = PhotonNetwork.LocalPlayer; Hashtable val = new Hashtable(); ((Dictionary<object, object>)(object)val).Add((object)"local.repo.enemywatch.protocol", (object)2); localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); } if (InMission() && !PhotonNetwork.IsMasterClient && HasMod(PhotonNetwork.MasterClient) && !(Time.unscaledTime < helloAt)) { helloAt = Time.unscaledTime + 2f; object[] obj = new object[4] { "local.repo.enemywatch/timers/2", "subscribe", nonce, SceneKey() }; RaiseEventOptions val2 = new RaiseEventOptions(); val2.TargetActors = new int[1] { num }; PhotonNetwork.RaiseEvent((byte)173, (object)obj, val2, SendOptions.SendReliable); } } } private void ReceiveEvent(EventData evt) { if (evt.Code != 173 || !PhotonNetwork.InRoom || !InMission()) { return; } try { if (!(evt.CustomData is object[] array) || array.Length < 2 || !object.Equals(array[0], "local.repo.enemywatch/timers/2")) { return; } if (PhotonNetwork.IsMasterClient) { Player player = PhotonNetwork.CurrentRoom.GetPlayer(evt.Sender, false); if (array.Length == 4 && object.Equals(array[1], "subscribe") && array[2] is string && ((string)array[2]).Length == 32 && object.Equals(array[3], SceneKey()) && HasMod(player)) { subscribers[evt.Sender] = (string)array[2]; } return; } int num = ((PhotonNetwork.MasterClient != null) ? PhotonNetwork.MasterClient.ActorNumber : 0); if (num != syncMaster || !object.ReferenceEquals(syncRoom, PhotonNetwork.CurrentRoom)) { return; } double sentAt2; float rate2; TimerSample[] samples; if (object.Equals(array[1], "levelclock")) { if (levelClock.Active && LevelClockProtocol.TryDecode(array, nonce, SceneKey(), evt.Sender, num, PhotonNetwork.Time, levelClockSentAt, out var sentAt, out var elapsed, out var rate)) { levelClockSentAt = sentAt; levelClockAtSend = elapsed; levelClockRate = rate; levelClock.Synchronize(LevelClockProtocol.Project(elapsed, sentAt, PhotonNetwork.Time, rate)); } } else if (TimerProtocol.TryDecode(array, nonce, SceneKey(), evt.Sender, num, PhotonNetwork.Time, remoteSentAt, out sentAt2, out rate2, out samples)) { remote.Clear(); TimerSample[] array2 = samples; foreach (TimerSample timerSample in array2) { remote.Add(timerSample.ViewId, timerSample); } remoteSentAt = sentAt2; remoteRate = rate2; } } catch (Exception ex) { LogNetworkError(ex); } } private void SendSnapshots() { //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient || subscribers.Count == 0 || Time.unscaledTime < sendAt) { return; } sendAt = Time.unscaledTime + 0.5f; try { List<TimerSample> list = new List<TimerSample>(); foreach (Row item in ordered) { if (Object.op_Implicit((Object)(object)item.Parent) && item.ViewId > 0) { list.Add(new TimerSample { ViewId = item.ViewId, Remaining = item.Remaining, Spawned = item.Spawned, Dead = item.Dead, ActiveRemaining = item.ActiveRemaining, InitialPause = item.InitialPause, ActiveBudget = item.ActiveBudget, PlayerClose = item.PlayerClose }); } } List<int> list2 = new List<int>(); foreach (KeyValuePair<int, string> subscriber in subscribers) { Player player = PhotonNetwork.CurrentRoom.GetPlayer(subscriber.Key, false); if (player == null || !HasMod(player)) { list2.Add(subscriber.Key); continue; } object[] array = TimerProtocol.Encode(subscriber.Value, SceneKey(), PhotonNetwork.Time, Time.timeScale, list.ToArray()); RaiseEventOptions val = new RaiseEventOptions(); val.TargetActors = new int[1] { subscriber.Key }; PhotonNetwork.RaiseEvent((byte)173, (object)array, val, SendOptions.SendReliable); object[] array2 = LevelClockProtocol.Encode(subscriber.Value, SceneKey(), PhotonNetwork.Time, levelClock.Elapsed, Time.timeScale); RaiseEventOptions val2 = new RaiseEventOptions(); val2.TargetActors = new int[1] { subscriber.Key }; PhotonNetwork.RaiseEvent((byte)173, (object)array2, val2, SendOptions.SendReliable); } foreach (int item2 in list2) { subscribers.Remove(item2); } } catch (Exception ex) { LogNetworkError(ex); } } private void UpdateTimer(Row row) { row.TimerKnown = false; row.Remaining = 0f; row.BarKnown = false; row.ActiveRemaining = 0f; row.InitialPause = 0f; row.ActiveBudget = 0f; if (SemiFunc.IsMasterClientOrSingleplayer()) { row.TimerKnown = !row.Spawned; if (row.TimerKnown) { row.Remaining = Mathf.Max(0f, Convert.ToSingle(Read(row.Parent, "DespawnedTimer"))); } if (row.Spawned && !row.Dead) { row.ActiveRemaining = Mathf.Max(0f, Convert.ToSingle(Read(row.Parent, "SpawnedTimer"))); row.InitialPause = Mathf.Max(0f, Convert.ToSingle(Read(row.Parent, "spawnedTimerPauseTimer"))); row.PlayerClose = (bool)Read(row.Parent, "playerClose"); int instanceID = ((Object)row.Parent).GetInstanceID(); LiveBudgets.TryGetValue(instanceID, out var value); row.ActiveBudget = Mathf.Max(1f, Mathf.Max(value, DespawnProgress.Remaining(row.ActiveRemaining, row.InitialPause, close: false, 0f))); LiveBudgets[instanceID] = row.ActiveBudget; row.BarKnown = true; } return; } int num = ((PhotonNetwork.MasterClient != null) ? PhotonNetwork.MasterClient.ActorNumber : 0); if (num == syncMaster && HasMod(PhotonNetwork.MasterClient) && !(PhotonNetwork.Time - remoteSentAt > 4.0) && remote.TryGetValue(row.ViewId, out var value2) && row.Spawned == value2.Spawned) { row.Dead = row.Dead || value2.Dead; row.TimerKnown = !row.Spawned; if (row.TimerKnown) { row.Remaining = TimerProtocol.Countdown(value2.Remaining, remoteSentAt, PhotonNetwork.Time, remoteRate); } if (row.Spawned && !row.Dead && value2.ActiveBudget > 0f) { row.ActiveRemaining = value2.ActiveRemaining; row.InitialPause = value2.InitialPause; row.PlayerClose = value2.PlayerClose; row.ActiveBudget = value2.ActiveBudget; row.SampleAt = remoteSentAt; row.SampleRate = remoteRate; row.BarKnown = true; } } } private bool BarFresh(Row row) { if (SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (PhotonNetwork.InRoom && object.ReferenceEquals(syncRoom, PhotonNetwork.CurrentRoom) && PhotonNetwork.MasterClient != null && PhotonNetwork.MasterClient.ActorNumber == syncMaster && HasMod(PhotonNetwork.MasterClient)) { return PhotonNetwork.Time - row.SampleAt <= 4.0; } return false; } private static void BarState(Row row, out float active, out float pause, out bool close, out float elapsed) { active = row.ActiveRemaining; pause = row.InitialPause; close = row.PlayerClose; elapsed = Mathf.Max(0f, (float)(PhotonNetwork.Time - row.SampleAt)) * row.SampleRate; if (SemiFunc.IsMasterClientOrSingleplayer()) { active = Mathf.Max(0f, Convert.ToSingle(Read(row.Parent, "SpawnedTimer"))); pause = Mathf.Max(0f, Convert.ToSingle(Read(row.Parent, "spawnedTimerPauseTimer"))); close = (bool)Read(row.Parent, "playerClose"); elapsed = 0f; } } internal static void RememberLiveBudget(EnemyParent parent) { if (SemiFunc.IsMasterClientOrSingleplayer()) { float active = Mathf.Max(0f, Convert.ToSingle(Read(parent, "SpawnedTimer"))); float pause = Mathf.Max(0f, Convert.ToSingle(Read(parent, "spawnedTimerPauseTimer"))); LiveBudgets[((Object)parent).GetInstanceID()] = Mathf.Max(1f, DespawnProgress.Remaining(active, pause, close: false, 0f)); } } private void LogNetworkError(Exception ex) { if (!(Time.unscaledTime - lastNetworkError < 10f)) { lastNetworkError = Time.unscaledTime; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Enemy Watch timer sync: " + ex.Message)); } } private static string ResolveDisplayName(EnemyParent parent, string original) { object obj = Read(parent, "Enemy"); Component val = (Component)((obj is Component) ? obj : null); if (Object.op_Implicit((Object)(object)val)) { MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2) && DisplayNames.TryGetBehaviourName(((object)val2).GetType().Name, out var display)) { return display; } } } return DisplayNames.GetDisplayName(original); } internal static object Read(object obj, string name) { if (obj == null) { return null; } FieldInfo fieldInfo = AccessTools.Field(obj.GetType(), name); if (fieldInfo == null) { throw new MissingFieldException(obj.GetType().Name, name); } return fieldInfo.GetValue(obj); } internal static EnemyHealth Health(EnemyParent parent) { object obj = Read(parent, "Enemy"); if (obj != null) { object obj2 = Read(obj, "Health"); return (EnemyHealth)((obj2 is EnemyHealth) ? obj2 : null); } return null; } private void Awake() { //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown DisplayNames.Bind(((BaseUnityPlugin)this).Config); toggle = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Toggle", (KeyCode)287, "Show or hide the enemy panel."); next = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "NextPage", (KeyCode)281, "Next page."); previous = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "PreviousPage", (KeyCode)280, "Previous page."); show = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "Visible", true, "Panel visible."); aliveStatus = ((BaseUnityPlugin)this).Config.Bind<string>("Statuses", "Alive Monster", "ЖИВЧИК", "Label shown for living monsters. Leave blank to use the default."); DisplayNames.MigrateSettings(((BaseUnityPlugin)this).Config, aliveStatus); try { string[] array = new string[8] { "Enemy", "Spawned", "SetupDone", "enemyName", "DespawnedTimer", "SpawnedTimer", "spawnedTimerPauseTimer", "playerClose" }; foreach (string text in array) { if (AccessTools.Field(typeof(EnemyParent), text) == null) { throw new MissingFieldException("EnemyParent", text); } } harmony = new Harmony("local.repo.enemywatch"); harmony.PatchAll(typeof(Plugin).Assembly); SceneManager.activeSceneChanged += SceneChanged; PhotonNetwork.NetworkingClient.EventReceived += ReceiveEvent; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Enemy Watch 0.7.3 ready. F6: toggle. Living enemies sorted by despawn bar fullness, nearest respawn first. Host timer sharing unchanged."); } catch (Exception ex) { error = "Несовместимая версия игры — см. BepInEx/LogOutput.log"; if (harmony != null) { harmony.UnpatchSelf(); } ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private void SceneChanged(Scene oldScene, Scene newScene) { rows.Clear(); ordered.Clear(); Deaths.Clear(); page = 0; scanAt = 0f; LiveBudgets.Clear(); levelClock.Reset(); ResetSync(); } private void OnDestroy() { SceneManager.activeSceneChanged -= SceneChanged; PhotonNetwork.NetworkingClient.EventReceived -= ReceiveEvent; if (Object.op_Implicit((Object)(object)displayFont)) { Object.Destroy((Object)(object)displayFont); } if (Object.op_Implicit((Object)(object)clockFont)) { Object.Destroy((Object)(object)clockFont); } if (harmony != null) { harmony.UnpatchSelf(); } Deaths.Clear(); LiveBudgets.Clear(); } private void Update() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (error == null) { UpdateLevelClock(); } if (Input.GetKeyDown(toggle.Value)) { show.Value = !show.Value; } if (Input.GetKeyDown(next.Value)) { page++; } if (Input.GetKeyDown(previous.Value)) { page = Math.Max(0, page - 1); } if (error != null || Time.unscaledTime < scanAt) { return; } scanAt = Time.unscaledTime + 0.25f; try { try { NetworkTick(); } catch (Exception ex) { LogNetworkError(ex); } if (!InMission()) { rows.Clear(); ordered.Clear(); page = 0; } else { Scan(); SendSnapshots(); } } catch (Exception ex2) { error = "Ошибка чтения состояния — см. BepInEx/LogOutput.log"; if (!reportedError) { ((BaseUnityPlugin)this).Logger.LogError((object)ex2); reportedError = true; } } } private void Scan() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) HashSet<int> hashSet = new HashSet<int>(); EnemyParent[] array = Object.FindObjectsOfType<EnemyParent>(true); foreach (EnemyParent val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } Scene scene2 = ((Component)val).gameObject.scene; if (((Scene)(ref scene2)).isLoaded && (bool)Read(val, "SetupDone")) { int instanceID = ((Object)val).GetInstanceID(); hashSet.Add(instanceID); if (!rows.TryGetValue(instanceID, out var value)) { Row row = new Row(); row.Parent = val; value = row; rows.Add(instanceID, value); } bool spawned = (bool)Read(val, "Spawned"); value.Spawned = spawned; value.Name = Read(val, "enemyName") as string; if (string.IsNullOrEmpty(value.Name)) { value.Name = ((Object)val).name.Replace("(Clone)", ""); } value.Name = ResolveDisplayName(val, value.Name); PhotonView component = ((Component)val).GetComponent<PhotonView>(); value.ViewId = (Object.op_Implicit((Object)(object)component) ? component.ViewID : 0); EnemyHealth val2 = Health(val); value.Dead = Object.op_Implicit((Object)(object)val2) && (Deaths.Contains(((Object)val2).GetInstanceID()) || (SemiFunc.IsMasterClientOrSingleplayer() && (bool)Read(val2, "dead"))); } } List<int> list = new List<int>(); foreach (KeyValuePair<int, Row> row2 in rows) { if (!hashSet.Contains(row2.Key)) { list.Add(row2.Key); } } foreach (int item in list) { rows.Remove(item); } foreach (Row value2 in rows.Values) { UpdateTimer(value2); value2.SortKey = new RowSortKey { Spawned = value2.Spawned, Dead = value2.Dead, TimerKnown = value2.TimerKnown, Remaining = value2.Remaining, BarKnown = (value2.Spawned && !value2.Dead && value2.BarKnown && BarFresh(value2)) }; if (value2.SortKey.BarKnown) { BarState(value2, out var active, out var pause, out var close, out var elapsed); value2.SortKey.Fraction = DespawnProgress.Fraction(active, pause, close, elapsed, value2.ActiveBudget); } } ordered.Clear(); ordered.AddRange(rows.Values); ordered.Sort(delegate(Row a, Row b) { int num = RowOrder.Compare(a.SortKey, b.SortKey); if (num != 0) { return num; } num = string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); return (num == 0) ? ((Object)a.Parent).GetInstanceID().CompareTo(((Object)b.Parent).GetInstanceID()) : num; }); if (ordered.Count == 0) { Deaths.Clear(); } } private static string Duration(float seconds) { int num = Mathf.CeilToInt(Mathf.Max(0f, seconds)); return (num / 60).ToString("00") + ":" + (num % 60).ToString("00"); } private static bool InMission() { if (Object.op_Implicit((Object)(object)RunManager.instance) && Object.op_Implicit((Object)(object)RunManager.instance.levelCurrent) && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && SemiFunc.RunIsLevel()) { return SemiFunc.LevelGenDone(); } return false; } private static void DrawFrame(Rect rect, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture); } private void OnGUI() { //IL_0824: Unknown result type (might be due to invalid IL or missing references) //IL_082b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Expected O, but got Unknown //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Expected O, but got Unknown //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_0777: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Unknown result type (might be due to invalid IL or missing references) if (!show.Value || error != null || !InMission()) { return; } if (label == null) { displayFont = Font.CreateDynamicFontFromOSFont(new string[3] { "Comic Sans MS", "Trebuchet MS", "Arial" }, 15); GUIStyle val = new GUIStyle(GUI.skin.label); val.font = displayFont; val.fontStyle = (FontStyle)1; val.fontSize = 15; val.richText = false; val.wordWrap = false; val.padding = new RectOffset(0, 0, 0, 0); val.alignment = (TextAnchor)3; label = val; GUIStyle val2 = new GUIStyle(label); val2.clipping = (TextClipping)1; aliveStatusLabel = val2; clockFont = Font.CreateDynamicFontFromOSFont(new string[3] { "Bahnschrift", "Consolas", "Arial" }, 20); GUIStyle val3 = new GUIStyle(label); val3.font = clockFont; val3.fontStyle = (FontStyle)1; val3.fontSize = 20; val3.alignment = (TextAnchor)4; clockLabel = val3; } float num = Mathf.Clamp((float)Screen.height / 900f, 0.65f, 1.6f); Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); try { float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; int num4 = Math.Max(1, Math.Min(16, Mathf.FloorToInt((num3 - 84f) / 28f))); int num5 = Math.Max(1, (ordered.Count + num4 - 1) / num4); page = Mathf.Clamp(page, 0, num5 - 1); int num6 = Math.Min(num4, ordered.Count - page * num4); float num7 = 0f; for (int i = 0; i < ordered.Count; i++) { num7 = Mathf.Max(num7, label.CalcSize(new GUIContent(ordered[i].Name)).x); } num7 = Mathf.Min(num7, Mathf.Min(180f, num2 * 0.35f)); string text = (string.IsNullOrWhiteSpace(aliveStatus.Value) ? "ЖИВЧИК" : aliveStatus.Value.Trim()); float x = aliveStatusLabel.CalcSize(new GUIContent(text)).x; float num8 = Mathf.Min(x, num2 * 0.4f); num8 = Mathf.Max(num8, label.CalcSize(new GUIContent("ПОМЕР")).x); num8 = Mathf.Max(num8, label.CalcSize(new GUIContent("000:00")).x) + 4f; string text2 = MissionClock.Format(LevelSeconds()); num8 = Mathf.Max(num8, clockLabel.CalcSize(new GUIContent(text2)).x + 4f); float num9 = num7 + 6f; float num10 = num8 + 6f; float num11 = 12f + num9 + 8f + num10; float num12 = 12f + (float)num6 * 28f; float num13 = num2 - num11 - 18f; float num14 = (num3 - num12) * 0.5f; Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(num13 + 6f + num9 + 8f, num14 - 32f, num10, 26f); GUI.color = new Color(0f, 0f, 0f, 0.65f); GUI.Label(new Rect(((Rect)(ref val4)).x + 1f, ((Rect)(ref val4)).y + 1f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text2, clockLabel); GUI.color = new Color(0.22f, 0.62f, 1f); GUI.Label(val4, text2, clockLabel); if (num6 == 0) { return; } GUI.color = new Color(0f, 0f, 0f, 0.04f); GUI.DrawTexture(new Rect(num13, num14, num11, num12), (Texture)(object)Texture2D.whiteTexture); DrawFrame(new Rect(num13, num14, num11, num12), new Color(0f, 0f, 0f, 0.55f)); GUI.color = new Color(0f, 0f, 0f, 0.45f); float num15 = num13 + 6f + num9 + 4f; GUI.DrawTexture(new Rect(num15, num14 + 1f, 1f, num12 - 2f), (Texture)(object)Texture2D.whiteTexture); Rect val5 = default(Rect); Rect val6 = default(Rect); for (int j = 0; j < num6; j++) { Row row = ordered[page * num4 + j]; if (!Object.op_Implicit((Object)(object)row.Parent)) { continue; } bool flag = row.Spawned && !row.Dead; string text3 = ((!row.Spawned) ? (row.TimerKnown ? Duration(row.Remaining) : "?") : (row.Dead ? "ПОМЕР" : text)); float num16 = num14 + 6f + (float)j * 28f; ((Rect)(ref val5))..ctor(num13 + 6f, num16, num9, 28f); ((Rect)(ref val6))..ctor(((Rect)(ref val5)).xMax + 8f, num16, num10, 28f); GUI.color = new Color(1f, 0.32f, 0.32f); GUI.Label(new Rect(((Rect)(ref val5)).x + 3f, num16, num7, ((Rect)(ref val5)).height), row.Name, label); GUI.color = (row.Spawned ? new Color(0.85f, 0.88f, 0.93f) : ((!row.TimerKnown) ? new Color(0.65f, 0.68f, 0.73f) : ((row.Remaining <= 10f) ? new Color(1f, 0.3f, 0.3f) : ((row.Remaining <= 30f) ? new Color(1f, 0.72f, 0.23f) : ((row.Remaining <= 60f) ? new Color(1f, 0.92f, 0.4f) : new Color(0.55f, 1f, 0.65f)))))); GUI.Label(new Rect(((Rect)(ref val6)).x + 3f, num16, num8, flag ? 21f : ((Rect)(ref val6)).height), text3, flag ? aliveStatusLabel : label); if (flag && row.BarKnown && BarFresh(row)) { BarState(row, out var active, out var pause, out var close, out var elapsed); float num17 = DespawnProgress.Fraction(active, pause, close, elapsed, row.ActiveBudget); float num18 = ((Rect)(ref val6)).x + 3f; GUI.color = new Color(0f, 0f, 0f, 0.25f); GUI.DrawTexture(new Rect(num18, num16 + 23f, num8, 3f), (Texture)(object)Texture2D.whiteTexture); GUI.color = (DespawnProgress.Paused(pause, close, elapsed) ? new Color(0.65f, 0.66f, 0.7f, 0.65f) : new Color(0.85f, 0.32f, 0.32f, 0.75f)); if (num17 > 0f) { GUI.DrawTexture(new Rect(num18, num16 + 23f, num8 * num17, 3f), (Texture)(object)Texture2D.whiteTexture); } } } } finally { GUI.matrix = matrix; GUI.color = color; } } } internal static class LevelClockProtocol { internal static object[] Encode(string nonce, string scene, double sentAt, double elapsed, float rate) { return new object[7] { "local.repo.enemywatch/timers/2", "levelclock", nonce, scene, sentAt, elapsed, rate }; } internal static bool TryDecode(object payload, string nonce, string scene, int sender, int master, double now, double lastSentAt, out double sentAt, out double elapsed, out float rate) { sentAt = (elapsed = 0.0); rate = 0f; object[] array = payload as object[]; if (master <= 0 || sender != master || array == null || array.Length != 7 || !object.Equals(array[0], "local.repo.enemywatch/timers/2") || !object.Equals(array[1], "levelclock") || !object.Equals(array[2], nonce) || !object.Equals(array[3], scene) || !(array[4] is double) || !(array[5] is double) || !(array[6] is float)) { return false; } sentAt = (double)array[4]; elapsed = (double)array[5]; rate = (float)array[6]; if (Finite(now) && Finite(sentAt) && sentAt >= lastSentAt && now - sentAt <= 4.0 && sentAt - now <= 1.0 && Finite(elapsed) && elapsed >= 0.0 && elapsed <= 2678400.0 && !float.IsNaN(rate) && !float.IsInfinity(rate) && rate >= 0f) { return rate <= 100f; } return false; } internal static double Project(double elapsed, double sentAt, double now, float rate) { return elapsed + Math.Max(0.0, now - sentAt) * (double)rate; } private static bool Finite(double value) { if (!double.IsNaN(value)) { return !double.IsInfinity(value); } return false; } } internal sealed class MissionClock { private int generation; private object room; internal bool Active { get; private set; } internal double Elapsed { get; private set; } internal void Reset() { Active = false; Elapsed = 0.0; generation = 0; room = null; } internal bool Tick(bool playableLevel, int generationId, object roomIdentity, double delta) { if (!playableLevel) { Reset(); return false; } if (!Active || generation != generationId || !object.ReferenceEquals(room, roomIdentity)) { Active = true; Elapsed = 0.0; generation = generationId; room = roomIdentity; return true; } if (delta >= 0.0 && !double.IsNaN(delta) && !double.IsInfinity(delta)) { Elapsed += delta; } return false; } internal void Synchronize(double seconds) { if (Active && seconds >= 0.0 && !double.IsNaN(seconds) && !double.IsInfinity(seconds)) { Elapsed = seconds; } } internal static string Format(double seconds) { if (double.IsNaN(seconds) || double.IsInfinity(seconds) || seconds < 0.0) { seconds = 0.0; } long num = (long)Math.Min(2147483647.0, Math.Floor(seconds)); if (num < 3600) { return (num / 60).ToString("00") + ":" + (num % 60).ToString("00"); } return num / 3600 + ":" + (num / 60 % 60).ToString("00") + ":" + (num % 60).ToString("00"); } } [HarmonyPatch(typeof(EnemyHealth), "DeathRPC")] internal static class DeathPatch { private static void Postfix(EnemyHealth __instance, PhotonMessageInfo __1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(__1)) { Plugin.Deaths.Add(((Object)__instance).GetInstanceID()); } } } [HarmonyPatch(typeof(EnemyParent), "SpawnRPC")] internal static class SpawnPatch { private static void Postfix(EnemyParent __instance, PhotonMessageInfo __0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(__0)) { Plugin.RememberLiveBudget(__instance); EnemyHealth val = Plugin.Health(__instance); if (Object.op_Implicit((Object)(object)val)) { Plugin.Deaths.Remove(((Object)val).GetInstanceID()); } } } } internal struct RowSortKey { internal bool Spawned; internal bool Dead; internal bool TimerKnown; internal bool BarKnown; internal float Remaining; internal float Fraction; } internal static class RowOrder { internal static int Compare(RowSortKey a, RowSortKey b) { int num = TimerProtocol.Priority(a.Spawned, a.TimerKnown).CompareTo(TimerProtocol.Priority(b.Spawned, b.TimerKnown)); if (num != 0) { return num; } if (!a.Spawned) { if (!a.TimerKnown) { return 0; } return a.Remaining.CompareTo(b.Remaining); } int num2 = a.Dead.CompareTo(b.Dead); if (num2 != 0) { return num2; } if (a.Dead) { return 0; } bool flag = a.BarKnown && Finite(a.Fraction); bool flag2 = b.BarKnown && Finite(b.Fraction); if (flag != flag2) { if (!flag) { return 1; } return -1; } if (!flag) { return 0; } return Clamp(b.Fraction).CompareTo(Clamp(a.Fraction)); } private static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private static float Clamp(float value) { return Math.Max(0f, Math.Min(1f, value)); } } internal sealed class TimerSample { internal int ViewId; internal float Remaining; internal bool Spawned; internal bool Dead; internal float ActiveRemaining; internal float InitialPause; internal float ActiveBudget; internal bool PlayerClose; } internal static class TimerProtocol { internal const string Magic = "local.repo.enemywatch/timers/2"; internal const byte EventCode = 173; internal const double Expiry = 4.0; internal static object[] Encode(string nonce, string scene, double sentAt, float rate, TimerSample[] samples) { object[] array = new object[samples.Length]; for (int i = 0; i < samples.Length; i++) { array[i] = new object[8] { samples[i].ViewId, samples[i].Remaining, samples[i].Spawned, samples[i].Dead, samples[i].ActiveRemaining, samples[i].InitialPause, samples[i].ActiveBudget, samples[i].PlayerClose }; } return new object[7] { "local.repo.enemywatch/timers/2", "snapshot", nonce, scene, sentAt, rate, array }; } internal static bool TryDecode(object payload, string nonce, string scene, int sender, int master, double now, double lastSentAt, out double sentAt, out float rate, out TimerSample[] samples) { sentAt = 0.0; rate = 0f; samples = null; object[] array = payload as object[]; if (sender != master || array == null || array.Length != 7 || !(array[0] is string) || (string)array[0] != "local.repo.enemywatch/timers/2" || !object.Equals(array[1], "snapshot") || !object.Equals(array[2], nonce) || !object.Equals(array[3], scene) || !(array[4] is double) || !(array[5] is float)) { return false; } sentAt = (double)array[4]; rate = (float)array[5]; if (double.IsNaN(sentAt) || double.IsInfinity(sentAt) || sentAt < lastSentAt || now - sentAt > 4.0 || sentAt - now > 1.0 || float.IsNaN(rate) || rate < 0f || rate > 100f) { return false; } if (!(array[6] is object[] array2) || array2.Length > 512) { return false; } HashSet<int> hashSet = new HashSet<int>(); samples = new TimerSample[array2.Length]; for (int i = 0; i < array2.Length; i++) { if (!(array2[i] is object[] array3) || array3.Length != 8 || !(array3[0] is int) || !(array3[1] is float) || !(array3[2] is bool) || !(array3[3] is bool) || !(array3[4] is float) || !(array3[5] is float) || !(array3[6] is float) || !(array3[7] is bool)) { return false; } int num = (int)array3[0]; float num2 = (float)array3[1]; if (num <= 0 || !hashSet.Add(num) || float.IsNaN(num2) || float.IsInfinity(num2) || num2 < 0f) { return false; } for (int j = 4; j <= 6; j++) { if (float.IsNaN((float)array3[j]) || float.IsInfinity((float)array3[j]) || (float)array3[j] < 0f) { return false; } } samples[i] = new TimerSample { ViewId = num, Remaining = num2, Spawned = (bool)array3[2], Dead = (bool)array3[3], ActiveRemaining = (float)array3[4], InitialPause = (float)array3[5], ActiveBudget = (float)array3[6], PlayerClose = (bool)array3[7] }; } return true; } internal static float Countdown(float remaining, double sentAt, double now, float rate) { return Math.Max(0f, remaining - (float)Math.Max(0.0, now - sentAt) * rate); } internal static int Priority(bool spawned, bool known) { if (spawned || !known) { if (spawned) { return 2; } return 1; } return 0; } }