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 Chaos Events v1.1.2
LCChaosEvents.dll
Decompiled 2 weeks 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.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCChaosMod.Cogs; using LCChaosMod.Cogs.BerserkTurret; using LCChaosMod.Cogs.FakeMessage; using LCChaosMod.Cogs.Firefly; using LCChaosMod.Cogs.Football; using LCChaosMod.Cogs.InfiniteStamina; using LCChaosMod.Cogs.MineSpawner; using LCChaosMod.Cogs.MobSpawner; using LCChaosMod.Cogs.PlayerSwap; using LCChaosMod.Cogs.RandomSound; using LCChaosMod.Cogs.SizeMatters; using LCChaosMod.Cogs.TeleportDungeon; using LCChaosMod.Cogs.TeleportShip; using LCChaosMod.Cogs.TurretSpawner; using LCChaosMod.Patches; using LCChaosMod.UI; using LCChaosMod.Utils; using Microsoft.CodeAnalysis; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; 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("LCChaosMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+b66cfc7106b7d3bef90993de39f4a2b1792586e9")] [assembly: AssemblyProduct("LCChaosMod")] [assembly: AssemblyTitle("LCChaosMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LCChaosMod { internal static class ChaosNetworkHandler { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnReceiveWarning; } private const string MsgWarning = "LCChaosMod_Warning"; public static void Init() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>O.<0>__OnReceiveWarning; if (obj == null) { HandleNamedMessageDelegate val = OnReceiveWarning; <>O.<0>__OnReceiveWarning = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("LCChaosMod_Warning", (HandleNamedMessageDelegate)obj); TeleportNet.Init(); LCChaosMod.Cogs.RandomSound.Net.Init(); LCChaosMod.Cogs.InfiniteStamina.Net.Init(); LCChaosMod.Cogs.Firefly.Net.Init(); LCChaosMod.Cogs.PlayerSwap.Net.Init(); LCChaosMod.Cogs.FakeMessage.Net.Init(); LCChaosMod.Cogs.SizeMatters.Net.Init(); LCChaosMod.Cogs.Football.Net.Init(); Plugin.Log.LogInfo((object)"[ChaosNetworkHandler] All handlers registered."); } public static void BroadcastWarning(string eventName) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) ShowHUD(eventName); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(512, (Allocator)2, -1); FastBufferWriter val2 = val; try { ((FastBufferWriter)(ref val)).WriteValueSafe(eventName, false); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("LCChaosMod_Warning", val, (NetworkDelivery)3); } finally { ((IDisposable)(FastBufferWriter)(ref val2)).Dispose(); } } private static void OnReceiveWarning(ulong _, FastBufferReader reader) { if (!NetworkManager.Singleton.IsServer) { string eventName = default(string); ((FastBufferReader)(ref reader)).ReadValueSafe(ref eventName, false); ShowHUD(eventName); } } private static void ShowHUD(string eventName) { bool num = ChaosSettings.Language.Value == "UA"; string text = (num ? "ХАОС" : "CHAOS"); string text2 = (num ? (eventName + " через 5 секунд!") : (eventName + " in 5 seconds!")); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip(text, text2, true, false, "LC_Tip1"); } } } public static class ChaosSettings { public static ConfigEntry<bool> ModEnabled { get; private set; } public static ConfigEntry<string> Language { get; private set; } public static ConfigEntry<float> MinInterval { get; private set; } public static ConfigEntry<float> MaxInterval { get; private set; } public static ConfigEntry<int> Difficulty { get; private set; } public static ConfigEntry<int> MineCountMin { get; private set; } public static ConfigEntry<int> MineCountMax { get; private set; } public static ConfigEntry<float> MineRateMin { get; private set; } public static ConfigEntry<float> MineRateMax { get; private set; } public static ConfigEntry<int> TurretCountMin { get; private set; } public static ConfigEntry<int> TurretCountMax { get; private set; } public static ConfigEntry<float> TurretRateMin { get; private set; } public static ConfigEntry<float> TurretRateMax { get; private set; } public static ConfigEntry<bool> EnableMines { get; private set; } public static ConfigEntry<bool> EnableTurrets { get; private set; } public static ConfigEntry<bool> EnableMobSpawn { get; private set; } public static ConfigEntry<bool> EnableTeleportDungeon { get; private set; } public static ConfigEntry<bool> EnableTeleportShip { get; private set; } public static ConfigEntry<bool> EnablePlayerSwap { get; private set; } public static ConfigEntry<bool> EnableGlowstick { get; private set; } public static ConfigEntry<bool> EnableRandomSound { get; private set; } public static ConfigEntry<bool> EnableInfiniteStamina { get; private set; } public static ConfigEntry<float> StaminaDuration { get; private set; } public static ConfigEntry<bool> EnableBerserkTurret { get; private set; } public static ConfigEntry<float> BerserkDuration { get; private set; } public static ConfigEntry<bool> EnableFootball { get; private set; } public static ConfigEntry<float> FootballDuration { get; private set; } public static ConfigEntry<bool> EnableFakeMessage { get; private set; } public static ConfigEntry<bool> EnableSizeMatters { get; private set; } public static ConfigEntry<float> SizeScale { get; private set; } public static ConfigEntry<float> SizeStretchScale { get; private set; } public static ConfigEntry<float> SizeDuration { get; private set; } public static void Init(ConfigFile config) { ModEnabled = config.Bind<bool>("General", "Enabled", true, "Вмикає/вимикає мод повністю"); Language = config.Bind<string>("General", "Language", "EN", "Мова повідомлень: EN / UA"); MinInterval = config.Bind<float>("Timing", "MinInterval", 20f, "Мінімальний інтервал між евентами (секунди)"); MaxInterval = config.Bind<float>("Timing", "MaxInterval", 120f, "Максимальний інтервал між евентами (секунди)"); Difficulty = config.Bind<int>("Difficulty", "Level", 2, "Складність: 1 (легко) — 3 (хаос)"); MineCountMin = config.Bind<int>("Mines", "CountMin", 5, "Мінімальна кількість мін за евент"); MineCountMax = config.Bind<int>("Mines", "CountMax", 10, "Максимальна кількість мін за евент"); MineRateMin = config.Bind<float>("Mines", "RateMin", 1f, "Мінімальний інтервал між мінами (с)"); MineRateMax = config.Bind<float>("Mines", "RateMax", 3f, "Максимальний інтервал між мінами (с)"); TurretCountMin = config.Bind<int>("Turrets", "CountMin", 2, "Мінімальна кількість турелей за евент"); TurretCountMax = config.Bind<int>("Turrets", "CountMax", 5, "Максимальна кількість турелей за евент"); TurretRateMin = config.Bind<float>("Turrets", "RateMin", 1f, "Мінімальний інтервал між турелями (с)"); TurretRateMax = config.Bind<float>("Turrets", "RateMax", 3f, "Максимальний інтервал між турелями (с)"); EnableMines = config.Bind<bool>("Events", "Mines", true, "Міни під ногами"); EnableTurrets = config.Bind<bool>("Events", "Turrets", true, "Турелі навколо"); EnableMobSpawn = config.Bind<bool>("Events", "MobSpawn", true, "Спавн рандомного моба"); EnableTeleportDungeon = config.Bind<bool>("Events", "TeleportDungeon", true, "Рандомна телепортація по данжу"); EnableTeleportShip = config.Bind<bool>("Events", "TeleportShip", true, "Телепортація на корабель"); EnablePlayerSwap = config.Bind<bool>("Events", "PlayerSwap", true, "Підміна гравців місцями"); EnableGlowstick = config.Bind<bool>("Events", "Glowstick", true, "Світіння при підйомі Apparatus"); EnableRandomSound = config.Bind<bool>("Events", "RandomSound", true, "Рандомний звук моба поруч"); EnableInfiniteStamina = config.Bind<bool>("Events", "InfiniteStamina", true, "Нескінченна витривалість"); StaminaDuration = config.Bind<float>("Events", "StaminaDuration", 10f, "Тривалість нескінченної витривалості (секунди)"); EnableBerserkTurret = config.Bind<bool>("Events", "BerserkTurret", true, "Турелі збожеволіли"); BerserkDuration = config.Bind<float>("Events", "BerserkDuration", 10f, "Тривалість берсерку турелі (секунди)"); EnableFootball = config.Bind<bool>("Events", "Football", true, "Час футболу"); FootballDuration = config.Bind<float>("Events", "FootballDuration", 30f, "Тривалість футбольного режиму (секунди)"); EnableFakeMessage = config.Bind<bool>("Events", "FakeMessage", true, "Фейкове повідомлення компанії"); EnableSizeMatters = config.Bind<bool>("Events", "SizeMatters", true, "Зміна розміру гравця"); SizeScale = config.Bind<float>("Events", "SizeScale", 0.4f, "Розмір маленького гравця (0.1 - 1.0)"); SizeStretchScale = config.Bind<float>("Events", "SizeStretchScale", 1.8f, "Висота великого гравця (1.0 - 3.0)"); SizeDuration = config.Bind<float>("Events", "SizeDuration", 15f, "Тривалість зміни розміру (секунди)"); } } public class EventManager : MonoBehaviour { [CompilerGenerated] private sealed class <EventLoop>d__9 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EventManager <>4__this; private IChaosEvent <next>5__2; object? IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EventLoop>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <next>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown int num = <>1__state; EventManager eventManager = <>4__this; float num2; switch (num) { default: return false; case 0: <>1__state = -1; Plugin.Log.LogInfo((object)"[EventManager] EventLoop entered."); goto IL_0044; case 1: { <>1__state = -1; Plugin.Log.LogInfo((object)"[EventManager] Picking event..."); if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.inShipPhase) { <>2__current = (object)new WaitForSeconds(5f); <>1__state = 2; return true; } SelectableLevel currentLevel = StartOfRound.Instance.currentLevel; if ((Object)(object)currentLevel != (Object)null && currentLevel.sceneName == "CompanyBuilding") { <>2__current = (object)new WaitForSeconds(5f); <>1__state = 3; return true; } <next>5__2 = eventManager.PickEvent(); if (<next>5__2 == null) { Plugin.Log.LogWarning((object)"[EventManager] No event available, skipping."); <>2__current = (object)new WaitForSeconds(5f); <>1__state = 4; return true; } Plugin.Log.LogInfo((object)("[EventManager] Chose: " + <next>5__2.GetName())); if (<next>5__2.ShowWarning()) { ChaosNetworkHandler.BroadcastWarning(<next>5__2.GetName()); <>2__current = (object)new WaitForSeconds(5f); <>1__state = 5; return true; } goto IL_01e0; } case 2: <>1__state = -1; goto IL_0044; case 3: <>1__state = -1; goto IL_0044; case 4: <>1__state = -1; goto IL_0044; case 5: { <>1__state = -1; goto IL_01e0; } IL_0044: num2 = Random.Range(ChaosSettings.MinInterval.Value, ChaosSettings.MaxInterval.Value); Plugin.Log.LogInfo((object)$"[EventManager] Next event in {num2:F1}s."); <>2__current = (object)new WaitForSeconds(Mathf.Max(0f, num2 - 5f)); <>1__state = 1; return true; IL_01e0: Plugin.Log.LogInfo((object)("[EventManager] Executing: " + <next>5__2.GetName())); try { <next>5__2.Execute(); } catch (Exception arg) { Plugin.Log.LogError((object)$"[EventManager] Error '{<next>5__2.GetName()}': {arg}"); } <next>5__2 = null; goto IL_0044; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private readonly List<IChaosEvent> _events = new List<IChaosEvent>(); private Coroutine? _loop; public static EventManager? Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { _events.Add(new MineSpawnEvent()); _events.Add(new TurretSpawnEvent()); _events.Add(new MobSpawnEvent()); _events.Add(new TeleportDungeonEvent()); _events.Add(new TeleportShipEvent()); _events.Add(new RandomSoundEvent()); _events.Add(new InfiniteStaminaEvent()); _events.Add(new PlayerSwapEvent()); _events.Add(new BerserkTurretEvent()); _events.Add(new FootballEvent()); _events.Add(new FakeMessageEvent()); _events.Add(new SizeMattersEvent()); Plugin.Log.LogInfo((object)$"[EventManager] Start() — {_events.Count} events registered."); if (_events.Count == 0) { Plugin.Log.LogWarning((object)"[EventManager] no events registered."); return; } _loop = ((MonoBehaviour)this).StartCoroutine(EventLoop()); Plugin.Log.LogInfo((object)"[EventManager] EventLoop coroutine started."); } private void OnDestroy() { if (_loop != null) { ((MonoBehaviour)this).StopCoroutine(_loop); } Instance = null; } [IteratorStateMachine(typeof(<EventLoop>d__9))] private IEnumerator EventLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EventLoop>d__9(0) { <>4__this = this }; } private IChaosEvent? PickEvent() { List<IChaosEvent> list = _events.FindAll((IChaosEvent e) => e.IsEnabled()); if (list.Count == 0) { return null; } return list[Random.Range(0, list.Count)]; } } internal static class MyPluginInfo { public const string PLUGIN_GUID = "s1spa.LCChaosEvents"; public const string PLUGIN_NAME = "LC Chaos Events"; public const string PLUGIN_VERSION = "1.1.0"; } [BepInPlugin("s1spa.LCChaosEvents", "LC Chaos Events", "1.1.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("s1spa.LCChaosEvents"); public static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; GameObject val = new GameObject("ChaosModButtonWatcher"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<ButtonWatcher>(); LCChaosMod.Cogs.MineSpawner.Lang.Init(); LCChaosMod.Cogs.TurretSpawner.Lang.Init(); LCChaosMod.Cogs.MobSpawner.Lang.Init(); LCChaosMod.Cogs.TeleportDungeon.Lang.Init(); LCChaosMod.Cogs.TeleportShip.Lang.Init(); LCChaosMod.Cogs.RandomSound.Lang.Init(); LCChaosMod.Cogs.InfiniteStamina.Lang.Init(); LCChaosMod.Cogs.Firefly.Lang.Init(); LCChaosMod.Cogs.PlayerSwap.Lang.Init(); LCChaosMod.Cogs.BerserkTurret.Lang.Init(); LCChaosMod.Cogs.Football.Lang.Init(); LCChaosMod.Cogs.FakeMessage.Lang.Init(); LCChaosMod.Cogs.SizeMatters.Lang.Init(); ChaosSettings.Init(((BaseUnityPlugin)this).Config); Loc.SetLang(ChaosSettings.Language.Value); _harmony.PatchAll(); RoundLifecycle.Init(); Log.LogInfo((object)"LC Chaos Events v1.1.0 loaded!"); } } public static class Loc { private static readonly Dictionary<string, Dictionary<string, string>> _t = new Dictionary<string, Dictionary<string, string>> { ["ui.title"] = T("Chaos Mod Settings", "Налаштування Chaos Mod"), ["ui.lang"] = T("Language", "Мова"), ["ui.min_interval"] = T("Minimum Event Interval", "Мінімальний інтервал"), ["ui.max_interval"] = T("Maximum Event Interval", "Максимальний інтервал"), ["ui.save"] = T("SAVE & CLOSE", "ЗБЕРЕГТИ"), ["ui.cancel"] = T("CANCEL", "СКАСУВАТИ"), ["ui.events"] = T("Events", "Події"), ["ui.enabled"] = T("Enabled", "Увімкнено"), ["ui.disabled"] = T("Disabled", "Вимкнено"), ["ui.s.lang"] = T("LANGUAGE", "МОВА"), ["ui.s.min_interval"] = T("MIN INTERVAL (sec)", "МІН ІНТЕРВАЛ (сек)"), ["ui.s.max_interval"] = T("MAX INTERVAL (sec)", "МАКС ІНТЕРВАЛ (сек)"), ["ui.s.mines"] = T("WHAT'S THAT SQUEAK?", "ЩО ЦЕ ЗА ПИСК?"), ["ui.s.turrets"] = T("DON'T MOVE!", "НЕ РУХАЙСЯ!"), ["ui.s.size_matters"] = T("SIZE MATTERS", "РОЗМІР МАЄ ЗНАЧЕННЯ"), ["ui.s.berserk_turret"] = T("TURRETS GOT RABIES!", "У ТУРЕЛІ ЗНАЙШЛИ СКАЗ!"), ["ui.s.football"] = T("FOOTBALL", "ФУТБОЛ"), ["ui.s.stamina"] = T("ADRENALINE", "АДРЕНАЛІН"), ["ui.s.mob_spawn"] = T("HUNTING", "ПОЛЮВАННЯ"), ["ui.s.teleport_dungeon"] = T("WHERE AM I?", "ДЕ Я? ХТО Я?"), ["ui.s.teleport_ship"] = T("LUNCH BREAK!", "ОБІДНЯ ПЕРЕРВА!"), ["ui.s.random_sound"] = T("SOMETHING'S WATCHING..", "ЩОСЬ СТЕЖИТЬ ЗА МНОЮ.."), ["ui.s.firefly"] = T("FIREFLY", "СВІТЛЯЧОК"), ["ui.s.player_swap"] = T("POSITIONING ERROR", "ПОМИЛКА ПОЗИЦІОНУВАННЯ"), ["ui.s.fake_message"] = T("COMPANY MESSAGE", "ПОВІДОМЛЕННЯ КОМПАНІЇ"), ["ui.s.enable"] = T("Enable", "Увімкнути"), ["ui.s.min_count"] = T("Min Count", "Мін. кількість"), ["ui.s.max_count"] = T("Max Count", "Макс. кількість"), ["ui.s.rate_min"] = T("Rate Min (s)", "Частота мін. (с)"), ["ui.s.rate_max"] = T("Rate Max (s)", "Частота макс. (с)"), ["ui.s.duration"] = T("Duration (s)", "Тривалість (с)"), ["ui.s.shrink_scale"] = T("Shrink Scale", "Масштаб зменшення"), ["ui.s.stretch_scale"] = T("Stretch Scale (Y)", "Масштаб розтягу (Y)") }; public static string Lang { get; private set; } = "EN"; public static void SetLang(string lang) { Lang = ((lang == "UA") ? "UA" : "EN"); } public static string Get(string key) { if (!_t.TryGetValue(key, out Dictionary<string, string> value) || !value.TryGetValue(Lang, out var value2)) { return key; } return value2; } public static void Register(string key, string en, string ua) { _t[key] = new Dictionary<string, string> { ["EN"] = en, ["UA"] = ua }; } private static Dictionary<string, string> T(string en, string ua) { return new Dictionary<string, string> { ["EN"] = en, ["UA"] = ua }; } } } namespace LCChaosMod.Utils { public static class PlayerUtils { public static PlayerControllerB? GetLocalPlayer() { return GameNetworkManager.Instance?.localPlayerController; } public static bool IsOnShip(PlayerControllerB player) { if (!player.isInElevator) { return player.isInHangarShipRoom; } return true; } public static bool IsInDungeon(PlayerControllerB player) { return player.isInsideFactory; } public static bool IsNearShip(Vector3 pos, float radius = 14f) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Transform val = StartOfRound.Instance?.elevatorTransform; if ((Object)(object)val == (Object)null) { return false; } return Vector3.Distance(pos, val.position) < radius; } } internal static class TeleportNet { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnReceive; } private const string MsgTeleport = "LCChaosMod_Teleport"; public static void Init() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>O.<0>__OnReceive; if (obj == null) { HandleNamedMessageDelegate val = OnReceive; <>O.<0>__OnReceive = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("LCChaosMod_Teleport", (HandleNamedMessageDelegate)obj); } public static void Send(PlayerControllerB player, Vector3 dest, bool toShip) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (player.actualClientId == NetworkManager.Singleton.LocalClientId) { Apply(player, dest, toShip); return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); FastBufferWriter val2 = val; try { ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref dest.x, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref dest.y, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref dest.z, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref toShip, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("LCChaosMod_Teleport", player.actualClientId, val, (NetworkDelivery)3); } finally { ((IDisposable)(FastBufferWriter)(ref val2)).Dispose(); } } private static void OnReceive(ulong _, FastBufferReader reader) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { float num = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num, default(ForPrimitives)); float num2 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives)); float num3 = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives)); bool toShip = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref toShip, default(ForPrimitives)); PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null)) { Apply(val, new Vector3(num, num2, num3), toShip); } } } private static void Apply(PlayerControllerB player, Vector3 dest, bool toShip) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (toShip) { player.isInsideFactory = false; player.isInHangarShipRoom = true; player.isInElevator = true; } player.TeleportPlayer(dest, false, 0f, false, true); } } } namespace LCChaosMod.UI { [HarmonyPatch(typeof(MenuManager), "Start")] internal static class MainMenuInjector { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Comparison<RectTransform> <>9__1_0; public static UnityAction <>9__1_1; internal int <TryInjectButton>b__1_0(RectTransform a, RectTransform b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return b.anchoredPosition.y.CompareTo(a.anchoredPosition.y); } internal void <TryInjectButton>b__1_1() { SettingsOverlay.Instance?.Show(); } } [HarmonyFinalizer] private static void Finalizer(Exception? __exception) { TryInjectButton(); } internal static void TryInjectButton() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Expected O, but got Unknown if ((Object)(object)GameObject.Find("ChaosModButton") != (Object)null) { return; } Button[] array = Object.FindObjectsOfType<Button>(true); Plugin.Log.LogInfo((object)$"[MainMenuInjector] Buttons found: {array.Length}"); Button val = null; float num = float.MinValue; float num2 = 60f; List<RectTransform> list = new List<RectTransform>(); Button[] array2 = array; foreach (Button val2 in array2) { RectTransform component = ((Component)val2).GetComponent<RectTransform>(); Vector2 val3 = (((Object)(object)component != (Object)null) ? component.anchoredPosition : Vector2.zero); ManualLogSource log = Plugin.Log; string name = ((Object)val2).name; Transform parent = ((Component)val2).transform.parent; log.LogInfo((object)$" '{name}' | parent: '{((parent != null) ? ((Object)parent).name : null)}' | anchoredPos: {val3}"); string text = ((Object)val2).name.ToLower(); if (text.Contains("host") || text.Contains("settings") || text.Contains("quit")) { val = (((Object)(object)val == (Object)null) ? val2 : val); } } if ((Object)(object)val == (Object)null) { val = ((array.Length != 0) ? array[0] : null); } if ((Object)(object)val == (Object)null) { return; } foreach (Transform item in ((Component)val).transform.parent) { RectTransform component2 = ((Component)item).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { list.Add(component2); } } if (list.Count >= 2) { list.Sort((RectTransform a, RectTransform b) => b.anchoredPosition.y.CompareTo(a.anchoredPosition.y)); num2 = list[1].anchoredPosition.y - list[0].anchoredPosition.y; num = list[0].anchoredPosition.y; } else if (list.Count == 1) { num = list[0].anchoredPosition.y; } Plugin.Log.LogInfo((object)$"[MainMenuInjector] topY={num}, spacing={num2}"); if ((Object)(object)SettingsOverlay.Instance == (Object)null) { GameObject val4 = new GameObject("ChaosModOverlay"); Object.DontDestroyOnLoad((Object)val4); val4.AddComponent<SettingsOverlay>(); } Button obj = Object.Instantiate<Button>(val, ((Component)val).transform.parent); ((Object)obj).name = "ChaosModButton"; TextMeshProUGUI componentInChildren = ((Component)obj).GetComponentInChildren<TextMeshProUGUI>(); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)componentInChildren).text = "> Chaos Mod"; } RectTransform component3 = ((Component)obj).GetComponent<RectTransform>(); if ((Object)(object)component3 != (Object)null) { component3.anchoredPosition = new Vector2(component3.anchoredPosition.x, num - num2); } ((Component)obj).transform.SetAsFirstSibling(); ((UnityEventBase)obj.onClick).RemoveAllListeners(); ButtonClickedEvent onClick = obj.onClick; object obj2 = <>c.<>9__1_1; if (obj2 == null) { UnityAction val5 = delegate { SettingsOverlay.Instance?.Show(); }; <>c.<>9__1_1 = val5; obj2 = (object)val5; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); Plugin.Log.LogInfo((object)"[MainMenuInjector] Button injected!"); } } internal class ButtonWatcher : MonoBehaviour { private float _timer; private const float Interval = 0.5f; private void Update() { _timer += Time.unscaledDeltaTime; if (!(_timer < 0.5f)) { _timer = 0f; if (!((Object)(object)Object.FindObjectOfType<MenuManager>() == (Object)null) && !((Object)(object)GameObject.Find("ChaosModButton") != (Object)null)) { Plugin.Log.LogInfo((object)"[ButtonWatcher] ChaosModButton відсутня — повторна ін'єкція."); MainMenuInjector.TryInjectButton(); } } } } public class SettingsOverlay : MonoBehaviour { private float _minInt; private float _maxInt; private int _diff; private int _langIdx; private bool _evtMines; private int _mineCountMin; private int _mineCountMax; private float _mineRateMin; private float _mineRateMax; private bool _evtTurrets; private int _turretCountMin; private int _turretCountMax; private float _turretRateMin; private float _turretRateMax; private bool _evtMob; private bool _evtTeleportDungeon; private bool _evtTeleportShip; private bool _evtRandomSound; private bool _evtInfiniteStamina; private float _staminaDuration; private bool _evtFirefly; private bool _evtPlayerSwap; private bool _evtBerserkTurret; private float _berserkDuration; private bool _evtFootball; private float _footballDuration; private bool _evtFakeMessage; private bool _evtSizeMatters; private float _sizeScale; private float _sizeStretchScale; private float _sizeDuration; private Font? _gameFont; private GameObject? _canvasRoot; private GameObject? _contentPanel; private static readonly string[] Langs = new string[2] { "EN", "UA" }; public static SettingsOverlay? Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); LoadFromConfig(); FindGameFont(); BuildModernCanvas(); Hide(); } public void Show() { LoadFromConfig(); GameObject? canvasRoot = _canvasRoot; if (canvasRoot != null) { canvasRoot.SetActive(true); } Canvas.ForceUpdateCanvases(); UpdateUIValues(); Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } public void Hide() { GameObject? canvasRoot = _canvasRoot; if (canvasRoot != null) { canvasRoot.SetActive(false); } } private void FindGameFont() { _gameFont = Resources.GetBuiltinResource<Font>("Arial.ttf"); Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val in array) { if (((Object)val).name.Contains("3270") || ((Object)val).name.Contains("edunline")) { _gameFont = val; break; } } } private void BuildModernCanvas() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_005f: 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) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) _canvasRoot = new GameObject("ChaosCanvas_UGUI"); Object.DontDestroyOnLoad((Object)(object)_canvasRoot); Canvas obj = _canvasRoot.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 999; _canvasRoot.AddComponent<GraphicRaycaster>(); CanvasScaler obj2 = _canvasRoot.AddComponent<CanvasScaler>(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); GameObject obj3 = UIBuilder.CreatePanel(_canvasRoot.transform, new Color(0f, 0f, 0f, 0.85f)); UIBuilder.StretchToFill(obj3.GetComponent<RectTransform>()); GameObject val = UIBuilder.CreatePanel(obj3.transform, new Color(0.03f, 0.05f, 0.03f, 1f)); val.GetComponent<RectTransform>().sizeDelta = new Vector2(900f, 750f); Outline obj4 = val.AddComponent<Outline>(); ((Shadow)obj4).effectColor = new Color(0.2f, 0.8f, 0.2f); ((Shadow)obj4).effectDistance = new Vector2(2f, -2f); VerticalLayoutGroup obj5 = val.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj5).padding = new RectOffset(30, 30, 30, 30); ((HorizontalOrVerticalLayoutGroup)obj5).spacing = 15f; ((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false; UIBuilder.CreateText(val.transform, "> LC CHAOS EVENTS v1.1.0", _gameFont, 36, new Color(0.2f, 0.9f, 0.2f), (TextAnchor)4, 50f); _contentPanel = UIBuilder.CreateScrollView(val.transform, new Vector2(840f, 520f)); PopulateSettings(); GameObject obj6 = UIBuilder.CreatePanel(val.transform, Color.clear); HorizontalLayoutGroup obj7 = obj6.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj7).spacing = 30f; ((LayoutGroup)obj7).childAlignment = (TextAnchor)4; obj6.GetComponent<RectTransform>().sizeDelta = new Vector2(840f, 60f); UIBuilder.CreateButton(obj6.transform, "[ SAVE ]", _gameFont, delegate { SaveToConfig(); Hide(); }, 200f, 50f); UIBuilder.CreateButton(obj6.transform, "[ CANCEL ]", _gameFont, Hide, 200f, 50f); Color color = default(Color); ((Color)(ref color))..ctor(0.2f, 0.5f, 0.2f); Text obj8 = UIBuilder.CreateText(val.transform, "BIOS ver. 1.1.0 by s1spa", _gameFont, 12, color, (TextAnchor)6, 18f); ((Component)obj8).gameObject.AddComponent<LayoutElement>().ignoreLayout = true; RectTransform component = ((Component)obj8).GetComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0f); component.anchorMax = val2; component.anchorMin = val2; component.pivot = new Vector2(0f, 0f); component.anchoredPosition = new Vector2(10f, 8f); component.sizeDelta = new Vector2(340f, 18f); Text obj9 = UIBuilder.CreateText(val.transform, "COMPANY DIRECTIVE", _gameFont, 12, color, (TextAnchor)8, 18f); ((Component)obj9).gameObject.AddComponent<LayoutElement>().ignoreLayout = true; RectTransform component2 = ((Component)obj9).GetComponent<RectTransform>(); ((Vector2)(ref val2))..ctor(1f, 0f); component2.anchorMax = val2; component2.anchorMin = val2; component2.pivot = new Vector2(1f, 0f); component2.anchoredPosition = new Vector2(-10f, 8f); component2.sizeDelta = new Vector2(280f, 18f); } private void Accordion(Transform parent, Func<string> getTitle, Action<Transform> fill) { Func<string> getTitle2 = getTitle; GameObject body = null; Button btn = null; bool isOpen = false; btn = UIBuilder.CreateAccordionBtn(parent, () => "> " + getTitle2(), _gameFont, delegate { isOpen = !isOpen; body.SetActive(isOpen); Text componentInChildren2 = ((Component)btn).GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.text = " " + (isOpen ? "v " : "> ") + getTitle2(); } }); ((Component)btn).gameObject.AddComponent<UIUpdater>().OnUpdate = delegate { Text componentInChildren = ((Component)btn).GetComponentInChildren<Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = " " + (isOpen ? "v " : "> ") + getTitle2(); } }; body = UIBuilder.CreateAccordionBody(parent); fill(body.transform); } private void PopulateSettings() { Transform transform = _contentPanel.transform; UIBuilder.CreateCycleButton(transform, L("ui.s.lang"), _gameFont, () => Langs[_langIdx], delegate { _langIdx = (_langIdx + 1) % Langs.Length; Loc.SetLang(Langs[_langIdx]); UpdateUIValues(); }); UIBuilder.CreateStepper(transform, L("ui.s.min_interval"), _gameFont, () => _minInt, delegate(float v) { _minInt = v; }, 5f); UIBuilder.CreateStepper(transform, L("ui.s.max_interval"), _gameFont, () => _maxInt, delegate(float v) { _maxInt = v; }, 5f); UIBuilder.CreateSpacer(transform, 15f); Accordion(transform, L("ui.s.mines"), delegate(Transform body) { UIBuilder.CreateToggle(body, L("ui.s.enable"), _gameFont, () => _evtMines, delegate(bool v) { _evtMines = v; }); UIBuilder.CreateStepper(body, L("ui.s.min_count"), _gameFont, () => _mineCountMin, delegate(float v) { _mineCountMin = (int)v; }, 1f); UIBuilder.CreateStepper(body, L("ui.s.max_count"), _gameFont, () => _mineCountMax, delegate(float v) { _mineCountMax = (int)v; }, 1f); UIBuilder.CreateStepper(body, L("ui.s.rate_min"), _gameFont, () => _mineRateMin, delegate(float v) { _mineRateMin = v; }, 0.5f); UIBuilder.CreateStepper(body, L("ui.s.rate_max"), _gameFont, () => _mineRateMax, delegate(float v) { _mineRateMax = v; }, 0.5f); }); Accordion(transform, L("ui.s.turrets"), delegate(Transform body) { UIBuilder.CreateToggle(body, L("ui.s.enable"), _gameFont, () => _evtTurrets, delegate(bool v) { _evtTurrets = v; }); UIBuilder.CreateStepper(body, L("ui.s.min_count"), _gameFont, () => _turretCountMin, delegate(float v) { _turretCountMin = (int)v; }, 1f); UIBuilder.CreateStepper(body, L("ui.s.max_count"), _gameFont, () => _turretCountMax, delegate(float v) { _turretCountMax = (int)v; }, 1f); UIBuilder.CreateStepper(body, L("ui.s.rate_min"), _gameFont, () => _turretRateMin, delegate(float v) { _turretRateMin = v; }, 0.5f); UIBuilder.CreateStepper(body, L("ui.s.rate_max"), _gameFont, () => _turretRateMax, delegate(float v) { _turretRateMax = v; }, 0.5f); }); Accordion(transform, L("ui.s.size_matters"), delegate(Transform body) { UIBuilder.CreateToggle(body, L("ui.s.enable"), _gameFont, () => _evtSizeMatters, delegate(bool v) { _evtSizeMatters = v; }); UIBuilder.CreateStepper(body, L("ui.s.shrink_scale"), _gameFont, () => _sizeScale, delegate(float v) { _sizeScale = v; }, 0.1f); UIBuilder.CreateStepper(body, L("ui.s.stretch_scale"), _gameFont, () => _sizeStretchScale, delegate(float v) { _sizeStretchScale = v; }, 0.1f); UIBuilder.CreateStepper(body, L("ui.s.duration"), _gameFont, () => _sizeDuration, delegate(float v) { _sizeDuration = v; }, 5f); }); Accordion(transform, L("ui.s.berserk_turret"), delegate(Transform body) { UIBuilder.CreateToggle(body, L("ui.s.enable"), _gameFont, () => _evtBerserkTurret, delegate(bool v) { _evtBerserkTurret = v; }); UIBuilder.CreateStepper(body, L("ui.s.duration"), _gameFont, () => _berserkDuration, delegate(float v) { _berserkDuration = v; }, 5f); }); Accordion(transform, L("ui.s.football"), delegate(Transform body) { UIBuilder.CreateToggle(body, L("ui.s.enable"), _gameFont, () => _evtFootball, delegate(bool v) { _evtFootball = v; }); UIBuilder.CreateStepper(body, L("ui.s.duration"), _gameFont, () => _footballDuration, delegate(float v) { _footballDuration = v; }, 5f); }); Accordion(transform, L("ui.s.stamina"), delegate(Transform body) { UIBuilder.CreateToggle(body, L("ui.s.enable"), _gameFont, () => _evtInfiniteStamina, delegate(bool v) { _evtInfiniteStamina = v; }); UIBuilder.CreateStepper(body, L("ui.s.duration"), _gameFont, () => _staminaDuration, delegate(float v) { _staminaDuration = v; }, 5f); }); UIBuilder.CreateSpacer(transform, 10f); UIBuilder.CreateToggle(transform, L("ui.s.mob_spawn"), _gameFont, () => _evtMob, delegate(bool v) { _evtMob = v; }); UIBuilder.CreateToggle(transform, L("ui.s.teleport_dungeon"), _gameFont, () => _evtTeleportDungeon, delegate(bool v) { _evtTeleportDungeon = v; }); UIBuilder.CreateToggle(transform, L("ui.s.teleport_ship"), _gameFont, () => _evtTeleportShip, delegate(bool v) { _evtTeleportShip = v; }); UIBuilder.CreateToggle(transform, L("ui.s.random_sound"), _gameFont, () => _evtRandomSound, delegate(bool v) { _evtRandomSound = v; }); UIBuilder.CreateToggle(transform, L("ui.s.firefly"), _gameFont, () => _evtFirefly, delegate(bool v) { _evtFirefly = v; }); UIBuilder.CreateToggle(transform, L("ui.s.player_swap"), _gameFont, () => _evtPlayerSwap, delegate(bool v) { _evtPlayerSwap = v; }); UIBuilder.CreateToggle(transform, L("ui.s.fake_message"), _gameFont, () => _evtFakeMessage, delegate(bool v) { _evtFakeMessage = v; }); static Func<string> L(string key) { string key2 = key; return () => Loc.Get(key2); } } private void UpdateUIValues() { if (!((Object)(object)_canvasRoot == (Object)null)) { IUIUpdater[] componentsInChildren = _canvasRoot.GetComponentsInChildren<IUIUpdater>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].UpdateVisuals(); } } } private void LoadFromConfig() { _minInt = ChaosSettings.MinInterval.Value; _maxInt = ChaosSettings.MaxInterval.Value; _diff = Mathf.Clamp(ChaosSettings.Difficulty.Value, 1, 5); _langIdx = ((ChaosSettings.Language.Value == "UA") ? 1 : 0); Loc.SetLang(Langs[_langIdx]); _evtMines = ChaosSettings.EnableMines.Value; _mineCountMin = ChaosSettings.MineCountMin.Value; _mineCountMax = ChaosSettings.MineCountMax.Value; _mineRateMin = ChaosSettings.MineRateMin.Value; _mineRateMax = ChaosSettings.MineRateMax.Value; _evtMob = ChaosSettings.EnableMobSpawn.Value; _evtTeleportDungeon = ChaosSettings.EnableTeleportDungeon.Value; _evtTeleportShip = ChaosSettings.EnableTeleportShip.Value; _evtRandomSound = ChaosSettings.EnableRandomSound.Value; _evtInfiniteStamina = ChaosSettings.EnableInfiniteStamina.Value; _staminaDuration = ChaosSettings.StaminaDuration.Value; _evtFirefly = ChaosSettings.EnableGlowstick.Value; _evtPlayerSwap = ChaosSettings.EnablePlayerSwap.Value; _evtBerserkTurret = ChaosSettings.EnableBerserkTurret.Value; _berserkDuration = ChaosSettings.BerserkDuration.Value; _evtFootball = ChaosSettings.EnableFootball.Value; _footballDuration = ChaosSettings.FootballDuration.Value; _evtFakeMessage = ChaosSettings.EnableFakeMessage.Value; _evtSizeMatters = ChaosSettings.EnableSizeMatters.Value; _sizeScale = ChaosSettings.SizeScale.Value; _sizeStretchScale = ChaosSettings.SizeStretchScale.Value; _sizeDuration = ChaosSettings.SizeDuration.Value; _evtTurrets = ChaosSettings.EnableTurrets.Value; _turretCountMin = ChaosSettings.TurretCountMin.Value; _turretCountMax = ChaosSettings.TurretCountMax.Value; _turretRateMin = ChaosSettings.TurretRateMin.Value; _turretRateMax = ChaosSettings.TurretRateMax.Value; } private void SaveToConfig() { ChaosSettings.MinInterval.Value = _minInt; ChaosSettings.MaxInterval.Value = _maxInt; ChaosSettings.Difficulty.Value = _diff; ChaosSettings.Language.Value = Langs[_langIdx]; ChaosSettings.EnableMines.Value = _evtMines; ChaosSettings.MineCountMin.Value = _mineCountMin; ChaosSettings.MineCountMax.Value = _mineCountMax; ChaosSettings.MineRateMin.Value = _mineRateMin; ChaosSettings.MineRateMax.Value = _mineRateMax; ChaosSettings.EnableMobSpawn.Value = _evtMob; ChaosSettings.EnableTeleportDungeon.Value = _evtTeleportDungeon; ChaosSettings.EnableTeleportShip.Value = _evtTeleportShip; ChaosSettings.EnableRandomSound.Value = _evtRandomSound; ChaosSettings.EnableInfiniteStamina.Value = _evtInfiniteStamina; ChaosSettings.StaminaDuration.Value = _staminaDuration; ChaosSettings.EnableGlowstick.Value = _evtFirefly; ChaosSettings.EnablePlayerSwap.Value = _evtPlayerSwap; ChaosSettings.EnableBerserkTurret.Value = _evtBerserkTurret; ChaosSettings.BerserkDuration.Value = _berserkDuration; ChaosSettings.EnableFootball.Value = _evtFootball; ChaosSettings.FootballDuration.Value = _footballDuration; ChaosSettings.EnableFakeMessage.Value = _evtFakeMessage; ChaosSettings.EnableSizeMatters.Value = _evtSizeMatters; ChaosSettings.SizeScale.Value = _sizeScale; ChaosSettings.SizeStretchScale.Value = _sizeStretchScale; ChaosSettings.SizeDuration.Value = _sizeDuration; ChaosSettings.EnableTurrets.Value = _evtTurrets; ChaosSettings.TurretCountMin.Value = _turretCountMin; ChaosSettings.TurretCountMax.Value = _turretCountMax; ChaosSettings.TurretRateMin.Value = _turretRateMin; ChaosSettings.TurretRateMax.Value = _turretRateMax; } } public static class UIBuilder { public static GameObject CreatePanel(Transform parent, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown GameObject val = new GameObject("Panel"); val.transform.SetParent(parent, false); ((Graphic)val.AddComponent<Image>()).color = color; return val; } public static void StretchToFill(RectTransform rt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = Vector2.zero; rt.offsetMax = Vector2.zero; } public static Text CreateText(Transform parent, string text, Font font, int size, Color color, TextAnchor align, float height) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>().sizeDelta = new Vector2(0f, height); Text obj = val.AddComponent<Text>(); obj.font = font; obj.text = text; obj.fontSize = size; ((Graphic)obj).color = color; obj.alignment = align; return obj; } public static GameObject CreateSpacer(Transform parent, float height) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown GameObject val = new GameObject("Spacer"); val.transform.SetParent(parent, false); val.AddComponent<RectTransform>().sizeDelta = new Vector2(0f, height); LayoutElement obj = val.AddComponent<LayoutElement>(); obj.preferredHeight = height; obj.minHeight = height; return val; } public static Button CreateButton(Transform parent, string text, Font font, Action onClick, float width, float height) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) Action onClick2 = onClick; GameObject obj = CreatePanel(parent, new Color(0.1f, 0.3f, 0.1f)); obj.GetComponent<RectTransform>().sizeDelta = new Vector2(width, height); obj.AddComponent<LayoutElement>().preferredHeight = height; Button val = obj.AddComponent<Button>(); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { onClick2(); }); StretchToFill(((Component)CreateText(obj.transform, text, font, 24, Color.white, (TextAnchor)4, height)).GetComponent<RectTransform>()); return val; } public static Button CreateAccordionBtn(Transform parent, Func<string> getText, Font font, Action onClick) { //IL_001d: 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) //IL_0055: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) Action onClick2 = onClick; GameObject obj = CreatePanel(parent, new Color(0.05f, 0.15f, 0.05f)); obj.AddComponent<LayoutElement>().preferredHeight = 40f; Button val = obj.AddComponent<Button>(); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { onClick2(); }); Text obj2 = CreateText(obj.transform, " " + getText(), font, 22, new Color(0.4f, 1f, 0.4f), (TextAnchor)3, 40f); StretchToFill(((Component)obj2).GetComponent<RectTransform>()); obj2.alignment = (TextAnchor)3; return val; } public static GameObject CreateAccordionBody(Transform parent) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown GameObject obj = CreatePanel(parent, Color.clear); obj.SetActive(false); VerticalLayoutGroup obj2 = obj.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj2).padding = new RectOffset(20, 0, 5, 5); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; obj.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; return obj; } public static void CreateStepper(Transform parent, Func<string> getLabel, Font font, Func<float> getVal, Action<float> setVal, float step) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) Action<float> setVal2 = setVal; Func<float> getVal2 = getVal; Func<string> getLabel2 = getLabel; GameObject val = CreatePanel(parent, Color.clear); HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).spacing = 15f; val.GetComponent<RectTransform>().sizeDelta = new Vector2(800f, 35f); Text labelText = CreateText(val.transform, getLabel2(), font, 20, Color.white, (TextAnchor)3, 35f); ((Component)labelText).GetComponent<RectTransform>().sizeDelta = new Vector2(400f, 35f); Text valText = CreateText(val.transform, getVal2().ToString("F1"), font, 22, Color.yellow, (TextAnchor)4, 35f); ((Component)valText).GetComponent<RectTransform>().sizeDelta = new Vector2(80f, 35f); CreateButton(val.transform, " - ", font, delegate { setVal2(getVal2() - step); valText.text = getVal2().ToString("F1"); }, 50f, 35f); ((Component)valText).transform.SetAsLastSibling(); CreateButton(val.transform, " + ", font, delegate { setVal2(getVal2() + step); valText.text = getVal2().ToString("F1"); }, 50f, 35f); val.AddComponent<UIUpdater>().OnUpdate = delegate { labelText.text = getLabel2(); valText.text = getVal2().ToString("F1"); }; } public static void CreateCycleButton(Transform parent, Func<string> getLabel, Font font, Func<string> getVal, Action onCycle) { //IL_001d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Action onCycle2 = onCycle; Func<string> getVal2 = getVal; Func<string> getLabel2 = getLabel; GameObject val = CreatePanel(parent, Color.clear); HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).spacing = 20f; val.GetComponent<RectTransform>().sizeDelta = new Vector2(800f, 35f); val.AddComponent<LayoutElement>().preferredHeight = 35f; Text labelText = CreateText(val.transform, getLabel2(), font, 20, Color.white, (TextAnchor)3, 35f); ((Component)labelText).GetComponent<RectTransform>().sizeDelta = new Vector2(400f, 35f); Text valText = null; Button val2 = CreateButton(val.transform, getVal2(), font, delegate { onCycle2(); valText.text = getVal2(); }, 120f, 35f); valText = ((Component)val2).GetComponentInChildren<Text>(); val.AddComponent<UIUpdater>().OnUpdate = delegate { labelText.text = getLabel2(); valText.text = getVal2(); }; } public static void CreateToggle(Transform parent, Func<string> getLabel, Font font, Func<bool> getVal, Action<bool> setVal) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) Action<bool> setVal2 = setVal; Func<bool> getVal2 = getVal; Func<string> getLabel2 = getLabel; GameObject val = CreatePanel(parent, Color.clear); HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).spacing = 20f; val.GetComponent<RectTransform>().sizeDelta = new Vector2(800f, 35f); Text labelText = CreateText(val.transform, getLabel2(), font, 20, Color.white, (TextAnchor)3, 35f); ((Component)labelText).GetComponent<RectTransform>().sizeDelta = new Vector2(400f, 35f); Text btnText = null; Button val2 = CreateButton(val.transform, getVal2() ? "[ ON ]" : "[ OFF ]", font, delegate { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) setVal2(!getVal2()); btnText.text = (getVal2() ? "[ ON ]" : "[ OFF ]"); ((Graphic)btnText).color = (getVal2() ? Color.green : Color.red); }, 100f, 35f); btnText = ((Component)val2).GetComponentInChildren<Text>(); ((Graphic)btnText).color = (getVal2() ? Color.green : Color.red); val.AddComponent<UIUpdater>().OnUpdate = delegate { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) labelText.text = getLabel2(); btnText.text = (getVal2() ? "[ ON ]" : "[ OFF ]"); ((Graphic)btnText).color = (getVal2() ? Color.green : Color.red); }; } public static GameObject CreateScrollView(Transform parent, Vector2 size) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown GameObject obj = CreatePanel(parent, new Color(0f, 0f, 0f, 0.2f)); obj.GetComponent<RectTransform>().sizeDelta = size; ScrollRect val = obj.AddComponent<ScrollRect>(); val.horizontal = false; val.scrollSensitivity = 5f; val.movementType = (MovementType)2; GameObject val2 = CreatePanel(obj.transform, Color.clear); StretchToFill(val2.GetComponent<RectTransform>()); val2.AddComponent<RectMask2D>(); val.viewport = val2.GetComponent<RectTransform>(); GameObject obj2 = CreatePanel(val2.transform, Color.clear); RectTransform component = obj2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.sizeDelta = new Vector2(0f, 0f); VerticalLayoutGroup obj3 = obj2.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj3).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)obj3).spacing = 10f; ((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true; obj2.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; val.content = component; return obj2; } } public interface IUIUpdater { void UpdateVisuals(); } public class UIUpdater : MonoBehaviour, IUIUpdater { public Action OnUpdate; public void UpdateVisuals() { OnUpdate?.Invoke(); } } } namespace LCChaosMod.Patches { public class LungPropWatcher : MonoBehaviour { private bool _triggered; private void Update() { if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.inShipPhase) { _triggered = false; FireflyTracker.Cleanup(); } else if (!_triggered && ChaosSettings.EnableGlowstick.Value) { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null) && val.currentlyHeldObjectServer is LungProp) { _triggered = true; Plugin.Log.LogInfo((object)"[LungPropWatcher] Local player grabbed Apparatus."); FireflyTracker.OnLocalPlayerGrabbed(); } } } } internal static class RoundLifecycle { public static void Init() { SceneManager.sceneLoaded += OnSceneLoaded; Plugin.Log.LogInfo((object)"[RoundLifecycle] Registered sceneLoaded."); } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Plugin.Log.LogInfo((object)("[RoundLifecycle] Scene loaded: '" + ((Scene)(ref scene)).name + "'")); if (((Scene)(ref scene)).name.StartsWith("Level")) { ChaosNetworkHandler.Init(); StartRound(); } else if (((Scene)(ref scene)).name == "SampleSceneRelay") { StopRound(); } } private static void StartRound() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) new GameObject("LungPropWatcher").AddComponent<LungPropWatcher>(); if (ChaosSettings.ModEnabled.Value && NetworkManager.Singleton.IsServer && !((Object)(object)EventManager.Instance != (Object)null) && (!((Object)(object)StartOfRound.Instance != (Object)null) || StartOfRound.Instance.currentLevelID != 3)) { new GameObject("ChaosEventManager").AddComponent<EventManager>(); Plugin.Log.LogInfo((object)"[RoundLifecycle] EventManager started."); } } private static void StopRound() { if ((Object)(object)EventManager.Instance != (Object)null) { Object.Destroy((Object)(object)((Component)EventManager.Instance).gameObject); Plugin.Log.LogInfo((object)"[RoundLifecycle] EventManager stopped."); } FireflyTracker.Cleanup(); } } } namespace LCChaosMod.Cogs { public class BerserkTurretEvent : IChaosEvent { [CompilerGenerated] private sealed class <BerserkCoroutine>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Turret turret; public float duration; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BerserkCoroutine>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002e: 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_0044: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)turret == (Object)null) { return false; } turret.turretMode = (TurretMode)3; <>2__current = (object)new WaitForSeconds(duration); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)turret != (Object)null) { turret.turretMode = (TurretMode)0; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public string GetName() { return Loc.Get("event.berserk_turret"); } public bool IsEnabled() { return ChaosSettings.EnableBerserkTurret.Value; } public void Execute() { if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[BerserkTurretEvent] Skipped - not host."); return; } Turret[] array = Object.FindObjectsOfType<Turret>(); if (array.Length == 0) { Plugin.Log.LogInfo((object)"[BerserkTurretEvent] No turrets found."); return; } float value = ChaosSettings.BerserkDuration.Value; Plugin.Log.LogInfo((object)$"[BerserkTurretEvent] {array.Length} turret(s) going berserk for {value}s."); Turret[] array2 = array; foreach (Turret turret in array2) { EventManager? instance = EventManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(BerserkCoroutine(turret, value)); } } } [IteratorStateMachine(typeof(<BerserkCoroutine>d__3))] private static IEnumerator BerserkCoroutine(Turret turret, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BerserkCoroutine>d__3(0) { turret = turret, duration = duration }; } } public class FootballEvent : IChaosEvent { public string GetName() { return Loc.Get("event.football"); } public bool IsEnabled() { return ChaosSettings.EnableFootball.Value; } public void Execute() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[FootballEvent] Skipped - not host."); return; } float value = ChaosSettings.FootballDuration.Value; Plugin.Log.LogInfo((object)$"[FootballEvent] Starting for {value}s."); new GameObject("FootballWatcher").AddComponent<FootballWatcher>().Setup(value); } } public interface IChaosEvent { string GetName(); bool IsEnabled(); void Execute(); bool ShowWarning() { return true; } } public class InfiniteStaminaEvent : IChaosEvent { public string GetName() { return Loc.Get("event.adrenaline"); } public bool IsEnabled() { return ChaosSettings.EnableInfiniteStamina.Value; } public void Execute() { LCChaosMod.Cogs.InfiniteStamina.Net.Broadcast(ChaosSettings.StaminaDuration.Value); } } public class MineSpawnEvent : IChaosEvent { [CompilerGenerated] private sealed class <SpawnLoop>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private GameObject <prefab>5__2; private int <count>5__3; private int <i>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnLoop>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <prefab>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <prefab>5__2 = FindMinePrefab(); if ((Object)(object)<prefab>5__2 == (Object)null) { Plugin.Log.LogWarning((object)"[MineSpawnEvent] Mine prefab not found in spawnableMapObjects."); return false; } <count>5__3 = Random.Range(ChaosSettings.MineCountMin.Value, ChaosSettings.MineCountMax.Value + 1); Plugin.Log.LogInfo((object)$"[MineSpawnEvent] Spawning {<count>5__3} mines."); <i>5__4 = 0; break; case 1: <>1__state = -1; <i>5__4++; break; } if (<i>5__4 < <count>5__3) { SpawnMine(<prefab>5__2); <>2__current = (object)new WaitForSeconds(Random.Range(ChaosSettings.MineRateMin.Value, ChaosSettings.MineRateMax.Value)); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public string GetName() { return Loc.Get("event.mines"); } public bool IsEnabled() { return ChaosSettings.EnableMines.Value; } public void Execute() { if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[MineSpawnEvent] Skipped - not host."); return; } EventManager? instance = EventManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(SpawnLoop()); } } [IteratorStateMachine(typeof(<SpawnLoop>d__3))] private static IEnumerator SpawnLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnLoop>d__3(0); } private static GameObject? FindMinePrefab() { SpawnableMapObject[] array = StartOfRound.Instance?.currentLevel?.spawnableMapObjects; if (array == null) { return null; } SpawnableMapObject[] array2 = array; foreach (SpawnableMapObject val in array2) { if ((Object)(object)val?.prefabToSpawn != (Object)null && (Object)(object)val.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null) { return val.prefabToSpawn; } } return null; } private static void SpawnMine(GameObject prefab) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB randomOutdoorPlayer = GetRandomOutdoorPlayer(); if ((Object)(object)randomOutdoorPlayer == (Object)null) { Plugin.Log.LogInfo((object)"[MineSpawnEvent] No outdoor player found, skipping mine."); return; } float num = Random.Range(-6f, 6f); float num2 = Random.Range(-6f, 6f); Vector3 val = ((Component)randomOutdoorPlayer).transform.position + new Vector3(num, 0f, num2); if (randomOutdoorPlayer.isInsideFactory) { NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 5f, -1)) { val = ((NavMeshHit)(ref val2)).position; } } else { int mask = LayerMask.GetMask(new string[5] { "Room", "Colliders", "Default", "Terrain", "MapHazards" }); RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val + Vector3.up * 50f, Vector3.down, ref val3, 150f, mask, (QueryTriggerInteraction)1)) { val = ((RaycastHit)(ref val3)).point; } } if (PlayerUtils.IsNearShip(val)) { Plugin.Log.LogInfo((object)"[MineSpawnEvent] Spawn pos too close to ship, skipping."); return; } Transform transform = RoundManager.Instance.mapPropsContainer.transform; NetworkObject component = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity, transform).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null) { component.Spawn(true); } else { Plugin.Log.LogWarning((object)"[MineSpawnEvent] Mine prefab has no NetworkObject component."); } } private static PlayerControllerB? GetRandomOutdoorPlayer() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (val.isPlayerControlled && !val.isPlayerDead && !PlayerUtils.IsOnShip(val)) { list.Add(val); } } if (list.Count == 0) { return null; } return list[Random.Range(0, list.Count)]; } } public class MobSpawnEvent : IChaosEvent { public string GetName() { return Loc.Get("event.mob"); } public bool IsEnabled() { return ChaosSettings.EnableMobSpawn.Value; } public void Execute() { if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[MobSpawnEvent] Skipped - not host."); return; } PlayerControllerB randomLivingPlayer = GetRandomLivingPlayer(); if ((Object)(object)randomLivingPlayer == (Object)null) { Plugin.Log.LogInfo((object)"[MobSpawnEvent] No living player found."); } else if (randomLivingPlayer.isInsideFactory) { SpawnIndoor(randomLivingPlayer); } else { SpawnOutdoor(randomLivingPlayer); } } private static void SpawnIndoor(PlayerControllerB target) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) List<SpawnableEnemyWithRarity> list = RoundManager.Instance.currentLevel?.Enemies; if (list == null || list.Count == 0) { Plugin.Log.LogWarning((object)"[MobSpawnEvent] No indoor enemies on this level."); return; } int num = Random.Range(0, list.Count); string enemyName = list[num].enemyType.enemyName; Vector3 nearestInsideNode = GetNearestInsideNode(((Component)target).transform.position); Plugin.Log.LogInfo((object)("[MobSpawnEvent] Spawning indoor '" + enemyName + "' near " + target.playerUsername + ".")); RoundManager.Instance.SpawnEnemyOnServer(nearestInsideNode, Random.Range(0f, 360f), num); } private static void SpawnOutdoor(PlayerControllerB target) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) List<SpawnableEnemyWithRarity> list = RoundManager.Instance.currentLevel?.OutsideEnemies; if (list == null || list.Count == 0) { Plugin.Log.LogWarning((object)"[MobSpawnEvent] No outdoor enemies on this level."); return; } int index = Random.Range(0, list.Count); EnemyType enemyType = list[index].enemyType; string enemyName = enemyType.enemyName; float num = Random.Range(-10f, 10f); float num2 = Random.Range(-10f, 10f); Vector3 val = ((Component)target).transform.position + new Vector3(num, 0f, num2); float num3 = Random.Range(0f, 360f); if (PlayerUtils.IsNearShip(val)) { Plugin.Log.LogInfo((object)"[MobSpawnEvent] Spawn pos too close to ship, skipping."); return; } Plugin.Log.LogInfo((object)("[MobSpawnEvent] Spawning outdoor '" + enemyName + "' near " + target.playerUsername + ".")); GameObject val2 = Object.Instantiate<GameObject>(enemyType.enemyPrefab, val, Quaternion.Euler(0f, num3, 0f)); NetworkObject componentInChildren = val2.GetComponentInChildren<NetworkObject>(); if ((Object)(object)componentInChildren == (Object)null) { Object.Destroy((Object)(object)val2); return; } componentInChildren.Spawn(true); EnemyAI component = val2.GetComponent<EnemyAI>(); if ((Object)(object)component != (Object)null) { component.isOutside = true; component.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode"); RoundManager.Instance.SpawnedEnemies.Add(component); } } private static Vector3 GetNearestInsideNode(Vector3 origin) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; if (insideAINodes == null || insideAINodes.Length == 0) { return origin; } float num = float.MaxValue; Vector3 result = origin; GameObject[] array = insideAINodes; foreach (GameObject val in array) { float num2 = Vector3.SqrMagnitude(val.transform.position - origin); if (num2 < num) { num = num2; result = val.transform.position; } } return result; } private static PlayerControllerB? GetRandomLivingPlayer() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (val.isPlayerControlled && !val.isPlayerDead && !PlayerUtils.IsOnShip(val)) { list.Add(val); } } if (list.Count == 0) { return null; } return list[Random.Range(0, list.Count)]; } } public class PlayerSwapEvent : IChaosEvent { public string GetName() { return Loc.Get("event.player_swap"); } public bool IsEnabled() { return ChaosSettings.EnablePlayerSwap.Value; } public void Execute() { //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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[PlayerSwapEvent] Skipped - not host."); return; } List<PlayerControllerB> eligiblePlayers = GetEligiblePlayers(); if (eligiblePlayers.Count < 2) { Plugin.Log.LogInfo((object)"[PlayerSwapEvent] Not enough players to swap."); return; } int num = Random.Range(0, eligiblePlayers.Count); int num2; do { num2 = Random.Range(0, eligiblePlayers.Count); } while (num2 == num); PlayerControllerB val = eligiblePlayers[num]; PlayerControllerB val2 = eligiblePlayers[num2]; Vector3 position = ((Component)val).transform.position; Vector3 position2 = ((Component)val2).transform.position; bool isInsideFactory = val.isInsideFactory; bool isInsideFactory2 = val2.isInsideFactory; Plugin.Log.LogInfo((object)("[PlayerSwapEvent] Swapping " + val.playerUsername + " ↔ " + val2.playerUsername + ".")); LCChaosMod.Cogs.PlayerSwap.Net.Send(val, position2, isInsideFactory2); LCChaosMod.Cogs.PlayerSwap.Net.Send(val2, position, isInsideFactory); } private static List<PlayerControllerB> GetEligiblePlayers() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return new List<PlayerControllerB>(); } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (val.isPlayerControlled && !val.isPlayerDead && !PlayerUtils.IsOnShip(val)) { list.Add(val); } } return list; } } public class RandomSoundEvent : IChaosEvent { public string GetName() { return Loc.Get("event.random_sound"); } public bool IsEnabled() { return ChaosSettings.EnableRandomSound.Value; } public void Execute() { //IL_01b8: 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) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) List<PlayerControllerB> insidePlayers = GetInsidePlayers(); if (insidePlayers.Count == 0) { Plugin.Log.LogInfo((object)"[RandomSoundEvent] No players inside factory."); return; } List<SpawnableEnemyWithRarity> list = RoundManager.Instance?.currentLevel?.Enemies; if (list == null || list.Count == 0) { Plugin.Log.LogWarning((object)"[RandomSoundEvent] No indoor enemies on this level."); return; } List<AudioClip> list2 = new List<AudioClip>(); foreach (SpawnableEnemyWithRarity item in list) { AudioClip[] array = item?.enemyType?.audioClips; if (array == null) { continue; } AudioClip[] array2 = array; foreach (AudioClip val in array2) { if ((Object)(object)val != (Object)null) { list2.Add(val); } } } if (list2.Count == 0) { Plugin.Log.LogWarning((object)"[RandomSoundEvent] No enemies with audioClips on this level."); return; } AudioClip val2 = list2[Random.Range(0, list2.Count)]; if (!((Object)(object)val2 == (Object)null)) { for (int num = insidePlayers.Count - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); List<PlayerControllerB> list3 = insidePlayers; int i = num; int index = num2; PlayerControllerB value = insidePlayers[num2]; PlayerControllerB value2 = insidePlayers[num]; list3[i] = value; insidePlayers[index] = value2; } int num3 = Mathf.Max(1, insidePlayers.Count / 2); int num4 = Random.Range(1, num3 + 1); for (int j = 0; j < num4; j++) { PlayerControllerB val3 = insidePlayers[j]; float num5 = Random.Range(-6f, 6f); float num6 = Random.Range(-6f, 6f); Vector3 pos = ((Component)val3).transform.position + new Vector3(num5, 1f, num6); Plugin.Log.LogInfo((object)("[RandomSoundEvent] Playing '" + ((Object)val2).name + "' near " + val3.playerUsername + ".")); LCChaosMod.Cogs.RandomSound.Net.Broadcast(((Object)val2).name, pos); } } } private static List<PlayerControllerB> GetInsidePlayers() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return new List<PlayerControllerB>(); } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (val.isPlayerControlled && !val.isPlayerDead && PlayerUtils.IsInDungeon(val)) { list.Add(val); } } return list; } } public class TeleportDungeonEvent : IChaosEvent { public string GetName() { return Loc.Get("event.teleport_dungeon"); } public bool IsEnabled() { return ChaosSettings.EnableTeleportDungeon.Value; } public void Execute() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[TeleportDungeonEvent] Skipped - not host."); return; } GameObject[] array = RoundManager.Instance?.insideAINodes; if (array == null || array.Length == 0) { Plugin.Log.LogWarning((object)"[TeleportDungeonEvent] No inside AI nodes."); return; } List<PlayerControllerB> insidePlayers = GetInsidePlayers(); if (insidePlayers.Count == 0) { Plugin.Log.LogInfo((object)"[TeleportDungeonEvent] No players inside factory."); return; } foreach (PlayerControllerB item in insidePlayers) { Vector3 position = array[Random.Range(0, array.Length)].transform.position; Plugin.Log.LogInfo((object)$"[TeleportDungeonEvent] Teleporting {item.playerUsername} to {position}."); TeleportNet.Send(item, position, toShip: false); } } private static List<PlayerControllerB> GetInsidePlayers() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return new List<PlayerControllerB>(); } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (val.isPlayerControlled && !val.isPlayerDead && PlayerUtils.IsInDungeon(val)) { list.Add(val); } } return list; } } public class TeleportShipEvent : IChaosEvent { public string GetName() { return Loc.Get("event.teleport_ship"); } public bool IsEnabled() { return ChaosSettings.EnableTeleportShip.Value; } public void Execute() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[TeleportShipEvent] Skipped - not host."); return; } Vector3 shipPosition = GetShipPosition(); List<PlayerControllerB> playersNotOnShip = GetPlayersNotOnShip(); if (playersNotOnShip.Count == 0) { Plugin.Log.LogInfo((object)"[TeleportShipEvent] All players already on ship."); return; } PlayerControllerB val = playersNotOnShip[Random.Range(0, playersNotOnShip.Count)]; Plugin.Log.LogInfo((object)("[TeleportShipEvent] Teleporting " + val.playerUsername + " to ship.")); TeleportNet.Send(val, shipPosition, toShip: true); } private static Vector3 GetShipPosition() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Transform val = StartOfRound.Instance?.middleOfShipNode; if ((Object)(object)val != (Object)null) { return val.position; } Transform[] array = StartOfRound.Instance?.playerSpawnPositions; if (array != null && array.Length != 0) { return array[0].position; } return Vector3.zero; } private static List<PlayerControllerB> GetPlayersNotOnShip() { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return new List<PlayerControllerB>(); } List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array2 = array; foreach (PlayerControllerB val in array2) { if (val.isPlayerControlled && !val.isPlayerDead && !PlayerUtils.IsOnShip(val)) { list.Add(val); } } return list; } } public class TurretSpawnEvent : IChaosEvent { [CompilerGenerated] private sealed class <SpawnLoop>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private GameObject <prefab>5__2; private int <count>5__3; private int <i>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpawnLoop>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <prefab>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <prefab>5__2 = FindTurretPrefab(); if ((Object)(object)<prefab>5__2 == (Object)null) { Plugin.Log.LogWarning((object)"[TurretSpawnEvent] Turret prefab not found in spawnableMapObjects."); return false; } <count>5__3 = Random.Range(ChaosSettings.TurretCountMin.Value, ChaosSettings.TurretCountMax.Value + 1); Plugin.Log.LogInfo((object)$"[TurretSpawnEvent] Spawning {<count>5__3} turrets."); <i>5__4 = 0; break; case 1: <>1__state = -1; <i>5__4++; break; } if (<i>5__4 < <count>5__3) { SpawnTurret(<prefab>5__2); <>2__current = (object)new WaitForSeconds(Random.Range(ChaosSettings.TurretRateMin.Value, ChaosSettings.TurretRateMax.Value)); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public string GetName() { return Loc.Get("event.turrets"); } public bool IsEnabled() { return ChaosSettings.EnableTurrets.Value; } public void Execute() { if (!NetworkManager.Singleton.IsServer) { Plugin.Log.LogInfo((object)"[TurretSpawnEvent] Skipped - not host."); return; } EventManager? instance = EventManager.Instance; if (instance != null) { ((MonoBehaviour)instance).StartCoroutine(SpawnLoop()); } } [IteratorStateMachine(typeof(<SpawnLoop>d__3))] private static IEnumerator SpawnLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpawnLoop>d__3(0); } private static GameObject? FindTurretPrefab() { SpawnableMapObject[] array = StartOfRound.Instance?.currentLevel?.spawnableMapObjects; if (array == null) { return null; } SpawnableMapObject[] array2 = array; foreach (SpawnableMapObject val in array2) { if ((Object)(object)val?.prefabToSpawn != (Object)null && (Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null) { return val.prefabToSpawn; } } return null; } private static void SpawnTurret(GameObject prefab) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB randomOutdoorPlayer = GetRandomOutdoorPlayer(); if ((Object)(object)randomOutdoorPlayer == (Object)null) { Plugin.Log.LogInfo((object)"[TurretSpawnEvent] No outdoor player found, skipping turret."); return; } float num = Random.Range(-8f, 8f); float num2 = Random.Range(-8f, 8f); Vector3 val = ((Component)randomOutdoorPlayer).transform.position + new Vector3(num, 0f, num2); if (randomOutdoorPlayer.isInsideFactory) { NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(val, ref val2, 5f, -1)) { val = ((NavMeshHit)(ref val2)).position; } } else { int mask = LayerMask.GetMask(new string[5] { "Room", "Colliders", "Default", "Terrain", "MapHazards" }); RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val + Vector3.up * 50f, Vector3.down, ref val3, 150f, mask, (QueryTriggerInteraction)1)) { val = ((RaycastHit)(ref val3)).point; } } if (PlayerUtils.IsNearShip(val)) { Plugin.Log.LogInfo((object)"[TurretSpawnEvent] Spawn pos too close to ship, skipping."); return; } Transform transform = RoundManager.Instance.mapPropsContainer.transform; NetworkObject component = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity, transform).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null) { component.Spawn(true); } else { Plugin.Log.LogWarning((object)"[TurretSpawnEvent] Turret prefab has no NetworkObject com