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 DefinitelyNotCheats v1.4.4
DefinitelyNotCheats.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DefinitelyNotCheats.Core; using DefinitelyNotCheats.World; using DunGen; using GameNetcodeStuff; using HarmonyLib; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; 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("DefinitelyNotCheats")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.4.0")] [assembly: AssemblyInformationalVersion("1.4.4")] [assembly: AssemblyProduct("DefinitelyNotCheats")] [assembly: AssemblyTitle("DefinitelyNotCheats")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "Code generated with Anthropic Claude (Claude Opus 5.5 and other Claude models, via Claude Code); designed and tested by the author")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: AssemblyVersion("1.4.4.0")] namespace DefinitelyNotCheats { internal static class Compat { private static readonly Dictionary<string, Type> _types = new Dictionary<string, Type>(); internal const string BcmGuid = "Drinkable.BrutalCompanyMinus"; internal static readonly string[] MidDayEvents = new string[47] { "Arachnophobia", "BaboonHorde", "Bees", "Birds", "Bracken", "BugHorde", "Butlers", "Cleaners", "Coilhead", "Dogs", "FlowerSnake", "Football", "ForestGiant", "GiantShowdown", "Herobrine", "HoardingBugs", "ImmortalSnail", "Jester", "KamikazieBugs", "LittleGirl", "Lizard", "Lockers", "Locusts", "Masked", "MobileTurrets", "Nutcracker", "OldBirds", "Peepers", "RollingGiants", "Roomba", "ShockwaveDrones", "Shrimp", "ShyGuy", "SirenHead", "SlenderMan", "Slimes", "SnareFleas", "Spiders", "TheFiend", "Thumpers", "Walkers", "Worms", "InsideBees", "Bonus", "BigBonus", "SmallDelivery", "BigDelivery" }; internal const string WeatherGuid = "mrov.WeatherRegistry"; internal const string LpGuid = "TisRyno.LethalProgression"; internal const string StlGuid = "jacob.SimpleTeamLives"; internal const string LllGuid = "imabatby.lethallevelloader"; internal static string ForcedInterior; internal static Type BcmEventManager => T("BrutalCompanyMinus", "BrutalCompanyMinus.Minus.EventManager"); internal static Type BcmMEvent => T("BrutalCompanyMinus", "BrutalCompanyMinus.Minus.MEvent"); internal static Type BcmSpawn => T("BrutalCompanyMinus", "BrutalCompanyMinus.Minus.Manager+Spawn"); internal static Type BcmSpawnCycle => T("BrutalCompanyMinus", "BrutalCompanyMinus.Minus.MonoBehaviours.EnemySpawnCycle"); internal static Type WrManager => T("WeatherRegistry", "WeatherRegistry.WeatherManager"); internal static Type WrController => T("WeatherRegistry", "WeatherRegistry.WeatherController"); internal static bool Has(string guid) { return Chainloader.PluginInfos.ContainsKey(guid); } internal static Type T(string assembly, string fullName) { if (_types.TryGetValue(fullName, out var value)) { return value; } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { string name; try { name = assembly2.GetName().Name; } catch { continue; } if (!(name != assembly)) { try { value = assembly2.GetType(fullName, throwOnError: false); } catch { value = null; } _types[fullName] = value; return value; } } return null; } internal static string BcmMissing() { if (!Has("Drinkable.BrutalCompanyMinus") || !(BcmEventManager != null)) { return "BCM not installed"; } return null; } internal static IList BcmList(string field) { Type bcmEventManager = BcmEventManager; if (!(bcmEventManager == null)) { return AccessTools.Field(bcmEventManager, field)?.GetValue(null) as IList; } return null; } internal static string EventName(object ev) { try { return (string)AccessTools.Method(ev.GetType(), "Name", (Type[])null, (Type[])null).Invoke(ev, null); } catch { return ev.GetType().Name; } } internal static string EventGoodness(object ev) { return EventRank(ev) switch { 0 => "very good", 1 => "good", 2 => "neutral", 3 => "bad", 4 => "very bad", 5 => "removes a spawn", _ => "?", }; } internal static int EventRank(object ev) { try { switch (AccessTools.Field(ev.GetType(), "Type")?.GetValue(ev)?.ToString()) { case "VeryGood": return 0; case "Good": return 1; case "Neutral": return 2; case "Bad": return 3; case "VeryBad": return 4; case "Remove": return 5; } } catch { } return 6; } internal static string EventDescription(object ev) { try { return (AccessTools.Field(ev.GetType(), "Descriptions")?.GetValue(ev) is IList { Count: >0 } list) ? (list[0] as string) : ""; } catch { return ""; } } internal static List<object> BcmMidDay() { IList list = BcmList("events"); List<object> list2 = new List<object>(); if (list == null) { return list2; } foreach (object item in list) { if (item != null && MidDayEvents.Contains(item.GetType().Name)) { list2.Add(item); } } return list2.OrderBy<object, string>(EventName, StringComparer.OrdinalIgnoreCase).ToList(); } internal static string BcmRunNow(string typeName) { IList list = BcmList("events"); if (list == null) { return "BCM isn't installed."; } object obj = null; foreach (object item in list) { if (item != null && item.GetType().Name == typeName) { obj = item; break; } } if (obj == null) { return "BCM has no event " + typeName + "."; } AccessTools.Method(obj.GetType(), "Execute", (Type[])null, (Type[])null).Invoke(obj, null); int num = 0; string[] array = new string[2] { "DoSpawnInsideEnemies", "DoSpawnOutsideEnemies" }; foreach (string text in array) { MethodInfo methodInfo = ((BcmSpawn != null) ? AccessTools.Method(BcmSpawn, text, (Type[])null, (Type[])null) : null); if (methodInfo == null) { continue; } Patches.AllowBcmSpawnOnce = true; try { if (methodInfo.Invoke(null, null) is IList list2) { num += list2.Count; } } finally { Patches.AllowBcmSpawnOnce = false; } } IList list3 = BcmList("currentEvents"); if (list3 != null && !list3.Contains(obj)) { list3.Add(obj); } return "Event " + EventName(obj) + " added" + ((num > 0) ? (", " + num + " spawned") : "") + "."; } internal static string WeatherMissing() { if (!(WrManager != null) || !(WrController != null)) { return "WeatherRegistry not installed"; } return null; } internal static bool WrReady() { try { return WrManager != null && (bool)AccessTools.Property(WrManager, "IsSetupFinished").GetValue(null); } catch { return false; } } internal static object ToWeather(object w) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (w == null || w.GetType().Name == "Weather") { return w; } if (w is LevelWeatherType val) { try { return AccessTools.Method(WrManager, "GetWeather", new Type[1] { typeof(LevelWeatherType) }, (Type[])null)?.Invoke(null, new object[1] { val }); } catch { return null; } } return null; } internal static string WeatherNameOf(object w) { try { return (string)AccessTools.Property(w.GetType(), "Name").GetValue(w); } catch { return w?.ToString(); } } internal static List<object> PossibleWeathers(SelectableLevel level) { List<object> list = new List<object>(); if (!WrReady() || (Object)(object)level == (Object)null) { return list; } try { MethodInfo methodInfo = AccessTools.Method(WrManager, "GetPlanetPossibleWeathers", (Type[])null, (Type[])null); if (methodInfo != null && methodInfo.Invoke(null, new object[1] { level }) is IEnumerable enumerable) { foreach (object item in enumerable) { object obj = ToWeather(item); if (obj != null && !list.Contains(obj)) { list.Add(obj); } } } } catch { } if (list.Count == 0) { try { if (AccessTools.Method(WrManager, "GetWeathers", (Type[])null, (Type[])null).Invoke(null, null) is IEnumerable enumerable2) { foreach (object item2 in enumerable2) { list.Add(item2); } } } catch { } } return list; } internal static object FindWeather(string name, SelectableLevel level) { foreach (object item in PossibleWeathers(level)) { if (WeatherNameOf(item) == name) { return item; } } return null; } internal static string CurrentWeatherName(SelectableLevel level) { try { return (string)AccessTools.Method(WrManager, "GetCurrentWeatherName", (Type[])null, (Type[])null).Invoke(null, new object[2] { level, false }); } catch { return ((Object)(object)level != (Object)null) ? ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref level.currentWeather)/*cast due to .constrained prefix*/).ToString() : "?"; } } internal static string ChangeWeather(string name) { SelectableLevel level = StartOfRound.Instance?.currentLevel; object obj = FindWeather(name, level); if (obj == null) { return name + " isn't possible on this moon."; } MethodInfo methodInfo = WrController.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo x) => x.Name == "ChangeCurrentWeather" && x.GetParameters().Length == 1 && x.GetParameters()[0].ParameterType.Name == "Weather"); if (methodInfo == null) { return "WeatherRegistry has no ChangeCurrentWeather(Weather)."; } methodInfo.Invoke(null, new object[1] { obj }); return "Weather changing to " + name + "."; } internal static bool WeatherIsNone(object w) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 try { return (int)(LevelWeatherType)AccessTools.Property(w.GetType(), "VanillaWeatherType").GetValue(w) == -1; } catch { return WeatherNameOf(w) == "None"; } } internal static string ChangeWeatherFor(int levelId, string name) { SelectableLevel val = StartOfRound.Instance?.levels?.FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => (Object)(object)l != (Object)null && l.levelID == levelId)); if ((Object)(object)val == (Object)null) { return "Unknown moon."; } object obj = FindWeather(name, val); if (obj == null) { return name + " isn't possible on " + val.PlanetName + "."; } MethodInfo methodInfo = WrController.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo x) => x.Name == "ChangeWeather" && x.GetParameters().Length == 2 && x.GetParameters()[1].ParameterType.Name == "Weather"); if (methodInfo == null) { return "WeatherRegistry has no ChangeWeather(level, Weather)."; } methodInfo.Invoke(null, new object[2] { val, obj }); return val.PlanetName + " weather set to " + name + "."; } internal static string LpMissing() { if (!Has("TisRyno.LethalProgression") || !(T("LethalProgression", "LethalProgression.LP_NetworkManager") != null)) { return "Lethal Progression not installed"; } return null; } internal static void AddSkillPointsLocal(int n) { Type type = T("LethalProgression", "LethalProgression.LP_NetworkManager"); object obj = ((!(type != null)) ? null : AccessTools.Field(type, "xpInstance")?.GetValue(null)); if (obj == null) { Plugin.Log.LogWarning((object)"DNC: Lethal Progression isn't ready"); return; } AccessTools.Method(obj.GetType(), "UpdateSkillPoints_S2CMessage", (Type[])null, (Type[])null).Invoke(obj, new object[1] { n }); } internal static string StlMissing() { if (!Has("jacob.SimpleTeamLives") || !(T("SimpleTeamLives", "SimpleTeamLives.TeamLives") != null)) { return "SimpleTeamLives not installed"; } return null; } internal static string AddLives(int n) { Type type = T("SimpleTeamLives", "SimpleTeamLives.TeamLives"); Type type2 = T("SimpleTeamLives", "SimpleTeamLives.Net"); if (type == null || type2 == null) { return "SimpleTeamLives isn't installed."; } MethodInfo methodInfo = AccessTools.Method(type, "EnsureLivesReady", (Type[])null, (Type[])null); if (methodInfo != null && !(bool)methodInfo.Invoke(null, null)) { return "SimpleTeamLives isn't ready (no save loaded?)."; } FieldInfo fieldInfo = AccessTools.Field(type, "Lives"); int num = (int)fieldInfo.GetValue(null) + n; fieldInfo.SetValue(null, num); AccessTools.Method(type, "Save", (Type[])null, (Type[])null)?.Invoke(null, null); AccessTools.Method(type2, "PublishLives", (Type[])null, (Type[])null)?.Invoke(null, new object[1] { num }); return "Team lives now " + num + "."; } internal static string LllMissing() { if (!Has("imabatby.lethallevelloader") || !(T("LethalLevelLoader", "LethalLevelLoader.DungeonManager") != null)) { return "LethalLevelLoader not installed"; } return null; } internal static List<(string name, string mod)> Interiors() { Type type = T("LethalLevelLoader", "LethalLevelLoader.PatchedContent"); List<(string, string)> list = new List<(string, string)>(); if (type == null) { return list; } if (AccessTools.Property(type, "ExtendedDungeonFlows")?.GetValue(null) is IEnumerable enumerable) { foreach (object item2 in enumerable) { string n = AccessTools.Property(item2.GetType(), "DungeonName")?.GetValue(item2) as string; string item = ""; try { item = (AccessTools.Property(item2.GetType(), "ModName")?.GetValue(item2) as string) ?? ""; } catch { } if (!string.IsNullOrEmpty(n) && !list.Any(((string, string) x) => x.Item1 == n)) { list.Add((n, item)); } } } return list; } internal static List<string> InteriorNames() { Type type = T("LethalLevelLoader", "LethalLevelLoader.PatchedContent"); List<string> list = new List<string>(); if (type == null) { return list; } if (AccessTools.Property(type, "ExtendedDungeonFlows")?.GetValue(null) is IEnumerable enumerable) { foreach (object item in enumerable) { string text = AccessTools.Property(item.GetType(), "DungeonName")?.GetValue(item) as string; if (!string.IsNullOrEmpty(text) && !list.Contains(text)) { list.Add(text); } } } return list.OrderBy<string, string>((string x) => x, StringComparer.OrdinalIgnoreCase).ToList(); } internal static void PatchLll(Harmony h) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown Type type = T("LethalLevelLoader", "LethalLevelLoader.DungeonManager"); if (!(type == null)) { Patches.TryPatch(h, AccessTools.Method(type, "GetValidExtendedDungeonFlows", (Type[])null, (Type[])null), null, new HarmonyMethod(typeof(Compat), "ValidFlowsPostfix", (Type[])null)); } } private static void ValidFlowsPostfix(object __result) { if (string.IsNullOrEmpty(ForcedInterior) || !(__result is IList { Count: not 0 } list)) { return; } try { List<object> list2 = new List<object>(); foreach (object item in list) { object obj = AccessTools.Field(item.GetType(), "extendedDungeonFlow")?.GetValue(item); if (((obj != null) ? (AccessTools.Property(obj.GetType(), "DungeonName")?.GetValue(obj) as string) : null) == ForcedInterior) { list2.Add(item); } } if (list2.Count == 0) { Plugin.Log.LogInfo((object)"DNC: forced interior isn't valid for this moon; leaving the pick alone"); return; } list.Clear(); foreach (object item2 in list2) { list.Add(item2); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("DNC: interior override: " + ex.Message)); } } internal static List<object> BcmAllEvents() { IList list = BcmList("events"); List<object> list2 = new List<object>(); if (list != null) { foreach (object item in list) { if (item != null) { list2.Add(item); } } } return list2.OrderBy<object, string>(EventName, StringComparer.OrdinalIgnoreCase).ToList(); } internal static object BcmForce(string typeName) { IList list = BcmList("forcedEvents"); object obj = BcmAllEvents().FirstOrDefault((object e) => e.GetType().Name == typeName); if (list == null || obj == null) { return null; } if (!list.Contains(obj)) { list.Add(obj); } return obj; } internal static void BcmUnforce(object ev) { IList list = BcmList("forcedEvents"); if (list != null && ev != null) { list.Remove(ev); } } } internal enum Scope { Host, Local } internal sealed class ActionDef { public string Id; public Scope Scope; public Func<Ctx, string> Run; public bool NeedsTarget; } internal sealed class Ctx { public ulong Requester; public PlayerControllerB RequesterPlayer; public PlayerControllerB Target; public Dictionary<string, string> Args; public bool IsLocalRequester => Requester == Game.LocalClientId; public string TargetName { get { if (!((Object)(object)Target != (Object)null)) { return "nobody"; } return Target.playerUsername; } } public Effect AddEffect(EffectRegistry reg, Effect e) { e.Owner = Requester; if (string.IsNullOrEmpty(e.Target) && (Object)(object)Target != (Object)null) { e.Target = Target.playerUsername; } return reg.Add(e); } } internal static class DNC { internal static readonly Dictionary<string, ActionDef> Actions; internal static readonly EffectRegistry HostFx; internal static readonly EffectRegistry LocalFx; internal static readonly History History; internal static List<EffectView> RemoteActive; internal static float RemoteActiveAt; internal static string ResultLine; internal static int ResultVersion; internal static ulong TargetId; internal static bool TargetPicked; internal static int NextLandingKeep { get { if (!((Object)(object)StartOfRound.Instance != (Object)null) || StartOfRound.Instance.inShipPhase) { return 0; } return 1; } } static DNC() { Actions = new Dictionary<string, ActionDef>(); HostFx = new EffectRegistry(); LocalFx = new EffectRegistry(); History = new History(); RemoteActive = new List<EffectView>(); ResultLine = ""; TargetId = ulong.MaxValue; HostFx.OnError = delegate(string s) { Plugin.Log.LogWarning((object)("DNC: " + s)); }; LocalFx.OnError = delegate(string s) { Plugin.Log.LogWarning((object)("DNC: " + s)); }; } internal static void Warn(Ctx c, string detail) { if (c == null || c.IsLocalRequester) { Plugin.Log.LogWarning((object)("DNC: " + detail)); } else { Plugin.Log.LogWarning((object)"DNC: msg warning"); } } internal static void Register(string id, Scope scope, Func<Ctx, string> run, bool needsTarget = false) { Actions[id] = new ActionDef { Id = id, Scope = scope, Run = run, NeedsTarget = needsTarget }; } internal static void SetResult(string s) { ResultLine = s ?? ""; ResultVersion++; } internal static void Invoke(string actionId, Dictionary<string, string> args, string path, bool again = false, bool keepTarget = false) { if (!Actions.TryGetValue(actionId, out var value)) { SetResult("Unknown action " + actionId); return; } args = args ?? new Dictionary<string, string>(); if (!keepTarget || !args.ContainsKey("t")) { args["t"] = ((TargetId == ulong.MaxValue) ? "-1" : TargetId.ToString()); } args.Remove("again"); if (!again || !args.ContainsKey("lv")) { args["lv"] = (StartOfRound.Instance?.currentLevel?.levelID ?? (-1)).ToString(); } Dictionary<string, string> dictionary = new Dictionary<string, string>(args); dictionary.Remove("t"); History.Push(actionId, Args.Encode(dictionary), path); if (again) { args["again"] = "1"; } if (actionId == "spawn") { EnemyCatalog.NoteSpawned(args.Get("enemy")); } Plugin.Log.LogInfo((object)("DNC: " + path)); if (value.Scope == Scope.Local || Game.IsHost) { SetResult(RunHere(value, Game.LocalClientId, args)); } else { Net.SendRun(actionId, args); } } internal static string RunHere(ActionDef def, ulong requester, Dictionary<string, string> args) { string text = Access.GateRun(def, requester, args); if (text != null) { return text; } try { Ctx ctx = new Ctx { Requester = requester, Args = args, RequesterPlayer = Game.PlayerByClientId(requester) }; int num = args.GetInt("t", -1); ctx.Target = ((num >= 0) ? Game.PlayerByIndex(num) : null); if ((Object)(object)ctx.Target != (Object)null && (!ctx.Target.isPlayerControlled || ctx.Target.isPlayerDead)) { ctx.Target = null; } if (def.NeedsTarget && (Object)(object)ctx.Target == (Object)null) { return "Pick a target first (nobody alive is picked)."; } return def.Run(ctx) ?? "Done."; } catch (Exception ex) { if (requester == Game.LocalClientId) { Plugin.Log.LogWarning((object)("DNC action " + def.Id + " failed: " + ex)); } else { Plugin.Log.LogWarning((object)("DNC: msg failed (" + ex.GetType().Name + ")")); } return "Failed: " + ex.GetType().Name + " " + ex.Message; } } internal static void InvokeQuiet(string actionId, Dictionary<string, string> args) { if (Actions.TryGetValue(actionId, out var value)) { if (!args.ContainsKey("t")) { args["t"] = "-1"; } if (value.Scope == Scope.Local || Game.IsHost) { SetResult(RunHere(value, Game.LocalClientId, args)); } else { Net.SendRun(actionId, args); } } } internal static void RepeatLast() { History.Entry last = History.Last; if (last == null) { SetResult("Nothing to repeat yet."); } else { Invoke(last.ActionId, Args.Decode(last.Args), last.Path, again: true); } } internal static void UndoMine() { int num = LocalFx.StopOwner(Game.LocalClientId); if (Game.IsHost) { num += HostFx.StopOwner(Game.LocalClientId); } else if (Game.InGame) { Net.SendStopAll(); } Spectate.Stop(); SetResult((num > 0 || !Game.IsHost) ? "Undone: everything you started has been put back." : "Nothing to undo."); } internal static void CleanupAll(string why, bool newDay = false) { if (newDay) { LocalFx.StopAllExceptKept(); if (Game.IsHost) { HostFx.StopAllExceptKept(); } FxRunner.StopAllExceptKept(); } else { LocalFx.StopAll(); if (Game.IsHost) { HostFx.StopAll(); } FxRunner.StopAll(); RemoteActive.Clear(); } Spectate.Stop(); InsideState.Clear(); Game.ClearLevelCaches(); Doors.Clear(); Spawns.Clear(); Patches.ClearEnemyIgnores(); if (!string.IsNullOrEmpty(why)) { Plugin.Log.LogInfo((object)("DNC: cleanup (" + why + ")")); } } internal static void StopActive(int id, bool remote) { if (!remote) { LocalFx.Stop(id, Game.LocalClientId); SetResult("Stopped."); } else if (Game.IsHost) { HostFx.Stop(id, Game.LocalClientId); SetResult("Stopped."); } else { Net.SendStop(id); } } internal static List<(string text, int id, bool remote, float left)> MyActive() { List<(string, int, bool, float)> list = new List<(string, int, bool, float)>(); float now = Time.time; foreach (Effect item in LocalFx.ForOwner(Game.LocalClientId)) { list.Add((item.Describe(now), item.Id, false, Left(item))); } if (Game.IsHost) { foreach (Effect item2 in HostFx.ForOwner(Game.LocalClientId)) { list.Add((item2.Describe(now), item2.Id, true, Left(item2))); } } else { foreach (EffectView item3 in RemoteActive) { Effect effect = new Effect { Label = item3.Label, Target = item3.Target, WaitingText = item3.WaitingText, EndTime = (float.IsInfinity(item3.Remaining) ? item3.Remaining : (RemoteActiveAt + item3.Remaining)) }; list.Add((effect.Describe(now), item3.Id, true, Left(effect))); } } return list; float Left(Effect e) { if (e.EndTime != float.PositiveInfinity && e.EndTime != float.NegativeInfinity) { return e.EndTime - now; } return e.EndTime; } } } internal abstract class LocalFx { public int Id; public virtual bool Update(float now) { return true; } public abstract void Stop(); } internal static class FxRunner { private sealed class PersistentFx { public string Kind; public string Args; public HashSet<ulong> Except; } internal static readonly Dictionary<string, Func<Dictionary<string, string>, LocalFx>> Kinds = new Dictionary<string, Func<Dictionary<string, string>, LocalFx>>(); private static readonly Dictionary<int, LocalFx> Running = new Dictionary<int, LocalFx>(); private static readonly Dictionary<int, string> RunningKind = new Dictionary<int, string>(); internal static readonly HashSet<string> KeptKinds = new HashSet<string> { "ignoreplayer", "invisible" }; private static readonly List<int> _done = new List<int>(); private static int _nextFxId = 1; private static readonly Dictionary<int, PersistentFx> Persistent = new Dictionary<int, PersistentFx>(); internal static void Start(int fxId, string kind, Dictionary<string, string> args) { if (!Kinds.TryGetValue(kind, out var value)) { Plugin.Log.LogDebug((object)"DNC: msg ?"); return; } Stop(fxId); try { args["_id"] = fxId.ToString(); LocalFx localFx = value(args); if (localFx != null) { localFx.Id = fxId; Running[fxId] = localFx; RunningKind[fxId] = kind; ModMenus.OnLocalFxStarted(kind); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("DNC: fx failed: " + ex.Message)); } } internal static void Stop(int fxId) { if (!Running.TryGetValue(fxId, out var value)) { return; } Running.Remove(fxId); RunningKind.Remove(fxId); try { value.Stop(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("DNC: fx stop failed: " + ex.Message)); } } internal static void StopAll() { foreach (int item in new List<int>(Running.Keys)) { Stop(item); } Persistent.Clear(); } internal static void StopAllExceptKept() { foreach (int item in new List<int>(Running.Keys)) { if (!RunningKind.TryGetValue(item, out var value) || !KeptKinds.Contains(value)) { Stop(item); } } foreach (int item2 in new List<int>(Persistent.Keys)) { if (!KeptKinds.Contains(Persistent[item2].Kind)) { Persistent.Remove(item2); } } } internal static void Update() { if (Running.Count == 0) { return; } float time = Time.time; _done.Clear(); foreach (KeyValuePair<int, LocalFx> item in Running) { bool flag; try { flag = item.Value.Update(time); } catch (Exception ex) { Plugin.Log.LogWarning((object)("DNC: fx error: " + ex.Message)); flag = false; } if (!flag) { _done.Add(item.Key); } } foreach (int item2 in _done) { Stop(item2); } } internal static Effect StartOn(Ctx ctx, IEnumerable<ulong> clients, string kind, Dictionary<string, string> args, string label, float duration, string effectKind = null, bool persistent = false, string waitingText = null, IEnumerable<ulong> except = null) { int fxId = _nextFxId++; string args2 = Args.Encode(args); List<ulong> to = new List<ulong>(clients); foreach (ulong item in to) { Net.SendFxStart(item, fxId, kind, args2); } if (persistent) { Persistent[fxId] = new PersistentFx { Kind = kind, Args = args2, Except = ((except != null) ? new HashSet<ulong>(except) : new HashSet<ulong>()) }; } Effect effect = new Effect { Label = label, Kind = effectKind, EndTime = (float.IsNegativeInfinity(duration) ? float.NegativeInfinity : ((duration > 0f) ? (Time.time + duration) : float.PositiveInfinity)), WaitingText = waitingText, Undo = delegate { Persistent.Remove(fxId); foreach (ulong item2 in Net.AllClientsOr(to)) { Net.SendFxStop(item2, fxId); } } }; effect.Tag = fxId; return ctx.AddEffect(DNC.HostFx, effect); } internal static void FireOn(IEnumerable<ulong> clients, string kind, Dictionary<string, string> args) { int fxId = _nextFxId++; string args2 = Args.Encode(args); foreach (ulong client in clients) { Net.SendFxStart(client, fxId, kind, args2); } } internal static void SendPersistentTo(ulong client) { foreach (KeyValuePair<int, PersistentFx> item in Persistent) { if (!item.Value.Except.Contains(client)) { Net.SendFxStart(client, item.Key, item.Value.Kind, item.Value.Args); } } } internal static void OnClientJoined(ulong client) { SendPersistentTo(client); } } internal static class Game { private static int _cacheFrameLevel = -1; internal static DoorLock[] Doors = (DoorLock[])(object)new DoorLock[0]; internal static TerminalAccessibleObject[] BigDoors = (TerminalAccessibleObject[])(object)new TerminalAccessibleObject[0]; internal static EntranceTeleport[] Exits = (EntranceTeleport[])(object)new EntranceTeleport[0]; internal static Turret[] Turrets = (Turret[])(object)new Turret[0]; internal static Landmine[] Mines = (Landmine[])(object)new Landmine[0]; internal static SpikeRoofTrap[] Spikes = (SpikeRoofTrap[])(object)new SpikeRoofTrap[0]; internal static SteamValveHazard[] Valves = (SteamValveHazard[])(object)new SteamValveHazard[0]; internal static BreakerBox Breaker; internal static Terminal TerminalScript; internal static NetworkManager NM => NetworkManager.Singleton; internal static bool InGame { get { if ((Object)(object)NM != (Object)null && NM.IsListening) { return (Object)(object)StartOfRound.Instance != (Object)null; } return false; } } internal static bool IsHost { get { if ((Object)(object)NM != (Object)null) { return NM.IsServer; } return false; } } internal static ulong LocalClientId { get { if (!((Object)(object)NM != (Object)null)) { return 0uL; } return NM.LocalClientId; } } internal static PlayerControllerB Local { get { if (!((Object)(object)GameNetworkManager.Instance != (Object)null)) { return null; } return GameNetworkManager.Instance.localPlayerController; } } internal static bool AtCompany { get { SelectableLevel val = StartOfRound.Instance?.currentLevel; if ((Object)(object)val != (Object)null) { if (!(val.sceneName == "CompanyBuilding")) { return (val.PlanetName ?? "").IndexOf("Gordion", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } return false; } } internal static bool OnMoon { get { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance != (Object)null && !instance.inShipPhase && instance.shipHasLanded && !instance.shipIsLeaving && !AtCompany) { return (Object)(object)RoundManager.Instance != (Object)null; } return false; } } internal static bool Typing { get { PlayerControllerB local = Local; if ((Object)(object)local != (Object)null && (local.isTypingChat || local.inTerminalMenu)) { return true; } QuickMenuManager val = (((Object)(object)local != (Object)null) ? local.quickMenuManager : null); if ((Object)(object)val != (Object)null) { return val.isMenuOpen; } return false; } } internal static PlayerControllerB Target { get { if (DNC.TargetId == ulong.MaxValue) { return null; } PlayerControllerB val = PlayerByIndex((int)DNC.TargetId); if (!((Object)(object)val != (Object)null) || !val.isPlayerControlled || val.isPlayerDead) { return null; } return val; } } internal static Terminal Terminal { get { if ((Object)(object)TerminalScript == (Object)null) { TerminalScript = Object.FindObjectOfType<Terminal>(); } return TerminalScript; } } internal static string NotOnMoon() { if (!OnMoon) { return "not on a moon"; } return null; } internal static PlayerControllerB PlayerByIndex(int i) { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null || i < 0 || i >= array.Length) { return null; } return array[i]; } internal static PlayerControllerB PlayerByClientId(ulong clientId) { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && val.actualClientId == clientId) { return val; } } if (clientId != 0L || array.Length == 0) { return null; } return array[0]; } internal static IEnumerable<PlayerControllerB> Living() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { yield break; } PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead) { yield return val; } } } internal static IEnumerable<PlayerControllerB> Dead() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { yield break; } PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if ((Object)(object)val != (Object)null && val.isPlayerDead && (val.isPlayerControlled || val.hasBegunSpectating || val.playerSteamId != 0L || (Object)(object)val == (Object)(object)Local)) { yield return val; } } } internal static string NoTarget() { if (!((Object)(object)Target == (Object)null)) { return null; } return "pick a target"; } internal static void UpdateTarget() { if (!InGame) { DNC.TargetId = ulong.MaxValue; DNC.TargetPicked = false; } else { if ((Object)(object)Target != (Object)null) { return; } if (DNC.TargetId != ulong.MaxValue) { DNC.TargetId = ulong.MaxValue; if (DNC.TargetPicked) { DNC.SetResult("Target is gone; target is now nobody."); Spectate.Stop("Their view switched off: target is gone."); } DNC.TargetPicked = false; } else { if (DNC.TargetPicked) { return; } foreach (PlayerControllerB item in Living()) { if ((Object)(object)item != (Object)(object)Local) { DNC.TargetId = item.playerClientId; break; } } } } } internal static void CycleTarget(int dir) { List<PlayerControllerB> list = new List<PlayerControllerB>(Living()); if (list.Count == 0) { DNC.TargetId = ulong.MaxValue; return; } int num = list.FindIndex((PlayerControllerB p) => p.playerClientId == DNC.TargetId); num = ((num >= 0) ? ((num + dir + list.Count) % list.Count) : 0); DNC.TargetId = list[num].playerClientId; DNC.TargetPicked = true; } internal static string TargetLabel() { PlayerControllerB target = Target; if ((Object)(object)target == (Object)null) { return "nobody"; } if (!((Object)(object)target == (Object)(object)Local)) { return target.playerUsername; } return target.playerUsername + " (you)"; } internal static void EnsureLevelCaches(bool force = false) { int num = (((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.currentLevel != (Object)null) ? (StartOfRound.Instance.currentLevel.levelID * 7 + (OnMoon ? 1 : 0)) : (-1)); if (!force && num == _cacheFrameLevel) { Prune(); return; } _cacheFrameLevel = num; Doors = Object.FindObjectsOfType<DoorLock>(); BigDoors = Object.FindObjectsOfType<TerminalAccessibleObject>(); Exits = Object.FindObjectsOfType<EntranceTeleport>(); Turrets = Object.FindObjectsOfType<Turret>(); Mines = Object.FindObjectsOfType<Landmine>(); Spikes = Object.FindObjectsOfType<SpikeRoofTrap>(); Valves = Object.FindObjectsOfType<SteamValveHazard>(); Breaker = Object.FindObjectOfType<BreakerBox>(); TerminalScript = Object.FindObjectOfType<Terminal>(); } private static void Prune() { if (Array.Exists(Mines, (Landmine m) => (Object)(object)m == (Object)null)) { Mines = Array.FindAll(Mines, (Landmine m) => (Object)(object)m != (Object)null); } if (Array.Exists(Turrets, (Turret m) => (Object)(object)m == (Object)null)) { Turrets = Array.FindAll(Turrets, (Turret m) => (Object)(object)m != (Object)null); } if (Array.Exists(Spikes, (SpikeRoofTrap m) => (Object)(object)m == (Object)null)) { Spikes = Array.FindAll(Spikes, (SpikeRoofTrap m) => (Object)(object)m != (Object)null); } } internal static void ClearLevelCaches() { _cacheFrameLevel = -1; Doors = (DoorLock[])(object)new DoorLock[0]; BigDoors = (TerminalAccessibleObject[])(object)new TerminalAccessibleObject[0]; Exits = (EntranceTeleport[])(object)new EntranceTeleport[0]; Turrets = (Turret[])(object)new Turret[0]; Mines = (Landmine[])(object)new Landmine[0]; Spikes = (SpikeRoofTrap[])(object)new SpikeRoofTrap[0]; Valves = (SteamValveHazard[])(object)new SteamValveHazard[0]; Breaker = null; } internal static T Nearest<T>(IEnumerable<T> list, Vector3 pos, float maxDist = float.MaxValue) where T : Component { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) T result = default(T); float num = maxDist * maxDist; foreach (T item in list) { if (!((Object)(object)item == (Object)null)) { Vector3 val = ((Component)item).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } internal static string Metres(float d) { return Mathf.RoundToInt(d) + " m"; } } internal static class InsideState { private const float Settle = 0.6f; private const float Interval = 0.25f; private const float OutsideMargin = 10f; private static readonly List<Tile> _tiles = new List<Tile>(); private static Bounds _all; private static float _nextTileScan; private static float _nextTick; private static readonly Dictionary<int, float> _wrongSince = new Dictionary<int, float>(); private static readonly Dictionary<int, List<float>> _fixes = new Dictionary<int, List<float>>(); private static readonly HashSet<int> _gaveUp = new HashSet<int>(); private static Bounds _outer; private static MethodInfo _setAudioPreset; private static bool _lookedUp; private static MethodInfo SetAudioPreset { get { if (!_lookedUp) { _lookedUp = true; _setAudioPreset = AccessTools.Method(typeof(EntranceTeleport), "SetAudioPreset", new Type[1] { typeof(int) }, (Type[])null); } return _setAudioPreset; } } internal static void Clear() { _tiles.Clear(); _wrongSince.Clear(); _fixes.Clear(); _gaveUp.Clear(); _nextTileScan = 0f; } internal static void Apply(PlayerControllerB p, bool inside) { //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Invalid comparison between Unknown and I4 //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Invalid comparison between Unknown and I4 //IL_019e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null) { return; } p.isInsideFactory = inside; if (inside) { p.isInElevator = false; p.isInHangarShipRoom = false; } if (p.ItemSlots != null) { GrabbableObject[] itemSlots = p.ItemSlots; foreach (GrabbableObject val in itemSlots) { if ((Object)(object)val != (Object)null) { val.isInFactory = inside; } } } Game.EnsureLevelCaches(); EntranceTeleport val2 = null; EntranceTeleport[] exits = Game.Exits; foreach (EntranceTeleport val3 in exits) { if ((Object)(object)val3 != (Object)null && val3.isEntranceToBuilding == inside && val3.audioReverbPreset >= 0) { val2 = val3; break; } } if ((Object)(object)val2 != (Object)null && SetAudioPreset != null) { try { SetAudioPreset.Invoke(val2, new object[1] { (int)p.playerClientId }); } catch (Exception ex) { Exception ex2 = ex.InnerException ?? ex; Plugin.Log.LogInfo((object)("DNC: door audio preset failed (" + ex2.GetType().Name + ": " + ex2.Message + "); setting weather and lighting directly")); val2 = null; } } if ((Object)(object)p == (Object)(object)Game.Local) { TimeOfDay instance = TimeOfDay.Instance; if ((Object)(object)val2 == (Object)null && (Object)(object)instance != (Object)null) { instance.insideLighting = inside; if (inside) { instance.DisableAllWeather(false); } else if ((int)instance.currentLevelWeather >= 0 && instance.effects != null && (int)instance.currentLevelWeather < instance.effects.Length) { instance.effects[instance.currentLevelWeather].effectEnabled = true; } } AdjacentRoomCullingModified val4 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.occlusionCuller : null); if ((Object)(object)val4 != (Object)null) { val4.currentTile = null; } } _wrongSince.Remove((int)p.playerClientId); } internal static bool? InInterior(Vector3 pos) { //IL_0016: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (!RefreshTiles()) { return null; } if (!((Bounds)(ref _outer)).Contains(pos)) { return false; } if (!((Bounds)(ref _all)).Contains(pos)) { return null; } foreach (Tile tile in _tiles) { if ((Object)(object)tile == (Object)null) { _tiles.Clear(); return null; } Bounds bounds = tile.Bounds; ((Bounds)(ref bounds)).Expand(1f); if (((Bounds)(ref bounds)).Contains(pos)) { return true; } } return null; } internal static void Tick() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; if (now < _nextTick) { return; } _nextTick = now + 0.25f; StartOfRound instance = StartOfRound.Instance; RoundManager instance2 = RoundManager.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || instance.inShipPhase || !instance2.dungeonCompletedGenerating) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead) { continue; } int num = (int)val.playerClientId; if (_gaveUp.Contains(num)) { continue; } bool? flag = InInterior(((Component)val).transform.position); float value; if (!flag.HasValue || flag.Value == val.isInsideFactory) { _wrongSince.Remove(num); } else if (!_wrongSince.TryGetValue(num, out value)) { _wrongSince[num] = now; } else if (!(now - value < 0.6f)) { if (!_fixes.TryGetValue(num, out var value2)) { value2 = (_fixes[num] = new List<float>()); } value2.RemoveAll((float x) => now - x > 20f); if (value2.Count >= 2) { _gaveUp.Add(num); Plugin.Log.LogWarning((object)("DNC: stopped fixing " + val.playerUsername + "'s inside/outside state for today (kept flipping)")); continue; } value2.Add(now); Plugin.Log.LogInfo((object)("DNC: " + val.playerUsername + " is " + (flag.Value ? "inside" : "outside") + " but the game thought otherwise; fixed")); Apply(val, flag.Value); } } } private static bool RefreshTiles() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_0088: Unknown result type (might be due to invalid IL or missing references) if (_tiles.Count > 0) { return true; } if (Time.time < _nextTileScan) { return false; } _nextTileScan = Time.time + 10f; RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null || !instance.dungeonCompletedGenerating) { return false; } bool flag = true; Tile[] array = Object.FindObjectsOfType<Tile>(true); foreach (Tile val in array) { if (!((Object)(object)val == (Object)null)) { _tiles.Add(val); Bounds bounds = val.Bounds; ((Bounds)(ref bounds)).Expand(1f); if (flag) { _all = bounds; flag = false; } else { ((Bounds)(ref _all)).Encapsulate(bounds); } } } if (_tiles.Count > 0) { _nextTileScan = 0f; _outer = _all; ((Bounds)(ref _outer)).Expand(20f); } return _tiles.Count > 0; } } internal static class MenuTree { internal static Navigator _nav; private static readonly (string, string)[] SoundWhere = new(string, string)[4] { ("Behind them", "behind"), ("Near them", "near"), ("In the next room", "nextroom"), ("Through their walkie", "walkie") }; private static readonly string[] ClipSorts = new string[3] { "As found", "A–Z", "Shortest first" }; private static readonly string[] ItemSorts = new string[4] { "A–Z", "Most valuable", "Heaviest", "Lightest" }; private static readonly (string, string)[] Counts = new(string, string)[4] { ("1", "1"), ("2", "2"), ("3", "3"), ("5", "5") }; private static readonly (string, string)[] Extras = new(string, string)[3] { ("Hunting them", "hunt"), ("Already angry", "angry"), ("Normal", "normal") }; private static readonly string[] VanillaSorts = new string[3] { "Scariest first", "A–Z", "Most powerful" }; private static readonly string[] EnemySorts = new string[4] { "A–Z", "Most powerful", "By mod", "Inside, then outside" }; internal static readonly string[] EventSorts = new string[3] { "A–Z", "Good first", "Bad first" }; internal static Navigator Nav => _nav ?? (_nav = new Navigator(Root())); private static Node Root() { return Node.Group("root", () => Access.FilterRoot(new List<Node> { Node.Value("Target", Game.TargetLabel, delegate(int d) { Game.CycleTarget(d); }), Node.Group("Again", Again), Node.Sorted("Active", new string[2] { "Newest first", "Ending soonest" }, Active), Node.Group("Combos", () => Combos.List.Select(((string id, string label) x) => new Node { Label = x.label, ActionId = "combo", ArgKey = "id", ArgValue = x.id, Hint = Combos.Describe(x.id), Disabled = () => Game.NotOnMoon() ?? Game.NoTarget() }).ToList(), Game.NotOnMoon), Node.Group("Spawn enemy", SpawnGroup, Game.NotOnMoon), Node.Group("Scare effects", ScareGroup, Game.NotOnMoon), Node.Group("Lights and power", LightsGroup, Game.NotOnMoon), Node.Group("Doors and exits", DoorsGroup, Game.NotOnMoon), Node.Group("Enemies", EnemiesGroup, Game.NotOnMoon), Node.Group("Hazards", HazardsGroup, Game.NotOnMoon), Node.Group("Weather", WeatherGroup, Game.NotOnMoon), Node.Group("Events (BCM)", EventsGroup, () => Game.NotOnMoon() ?? Compat.BcmMissing()), Node.Group("Target player", TargetGroup, Game.NotOnMoon), Node.Group("Me", MeGroup, () => (!Game.InGame) ? "not in a game" : null), Node.Group("Time and ship", TimeGroup, () => (!Game.InGame) ? "not in a game" : null), Node.Group("Items", ItemsGroup, () => (!Game.InGame) ? "not in a game" : null), Node.Group("Testing", TestingGroup, () => (!Game.InGame) ? "not in a game" : null), Node.Group("Settings", SettingsGroup), Node.Local("Undo all", DNC.UndoMine) })); } private static List<Node> Again() { List<Node> list = new List<Node>(); foreach (History.Entry item in DNC.History.Items) { History.Entry e = item; list.Add(Node.Local(e.Path, delegate { DNC.Invoke(e.ActionId, Args.Decode(e.Args), e.Path, again: true); })); } if (list.Count == 0) { list.Add(Node.Info("(nothing yet)")); } return list; } private static List<Node> Active(int sort) { List<Node> list = new List<Node> { Node.Local("Stop everything", DNC.UndoMine) }; List<(string, int, bool, float)> list2 = DNC.MyActive(); if (sort == 1) { list2 = list2.OrderBy<(string, int, bool, float), float>(((string text, int id, bool remote, float left) x) => (!float.IsNegativeInfinity(x.left)) ? x.left : 100000000f).ToList(); } foreach (var item in list2) { (string text, int id, bool remote, float left) it = item; list.Add(Node.Local(it.text, delegate { DNC.StopActive(it.id, it.remote); })); } if (list2.Count == 0) { list.Add(Node.Info("(nothing of yours is running)")); } return list; } private static List<Node> SettingsGroup() { return new List<Node> { Node.Value("Again list length", () => Settings.Data.againLength.ToString(), delegate(int d) { Settings.Data.againLength += d; Settings.Save(); }), Node.Value("Menu position", () => Settings.PositionNames[Settings.Data.menuPosition], delegate(int d) { Settings.Data.menuPosition = (Settings.Data.menuPosition + d + 2) % 2; Settings.Save(); }), Node.Value("Spectate size", () => Settings.SizeNames[Settings.Data.spectateSize], delegate(int d) { Settings.Data.spectateSize = (Settings.Data.spectateSize + d + 3) % 3; Settings.Save(); Spectate.Relayout(); }), Node.Value("Spectate corner", () => Settings.CornerNames[Settings.Data.spectateCorner], delegate(int d) { Settings.Data.spectateCorner = (Settings.Data.spectateCorner + d + 4) % 4; Settings.Save(); Spectate.Relayout(); }) }; } internal static List<Node> Choices(string argKey, IEnumerable<(string label, string value)> options, Func<List<Node>> next, Func<string, string> disabled = null) { List<Node> list = new List<Node>(); foreach (var option in options) { string v = option.value; list.Add(Node.Choice(option.label, argKey, v, next, (disabled == null) ? null : ((Func<string>)(() => disabled(v))))); } return list; } internal static List<Node> Finals(string actionId, string argKey, IEnumerable<(string label, string value)> options, Func<string, string> disabled = null) { List<Node> list = new List<Node>(); foreach (var option in options) { string v = option.value; list.Add(Node.Act(option.label, actionId, (disabled == null) ? null : ((Func<string>)(() => disabled(v))), argKey, v)); } return list; } private static List<Node> ScareGroup() { return new List<Node> { Node.Group("Sound", SoundGroup, Game.NoTarget), Node.Act("Footsteps following them (20 s)", "follow", Game.NoTarget), Node.Group("Lightning strike near them", () => new List<Node> { Node.Act("Near them", "lightning", null, "miss", "0"), Node.Act("Near miss (6–10 m)", "lightning", null, "miss", "1") }, () => Game.NoTarget() ?? OutsideOnly()), Node.Act("Lights flicker around them (3 s)", "flickernear", Game.NoTarget), Node.Act("Rolling blackout towards them", "blackout", () => Game.NoTarget() ?? InsideOnly()), Node.Group("Their flashlight", () => new List<Node> { Node.Act("Flickers for 5 s", "flashlight", null, "mode", "flicker"), Node.Act("Dies until they switch it off and on", "flashlight", null, "mode", "die") }, () => Game.NoTarget() ?? NoFlashlight()), Node.Act("Fake apparatus pull", "apparatus"), Node.Act("Creepy terminal line", "termline", Game.NoTarget), Node.Act("Fake radar blip near them (15 s)", "radarblip", Game.NoTarget), Node.Act("Fog rolls in (30 s)", "fog", () => Game.NoTarget() ?? InsideOnly()) }; } private static string NoFlashlight() { PlayerControllerB target = Game.Target; if (!((Object)(object)target != (Object)null) || target.ItemSlots == null || !target.ItemSlots.OfType<FlashlightItem>().Any((FlashlightItem f) => (Object)(object)f != (Object)null && ((GrabbableObject)f).isBeingUsed)) { return "their flashlight isn't on"; } return null; } private static string NoWalkie() { if (!((Object)(object)ScareFx.HeldWalkie(Game.Target) == (Object)null)) { return null; } return "no walkie switched on"; } private static List<Node> SoundGroup() { EnemyCatalog.Ensure(); List<Node> list = new List<Node>(); (string, string)[] order = SoundCatalog.Order; for (int i = 0; i < order.Length; i++) { (string, string) tuple = order[i]; string ai = tuple.Item1; string item = tuple.Item2; EnemyEntry enemyEntry = EnemyCatalog.Vanilla(ai); if (enemyEntry == null) { list.Add(Node.Info(item + " (not loaded)")); continue; } EnemyEntry entry = enemyEntry; list.Add(Node.Group(item, delegate { List<Node> list2 = SoundCatalog.NamedFor(ai).Select(SoundPickNode).ToList(); list2.Add(Node.Sorted("All clips (" + SoundCatalog.ClipsOf(entry).Count + ")", ClipSorts, (int j) => AllClips(entry, j))); return list2; })); } list.Add(Node.Sorted("Modded enemies", new string[2] { "A–Z", "By mod" }, delegate(int num) { IEnumerable<EnemyEntry> source = EnemyCatalog.All.Where((EnemyEntry e) => e.Mod != "Vanilla"); source = ((num == 1) ? source.OrderBy<EnemyEntry, string>((EnemyEntry e) => e.Mod, StringComparer.OrdinalIgnoreCase).ThenBy((EnemyEntry e) => e.Display) : source.OrderBy<EnemyEntry, string>((EnemyEntry e) => e.Display, StringComparer.OrdinalIgnoreCase)); List<Node> list2 = source.Select(delegate(EnemyEntry e) { EnemyEntry en = e; Node node = Node.Sorted(e.Display, ClipSorts, (int j) => AllClips(en, j)); node.Hint = e.Mod; return node; }).ToList(); if (list2.Count == 0) { list2.Add(Node.Info("(no modded enemies loaded)")); } return list2; })); list.Add(Node.Group("World", () => SoundCatalog.World().Select(SoundPickNode).ToList())); return list; } private static List<Node> AllClips(EnemyEntry e, int sort = 0) { IEnumerable<(string, AudioClip)> source = SoundCatalog.ClipsOf(e); switch (sort) { case 1: source = source.OrderBy<(string, AudioClip), string>(((string tag, AudioClip clip) c) => c.tag, StringComparer.OrdinalIgnoreCase); break; case 2: source = source.OrderBy<(string, AudioClip), float>(((string tag, AudioClip clip) c) => c.clip.length); break; } List<Node> list = source.Select<(string, AudioClip), Node>(delegate((string tag, AudioClip clip) c) { Node node = SoundPickNode(new SoundPick { Label = c.tag, Clip = c.clip }); node.Hint = c.clip.length.ToString("0.0") + " s"; return node; }).ToList(); if (list.Count == 0) { list.Add(Node.Info("(no clips found)")); } return list; } private static Node SoundPickNode(SoundPick s) { if ((Object)(object)s.Clip == (Object)null) { return Node.Info(s.Label + " (not found)"); } string max = (s.Label.StartsWith("Music box") ? "5" : "0"); return Node.Choice(s.Label, "c", ((Object)s.Clip).name, () => Choices("where", SoundWhere, null, (string w) => (!(w == "walkie")) ? null : NoWalkie()).Select(delegate(Node x) { x.ActionId = "sound"; x.Children = null; x.Extra = new Dictionary<string, string> { { "max", max } }; return x; }).ToList()); } private static List<Node> TargetGroup() { return new List<Node> { Node.Act("Drain their stamina", "tgt", Game.NoTarget, "what", "stamina"), Node.Act("Make them drop what they're holding", "tgt", Game.NoTarget, "what", "drop"), Node.Act("Small hit (10, never below 20 health)", "tgt", Game.NoTarget, "what", "hit"), Node.Act("Drunk for 15 s", "tgt", Game.NoTarget, "what", "drunk"), Node.Act("Watch their view: on", "spectate", delegate { object obj = Game.NoTarget(); if (obj == null) { if (!((Object)(object)Game.Target == (Object)(object)Game.Local)) { return (string)null; } obj = "that's you"; } return (string)obj; }, "on", "1"), Node.Act("Watch their view: off", "spectate", () => (!Spectate.Active) ? "not watching" : null, "on", "0") }; } private static string OnOff(string kind) { if (!DNC.LocalFx.Has(kind, Game.LocalClientId)) { return "off"; } return "on"; } private static List<Node> MeGroup() { return new List<Node> { new Node { LabelFn = () => "God mode (" + OnOff("god") + ")", ActionId = "god" }, new Node { LabelFn = () => "Infinite stamina (" + OnOff("infstamina") + ")", ActionId = "stamina" }, new Node { LabelFn = () => "Noclip / fly (" + OnOff("noclip") + ")", ActionId = "noclip" }, Node.Value("Fly speed", () => Noclip.Speed.ToString("0"), delegate(int d) { Noclip.Speed = Mathf.Clamp(Noclip.Speed + (float)d * 5f, 5f, 60f); }), Node.Act("Invisible to enemies: on", "ignoreme", null, "on", "1"), Node.Act("Invisible to enemies: off", "ignoreme", null, "on", "0"), Node.Act("Invisible to them: on", "invisible", null, "on", "1"), Node.Act("Invisible to them: off", "invisible", null, "on", "0"), Node.Group("Teleport to", () => new List<Node> { Node.Act("Them", "tp", () => (!((Object)(object)Game.Target == (Object)null) && !((Object)(object)Game.Target == (Object)(object)Game.Local)) ? null : "pick another player", "to", "them"), Node.Act("The ship", "tp", null, "to", "ship"), Node.Act("The main entrance", "tp", Game.NotOnMoon, "to", "main"), Node.Act("The nearest fire exit", "tp", Game.NotOnMoon, "to", "fire"), Node.Act("A random spot inside", "tp", Game.NotOnMoon, "to", "inside") }), Node.Group("Run speed", () => Finals("speed", "x", new(string, string)[3] { ("×1.5", "1.5"), ("×2", "2"), ("Normal", "1") })) }; } private static List<Node> ItemsGroup() { return new List<Node> { Node.Group("Spawn item at me", () => new List<Node> { Node.Sorted("Tools", ItemSorts, (int j) => ItemNodes((Item i) => !i.isScrap && !Items.IsModded(i), j)), Node.Sorted("Scrap", ItemSorts, (int j) => ItemNodes((Item i) => i.isScrap && !Items.IsModded(i), j)), Node.Sorted("Modded", ItemSorts, (int j) => ItemNodes(Items.IsModded, j)) }), Node.Sorted("Spawn scrap near them as bait", ItemSorts, delegate(int j) { List<Node> list = new List<Node>(); list.Add(Node.Choice("Random", "i", "random", BaitValues)); list.AddRange(SortItems(from i in Items.All() where i.isScrap select i, j).Select(delegate(Item i) { Node node = Node.Choice(i.itemName, "i", i.itemName, BaitValues); node.Hint = ItemHint(i); return node; })); return list; }, () => Game.NotOnMoon() ?? Game.NoTarget()), Node.Act("Charge my held item's battery", "charge") }; } private static List<Node> BaitValues() { return Finals("bait", "value", new(string, string)[3] { ("Low ($10–40)", "low"), ("Mid ($60–120)", "mid"), ("High ($150–300)", "high") }); } private static IEnumerable<Item> SortItems(IEnumerable<Item> items, int sort) { return sort switch { 1 => items.OrderByDescending(Value).ThenBy((Item i) => i.itemName), 2 => from i in items orderby i.weight descending, i.itemName select i, 3 => from i in items orderby i.weight, i.itemName select i, _ => items.OrderBy<Item, string>((Item i) => i.itemName, StringComparer.OrdinalIgnoreCase), }; } private static float Value(Item i) { if (!i.isScrap) { return i.creditsWorth; } return (float)i.maxValue * 0.4f; } private static string ItemHint(Item i) { int num = Mathf.Max(0, Mathf.RoundToInt((i.weight - 1f) * 105f)); string text = (i.isScrap ? ("$" + Mathf.RoundToInt((float)i.minValue * 0.4f) + "–" + Mathf.RoundToInt((float)i.maxValue * 0.4f)) : ((i.creditsWorth > 0) ? ("$" + i.creditsWorth) : "")); return ((text.Length > 0) ? (text + " · ") : "") + num + " lb"; } private static List<Node> ItemNodes(Func<Item, bool> pick, int sort = 0) { List<Node> list = SortItems(Items.All().Where(pick), sort).Select(delegate(Item i) { Node node = Node.Act(i.itemName, "item", null, "i", i.itemName); node.Hint = ItemHint(i); return node; }).ToList(); if (list.Count == 0) { list.Add(Node.Info("(none)")); } return list; } private static int RiskRank(string r) { string[] array = new string[9] { "Safe", "D", "C", "B", "A", "S", "S+", "S++", "S+++" }; int num = Array.IndexOf(array, (r ?? "").Trim()); if (num < 0) { return array.Length; } return num; } private static List<Node> TestingGroup() { List<Node> list = TestingItems(); Node node = MimicMenu.Group(); if (node != null) { list.Insert(0, node); } ModMenus.AddTo(list); return list; } private static List<Node> TestingItems() { List<Node> list = new List<Node>(); list.Add(Node.Group("Force next landing", () => new List<Node> { Node.Sorted("Interior", new string[2] { "A–Z", "By mod" }, delegate(int j) { List<(string, string)> source = Compat.Interiors(); source = ((j == 1) ? source.OrderBy<(string, string), string>(((string name, string mod) x) => x.mod, StringComparer.OrdinalIgnoreCase).ThenBy<(string, string), string>(((string name, string mod) x) => x.name).ToList() : source.OrderBy<(string, string), string>(((string name, string mod) x) => x.name, StringComparer.OrdinalIgnoreCase).ToList()); List<Node> list2 = source.Select<(string, string), Node>(delegate((string name, string mod) x) { Node node = Node.Act(x.name, "forceinterior", null, "n", x.name); node.Hint = x.mod; return node; }).ToList(); if (list2.Count == 0) { list2.Add(Node.Info("(no interiors found)")); } return list2; }, Compat.LllMissing), Node.Group("Size", () => Finals("forcesize", "x", new(string, string)[3] { ("Smaller (×0.7)", "0.7"), ("Bigger (×1.5)", "1.5"), ("Normal", "1") })), Node.Sorted("BCM events", EventSorts, (int j) => SortEvents(Compat.BcmAllEvents(), j).Select(delegate(object ev) { Node node = Node.Act(Compat.EventName(ev), "forcebcm", null, "e", ev.GetType().Name); node.Hint = Compat.EventGoodness(ev); return node; }).ToList(), Compat.BcmMissing) }, () => (!((Object)(object)StartOfRound.Instance != (Object)null) || !StartOfRound.Instance.inShipPhase) ? "in orbit only" : null)); list.Add(Node.Sorted("Force tomorrow's weather", new string[2] { "A–Z", "By risk level" }, delegate(int j) { IEnumerable<SelectableLevel> source = ((IEnumerable<SelectableLevel>)(((object)StartOfRound.Instance?.levels) ?? ((object)new SelectableLevel[0]))).Where((SelectableLevel l) => (Object)(object)l != (Object)null && l.planetHasTime); source = ((j == 1) ? (from l in source orderby RiskRank(l.riskLevel), l.PlanetName select l) : source.OrderBy((SelectableLevel l) => l.PlanetName)); return source.Select(delegate(SelectableLevel l) { SelectableLevel lv = l; Node node = Node.Choice(l.PlanetName, "moon", l.levelID.ToString(), () => (from x in (from w in Compat.PossibleWeathers(lv) select Compat.WeatherNameOf(w)).Distinct() select Node.Act(x, "forceweather", null, "w", x)).ToList()); node.Hint = (string.IsNullOrEmpty(l.riskLevel) ? "" : ("risk " + l.riskLevel)); return node; }).ToList(); }, delegate { object obj = Compat.WeatherMissing(); if (obj == null) { if (!((Object)(object)StartOfRound.Instance != (Object)null) || !StartOfRound.Instance.inShipPhase) { return "in orbit only"; } obj = null; } return (string)obj; })); list.Add(Node.Act("Revive dead players", "revive", () => (!Game.Dead().Any()) ? "nobody is dead" : null)); list.Add(Node.Group("Credits", () => Finals("credits", "n", new(string, string)[3] { ("+500", "500"), ("+1,000", "1000"), ("+5,000", "5000") }))); list.Add(Node.Act("Quota: mark it as met", "quota")); list.Add(Node.Act("Skip to the next day (ship leaves now)", "skipday", Game.NotOnMoon)); list.Add(Node.Act("Info line", "info")); list.Add(RemoveSpawnsGroup()); list.Add(Node.Act("Spawn every enemy once at me", "spawnall", Game.NotOnMoon)); list.Add(Node.Group("Give skill points", () => Choices("who", new(string, string)[2] { ("Me", "me"), ("Target", "target") }, () => Finals("skillpoints", "n", new(string, string)[3] { ("1", "1"), ("5", "5"), ("10", "10") }), (string w) => (!(w == "target")) ? null : Game.NoTarget()), Compat.LpMissing)); list.Add(Node.Act("Clear the weather now", "clearweather", () => Game.NotOnMoon() ?? Compat.WeatherMissing())); list.Add(Node.Act("Teleport to the ship", "tp", null, "to", "ship")); list.Add(Node.Group("Add team lives", () => Finals("lives", "n", new(string, string)[2] { ("+1", "1"), ("+3", "3") }), Compat.StlMissing)); return list; } private static List<Node> SpawnGroup() { EnemyCatalog.Ensure(); List<Node> list = new List<Node>(); list.Add(Node.Group("Recent", () => EnemyNodes(from e in EnemyCatalog.Recent.Select(EnemyCatalog.Find) where e != null select e, "(nothing spawned yet)"))); list.Add(Node.Sorted("Inside", VanillaSorts, (int i) => VanillaNodes(EnemyCatalog.Inside, i))); list.Add(Node.Sorted("Outside, night", VanillaSorts, (int i) => VanillaNodes(EnemyCatalog.OutsideNight, i))); list.Add(Node.Sorted("Outside, day", VanillaSorts, (int i) => VanillaNodes(EnemyCatalog.OutsideDay, i))); list.Add(Node.Sorted("Modded", new string[2] { "A–Z", "Most enemies" }, delegate(int i) { List<List<EnemyEntry>> source = (from g in EnemyCatalog.Modded() select g.ToList()).ToList(); source = ((i == 0) ? source.OrderBy<List<EnemyEntry>, string>((List<EnemyEntry> g) => g[0].Mod, StringComparer.OrdinalIgnoreCase).ToList() : (from g in source orderby g.Count descending, g[0].Mod select g).ToList()); List<Node> list2 = source.Select((List<EnemyEntry> grp) => Node.Sorted(grp[0].Mod + " (" + grp.Count + ")", EnemySorts.Take(3).ToArray(), (int j) => EnemyNodes(SortEnemies(grp, j), ""))).ToList(); if (list2.Count == 0) { list2.Add(Node.Info("(no modded enemies loaded)")); } return list2; })); list.Add(Node.Sorted("All", EnemySorts, (int i) => EnemyNodes(SortEnemies(EnemyCatalog.All, i), "(no enemies loaded)"))); list.Add(RemoveSpawnsGroup()); return list; } internal static Node RemoveSpawnsGroup() { return Node.Group("Remove my spawns", () => new List<Node> { Node.Act("Everything I spawned", "removespawns", null, "which", "all"), Node.Act("Enemies", "removespawns", null, "which", "enemys"), Node.Act("Hazards", "removespawns", null, "which", "hazards"), Node.Act("Items (not ones being held)", "removespawns", null, "which", "items") }); } private static List<Node> VanillaNodes((string ai, string name)[] list, int sort) { List<(EnemyEntry, string, int)> list2 = new List<(EnemyEntry, string, int)>(); List<Node> list3 = new List<Node>(); int num = 0; for (int i = 0; i < list.Length; i++) { (string ai, string name) tuple = list[i]; string item = tuple.ai; string item2 = tuple.name; EnemyEntry enemyEntry = EnemyCatalog.Vanilla(item); if (enemyEntry == null) { list3.Add(Node.Info(item2 + " (not loaded)")); } else { list2.Add((enemyEntry, item2, num)); } num++; } IEnumerable<(EnemyEntry, string, int)> source = list2; switch (sort) { case 1: source = list2.OrderBy<(EnemyEntry, string, int), string>(((EnemyEntry e, string name, int order) x) => x.name, StringComparer.OrdinalIgnoreCase); break; case 2: source = from x in list2 orderby x.e.Type.PowerLevel descending, x.order select x; break; } List<Node> list4 = source.Select<(EnemyEntry, string, int), Node>(((EnemyEntry e, string name, int order) x) => EnemyNode(x.e, x.name)).ToList(); list4.AddRange(list3); return list4; } private static IEnumerable<EnemyEntry> SortEnemies(IEnumerable<EnemyEntry> list, int sort) { return sort switch { 1 => list.OrderByDescending((EnemyEntry e) => e.Type.PowerLevel).ThenBy<EnemyEntry, string>((EnemyEntry e) => e.Display, StringComparer.OrdinalIgnoreCase), 2 => list.OrderBy<EnemyEntry, string>((EnemyEntry e) => (!(e.Mod == "Vanilla")) ? e.Mod : "", StringComparer.OrdinalIgnoreCase).ThenBy<EnemyEntry, string>((EnemyEntry e) => e.Display, StringComparer.OrdinalIgnoreCase), 3 => list.OrderBy((EnemyEntry e) => (!e.Daytime) ? (e.Outside ? 1 : 0) : 2).ThenBy<EnemyEntry, string>((EnemyEntry e) => e.Display, StringComparer.OrdinalIgnoreCase), _ => list.OrderBy<EnemyEntry, string>((EnemyEntry e) => e.Display, StringComparer.OrdinalIgnoreCase), }; } private static List<Node> EnemyNodes(IEnumerable<EnemyEntry> list, string empty) { List<Node> list2 = list.Select((EnemyEntry e) => EnemyNode(e, e.Display)).ToList(); if (list2.Count == 0 && empty.Length > 0) { list2.Add(Node.Info(empty)); } return list2; } private static Node EnemyNode(EnemyEntry e, string label) { Node node = Node.Choice(label, "enemy", e.Key, () => Choices("where", Where.SpawnOptions, () => Choices("count", Counts, () => Finals("spawn", "extra", Extras)), (string w) => Where.Disabled(w))); string text = (e.Daytime ? "day" : (e.Outside ? "outside" : "inside")); node.Hint = "power " + e.Type.PowerLevel.ToString("0.#") + " · " + text + ((e.Mod != "Vanilla") ? (" · " + e.Mod) : ""); return node; } private static List<Node> LightsGroup() { return new List<Node> { Node.Act("Breaker off (facility dark)", "breaker", null, "on", "0"), Node.Act("Breaker on", "breaker", null, "on", "1"), Node.Act("Flicker the whole facility", "flickerall"), Node.Act("Power surge (flash, then off)", "surge"), Node.Act("Ship lights off", "shiplights", null, "on", "0"), Node.Act("Ship lights on", "shiplights", null, "on", "1") }; } private static List<Node> DoorsGroup() { return new List<Node> { Node.Act("Lock doors within 20 m of them", "lockdoors", () => Game.NoTarget() ?? InsideOnly()), Node.Act("Unlock all doors", "unlockall"), Node.Act("Slam the nearest door to them", "slam", () => Game.NoTarget() ?? InsideOnly()), Node.Act("Close the door behind them", "closebehind", () => Game.NoTarget() ?? InsideOnly()), Node.Act("Big doors: close all", "bigdoors", null, "open", "0"), Node.Act("Big doors: open all", "bigdoors", null, "open", "1"), Node.Choice("Hide fire exits", "which", "fire", () => Finals("hideexits", "s", new(string, string)[3] { ("30 s", "30"), ("2 min", "120"), ("Until undone", "0") })), Node.Choice("Hide main entrance (30 s)", "which", "main", () => Finals("hideexits", "s", new(string, string)[1] { ("30 s", "30") })), Node.Act("Swap exits (2 min)", "swapexits"), Node.Act("Close the ship doors (20 s)", "shipdoors") }; } private static string InsideOnly() { PlayerControllerB target = Game.Target; if (!((Object)(object)target != (Object)null) || target.isInsideFactory) { return null; } return "they're outside"; } private static List<Node> EnemiesGroup() { return new List<Node> { Node.Group("Spawning", () => new List<Node> { Node.Act("Inside off", "spawning", null, "which", "inside").WithArg("on", "0"), Node.Act("Inside on", "spawning", null, "which", "inside").WithArg("on", "1"), Node.Act("Outside off", "spawning", null, "which", "outside").WithArg("on", "0"), Node.Act("Outside on", "spawning", null, "which", "outside").WithArg("on", "1"), Node.Act("Everything off", "spawning", null, "which", "all").WithArg("on", "0"), Node.Act("Everything on", "spawning", null, "which", "all").WithArg("on", "1") }), Node.Group("Kill", () => new List<Node> { Node.Act("All enemies", "kill", null, "which", "all"), Node.Act("Nearest to them", "kill", Game.NoTarget, "which", "nearthem"), Node.Act("Nearest to me", "kill", null, "which", "nearme") }), Node.Group("Freeze", () => Finals("freeze", "s", new(string, string)[3] { ("10 s", "10"), ("30 s", "30"), ("Until undone", "0") })), Node.Act("All enemies hunt them", "allhunt", Game.NoTarget), Node.Act("Enemies ignore me: on", "ignoreme", null, "on", "1"), Node.Act("Enemies ignore me: off", "ignoreme", null, "on", "0"), Node.Act("Teleport nearest enemy behind them", "tpenemy", Game.NoTarget), Node.Act("Make the nearest enemy stare", "stare", () => Game.NoTarget() ?? InsideOnly()) }; } private static List<Node> HazardsGroup() { return new List<Node> { Node.Group("Spawn", () => Choices("what", new(string, string)[3] { ("Turret", "turret"), ("Landmine", "mine"), ("Spike trap", "spike") }, () => Finals("hazard", "where", Where.HazardOptions, (string w) => Where.Disabled(w)), (string w) => (!((Object)(object)Hazards.Prefab(w) == (Object)null)) ? null : "not loaded")), Node.Act("Turret berserk (nearest to them)", "berserk", Game.NoTarget), Node.Act("Explode nearest landmine to them", "explodemine", Game.NoTarget), Node.Act("Fire nearest spike trap to them", "firespike", Game.NoTarget), Node.Act("Steam valve burst near them", "valve", Game.NoTarget), Node.Act("Quicksand under them", "quicksand", () => Game.NoTarget() ?? OutsideOnly()), Node.Act("Beehive near them", "beehive", () => Game.NoTarget() ?? OutsideOnly()) }; } private static string OutsideOnly() { PlayerControllerB target = Game.Target; if (!((Object)(object)target != (Object)null) || !target.isInsideFactory) { return null; } return "they're inside"; } private static List<Node> WeatherGroup() { return new List<Node> { Node.Group("Change now", delegate { SelectableLevel level = StartOfRound.Instance?.currentLevel; List<object> list = Compat.PossibleWeathers(level); if (list.Count == 0) { return new List<Node> { Node.Info(Compat.WeatherMissing() ?? "(WeatherRegistry isn't ready)") }; } string cur = Compat.CurrentWeatherName(level); return (from n in list.Select((object w) => Compat.WeatherNameOf(w)).Distinct() select Node.Act(n + ((n == cur) ? " (now)" : ""), "weather", null, "w", n)).ToList(); }, Compat.WeatherMissing), Node.Act("Meteor shower in 10 s", "meteor"), Node.Act("Flood rises faster", "floodfast", () => (!((Object)(object)TimeOfDay.Instance != (Object)null) || (int)TimeOfDay.Instance.currentLevelWeather != 4) ? "not flooded here" : null) }; } private static List<Node> EventsGroup() { List<Node> list = new List<Node>(); list.Add(Node.Sorted("Add event now", EventSorts, delegate(int i) { List<Node> list2 = SortEvents(Compat.BcmMidDay(), i).Select(delegate(object ev) { Node node = Node.Act(Compat.EventName(ev), "bcmevent", null, "e", ev.GetType().Name); node.Hint = Compat.EventGoodness(ev); return node; }).ToList(); if (list2.Count == 0) { list2.Add(Node.Info("(no mid-day events found)")); } return list2; })); list.Add(Node.Sorted("Today's events", new string[3] { "As rolled", "Good first", "Bad first" }, delegate(int i) { IList list2 = Compat.BcmList("currentEvents"); List<object> list3 = new List<object>(); if (list2 != null) { foreach (object item in list2) { if (item != null) { list3.Add(item); } } } switch (i) { case 1: list3 = list3.OrderBy(Compat.EventRank).ToList(); break; case 2: list3 = list3.OrderByDescending(Compat.EventRank).ToList(); break; } List<Node> list4 = list3.Select((object ev) => new Node { Label = Compat.EventName(ev), Hint = Compat.EventGoodness(ev) + " · " + Compat.EventDescription(ev), Disabled = () => "" }).ToList(); if (list4.Count == 0) { list4.Add(Node.Info("(no events today)")); } return list4; })); return list; } internal static IEnumerable<object> SortEvents(IEnumerable<object> evs, int sort) { return sort switch { 1 => evs.OrderBy(Compat.EventRank).ThenBy<object, string>(Compat.EventName, StringComparer.OrdinalIgnoreCase), 2 => evs.OrderByDescending(Compat.EventRank).ThenBy<object, string>(Compat.EventName, StringComparer.OrdinalIgnoreCase), _ => evs.OrderBy<object, string>(Compat.EventName, StringComparer.OrdinalIgnoreCase), }; } private static List<Node> TimeGroup() { return new List<Node> { Node.Act("Freeze the clock", "clock", Game.NotOnMoon, "on", "0"), Node.Act("Unfreeze the clock", "clock", null, "on", "1"), Node.Act("Skip ahead 1 hour", "skiphour", Game.NotOnMoon), Node.Act("Set time to evening", "settime", Game.NotOnMoon, "to", "evening"), Node.Act("Set time to night", "settime", Game.NotOnMoon, "to", "night"), Node.Act("Make the ship leave in 60 s", "leave", Game.NotOnMoon, "cancel", "0"), Node.Act("Cancel the early leave", "leave", null, "cancel", "1") }; } } internal class MenuView : MonoBehaviour { internal static MenuView Instance; internal static bool Dirty = true; private string _text = ""; private GUIStyle _style; private GUIStyle _box; private int _navVersion = -1; private int _resultVersion = -1; private readonly GUIContent _content = new GUIContent(); private Vector2 _size; private void Awake() { Instance = this; } internal static void UpdateEnabled() { if (!((Object)(object)Instance == (Object)null)) { ((Behaviour)Instance).enabled = Runner.MenuOpen || Spectate.Active; } } private void Rebuild() { //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) Navigator nav = MenuTree.Nav; StringBuilder stringBuilder = new StringBuilder(512); stringBuilder.Append("<b>Target:</b> ").Append(Game.TargetLabel()).Append(" <color=#8a8a8a>(← → on Target row)</color>\n"); string text = nav.PathText(); stringBuilder.Append("<color=#c8b27a>").Append((text.Length == 0) ? "Menu" : text).Append("</color>"); string sortName = nav.SortName; if (sortName != null) { stringBuilder.Append(" <color=#8a8a8a>Del: sort (").Append(sortName).Append(")</color>"); } stringBuilder.Append('\n'); IReadOnlyList<Node> items = nav.Items; if (items.Count == 0) { stringBuilder.Append("<color=#8a8a8a> (empty)</color>\n"); } int num = Mathf.Clamp(nav.Cursor - 6, 0, Mathf.Max(0, items.Count - 14)); int num2 = Mathf.Min(items.Count, num + 14); if (num > 0) { stringBuilder.Append("<color=#8a8a8a> ↑ ").Append(num).Append(" more</color>\n"); } for (int i = num; i < num2; i++) { Node node = items[i]; string text2 = null; try { text2 = node.Disabled?.Invoke(); } catch (Exception ex) { text2 = ex.Message; } bool flag = i == nav.Cursor; stringBuilder.Append(flag ? "<color=#ffd84a>▶ " : " "); if (text2 != null) { stringBuilder.Append("<color=#7a7a7a>"); } stringBuilder.Append(Esc(node.Text)); if (node.IsValue) { string s = ""; try { s = node.ValueText(); } catch { } stringBuilder.Append(": ← ").Append(Esc(s)).Append(" →"); } else if (node.IsGroup) { stringBuilder.Append(" ›"); } if (!string.IsNullOrEmpty(node.Hint)) { stringBuilder.Append(" <color=#8a8a8a>").Append(Esc(node.Hint)).Append("</color>"); } if (text2 != null) { stringBuilder.Append("</color>"); if (text2.Length > 0) { stringBuilder.Append(" <color=#8a6a6a>").Append(Esc(text2)).Append("</color>"); } } if (flag) { stringBuilder.Append("</color>"); } stringBuilder.Append('\n'); } if (num2 < items.Count) { stringBuilder.Append("<color=#8a8a8a> ↓ ").Append(items.Count - num2).Append(" more</color>\n"); } if (!string.IsNullOrEmpty(DNC.ResultLine)) { stringBuilder.Append("<color=#9fd39f>").Append(Esc(DNC.ResultLine)).Append("</color>"); } _text = stringBuilder.ToString().TrimEnd('\n'); _content.text = _text; _navVersion = nav.Version; _resultVersion = DNC.ResultVersion; _size = Vector2.zero; Dirty = false; } private static string Esc(string s) { if (!string.IsNullOrEmpty(s)) { return s.Replace("<", "‹").Replace(">", "›"); } return ""; } private void OnGUI() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00d0: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) if ((int)Event.current.type != 7 && (int)Event.current.type != 8) { return; } Spectate.Draw(); if (Runner.MenuOpen) { if (_style == null) { _style = new GUIStyle(GUI.skin.label) { richText = true, fontSize = Mathf.Clamp(Screen.height / 60, 12, 20), wordWrap = false }; _style.normal.textColor = new Color(0.92f, 0.92f, 0.92f); _box = new GUIStyle(GUI.skin.box); } if (Dirty || _navVersion != MenuTree.Nav.Version || _resultVersion != DNC.ResultVersion) { Rebuild(); } if (_size == Vector2.zero) { _size = _style.CalcSize(_content); } float num = Mathf.Max(_size.x + 20f, 320f); float num2 = _size.y + 12f; float num3 = ((Settings.Data.menuPosition == 0) ? (((float)Screen.width - num) / 2f) : 12f); Rect val = default(Rect); ((Rect)(ref val))..ctor(num3, 10f, num, num2); Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.72f); GUI.Box(val, GUIContent.none, _box); GUI.color = color; GUI.Label(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 6f, _size.x + 4f, _size.y), _content, _style); } } } internal static class MimicMenu { private const string TypeName = "MimicPlus.Debug"; private const int WantedApi = 1; private static int _apiVersion; private static Type _api; private static bool _resolved; private static readonly Dictionary<string, MethodInfo> _methods = new Dictionary<string, MethodInfo>(); private static PropertyInfo _available; private const string SimDeadTip = "needs a masked alive + your answer lines (made in orbit); ask on walkie: are you alive?"; private static bool _simBroken; private static string _responder = ""; private static float _responderAt = -10f; private static readonly (string label, string value)[] FakeQuestions = new(string, string)[5] { ("\"are you alive?\"", "are you alive?"), ("\"can you hear me?\"", "can you hear me?"), ("\"are you dead?\"", "are you dead?"), ("\"where are you?\" (normally no answer)", "where are you?"), ("\"we're going to the ship\"", "we're going to the ship") }; private static readonly Dictionary<string, (Type ret, Type[] args)> ArcSigs = new Dictionary<string, (Type, Type[])> { { "SetFrustration", (typeof(bool), new Type[1] { typeof(int) }) }, { "FakeQuestion", (typeof(string), new Type[1] { typeof(string) }) }, { "ForceResponse", (typeof(bool), new Type[2] { typeof(string), typeof(string) }) }, { "PreviewDistortion", (typeof(bool), new Type[2] { typeof(string), typeof(int) }) }, { "LayerSounds", (typeof(string[]), new Type[0]) }, { "PreviewLayerSound", (typeof(bool), new Type[1] { typeof(string) }) }, { "ResetResponderDay", (typeof(bool), new Type[0]) } }; private static readonly Dictionary<string, bool> _sigOk = new Dictionary<string, bool>(); private static readonly Dictionary<string, string> _arcBroken = new Dictionary<string, string>(); private static PropertyInfo _frustration; private static bool _frustrationLooked; internal const string TodayKey = "mimicplus-today"; private static Type Api { get { if (_resolved) { return _api; } Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type2; try { type2 = assembly.GetType("MimicPlus.Debug", throwOnError: false); } catch { continue; } if (type2 != null) { type = type2; break; } } if (type != null) { int num = -1; try { FieldInfo field = type.GetField("ApiVersion", BindingFlags.Static | BindingFlags.Public); if (field != null) { num = Convert.ToInt32(field.GetValue(null)); } } catch { num = -1; } _apiVersion = num; if (num < 1) { Plugin.Log.LogInfo((object)("DNC: Mimic+ found but its debug API is version " + num + " (want at least " + 1 + "); Mimic+ menu hidden")); type = null; } else { _available = type.GetProperty("Available", BindingFlags.Static | BindingFlags.Public); Plugin.Log.LogInfo((object)("DNC: Mimic+ debug API " + num + " found")); } } _api = type; if (type != null || Game.InGame) { _resolved = true; } return _api; } } internal static bool Shown { get { if (Api == null || _available == null) { return false; } try { return (bool)_available.GetValue(null); } catch (Exception ex) { Fail("Available", ex); return false; } } } private static string Missing() { if (!Shown) { return "Mimic+ isn't processing on this PC"; } return null; } private static MethodInfo M(string name) { if (_methods.TryGetValue(name, out var value)) { return value; } value = Api?.GetMethod(name, BindingFlags.Static | BindingFlags.Public); _methods[name] = value; return value; } private static object Call(string name, params object[] args) { MethodInfo methodInfo = M(name); if (methodInfo == null) { throw new MissingMethodException("MimicPlus.Debug", name); } return methodInfo.Invoke(null, args); } private static string[] Strings(string name, params object[] args) { try { return (Call(name, args) as string[]) ?? new string[0]; } catch (Exception ex) { Fail(name, ex); return new string[0]; } } private static string Do(string name, params object[] args) { try { object obj = Call(name, args); if (obj is bool && !(bool)obj) { return "Mimic+ couldn't do that right now (" + name + " said no)."; } return null; } catch (Exception ex) { Fail(name, ex); return "Mimic+ couldn't do that (see the log)."; } } private static void Fail(string what, Exception ex) { Exception ex2 = ((ex is TargetInvocationException && ex.InnerException != null) ? ex.InnerException : ex); Plugin.Log.LogWarning((object)("DNC: Mimic+ " + what + " failed: " + ex2.GetType().Name + ": " + ex2.Message)); } private static (string a, string b) Split2(string s) { int num = (s ?? "").IndexOf('|'); if (num >= 0) { return (a: s.Substring(0, num), b: s.Substring(num + 1)); } return (a: s ?? "", b: s ?? ""); } private static string Short(string s, int max = 60) { if (s != null) { if (s.Length > max) { return s.Substring(0, max - 1) + "…"; } return s; } return ""; } internal static void Register() { DNC.Register("mimicradio", Scope.Local, delegate(Ctx c) { string text = c.Args.Get("k", ""); string text2 = c.Args.Get("g", ""); return Do("ForceRadioMimic", text, text2) ?? ("Radio mimic: " + Who(text) + ", " + ((text2.Length == 0) ? "any group" : text2) + "."); }); DNC.Register("mimicline", Scope.Local, delegate(Ctx c) { string text = c.Args.Get("k", ""); string text2 = c.Args.Get("id", ""); return Do("PlayLine", text, text2) ?? ("Radio mimic: playing " + Who(text) + "'s line " + text2 + "."); }); DNC.Register("mimicsimdead", Scope.Local, (Ctx c) => ToggleSimDead()); DNC.Register("mimicfrust", Scope.Local, (Ctx c) => ArcBool("SetFrustration", "Frustration set to " + c.Args.GetInt("fl") + ".", c.Args.GetInt("fl")) ?? "Mimic+ wouldn't set the frustration level."); DNC.Register("mimicfakeq", Scope.Local, delegate(Ctx c) { string text = ArcMissing("FakeQuestion"); if (text != null) { return "Fake question: " + text + "."; } try { string text2 = Call("FakeQuestion", c.Args.Get("q", "")) as string; return string.IsNullOrEmpty(text2) ? "Fake question: (no reply from Mimic+)" : text2; } catch (Exception ex) { ArcFail("FakeQuestion", ex); return "Mimic+ couldn't do that (see the log)."; } }); DNC.Register("mimicresp", Scope.Local, (Ctx c) => ArcBool("ForceResponse", null, c.Args.Get("k", ""), c.Args.Get("kind", "yes")) ?? ("No checked " + c.Args.Get("kind", "") + " line for " + Who(c.Args.Get("k", "")) + " yet.")); DNC.Register("mimicdistort", Scope.Local, (Ctx c) => ArcBool("PreviewDistortion", "Distortion preview: level " + c.Args.GetInt("dl") + ", " + Who(c.Args.Get("k", "")) + "'s voice.", c.Args.Get("k", ""), c.Args.GetInt("dl")) ?? ("No checked line for " + Who(c.Args.Get("k", "")) + " to preview yet.")); DNC.Register("mimiclayer", Scope.Local, (Ctx c) => ArcBool("PreviewLayerSound", "Layer preview: " + c.Args.Get("s", "") + " at level 3.", c.Args.Get("s", "")) ?? "Mimic+ couldn't play that layer (no checked host line yet?)."); DNC.Register("mimicresetday", Scope.Local, (Ctx c) => ArcBool("ResetResponderDay", "Responder day reset") ?? "Mimic+ couldn't reset the responder day."); DNC.Register("mimiclate", Scope.Local, (Ctx c) => Do("ForceLateNight") ?? "Mimic+ late-night phase started."); DNC.Register("mimicreclone", Scope.Local, delegate(Ctx c) { string text = c.Args.Get("k", ""); return Do("Reclone", text) ?? (Who(text) + "'s clone will be rebuilt on the next ML pass."); }); DNC.Register("mimicrollback", Scope.Local, delegate(Ctx c) { string text = c.Args.Get("k", ""); return Do("RollbackClone", text) ?? (Who(text) + "'s clone rolled back to the previous reference."); }); DNC.Register("mimicgen", Scope.Local, delegate(Ctx c) { string text = c.Args.Get("k", ""); int num = c.Args.GetInt("n", 3); return Do("GenerateLines", text, num) ?? ("Generating " + num + " more cloned lines per daytime group for " + Who(text) + "."); }); DNC.Register("mimicreload", Scope.Local, delegate { try { Call("ReloadTextFiles"); return "Mimic+ text files reloaded (groups.json, lines*.txt, names.json)."; } catch (Exception ex) { Fail("ReloadTextFiles", ex); return "Mimic+ couldn't do that (see the log)."; } }); } private static string Who(string key) { if (string.IsNullOrEmpty(key)) { return "anyone"; } string[] array = Strings("Players"); for (int i = 0; i < array.Length; i++) { var (text, result) = Split2(array[i]); if (text == key) { return result; } } return key; } private static string SimDeadMissing() { if (_simBroken) { return "Mimic+ responder test failed earlier (see the log); off until restart"; } if (_apiVersion < 2 || M("SimulateDeadTeammate") == null) { return "needs Mimic+ 1.0.4"; } return Missing(); } private static bool SimulatingDead() { if (SimDeadMissing() != null) { return false; } try { PropertyInfo property = Api.GetProperty("SimulatingDeadTeammate", BindingFlags.Static | BindingFlags.Public); return property != null && (bool)property.GetValue(null); } catch (Exception ex) { SimFail("SimulatingDeadTeammate", ex); return false; } } private static string ResponderLine() { if (SimDeadMissing() != null) { return ""; } if (Time.unscaledTime - _responderAt < 1f) { return _responder; } _responderAt = Time.unscaledTime; try { _responder = (Call("ResponderState") as string) ?? ""; } catch (Exception ex) { SimFail("ResponderState", ex); _responder = ""; } return _responder; } private static string ToggleSimDead() { string text = SimDeadMissing(); if (text != null) { return "Simulate dead teammate: " + text + "."; } bool flag = SimulatingDead(); if (_simBroken) { return "Mimic+ couldn't do that (see the log)."; } object obj; try { obj = Call("SimulateDeadTeammate", !flag); } catch (Exception ex) { SimFail("SimulateDeadTeammate", ex); return "Mimic+ couldn't do that (see the log)."; } if (obj is bool && !(bool)obj) { return "Host only (Mimic+ processing host)"; } _responderAt = -10f; string text2 = ResponderLine(); if (text2.Length <= 0) { return "Simulate dead teammate " + ((!flag) ? "on" : "off") + "."; } return text2; } private static void SimFail(string what, Exception ex) { Fail(what, ex); if (!_simBroken) { Plugin.Log.LogWarning((object)"DNC: Mimic+ responder test switched off for this session"); } _simBroken = true; } private static Node SimDeadRow() { Node node = Node.Act("Simulate dead teammate (my voice)", "mimicsimdead", SimDeadMissing); node.LabelFn = () => "Simulate dead teammate (my voice): " + (SimulatingDead() ? "ON" : "off"); node.Hint = "needs a masked alive + your answer lines (made in orbit); ask on walkie: are you alive?"; return node; } private static Node SimDeadStateRow() { Node node = Node.Info(""); node.LabelFn = delegate { if (SimDeadMissing() != null) { return " (responder test needs Mimic+ 1.0.4)"; } string text = ResponderLine(); return " " + ((text.Length > 0) ? text : "Responder: (no state)"); }; return node; } private static bool SigOk(string name) { if (_sigOk.TryGetValue(name, out var value)) { return value; } value = false; if (Api != null && ArcSigs.TryGetValue(name, out (Type, Type[]) value2)) { MethodInfo method = Api.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, value2.Item2, null); value = method != null && method.ReturnType == value2.Item1; if (method != null && !value) { Plugin.Log.LogWarning((object)("DNC: Mimic+ " + name + " has an unexpected signature; its row stays off")); } } _sigOk[name] = value; return value; } private static string ArcMissing(string member) { string text = Missing(); if (text != null) { return text; } if (_arcBroken.TryGetValue(member, out var value)) { return value; } if (_apiVersion < 3 || !SigOk(member)) { return "needs Mimic+ 1.0.5"; } return null; } private static void ArcFail(string member, Exception ex) { Fail(member, ex); Exception ex2 = ((ex is TargetInvocationException && ex.InnerException != null) ? ex.InnerException : ex); _arcBroken[member] = "failed earlier: " + ex2.GetType().Name + " (off until restart)"; } private static string ArcBool(string member, string done, params object[] args) { string text = ArcMissing(member); if (text != null) { return member + ": " + text + "."; } object obj; try { obj = Call(member, args); } catch (Exception ex) { ArcFail(member, ex); return "Mimic+ couldn't do that (see the log)."; } if (obj is bool && !(bool)obj) { return null; } _responderAt = -10f; string text2 = ResponderLine(); if (done == null) { if (text2.Length <= 0) { return "Done."; } return text2; } return done + ((text2.Length > 0) ? (" | " + text2) : ""); } private static int? Frustration() { if (ArcMissing("SetFrustration") != null) { return null; } try { if (!_frustrationLooked) { _frustrationLooked = true; PropertyInfo property = Api.GetProperty("Frustration", BindingFlags.Static | BindingFlags.Public); _frustration = ((property != null && property.PropertyType == typeof(int)) ? property : null); } if (_frustration == null) { return null; } return (int)_frustration.GetValue(null); } catch (Exception ex) { ArcFail("SetFrustration", ex); return null; } } private static Node FrustrationRow() { Node node = Node.Value("Frustration", delegate { string text = ArcMissing("SetFrustration"); if (