using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using BepinControl; using ConnectorLib.JSON; using CrowdControl; using CrowdControl.Delegates.Effects; using CrowdControl.Delegates.Metadata; using CrowdControl.Harmony; using HarmonyLib; using Il2CppFishNet; using Il2CppFishNet.Connection; using Il2CppFishNet.Object; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.Audio; using Il2CppScheduleOne.Core.Items.Framework; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Effects; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.NPCs.Behaviour; using Il2CppScheduleOne.Networking; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.PlayerScripts.Health; using Il2CppScheduleOne.Police; using Il2CppScheduleOne.Trash; using Il2CppScheduleOne.UI; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using UnityEngine; using UnityEngine.AI; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(CrowdControlMod), "Crowd Control", "1.2.1.0", "Warp World", null)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class ParamCollectionAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepinControl { public class StatusEffectSystem : MonoBehaviour { private static TextMeshProUGUI customMessageLabel; public static void CustomUIMessage(string message) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_008b: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) HUD instance = Singleton.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.cashSlotUI == (Object)null)) { Transform transform = ((Component)instance.cashSlotUI).transform; Transform parent = transform.parent; if ((Object)(object)customMessageLabel != (Object)null) { ((TMP_Text)customMessageLabel).text = message; return; } GameObject val = new GameObject("CustomMessageLabel"); val.transform.SetParent(parent); val.transform.localScale = Vector3.one; RectTransform component = ((Component)transform).GetComponent(); RectTransform obj = val.AddComponent(); obj.anchorMin = component.anchorMin; obj.anchorMax = component.anchorMax; obj.pivot = component.pivot; obj.sizeDelta = new Vector2(240f, 30f); obj.anchoredPosition = component.anchoredPosition + new Vector2(-300f, 50f); customMessageLabel = val.AddComponent(); ((TMP_Text)customMessageLabel).text = message; ((TMP_Text)customMessageLabel).fontSize = 14f; ((Graphic)customMessageLabel).color = Color.white; ((TMP_Text)customMessageLabel).enableWordWrapping = false; ((TMP_Text)customMessageLabel).alignment = (TextAlignmentOptions)513; } } } } namespace CrowdControl { public class CrowdControlMod : MelonMod { public const string MOD_GUID = "WarpWorld.CrowdControl"; public const string MOD_NAME = "Crowd Control"; public const string MOD_AUTHOR = "Warp World"; public const string MOD_VERSION = "1.2.1.0"; private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl"); private const float GAME_STATUS_UPDATE_INTERVAL = 1f; private float m_gameStatusUpdateTimer; public static Instance Logger => ((MelonBase)Instance).LoggerInstance; internal static CrowdControlMod Instance { get; private set; } public GameStateManager GameStateManager { get; private set; } public EffectLoader EffectLoader { get; private set; } public bool ClientConnected => Client.Connected; public NetworkClient Client { get; private set; } public Scheduler Scheduler { get; private set; } public override void OnInitializeMelon() { Instance = this; Logger.Msg("Loaded WarpWorld.CrowdControl. Patching."); foreach (MethodBase patchedMethod in harmony.GetPatchedMethods()) { Logger.Msg("Found patch: " + patchedMethod.Name); } harmony.PatchAll(); Logger.Msg("Initializing Crowd Control"); try { GameStateManager = new GameStateManager(this); Client = new NetworkClient(this); EffectLoader = new EffectLoader(this, Client); Scheduler = new Scheduler(this, Client); } catch (Exception value) { Logger.Error($"Crowd Control Init Error: {value}"); } Logger.Msg("Crowd Control Initialized"); } public override void OnFixedUpdate() { m_gameStatusUpdateTimer += Time.fixedDeltaTime; if (m_gameStatusUpdateTimer >= 1f) { GameStateManager.UpdateGameState(); m_gameStatusUpdateTimer = 0f; } Scheduler?.Tick(); } } public class DelimitedStreamReader : IDisposable { [CompilerGenerated] private NetworkStream P; private readonly MemoryStream _memory_stream; public DelimitedStreamReader(NetworkStream stream) { P = stream; _memory_stream = new MemoryStream(); base..ctor(); } ~DelimitedStreamReader() { Dispose(disposing: false); } public void Dispose() { Dispose(disposing: true); } protected virtual void Dispose(bool disposing) { if (!disposing) { return; } try { _memory_stream.Dispose(); } catch { } } public string ReadUntilNullTerminator() { int num; while ((num = P.ReadByte()) != -1 && num != 0) { _memory_stream.WriteByte(checked((byte)num)); } if (num == -1) { throw new EndOfStreamException("Reached end of stream without finding a null terminator."); } string @string = Encoding.UTF8.GetString(_memory_stream.ToArray()); _memory_stream.SetLength(0L); return @string; } } public class GameStateManager { [CompilerGenerated] private CrowdControlMod P; public static bool effectUpdate; private GameState? _last_game_state; public GameStateManager(CrowdControlMod mod) { P = mod; base..ctor(); } public static async Task DialogMsgAsync(string title, string message, float duration, bool playSound) { Singleton.Instance.SendNotification(title, message, (Sprite)null, duration, playSound); } public static void UpdateEffects() { if (!((NetworkBehaviour)PlayerPatch.PlayerReference.Instance).IsHost) { CrowdControlMod.Instance.Client.HideEffects("spawnVehicle_shitbox", "spawnVehicle_veeper", "spawnVehicle_bruiser", "spawnVehicle_dinkler", "spawnVehicle_hounddog", "spawnVehicle_cheetah", "setTime_0600", "setTime_1200", "setTime_2000", "spawnPolice"); } else { CrowdControlMod.Instance.Client.ShowEffects("spawnVehicle_shitbox", "spawnVehicle_veeper", "spawnVehicle_bruiser", "spawnVehicle_dinkler", "spawnVehicle_hounddog", "spawnVehicle_cheetah", "setTime_0600", "setTime_1200", "setTime_2000", "spawnPolice"); } effectUpdate = true; } public bool IsReady(string code = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)GetGameState() == 1; } public GameState GetGameState() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) try { if (!Singleton.Instance.IsGameLoaded) { return (GameState)(-6); } if (Singleton.Instance.IsLoading) { return (GameState)(-6); } if ((Object)(object)PlayerPatch.PlayerReference.Instance == (Object)null) { return (GameState)(-9); } if (Singleton.Instance.IsPaused && !Singleton.Instance.IsInLobby) { return (GameState)(-5); } if (!effectUpdate) { UpdateEffects(); } return (GameState)1; } catch (Exception value) { CrowdControlMod.Logger.Error($"ERROR {value}"); return (GameState)(-1); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool UpdateGameState(bool force = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return UpdateGameState(GetGameState(), force); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool UpdateGameState(GameState newState, bool force) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return UpdateGameState(newState, null, force); } public bool UpdateGameState(GameState newState, string? message = null, bool force = false) { //IL_0021: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (force || _last_game_state != (GameState?)newState) { _last_game_state = newState; return P.Client.Send((SimpleJSONResponse?)new GameUpdate(newState, message)); } return true; } } public class NetworkClient : IDisposable { public static readonly string CV_HOST = "127.0.0.1"; public static readonly int CV_PORT = 51337; private TcpClient? m_client; private DelimitedStreamReader? m_streamReader; private readonly CrowdControlMod m_mod; private readonly CancellationTokenSource m_quitting = new CancellationTokenSource(); private readonly Thread m_readLoop; private readonly Thread m_maintenanceLoop; private static readonly EmptyResponse KEEPALIVE = new EmptyResponse { type = (ResponseType)255 }; public bool Connected => m_client?.Connected ?? false; ~NetworkClient() { Dispose(disposing: false); } public void Dispose() { Dispose(disposing: true); } protected virtual void Dispose(bool disposing) { try { m_client?.Dispose(); } catch { } try { m_quitting.Cancel(); } catch { } GC.SuppressFinalize(this); } public NetworkClient(CrowdControlMod mod) { m_mod = mod; (m_readLoop = new Thread(NetworkLoop)).Start(); (m_maintenanceLoop = new Thread(MaintenanceLoop)).Start(); } private void NetworkLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (!m_quitting.IsCancellationRequested) { CrowdControlMod.Logger.Msg("Attempting to connect to Crowd Control"); try { m_client = new TcpClient(); m_client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, optionValue: true); m_client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, optionValue: true); if (m_client.BeginConnect(CV_HOST, CV_PORT, null, null).AsyncWaitHandle.WaitOne(2000, exitContext: true) && m_client.Connected) { ClientLoop(); } else { CrowdControlMod.Logger.Msg("Failed to connect to Crowd Control"); } } catch (Exception ex) { CrowdControlMod.Logger.Error((object)ex); CrowdControlMod.Logger.Error("Failed to connect to Crowd Control"); } finally { try { m_client?.Close(); } catch { } } Thread.Sleep(2000); } } private void MaintenanceLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (!m_quitting.IsCancellationRequested) { try { TcpClient? client = m_client; if (client != null && client.Connected) { KeepAlive(); } } catch (Exception ex) { CrowdControlMod.Logger.Error((object)ex); } Thread.Sleep(2000); } } private void ClientLoop() { m_streamReader = new DelimitedStreamReader(m_client.GetStream()); CrowdControlMod.Logger.Msg("Connected to Crowd Control"); try { while (!m_quitting.IsCancellationRequested) { string text = m_streamReader.ReadUntilNullTerminator(); OnMessage(text.Trim()); } } catch (EndOfStreamException) { CrowdControlMod.Logger.Msg("Disconnected from Crowd Control"); m_client?.Close(); } catch (Exception ex2) { CrowdControlMod.Logger.Error((object)ex2); m_client?.Close(); } } private void OnMessage(string message) { if (string.IsNullOrWhiteSpace(message)) { return; } try { SimpleJSONRequest request = default(SimpleJSONRequest); if (SimpleJSONRequest.TryParse(message, ref request)) { m_mod.Scheduler.ProcessRequest(request); } } catch (Exception ex) { CrowdControlMod.Logger.Error((object)ex); } } public bool Send(SimpleJSONResponse? response) { try { if (response == null) { return false; } if (!Connected) { return false; } byte[] bytes = Encoding.UTF8.GetBytes(((SimpleJSONMessage)response).Serialize()); int num = 0; byte[] array = new byte[1 + bytes.Length]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(bytes); readOnlySpan.CopyTo(new Span(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; array[num] = 0; byte[] array2 = array; m_client.GetStream().Write(array2, 0, array2.Length); return true; } catch (Exception value) { CrowdControlMod.Logger.Error($"Error sending a message to the Crowd Control client: {value}"); return false; } } public Task SendAsync(SimpleJSONResponse? response) { SimpleJSONResponse response2 = response; return Task.Run(() => Send(response2)); } public void Stop(string? message = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (message != null) { Send((SimpleJSONResponse?)new MessageResponse { type = (ResponseType)254, message = message }); } m_client?.Close(); } public Task StopAsync(string? message = null) { string message2 = message; return Task.Run(delegate { Stop(message2); }); } public bool KeepAlive() { return Send((SimpleJSONResponse?)(object)KEEPALIVE); } public Task KeepAliveAsync() { return Task.Run((Func)KeepAlive); } public void AttachMetadata(EffectResponse response) { response.metadata = new Dictionary(); string[] commonMetadata = MetadataDelegates.CommonMetadata; foreach (string text in commonMetadata) { if (MetadataLoader.Metadata.TryGetValue(text, out MetadataDelegate value)) { response.metadata.Add(text, value(m_mod)); } else { CrowdControlMod.Logger.Error("Metadata delegate \"" + text + "\" could not be found. Available delegates: " + string.Join(", ", MetadataLoader.Metadata.Keys)); } } } public bool ShowEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public bool ShowEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public Task ShowEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public Task ShowEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public bool ShowAllEffects() { return ShowEffects(m_mod.EffectLoader.Effects.Keys); } public Task ShowAllEffectsAsync() { return ShowEffectsAsync(m_mod.EffectLoader.Effects.Keys); } public bool HideEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public bool HideEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public Task HideEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public Task HideEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public bool HideAllEffects() { return HideEffects(m_mod.EffectLoader.Effects.Keys); } public Task HideAllEffectsAsync() { return HideEffectsAsync(m_mod.EffectLoader.Effects.Keys); } public bool EnableEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public bool EnableEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public Task EnableEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public Task EnableEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public bool EnableAllEffects() { return ShowEffects(m_mod.EffectLoader.Effects.Keys); } public Task EnableAllEffectsAsync() { return ShowEffectsAsync(m_mod.EffectLoader.Effects.Keys); } public bool DisableEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public bool DisableEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public Task DisableEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public Task DisableEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public bool DisableAllEffects() { return ShowEffects(m_mod.EffectLoader.Effects.Keys); } public Task DisableAllEffectsAsync() { return ShowEffectsAsync(m_mod.EffectLoader.Effects.Keys); } } internal static class NpcBehaviourCompat { private static readonly BindingFlags MethodFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly string[] FootPatrolStartMethods = new string[8] { "Begin", "StartPatrol", "BeginPatrol", "Activate", "EnableBehaviour", "Enable", "Resume", "Initialize" }; public static bool TryStartFootPatrol(FootPatrolBehaviour patrol) { MethodInfo methodInfo = ResolveZeroArgMethod(((object)patrol).GetType(), FootPatrolStartMethods); if (methodInfo == null) { CrowdControlMod.Logger.Warning("Unable to find a patrol start method on '" + ((object)patrol).GetType().FullName + "'. Patrol component was enabled only."); return false; } try { methodInfo.Invoke(patrol, null); CrowdControlMod.Logger.Msg("Started foot patrol using '" + methodInfo.Name + "'."); return true; } catch (Exception value) { CrowdControlMod.Logger.Error($"Failed to invoke '{methodInfo.Name}' on '{((object)patrol).GetType().FullName}': {value}"); return false; } } private static MethodInfo? ResolveZeroArgMethod(Type type, IEnumerable candidateNames) { foreach (string candidateName in candidateNames) { MethodInfo method2 = type.GetMethod(candidateName, MethodFlags, null, Type.EmptyTypes, null); if (method2 != null) { return method2; } } return (from method in type.GetMethods(MethodFlags) where method.GetParameters().Length == 0 select method).FirstOrDefault((MethodInfo method) => method.Name.Contains("Patrol", StringComparison.OrdinalIgnoreCase) || method.Name.Contains("Begin", StringComparison.OrdinalIgnoreCase) || method.Name.Contains("Start", StringComparison.OrdinalIgnoreCase) || method.Name.Contains("Resume", StringComparison.OrdinalIgnoreCase) || method.Name.Contains("Activate", StringComparison.OrdinalIgnoreCase)); } } internal static class ReflectionEx { private const BindingFlags BINDING_FLAGS = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static void SetField(this object obj, string prop, object val) { obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, val); } public static T GetField(this object obj, string prop) { return (T)obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(obj); } public static void SetProperty(this object obj, string prop, object val) { obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, val); } public static T GetProperty(this object obj, string prop) { return (T)obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(obj); } public static void CallMethod(this object obj, string methodName, params object[] vals) { obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, vals); } public static T CallMethod(this object obj, string methodName, params object[] vals) { return (T)obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, vals); } } public class Scheduler { private class RequestState { private IEnumerator? m_enumerator; public EffectRequest Request { get; } public Effect Effect { get; } public TimedEffectState? TimedEffectState { get; } public bool MoveNext() { if (m_enumerator != null) { if (m_enumerator.MoveNext()) { return true; } (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; } switch (TimedEffectState?.State) { case CrowdControl.Delegates.Effects.TimedEffectState.EffectState.NotStarted: if (m_enumerator == null) { m_enumerator = TimedEffectState.Start(); } break; case CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Running: if (m_enumerator == null) { m_enumerator = TimedEffectState.Tick(); } break; case CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Finished: return false; } return m_enumerator != null; } public void Pause() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue && effectState.GetValueOrDefault() == CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Running) { m_enumerator = TimedEffectState.Pause(); } } public void Resume() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue && effectState.GetValueOrDefault() == CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Paused) { m_enumerator = TimedEffectState.Resume(); } } public void Stop() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue) { TimedEffectState.EffectState valueOrDefault = effectState.GetValueOrDefault(); if ((uint)(valueOrDefault - 1) <= 1u) { m_enumerator = TimedEffectState.Stop(); } } } public RequestState(EffectRequest request, Effect effect) { Request = request; Effect = effect; if (Effect.IsTimed) { TimedEffectState = new TimedEffectState(effect, request, SITimeSpan.FromMilliseconds(request.duration.GetValueOrDefault())); } } } private CrowdControlMod m_mod; private NetworkClient m_networkClient; private readonly ConcurrentQueue m_requestQueue; private readonly ConcurrentDictionary m_runningEffects; public Scheduler(CrowdControlMod mod, NetworkClient networkClient) { m_mod = mod; m_networkClient = networkClient; m_requestQueue = new ConcurrentQueue(); m_runningEffects = new ConcurrentDictionary(); base..ctor(); } public bool IsRunning(string id) { foreach (TimedEffectState item in m_requestQueue.Select((RequestState p) => p.TimedEffectState).OfType()) { if (item.Effect.EffectAttribute.IDs.Contains(id)) { return true; } } return false; } public void ProcessRequest(SimpleJSONRequest? request) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected I4, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown RequestType? val = request?.type; if (!val.HasValue) { return; } RequestType valueOrDefault = val.GetValueOrDefault(); switch ((int)valueOrDefault) { default: if ((int)valueOrDefault == 253) { m_mod.GameStateManager.UpdateGameState(force: true); } break; case 0: { EffectRequest val5 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val5 != null) { EffectRequest val4 = val5; if (val4.code == null) { val4.code = string.Empty; } if (!m_mod.EffectLoader.Effects.ContainsKey(val5.code)) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val5).id, (EffectStatus)2, (StandardErrors)3)); CrowdControlMod.Logger.Error((object)(StandardErrors)3); } else { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val5).id, (EffectStatus)((!m_mod.GameStateManager.IsReady(val5.code)) ? 1 : 0), (string)null)); } } break; } case 1: { EffectRequest val3 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val3 != null) { EffectRequest val4 = val3; if (val4.code == null) { val4.code = string.Empty; } if (!m_mod.EffectLoader.Effects.TryGetValue(val3.code, out Effect value2)) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val3).id, (EffectStatus)2, (StandardErrors)3)); CrowdControlMod.Logger.Error((object)(StandardErrors)3); } else { m_requestQueue.Enqueue(new RequestState(val3, value2)); } } break; } case 2: { EffectRequest val2 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val2 != null) { if (!m_runningEffects.TryGetValue(((SimpleJSONRequest)val2).id, out RequestState value)) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val2).id, (EffectStatus)1, (StandardErrors)29)); CrowdControlMod.Logger.Error((object)(StandardErrors)29); } else { value.Stop(); } } break; } } } public void Enqueue(EffectRequest request, Effect effect) { m_requestQueue.Enqueue(new RequestState(request, effect)); } public void PauseAll() { foreach (KeyValuePair runningEffect in m_runningEffects) { runningEffect.Value.Pause(); } } public void ResumeAll() { foreach (KeyValuePair runningEffect in m_runningEffects) { runningEffect.Value.Resume(); } } public void Tick() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown RequestState result; while (m_requestQueue.TryDequeue(out result)) { if (!m_mod.GameStateManager.IsReady(result.Request.code)) { m_networkClient.SendAsync((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)result.Request).id, (EffectStatus)3, (string)null)).Forget(); continue; } if (result.TimedEffectState != null) { m_runningEffects.TryAdd(((SimpleJSONRequest)result.Request).id, result); continue; } EffectResponse response; try { response = result.Effect.Start(result.Request); } catch (Exception ex) { response = EffectResponse.Failure(((SimpleJSONRequest)result.Request).id, (StandardErrors)1); CrowdControlMod.Logger.Error(ex.Message); } m_networkClient.AttachMetadata(response); m_networkClient.SendAsync((SimpleJSONResponse?)(object)response).Forget(); } ConsumeEnumerators(); } private void ConsumeEnumerators() { foreach (KeyValuePair runningEffect in m_runningEffects) { if (!runningEffect.Value.MoveNext()) { m_runningEffects.TryRemove(runningEffect.Key, out RequestState _); } } } } [Serializable] [JsonConverter(typeof(Converter))] public struct SITimeSpan : IEquatable, IEquatable, IEquatable, IComparable, IComparable, IComparable, IFormattable { private class Converter : JsonConverter { public override void WriteJson(JsonWriter writer, SITimeSpan value, JsonSerializer serializer) { writer.WriteValue(value._value.TotalSeconds); } public override SITimeSpan ReadJson(JsonReader reader, Type objectType, SITimeSpan existingValue, bool hasExistingValue, JsonSerializer serializer) { if (reader.Value is TimeSpan timeSpan) { return timeSpan; } if (reader.Value is string s) { if (TimeSpan.TryParse(s, out var result)) { return result; } if (double.TryParse(s, out var result2)) { return result2; } } return Convert.ToDouble(reader.Value); } } public static readonly SITimeSpan Zero = new SITimeSpan(TimeSpan.Zero); public static readonly SITimeSpan MinValue = new SITimeSpan(TimeSpan.MinValue); public static readonly SITimeSpan MaxValue = new SITimeSpan(TimeSpan.MaxValue); private readonly TimeSpan _value; public long Ticks => _value.Ticks; public int Milliseconds => _value.Milliseconds; public int Seconds => _value.Seconds; public int Minutes => _value.Minutes; public int Hours => _value.Hours; public int Days => _value.Days; public double TotalMilliseconds => _value.TotalMilliseconds; public double TotalSeconds => _value.TotalSeconds; public double TotalMinutes => _value.TotalMinutes; public double TotalHours => _value.TotalHours; public double TotalDays => _value.TotalDays; public override string ToString() { return _value.ToString(); } public string ToString(string? format) { return _value.ToString(format); } public string ToString(string? format, IFormatProvider? formatProvider) { return _value.ToString(format, formatProvider); } public static SITimeSpan Parse(string input) { if (input.Contains('.')) { return new SITimeSpan(TimeSpan.ParseExact(input, "mm\\:ss\\.fff", null)); } return new SITimeSpan(TimeSpan.Parse(input)); } public static bool TryParse(string s, out SITimeSpan result) { TimeSpan result2; bool result3 = TimeSpan.TryParse(s, out result2); result = new SITimeSpan(result2); return result3; } public static int Compare(SITimeSpan t1, SITimeSpan t2) { return TimeSpan.Compare(t1._value, t2._value); } public static int Compare(TimeSpan t1, SITimeSpan t2) { return TimeSpan.Compare(t1, t2._value); } public static int Compare(SITimeSpan t1, TimeSpan t2) { return TimeSpan.Compare(t1._value, t2); } public static int Compare(double t1, SITimeSpan t2) { if (t1 > t2.TotalSeconds) { return 1; } if (!(t1 < t2.TotalSeconds)) { return 0; } return -1; } public static int Compare(SITimeSpan t1, double t2) { if (t1.TotalSeconds > t2) { return 1; } if (!(t1.TotalSeconds < t2)) { return 0; } return -1; } public static bool Equals(SITimeSpan t1, SITimeSpan t2) { return TimeSpan.Equals(t1._value, t2._value); } public static bool Equals(TimeSpan t1, SITimeSpan t2) { return TimeSpan.Equals(t1, t2._value); } public static bool Equals(SITimeSpan t1, TimeSpan t2) { return TimeSpan.Equals(t1._value, t2); } public static bool Equals(double t1, SITimeSpan t2) { return object.Equals(t1, (double)t2); } public static bool Equals(SITimeSpan t1, double t2) { return object.Equals((double)t1, t2); } public static SITimeSpan FromTicks(long value) { return new SITimeSpan(TimeSpan.FromTicks(value)); } public static SITimeSpan FromMilliseconds(double value) { return new SITimeSpan(TimeSpan.FromMilliseconds(value)); } public static SITimeSpan FromSeconds(double value) { return new SITimeSpan(TimeSpan.FromSeconds(value)); } public static SITimeSpan FromMinutes(double value) { return new SITimeSpan(TimeSpan.FromMinutes(value)); } public static SITimeSpan FromHours(double value) { return new SITimeSpan(TimeSpan.FromHours(value)); } public static SITimeSpan FromDays(double value) { return new SITimeSpan(TimeSpan.FromDays(value)); } public SITimeSpan Duration() { return new SITimeSpan(_value.Duration()); } public SITimeSpan Add(SITimeSpan other) { return new SITimeSpan(_value.Add(other._value)); } public SITimeSpan Subtract(SITimeSpan other) { return new SITimeSpan(_value.Subtract(other._value)); } public SITimeSpan Negate() { return new SITimeSpan(_value.Negate()); } private SITimeSpan(TimeSpan value) { _value = value; } private SITimeSpan(double value) { _value = TimeSpan.FromSeconds(value); } private SITimeSpan(long value) { _value = TimeSpan.FromSeconds(value); } public SITimeSpan? NullIfZero() { if (!(_value == TimeSpan.Zero)) { return this; } return null; } public static implicit operator SITimeSpan(double value) { return new SITimeSpan(value); } public static implicit operator SITimeSpan?(double? value) { if (!value.HasValue) { return null; } return new SITimeSpan(value.Value); } public static implicit operator SITimeSpan(TimeSpan value) { return new SITimeSpan(value); } public static implicit operator SITimeSpan?(TimeSpan? value) { if (!value.HasValue) { return null; } return new SITimeSpan(value.Value); } public static implicit operator SITimeSpan(Func value) { return new SITimeSpan(value()); } public static implicit operator SITimeSpan?(Func? value) { if (value == null) { return null; } return new SITimeSpan(value()); } public static implicit operator SITimeSpan(Func value) { return new SITimeSpan(value()._value); } public static implicit operator SITimeSpan?(Func? value) { if (value == null) { return null; } return new SITimeSpan(value()._value); } public static explicit operator double(SITimeSpan value) { return value._value.TotalSeconds; } public static explicit operator double?(SITimeSpan? value) { return value?._value.TotalSeconds; } public static explicit operator float(SITimeSpan value) { return (float)value._value.TotalSeconds; } public static explicit operator float?(SITimeSpan? value) { return (float?)value?._value.TotalSeconds; } public static explicit operator long(SITimeSpan value) { return checked((long)value._value.TotalSeconds); } public static explicit operator long?(SITimeSpan? value) { return checked((long?)value?._value.TotalSeconds); } public static explicit operator TimeSpan(SITimeSpan value) { return value._value; } public static explicit operator TimeSpan?(SITimeSpan? value) { return value?._value; } public static explicit operator Func(SITimeSpan value) { return () => value._value; } public static explicit operator Func(SITimeSpan? value) { return () => value?._value; } public static explicit operator Func(SITimeSpan value) { return () => value; } public static explicit operator Func(SITimeSpan? value) { return () => value; } public override bool Equals(object? obj) { if (obj is SITimeSpan other) { return Equals(other); } if (obj is TimeSpan other2) { return Equals(other2); } if (obj is double other3) { return Equals(other3); } return false; } public override int GetHashCode() { return _value.GetHashCode(); } public bool Equals(SITimeSpan other) { return _value.Equals(other._value); } public int CompareTo(SITimeSpan other) { return _value.CompareTo(other._value); } public static bool operator ==(SITimeSpan a, SITimeSpan b) { return a._value.Equals(b._value); } public static bool operator !=(SITimeSpan a, SITimeSpan b) { return !a._value.Equals(b._value); } public static bool operator <(SITimeSpan a, SITimeSpan b) { return a._value < b._value; } public static bool operator <=(SITimeSpan a, SITimeSpan b) { return a._value <= b._value; } public static bool operator >(SITimeSpan a, SITimeSpan b) { return a._value > b._value; } public static bool operator >=(SITimeSpan a, SITimeSpan b) { return a._value >= b._value; } public bool Equals(TimeSpan other) { return _value.Equals(other); } public int CompareTo(TimeSpan other) { return _value.CompareTo(other); } public static bool operator ==(SITimeSpan a, TimeSpan b) { return a.Equals(b); } public static bool operator ==(TimeSpan a, SITimeSpan b) { return b.Equals(a); } public static bool operator !=(SITimeSpan a, TimeSpan b) { return !a.Equals(b); } public static bool operator !=(TimeSpan a, SITimeSpan b) { return !b.Equals(a); } public static bool operator <(SITimeSpan a, TimeSpan b) { return a._value < b; } public static bool operator <(TimeSpan a, SITimeSpan b) { return a < b._value; } public static bool operator <=(SITimeSpan a, TimeSpan b) { return a._value <= b; } public static bool operator <=(TimeSpan a, SITimeSpan b) { return a <= b._value; } public static bool operator >(SITimeSpan a, TimeSpan b) { return a._value > b; } public static bool operator >(TimeSpan a, SITimeSpan b) { return a > b._value; } public static bool operator >=(SITimeSpan a, TimeSpan b) { return a._value >= b; } public static bool operator >=(TimeSpan a, SITimeSpan b) { return a >= b._value; } public static SITimeSpan operator -(SITimeSpan a) { return -a._value; } public static SITimeSpan operator +(TimeSpan a, SITimeSpan b) { return a + b._value; } public static SITimeSpan operator -(TimeSpan a, SITimeSpan b) { return a - b._value; } public static SITimeSpan operator +(SITimeSpan a, TimeSpan b) { return a._value + b; } public static SITimeSpan operator -(SITimeSpan a, TimeSpan b) { return a._value - b; } public static SITimeSpan operator +(SITimeSpan a, SITimeSpan b) { return a._value + b._value; } public static SITimeSpan operator -(SITimeSpan a, SITimeSpan b) { return a._value - b._value; } public static DateTime operator +(DateTime a, SITimeSpan b) { return a + b._value; } public static DateTime operator -(DateTime a, SITimeSpan b) { return a - b._value; } public static DateTimeOffset operator +(DateTimeOffset a, SITimeSpan b) { return a + b._value; } public static DateTimeOffset operator -(DateTimeOffset a, SITimeSpan b) { return a - b._value; } public static SITimeSpan operator +(double a, SITimeSpan b) { return a + b._value.TotalSeconds; } public static SITimeSpan operator -(double a, SITimeSpan b) { return a - b._value.TotalSeconds; } public static SITimeSpan operator *(double a, SITimeSpan b) { return a * b._value.TotalSeconds; } public static SITimeSpan operator +(SITimeSpan a, double b) { return a._value.TotalSeconds + b; } public static SITimeSpan operator -(SITimeSpan a, double b) { return a._value.TotalSeconds - b; } public static SITimeSpan operator *(SITimeSpan a, double b) { return a._value.TotalSeconds * b; } public static SITimeSpan operator /(SITimeSpan a, double b) { return a._value.TotalSeconds / b; } public static SITimeSpan operator %(SITimeSpan a, double b) { return a._value.TotalSeconds % b; } public bool Equals(double other) { return _value.TotalSeconds.Equals(other); } public int CompareTo(double other) { return _value.TotalSeconds.CompareTo(other); } public static bool operator ==(SITimeSpan a, double b) { return a.Equals(b); } public static bool operator ==(double a, SITimeSpan b) { return b.Equals(a); } public static bool operator !=(SITimeSpan a, double b) { return !a.Equals(b); } public static bool operator !=(double a, SITimeSpan b) { return !b.Equals(a); } public static bool operator <(SITimeSpan a, double b) { return a._value.TotalSeconds < b; } public static bool operator <(double a, SITimeSpan b) { return a < b._value.TotalSeconds; } public static bool operator <=(SITimeSpan a, double b) { return a._value.TotalSeconds <= b; } public static bool operator >=(SITimeSpan a, double b) { return a._value.TotalSeconds >= b; } public static bool operator >(SITimeSpan a, double b) { return a._value.TotalSeconds > b; } public static bool operator >(double a, SITimeSpan b) { return a > b._value.TotalSeconds; } public static bool operator <=(double a, SITimeSpan b) { return a <= b._value.TotalSeconds; } public static bool operator >=(double a, SITimeSpan b) { return a >= b._value.TotalSeconds; } } public static class TaskEx { public static async void Forget(this Task task) { try { await task.ConfigureAwait(continueOnCapturedContext: false); } catch (Exception ex) { CrowdControlMod.Logger.Error((object)ex); } } public static async void Forget(this Task task, bool silent) { try { await task.ConfigureAwait(continueOnCapturedContext: false); } catch (Exception ex) { if (!silent) { CrowdControlMod.Logger.Error((object)ex); } } } } } namespace CrowdControl.Harmony { [HarmonyPatch] public static class PlayerPatch { public static class PlayerReference { public static Player Instance; } [HarmonyPatch(typeof(Player), "OnStartClient")] public class Player_OnStartClient_Patch { private static void Postfix(Player __instance) { if (((NetworkBehaviour)__instance).IsOwner && (Object)(object)PlayerReference.Instance == (Object)null) { PlayerReference.Instance = __instance; } } } [HarmonyPatch(typeof(Player), "OnDestroy")] public class Player_Awake_Patch { private static void Postfix(Player __instance) { if (((Object)__instance).GetInstanceID() == ((Object)PlayerReference.Instance).GetInstanceID()) { PlayerReference.Instance = null; GameStateManager.effectUpdate = false; } } } } } namespace CrowdControl.Delegates.Metadata { [AttributeUsage(AttributeTargets.Method)] public class MetadataAttribute : Attribute { public string[] IDs { get; } public MetadataAttribute(params string[] ids) { IDs = ids; base..ctor(); } public MetadataAttribute(string ids) : this(new string[1] { ids }) { } public MetadataAttribute([ParamCollection] IEnumerable ids) : this(ids.ToArray()) { } } public delegate DataResponse MetadataDelegate(CrowdControlMod mod); public static class MetadataDelegates { public static readonly string[] CommonMetadata = new string[1] { "levelTime" }; [Metadata("levelTime")] public static DataResponse LevelTime(CrowdControlMod mod) { try { return DataResponse.Failure("levelTime", (object)"", "The plugin encountered an internal error. Check the game logs for more information."); } catch (Exception ex) { CrowdControlMod.Logger.Error($"Crowd Control Error: {ex}"); return DataResponse.Failure("levelTime", (object)ex, "The plugin encountered an internal error. Check the game logs for more information."); } } } public static class MetadataLoader { private const BindingFlags BINDING_FLAGS = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static readonly Dictionary Metadata; static MetadataLoader() { Metadata = new Dictionary(); Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { try { MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { try { foreach (MetadataAttribute customAttribute in methodInfo.GetCustomAttributes()) { string[] iDs = customAttribute.IDs; foreach (string key in iDs) { try { Metadata[key] = (MetadataDelegate)Delegate.CreateDelegate(typeof(MetadataDelegate), methodInfo); } catch (Exception ex) { CrowdControlMod.Logger.Error((object)ex); } } } } catch { } } } catch { } } } } } namespace CrowdControl.Delegates.Effects { public abstract class Effect { public EffectAttribute EffectAttribute { get; } public bool IsTimed => EffectAttribute.DefaultDuration > 0.0; public CrowdControlMod Mod { get; } public NetworkClient Client { get; } protected Effect(CrowdControlMod mod, NetworkClient client) { Mod = mod; Client = client; EffectAttribute = GetType().GetCustomAttributes(inherit: false).First(); } public abstract EffectResponse Start(EffectRequest request); public virtual EffectResponse? Tick(EffectRequest request) { return null; } public virtual EffectResponse? Pause(EffectRequest request) { return null; } public virtual EffectResponse? Resume(EffectRequest request) { return null; } public virtual EffectResponse? Stop(EffectRequest request) { return null; } } [AttributeUsage(AttributeTargets.Class)] public class EffectAttribute : Attribute { public IReadOnlyList IDs { get; } public SITimeSpan DefaultDuration { get; } public IReadOnlyList Conflicts { get; } public EffectAttribute(string[] ids, SITimeSpan defaultDuration, string[] conflicts) { IDs = ids; DefaultDuration = defaultDuration; Conflicts = conflicts; base..ctor(); } public EffectAttribute([ParamCollection] IEnumerable ids) : this(ids.ToArray(), SITimeSpan.Zero, Array.Empty()) { } public EffectAttribute(params string[] ids) : this(ids.ToArray(), SITimeSpan.Zero, Array.Empty()) { } public EffectAttribute(string[] ids, float defaultDuration, string[] conflicts) : this(ids, (SITimeSpan)defaultDuration, conflicts) { } public EffectAttribute(string[] ids, float defaultDuration, string conflict) : this(ids, defaultDuration, new string[1] { conflict }) { } public EffectAttribute(string id) : this(new string[1] { id }, SITimeSpan.Zero, Array.Empty()) { } public EffectAttribute(string id, float defaultDuration) : this(new string[1] { id }, defaultDuration, (!(SITimeSpan.Zero > 0.0)) ? Array.Empty() : new string[1] { id }) { } public EffectAttribute(string id, float defaultDuration, string conflict) : this(new string[1] { id }, defaultDuration, new string[1] { conflict }) { } public EffectAttribute(string id, float defaultDuration, string[] conflicts) : this(new string[1] { id }, defaultDuration, conflicts) { } public EffectAttribute(string id, float defaultDuration, bool selfConflict) : this(new string[1] { id }, defaultDuration, (!selfConflict) ? Array.Empty() : new string[1] { id }) { } public EffectAttribute(string[] ids, float defaultDuration, bool selfConflict) : this(ids, defaultDuration, selfConflict ? ids : Array.Empty()) { } public EffectAttribute(string id, bool selfConflict) : this(new string[1] { id }, SITimeSpan.Zero, (!selfConflict) ? Array.Empty() : new string[1] { id }) { } public EffectAttribute(string[] ids, bool selfConflict) : this(ids, SITimeSpan.Zero, selfConflict ? ids : Array.Empty()) { } } public class EffectLoader { private const BindingFlags BINDING_FLAGS = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public readonly Dictionary Effects = new Dictionary(); public EffectLoader(CrowdControlMod mod, NetworkClient client) { foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes() where type.IsSubclassOf(typeof(Effect)) select type) { try { foreach (EffectAttribute customAttribute in item.GetCustomAttributes()) { foreach (string iD in customAttribute.IDs) { try { Effects[iD] = (Effect)Activator.CreateInstance(item, mod, client); } catch (Exception ex) { CrowdControlMod.Logger.Error((object)ex); } } } } catch (Exception ex2) { CrowdControlMod.Logger.Error((object)ex2); } } } } public class TimedEffectState { public enum EffectState { NotStarted, Running, Paused, Finished, Errored } [CompilerGenerated] private sealed class d__15 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != EffectState.Running) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Pause(timedEffectState.Request); timedEffectState.State = EffectState.Paused; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Logger.Error(ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__16 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != EffectState.Paused) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Resume(timedEffectState.Request); timedEffectState.State = EffectState.Running; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Logger.Error(ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__14 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != 0) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Start(timedEffectState.Request); timedEffectState.TimeRemaining = timedEffectState.Duration; timedEffectState.State = EffectState.Running; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Logger.Error(ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__17 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State == EffectState.Finished) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Stop(timedEffectState.Request); timedEffectState.State = EffectState.Finished; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Logger.Error(ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__18 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != EffectState.Running) { result = false; <>m__Finally1(); } else { try { if (timedEffectState.TimeRemaining > 0.0) { 5__2 = timedEffectState.Effect.Tick(timedEffectState.Request); timedEffectState.TimeRemaining -= (double)Time.fixedDeltaTime; } else { 5__2 = timedEffectState.Effect.Stop(timedEffectState.Request); timedEffectState.State = EffectState.Finished; timedEffectState.TimeRemaining = SITimeSpan.Zero; } } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Logger.Error(ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public readonly EffectRequest Request; public readonly SITimeSpan Duration; public readonly Effect Effect; public readonly NetworkClient Client; public SITimeSpan TimeRemaining; private int m_stateLock; public EffectState State { get; private set; } private bool TryGetLock() { return Interlocked.CompareExchange(ref m_stateLock, 1, 0) == 0; } private void ReleaseLock() { m_stateLock = 0; } public TimedEffectState(Effect effect, EffectRequest request, SITimeSpan duration) { Effect = effect; Client = effect.Client; Request = request; Duration = duration; TimeRemaining = duration; } [IteratorStateMachine(typeof(d__14))] public IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__15))] public IEnumerator Pause() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__16))] public IEnumerator Resume() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__16(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__17))] public IEnumerator Stop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__17(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__18))] public IEnumerator Tick() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0) { <>4__this = this }; } } } namespace CrowdControl.Delegates.Effects.Implementations { [Effect(new string[] { "spawnVehicle_shitbox", "spawnVehicle_veeper", "spawnVehicle_bruiser", "spawnVehicle_dinkler", "spawnVehicle_hounddog", "spawnVehicle_cheetah", "clearWanted", "lowerWanted", "raiseWanted", "setTime_0600", "setTime_1200", "setTime_2000", "setLawIntensity_0", "setLawIntensity_10", "teleport_rv", "teleport_townhall", "teleport_motel", "teleport_barn", "teleport_docks", "teleport_laundromat", "teleport_postoffice", "teleport_bungalow" })] public class ConsoleCommands : Effect { public ConsoleCommands(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00cc: 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_00e0: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) string[] array = request.code.Split('_'); string text = ((array.Length != 0) ? array[0] : request.code); string text2 = ((array.Length > 1) ? array[1] : string.Empty); Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to trigger while player is dead."); } if (text.Contains("teleport") && (Object)(object)instance.CurrentVehicle != (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to teleport while player is in a vehicle."); } if (text.Contains("Time")) { if (!((NetworkBehaviour)instance).IsHost) { GameStateManager.UpdateEffects(); } if (!((NetworkBehaviour)instance).IsHost) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Can only adjust time on the host."); } } if (text.Contains("spawnVehicle")) { bool flag = false; Vector3 val = ((Component)instance).transform.position + Vector3.up; Vector3 down = Vector3.down; float num = 2f; RaycastHit[] array2 = Il2CppArrayBase.op_Implicit((Il2CppArrayBase)(object)Physics.RaycastAll(val, down, num)); for (int i = 0; i < array2.Length; i++) { RaycastHit val2 = array2[i]; if (!((Component)((RaycastHit)(ref val2)).collider).transform.IsChildOf(((Component)instance).transform)) { string name = ((Object)((Component)((RaycastHit)(ref val2)).collider).gameObject).name; if (name.Contains("Main") || name.Contains("Sidewalk") || name.Contains("Concrete") || name.Contains("Roof") || name.Contains("Road")) { flag = true; } break; } } if (!flag) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, "Can only spawn while the player is on the road/sidewalk."); } if (!((NetworkBehaviour)instance).IsHost) { GameStateManager.UpdateEffects(); } if (!((NetworkBehaviour)instance).IsHost) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Can only spawn cars on the host player."); } } switch (text) { case "lowerWanted": case "raiseWanted": case "clearWanted": { EPursuitLevel currentPursuitLevel = instance.CrimeData.CurrentPursuitLevel; string text3 = ((object)(EPursuitLevel)(ref currentPursuitLevel)).ToString(); if (text3 == "None" && (text == "lowerWanted" || text == "clearWanted")) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is not currently wanted."); } if (text3 == "Lethal" && text == "raiseWanted") { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is at highest wanted level."); } break; } } if (!string.IsNullOrEmpty(text)) { object obj = CommandFactory.CreateCommand(text); if (obj != null) { MethodInfo method = obj.GetType().GetMethod("Execute", new Type[1] { typeof(List) }); if (method != null) { List val3 = new List(); if (text2 != null) { val3.Add(text2); } method.Invoke(obj, new object[1] { val3 }); } } } switch (text) { case "lowerWanted": case "raiseWanted": case "clearWanted": StatusEffectSystem.CustomUIMessage(((text == "lowerWanted") ? "Lowered" : ((text == "raiseWanted") ? "Raised" : "Cleared")) + " wanted level!"); break; default: if (text.Contains("spawnVehicle")) { StatusEffectSystem.CustomUIMessage("Spawned " + text2 + "!"); } else if (text.Contains("Time")) { string text4 = ((text2 == "0600") ? "Dawn" : ((text2 == "1200") ? "Noon" : "Dusk")); StatusEffectSystem.CustomUIMessage("Set time to " + text4); } break; } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } public class CommandFactory { private static readonly Dictionary> CommandConstructors = new Dictionary>(StringComparer.OrdinalIgnoreCase) { { "addEmployee", () => (object)new AddEmployeeCommand(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "clearWanted", () => (object)new ClearWanted(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "lowerWanted", () => (object)new LowerWanted(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "raiseWanted", () => (object)new RaisedWanted(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "spawnVehicle", () => (object)new SpawnVehicleCommand(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "setLawIntensity", () => (object)new SetLawIntensity(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "setTime", () => (object)new SetTimeCommand(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) }, { "teleport", () => (object)new Teleport(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) } }; public static object CreateCommand(string className) { if (CommandConstructors.TryGetValue(className, out Func value)) { return value(); } throw new Exception("No known constructor for status class '" + className + "'"); } } [Effect("drugNPC")] public class DrugNPC : Effect { public static class StatusFactory { public static readonly Dictionary> StatusConstructors = new Dictionary> { { "Spicy", () => (object)new Spicy() }, { "AntiGravity", () => (object)new AntiGravity() }, { "Athletic", () => (object)new Athletic() }, { "Balding", () => (object)new Balding() }, { "BrightEyed", () => (object)new BrightEyed() }, { "Calming", () => (object)new Calming() }, { "CalorieDense", () => (object)new CalorieDense() }, { "Cyclopean", () => (object)new Cyclopean() }, { "Disorienting", () => (object)new Disorienting() }, { "Electrifying", () => (object)new Electrifying() }, { "Energizing", () => (object)new Energizing() }, { "Euphoric", () => (object)new Euphoric() }, { "Explosive", () => (object)new Explosive() }, { "Focused", () => (object)new Focused() }, { "Foggy", () => (object)new Foggy() }, { "Gingeritis", () => (object)new Gingeritis() }, { "Glowie", () => (object)new Glowie() }, { "Jennerising", () => (object)new Jennerising() }, { "Laxative", () => (object)new Laxative() }, { "LongFaced", () => (object)new LongFaced() }, { "Munchies", () => (object)new Munchies() }, { "Paranoia", () => (object)new Paranoia() }, { "Refreshing", () => (object)new Refreshing() }, { "Schizophrenic", () => (object)new Schizophrenic() }, { "Sedating", () => (object)new Sedating() }, { "Seizure", () => (object)new Seizure() }, { "Shrinking", () => (object)new Shrinking() }, { "Slippery", () => (object)new Slippery() }, { "Smelly", () => (object)new Smelly() }, { "Sneaky", () => (object)new Sneaky() }, { "ThoughtProvoking", () => (object)new ThoughtProvoking() }, { "Toxic", () => (object)new Toxic() }, { "TropicThunder", () => (object)new TropicThunder() }, { "Zombifying", () => (object)new Zombifying() } }; public static object CreateStatus(string key) { if (StatusConstructors.TryGetValue(key, out Func value)) { return value(); } return null; } } public DrugNPC(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No valid NPC found."); } if ((Object)(object)NetworkSingleton.Instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No valid NPC found."); } List nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null || nPCRegistry.Count == 0) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No valid NPC found."); } List list = new List(); Enumerator enumerator = nPCRegistry.GetEnumerator(); while (enumerator.MoveNext()) { NPC current = enumerator.Current; if (!((Object)(object)current == (Object)null) && !((Object)current).name.Contains("Clone", StringComparison.OrdinalIgnoreCase) && ((Component)current).gameObject.activeInHierarchy) { list.Add(current); } } if (list.Count == 0) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No valid NPC found."); } Vector3 position = ((Component)instance).transform.position; NPC val = null; float num = float.MaxValue; foreach (NPC item in list) { float num2 = Vector3.Distance(position, ((Component)item).transform.position); if (num2 < num) { num = num2; val = item; } } if ((Object)(object)val == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No valid NPC found."); } if (num >= 2f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "The closest NPC is too far away."); } List list2 = StatusFactory.StatusConstructors.Keys.ToList(); checked { int num3 = Random.Range(1, list2.Count + 1); for (int i = 0; i < list2.Count; i++) { int num4 = Random.Range(i, list2.Count); List list3 = list2; int index = i; int index2 = num4; string value = list2[num4]; string value2 = list2[i]; list3[index] = value; list2[index2] = value2; } try { for (int j = 0; j < num3; j++) { object obj = StatusFactory.CreateStatus(list2[j]); if (obj != null) { MethodInfo method = obj.GetType().GetMethod("ApplyToNPC"); if (method != null) { method.Invoke(obj, new object[1] { val }); } } } } catch (Exception) { } StatusEffectSystem.CustomUIMessage("Drugged " + ((Object)val).name + "!"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } } [Effect("flipScreen")] public class FlipScreen : Effect { public FlipScreen(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_000a: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_003e: 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) Vector3 position = ((Component)PlayerSingleton.Instance).transform.position; Quaternion val = ((Component)PlayerSingleton.Instance).transform.rotation * Quaternion.Euler(0f, 0f, 180f); PlayerSingleton.Instance.OverrideTransform(position, val, 0.5f, false); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "giveItem_granddaddypurple", "giveItem_greencrack", "giveItem_ogkush", "giveItem_sourdiesel", "giveItem_cocaine", "giveItem_meth", "giveItem_baggie", "giveItem_brick", "giveItem_jar", "giveItem_extralonglifesoil", "giveItem_fertilizer", "giveItem_longlifesoil", "giveItem_pgr", "giveItem_soil", "giveItem_speedgrow", "giveItem_cocaleaf", "giveItem_granddaddypurpleseed", "giveItem_greencrackseed", "giveItem_ogkushseed", "giveItem_sourdieselseed", "giveItem_cocaseed", "giveItem_electrictrimmers", "giveItem_flashlight", "giveItem_managementclipboard", "giveItem_trashbag", "giveItem_trashgrabber", "giveItem_trimmers", "giveItem_wateringcan", "giveItem_bigsprinkler", "giveItem_soilpourer", "giveItem_potsprinkler", "giveItem_baseballbat", "giveItem_fryingpan", "giveItem_m1911", "giveItem_m1911mag", "giveItem_machete", "giveItem_revolvercylinder", "giveItem_revolver", "giveItem_coffeetable", "giveItem_dumpster", "giveItem_suspensionrack", "giveItem_metalsquaretable", "giveItem_trashcan", "giveItem_bed", "giveItem_smalltrashcan", "giveItem_TV", "giveItem_woodsquaretable", "giveItem_fullspectrumgrowlight", "giveItem_halogengrowlight", "giveItem_ledgrowlight", "giveItem_banana", "giveItem_cuke", "giveItem_donut", "giveItem_energydrink", "giveItem_flumedicine", "giveItem_chili", "giveItem_airpot", "giveItem_plasticpot", "giveItem_growtent", "giveItem_moisturepreservingpot", "giveItem_largestoragerack", "giveItem_mediumstoragerack", "giveItem_smallstoragerack", "giveItem_brickpress", "giveItem_cauldron", "giveItem_chemistrystation", "giveItem_dryingrack", "giveItem_laboven", "giveItem_launderingstation", "giveItem_mixingstation", "giveItem_mixingstationmk2", "giveItem_packagingstation", "giveItem_packagingstationmk2", "giveItem_acid", "giveItem_addy", "giveItem_battery", "giveItem_gasoline", "giveItem_horsesemen", "giveItem_motoroil", "giveItem_mouthwash", "giveItem_paracetamol", "giveItem_viagra", "giveItem_floorlamp", "giveItem_displaycabinet", "giveItem_filingcabinet", "giveItem_cargopants", "giveItem_jeans", "giveItem_jorts", "giveItem_longskirt", "giveItem_overalls", "giveItem_skirt", "giveItem_legendsunglasses", "giveItem_rectangleframeglasses", "giveItem_smallroundglasses", "giveItem_speeddealershades", "giveItem_combatboots", "giveItem_dressshoes", "giveItem_flats", "giveItem_sandals", "giveItem_sneakers", "giveItem_fingerlessgloves", "giveItem_gloves", "giveItem_buckethat", "giveItem_cap", "giveItem_chefhat", "giveItem_cowboyhat", "giveItem_flatcap", "giveItem_porkpiehat", "giveItem_saucepan", "giveItem_apron", "giveItem_blazer", "giveItem_collarjacket", "giveItem_tacticalvest", "giveItem_vest", "giveItem_buttonup", "giveItem_rolledbuttonup", "giveItem_flannelshirt", "giveItem_tshirt", "giveItem_vneck", "giveItem_belt", "giveItem_cheapskateboard", "giveItem_cruiser", "giveItem_goldenskateboard", "giveItem_lightweightskateboard", "giveItem_skateboard", "giveItem_chateaulapeepee", "giveItem_goldbar", "giveItem_oldmanjimmys", "giveItem_cocainebase", "giveItem_iodine", "giveItem_liquidbabyblue", "giveItem_liquidbikercrank", "giveItem_liquidglass", "giveItem_liquidmeth", "giveItem_megabean", "giveItem_phosphorus", "giveItem_babyblue", "giveItem_bikercrank", "giveItem_glass", "giveItem_testweed" })] public class GiveItem : Effect { public GiveItem(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) string text = ((request.code.Split('_').Length > 1) ? request.code.Split('_')[1] : string.Empty); Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to give items while player is dead."); } List hotbarSlots = ((Component)instance).GetComponentInChildren().hotbarSlots; ItemInstance val = null; bool flag = false; Enumerator enumerator = hotbarSlots.GetEnumerator(); while (enumerator.MoveNext()) { HotbarSlot current = enumerator.Current; ItemInstance val2 = ((current != null) ? ((ItemSlot)current).ItemInstance : null); if (val2 == null) { flag = true; } else if (((BaseItemInstance)val2).Name != null && ((BaseItemInstance)val2).Name.Replace(" ", "").Equals(text, StringComparison.OrdinalIgnoreCase)) { val = val2; } } if (flag || (val != null && ((BaseItemInstance)val).Quantity < ((BaseItemInstance)val).StackLimit)) { AddItemToInventoryCommand val3 = new AddItemToInventoryCommand(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)); List val4 = new List(); val4.Add(text); ((ConsoleCommand)val3).Execute(val4); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Inventory is at max capacity."); } } [Effect("event-hype-train")] public class HypeTrainEffect : Effect { public AssetBundle bundle; private static GameObject hypetrainPrefab; public static bool trainLoaded; private static readonly string BUNDLE_PATH = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "warpworld.hypetrain"); public HypeTrainEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public void LoadAssetsFromBundle() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown if (trainLoaded) { return; } try { CrowdControlMod.Logger.Msg("Loading AssetBundle from: " + BUNDLE_PATH); bundle = AssetBundle.LoadFromFile(BUNDLE_PATH); if ((Object)(object)bundle == (Object)null) { CrowdControlMod.Logger.Msg("Failed to load AssetBundle."); return; } try { hypetrainPrefab = (GameObject)bundle.LoadAsset("HypeTrain"); if ((Object)(object)hypetrainPrefab == (Object)null) { CrowdControlMod.Logger.Msg("HypeTrain prefab not found in AssetBundle."); } else { CrowdControlMod.Logger.Msg("HypeTrain prefab successfully loaded."); } } catch (Exception value) { CrowdControlMod.Logger.Error($"Error loading HypeTrain prefab: {value}"); } trainLoaded = true; } catch (Exception value2) { CrowdControlMod.Logger.Error($"Exception during LoadAssetsFromBundle: {value2}"); } } public void Spawn_HypeTrain(Vector3 position, Quaternion rotation, HypeTrainSourceDetails sourceDetails) { } 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 override EffectResponse Start(EffectRequest request) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown Player instance = PlayerPatch.PlayerReference.Instance; if (!trainLoaded) { LoadAssetsFromBundle(); } try { Spawn_HypeTrain(((Component)instance).transform.position, Quaternion.identity, (HypeTrainSourceDetails)request.sourceDetails); } catch (Exception) { CrowdControlMod.Logger.Msg("WTF"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("playerArrest")] public class PlayerArrest : Effect { public PlayerArrest(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to arrest the dead."); } if (instance.IsArrested) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to arrest player while they are arrested."); } instance.Arrest_Client(); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("playerHeal")] public class PlayerHeal : Effect { public PlayerHeal(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { PlayerHealth componentInChildren = ((Component)PlayerPatch.PlayerReference.Instance).GetComponentInChildren(); if (!componentInChildren.IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is dead unable to be healed."); } if (componentInChildren.CurrentHealth >= 100f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already at full health."); } componentInChildren.SetHealth(100f); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("playerHurt")] public class PlayerHurt : Effect { public PlayerHurt(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { PlayerHealth componentInChildren = ((Component)PlayerPatch.PlayerReference.Instance).GetComponentInChildren(); if (!componentInChildren.IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is dead unable to be hurt."); } if (componentInChildren.CurrentHealth <= 10f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player too low on health to take damage."); } componentInChildren.TakeDamage(10f, true, true); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("playerKill")] public class PlayerKill : Effect { public PlayerKill(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { PlayerHealth componentInChildren = ((Component)PlayerPatch.PlayerReference.Instance).GetComponentInChildren(); if (!componentInChildren.IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to kill the dead."); } componentInChildren.SendDie(); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("playerRevive")] public class PlayerRevive : Effect { public PlayerRevive(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_002d: 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) Player instance = PlayerPatch.PlayerReference.Instance; PlayerHealth componentInChildren = ((Component)instance).GetComponentInChildren(); if (componentInChildren.IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to revive someone that is not dead."); } componentInChildren.SendRevive(((Component)instance).transform.position, ((Component)instance).transform.rotation); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "player_Spicy", "player_AntiGravity", "player_Athletic", "player_Balding", "player_BrightEyed", "player_Calming", "player_CalorieDense", "player_Cyclopean", "player_Disorienting", "player_Electrifying", "player_Energizing", "player_Euphoric", "player_Explosive", "player_Focused", "player_Foggy", "player_Gingeritis", "player_Glowie", "player_Jennerising", "player_Laxative", "player_Lethal", "player_LongFaced", "player_Munchies", "player_Paranoia", "player_Property", "player_Refreshing", "player_Schizophrenic", "player_Sedating", "player_Seizure", "player_Shrinking", "player_Slippery", "player_Smelly", "player_Sneaky", "player_Spicy", "player_ThoughtProvoking", "player_Toxic", "player_TropicThunder", "player_Zombifying" }, 30f, true)] public class PlayerEffect : Effect { private static readonly BindingFlags StatusMethodFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; public PlayerEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to set a status when player is dead."); } string statusCode = GetStatusCode(request.code); if (!string.IsNullOrEmpty(statusCode)) { if (statusCode == "Disorienting" && instance.Disoriented) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already under the influence of Disorienting effect."); } if (statusCode == "Paranoia" && instance.Paranoid) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already under the influence of Paranoia effect."); } if (statusCode == "Schizophrenic" && instance.Schizophrenic) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already under the influence of Schizophrenic effect."); } if (statusCode == "Seizure" && instance.Seizure) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already under the influence of Seizure effect."); } if (statusCode == "Slippery" && instance.Slippery) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already under the influence of Slippery effect."); } if (statusCode == "Sneaky" && instance.Sneaky) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is already under the influence of Sneaky effect."); } object obj = StatusFactory.CreateStatus(statusCode); if (obj == null) { CrowdControlMod.Logger.Warning("No status constructor found for player status '" + statusCode + "'."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unsupported player status '" + statusCode + "'."); } if (!TryInvokeStatusMethod(obj, instance, "ApplyToPlayer", "Apply", "Enable", "Activate", "AddToPlayer")) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to apply player status '" + statusCode + "'."); } StatusEffectSystem.CustomUIMessage("Activated " + statusCode + " Effect!"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Missing player status code."); } public override EffectResponse? Stop(EffectRequest request) { Player instance = PlayerPatch.PlayerReference.Instance; string statusCode = GetStatusCode(request.code, keepWholeCodeWhenNoSeparator: true); if (!string.IsNullOrEmpty(statusCode)) { object obj = StatusFactory.CreateStatus(statusCode); if (obj == null) { CrowdControlMod.Logger.Warning("No status constructor found while clearing player status '" + statusCode + "'."); return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } if (!TryInvokeStatusMethod(obj, instance, "ClearFromPlayer", "Clear", "Disable", "Deactivate", "RemoveFromPlayer", "Remove")) { CrowdControlMod.Logger.Warning("Unable to find a clear method for player status '" + statusCode + "'."); } } StatusEffectSystem.CustomUIMessage(""); if (statusCode == "Schizophrenic") { instance.Disoriented = false; instance.Schizophrenic = false; AudioManager instance2 = Singleton.Instance; if ((Object)(object)instance2 != (Object)null) { instance2.SetDistorted(false, 5f); } } return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } private static string GetStatusCode(string? code, bool keepWholeCodeWhenNoSeparator = false) { if (string.IsNullOrWhiteSpace(code)) { return string.Empty; } string[] array = code.Split('_', StringSplitOptions.RemoveEmptyEntries); if (array.Length > 1) { return array[1]; } if (!keepWholeCodeWhenNoSeparator) { return string.Empty; } return code; } private static bool TryInvokeStatusMethod(object status, object target, params string[] candidateNames) { MethodInfo methodInfo = ResolveStatusMethod(status.GetType(), target.GetType(), candidateNames); if (methodInfo == null) { string value = string.Join(", ", from name in (from m in status.GetType().GetMethods(StatusMethodFlags) where m.GetParameters().Length == 1 select m.Name).Distinct() orderby name select name); CrowdControlMod.Logger.Warning($"No compatible status method found on '{status.GetType().FullName}' for target '{target.GetType().FullName}'. Available one-arg methods: {value}"); return false; } try { methodInfo.Invoke(status, new object[1] { target }); return true; } catch (Exception value2) { CrowdControlMod.Logger.Error($"Failed to invoke '{methodInfo.Name}' on '{status.GetType().FullName}': {value2}"); return false; } } private static MethodInfo? ResolveStatusMethod(Type statusType, Type targetType, IEnumerable candidateNames) { Type targetType2 = targetType; IEnumerable candidateNames2 = candidateNames; foreach (string candidateName in candidateNames2) { MethodInfo methodInfo = statusType.GetMethods(StatusMethodFlags).FirstOrDefault((MethodInfo method) => string.Equals(method.Name, candidateName, StringComparison.Ordinal) && IsCompatibleStatusMethod(method, targetType2)); if (methodInfo != null) { return methodInfo; } } return (from method in statusType.GetMethods(StatusMethodFlags) where IsCompatibleStatusMethod(method, targetType2) orderby GetMethodPriority(method.Name, candidateNames2), method.Name.Length select method).FirstOrDefault(); } private static bool IsCompatibleStatusMethod(MethodInfo method, Type targetType) { ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != 1) { return false; } Type parameterType = parameters[0].ParameterType; if (!parameterType.IsAssignableFrom(targetType) && !targetType.IsAssignableFrom(parameterType) && !string.Equals(parameterType.FullName, targetType.FullName, StringComparison.Ordinal)) { return string.Equals(parameterType.Name, targetType.Name, StringComparison.Ordinal); } return true; } private static int GetMethodPriority(string methodName, IEnumerable candidateNames) { string methodName2 = methodName; int num = (from item in candidateNames.Select((string name, int idx) => new { name, idx }) where string.Equals(item.name, methodName2, StringComparison.OrdinalIgnoreCase) select item.idx).DefaultIfEmpty(1073741823).First(); if (num != 1073741823) { return num; } if (methodName2.Contains("Apply", StringComparison.OrdinalIgnoreCase) || methodName2.Contains("Clear", StringComparison.OrdinalIgnoreCase) || methodName2.Contains("Remove", StringComparison.OrdinalIgnoreCase) || methodName2.Contains("Activate", StringComparison.OrdinalIgnoreCase) || methodName2.Contains("Deactivate", StringComparison.OrdinalIgnoreCase)) { return 1073741824; } return int.MaxValue; } } public static class StatusFactory { public static readonly Dictionary> StatusConstructors = new Dictionary> { { "Spicy", () => (object)new Spicy() }, { "AntiGravity", () => (object)new AntiGravity() }, { "Athletic", () => (object)new Athletic() }, { "Balding", () => (object)new Balding() }, { "BrightEyed", () => (object)new BrightEyed() }, { "Calming", () => (object)new Calming() }, { "CalorieDense", () => (object)new CalorieDense() }, { "Cyclopean", () => (object)new Cyclopean() }, { "Disorienting", () => (object)new Disorienting() }, { "Electrifying", () => (object)new Electrifying() }, { "Energizing", () => (object)new Energizing() }, { "Euphoric", () => (object)new Euphoric() }, { "Explosive", () => (object)new Explosive() }, { "Focused", () => (object)new Focused() }, { "Foggy", () => (object)new Foggy() }, { "Gingeritis", () => (object)new Gingeritis() }, { "Glowie", () => (object)new Glowie() }, { "Jennerising", () => (object)new Jennerising() }, { "Laxative", () => (object)new Laxative() }, { "LongFaced", () => (object)new LongFaced() }, { "Munchies", () => (object)new Munchies() }, { "Paranoia", () => (object)new Paranoia() }, { "Refreshing", () => (object)new Refreshing() }, { "Schizophrenic", () => (object)new Schizophrenic() }, { "Sedating", () => (object)new Sedating() }, { "Seizure", () => (object)new Seizure() }, { "Shrinking", () => (object)new Shrinking() }, { "Slippery", () => (object)new Slippery() }, { "Smelly", () => (object)new Smelly() }, { "Sneaky", () => (object)new Sneaky() }, { "ThoughtProvoking", () => (object)new ThoughtProvoking() }, { "Toxic", () => (object)new Toxic() }, { "TropicThunder", () => (object)new TropicThunder() }, { "Zombifying", () => (object)new Zombifying() } }; public static object CreateStatus(string key) { if (StatusConstructors.TryGetValue(key, out Func value)) { return value(); } return null; } } [Effect("level_restart")] public class RestartLevel : Effect { public RestartLevel(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) CrowdControlMod.Logger.Msg("Passing out?"); _ = PlayerPatch.PlayerReference.Instance; new PlayerHealth(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)); NPC val = ((IEnumerable)Object.FindObjectsOfType()).FirstOrDefault((Func)((NPC n) => ((Object)n).name == "YourNPCName")); if ((Object)(object)val != (Object)null) { val.SendTextMessage("Hello Customer!"); CrowdControlMod.Logger.Msg("Message sent via NPC."); } else { CrowdControlMod.Logger.Warning("NPC not found!"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("spawnPolice")] public class SpawnPolice : Effect { [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject policeClone; public PoliceOfficer clonedOfficer; public Vector3 returnPosition; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(4f); <>1__state = 1; return true; case 1: { <>1__state = -1; if ((Object)(object)policeClone == (Object)null || (Object)(object)clonedOfficer == (Object)null) { return false; } clonedOfficer.Suspicion = 0f; ((NPC)clonedOfficer).Aggression = 0f; PrimeOfficerMovement(policeClone, returnPosition); FootPatrolBehaviour componentInChildren = policeClone.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = true; NpcBehaviourCompat.TryStartFootPatrol(componentInChildren); TryInvokeZeroArgMethod(componentInChildren, "StartPatrol"); } TryInvokeZeroArgMethod(clonedOfficer, "StartPatrol"); CrowdControlMod.Logger.Msg("Sent cloned officer back toward patrol route."); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly BindingFlags MethodFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; public SpawnPolice(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) if (!InstanceFinder.IsServer) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Only the host can spawn police."); } Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police while the player is dead."); } if ((Object)(object)NetworkSingleton.Instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } List nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null || nPCRegistry.Count == 0) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } if ((Object)(object)instance.CurrentVehicle != (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police while the player is in a vehicle."); } NPC cloneableOfficer = GetCloneableOfficer(nPCRegistry, ((Component)instance).transform.position); if ((Object)(object)cloneableOfficer == (Object)null) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, "No active initialized police officer is available to clone right now."); } GameObject gameObject = ((Component)cloneableOfficer).gameObject; Vector3 position = ((Component)cloneableOfficer).transform.position; Vector3 val = ((Component)instance).transform.position + ((Component)instance).transform.forward * 2f; GameObject val2 = Object.Instantiate(gameObject, val, Quaternion.LookRotation(-((Component)instance).transform.forward, Vector3.up)); if ((Object)(object)val2 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to clone initialized police officer."); } NetworkObject component = val2.GetComponent(); if ((Object)(object)component != (Object)null && !component.IsSpawned) { InstanceFinder.ServerManager.Spawn(val2, (NetworkConnection)null, default(Scene)); } foreach (NPCBehaviour componentsInChild in val2.GetComponentsInChildren(true)) { ((Component)componentsInChild).gameObject.SetActive(true); ((Behaviour)componentsInChild).enabled = true; } FootPatrolBehaviour componentInChildren = val2.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).gameObject.SetActive(true); ((Behaviour)componentInChildren).enabled = true; NpcBehaviourCompat.TryStartFootPatrol(componentInChildren); } PoliceOfficer componentInChildren2 = val2.GetComponentInChildren(true); if ((Object)(object)componentInChildren2 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Cloned police officer is missing PoliceOfficer component."); } NetworkObject component2 = ((Component)instance).GetComponent(); ((Component)componentInChildren2).gameObject.SetActive(true); PrimeOfficerMovement(val2, ((Component)instance).transform.position); if ((Object)(object)component2 != (Object)null) { ((NPC)componentInChildren2).AimedAtByPlayer(component2); } componentInChildren2.Suspicion = 9999f; ((NPC)componentInChildren2).Aggression = 9999f; componentInChildren2.CanInvestigatePlayer(instance); TryInvokeZeroArgMethod(componentInChildren2, "StartPatrol"); TryInvokeMethod(componentInChildren2, "NoticedWantedPlayer", instance); MelonCoroutines.Start(ReturnOfficerToPatrol(val2, componentInChildren2, position)); int length = val2.GetComponentsInChildren(true).Length; CrowdControlMod.Logger.Msg($"Cloned active officer '{((Object)cloneableOfficer).name}' with {length} renderers and positioned near player."); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private static NPC? GetCloneableOfficer(List registry, Vector3 playerPosition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0095: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(12.85f, 0.85f, 38.53f); List list = new List(); Enumerator enumerator = registry.GetEnumerator(); while (enumerator.MoveNext()) { NPC current = enumerator.Current; if ((Object)(object)current == (Object)null || !((Object)current).name.Contains("Officer", StringComparison.OrdinalIgnoreCase) || ((Object)current).name.Contains("Clone", StringComparison.OrdinalIgnoreCase) || !((Component)current).gameObject.activeInHierarchy || Vector3.Distance(((Component)current).transform.position, val) < 0.5f || (Object)(object)((Component)current).GetComponent() == (Object)null || (Object)(object)((Component)current).GetComponent() == (Object)null || (Object)(object)((Component)current).GetComponentInChildren(true) == (Object)null) { continue; } FootPatrolBehaviour componentInChildren = ((Component)current).GetComponentInChildren(true); if (!((Object)(object)componentInChildren == (Object)null) && ((Behaviour)componentInChildren).enabled && ((Component)componentInChildren).gameObject.activeInHierarchy) { int num = ((IEnumerable)((Component)current).GetComponentsInChildren(true)).Count((Renderer renderer) => renderer.enabled && ((Component)renderer).gameObject.activeInHierarchy); int num2 = ((IEnumerable)((Component)current).GetComponentsInChildren(true)).Count((SkinnedMeshRenderer renderer) => ((Renderer)renderer).enabled && ((Component)renderer).gameObject.activeInHierarchy && (Object)(object)renderer.sharedMesh != (Object)null); if (num >= 10 && num2 != 0) { list.Add(current); } } } if (list.Count == 0) { return null; } return list.OrderBy((NPC npc) => Vector3.Distance(((Component)npc).transform.position, playerPosition)).ThenBy((NPC _) => Random.value).FirstOrDefault(); } [IteratorStateMachine(typeof(d__4))] private static IEnumerator ReturnOfficerToPatrol(GameObject policeClone, PoliceOfficer clonedOfficer, Vector3 returnPosition) { //IL_0015: 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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { policeClone = policeClone, clonedOfficer = clonedOfficer, returnPosition = returnPosition }; } private static void PrimeOfficerMovement(GameObject policeClone, Vector3 targetPosition) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) NavMeshAgent component = policeClone.GetComponent(); NPCMovement component2 = policeClone.GetComponent(); NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(policeClone.transform.position, ref val, 3f, -1)) { policeClone.transform.position = ((NavMeshHit)(ref val)).position; if (component != null) { component.Warp(((NavMeshHit)(ref val)).position); } if (component2 != null) { component2.Warp(((NavMeshHit)(ref val)).position); } } else if (component2 != null) { component2.WarpToNavMesh(); } if (component != null) { component.ResetPath(); } if ((Object)(object)component != (Object)null) { component.isStopped = false; component.SetDestination(targetPosition); } if (component2 != null) { component2.SetDestination(targetPosition); } CrowdControlMod.Logger.Msg("Primed cloned officer movement toward player."); } private static bool TryInvokeZeroArgMethod(object target, string methodName) { MethodInfo method = target.GetType().GetMethod(methodName, MethodFlags, null, Type.EmptyTypes, null); if (method == null) { return false; } try { method.Invoke(target, null); CrowdControlMod.Logger.Msg($"Invoked '{methodName}' on '{target.GetType().Name}'."); return true; } catch (Exception ex) { CrowdControlMod.Logger.Warning($"Failed invoking '{methodName}' on '{target.GetType().Name}': {ex.Message}"); return false; } } private static bool TryInvokeMethod(object target, string methodName, params object[] args) { string methodName2 = methodName; object[] args2 = args; MethodInfo methodInfo = target.GetType().GetMethods(MethodFlags).FirstOrDefault((MethodInfo m) => string.Equals(m.Name, methodName2, StringComparison.Ordinal) && m.GetParameters().Length == args2.Length); if (methodInfo == null) { return false; } try { methodInfo.Invoke(target, args2); CrowdControlMod.Logger.Msg($"Invoked '{methodName2}' on '{target.GetType().Name}'."); return true; } catch (Exception ex) { CrowdControlMod.Logger.Warning($"Failed invoking '{methodName2}' on '{target.GetType().Name}': {ex.Message}"); return false; } } } [Effect("spawnTrash")] public class SpawnTrash : Effect { public SpawnTrash(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) if (!InstanceFinder.IsServer) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Only the host can spawn police."); } Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police while the player is dead."); } if ((Object)(object)NetworkSingleton.Instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } List nPCRegistry = NPCManager.NPCRegistry; if (nPCRegistry == null || nPCRegistry.Count == 0) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } Vector3 position = ((Component)instance).transform.position; Il2CppArrayBase obj = Object.FindObjectsOfType(); List list = new List(); foreach (TrashItem item in obj) { if ((Object)(object)item != (Object)null && ((Component)item).gameObject.activeInHierarchy) { list.Add(item); } } TrashItem val = null; if (list.Count > 0) { int index = Random.Range(0, list.Count); val = list[index]; } GameObject val2 = Object.Instantiate(((Component)val).gameObject); ((Object)val2).name = "CrowdControlTrash"; val2.transform.position = position + Vector3.forward * 1.5f; val2.transform.rotation = Quaternion.identity; val2.SetActive(true); Rigidbody val3 = val2.GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = val2.AddComponent(); } val3.useGravity = true; val3.isKinematic = false; NetworkObject component = val2.GetComponent(); InstanceFinder.ServerManager.Spawn(component, (NetworkConnection)null, default(Scene)); CrowdControlMod.Logger.Msg("Spawned trash object '" + ((Object)val2).name + "' at player position."); List list2 = new List(); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(12.85f, 0.85f, 38.53f); float num = 0.5f; Enumerator enumerator2 = nPCRegistry.GetEnumerator(); while (enumerator2.MoveNext()) { NPC current2 = enumerator2.Current; if ((Object)(object)current2 == (Object)null || !((Object)current2).name.Contains("Officer", StringComparison.OrdinalIgnoreCase) || ((Object)current2).name.Contains("Clone", StringComparison.OrdinalIgnoreCase) || !((Component)current2).gameObject.activeInHierarchy || (Object)(object)((Component)current2).GetComponent() == (Object)null || (Object)(object)((Component)current2).GetComponent() == (Object)null || (Object)(object)((Component)current2).GetComponent() == (Object)null) { continue; } if (Vector3.Distance(((Component)current2).transform.position, val4) < num) { CrowdControlMod.Logger.Msg($"Skipping idle officer at station: {((Component)current2).transform.position}"); continue; } foreach (FootPatrolBehaviour componentsInChild in ((Component)current2).GetComponentsInChildren(true)) { if ((Object)(object)componentsInChild != (Object)null && ((Behaviour)componentsInChild).enabled && ((Component)componentsInChild).gameObject.activeInHierarchy) { list2.Add(current2); CrowdControlMod.Logger.Msg($"Found valid officer: {((Object)current2).name} at {((Component)current2).transform.position}"); break; } } } if (list2.Count == 0) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time. None to find"); } NPC val5 = list2[Random.Range(0, list2.Count)]; if ((Object)(object)val5 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } CrowdControlMod.Logger.Msg($"Found valid officer: {((Object)val5).name} at {((Component)val5).transform.position}"); Vector3 val6 = ((Component)instance).transform.position + Vector3.forward * 2f; GameObject val7 = Object.Instantiate(((Component)val5).gameObject, val6, Quaternion.identity); if ((Object)(object)val7 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } FootPatrolBehaviour componentInChildren = val7.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).gameObject.SetActive(true); ((Behaviour)componentInChildren).enabled = true; NpcBehaviourCompat.TryStartFootPatrol(componentInChildren); CrowdControlMod.Logger.Msg("Force-enabled patrol behavior after spawn."); } NetworkObject component2 = ((Component)PlayerPatch.PlayerReference.Instance).GetComponent(); PoliceOfficer componentInChildren2 = val7.GetComponentInChildren(true); ((NPC)componentInChildren2).AimedAtByPlayer(component2); componentInChildren2.Suspicion = 9999f; ((NPC)componentInChildren2).Aggression = 9999f; componentInChildren2.CanInvestigatePlayer(instance); NetworkObject component3 = val7.GetComponent(); if ((Object)(object)component3 != (Object)null && !component3.IsSpawned) { InstanceFinder.ServerManager.Spawn(val7, (NetworkConnection)null, default(Scene)); foreach (NPCBehaviour componentsInChild2 in val7.GetComponentsInChildren(true)) { ((Component)componentsInChild2).gameObject.SetActive(true); ((Behaviour)componentsInChild2).enabled = true; } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to spawn police at this time"); } } [Effect(new string[] { "giveCash_100", "giveCash_1000", "giveCash_10000", "takeCash_100", "takeCash_1000", "takeCash_10000" })] public class UpdateCash : Effect { public UpdateCash(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Player instance = PlayerPatch.PlayerReference.Instance; if (!((Component)instance).GetComponentInChildren().IsAlive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to give/take cash when the player is dead."); } PlayerInventory componentInChildren = ((Component)instance).GetComponentInChildren(); string text = ((request.code.Split('_').Length > 1) ? request.code.Split('_')[1] : string.Empty); if (text == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Invalid cash amount."); } if (request.code.Contains("takeCash")) { text = "-" + text; if (((BaseItemInstance)((ItemSlot)componentInChildren.cashSlot).ItemInstance).Quantity < int.Parse(text)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Not enough cash to take."); } } List val = new List(); val.Add(text); ((ConsoleCommand)new ChangeCashCommand(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr))).Execute(val); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } }