using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Net; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using DG.Tweening; using DG.Tweening.Core; using DG.Tweening.Plugins.Options; using HarmonyLib; using MyBox; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Steamworks; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("LethalCompanyCrowdControlMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LethalCompanyCrowdControlMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d4f6b961-e8ae-4e4b-950c-37644e42d4ca")] [assembly: AssemblyFileVersion("1.10.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.10.0.0")] namespace BepinControl; public enum TimedType { HIGH_FOV, LOW_FOV, LIMIT_FPS, LIMIT_RENDER, THRID_PERSON, MODEL_SIZE } public class Timed { public TimedType type; private float old; public static byte originalFOV = 80; public static int originalFPSLimit = 0; public static float originalRenderLimit = 0f; private static Dictionary customVariables = new Dictionary(); private static int frames = 0; public static T GetCustomVariable(string key) { if (customVariables.TryGetValue(key, out var value)) { return (T)value; } throw new KeyNotFoundException("Custom variable with key '" + key + "' not found."); } public void SetCustomVariables(Dictionary variables) { customVariables = variables; } public Timed(TimedType t) { type = t; } public void addEffect() { switch (type) { case TimedType.HIGH_FOV: case TimedType.LOW_FOV: CrowdControlMod.ActionQueue.Enqueue(delegate { AppSettingsManager instance2 = Singleton.Instance; originalFOV = instance2.appSettings.video.fov; instance2.appSettings.video.fov = (byte)((type == TimedType.HIGH_FOV) ? 120u : 30u); instance2.InvokeSettingsChange(); CrowdDelegates.callFunc(instance2, "ApplySettings", false); }); break; case TimedType.LIMIT_FPS: CrowdControlMod.ActionQueue.Enqueue(delegate { AppSettingsManager instance = Singleton.Instance; originalFPSLimit = instance.appSettings.video.fpsLimit; instance.appSettings.video.fpsLimit = 10; instance.InvokeSettingsChange(); CrowdDelegates.callFunc(instance, "ApplySettings", false); }); break; case TimedType.LIMIT_RENDER: CrowdControlMod.ActionQueue.Enqueue(delegate { AppSettingsManager instance3 = Singleton.Instance; originalRenderLimit = instance3.appSettings.video.renderDist; instance3.appSettings.video.renderDist = 6f; instance3.InvokeSettingsChange(); CrowdDelegates.callFunc(instance3, "ApplySettings", false); }); break; case TimedType.THRID_PERSON: CrowdDelegates.EnableThirdPerson(); break; case TimedType.MODEL_SIZE: break; } } public static bool removeEffect(TimedType etype) { try { switch (etype) { case TimedType.HIGH_FOV: case TimedType.LOW_FOV: CrowdControlMod.ActionQueue.Enqueue(delegate { try { AppSettingsManager instance = Singleton.Instance; instance.appSettings.video.fov = originalFOV; instance.InvokeSettingsChange(); CrowdDelegates.callFunc(instance, "ApplySettings", false); } catch (Exception ex2) { CrowdControlMod.mls.LogInfo((object)ex2.ToString()); removeEffect(etype); } }); break; case TimedType.LIMIT_FPS: CrowdControlMod.ActionQueue.Enqueue(delegate { try { AppSettingsManager instance2 = Singleton.Instance; instance2.appSettings.video.fpsLimit = originalFPSLimit; instance2.InvokeSettingsChange(); CrowdDelegates.callFunc(instance2, "ApplySettings", false); } catch (Exception ex3) { CrowdControlMod.mls.LogInfo((object)ex3.ToString()); removeEffect(etype); } }); break; case TimedType.LIMIT_RENDER: CrowdControlMod.ActionQueue.Enqueue(delegate { try { AppSettingsManager instance3 = Singleton.Instance; instance3.appSettings.video.renderDist = originalRenderLimit; instance3.InvokeSettingsChange(); CrowdDelegates.callFunc(instance3, "ApplySettings", false); } catch (Exception ex4) { CrowdControlMod.mls.LogInfo((object)ex4.ToString()); removeEffect(etype); } }); break; case TimedType.THRID_PERSON: CrowdDelegates.DisableThirdPerson(); break; case TimedType.MODEL_SIZE: break; } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); return false; } return true; } public void tick() { frames++; if (type == TimedType.HIGH_FOV) { CrowdControlMod.ActionQueue.Enqueue(delegate { }); } } } public class TimedThread { public static List threads = new List(); public readonly Timed effect; public int duration; public int remain; public int id; public bool paused; public static bool isRunning(TimedType t) { foreach (TimedThread thread in threads) { if (thread.effect.type == t) { return true; } } return false; } public static void tick() { foreach (TimedThread thread in threads) { if (!thread.paused) { thread.effect.tick(); } } } public static void addTime(int duration) { try { lock (threads) { foreach (TimedThread thread in threads) { Interlocked.Add(ref thread.duration, duration + 5); if (!thread.paused) { int dur = Volatile.Read(ref thread.remain); new TimedResponse(thread.id, dur, CrowdResponse.Status.STATUS_PAUSE).Send(ControlClient.Socket); thread.paused = true; } } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public static void tickTime(int duration) { try { lock (threads) { foreach (TimedThread thread in threads) { int num = Volatile.Read(ref thread.remain); num -= duration; if (num < 0) { num = 0; } Volatile.Write(ref thread.remain, num); } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public static void unPause() { try { lock (threads) { foreach (TimedThread thread in threads) { if (thread.paused) { int dur = Volatile.Read(ref thread.remain); new TimedResponse(thread.id, dur, CrowdResponse.Status.STATUS_RESUME).Send(ControlClient.Socket); thread.paused = false; } } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public TimedThread(int id, TimedType type, int duration, Dictionary customVariables = null) { effect = new Timed(type); this.duration = duration; remain = duration; this.id = id; paused = false; if (customVariables == null) { customVariables = new Dictionary(); } effect.SetCustomVariables(customVariables); try { lock (threads) { threads.Add(this); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public void Run() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; effect.addEffect(); bool flag = false; try { do { flag = false; for (int num = Volatile.Read(ref duration); num > 0; num = Volatile.Read(ref duration)) { Interlocked.Add(ref duration, -num); Thread.Sleep(num); } if (Timed.removeEffect(effect.type)) { lock (threads) { threads.Remove(this); } new TimedResponse(id, 0, CrowdResponse.Status.STATUS_STOP).Send(ControlClient.Socket); } else { flag = true; } } while (flag); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } } [BepInPlugin("WarpWorld.CrowdControl", "Crowd Control", "1.10.2.0")] public class CrowdControlMod : BaseUnityPlugin { [HarmonyPatch(typeof(TextChatViewUI), "OnMessage")] public class OnMessagePatch { private static bool Prefix(string pName, string msg, TextChatViewUI __instance) { try { string text = ChatComms.DecodeAndDecompress(msg); if (text.Contains("_CC")) { if (ChatComms.IsValidJson(text)) { ChatComms.ProcessMessage(text, pName); } return false; } } catch (Exception) { return true; } return true; } } [HarmonyPatch(typeof(Dishwasher))] [HarmonyPatch("MGCancel")] public class Patch_Dishwasher_MGCancel { private static bool Prefix(Dishwasher __instance) { if (!thirdPerson) { return true; } thirdPersonPaused = false; Singleton.Instance.OnMinigameEnd(); PlayerInventory.Instance.SetState((State)0); ((Behaviour)PlayerCamera.Instance).enabled = true; PlayerMovement.Instance.canMove = true; CrowdDelegates.EnableThirdPerson(); return false; } } [HarmonyPatch(typeof(Dishwasher))] [HarmonyPatch("MGStart")] public class Patch_Dishwasher_MGStart { private static void Postfix(Dishwasher __instance) { if (thirdPerson) { Singleton.Instance.SetVisible(false, false); thirdPersonPaused = true; } } } [HarmonyPatch(typeof(PlayerInventory))] [HarmonyPatch("OnSelectedSlotChanged")] public class Patch_OnSelectedSlotChanged { private static void Postfix(byte p, byte n, PlayerInventory __instance) { if (!thirdPerson) { return; } Transform[] componentsInChildren = ((Component)((Component)Singleton.Instance).transform.parent).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (CrowdDelegates.ToolNames.Contains(((Object)val).name)) { ((Component)val).gameObject.SetActive(false); if (((Component)val).gameObject.layer == 0) { ((Component)val).gameObject.SetActive(true); } } } } } [HarmonyPatch(typeof(SwitchLights))] [HarmonyPatch("InteractServerRpc")] public class Patch_SwitchLights_InteractServerRpc { private static void Postfix(SwitchLights __instance) { if ((Object)(object)__instance != (Object)null && lightsOut) { ChatComms.SendMessage("LightsOn", "BST", 0); } } } [HarmonyPatch(typeof(Master))] [HarmonyPatch("OnApplicationQuit")] public class OnApplicationQuitPatch { private static bool Prefix() { try { ControlClient.connected = false; Instance?.client?.Stop(); mls.LogInfo((object)"ControlClient stopped successfully."); } catch (Exception arg) { mls.LogError((object)$"Error during application quit: {arg}"); } return true; } } [HarmonyPatch(typeof(SaveManager), "SaveGameData")] public class SaveGameDataPatch { private static void Postfix(ref SaveData saveData) { if (saveData != null && !string.IsNullOrEmpty(saveData.tavernName)) { saveData.tavernName = saveData.tavernName.Replace(" [CC]", string.Empty); } } } [HarmonyPatch] public static class SteamManagerPatch { [HarmonyPatch(typeof(SteamManager), "OnHostReady")] [HarmonyPostfix] public static void OnHostReady_Postfix() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) CrowdDelegates.SendStatusEffect((EffectType)Enum.Parse(typeof(EffectType), "Light", ignoreCase: true), 1, 1); ControlClient.SetTavernName(); } } [HarmonyPatch(typeof(Interactive), "Interact")] private class Patch_Interactive_Interact { private static void Prefix(Event e, ushort itemDataId, uint itemId, Interactive __instance) { try { NetworkObject component = ((Component)__instance).GetComponent(); if (((object)(Event)(ref e)).ToString() == "LookOver") { if ((Object)(object)component != (Object)null) { if (netIdToViewerName.TryGetValue((int)component.NetworkObjectId, out var value)) { lookingOver = true; spawnName = value; } else { spawnName = ""; lookingOver = false; } } } else { lookingOver = false; } } catch (Exception) { lookingOver = false; } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] private class Patch_Interactive_ObjectTitle { private static void Postfix(ref string __result) { if (lookingOver && !string.IsNullOrEmpty(spawnName)) { __result = spawnName; } } } [HarmonyPatch(typeof(CustomerNameManager), "OnNameIdentifierChanged")] public class OnNameIdentifierChangedPatch { private static bool Prefix(int prevValue, int newValue, CustomerNameManager __instance) { if (newValue == -1) { return false; } object obj = AccessTools.Field(typeof(CustomerNameManager), "customer")?.GetValue(__instance); if (obj == null) { return false; } PropertyInfo property = obj.GetType().GetProperty("NetworkObjectId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { try { object value = property.GetValue(obj); int key; if (value is ulong num) { if (num > int.MaxValue) { return false; } key = (int)num; } else { if (!(value is string s) || !int.TryParse(s, out var result)) { return false; } key = result; } if (netIdToViewerName.TryGetValue(key, out var value2)) { object obj2 = AccessTools.Field(typeof(CustomerNameManager), "interactive")?.GetValue(__instance); if (obj2 != null) { PropertyInfo property2 = obj2.GetType().GetProperty("ObjectTitle", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property2 != null) { property2.SetValue(obj2, value2); return false; } } } } catch (Exception ex) { mls.LogInfo((object)("Error accessing NetworkObjectId: " + ex.Message)); } } return true; } } [HarmonyPatch(typeof(CustomerNameManager), "OnNetworkDespawn")] public class OnNetworkDespawnPatch { private static void Prefix(CustomerNameManager __instance) { object obj = null; FieldInfo fieldInfo = AccessTools.Field(typeof(CustomerNameManager), "customer"); if (fieldInfo != null) { obj = fieldInfo.GetValue(__instance); } if (obj == null) { return; } PropertyInfo property = obj.GetType().GetProperty("NetworkObjectId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(property != null)) { return; } try { object value = property.GetValue(obj); if (!(value is ulong)) { return; } ulong num = (ulong)value; if (num <= int.MaxValue) { int key = (int)num; try { netIdToViewerName.Remove(key); return; } catch (Exception) { return; } } } catch (Exception) { } } } [HarmonyPatch(typeof(MainMenu), "Start")] public static class MainMenu_Start_Patch { private static void Postfix(MainMenu __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) FieldInfo field = typeof(MainMenu).GetField("versionText", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field != null)) { return; } TextMeshProUGUI val = (TextMeshProUGUI)field.GetValue(__instance); if ((Object)(object)val != (Object)null) { ((TMP_Text)val).text = ((TMP_Text)val).text + " | CrowdControl: 1.10.2.0"; RectTransform component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null) { component.sizeDelta = new Vector2(component.sizeDelta.x + 100f, component.sizeDelta.y); } } } } [HarmonyPatch(typeof(StatusUI))] [HarmonyPatch("OnTavernNameEdit")] public class Patch_StatusUI_OnTavernNameEdit { private static bool Prefix(StatusUI __instance, string s) { if (s.EndsWith(" [CC]")) { GameStatus.Instance.SetNameServerRpc(s); } else { GameStatus.Instance.SetNameServerRpc(s + " [CC]"); } return false; } } private const string modGUID = "WarpWorld.CrowdControl"; private const string modName = "Crowd Control"; private const string modVersion = "1.10.2.0"; private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl"); public static ManualLogSource mls; internal static CrowdControlMod Instance = null; private ControlClient client; public static bool isFocused = true; public const string MESSAGE_TAG = "_CC"; public static bool lightsOut = false; public static bool thirdPerson = false; public static bool thirdPersonPaused = false; public static bool modActivated = false; public static string spawnName = ""; public static bool lookingOver = false; public static float sizeValue = 1f; public static Dictionary netIdToViewerName = new Dictionary(); public static Queue ActionQueue = new Queue(); private void Awake() { Instance = this; mls = Logger.CreateLogSource("Crowd Control"); mls.LogInfo((object)"Loaded WarpWorld.CrowdControl. Patching."); harmony.PatchAll(typeof(CrowdControlMod)); harmony.PatchAll(); mls.LogInfo((object)"Initializing Crowd Control"); try { client = new ControlClient(); new Thread(client.NetworkLoop).Start(); new Thread(client.RequestLoop).Start(); } catch (Exception ex) { mls.LogInfo((object)("CC Init Error: " + ex.ToString())); } mls.LogInfo((object)"Crowd Control Initialized"); mls = ((BaseUnityPlugin)this).Logger; } [HarmonyPatch(typeof(EffectsController), "ChangePlayerScaleClientRpc")] [HarmonyPrefix] public static bool ChangePlayerScaleClientRpc_Prefix(ref float newValue) { if (sizeValue != 1f) { newValue = sizeValue; } return true; } [HarmonyPatch(typeof(EffectsController), "ChangePlayerScaleClientRpc")] [HarmonyPostfix] public static void ChangePlayerScaleClientRpc_Postfix(float newValue) { if (sizeValue != 1f) { sizeValue = 1f; } } [HarmonyPatch(typeof(PlayerCamera), "Update")] [HarmonyPrefix] private static void RunEffects() { //IL_0020: 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) ControlClient.UpdateReadyState(); if (!ControlClient.connected) { FixedString64Bytes value = GameStatus.Instance.tavernName.Value; string tavernName = ((object)(FixedString64Bytes)(ref value)).ToString(); if (CrowdDelegates.IsHost() && !ControlClient.resetName && ControlClient.setName && tavernName.EndsWith(" [CC]")) { ControlClient.setName = false; ControlClient.resetName = true; ActionQueue.Enqueue(delegate { GameStatus.Instance.SetNameServerRpc(tavernName.Replace(" [CC]", string.Empty)); modActivated = false; }); } } while (ActionQueue.Count > 0) { ActionQueue.Dequeue()(); } lock (TimedThread.threads) { foreach (TimedThread thread in TimedThread.threads) { if (!thread.paused) { thread.effect.tick(); } } } } } public class ControlClient { public static readonly string CV_HOST = "127.0.0.1"; public static readonly int CV_PORT = 51337; public static readonly object SocketSendLock = new object(); private static ControlClient activeClient; private static volatile bool gameReady; private bool paused; public static bool connected = false; public static bool setName = false; public static bool resetName = false; public static bool disableLogging = true; public bool inGame = true; public bool questMessage; private volatile bool keepAliveRunning; private Thread keepAliveThread; private Dictionary Delegate { get; set; } private IPEndPoint Endpoint { get; set; } private Queue Requests { get; set; } private bool Running { get; set; } public static Socket Socket { get; set; } public static bool GameReady => gameReady; public ControlClient() { activeClient = this; Endpoint = new IPEndPoint(IPAddress.Parse(CV_HOST), CV_PORT); Requests = new Queue(); Running = true; Socket = null; Delegate = new Dictionary { { "spawnmess_Puddle", CrowdDelegates.SpawnMess }, { "spawnmess_Hay", CrowdDelegates.SpawnMess }, { "spawnmess_Footsteps", CrowdDelegates.SpawnMess }, { "spawnmess_DirtDecal", CrowdDelegates.SpawnMess }, { "spawnmess_Fire", CrowdDelegates.SpawnMess }, { "spawnmess_Soot", CrowdDelegates.SpawnMess }, { "spawnmess_Web", CrowdDelegates.SpawnMess }, { "clearmesses", CrowdDelegates.ClearMess }, { "givemoney_100", CrowdDelegates.GiveMoney }, { "givemoney_1000", CrowdDelegates.GiveMoney }, { "givemoney_10000", CrowdDelegates.GiveMoney }, { "takemoney_100", CrowdDelegates.TakeMoney }, { "takemoney_1000", CrowdDelegates.TakeMoney }, { "takemoney_10000", CrowdDelegates.TakeMoney }, { "addtime_1", CrowdDelegates.ChangeTime }, { "addtime_6", CrowdDelegates.ChangeTime }, { "addtime_12", CrowdDelegates.ChangeTime }, { "highFOV", CrowdDelegates.HighFOV }, { "lowFOV", CrowdDelegates.LowFOV }, { "limitFPS", CrowdDelegates.LimitFPS }, { "limitRender", CrowdDelegates.LimitRender }, { "thirdPerson", CrowdDelegates.ThirdPersonMode }, { "player_shake", CrowdDelegates.ShakePlayerScreen }, { "toggle_tavern", CrowdDelegates.ToggleTavern }, { "player_Speed_200", CrowdDelegates.StatusEffect }, { "player_ModelSize_200", CrowdDelegates.StatusEffect }, { "player_ModelSize_50", CrowdDelegates.StatusEffect }, { "player_Poison", CrowdDelegates.StatusEffect }, { "player_HealthRegeneration", CrowdDelegates.StatusEffect }, { "player_ResistPoison", CrowdDelegates.StatusEffect }, { "player_Slow", CrowdDelegates.StatusEffect }, { "player_ResistSlow", CrowdDelegates.StatusEffect }, { "player_Physical", CrowdDelegates.StatusEffect }, { "player_ResistPhysical", CrowdDelegates.StatusEffect }, { "player_Stun", CrowdDelegates.StatusEffect }, { "player_Drunk", CrowdDelegates.StatusEffect }, { "player_Feather", CrowdDelegates.StatusEffect }, { "player_Light", CrowdDelegates.StatusEffect }, { "player_MaxHealthIncrease", CrowdDelegates.StatusEffect }, { "player_HealthRestore", CrowdDelegates.StatusEffect }, { "player_Teleportation", CrowdDelegates.TeleportPlayer }, { "player_Damage", CrowdDelegates.DamagePlayer }, { "player_Wormhole", CrowdDelegates.StatusEffect }, { "player_Kill", CrowdDelegates.KillPlayer }, { "drophelditem", CrowdDelegates.DropHeldItem }, { "dropallitems", CrowdDelegates.DropAllItems }, { "spawnenemy_Boar", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Wolf", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Bear", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Bat", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Hornet", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Turtle", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Crab", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Toad", CrowdDelegates.SpawnEnemy }, { "spawnenemy_RangedHornet", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Rabbit", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Wildfowl", CrowdDelegates.SpawnEnemy }, { "spawnenemy_WildfowlGroup", CrowdDelegates.SpawnEnemy }, { "spawnenemy_OrcMelee", CrowdDelegates.SpawnEnemy }, { "spawnenemy_OrcHostage", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Zombie", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Spider", CrowdDelegates.SpawnEnemy }, { "spawnenemy_RangedSpider", CrowdDelegates.SpawnEnemy }, { "spawnenemy_ZombieHound", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Ghoul", CrowdDelegates.SpawnEnemy }, { "spawnenemy_GhostRanged", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Mummy", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Snake", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Snail", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Slug", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SkeletonArcher", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SkeletonWarrior2H", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SkeletonWarriorShield", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SkeletonNecromancer", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SlimeSmall", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SlimeMedium", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SlimeBig", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SkeletonBoss", CrowdDelegates.SpawnEnemy }, { "spawnenemy_ZombieBoss", CrowdDelegates.SpawnEnemy }, { "spawnenemy_SpiderBoss", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomAmanita", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomAzure", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomEmerald", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomWhite", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomAmanitaGroup", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomAzureGroup", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomEmeraldGroup", CrowdDelegates.SpawnEnemy }, { "spawnenemy_MushroomWhiteGroup", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Corn", CrowdDelegates.SpawnEnemy }, { "spawnenemy_Polypore", CrowdDelegates.SpawnEnemy }, { "spawnenemy_LootCrate", CrowdDelegates.SpawnEnemy }, { "spawnenemy_LootBarrel", CrowdDelegates.SpawnEnemy }, { "spawn_customer", CrowdDelegates.SpawnCustomer }, { "spawn_vip", CrowdDelegates.SpawnCustomer }, { "breakfurniture", CrowdDelegates.BreakFurniture }, { "enable_fog", CrowdDelegates.EnableFog }, { "enable_fog_all", CrowdDelegates.EnableFogAll }, { "turnoutlights", CrowdDelegates.TurnOutLights }, { "fliptables", CrowdDelegates.FlipTables }, { "event-hype-train", CrowdDelegates.SpawnHypeTrain }, { "spawnitem_Money", CrowdDelegates.SpawnItem }, { "spawnitem_WaterBucket", CrowdDelegates.SpawnItem }, { "spawnitem_FreshCrucian", CrowdDelegates.SpawnItem }, { "spawnitem_FreshTrout", CrowdDelegates.SpawnItem }, { "spawnitem_Egg", CrowdDelegates.SpawnItem }, { "spawnitem_AppleCore", CrowdDelegates.SpawnItem }, { "spawnitem_Barley", CrowdDelegates.SpawnItem }, { "spawnitem_BarleyWort", CrowdDelegates.SpawnItem }, { "spawnitem_RawPork", CrowdDelegates.SpawnItem }, { "spawnitem_RawRibs", CrowdDelegates.SpawnItem }, { "spawnitem_ChickenBreast", CrowdDelegates.SpawnItem }, { "spawnitem_Carrot", CrowdDelegates.SpawnItem }, { "spawnitem_Potato", CrowdDelegates.SpawnItem }, { "spawnitem_Corn", CrowdDelegates.SpawnItem }, { "spawnitem_Grape", CrowdDelegates.SpawnItem }, { "spawnitem_ToadLeg", CrowdDelegates.SpawnItem }, { "spawnitem_CrabMeat", CrowdDelegates.SpawnItem }, { "spawnitem_BoarPorkRaw", CrowdDelegates.SpawnItem }, { "spawnitem_WineWort", CrowdDelegates.SpawnItem }, { "spawnitem_EmeraldMushroom", CrowdDelegates.SpawnItem }, { "spawnitem_AmanitaMushroom", CrowdDelegates.SpawnItem }, { "spawnitem_AzureMushroom", CrowdDelegates.SpawnItem }, { "spawnitem_WhiteMushroom", CrowdDelegates.SpawnItem }, { "spawnitem_CornWort", CrowdDelegates.SpawnItem }, { "spawnitem_CornWash", CrowdDelegates.SpawnItem }, { "spawnitem_BarleyWash", CrowdDelegates.SpawnItem }, { "spawnitem_Honey", CrowdDelegates.SpawnItem }, { "spawnitem_Hop", CrowdDelegates.SpawnItem }, { "spawnitem_Apple", CrowdDelegates.SpawnItem }, { "spawnitem_WolfFang", CrowdDelegates.SpawnItem }, { "spawnitem_BearLiver", CrowdDelegates.SpawnItem }, { "spawnitem_TurtleShell", CrowdDelegates.SpawnItem }, { "spawnitem_SpiderVenomGland", CrowdDelegates.SpawnItem }, { "spawnitem_GhoulEye", CrowdDelegates.SpawnItem }, { "spawnitem_HoundClaw", CrowdDelegates.SpawnItem }, { "spawnitem_PufferFish", CrowdDelegates.SpawnItem }, { "spawnitem_PigInCage", CrowdDelegates.SpawnItem }, { "spawnitem_ChickenInCage", CrowdDelegates.SpawnItem }, { "spawnitem_Barrel", CrowdDelegates.SpawnItem }, { "spawnitem_Mug", CrowdDelegates.SpawnItem }, { "spawnitem_MugDirty", CrowdDelegates.SpawnItem }, { "spawnitem_Plate", CrowdDelegates.SpawnItem }, { "spawnitem_PlateDirty", CrowdDelegates.SpawnItem }, { "spawnitem_Bucket", CrowdDelegates.SpawnItem }, { "spawnitem_SmallHealthPotion", CrowdDelegates.SpawnItem }, { "spawnitem_SpeedPotion", CrowdDelegates.SpawnItem }, { "spawnitem_ResistPhysicalPotion", CrowdDelegates.SpawnItem }, { "spawnitem_ResistPoisonPotion", CrowdDelegates.SpawnItem }, { "spawnitem_FeatherPotion", CrowdDelegates.SpawnItem }, { "spawnitem_RegenerationPotion", CrowdDelegates.SpawnItem }, { "spawnitem_SmallHealthIncreasePotion", CrowdDelegates.SpawnItem }, { "spawnitem_BigHealthIncreasePotion", CrowdDelegates.SpawnItem }, { "spawnitem_BigHealthPotion", CrowdDelegates.SpawnItem }, { "spawnitem_TeleportationPotion", CrowdDelegates.SpawnItem }, { "spawnitem_SlopPotion", CrowdDelegates.SpawnItem }, { "spawnitem_SizePotion", CrowdDelegates.SpawnItem }, { "spawnitem_WormholePotion", CrowdDelegates.SpawnItem }, { "spawnitem_LightPotion", CrowdDelegates.SpawnItem }, { "spawnitem_Grindstone", CrowdDelegates.SpawnItem }, { "spawnitem_ReviveStone", CrowdDelegates.SpawnItem }, { "spawnitem_Compost", CrowdDelegates.SpawnItem }, { "spawnitem_Bullet", CrowdDelegates.SpawnItem }, { "spawnitem_CrossbowBolt", CrowdDelegates.SpawnItem }, { "spawnitem_Broom", CrowdDelegates.SpawnItem }, { "spawnitem_Hoe", CrowdDelegates.SpawnItem }, { "spawnitem_WateringCan", CrowdDelegates.SpawnItem }, { "spawnitem_FishingRod", CrowdDelegates.SpawnItem }, { "spawnitem_Hammer", CrowdDelegates.SpawnItem }, { "spawnitem_BroomPro", CrowdDelegates.SpawnItem }, { "spawnitem_HoePro", CrowdDelegates.SpawnItem }, { "spawnitem_Torch", CrowdDelegates.SpawnItem }, { "spawnitem_Axe", CrowdDelegates.SpawnItem }, { "spawnitem_Sword", CrowdDelegates.SpawnItem }, { "spawnitem_Crossbow", CrowdDelegates.SpawnItem }, { "spawnitem_Musket", CrowdDelegates.SpawnItem }, { "spawnitem_OnePunchStick", CrowdDelegates.SpawnItem }, { "spawnitem_CrucianSoup", CrowdDelegates.SpawnItem }, { "spawnitem_ChickenSoup", CrowdDelegates.SpawnItem }, { "spawnitem_BarleyPorridge", CrowdDelegates.SpawnItem }, { "spawnitem_TroutSoup", CrowdDelegates.SpawnItem }, { "spawnitem_MushroomSoup", CrowdDelegates.SpawnItem }, { "spawnitem_ToadSoup", CrowdDelegates.SpawnItem }, { "spawnitem_FriedCrucian", CrowdDelegates.SpawnItem }, { "spawnitem_FriedChicken", CrowdDelegates.SpawnItem }, { "spawnitem_BoiledChickenEggs", CrowdDelegates.SpawnItem }, { "spawnitem_FriedPigRibs", CrowdDelegates.SpawnItem }, { "spawnitem_FriedPigSteak", CrowdDelegates.SpawnItem }, { "spawnitem_FriedPotatoes", CrowdDelegates.SpawnItem }, { "spawnitem_BoiledCorn", CrowdDelegates.SpawnItem }, { "spawnitem_FriedBoarSteak", CrowdDelegates.SpawnItem }, { "spawnitem_CrabSalad", CrowdDelegates.SpawnItem }, { "spawnitem_CornCake", CrowdDelegates.SpawnItem }, { "spawnitem_BarleyBread", CrowdDelegates.SpawnItem }, { "spawnitem_FriedTrout", CrowdDelegates.SpawnItem }, { "spawnitem_FriedToadLegs", CrowdDelegates.SpawnItem }, { "spawnitem_Cupcake", CrowdDelegates.SpawnItem }, { "spawnitem_PotatoesMushroom", CrowdDelegates.SpawnItem }, { "spawnitem_ApplePie", CrowdDelegates.SpawnItem }, { "spawnitem_FriedEggs", CrowdDelegates.SpawnItem }, { "spawnitem_FriedEggsWithMushrooms", CrowdDelegates.SpawnItem }, { "spawnitem_FriedEggsWithBacon", CrowdDelegates.SpawnItem }, { "spawnitem_EggyBread", CrowdDelegates.SpawnItem }, { "spawnitem_FriedChickenWings", CrowdDelegates.SpawnItem }, { "spawnitem_MeatPlate", CrowdDelegates.SpawnItem }, { "spawnitem_SweetPopcorn", CrowdDelegates.SpawnItem }, { "spawnitem_BakedPigWithApples", CrowdDelegates.SpawnItem }, { "spawnitem_AssortedSeafood", CrowdDelegates.SpawnItem }, { "spawnitem_AleMug", CrowdDelegates.SpawnItem }, { "spawnitem_WineMug", CrowdDelegates.SpawnItem }, { "spawnitem_BeerMug", CrowdDelegates.SpawnItem }, { "spawnitem_CiderMug", CrowdDelegates.SpawnItem }, { "spawnitem_BourbonMug", CrowdDelegates.SpawnItem }, { "spawnitem_GrapeJuiceMug", CrowdDelegates.SpawnItem }, { "spawnitem_CarrotJuiceMug", CrowdDelegates.SpawnItem }, { "spawnitem_AppleJuiceMug", CrowdDelegates.SpawnItem }, { "spawnitem_WhiskeyMug", CrowdDelegates.SpawnItem }, { "spawnitem_AleBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_WineBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_BeerBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_CiderBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_BourbonBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_GrapeJuiceBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_CarrotJuiceBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_AppleJuiceBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_WhiskeyBarrel", CrowdDelegates.SpawnItem }, { "spawnitem_RectangularTable", CrowdDelegates.SpawnItem }, { "spawnitem_RoundTable", CrowdDelegates.SpawnItem }, { "spawnitem_BarrelDispencer", CrowdDelegates.SpawnItem }, { "spawnitem_Dishwasher", CrowdDelegates.SpawnItem }, { "spawnitem_Chest", CrowdDelegates.SpawnItem }, { "spawnitem_Oven", CrowdDelegates.SpawnItem }, { "spawnitem_CompostBin", CrowdDelegates.SpawnItem }, { "spawnitem_AutoDishwasher", CrowdDelegates.SpawnItem }, { "spawnitem_StoveSingle", CrowdDelegates.SpawnItem }, { "spawnitem_StoveDouble", CrowdDelegates.SpawnItem }, { "spawnitem_Fermenter", CrowdDelegates.SpawnItem }, { "spawnitem_Brew", CrowdDelegates.SpawnItem }, { "spawnitem_Press", CrowdDelegates.SpawnItem }, { "spawnitem_ShelfMug", CrowdDelegates.SpawnItem }, { "spawnitem_ShelfPlate", CrowdDelegates.SpawnItem }, { "spawnitem_Grill", CrowdDelegates.SpawnItem }, { "spawnitem_GrillPro", CrowdDelegates.SpawnItem }, { "spawnitem_ChestLarge", CrowdDelegates.SpawnItem }, { "spawnitem_Alembic", CrowdDelegates.SpawnItem }, { "spawnitem_BarrelHolderStand", CrowdDelegates.SpawnItem }, { "spawnitem_ServingTable", CrowdDelegates.SpawnItem }, { "spawnitem_Jukebox", CrowdDelegates.SpawnItem }, { "spawnitem_AlchemicalLab", CrowdDelegates.SpawnItem }, { "spawnitem_OrderStickersDesk", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingWorldMap", CrowdDelegates.SpawnItem }, { "spawnitem_HelperWaiterHouse", CrowdDelegates.SpawnItem }, { "spawnitem_HelperCleanerHouse", CrowdDelegates.SpawnItem }, { "spawnitem_BarleySeeds", CrowdDelegates.SpawnItem }, { "spawnitem_CarrotSeeds", CrowdDelegates.SpawnItem }, { "spawnitem_PotatoSeeds", CrowdDelegates.SpawnItem }, { "spawnitem_CornSeeds", CrowdDelegates.SpawnItem }, { "spawnitem_GrapeSeeds", CrowdDelegates.SpawnItem }, { "spawnitem_StatueWarrior", CrowdDelegates.SpawnItem }, { "spawnitem_StatueHamster", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyFishHead", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyWolfHead", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyBearHead", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyBoarHead", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyWaspHead", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyAxeShield", CrowdDelegates.SpawnItem }, { "spawnitem_AlchemistStand", CrowdDelegates.SpawnItem }, { "spawnitem_Globe", CrowdDelegates.SpawnItem }, { "spawnitem_JugsStand", CrowdDelegates.SpawnItem }, { "spawnitem_StatueBoss", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyTrout", CrowdDelegates.SpawnItem }, { "spawnitem_TrophyCrucian", CrowdDelegates.SpawnItem }, { "spawnitem_ChristmasPine", CrowdDelegates.SpawnItem }, { "spawnitem_ChristmasSocks", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingAncestor", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingVampire", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingDarkForest", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingElvinForest", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingGod", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingDrunkard", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingDrunkenness", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingKnights", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingKitten", CrowdDelegates.SpawnItem }, { "spawnitem_PaintingUnequalBattle", CrowdDelegates.SpawnItem } }; } public static void UpdateReadyState() { gameReady = activeClient != null && activeClient.EvaluateReady(); } private bool EvaluateReady() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Invalid comparison between Unknown and I4 //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Invalid comparison between Unknown and I4 //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) try { if (!Object.op_Implicit((Object)(object)GameStatus.Instance)) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: GameStatus.Instance is null"); } return false; } Master instance = Singleton.Instance; try { if (!Object.op_Implicit((Object)(object)instance)) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Master instance is null"); } return false; } if (!((Behaviour)instance).isActiveAndEnabled) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Master is not active and enabled"); } return false; } if (CrowdDelegates.IsHost() && !instance.isHostReady) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Host is not ready"); } return false; } if (instance.HasConnectingClients()) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: There are connecting clients"); } return false; } if ((int)instance.state != 3) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Master state is not Game"); } return false; } } catch { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Exception in master validation"); } return false; } if ((int)Singleton.Instance.state == 100) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: PlayerInventory state is Dead"); } return false; } PlayerNet instance2 = Singleton.Instance; if (!Object.op_Implicit((Object)(object)instance2)) { if (!disableLogging && !disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: PlayerNet instance is null"); } return false; } if (instance2.hp.Value < 1) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: PlayerNet HP is less than 1"); } return false; } QuestManager instance3 = Singleton.Instance; if (!Object.op_Implicit((Object)(object)instance3)) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: QuestManager instance is null"); } return false; } if (!instance3.completedQuests.Contains((ushort)2)) { if (!questMessage) { CrowdDelegates.SendUIMessage("Must complete starting quest before Crowd Control can be used."); if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Starting quest not completed"); } } questMessage = true; return false; } if (questMessage) { CrowdDelegates.SendUIMessage("Crowd Control can now be used!", "NewLevel"); if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Info: Starting quest completed, Crowd Control can now be used"); } questMessage = false; } FixedString64Bytes value = GameStatus.Instance.tavernName.Value; string text = ((object)(FixedString64Bytes)(ref value)).ToString(); if (connected && CrowdDelegates.IsHost() && !setName && !text.EndsWith(" [CC]")) { SetTavernName(); } if (!CrowdControlMod.modActivated && text.EndsWith(" [CC]")) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Info: Mod activated based on tavern name"); } CrowdControlMod.modActivated = true; } if (!CrowdControlMod.modActivated) { if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Fail: Mod is not activated"); } return false; } } catch (Exception arg) { if (!disableLogging) { CrowdControlMod.mls.LogError((object)$"Exception caught: {arg}"); } return false; } if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Success: All checks passed"); } return true; } public static void SetTavernName() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) FixedString64Bytes value = GameStatus.Instance.tavernName.Value; string tavernName = ((object)(FixedString64Bytes)(ref value)).ToString(); if (connected && CrowdDelegates.IsHost() && !setName && !tavernName.EndsWith(" [CC]")) { setName = true; resetName = false; if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Info: Updating tavern name to include [CC]"); } CrowdControlMod.ActionQueue.Enqueue(delegate { GameStatus.Instance.SetNameServerRpc(tavernName + " [CC]"); CrowdControlMod.modActivated = true; }); } } public static void HideEffect(string code) { CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_NOTVISIBLE); crowdResponse.type = 1; crowdResponse.code = code; crowdResponse.Send(Socket); } public static void ShowEffect(string code) { CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_VISIBLE); crowdResponse.type = 1; crowdResponse.code = code; crowdResponse.Send(Socket); } public static void DisableEffect(string code) { CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_NOTSELECTABLE); crowdResponse.type = 1; crowdResponse.code = code; crowdResponse.Send(Socket); } public static void EnableEffect(string code) { CrowdResponse crowdResponse = new CrowdResponse(0, CrowdResponse.Status.STATUS_SELECTABLE); crowdResponse.type = 1; crowdResponse.code = code; crowdResponse.Send(Socket); } private void StartKeepAliveLoop() { keepAliveRunning = true; keepAliveThread = new Thread(KeepAliveLoop) { IsBackground = true, Name = "CrowdControl-KeepAlive" }; keepAliveThread.Start(); } private void StopKeepAliveLoop() { keepAliveRunning = false; } private void KeepAliveLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (keepAliveRunning && Running) { try { Socket socket = Socket; if (socket != null && socket.Connected) { CrowdResponse.KeepAlive(socket); } } catch (Exception) { } Thread.Sleep(1000); } } private void ClientLoop() { CrowdControlMod.mls.LogInfo((object)"Connected to Crowd Control"); Timer timer = new Timer(timeUpdate, null, 0, 200); StartKeepAliveLoop(); try { while (Running) { try { if (Socket == null || !Socket.Connected) { break; } connected = true; CrowdRequest crowdRequest = CrowdRequest.Recieve(this, Socket); if (crowdRequest != null && !crowdRequest.IsKeepAlive()) { lock (Requests) { Requests.Enqueue(crowdRequest); } } continue; } catch (ObjectDisposedException) { break; } catch (SocketException) { break; } catch (ThreadAbortException) { Thread.ResetAbort(); break; } catch (Exception) { } } } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Critical Error: {arg}"); } finally { CrowdControlMod.mls.LogInfo((object)"Disconnected from Crowd Control."); connected = false; gameReady = false; StopKeepAliveLoop(); try { timer.Dispose(); } catch (Exception) { } CloseSocket(); } } private static void CloseSocket() { lock (SocketSendLock) { try { if (Socket != null) { if (Socket.Connected) { Socket.Shutdown(SocketShutdown.Both); Socket.Close(); } Socket.Dispose(); } } catch (Exception) { } finally { Socket = null; } } } public void timeUpdate(object state) { inGame = GameReady; if (!inGame) { TimedThread.addTime(200); paused = true; } else if (paused) { paused = false; TimedThread.unPause(); TimedThread.tickTime(200); } else { TimedThread.tickTime(200); } } public bool IsRunning() { return Running; } public void NetworkLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (Running) { CrowdControlMod.mls.LogInfo((object)"Attempting to connect to Crowd Control"); connected = false; try { Socket = new Socket(Endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, optionValue: true); if (Socket.BeginConnect(Endpoint, null, null).AsyncWaitHandle.WaitOne(10000, exitContext: true) && Socket.Connected) { ClientLoop(); } else { CrowdControlMod.mls.LogInfo((object)"Failed to connect to Crowd Control"); connected = false; } CloseSocket(); } catch (Exception ex) { if (Running) { CrowdControlMod.mls.LogInfo((object)(ex.GetType().Name + ": " + ex.Message)); CrowdControlMod.mls.LogInfo((object)"Failed to connect to Crowd Control"); } else { CrowdControlMod.mls.LogInfo((object)("Crowd Control network loop ended during shutdown: " + ex.GetType().Name)); } connected = false; CloseSocket(); } Thread.Sleep(10000); } } public void RequestLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (Running) { try { CrowdRequest crowdRequest = null; lock (Requests) { if (Requests.Count == 0) { Thread.Sleep(5); continue; } crowdRequest = Requests.Dequeue(); goto IL_0058; } IL_0058: string reqCode = crowdRequest.GetReqCode(); try { CrowdResponse crowdResponse = (GameReady ? Delegate[reqCode](this, crowdRequest) : new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_RETRY)); if (crowdResponse == null) { new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Request error for '" + reqCode + "'").Send(Socket); } else { crowdResponse.Send(Socket); } } catch (KeyNotFoundException) { new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Request error for '" + reqCode + "'").Send(Socket); } } catch (Exception) { CrowdControlMod.mls.LogInfo((object)"Disconnected from Crowd Control."); connected = false; CloseSocket(); } } } public void Stop() { Running = false; StopKeepAliveLoop(); CloseSocket(); } } public delegate CrowdResponse CrowdDelegate(ControlClient client, CrowdRequest req); public static class CustomerChatNames { private static Dictionary chatNames = new Dictionary(); public static void SetChatName(int customerId, string name) { chatNames[customerId] = name; } public static string GetChatName(int customerId) { if (chatNames.TryGetValue(customerId, out var value)) { return value; } return null; } } public class CrowdDelegates { public class Flippable : MonoBehaviour { public bool IsFlipped { get; set; } } public static Random rnd = new Random(); public static readonly TimeSpan SERVER_TIMEOUT = TimeSpan.FromSeconds(5.0); public static Dictionary items = new Dictionary { { "Money", 1u }, { "WaterBucket", 5u }, { "FreshCrucian", 6u }, { "FreshTrout", 7u }, { "Egg", 8u }, { "AppleCore", 9u }, { "Barley", 10u }, { "BarleyWort", 11u }, { "RawPork", 12u }, { "RawRibs", 13u }, { "ChickenBreast", 14u }, { "Carrot", 15u }, { "Potato", 16u }, { "Corn", 17u }, { "Grape", 18u }, { "ToadLeg", 19u }, { "CrabMeat", 20u }, { "BoarPorkRaw", 21u }, { "WineWort", 22u }, { "EmeraldMushroom", 23u }, { "AmanitaMushroom", 24u }, { "AzureMushroom", 25u }, { "WhiteMushroom", 26u }, { "CornWort", 27u }, { "CornWash", 28u }, { "BarleyWash", 29u }, { "Honey", 32u }, { "Hop", 34u }, { "Apple", 35u }, { "WolfFang", 50u }, { "BearLiver", 51u }, { "TurtleShell", 52u }, { "SpiderVenomGland", 53u }, { "GhoulEye", 55u }, { "HoundClaw", 56u }, { "PufferFish", 57u }, { "PigInCage", 95u }, { "ChickenInCage", 96u }, { "Barrel", 101u }, { "Mug", 102u }, { "MugDirty", 103u }, { "Plate", 106u }, { "PlateDirty", 107u }, { "Bucket", 108u }, { "SmallHealthPotion", 200u }, { "SpeedPotion", 201u }, { "ResistPhysicalPotion", 204u }, { "ResistPoisonPotion", 205u }, { "FeatherPotion", 206u }, { "RegenerationPotion", 207u }, { "SmallHealthIncreasePotion", 208u }, { "BigHealthIncreasePotion", 209u }, { "BigHealthPotion", 210u }, { "TeleportationPotion", 211u }, { "SlopPotion", 212u }, { "SizePotion", 213u }, { "WormholePotion", 214u }, { "LightPotion", 215u }, { "Grindstone", 220u }, { "ReviveStone", 221u }, { "Compost", 280u }, { "Bullet", 290u }, { "CrossbowBolt", 291u }, { "Broom", 301u }, { "Hoe", 302u }, { "WateringCan", 303u }, { "FishingRod", 304u }, { "Hammer", 305u }, { "BroomPro", 306u }, { "HoePro", 307u }, { "Torch", 310u }, { "Axe", 350u }, { "Sword", 351u }, { "Crossbow", 355u }, { "Musket", 360u }, { "OnePunchStick", 390u }, { "CrucianSoup", 502u }, { "ChickenSoup", 503u }, { "BarleyPorridge", 504u }, { "TroutSoup", 505u }, { "MushroomSoup", 506u }, { "ToadSoup", 507u }, { "FriedCrucian", 602u }, { "FriedChicken", 603u }, { "BoiledChickenEggs", 604u }, { "FriedPigRibs", 605u }, { "FriedPigSteak", 606u }, { "FriedPotatoes", 607u }, { "BoiledCorn", 608u }, { "FriedBoarSteak", 609u }, { "CrabSalad", 610u }, { "CornCake", 611u }, { "BarleyBread", 612u }, { "FriedTrout", 613u }, { "FriedToadLegs", 614u }, { "Cupcake", 615u }, { "PotatoesMushroom", 616u }, { "ApplePie", 617u }, { "FriedEggs", 618u }, { "FriedEggsWithMushrooms", 619u }, { "FriedEggsWithBacon", 620u }, { "EggyBread", 621u }, { "FriedChickenWings", 622u }, { "MeatPlate", 623u }, { "SweetPopcorn", 624u }, { "BakedPigWithApples", 625u }, { "AssortedSeafood", 626u }, { "AleMug", 701u }, { "WineMug", 702u }, { "BeerMug", 703u }, { "CiderMug", 704u }, { "BourbonMug", 705u }, { "GrapeJuiceMug", 706u }, { "CarrotJuiceMug", 707u }, { "AppleJuiceMug", 708u }, { "WhiskeyMug", 709u }, { "AleBarrel", 751u }, { "WineBarrel", 752u }, { "BeerBarrel", 753u }, { "CiderBarrel", 754u }, { "BourbonBarrel", 755u }, { "GrapeJuiceBarrel", 756u }, { "CarrotJuiceBarrel", 757u }, { "AppleJuiceBarrel", 758u }, { "WhiskeyBarrel", 759u }, { "RectangularTable", 1101u }, { "RoundTable", 1102u }, { "BarrelDispencer", 1103u }, { "Dishwasher", 1104u }, { "Chest", 1105u }, { "Oven", 1106u }, { "CompostBin", 1107u }, { "AutoDishwasher", 1108u }, { "StoveSingle", 1109u }, { "StoveDouble", 1110u }, { "Fermenter", 1111u }, { "Brew", 1112u }, { "Press", 1113u }, { "ShelfMug", 1114u }, { "ShelfPlate", 1115u }, { "Grill", 1116u }, { "GrillPro", 1117u }, { "ChestLarge", 1118u }, { "Alembic", 1119u }, { "BarrelHolderStand", 1120u }, { "ServingTable", 1121u }, { "Jukebox", 1150u }, { "AlchemicalLab", 1151u }, { "OrderStickersDesk", 1153u }, { "PaintingWorldMap", 1154u }, { "HelperWaiterHouse", 1155u }, { "HelperCleanerHouse", 1156u }, { "BarleySeeds", 1201u }, { "CarrotSeeds", 1202u }, { "PotatoSeeds", 1203u }, { "CornSeeds", 1204u }, { "GrapeSeeds", 1205u }, { "StatueWarrior", 1301u }, { "StatueHamster", 1302u }, { "TrophyFishHead", 1303u }, { "TrophyWolfHead", 1304u }, { "TrophyBearHead", 1305u }, { "TrophyBoarHead", 1306u }, { "TrophyWaspHead", 1307u }, { "TrophyAxeShield", 1308u }, { "AlchemistStand", 1309u }, { "Globe", 1310u }, { "JugsStand", 1311u }, { "StatueBoss", 1312u }, { "TrophyTrout", 1313u }, { "TrophyCrucian", 1314u }, { "ChristmasPine", 1315u }, { "ChristmasSocks", 1316u }, { "PaintingAncestor", 1350u }, { "PaintingVampire", 1351u }, { "PaintingDarkForest", 1352u }, { "PaintingElvinForest", 1354u }, { "PaintingGod", 1355u }, { "PaintingDrunkard", 1356u }, { "PaintingDrunkenness", 1357u }, { "PaintingKnights", 1358u }, { "PaintingKitten", 1359u }, { "PaintingUnequalBattle", 1360u } }; public static readonly string[] ToolNames = new string[4] { "Axe", "Repair_Hammer", "Hammer", "Broom" }; public AssetBundle bundle; private static GameObject hypetrainPrefab; private static bool assetsLoaded = false; public static string AddSpacesBeforeUppercase(string input) { return Regex.Replace(input, "(?.Instance; if (!instance.IsHost) { return instance.IsServer; } return true; } public static void SendUIMessage(string message) { CrowdControlMod.ActionQueue.Enqueue(delegate { callFunc(Singleton.Instance, "OnGameEventText", message); }); } public static void SendUIMessage(string message, string soundFX) { CrowdControlMod.ActionQueue.Enqueue(delegate { GameEventLogUI instance = Singleton.Instance; PlaySoundFX(soundFX); callFunc(instance, "OnGameEventText", message); }); } public static void PlaySoundFX(string soundFX) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) SoundManager instance = Singleton.Instance; SoundEvent val = (SoundEvent)Enum.Parse(typeof(SoundEvent), soundFX, ignoreCase: true); instance.Play(val); }); } public void LoadAssetsFromBundle() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (assetsLoaded) { return; } new HypeTrainBoxData(); string text = Path.Combine(Paths.PluginPath, "CrowdControl", "warpworld.hypetrain"); string text2 = Path.Combine(Paths.PluginPath, "warpworld.hypetrain"); if (File.Exists(text)) { bundle = AssetBundle.LoadFromFile(text); } else if (File.Exists(text2)) { bundle = AssetBundle.LoadFromFile(text2); } else { bundle = null; } if ((Object)(object)bundle == (Object)null) { CrowdControlMod.mls.LogInfo((object)"Failed to load AssetBundle."); return; } hypetrainPrefab = bundle.LoadAsset("HypeTrain"); if ((Object)(object)hypetrainPrefab == (Object)null) { CrowdControlMod.mls.LogInfo((object)"HypeTrain Prefab not found in AssetBundle."); } assetsLoaded = true; } public static Vector3 GetGroundPosition(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 result = Vector3.zero; int num = ~LayerMask.GetMask(new string[1] { "Player" }); RaycastHit val = default(RaycastHit); if (Physics.Raycast(position, Vector3.down, ref val, float.PositiveInfinity, num)) { result = ((RaycastHit)(ref val)).point; } return result; } public static string GetGroundTexture(Vector3 position) { //IL_0000: 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_0022: Unknown result type (might be due to invalid IL or missing references) _ = Vector3.zero; int num = ~LayerMask.GetMask(new string[1] { "Player" }); string result = ""; RaycastHit val = default(RaycastHit); if (Physics.Raycast(position, Vector3.down, ref val, float.PositiveInfinity, num)) { result = ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name; } return result; } public static Color ConvertUserNameToColor(string userName) { //IL_003a: 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_004d: Unknown result type (might be due to invalid IL or missing references) using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(userName)); float num = (float)(int)array[0] / 255f; float num2 = (float)(int)array[1] / 255f; float num3 = (float)(int)array[2] / 255f; return new Color(num, num2, num3); } public void ExecuteHypeTrain(ulong steamID, CrowdRequest.SourceDetails sourceDetails) { //IL_0039: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_0146: Expected O, but got Unknown Transform transform = ((Component)PlayerManager.Instance.players[steamID]).gameObject.transform; if ((Object)(object)hypetrainPrefab == (Object)null || sourceDetails.top_contributions.Length == 0) { return; } HypeTrain component = Object.Instantiate(hypetrainPrefab, GetGroundPosition(transform.position), transform.rotation).GetComponent(); if (!((Object)null == (Object)(object)component)) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(-14.5f, 0f, 0f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(24.5f, 0f, 0f); Vector3 val3 = GetGroundPosition(transform.position) + transform.TransformDirection(val); Vector3 val4 = GetGroundPosition(transform.position) + transform.TransformDirection(val2); float num = 0.12f; val3.y += num; val4.y += num; List list = new List(); CrowdRequest.SourceDetails.Contribution[] top_contributions = sourceDetails.top_contributions; foreach (CrowdRequest.SourceDetails.Contribution contribution in top_contributions) { list.Add(new HypeTrainBoxData { name = contribution.user_name, box_color = ConvertUserNameToColor(contribution.user_name), bit_amount = ((contribution.type == "bits") ? contribution.total : 0) }); } float num2 = (float)sourceDetails.level * 0.1f; float value = Mathf.Min(1f + num2, 2f); component.StartHypeTrain(val3, val4, list.ToArray(), transform, new HypeTrainOptions { train_layer = LayerMask.NameToLayer(""), max_bits_per_car = 100, volume = 100f, distance_per_second = value }); } } public static CrowdResponse SpawnMess(ControlClient client, CrowdRequest req) { //IL_0069: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; string text = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); if (text == null) { status = CrowdResponse.Status.STATUS_FAILURE; message = "Unable to spawn that type of mess."; return new CrowdResponse(req.GetReqID(), status, message); } try { PlayerCamera instance = Singleton.Instance; string groundTexture = GetGroundTexture(((Component)instance).transform.position); CrowdControlMod.mls.LogInfo((object)("textureName: " + groundTexture)); if (!groundTexture.Contains("House") && text != "Fire" && text != "Web") { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } Vector3 groundPosition = GetGroundPosition(((Component)instance).transform.position); if (IsHost()) { SpawnMess_Host(hostInitiated: true, groundPosition, text); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("SpawnMess", "CMD", req.id, "position", groundPosition, "mess", text); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } return new CrowdResponse(req.GetReqID(), status, message); } public static void SpawnMess_Host(bool hostInitiated, Vector3 position, string mess) { //IL_000e: 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) try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_007d: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer) { CrowdControlMod.mls.LogWarning((object)"SpawnMess_Host called but not server/host."); } else { MessManager instance = Singleton.Instance; Type result; if ((Object)(object)instance == (Object)null) { CrowdControlMod.mls.LogWarning((object)"MessManager singleton is null."); } else if (string.Equals(mess, "Web", StringComparison.OrdinalIgnoreCase)) { CrowdControlMod.mls.LogInfo((object)"Skipping spawn: 'Web' is disabled."); } else if (Enum.TryParse(mess, ignoreCase: true, out result)) { Mess val = instance.SpawnJunkItem(result, position); if ((Object)(object)val == (Object)null) { CrowdControlMod.mls.LogWarning((object)$"SpawnJunkItem returned null for {result}"); } else { NetworkObject component = ((Component)val).GetComponent(); CrowdControlMod.mls.LogInfo((object)$"Spawned {result} @ {position}. IsSpawned={Object.op_Implicit((Object)(object)component) && component.IsSpawned}"); if (string.Equals(mess, "Fire", StringComparison.OrdinalIgnoreCase)) { Object.Destroy((Object)(object)((Component)val).gameObject, 10f); } } } else { CrowdControlMod.mls.LogWarning((object)("Unknown mess '" + mess + "'. Enum parse failed; nothing spawned.")); } } }); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Failed to spawn mess: " + ex.Message)); } } private static ushort GenJunkIdFromIterator(MessManager mm) { FieldInfo field = typeof(MessManager).GetField("_messIdIterator", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { throw new MissingFieldException("MessManager._messIdIterator not found."); } ushort it = (ushort)field.GetValue(mm); while (mm.activeJunk.Exists((SavedGO j) => j.id == it)) { it++; if (it == ushort.MaxValue) { it = 1; } } field.SetValue(mm, it); return it; } private static byte ResolvePrefabTypeIndexSafe(MessManager mm, Mess targetPrefab) { try { if (!(typeof(MessManager).GetField("_messPrefabs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(mm) is Mess[] array) || array.Length == 0) { CrowdControlMod.mls.LogWarning((object)"Could not read _messPrefabs; defaulting type byte to 0."); return 0; } for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] == (Object)null) && ((Object)array[i]).name == ((Object)targetPrefab).name) { return (byte)i; } } CrowdControlMod.mls.LogWarning((object)"Web prefab not found in _messPrefabs; defaulting type byte to 0."); return 0; } catch (Exception ex) { CrowdControlMod.mls.LogWarning((object)("ResolvePrefabTypeIndexSafe failed: " + ex.Message + ". Defaulting to 0.")); return 0; } } public static CrowdResponse ClearMess(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; Mess[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "No messes found to clean."); } try { if (IsHost()) { CleanMess_Host(hostInitiated: true); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("ClearMess", "CMD", req.id); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } return new CrowdResponse(req.GetReqID(), status, message); } public static void CleanMess_Host(bool hostInitiated) { try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) MessManager instance = Singleton.Instance; List list = new List(); foreach (object value in Enum.GetValues(typeof(Type))) { Mess[] array = Object.FindObjectsOfType(); foreach (Mess val in array) { if (val.type == (Type)value) { list.Add(val); Object.Destroy((Object)(object)((Component)val).gameObject); } } } foreach (Mess item in list) { instance.OnMessCleared(item); } }); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Failed to clear mess: " + ex.Message)); } } public static CrowdResponse SpawnHypeTrain(ControlClient client, CrowdRequest req) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; ulong value = SteamClient.SteamId.Value; ChatComms.SendMessage("HypeTrain", "BST", 0, "steamID", value, "sourceDetails", req.sourceDetails); return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse HighFOV(ControlClient client, CrowdRequest req) { int num = 30; if (req.duration > 0) { num = req.duration / 1000; } if (TimedThread.isRunning(TimedType.HIGH_FOV)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if (TimedThread.isRunning(TimedType.LOW_FOV)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to update FOV."); } new Thread(new TimedThread(req.GetReqID(), TimedType.HIGH_FOV, num * 1000).Run).Start(); return new TimedResponse(req.GetReqID(), num * 1000); } public static CrowdResponse LowFOV(ControlClient client, CrowdRequest req) { int num = 30; if (req.duration > 0) { num = req.duration / 1000; } if (TimedThread.isRunning(TimedType.HIGH_FOV)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if (TimedThread.isRunning(TimedType.LOW_FOV)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to update FOV."); } new Thread(new TimedThread(req.GetReqID(), TimedType.LOW_FOV, num * 1000).Run).Start(); return new TimedResponse(req.GetReqID(), num * 1000); } public static CrowdResponse LimitFPS(ControlClient client, CrowdRequest req) { int num = 30; if (req.duration > 0) { num = req.duration / 1000; } if (TimedThread.isRunning(TimedType.LIMIT_FPS)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to update FPS limit."); } new Thread(new TimedThread(req.GetReqID(), TimedType.LIMIT_FPS, num * 1000).Run).Start(); return new TimedResponse(req.GetReqID(), num * 1000); } public static CrowdResponse LimitRender(ControlClient client, CrowdRequest req) { int num = 30; if (req.duration > 0) { num = req.duration / 1000; } if (TimedThread.isRunning(TimedType.LIMIT_RENDER)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to update limit render distance."); } new Thread(new TimedThread(req.GetReqID(), TimedType.LIMIT_RENDER, num * 1000).Run).Start(); return new TimedResponse(req.GetReqID(), num * 1000); } public static CrowdResponse ThirdPersonMode(ControlClient client, CrowdRequest req) { int num = 5; if (req.duration > 0) { num = req.duration / 1000; } if (TimedThread.isRunning(TimedType.THRID_PERSON)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to set to 3rd person."); } new Thread(new TimedThread(req.GetReqID(), TimedType.THRID_PERSON, num * 1000).Run).Start(); return new TimedResponse(req.GetReqID(), num * 1000); } public static void EnableThirdPerson() { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_001e: 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: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) PlayerCamera instance = Singleton.Instance; Transform parent = ((Component)instance).transform.parent; float num = 1.8f; float num2 = 0.3f; Vector3 position = parent.position - parent.forward * num; position.y += num2; ((Component)instance).transform.position = position; ((Component)instance).transform.LookAt(parent.position + Vector3.up * 1f); Singleton.Instance.SetVisible(true, true); PlayerInventory playerInventoryInstanceByOwner = GetPlayerInventoryInstanceByOwner(); Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (ToolNames.Contains(((Object)val).name)) { ((Component)val).gameObject.SetActive(false); } } FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerInventory), "interactiveHitDist"); if (fieldInfo != null) { fieldInfo.SetValue(playerInventoryInstanceByOwner, 4.2f); } byte selectedSlot = playerInventoryInstanceByOwner.selectedSlot; byte b = (byte)((selectedSlot < 9) ? ((byte)(selectedSlot + 1)) : 0); callFunc(playerInventoryInstanceByOwner, "OnSelectedSlotChanged", new object[2] { selectedSlot, b }); callFunc(playerInventoryInstanceByOwner, "OnSelectedSlotChanged", new object[2] { b, selectedSlot }); CrowdControlMod.thirdPerson = true; }); } public static void DisableThirdPerson() { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0017: 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) PlayerCamera instance = Singleton.Instance; Transform parent = ((Component)instance).transform.parent; ((Component)instance).transform.localPosition = Vector3.zero; ((Component)instance).transform.localRotation = Quaternion.identity; Singleton.Instance.SetVisible(false, false); PlayerInventory playerInventoryInstanceByOwner = GetPlayerInventoryInstanceByOwner(); Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren(true); foreach (Transform val in componentsInChildren) { if (ToolNames.Contains(((Object)val).name)) { ((Component)val).gameObject.SetActive(true); } } FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerInventory), "interactiveHitDist"); if (fieldInfo != null) { fieldInfo.SetValue(playerInventoryInstanceByOwner, 2f); } CrowdControlMod.thirdPerson = false; }); } public static CrowdResponse GiveMoney(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; string text = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(text) || !ulong.TryParse(text, out var amount)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } try { CrowdControlMod.ActionQueue.Enqueue(delegate { Singleton.Instance.AddMoneyServerRpc(amount); }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse TakeMoney(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; GameStatus gameStatus = Singleton.Instance; string text = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(text) || !ulong.TryParse(text, out var amount)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if (gameStatus.moneyInit - amount < 0) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to remove more money than is available."); } try { CrowdControlMod.ActionQueue.Enqueue(delegate { gameStatus.RemoveMoneyServerRpc(amount); }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse ShakePlayerScreen(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; int duration = 30; if (req.duration > 0) { duration = req.duration / 1000; } try { CrowdControlMod.ActionQueue.Enqueue(delegate { Singleton.Instance.DoShake((float)duration, 1f); }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse ToggleTavern(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; GameStatus gameStatus = Singleton.Instance; string message = ""; try { CrowdControlMod.ActionQueue.Enqueue(delegate { gameStatus.TavernOpenCloseServerRpc(!gameStatus.isTavernOpen.Value); }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } if (status == CrowdResponse.Status.STATUS_SUCCESS) { string text = "Tavern has been " + (gameStatus.isTavernOpen.Value ? "closed" : "opened") + "."; ChatComms.SendMessage("SendUIMessage", "BST", 0, "msg", text); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse TurnOutLights(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; if (CrowdControlMod.lightsOut) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Lights are already out."); } try { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("TurnOutLights", "CMD", req.id); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } if (status == CrowdResponse.Status.STATUS_FAILURE) { message = "Unable turn out the lights."; } return new CrowdResponse(req.GetReqID(), status, message); } public static void TurnOnLights() { SwitchLights instance = Singleton.Instance; try { FieldInfo field = typeof(SwitchLights).GetField("state", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(instance); PropertyInfo property = value.GetType().GetProperty("Value"); if (property != null) { object value2 = Enum.Parse(property.PropertyType, "Lighted"); property.SetValue(value, value2); callFunc(instance, "ToggleLights", true); callFunc(instance, "LightUp", null); callFunc(instance, "UnsubscribeEvents", null); CrowdControlMod.lightsOut = false; } } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error updating state in Lights: {arg}"); } } public static void TurnOutLights_All() { CrowdControlMod.ActionQueue.Enqueue(delegate { try { SwitchLights instance = Singleton.Instance; callFunc(instance, "ToggleLights", false); callFunc(instance, "SetDark", null); callFunc(instance, "SubscribeEvents", null); callFunc(instance, "SaveDefaultLightProbes", null); object? value = typeof(SwitchLights).GetField("candleInteractive", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(instance); Interactive val = (Interactive)((value is Interactive) ? value : null); if ((Object)(object)val != (Object)null) { val.SetInteractParams((Event)1, true, "", 0); } CrowdControlMod.lightsOut = true; } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } }); } public static CrowdResponse EnableFog(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; if ((double)RenderSettings.fogDensity > 0.01) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to activate fog at this time."); } int num = 30; if (req.duration > 0) { num = req.duration / 1000; } try { TurnOnFog(num); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse EnableFogAll(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; if ((double)RenderSettings.fogDensity > 0.01) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to activate fog at this time."); } int num = 30; if (req.duration > 0) { num = req.duration / 1000; } try { ChatComms.SendMessage("ServerFog", "BST", 0, "duration", num); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static void TurnOnFog(float duration) { CrowdControlMod.ActionQueue.Enqueue(delegate { try { SwitchLights instance = Singleton.Instance; callFunc(instance, "EnableDarkNearFog", null); callFunc(instance, "DisableDarkFog", duration + 8f); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } }); } public static CrowdResponse SpawnBoss(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; try { CrowdControlMod.ActionQueue.Enqueue(delegate { }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse BreakFurniture(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; Furniture[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "No furniture to break!"); } bool flag = false; Furniture[] array2 = array; foreach (Furniture val in array2) { if (val.canBeBroken && !val.isBroken.Value) { flag = true; break; } } if (!flag) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "All furniture already broken!"); } try { if (IsHost()) { BreakFurniture_Host(hostInitiated: true); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("BreakFurniture", "CMD", req.id); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } if (status == CrowdResponse.Status.STATUS_FAILURE) { message = "Unable to break any furniture"; } if (status == CrowdResponse.Status.STATUS_SUCCESS) { string text = "All furniture has been broken!"; ChatComms.SendMessage("SendUIMessage", "BST", 0, "msg", text, "soundFX", "GunBreak"); } return new CrowdResponse(req.GetReqID(), status, message); } public static void BreakFurniture_Host(bool hostInitiated) { try { Furniture[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return; } Furniture[] array2 = array; foreach (Furniture val in array2) { if (!((Object)(object)val == (Object)null) && val.canBeBroken && !val.isBroken.Value) { try { val.Break(); } catch (Exception) { } } } } catch (Exception ex2) { CrowdControlMod.mls.LogInfo((object)("Unable to break furniture: " + ex2.Message)); } } public static CrowdResponse SpawnItem(ControlClient client, CrowdRequest req) { //IL_00fe: 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_012c: 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_009a: 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) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; string text = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); if (text == null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to find that item."); } uint value; bool num = items.TryGetValue(text, out value); uint num2 = value; if (!num) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to find that item."); } try { Transform transform = ((Component)Singleton.Instance).transform; if (IsHost()) { SpawnItem_Host(hostInitiated: true, transform.position, transform.forward, transform.rotation, num2); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("SpawnItem", "CMD", req.id, "position", transform.position, "forward", transform.forward, "rotation", transform.rotation, "itemID", num2); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } if (status == CrowdResponse.Status.STATUS_SUCCESS) { SendUIMessage(req.viewer + " sent a " + AddSpacesBeforeUppercase(text)); } return new CrowdResponse(req.GetReqID(), status, message); } public static void SpawnItem_Host(bool hostInitiated, Vector3 position, Vector3 forward, Quaternion rotation, uint itemID) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_001d: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) ItemData val = default(ItemData); if (ItemManager.Instance.GetItemData(itemID, ref val)) { Item val2 = default(Item); ((Item)(ref val2))..ctor(val); Vector3 val3 = position + forward * 3f + Vector3.up; CollectibleManager.Instance.Spawn(val2, val3, rotation, 0u, false); } }); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Failed to spawn customer: " + ex.Message)); } } public static CrowdResponse ChangeTime(ControlClient client, CrowdRequest req) { string message = "Unable to Change Time!"; CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message2 = ""; string text = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(text) || !float.TryParse(text, out var result)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, message); } if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, message); } try { if (IsHost()) { ChangeTime_Host(hostInitiated: true, result); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("ChangeTime", "CMD", req.id, "hours", result); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } return new CrowdResponse(req.GetReqID(), status, message2); } public static void ChangeTime_Host(bool hostInitiated, float hour) { try { CrowdControlMod.ActionQueue.Enqueue(delegate { Singleton.Instance.AddTime(hour); }); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Failed to spawn customer: " + ex.Message)); } } public static CrowdResponse SpawnCustomer(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; if (!Singleton.Instance.isTavernOpen.Value) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to spawn customer while tavern is closed."); } bool flag = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty) == "vip"; if ((Object)(object)Singleton.Instance == (Object)null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to spawn customer."); } string viewer = req.viewer; try { if (IsHost()) { SpawnCustomer_Host(hostInitiated: true, flag, viewer); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("SpawnCustomer", "CMD", req.id, "vip", flag, "viewerName", viewer); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_FAILURE; } return new CrowdResponse(req.GetReqID(), status, message); } public static void SpawnCustomer_Host(bool hostInitiated, bool vip, string viewerName) { try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) CustomersManager instance; try { instance = Singleton.Instance; if ((Object)(object)instance == (Object)null) { throw new InvalidOperationException("CustomersManager instance is null."); } } catch (Exception arg) { Debug.LogError((object)$"Error accessing CustomersManager: {arg}"); return; } Customer val; ObjectNameManager val2; ObjectNameManager val3; Transform val4; try { val = (Customer)AccessTools.Field(typeof(CustomersManager), "customerPrefab").GetValue(instance); val2 = (ObjectNameManager)AccessTools.Field(typeof(CustomersManager), "femaleNamesManager").GetValue(instance); val3 = (ObjectNameManager)AccessTools.Field(typeof(CustomersManager), "maleNamesManager").GetValue(instance); val4 = (Transform)AccessTools.Field(typeof(CustomersManager), "tavernEnter").GetValue(instance); } catch (Exception arg2) { Debug.LogError((object)$"Error accessing private fields: {arg2}"); return; } ushort num; try { num = (ushort)AccessTools.Method(typeof(CustomersManager), "GenId", (Type[])null, (Type[])null).Invoke(instance, null); } catch (Exception arg3) { Debug.LogError((object)$"Error invoking GenId method: {arg3}"); return; } Vector3 position; try { position = instance.debugSpawnPoint.position; } catch (Exception arg4) { Debug.LogError((object)$"Error determining spawn position: {arg4}"); return; } Customer val5; try { val5 = Object.Instantiate(val, position, Quaternion.identity); } catch (Exception arg5) { Debug.LogError((object)$"Error instantiating customer: {arg5}"); return; } CustomerNavigation component; CustomerNameManager component2; CustomerSkins component3; NetworkObject component4; try { component = ((Component)val5).GetComponent(); component2 = ((Component)val5).GetComponent(); component3 = ((Component)val5).GetComponent(); component4 = ((Component)val5).GetComponent(); } catch (Exception arg6) { Debug.LogError((object)$"Error accessing customer components: {arg6}"); return; } try { int num2 = Random.Range(0, 2); if (!((Object)(object)Master.Instance == (Object)null) && !((Object)(object)AppSettingsManager.Instance == (Object)null) && AppSettingsManager.Instance.appSettings != null) { if (Master.Instance.HasConnectingClients() && AppSettingsManager.Instance.appSettings.system.useSpawnQueue) { if ((Object)(object)Game.Instance == (Object)null) { return; } Game.Instance.SpawnEnqueue(component4); } else { component4.Spawn(false); } val5.humanTypeIndex.Value = num2; val5.InitializeVip(); val5.isVip.Value = vip; if (!((Object)(object)component3 == (Object)null)) { component3.InitializeSkin(num2); int value = ((num2 == 1) ? val2.GetNameIdentifierId() : val3.GetNameIdentifierId()); string text = ((NetworkBehaviour)val5).NetworkObjectId.ToString(); int key = (int)((NetworkBehaviour)val5).NetworkObjectId; if (CrowdControlMod.netIdToViewerName.ContainsKey(key)) { CrowdControlMod.netIdToViewerName[key] = viewerName; } else { CrowdControlMod.netIdToViewerName.Add(key, viewerName); } ChatComms.SendMessage("NetworkSpawn", "BST", 0, "netId", text, "viewerName", viewerName); component2.nameIdentifierId.Value = value; if (!((Object)(object)component == (Object)null) && !((Object)(object)val4 == (Object)null)) { component.Initialize(val4); component.WalkToTavern(); val5.id.Value = num; MethodInfo methodInfo = AccessTools.Property(typeof(CustomersManager), "CustomersList")?.GetGetMethod(); if (!(methodInfo == null) && methodInfo.Invoke(instance, null) is Dictionary dictionary) { dictionary.Add(num, val5); } } } } } catch (Exception arg7) { Debug.LogError((object)$"Error during customer initialization or spawning: {arg7}"); } }); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Failed to spawn customer: " + ex.Message)); } } public static CrowdResponse SpawnEnemy(ControlClient client, CrowdRequest req) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0088: 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_0125: 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) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; string text = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); if (text == null) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to find that enemy."); } string viewer = req.viewer; try { Transform transform = ((Component)Singleton.Instance).transform; Vector3 val = transform.position + transform.forward * 3f; if ((int)(Type)Enum.Parse(typeof(Type), text, ignoreCase: true) == 0) { status = CrowdResponse.Status.STATUS_FAILURE; message = "Unable to Spawn that type of Enemy."; return new CrowdResponse(req.GetReqID(), status, message); } CrowdControlMod.spawnName = viewer; if (IsHost()) { SpawnEnemy_Host(hostInitiated: true, val, viewer, text); } else { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("SpawnEnemy", "CMD", req.id, "position", val, "name", text, "viewerName", viewer); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); status = CrowdResponse.Status.STATUS_RETRY; } if (status == CrowdResponse.Status.STATUS_SUCCESS) { SendUIMessage(req.viewer + " spawned a " + AddSpacesBeforeUppercase(text)); } return new CrowdResponse(req.GetReqID(), status, message); } public static void SpawnEnemy_Host(bool hostInitiated, Vector3 spawnPosition, string viewerName, string spawnName) { //IL_000e: 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) try { CrowdControlMod.ActionQueue.Enqueue(delegate { //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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) SpawnManager instance = Singleton.Instance; Type key = (Type)Enum.Parse(typeof(Type), spawnName, ignoreCase: true); ushort num; try { num = (ushort)AccessTools.Method(typeof(SpawnManager), "GenId", (Type[])null, (Type[])null).Invoke(instance, null); } catch (Exception arg) { Debug.LogError((object)$"Error invoking GenId method: {arg}"); return; } Dictionary dictionary = (Dictionary)AccessTools.Field(typeof(SpawnManager), "_spawnablePrefabs").GetValue(instance); if (dictionary.TryGetValue(key, out var _)) { Spawnable val = Object.Instantiate(dictionary[key], spawnPosition, Quaternion.identity); val.id.Value = num; ((Object)((Component)val).gameObject).name = viewerName; instance.spawnables.Add(num, val); callFunc(instance, "RecalcTypeCount", null); NetworkObject networkObject = ((NetworkBehaviour)val).NetworkObject; if (Master.Instance.HasConnectingClients() && AppSettingsManager.Instance.appSettings.system.useSpawnQueue) { Game.Instance.SpawnEnqueue(networkObject); } else { networkObject.Spawn(false); string text = networkObject.NetworkObjectId.ToString(); int key2 = (int)networkObject.NetworkObjectId; if (CrowdControlMod.netIdToViewerName.ContainsKey(key2)) { CrowdControlMod.netIdToViewerName[key2] = viewerName; } else { CrowdControlMod.netIdToViewerName.Add(key2, viewerName); } ChatComms.SendMessage("NetworkSpawn", "BST", 0, "netId", text, "viewerName", viewerName); } } }); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("Failed to spawn customer: " + ex.Message)); } } public static CrowdResponse DrunkCustomers(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) try { TextChat.Instance.SendMessageServerRpc("hellO", default(ServerRpcParams)); } catch (Exception ex2) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex2.ToString())); } }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse StatusEffect(ControlClient client, CrowdRequest req) { //IL_00d5: 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) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; int duration = 30; if (req.duration > 0) { duration = req.duration / 1000; } string effectStatus = ((req.code.Split(new char[1] { '_' }).Length > 1) ? req.code.Split(new char[1] { '_' })[1] : string.Empty); int result; int effectValue = ((req.code.Split(new char[1] { '_' }).Length > 2 && int.TryParse(req.code.Split(new char[1] { '_' })[2], out result)) ? result : 100); _ = Singleton.Instance; EffectType effectType = (EffectType)Enum.Parse(typeof(EffectType), effectStatus, ignoreCase: true); PlayerNet playerNet = GetPlayerNetInstanceByOwner(); if (effectStatus == "ModelSize") { if (playerNet.modelScale.Value != 1f) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } CrowdControlMod.sizeValue = ((effectValue == 50) ? 0.5f : 2f); if (TimedThread.isRunning(TimedType.MODEL_SIZE)) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } } if (effectStatus == "Speed" && playerNet.speedEffectModifier.Value != 1f) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if (effectStatus == "Feather") { if (playerNet.jumpForceEffectModifier.Value != 1f) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if (playerNet.gravityEffectModifier.Value != 1f) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } } if (effectStatus == "MaxHealthIncrease" && playerNet.maxHealth.Value != playerNet.initHp) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if (effectStatus == "Poison" || effectStatus == "HealthRegeneration") { effectValue = Convert.ToInt32(playerNet.hp.Value) / duration; } try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_002c: 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_001c: 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) if (effectStatus == "Wormhole") { Vector3 randomWalkableNavMeshPoint = SpawnManager.Instance.GetRandomWalkableNavMeshPoint(); playerNet.Teleport(randomWalkableNavMeshPoint, false); } else { SendStatusEffect(effectType, duration, effectValue); } }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static void SendStatusEffect(EffectType effectType, int duration, int effectValue) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) EffectsController instance = Singleton.Instance; ulong localClientId = NetworkManager.Singleton.LocalClientId; ServerRpcParams val = new ServerRpcParams { Receive = new ServerRpcReceiveParams { SenderClientId = (IsHost() ? 0 : localClientId) } }; instance.AddEffectServerRpc(effectType, (float)duration, effectValue, val); } public static CrowdResponse DropHeldItem(ControlClient client, CrowdRequest req) { TaskCompletionSource tcs = new TaskCompletionSource(); try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0059: 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_0094: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) try { PlayerInventory playerInventoryInstanceByOwner = GetPlayerInventoryInstanceByOwner(); if ((Object)(object)playerInventoryInstanceByOwner == (Object)null) { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to drop item.")); } else { Item itemByPlace = playerInventoryInstanceByOwner.inventory.GetItemByPlace((ushort)playerInventoryInstanceByOwner.selectedSlot); if (itemByPlace.id == 0 || itemByPlace.dataId <= 0 || itemByPlace.amount <= 0) { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "No valid item in selected slot.")); } else if (itemByPlace.id != 0 && itemByPlace.dataId > 0 && itemByPlace.amount > 0) { ItemManager instance = Singleton.Instance; ItemData val = default(ItemData); if ((Object)(object)instance == (Object)null) { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Item manager is not initialized.")); } else if (instance.GetItemData((uint)itemByPlace.dataId, ref val)) { if (!val.playerCantDrop) { try { Singleton.Instance.OnItemDrop(itemByPlace.id, playerInventoryInstanceByOwner.GetDropPos(), ((Component)playerInventoryInstanceByOwner).transform.rotation); } catch (Exception) { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Item cannot be dropped.")); } tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_SUCCESS, "Item dropped successfully.")); } else { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY, "Item cannot be dropped.")); } } else { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY, "Item data not found.")); } } else { tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "No valid item in selected slot.")); } } } catch (Exception arg2) { CrowdControlMod.mls.LogInfo((object)$"Crowd Control Error: {arg2}"); tcs.SetResult(new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to drop item.")); } }); return tcs.Task.GetAwaiter().GetResult(); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Crowd Control Error: {arg}"); return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Unable to drop item."); } } public static CrowdResponse DropAllItems(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; try { Task.Run(delegate { try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) try { PlayerInventory playerInventory = null; ItemManager instance = ItemManager.Instance; try { playerInventory = GetPlayerInventoryInstanceByOwner(); } catch (Exception arg2) { CrowdControlMod.mls.LogInfo((object)$"Error getting PlayerInventory instance: {arg2}"); return; } ItemData val = default(ItemData); foreach (Item item in playerInventory.inventory.items) { try { if (item.id != 0 && item.dataId > 0) { try { if (instance.GetItemData((uint)item.dataId, ref val)) { try { if (!val.playerCantDrop) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_001d: 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) try { ContainerManager instance2 = Singleton.Instance; try { instance2.OnItemDrop(item.id, playerInventory.GetDropPos(), ((Component)GetPlayerMovementInstanceByOwner()).transform.rotation); } catch (Exception arg7) { CrowdControlMod.mls.LogInfo((object)$"Error dropping item ID={item.id}: {arg7}"); } } catch (Exception arg8) { CrowdControlMod.mls.LogInfo((object)$"Error in inner action queue for item ID={item.id}: {arg8}"); } }); } } catch (Exception arg3) { CrowdControlMod.mls.LogInfo((object)$"Error checking if item can be dropped ID={item.id}: {arg3}"); } } } catch (Exception arg4) { CrowdControlMod.mls.LogInfo((object)$"Error fetching item data for item ID={item.id}: {arg4}"); } } } catch (Exception arg5) { CrowdControlMod.mls.LogInfo((object)$"Error processing item ID={item.id}: {arg5}"); } } } catch (Exception arg6) { CrowdControlMod.mls.LogInfo((object)$"Error in outer action queue: {arg6}"); } }); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Error running Task: {arg}"); } }).Wait(); } catch (Exception) { status = CrowdResponse.Status.STATUS_RETRY; } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse TeleportPlayer(ControlClient client, CrowdRequest req) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; Vector3 teleportPosition = new Vector3(25.19f, 1.45f, 52.02f); try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) try { PlayerNet.Instance.Teleport(teleportPosition, false); } catch (Exception ex2) { CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex2.ToString())); } }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse DamagePlayer(ControlClient client, CrowdRequest req) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; PlayerNet playerNet = GetPlayerNetInstanceByOwner(); EffectType attackType = (EffectType)Enum.Parse(typeof(EffectType), "Physical", ignoreCase: true); Transform player = ((Component)Singleton.Instance).transform; if (playerNet.hp.Value - 10 <= 0) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } short damage = 10; try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_003d: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (IsHost()) { playerNet.HitClientRpc(damage, player.position, 999f, false, attackType); } else { playerNet.HitServerRpc(damage, attackType); } }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse KillPlayer(ControlClient client, CrowdRequest req) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; PlayerNet playerNet = GetPlayerNetInstanceByOwner(); EffectType attackType = (EffectType)Enum.Parse(typeof(EffectType), "Physical", ignoreCase: true); Transform player = ((Component)Singleton.Instance).transform; if (playerNet.hp.Value < 1 || !((NetworkBehaviour)playerNet).IsSpawned) { return new CrowdResponse(req.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) if (IsHost()) { playerNet.HitClientRpc((short)10000, player.position, 999f, false, attackType); } else { playerNet.HitServerRpc((short)10000, attackType); } }); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static CrowdResponse FlipTables(ControlClient client, CrowdRequest req) { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; try { TaskCompletionSource tcs = new TaskCompletionSource(); ChatComms.AddResponder(req.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); ChatComms.SendMessage("FlipTables", "BST", req.id); status = (tcs.Task.Wait(SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); ChatComms.RemoveResponder(req.id); } catch (Exception ex) { status = CrowdResponse.Status.STATUS_RETRY; CrowdControlMod.mls.LogInfo((object)("Crowd Control Error: " + ex.ToString())); } return new CrowdResponse(req.GetReqID(), status, message); } public static bool IsTableFlipped(Transform tableTransform) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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) Vector3 up = Vector3.up; return Vector3.Dot(tableTransform.up, up) < 0f; } public static PlayerMovement GetPlayerMovementInstanceByOwner() { PlayerMovement[] array = Object.FindObjectsOfType(); foreach (PlayerMovement val in array) { if (((Component)val).GetComponent().IsOwner) { return val; } } return null; } public static PlayerInventory GetPlayerInventoryInstanceByOwner() { PlayerInventory[] array = Object.FindObjectsOfType(); foreach (PlayerInventory val in array) { if (((Component)val).GetComponent().IsOwner) { return val; } } return null; } public static PlayerNet GetPlayerNetInstanceByOwner() { PlayerNet[] array = Object.FindObjectsOfType(); foreach (PlayerNet val in array) { if (((Component)val).GetComponent().IsOwner) { return val; } } return null; } public static ContainerManager GetContainerManagerInstanceByOwner() { ContainerManager[] array = Object.FindObjectsOfType(); foreach (ContainerManager val in array) { if (((Component)val).GetComponent().IsOwner) { return val; } } return null; } public static async Task FlipTables_All() { TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: 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_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Expected O, but got Unknown try { bool result = false; Furniture[] array = Object.FindObjectsOfType(); _ = Singleton.Instance; Furniture[] array2 = array; Vector3 val2 = default(Vector3); Vector3 val5 = default(Vector3); foreach (Furniture itemPlace in array2) { if (!((Object)(object)itemPlace == (Object)null) && (((Object)itemPlace).name.Contains("BigTable") || ((Object)itemPlace).name.Contains("RoundTable"))) { CustomerTable component = ((Component)itemPlace).GetComponent(); if (!((Object)(object)component == (Object)null) && component.GetBusyFeedPlaces().Count <= 0) { Flippable flippable = ((Component)itemPlace).GetComponent(); if ((Object)(object)flippable == (Object)null) { flippable = ((Component)itemPlace).gameObject.AddComponent(); } Vector3 position = ((Component)itemPlace).transform.position; Quaternion rotation = ((Component)itemPlace).transform.rotation; if (!flippable.IsFlipped && !IsTableFlipped(((Component)itemPlace).transform)) { result = true; FeedPlacesManager.Instance.HandleRemoveTable(component); DOTween.Kill((object)((Component)itemPlace).transform, true); Rigidbody rb = ((Component)itemPlace).GetComponent(); Sequence val = DOTween.Sequence(); bool flag = Object.op_Implicit((Object)(object)PlayerManager.Instance.playerSpawnPos[1]); ((Vector3)(ref val2))..ctor(position.x, position.y + (flag ? 2f : 1f), position.z); Quaternion val3 = rotation * Quaternion.Euler(180f, (float)(flag ? 70 : 40), 0f); if ((Object)(object)rb != (Object)null) { rb.useGravity = false; rb.isKinematic = false; rb.mass = 1.5f; rb.drag = 0.6f; rb.collisionDetectionMode = (CollisionDetectionMode)1; } if (flag) { Vector3 val4 = Vector3.up * 10f + ((Component)itemPlace).transform.forward * 5f; rb.AddForce(val4, (ForceMode)1); ((Vector3)(ref val5))..ctor(5f, 0f, 15f); rb.AddTorque(val5, (ForceMode)1); TweenSettingsExtensions.Append(val, (Tween)(object)TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOMove(((Component)itemPlace).transform, val2, 0.5f, false), (Ease)5)); TweenSettingsExtensions.Join(val, (Tween)(object)TweenSettingsExtensions.SetEase>(ShortcutExtensions.DORotateQuaternion(((Component)itemPlace).transform, val3, 0.5f), (Ease)5)); Vector3 val6 = val2 + ((Component)itemPlace).transform.forward * 0.5f; TweenSettingsExtensions.Append(val, (Tween)(object)TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOMove(((Component)itemPlace).transform, val6, 0.2f, false), (Ease)30)); } else { rb.constraints = (RigidbodyConstraints)80; TweenSettingsExtensions.Append(val, (Tween)(object)TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOMove(((Component)itemPlace).transform, val2, 0.8f, false), (Ease)6)); TweenSettingsExtensions.Join(val, (Tween)(object)TweenSettingsExtensions.SetEase>(ShortcutExtensions.DORotateQuaternion(((Component)itemPlace).transform, val3, 0.8f), (Ease)6)); TweenSettingsExtensions.Append(val, (Tween)(object)TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOMove(((Component)itemPlace).transform, val2 + Vector3.forward * 0.2f, 0.3f, false), (Ease)30)); } TweenSettingsExtensions.OnComplete(val, (TweenCallback)delegate { flippable.IsFlipped = true; rb.useGravity = true; rb.constraints = (RigidbodyConstraints)0; DOTween.Kill((object)((Component)itemPlace).transform, true); }); } } } } taskCompletionSource.SetResult(result); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Crowd Control Error: {arg}"); taskCompletionSource.SetResult(result: false); } }); return await taskCompletionSource.Task; } public static void setProperty(object a, string prop, object val) { PropertyInfo property = a.GetType().GetProperty(prop, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(a, val); } } public static object getProperty(object a, string prop) { return a.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(a); } public static void setSubProperty(object a, string prop, string prop2, object val) { FieldInfo field = a.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic); field.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(field, val); } public static void callSubFunc(object a, string prop, string func, object val) { callSubFunc(a, prop, func, new object[1] { val }); } public static void callSubFunc(object a, string prop, string func, object[] vals) { FieldInfo field = a.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic); field.GetType().GetMethod(func, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).Invoke(field, vals); } public static void callFunc(object a, string func, object val) { callFunc(a, func, new object[1] { val }); } public static void callFunc(object a, string func, object[] vals) { a.GetType().GetMethod(func, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(a, vals); } public static object callAndReturnFunc(object a, string func, object val) { return callAndReturnFunc(a, func, new object[1] { val }); } public static object callAndReturnFunc(object a, string func, object[] vals) { return a.GetType().GetMethod(func, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(a, vals); } } public class CrowdRequest { public enum Type { REQUEST_TEST = 0, REQUEST_START = 1, REQUEST_STOP = 2, REQUEST_KEEPALIVE = 255 } public class Target { public string service; public string id; public string name; public string avatar; } public class SourceDetails { public class Contribution { public string user_id; public string user_login; public string user_name; public string type; public int total; } public int total; public int progress; public int goal; public Contribution[] top_contributions; public Contribution last_contribution; public int level; } public static readonly int RECV_BUF = 4096; public static readonly int RECV_TIME = 5000000; public string code; public int id; public int duration; public string type; public string viewer; public Target[] targets; public SourceDetails sourceDetails; public static CrowdRequest Recieve(ControlClient client, Socket socket) { byte[] array = new byte[RECV_BUF]; string text = ""; int num = 0; do { if (!client.IsRunning()) { return null; } if (socket.Poll(RECV_TIME, SelectMode.SelectRead)) { num = socket.Receive(array); if (num <= 0) { return null; } text += Encoding.ASCII.GetString(array, 0, num); } else { CrowdResponse.KeepAlive(socket); } } while (num == 0 || (num == RECV_BUF && array[RECV_BUF - 1] != 0)); return JsonConvert.DeserializeObject(text); } public string GetReqCode() { return code; } public int GetReqID() { return id; } public int GetReqDuration() { return duration; } public Type GetReqType() { string text = type; if (text == "1") { return Type.REQUEST_START; } if (text == "2") { return Type.REQUEST_STOP; } return Type.REQUEST_TEST; } public string GetReqViewer() { return viewer; } public bool IsKeepAlive() { if (id == 0) { return type == "255"; } return false; } } public class CrowdResponse { public enum Status { STATUS_SUCCESS = 0, STATUS_FAILURE = 1, STATUS_UNAVAIL = 2, STATUS_RETRY = 3, STATUS_START = 5, STATUS_PAUSE = 6, STATUS_RESUME = 7, STATUS_STOP = 8, STATUS_VISIBLE = 128, STATUS_NOTVISIBLE = 129, STATUS_SELECTABLE = 130, STATUS_NOTSELECTABLE = 131, STATUS_KEEPALIVE = 255 } public int id; public string message; public string code; public int status; public int type; public CrowdResponse(int id, Status status = Status.STATUS_SUCCESS, string message = "") { type = 0; code = ""; this.id = id; this.message = message; this.status = (int)status; } public static void KeepAlive(Socket socket) { new CrowdResponse(0, Status.STATUS_KEEPALIVE).Send(socket); } public void Send(Socket socket) { if (socket == null || !socket.Connected) { return; } byte[] bytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject((object)this)); byte[] array = new byte[bytes.Length + 1]; Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length); array[bytes.Length] = 0; lock (ControlClient.SocketSendLock) { if (socket.Connected) { socket.Send(array); } } } } public class ChatComms { public class JsonMessage { [JsonProperty(/*Could not decode attribute arguments.*/)] public string cmd { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public string type { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public int id { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public uint itemID { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public int duration { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public string tag { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public string soundFX { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public string status { get; set; } [JsonProperty(/*Could not decode attribute arguments.*/)] public string msg { get; set; } [JsonExtensionData] public Dictionary AdditionalProperties { get; set; } = new Dictionary(); public T GetProperty(string propertyName) { if (AdditionalProperties.TryGetValue(propertyName, out var value)) { if (value is T) { return (T)value; } JObject val = (JObject)((value is JObject) ? value : null); if (val != null) { return ((JToken)val).ToObject(); } } return default(T); } } private static HashSet pendingRequestIDs = new HashSet(); private static readonly ConcurrentDictionary> rspResponders = new ConcurrentDictionary>(); public static readonly JsonSerializerSettings jsonSettings = new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1, ReferenceLoopHandling = (ReferenceLoopHandling)1 }; public static void AddResponder(int msgID, Action responder) { rspResponders[msgID] = responder; } public static void RemoveResponder(int msgID) { rspResponders.TryRemove(msgID, out var _); } public static string CompressAndEncode(string json) { byte[] bytes = Encoding.UTF8.GetBytes(json); using MemoryStream memoryStream = new MemoryStream(); using (GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress)) { gZipStream.Write(bytes, 0, bytes.Length); } return Convert.ToBase64String(memoryStream.ToArray()); } public static string DecodeAndDecompress(string base64CompressedJson) { using MemoryStream stream = new MemoryStream(Convert.FromBase64String(base64CompressedJson)); using GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); gZipStream.CopyTo(memoryStream); byte[] bytes = memoryStream.ToArray(); return Encoding.UTF8.GetString(bytes); } public static bool IsValidJson(string json) { try { JsonConvert.DeserializeObject(json, jsonSettings); return true; } catch { return false; } } public static void SendMessage(string cmd, string type, int id, params object[] args) { //IL_0010: 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) FixedString64Bytes value = GameStatus.Instance.tavernName.Value; if (!((object)(FixedString64Bytes)(ref value)).ToString().EndsWith(" [CC]")) { return; } Dictionary dictionary = new Dictionary { { "cmd", cmd }, { "type", type }, { "id", id }, { "tag", "_CC" } }; pendingRequestIDs.Add(id.ToString()); if (args != null && args.Length != 0) { if (args.Length % 2 != 0) { throw new ArgumentException("Arguments must be in key-value pairs."); } for (int i = 0; i < args.Length; i += 2) { string key = args[i].ToString(); object value2 = args[i + 1]; dictionary[key] = value2; } } string message = JsonConvert.SerializeObject((object)dictionary, jsonSettings); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) TextChat.Instance.SendMessageServerRpc(CompressAndEncode(message), default(ServerRpcParams)); }); } public static void ProcessMessage(string message, string playerName) { try { if (string.IsNullOrEmpty(message)) { CrowdControlMod.mls.LogError((object)("Received null or empty message from " + playerName)); return; } JsonMessage jsonMessage = JsonConvert.DeserializeObject(message, jsonSettings); if (jsonMessage == null || jsonMessage.cmd == null) { CrowdControlMod.mls.LogWarning((object)("Received malformed message from " + playerName + ": " + message)); return; } switch (jsonMessage.type) { case "CMD": ProcessCommand(jsonMessage, playerName); break; case "RSP": ProcessResponse(jsonMessage, playerName); break; case "BST": ProcessBroadcast(jsonMessage, playerName); break; default: CrowdControlMod.mls.LogWarning((object)("Unknown message type from " + playerName + ": " + jsonMessage.cmd)); break; } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error processing message: " + ex.Message + " " + message)); } } private static void ProcessCommand(JsonMessage jsonMessage, string playerName) { //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023f: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) string responseStatus = "STATUS_SUCCESS"; string responseMessage = ""; switch (jsonMessage.cmd) { case "SpawnCustomer": try { if (!CrowdDelegates.IsHost()) { return; } bool property10 = jsonMessage.GetProperty("vip"); string property11 = jsonMessage.GetProperty("viewerName"); CrowdDelegates.SpawnCustomer_Host(hostInitiated: false, property10, property11); } catch (Exception) { responseStatus = "STATUS_FAILURE"; } break; case "ChangeTime": try { if (!CrowdDelegates.IsHost()) { return; } float property9 = jsonMessage.GetProperty("hours"); CrowdDelegates.ChangeTime_Host(hostInitiated: false, property9); } catch (Exception) { responseStatus = "STATUS_FAILURE"; } break; case "SpawnEnemy": try { if (!CrowdDelegates.IsHost()) { return; } Vector3 property6 = jsonMessage.GetProperty("position"); string property7 = jsonMessage.GetProperty("name"); string property8 = jsonMessage.GetProperty("viewerName"); CrowdDelegates.SpawnEnemy_Host(hostInitiated: false, property6, property8, property7); } catch (Exception) { responseStatus = "STATUS_FAILURE"; } break; case "SpawnItem": try { if (!CrowdDelegates.IsHost()) { return; } Vector3 property3 = jsonMessage.GetProperty("position"); Vector3 property4 = jsonMessage.GetProperty("forward"); Quaternion property5 = jsonMessage.GetProperty("rotation"); CrowdDelegates.SpawnItem_Host(hostInitiated: false, property3, property4, property5, jsonMessage.itemID); } catch (Exception) { responseStatus = "STATUS_FAILURE"; } break; case "SpawnMess": try { if (!CrowdDelegates.IsHost()) { return; } Vector3 property = jsonMessage.GetProperty("position"); string property2 = jsonMessage.GetProperty("mess"); CrowdDelegates.SpawnMess_Host(hostInitiated: false, property, property2); } catch (Exception) { responseStatus = "STATUS_FAILURE"; } break; case "ClearMess": try { if (!CrowdDelegates.IsHost()) { return; } CrowdDelegates.CleanMess_Host(hostInitiated: false); } catch (Exception) { responseStatus = "STATUS_FAILURE"; responseMessage = "Failed to clean any messes."; } break; case "BreakFurniture": try { if (!CrowdDelegates.IsHost()) { return; } CrowdDelegates.BreakFurniture_Host(hostInitiated: false); } catch (Exception) { responseStatus = "STATUS_FAILURE"; responseMessage = "Unable to break any furniture."; } break; case "TurnOutLights": try { CrowdControlMod.ActionQueue.Enqueue(delegate { CrowdDelegates.TurnOutLights_All(); if (CrowdDelegates.IsHost() && !CrowdControlMod.lightsOut) { responseMessage = "Unable to turn out the lights."; responseStatus = "STATUS_FAILURE"; } }); } catch (Exception) { responseStatus = "STATUS_FAILURE"; } break; default: CrowdControlMod.mls.LogWarning((object)("Unknown command: " + jsonMessage.cmd)); break; } if (CrowdDelegates.IsHost()) { JsonMessage jsonMessage2 = new JsonMessage { type = "RSP", cmd = jsonMessage.cmd, id = jsonMessage.id, status = responseStatus, tag = jsonMessage.tag }; string jsonResponse = JsonConvert.SerializeObject((object)jsonMessage2, (Formatting)1); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) TextChat.Instance.SendMessageServerRpc(CompressAndEncode(jsonResponse), default(ServerRpcParams)); }); } } private static async void ProcessBroadcast(JsonMessage jsonMessage, string playerName) { string responseStatus = "STATUS_SUCCESS"; switch (jsonMessage.cmd) { case "SendUIMessage": if (jsonMessage.soundFX != null) { CrowdDelegates.SendUIMessage(jsonMessage.msg, jsonMessage.soundFX); } else { CrowdDelegates.SendUIMessage(jsonMessage.msg); } return; case "LightsOn": CrowdDelegates.TurnOnLights(); return; case "ServerFog": if (jsonMessage.duration > 0) { CrowdDelegates.TurnOnFog(jsonMessage.duration); } return; case "HypeTrain": { CrowdDelegates crowdDelegates = new CrowdDelegates(); crowdDelegates.LoadAssetsFromBundle(); ulong property = jsonMessage.GetProperty("steamID"); CrowdRequest.SourceDetails property2 = jsonMessage.GetProperty("sourceDetails"); crowdDelegates.ExecuteHypeTrain(property, property2); return; } case "FlipTables": if (CrowdDelegates.IsHost()) { if (!(await CrowdDelegates.FlipTables_All())) { responseStatus = "STATUS_FAILURE"; } } else { await CrowdDelegates.FlipTables_All(); } break; case "NetworkSpawn": if (CrowdDelegates.IsHost()) { break; } CrowdControlMod.ActionQueue.Enqueue(delegate { string property3 = jsonMessage.GetProperty("netId"); string property4 = jsonMessage.GetProperty("viewerName"); if (int.TryParse(property3, out var result)) { if (CrowdControlMod.netIdToViewerName.ContainsKey(result)) { CrowdControlMod.netIdToViewerName[result] = property4; } else { CrowdControlMod.netIdToViewerName.Add(result, property4); } } }); break; default: CrowdControlMod.mls.LogWarning((object)$"Unknown broadcast command: {jsonMessage}"); break; } if (CrowdDelegates.IsHost() && jsonMessage.id != 0) { JsonMessage jsonMessage2 = new JsonMessage { type = "RSP", cmd = jsonMessage.cmd, id = jsonMessage.id, status = responseStatus, tag = jsonMessage.tag }; string jsonResponse = JsonConvert.SerializeObject((object)jsonMessage2, (Formatting)1); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) TextChat.Instance.SendMessageServerRpc(CompressAndEncode(jsonResponse), default(ServerRpcParams)); }); } } private static void ProcessResponse(JsonMessage jsonMessage, string playerName) { switch (jsonMessage.cmd) { case "ClearMess": case "SpawnMess": case "SpawnItem": case "FlipTables": case "SpawnEnemy": case "SpawnCustomer": case "TurnOutLights": case "BreakFurniture": { if (!pendingRequestIDs.Remove(jsonMessage.id.ToString())) { break; } if (!int.TryParse(jsonMessage.id.ToString(), out var result)) { CrowdControlMod.mls.LogWarning((object)$"Invalid message ID: {jsonMessage}"); break; } if (!Enum.TryParse(jsonMessage.status, out var result2)) { CrowdControlMod.mls.LogWarning((object)$"Invalid status: {jsonMessage}"); break; } if (!rspResponders.TryGetValue(result, out var value)) { CrowdControlMod.mls.LogWarning((object)$"No responder for message ID: {jsonMessage}"); break; } try { value(result2); break; } catch (Exception ex) { CrowdControlMod.mls.LogWarning((object)$"Error processing response for message ID. {jsonMessage}"); CrowdControlMod.mls.LogError((object)ex); break; } } default: CrowdControlMod.mls.LogWarning((object)$"Unknown response command: {jsonMessage}"); break; case "SendUIMessage": break; case "NetworkSpawn": break; } } } public class TimedResponse : CrowdResponse { public int timeRemaining; public TimedResponse(int id, int dur, Status status = Status.STATUS_SUCCESS, string message = "") : base(id, status, message) { timeRemaining = dur; } }