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.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Actors.Enemies; using Assets.Scripts.Actors; using Assets.Scripts.Actors.Enemies; using Assets.Scripts.Actors.Player; using Assets.Scripts.Game.Spawning; using Assets.Scripts.Game.Spawning.New; using Assets.Scripts.Inventory__Items__Pickups; using Assets.Scripts.Inventory__Items__Pickups.Items; using Assets.Scripts.Inventory__Items__Pickups.Stats; using Assets.Scripts.Managers; using Assets.Scripts.Menu.Shop; using Assets.Scripts.Saves___Serialization.Progression.Achievements; using Assets.Scripts.Steam; using Assets.Scripts.Utility; using Assets.Scripts._Data.Tomes; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using ConnectorLib.JSON; using CrowdControl.Delegates.Effects; using CrowdControl.Delegates.Metadata; using CrowdControl.Utilities; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace CrowdControl { [BepInPlugin("WarpWorld.CrowdControl", "Crowd Control", "1.3.0")] public class CrowdControlMod : BasePlugin { [HarmonyPatch(typeof(PlayerInput), "FixedUpdate")] private class GameManager_Update { private static void Prefix() { Instance.Update_Impl(); } } [HarmonyPatch(typeof(PlayerHealth), "Damage")] public static class Patch_PlayerHealth_Damage { public static bool Prefix(PlayerHealth __instance, DamageContainer dc, bool ignoreShield) { return !godModeEnabled; } } [HarmonyPatch(typeof(PlayerHealth), "DamagePlayerExternal")] public static class Patch_PlayerHealth_DamagePlayerExternal { public static bool Prefix(ref float damage, PlayerHealth __instance) { return !godModeEnabled; } } [HarmonyPatch(typeof(TargetOfInterestPrefab), "Update")] public static class BossNamePatch { private static void Postfix(TargetOfInterestPrefab __instance) { if ((Object)(object)__instance.enemy != (Object)null && __instance.enemy.IsBoss()) { string name = ((Object)((Component)__instance.enemy).gameObject).name; if (name.StartsWith("CC_")) { string text = name.Substring(3); ((TMP_Text)__instance.t_name).text = text; } } } } public const string MOD_GUID = "WarpWorld.CrowdControl"; public const string MOD_DEVELOPER = "Warp World"; public const string MOD_NAME = "Crowd Control"; public const string MOD_VERSION = "1.3.0"; private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl"); private const float GAME_STATUS_UPDATE_INTERVAL = 1f; private float m_gameStatusUpdateTimer; public static int Preload; public static bool godModeEnabled; public static float DeltaTime => Time.fixedDeltaTime / Time.timeScale; public ManualLogSource Logger => ((BasePlugin)this).Log; 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 static void LogDebug(string message) { Instance.Logger.LogMessage((object)message); } public override void Load() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown Instance = this; ManualLogSource logger = Instance.Logger; bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("WarpWorld.CrowdControl"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Patching."); } logger.LogMessage(val); harmony.PatchAll(); Instance.Logger.LogMessage((object)"Initializing Crowd Control"); try { GameStateManager = new GameStateManager(this); Client = new NetworkClient(this); EffectLoader = new EffectLoader(this, Client); Scheduler = new Scheduler(this, Client); } catch (Exception ex) { ManualLogSource logger2 = Instance.Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Crowd Control Init Error: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } logger2.LogError(val2); } Instance.Logger.LogMessage((object)"Crowd Control Initialized"); } private void Update_Impl() { if (GameStateManager != null && Client != null) { if (Input.GetKeyDown((KeyCode)287)) { EffectAnnouncer.AnnounceSystem(EffectAnnouncer.ToggleMessages() ? "Effect messages enabled." : "Effect messages disabled."); } m_gameStatusUpdateTimer += Time.fixedDeltaTime; if (m_gameStatusUpdateTimer >= 1f) { GameStateManager.UpdateGameState(); m_gameStatusUpdateTimer = 0f; } Scheduler?.Tick(); } } } public static class CrowdControlProcess { private const bool PROCESS_LOOKUP_FALLBACK = true; public static bool IsCrowdControlRunning() { if (!IsCrowdControlSemaphorePresent()) { return IsCrowdControlProcessRunning(); } return true; } private static bool IsCrowdControlSemaphorePresent() { Semaphore result; return Semaphore.TryOpenExisting("CrowdControl", out result); } private static bool IsCrowdControlProcessRunning() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown checked { bool flag2 = default(bool); try { Process[] processes = Process.GetProcesses(); int num = 0; int num2 = 0; Process[] array = processes; bool flag = default(bool); foreach (Process process in array) { try { if (process.ProcessName.IndexOf("crowdcontrol", StringComparison.OrdinalIgnoreCase) >= 0) { ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(36, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found CrowdControl process: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(process.ProcessName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (PID: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(process.Id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogMessage(val); flag = true; return flag; } num++; } catch (UnauthorizedAccessException) { num2++; } catch (Exception ex2) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(26, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not access process: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex2.Message); } logger2.LogMessage(val); num2++; } } if (num2 > 0) { ManualLogSource logger3 = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(105, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" inaccessible processes (possibly running with different privileges). Attempting connection anyway."); } logger3.LogMessage(val); return true; } return false; } catch (Exception ex3) { ManualLogSource logger4 = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(43, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error checking for CrowdControl processes: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex3.Message); } logger4.LogMessage(val); return true; } } } } public class DelimitedStreamReader : IDisposable { private readonly MemoryStream _memory_stream = new MemoryStream(); private readonly NetworkStream m_stream; public DelimitedStreamReader(NetworkStream stream) { m_stream = stream; } ~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 = m_stream.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 { private enum EffectType { Enable, Disable } private readonly Dictionary _currentAbilities = new Dictionary(); private readonly Dictionary _lastKnownAbilities = new Dictionary(); private bool _abilitiesInitialized; private readonly Dictionary _effectToAbilityMap = new Dictionary(); private readonly HashSet _activeEffects = new HashSet(); private GameState? _last_game_state; private readonly CrowdControlMod m_mod; public bool IsActiveInConversation { get; set; } 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) try { if (!Application.isFocused) { return (GameState)(-7); } MyPlayer instance = MyPlayer.Instance; if ((Object)(object)instance == (Object)null) { return (GameState)(-8); } GameManager instance2 = GameManager.Instance; if ((Object)(object)instance2 == (Object)null) { return (GameState)(-8); } if (!instance2.isPlaying) { return (GameState)(-13); } if (instance2.IsTimeFreeze()) { return (GameState)(-6); } if (instance2.cutscene) { return (GameState)(-11); } bool flag = false; try { flag = instance.IsDead(); } catch { flag = true; } if (flag) { return (GameState)(-12); } if (instance2.isGameOver) { return (GameState)(-12); } if (instance.isTeleporting) { return (GameState)(-12); } if (!((Behaviour)instance).isActiveAndEnabled) { return (GameState)(-12); } UiManager instance3 = UiManager.Instance; PauseUi val = ((instance3 != null) ? instance3.pause : null); bool num = (Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled; ChestWindowUi val2 = Object.FindObjectOfType(); bool flag2 = (Object)(object)val2 != (Object)null && (Object)(object)val2.window != (Object)null && ((Component)val2.window).gameObject.activeInHierarchy; LevelupScreen val3 = Object.FindObjectOfType(); bool flag3 = ((Object)(object)val3 != (Object)null && (Object)(object)val3.window != (Object)null && val3.window.activeInHierarchy) || LevelupScreen.isLevelingUp; bool paused = MyTime.paused; if (num || flag2 || flag3 || paused) { return (GameState)(-7); } return (GameState)1; } catch (Exception ex) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag4 = default(bool); BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(24, 1, ref flag4); if (flag4) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("GameStateManager Error: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex); } logger.LogError(val4); return (GameState)(-1); } } public void OnEffectStarted(string effectId) { } public void OnEffectStopped(string effectId) { } [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 GameStateManager(CrowdControlMod mod) { m_mod = mod; } 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 m_mod.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 bool m_hasLoggedNoProcessFound; private readonly Thread m_readLoop; private readonly Thread m_maintenanceLoop; private static readonly SITimeSpan TIMEOUT_NO_PROCESS = 5.0; 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) { if (!CrowdControlProcess.IsCrowdControlRunning()) { CrowdControlMod.Instance.Logger.LogMessage((object)"No CrowdControl process found, skipping connection attempt..."); Thread.Sleep((TimeSpan)TIMEOUT_NO_PROCESS); continue; } m_hasLoggedNoProcessFound = false; CrowdControlMod.Instance.Logger.LogMessage((object)"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.Instance.Logger.LogMessage((object)"Failed to connect to Crowd Control"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); CrowdControlMod.Instance.Logger.LogError((object)"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.Instance.Logger.LogError((object)ex); } Thread.Sleep(2000); } } private void ClientLoop() { m_streamReader = new DelimitedStreamReader(m_client.GetStream()); CrowdControlMod.Instance.Logger.LogMessage((object)"Connected to Crowd Control"); try { while (!m_quitting.IsCancellationRequested) { string text = m_streamReader.ReadUntilNullTerminator(); OnMessage(text.Trim()); } } catch (EndOfStreamException) { CrowdControlMod.Instance.Logger.LogMessage((object)"Disconnected from Crowd Control"); m_client?.Close(); } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((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.Instance.Logger.LogError((object)ex); } } public bool Send(SimpleJSONResponse response) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown try { if (response == null) { return false; } if (!Connected) { return false; } byte[] array = Encoding.UTF8.GetBytes(((SimpleJSONMessage)response).Serialize()).Concat(new byte[1]).ToArray(); m_client.GetStream().Write(array, 0, array.Length); return true; } catch (Exception ex) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error sending a message to the Crowd Control client: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } logger.LogError(val); return false; } } public Task SendAsync(SimpleJSONResponse response) { return Task.Run(() => Send(response)); } 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) { return Task.Run(delegate { Stop(message); }); } public bool KeepAlive() { return Send((SimpleJSONResponse)(object)KEEPALIVE); } public Task KeepAliveAsync() { return Task.Run((Func)KeepAlive); } public void AttachMetadata(EffectResponse response) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown response.metadata = new Dictionary(); string[] commonMetadata = MetadataDelegates.CommonMetadata; bool flag = default(bool); foreach (string text in commonMetadata) { if (MetadataLoader.Metadata.TryGetValue(text, out var value)) { response.metadata.Add(text, value(m_mod)); continue; } ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(62, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Metadata delegate \""); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" could not be found. Available delegates: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(string.Join(", ", MetadataLoader.Metadata.Keys)); } logger.LogError(val); } } 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(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(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(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(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(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(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(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(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 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 TimedEffectState.EffectState.NotStarted: if (m_enumerator == null) { m_enumerator = TimedEffectState.Start(); } m_enumerator.MoveNext(); return true; case TimedEffectState.EffectState.Running: case TimedEffectState.EffectState.Paused: if (m_enumerator == null) { m_enumerator = TimedEffectState.Tick(); } m_enumerator.MoveNext(); return true; default: return false; } } public void Pause() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue && effectState.GetValueOrDefault() == 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() == 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 = new ConcurrentQueue(); private readonly ConcurrentDictionary m_runningEffects = new ConcurrentDictionary(); public Scheduler(CrowdControlMod mod, NetworkClient networkClient) { m_mod = mod; m_networkClient = networkClient; } public bool IsRunning(string id) { foreach (TimedEffectState item in m_runningEffects.Select((KeyValuePair p) => p.Value.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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: 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)(object)EffectResponse.Unavailable(((SimpleJSONRequest)val5).id, "Unknown effect.")); CrowdControlMod.Instance.Logger.LogError((object)"Unknown effect."); } else { m_networkClient.Send((SimpleJSONResponse)new EffectResponse(((SimpleJSONRequest)val5).id, (EffectStatus)((!m_mod.GameStateManager.IsReady(val5.code)) ? 1 : 0))); } } break; } case 1: { EffectRequest val3 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val3 == null) { break; } EffectRequest val4 = val3; if (val4.code == null) { val4.code = string.Empty; } if (!m_mod.EffectLoader.Effects.TryGetValue(val3.code, out var value2)) { m_networkClient.Send((SimpleJSONResponse)(object)EffectResponse.Unavailable(((SimpleJSONRequest)val3).id, "Unknown effect.")); CrowdControlMod.Instance.Logger.LogError((object)"Unknown effect."); break; } if (value2.IsTimed) { foreach (string conflict in value2.EffectAttribute.Conflicts) { if (IsRunning(conflict)) { m_networkClient.Send((SimpleJSONResponse)new EffectResponse(((SimpleJSONRequest)val3).id, (EffectStatus)3)); return; } } } 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 var value)) { m_networkClient.Send((SimpleJSONResponse)(object)EffectResponse.Failure(((SimpleJSONRequest)val2).id, "Effect already finished.")); CrowdControlMod.Instance.Logger.LogError((object)"Effect already finished."); } 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) 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)).Forget(); continue; } if (result.TimedEffectState != null) { m_runningEffects.TryAdd(((SimpleJSONRequest)result.Request).id, result); continue; } EffectResponse val; try { val = result.Effect.Start(result.Request); } catch (Exception ex) { val = EffectResponse.Failure(((SimpleJSONRequest)result.Request).id, "Exception thrown."); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); } if (val != null && (int)val.status == 0) { EffectAnnouncer.AnnounceEffect(result.Request); } m_networkClient.AttachMetadata(val); m_networkClient.SendAsync((SimpleJSONResponse)(object)val).Forget(); } ConsumeEnumerators(); } private void ConsumeEnumerators() { foreach (KeyValuePair runningEffect in m_runningEffects) { if (!runningEffect.Value.MoveNext()) { m_runningEffects.TryRemove(runningEffect.Key, out var _); } } } } internal static class Settings { private static readonly Regex OPTION_LINE; public static bool AllowAchievements { get; set; } public static bool AllowStats { get; set; } static Settings() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown AllowAchievements = false; AllowStats = false; OPTION_LINE = new Regex("^\\s*(?\\S+)\\s*=\\s*(?\\S)(;|\\s*).*$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CrowdControl.cfg"); if (!File.Exists(text)) { return; } CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { ManualLogSource logger = instance.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loading Crowd Control mod settings from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); } logger.LogInfo(val); } string[] array = File.ReadAllLines(text); foreach (string text2 in array) { if (string.IsNullOrWhiteSpace(text2)) { continue; } Match match = OPTION_LINE.Match(text2); if (!match.Success) { continue; } string value = match.Groups["key"].Value; string value2 = match.Groups["value"].Value; string text3 = value.ToLowerInvariant(); if (!(text3 == "allowachievements")) { if (text3 == "allowstats") { bool result = (AllowStats = (bool.TryParse(value2, out result) ? result : AllowStats)); } } else { bool result2 = (AllowAchievements = (bool.TryParse(value2, out result2) ? result2 : AllowAchievements)); } } } catch { } } } [Serializable] 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.Instance.Logger.LogError((object)ex); } } public static async void Forget(this Task task, bool silent) { try { await task.ConfigureAwait(continueOnCapturedContext: false); } catch (Exception ex) { if (!silent) { CrowdControlMod.Instance.Logger.LogError((object)ex); } } } } } namespace CrowdControl.Utilities { internal static class EffectRequestHelper { public static int GetQuantity(EffectRequest request) { if (request == null) { return 0; } if (request.quantity.HasValue && request.quantity.Value != 0) { uint value = request.quantity.Value; if (value <= int.MaxValue) { return checked((int)value); } return int.MaxValue; } return ParseQuantityFromParameters(GetParameters(request)); } private static JToken GetParameters(EffectRequest request) { if (request == null) { return null; } try { return request.parameters; } catch { return null; } } private static int ParseQuantityFromParameters(JToken parameters) { if (parameters == null) { return 0; } JValue val = (JValue)(object)((parameters is JValue) ? parameters : null); if (val != null) { return ParseJValue(val); } JObject val2 = (JObject)(object)((parameters is JObject) ? parameters : null); if (val2 != null) { string[] array = new string[3] { "quantity", "value", "amount" }; JToken val3 = default(JToken); foreach (string text in array) { if (val2.TryGetValue(text, ref val3) && val3 != null) { int num = ParseQuantityFromParameters(val3); if (num != 0) { return num; } } } } return 0; } private static int ParseJValue(JValue value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 JTokenType type = ((JToken)value).Type; if ((int)type != 6) { if ((int)type == 7) { return Mathf.RoundToInt(Convert.ToSingle(value.Value)); } return 0; } return ClampToInt(Convert.ToInt64(value.Value)); } private static int ClampToInt(long value) { if (value > int.MaxValue) { return int.MaxValue; } if (value < int.MinValue) { return int.MinValue; } return checked((int)value); } } internal static class EnemySpawnHelper { public static readonly EEnemy[] DefaultRegularEnemies; public static readonly EEnemy[] DefaultSwarmEnemies; public static readonly EEnemy[] DefaultBossEnemies; public static bool IsBoss(EEnemy type) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between I4 and Unknown for (int i = 0; i < DefaultBossEnemies.Length; i = checked(i + 1)) { if ((int)DefaultBossEnemies[i] == (int)type) { return true; } } return false; } public static Enemy SpawnWithFallback(EnemyManager manager, Vector3 position, EEnemy preferred, EEnemyFlag flag = 0, EEnemy[] fallbackPool = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_00b3: Expected O, but got Unknown //IL_0038: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)manager == (Object)null) { return null; } EEnemy[] array = BuildCandidateList(preferred, fallbackPool ?? DefaultRegularEnemies); bool flag2 = default(bool); foreach (EEnemy val in array) { Enemy val2 = TrySpawn(manager, val, position, flag); if ((Object)(object)val2 == (Object)null) { continue; } if (val != preferred) { ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val3 = new BepInExMessageLogInterpolatedStringHandler(33, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Spawned "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" instead of unavailable "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(preferred); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } logger.LogMessage(val3); } return val2; } ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Could not spawn "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(preferred); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" or any fallback enemy."); } logger2.LogError(val4); return null; } public static Enemy Spawn(EnemyManager manager, EEnemy type, Vector3 position, EEnemyFlag flag = 0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected I4, but got Unknown return SpawnWithFallback(manager, position, type, flag, (EEnemy[])(object)new EEnemy[1] { (EEnemy)(int)type }); } private static EEnemy[] BuildCandidateList(EEnemy preferred, EEnemy[] fallbackPool) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) List list; HashSet seen; checked { list = new List(fallbackPool.Length + 1); seen = new HashSet(); Add(preferred); int[] array = new int[fallbackPool.Length]; for (int i = 0; i < array.Length; i++) { array[i] = i; } for (int num = array.Length - 1; num > 0; num--) { int num2 = Random.Range(0, num + 1); ref int reference = ref array[num]; ref int reference2 = ref array[num2]; int num3 = array[num2]; int num4 = array[num]; reference = num3; reference2 = num4; } for (int j = 0; j < array.Length; j++) { Add(fallbackPool[array[j]]); } return list.ToArray(); } void Add(EEnemy type) { //IL_0006: 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) if (seen.Add(type)) { list.Add(type); } } } private static Enemy TrySpawn(EnemyManager manager, EEnemy type, Vector3 position, EEnemyFlag flag) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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 (!manager.CanSpawnEnemy()) { return null; } DataManager instance = DataManager.Instance; if ((Object)(object)instance == (Object)null) { return null; } EnemyData enemyData = instance.GetEnemyData(type); if ((Object)(object)enemyData == (Object)null) { return null; } EEnemyFlag val = ResolveSpawnFlag(type, flag); int waveNumber = GetWaveNumber(manager); return manager.SpawnEnemy(enemyData, position, waveNumber, true, val, true, 1f); } catch (Exception ex) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag2 = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(19, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Spawn failed for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(type); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } logger.LogError(val2); return null; } } private static EEnemyFlag ResolveSpawnFlag(EEnemy type, EEnemyFlag flag) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if ((int)flag != 0) { return flag; } if (IsBoss(type)) { return (EEnemyFlag)2; } return (EEnemyFlag)0; } private static int GetWaveNumber(EnemyManager manager) { SummonerController summonerController = manager.summonerController; if (summonerController != null) { if (summonerController.currentTimelineEvent > 0) { return summonerController.currentTimelineEvent; } if (summonerController.id > 0) { return summonerController.id; } } int num = 0; Dictionary enemies = manager.enemies; if (enemies != null) { Enumerator enumerator = enemies.GetEnumerator(); while (enumerator.MoveNext()) { Enemy value = enumerator.Current.Value; if ((Object)(object)value != (Object)null && value.waveNumber > num) { num = value.waveNumber; } } } if (num <= 0) { return 1; } return num; } static EnemySpawnHelper() { EEnemy[] array = new EEnemy[15]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); DefaultRegularEnemies = (EEnemy[])(object)array; EEnemy[] array2 = new EEnemy[13]; RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); DefaultSwarmEnemies = (EEnemy[])(object)array2; EEnemy[] array3 = new EEnemy[7]; RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); DefaultBossEnemies = (EEnemy[])(object)array3; } } public static class GameStateChecker { public static bool IsTransitioning { get { MyPlayer instance = MyPlayer.Instance; if (instance == null) { return false; } return instance.isTeleporting; } } public static bool IsDead { get { MyPlayer instance = MyPlayer.Instance; if (instance == null) { return false; } return instance.IsDead(); } } public static bool IsGameSaving => false; public static bool IsPaused => MyTime.paused; public static bool IsInCutsceneMovement => false; public static bool IsTriggerEventsPaused => false; public static bool IsAttacking { get { _ = (Object)(object)MyPlayer.Instance == (Object)null; return false; } } public static bool IsReady => !ShouldPauseEffects; public static bool ShouldPauseEffects { get { if (!IsTransitioning && !IsDead && !IsPaused && !IsInCutsceneMovement && !IsTriggerEventsPaused && !IsGameSaving) { return !Application.isFocused; } return true; } } private static bool IsInMenuOrUIState() { return false; } public static bool ShouldDisableEffects() { return IsDead; } public static string GetGameStateDebugInfo() { if ((Object)(object)MyPlayer.Instance == (Object)null) { return "HeroController not found"; } List list = new List(); if (IsTransitioning) { list.Add("Transitioning"); } if (IsDead) { list.Add("Dead"); } if (IsPaused) { list.Add("Paused"); } if (IsInCutsceneMovement) { list.Add("CutsceneMovement"); } if (IsTriggerEventsPaused) { list.Add("TriggerEventsPaused"); } if (list.Count <= 0) { return "Normal"; } return string.Join(", ", list); } } } namespace CrowdControl.Harmony { public static class LeaderboardsPatch { private static bool _messageShown; public static bool Prefix() { if (!_messageShown) { CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { instance.Logger.LogMessage((object)"LEADERBOARD FUNCTIONS BLOCKED - CrowdControl is active"); } _messageShown = true; } return false; } } [HarmonyPatch(typeof(Leaderboards), "UploadScore")] public static class Leaderboards_UploadScore { public static bool Prefix() { return LeaderboardsPatch.Prefix(); } } [HarmonyPatch(typeof(Leaderboards), "CanShowScore")] public static class Leaderboards_CanShowScore { public static bool Prefix() { return LeaderboardsPatch.Prefix(); } } [HarmonyPatch(typeof(LeaderboardUiNew), "OnLeaderboardReady")] public static class LeaderboardUiNew_OnLeaderboardReady { public static bool Prefix() { return LeaderboardsPatch.Prefix(); } } [HarmonyPatch(typeof(LeaderboardUiNew), "Start")] public static class LeaderboardUiNew_Start { public static bool Prefix() { return LeaderboardsPatch.Prefix(); } } [HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "UploadLeaderboardScore")] public static class SteamLeaderboardsManagerNew_UploadLeaderboardScore { public static bool Prefix() { return LeaderboardsPatch.Prefix(); } } [HarmonyPatch(typeof(SteamLeaderboardsManagerNew), "DownloadLeaderboardEntries")] public static class SteamLeaderboardsManagerNew_DownloadLeaderboardEntries { public static bool Prefix() { return LeaderboardsPatch.Prefix(); } } public static class SteamAchievementsManagerPatch { private static bool _messageShown; public static bool Prefix() { if (!_messageShown) { CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { instance.Logger.LogMessage((object)"ACHIEVEMENT UNLOCKING BLOCKED - CrowdControl is active"); } _messageShown = true; } return false; } } [HarmonyPatch(typeof(SteamAchievementsManager), "TryUploadAchievements")] public static class SteamAchievementsManager_TryUploadAchievements { public static bool Prepare() { return !Settings.AllowAchievements; } public static bool Prefix() { return SteamAchievementsManagerPatch.Prefix(); } } [HarmonyPatch(typeof(SteamAchievementsManager), "TryUnlockAchievement")] public static class SteamAchievementsManager_TryUnlockAchievement { public static bool Prepare() { return !Settings.AllowAchievements; } public static bool Prefix() { return SteamAchievementsManagerPatch.Prefix(); } } public static class SteamStatsManagerPatch { private static bool _messageShown; public static bool Prefix() { if (!_messageShown) { CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { instance.Logger.LogMessage((object)"STATS UPLOAD BLOCKED - CrowdControl is active"); } _messageShown = true; } return false; } } [HarmonyPatch(typeof(SteamStatsManager), "TryUploadStats")] public static class SteamStatsManager_TryUploadStats { public static bool Prepare() { return !Settings.AllowStats; } public static bool Prefix() { return SteamStatsManagerPatch.Prefix(); } } } namespace CrowdControl.Delegates.Metadata { [AttributeUsage(AttributeTargets.Method)] public class MetadataAttribute : Attribute { public string[] IDs { get; } public MetadataAttribute(string ids) : this(new string[1] { ids }) { } public MetadataAttribute(IEnumerable ids) : this(ids.Select((string id) => id).ToArray()) { } public MetadataAttribute(params string[] ids) { IDs = ids; } } 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) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown try { return DataResponse.Success("levelTime", (object)0); } catch (Exception ex) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Crowd Control Error: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); } logger.LogError(val); 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.Instance.Logger.LogError((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 EffectResponse.Paused(((SimpleJSONMessage)request).ID, (string)null); } public virtual EffectResponse Resume(EffectRequest request) { return EffectResponse.Resumed(((SimpleJSONMessage)request).ID, (string)null); } public virtual EffectResponse Stop(EffectRequest request) { return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } } internal static class EffectAnnouncer { private static readonly HashSet AnnouncedRequests = new HashSet(); public static bool MessagesEnabled { get; private set; } = true; public static void Announce(string message, float feedDuration = 3f, Texture icon = null, bool force = false) { if (string.IsNullOrWhiteSpace(message) || (!force && !MessagesEnabled)) { return; } try { Chatbox instance = Chatbox.Instance; if (instance != null) { instance.AppendMessage((EChatUserType)0, message); } } catch { } try { UiManager instance2 = UiManager.Instance; if (instance2 != null) { ServerFeed feed = instance2.feed; if (feed != null) { feed.SetFeed(message, feedDuration, icon); } } } catch { } } public static void AnnounceEffect(EffectRequest request) { if (request != null && TryMarkAnnounced(((SimpleJSONRequest)request).id)) { string text = request.message; if (string.IsNullOrWhiteSpace(text) || string.Equals(text, request.code, StringComparison.OrdinalIgnoreCase)) { text = BuildEffectMessage(request); } if (string.IsNullOrWhiteSpace(text)) { text = "An effect was triggered."; } Announce(text); } } public static void AnnounceCustom(EffectRequest request, string message, float feedDuration = 3f, Texture icon = null) { if (request != null) { TryMarkAnnounced(((SimpleJSONRequest)request).id); } Announce(message, feedDuration, icon); } public static bool ToggleMessages() { MessagesEnabled = !MessagesEnabled; return MessagesEnabled; } public static void AnnounceSystem(string message) { Announce(message, 3f, null, force: true); } private static bool TryMarkAnnounced(uint id) { if (AnnouncedRequests.Contains(id)) { return false; } AnnouncedRequests.Add(id); return true; } private static string BuildEffectMessage(EffectRequest request) { string text = request.code ?? string.Empty; if (string.IsNullOrWhiteSpace(text)) { return string.Empty; } if (text.StartsWith("spawnItem_", StringComparison.OrdinalIgnoreCase)) { return "Spawned " + Humanize(text.Substring("spawnItem_".Length)) + "."; } if (string.Equals(text, "spawnItem", StringComparison.OrdinalIgnoreCase)) { return "Spawned a random item."; } if (text.StartsWith("spawnEnemy_", StringComparison.OrdinalIgnoreCase)) { return "Spawned " + Humanize(text.Substring("spawnEnemy_".Length)) + "."; } if (string.Equals(text, "spawnEnemy", StringComparison.OrdinalIgnoreCase)) { return "Spawned a random enemy."; } if (string.Equals(text, "spawnEnemySwarm", StringComparison.OrdinalIgnoreCase)) { return "A swarm of enemies appears!"; } if (string.Equals(text, "spawnBoss", StringComparison.OrdinalIgnoreCase)) { return "A boss has appeared!"; } if (text.StartsWith("addTome_", StringComparison.OrdinalIgnoreCase)) { return "Gave Tome: " + Humanize(text.Substring("addTome_".Length)) + "."; } if (text.StartsWith("playerStatus_", StringComparison.OrdinalIgnoreCase)) { string text2 = text.Substring("playerStatus_".Length); if (text2.EndsWith("Player", StringComparison.OrdinalIgnoreCase)) { text2 = text2.Substring(0, checked(text2.Length - "Player".Length)); } return "Applied " + Humanize(text2) + "."; } return text switch { "goldUp" => BuildQuantityMessage("Gave", "gold", request), "goldDown" => BuildQuantityMessage("Took", "gold", request), "addXP" => BuildQuantityMessage("Gave", "XP", request), "addLevel" => "Gained a level!", "healPlayer" => "Healed the player to full!", "teleportPlayer" => "Teleported the player!", "despawnEnemies" => "Enemies destroyed!", "spawnChest" => "Spawned a chest!", "invulnerable" => "Player is invulnerable!", "slowTime" => "Time slowed!", "speedUpTime" => "Time sped up!", "giantPlayer" => "The player has grown!", "tinyPlayer" => "The player has been shrunk!", "giantEnemies" => "Make my monster grow!!", "tinyEnemies" => "Enemies have been shrunk!", _ => "An effect was triggered.", }; } private static string BuildQuantityMessage(string verb, string unit, EffectRequest request) { int num = ResolveQuantity(request); if (num == 0) { return verb + " " + unit + "."; } if (num < 0) { num = Math.Abs(num); } return $"{verb} {num} {unit}."; } private static int ResolveQuantity(EffectRequest request) { return EffectRequestHelper.GetQuantity(request); } private static string Humanize(string value) { if (string.IsNullOrWhiteSpace(value)) { return value; } string text = value.Replace('_', ' ').Trim(); checked { List list = new List(text.Length * 2); for (int i = 0; i < text.Length; i++) { char c = text[i]; if (i > 0) { char c2 = text[i - 1]; bool flag = char.IsUpper(c) && (char.IsLower(c2) || char.IsDigit(c2)); if (!flag && char.IsDigit(c) && char.IsLetter(c2)) { flag = true; } if (flag) { list.Add(' '); } } list.Add(c); } return new string(list.ToArray()).Replace("Xp", "XP").Replace("Hp", "HP").Trim(); } } } [AttributeUsage(AttributeTargets.Class)] public class EffectAttribute : Attribute { public IReadOnlyList IDs { get; } public SITimeSpan DefaultDuration { get; } public IReadOnlyList Conflicts { get; } public EffectAttribute(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 EffectAttribute(string[] ids, SITimeSpan defaultDuration, string[] conflicts) { IDs = ids; DefaultDuration = defaultDuration; Conflicts = conflicts; } } 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.Instance.Logger.LogError((object)ex); } } } } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((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, "Exception thrown."); CrowdControlMod.Instance.Logger.LogError((object)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, "Exception thrown."); CrowdControlMod.Instance.Logger.LogError((object)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, "Exception thrown."); CrowdControlMod.Instance.Logger.LogError((object)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() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); EffectResponse obj = 5__2; if (obj != null && (int)obj.status == 0) { EffectAnnouncer.AnnounceEffect(timedEffectState.Request); } 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) ?? EffectResponse.Finished(((SimpleJSONRequest)timedEffectState.Request).id, (string)null); timedEffectState.State = EffectState.Finished; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, "Exception thrown."); CrowdControlMod.Instance.Logger.LogError((object)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; private static readonly IEnumerator EMPTY_ENUMERATOR = Enumerable.Empty().GetEnumerator(); 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 }; } public IEnumerator Tick() { EffectResponse val = null; bool flag = false; try { if (!(flag = TryGetLock())) { return EMPTY_ENUMERATOR; } switch (State) { case EffectState.Running: if (GameStateChecker.ShouldPauseEffects) { return Pause(); } try { if (TimeRemaining > 0.0) { Effect.Tick(Request); TimeRemaining -= (double)CrowdControlMod.DeltaTime; } else { val = Effect.Stop(Request) ?? EffectResponse.Finished(((SimpleJSONRequest)Request).id, (string)null); State = EffectState.Finished; TimeRemaining = SITimeSpan.Zero; } } catch (Exception ex) { val = EffectResponse.Failure(((SimpleJSONRequest)Request).id, "Exception thrown."); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); State = EffectState.Errored; } break; case EffectState.Paused: if (!GameStateChecker.ShouldPauseEffects) { return Resume(); } break; } return EMPTY_ENUMERATOR; } finally { if (flag) { ReleaseLock(); if (val != null) { Client.Send((SimpleJSONResponse)(object)val); } } } } } } namespace CrowdControl.Delegates.Effects.Implementations { [Effect("addLevel")] public class AddLevel : Effect { public AddLevel(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { if (MyPlayer.Instance == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (string)null); } MyPlayer.Instance.inventory.AddLevel(); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "goldUp", "goldDown" })] public class AddRemoveGold : Effect { public AddRemoveGold(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { MyPlayer instance = MyPlayer.Instance; PlayerInventory val = ((instance != null) ? instance.inventory : null); if (val == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (string)null); } int num = ResolveQuantity(request); if (num == 0) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (string)null); } if (string.Equals("goldDown", request.code, StringComparison.OrdinalIgnoreCase)) { num = checked(num * -1); } val.ChangeGold(num); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private static int ResolveQuantity(EffectRequest request) { return EffectRequestHelper.GetQuantity(request); } } [Effect(new string[] { "addTome_Damage", "addTome_Agility", "addTome_Cooldown", "addTome_Quantity", "addTome_Knockback", "addTome_Armor", "addTome_Health", "addTome_Regeneration", "addTome_Size", "addTome_ProjectileSpeed", "addTome_Duration", "addTome_Evasion", "addTome_Attraction", "addTome_Luck", "addTome_Xp", "addTome_Golden", "addTome_Precision", "addTome_Shield", "addTome_Blood", "addTome_Thorns", "addTome_Bounce", "addTome_Cursed", "addTome_Silver", "addTome_Balance", "addTome_Chaos", "addTome_Gambler", "addTome_Hoarder" })] public class TomeAddEffect : Effect { public TomeAddEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_00b7: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) bool flag2 = default(bool); try { string[] array = (request.code ?? string.Empty).Split('_'); if (array.Length != 2 || !array[0].Equals("addTome", StringComparison.OrdinalIgnoreCase)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Invalid effect code."); } string text = array[1]; if (!Enum.TryParse(text, ignoreCase: true, out ETome result)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unknown tome '" + text + "'."); } MyPlayer instance = MyPlayer.Instance; object obj; if (instance == null) { obj = null; } else { PlayerInventory inventory = instance.inventory; obj = ((inventory != null) ? inventory.tomeInventory : null); } TomeInventory val = (TomeInventory)obj; if ((Object)(object)instance == (Object)null || val == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player or tome inventory not available."); } TomeData val2 = FindTomeData(result); if ((Object)(object)val2 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, $"TomeData not found for '{result}'."); } bool flag = val.HasTome(result); BepInExMessageLogInterpolatedStringHandler val3; if (!flag && val.IsMaxed()) { ManualLogSource logger = CrowdControlMod.Instance.Logger; val3 = new BepInExMessageLogInterpolatedStringHandler(61, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Cannot add tome '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(result); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' because tome inventory is at max capacity."); } logger.LogMessage(val3); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Tome inventory is already full."); } if (flag && val.IsMaxLevel(result)) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; val3 = new BepInExMessageLogInterpolatedStringHandler(26, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Tome '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(result); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' already maxed out."); } logger2.LogMessage(val3); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, $"'{result}' is already max level."); } ERarity randomRarity = GetRandomRarity(); List upgradeOffer = val2.GetUpgradeOffer(randomRarity); val.AddTome(val2, upgradeOffer, randomRarity); ManualLogSource logger3 = CrowdControlMod.Instance.Logger; val3 = new BepInExMessageLogInterpolatedStringHandler(32, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Added/Upgraded tome '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(result); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("', rarity "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(randomRarity); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } logger3.LogMessage(val3); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { ManualLogSource logger4 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("TomeAddEffect error: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex); } logger4.LogError(val4); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, ex.Message); } } private static TomeData FindTomeData(ETome target) { //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_003b: Unknown result type (might be due to invalid IL or missing references) Il2CppReferenceArray val = Resources.FindObjectsOfTypeAll(Il2CppType.Of()); if (val == null || ((Il2CppArrayBase)(object)val).Length == 0) { return null; } for (int i = 0; i < ((Il2CppArrayBase)(object)val).Length; i = checked(i + 1)) { TomeData val2 = ((Il2CppObjectBase)((Il2CppArrayBase)(object)val)[i]).TryCast(); if ((Object)(object)val2 != (Object)null) { ETome eTome = val2.eTome; if (((object)(ETome)(ref eTome)).Equals((object?)target)) { return val2; } } } return null; } private static ERarity GetRandomRarity() { ERarity[] array = new ERarity[6]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); ERarity[] array2 = (ERarity[])(object)array; int num = Random.Range(0, array2.Length); return array2[num]; } } [Effect("addXP")] public class AddXP : Effect { public AddXP(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { if (MyPlayer.Instance == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (string)null); } float num = ((float?)request.quantity) ?? 0f; if (num == 0f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (string)null); } int num2 = Mathf.RoundToInt(num); MyPlayer.Instance.inventory.AddXp(num2); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } internal static class DespawnConfig { public const float DefaultRadius = 35f; public const float MinRadius = 4f; public const float MaxRadius = 35f; public static float ResolveRadius(float? quantity) { if (quantity.HasValue && quantity.Value > 0f) { return Mathf.Clamp(quantity.Value, 4f, 35f); } return 35f; } } [Effect("despawnEnemies")] public class DespawnEnemies : Effect { private const float BigDamage = 999999f; private const float RingDuration = 1f; private const float RingThickness = 4.25f; private const int RingSegments = 128; private static readonly Color RingColor = new Color(1f, 0.25f, 0.05f, 0.9f); private const float RingYOffset = 0.25f; public DespawnEnemies(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown EnemyManager instance = EnemyManager.Instance; if ((Object)(object)instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "EnemyManager not found."); } Dictionary enemies = instance.enemies; if (enemies == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No enemies list available."); } MyPlayer instance2 = MyPlayer.Instance; GameObject val = ((instance2 != null) ? ((Component)instance2).gameObject : null); if ((Object)(object)val == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } float num = DespawnConfig.ResolveRadius(request.quantity); VisualHelpers.BuildSolidRingMesh(val.transform, num, 4.25f, 128, RingColor, 0.25f, 1f); Vector3 position = val.transform.position; List list = new List(); Enumerator enumerator = enemies.GetEnumerator(); while (enumerator.MoveNext()) { Enemy value = enumerator.Current.Value; if (!((Object)(object)value == (Object)null) && !((Object)(object)((Component)value).gameObject == (Object)null) && ((Component)value).gameObject.activeInHierarchy && Vector3.Distance(((Component)value).transform.position, position) <= num) { list.Add(value); } } bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val2; if (list.Count == 0) { ManualLogSource logger = CrowdControlMod.Instance.Logger; val2 = new BepInExMessageLogInterpolatedStringHandler(58, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("despawnEnemies: no enemies within "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("m (succeeding silently)."); } logger.LogMessage(val2); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } int num2 = 0; foreach (Enemy item in list) { if (TryKillEnemy(item)) { num2 = checked(num2 + 1); } } ManualLogSource logger2 = CrowdControlMod.Instance.Logger; val2 = new BepInExMessageLogInterpolatedStringHandler(45, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("despawnEnemies: attempted "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", killed "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" within "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num, "0.#"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("m."); } logger2.LogMessage(val2); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private static bool TryKillEnemy(Enemy enemy) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown if ((Object)(object)enemy == (Object)null || (Object)(object)((Component)enemy).gameObject == (Object)null) { return false; } GameObject gameObject = ((Component)enemy).gameObject; enemy.Kill("CrowdControl"); if (!gameObject.activeInHierarchy) { return true; } if (enemy.CanTakeDamage()) { DamageContainer val = new DamageContainer(0f, "CrowdControl") { damage = 999999f, isExecute = true }; enemy.DamageExternal(val); } if (!gameObject.activeInHierarchy) { return true; } enemy.DiedNextFrame(); return !gameObject.activeInHierarchy; } } internal static class VisualHelpers { public static void BuildSolidRingMesh(Transform anchor, float radius, float thickness, int segments, Color color, float yOffset, float lifetime) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown if (!((Object)(object)anchor == (Object)null) && !(radius <= 0f) && segments >= 12) { float num = Mathf.Max(0.01f, radius - Mathf.Abs(thickness) * 2f); float outerR = num + Mathf.Abs(thickness); GameObject val = new GameObject("CC_SolidRing"); val.transform.SetParent(anchor, false); val.transform.localPosition = new Vector3(0f, yOffset, 0f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; MeshFilter val2 = val.AddComponent(); MeshRenderer obj = val.AddComponent(); Material val3 = new Material(Shader.Find("Standard") ?? Shader.Find("Diffuse")); val3.color = color; ((Renderer)obj).material = val3; val2.mesh = BuildRingMesh(num, outerR, segments); Object.Destroy((Object)val, Mathf.Max(0.1f, lifetime)); Object.Destroy((Object)(object)val3, Mathf.Max(0.1f, lifetime)); } } private static Mesh BuildRingMesh(float innerR, float outerR, int segments) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); checked { int num = segments * 2; Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector2[] array2 = (Vector2[])(object)new Vector2[num]; int[] array3 = new int[segments * 6]; float num2 = (float)Math.PI * 2f / (float)segments; for (int i = 0; i < segments; i++) { float num3 = (float)i * num2; float num4 = Mathf.Cos(num3); float num5 = Mathf.Sin(num3); int num6 = i * 2; int num7 = i * 2 + 1; array[num6] = new Vector3(num4 * innerR, 0f, num5 * innerR); array[num7] = new Vector3(num4 * outerR, 0f, num5 * outerR); array2[num6] = new Vector2((num4 + 1f) * 0.5f, (num5 + 1f) * 0.5f); array2[num7] = array2[num6]; } for (int j = 0; j < segments; j++) { int num8; int num9; int num10; int num11; unchecked { num8 = checked(j * 2) % num; num9 = checked(j * 2 + 1) % num; num10 = checked(j * 2 + 2) % num; num11 = checked(j * 2 + 3) % num; } int num12 = j * 6; array3[num12] = num8; array3[num12 + 1] = num11; array3[num12 + 2] = num9; array3[num12 + 3] = num8; array3[num12 + 4] = num10; array3[num12 + 5] = num11; } val.vertices = Il2CppStructArray.op_Implicit(array); val.uv = Il2CppStructArray.op_Implicit(array2); val.triangles = Il2CppStructArray.op_Implicit(array3); val.RecalculateNormals(); val.RecalculateBounds(); return val; } } } [Effect(new string[] { "giantEnemies", "tinyEnemies" }, 20f, new string[] { "giantEnemies", "tinyEnemies" })] public class EnemySize : Effect { private const float GiantMultiplier = 2f; private const float TinyMultiplier = 0.5f; private static readonly Dictionary OriginalScales = new Dictionary(); private static bool s_isActive; private static float s_currentMultiplier = 1f; public EnemySize(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { EnemyManager instance = EnemyManager.Instance; if ((Object)(object)instance == (Object)null || instance.enemies == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Enemy manager not available."); } float num = ResolveMultiplier(request.code); s_isActive = true; s_currentMultiplier = num; if (ApplyScale(instance.enemies, num) == 0) { return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } EffectAnnouncer.AnnounceCustom(request, (num > 1f) ? "Enemies grow huge!" : "Enemies shrink tiny!", 3.5f); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } public override EffectResponse Tick(EffectRequest request) { if (!s_isActive) { return null; } EnemyManager instance = EnemyManager.Instance; if (((instance != null) ? instance.enemies : null) == null) { return null; } ApplyScale(instance.enemies, s_currentMultiplier); PruneMissingEnemies(instance.enemies); return null; } public override EffectResponse Stop(EffectRequest request) { EnemyManager instance = EnemyManager.Instance; if (((instance != null) ? instance.enemies : null) != null) { RestoreScale(instance.enemies); } OriginalScales.Clear(); s_isActive = false; s_currentMultiplier = 1f; return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } private static float ResolveMultiplier(string code) { if (!string.Equals(code, "giantEnemies", StringComparison.OrdinalIgnoreCase)) { return 0.5f; } return 2f; } private static int ApplyScale(Dictionary enemies, float multiplier) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) int num = 0; Enumerator enumerator = enemies.GetEnumerator(); while (enumerator.MoveNext()) { Enemy value = enumerator.Current.Value; if (!((Object)(object)value == (Object)null) && !((Object)(object)((Component)value).gameObject == (Object)null) && ((Component)value).gameObject.activeInHierarchy) { int instanceID = ((Object)((Component)value).gameObject).GetInstanceID(); if (!OriginalScales.ContainsKey(instanceID)) { OriginalScales[instanceID] = ((Component)value).transform.localScale; } ((Component)value).transform.localScale = OriginalScales[instanceID] * multiplier; num = checked(num + 1); } } return num; } private static void RestoreScale(Dictionary enemies) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = enemies.GetEnumerator(); while (enumerator.MoveNext()) { Enemy value = enumerator.Current.Value; if (!((Object)(object)value == (Object)null) && !((Object)(object)((Component)value).gameObject == (Object)null)) { int instanceID = ((Object)((Component)value).gameObject).GetInstanceID(); if (OriginalScales.TryGetValue(instanceID, out var value2)) { ((Component)value).transform.localScale = value2; } } } } private static void PruneMissingEnemies(Dictionary enemies) { if (OriginalScales.Count == 0) { return; } HashSet hashSet = new HashSet(); Enumerator enumerator = enemies.GetEnumerator(); while (enumerator.MoveNext()) { Enemy value = enumerator.Current.Value; if (!((Object)(object)((value != null) ? ((Component)value).gameObject : null) == (Object)null)) { hashSet.Add(((Object)((Component)value).gameObject).GetInstanceID()); } } List list = new List(); foreach (int key in OriginalScales.Keys) { if (!hashSet.Contains(key)) { list.Add(key); } } foreach (int item in list) { OriginalScales.Remove(item); } } } [Effect("healPlayer")] public class HealPlayer : Effect { public HealPlayer(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown try { if (Object.op_Implicit((Object)(object)MyPlayer.Instance) && MyPlayer.Instance.inventory.playerHealth.hp != MyPlayer.Instance.inventory.playerHealth.maxHp) { MyPlayer.Instance.inventory.playerHealth.Heal((float)MyPlayer.Instance.inventory.playerHealth.maxHp, true); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Cannot heal player at this time."); } catch (Exception ex) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error healing player: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } logger.LogError(val); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error healing player: " + ex.Message); } } } [Effect(new string[] { "invulnerable" }, 30f, new string[] { "invulnerable" })] public class Invulnerable : Effect { public Invulnerable(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { try { CrowdControlMod.godModeEnabled = true; return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception value) { CrowdControlMod.LogDebug($"Invulnerable error: {value}"); return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } } public override EffectResponse Stop(EffectRequest request) { try { CrowdControlMod.godModeEnabled = false; } catch (Exception value) { CrowdControlMod.LogDebug($"Invulnerable stop error: {value}"); } return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "giantPlayer", "tinyPlayer" }, 30f, new string[] { "giantPlayer", "tinyPlayer" })] public class PlayerSize : Effect { private const float GiantMultiplier = 2.5f; private const float TinyMultiplier = 0.5f; private static Vector3? s_originalScale; public PlayerSize(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { MyPlayer instance = MyPlayer.Instance; if ((Object)(object)instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } float num = ResolveMultiplier(request.code); if (!TryApplyPlayerSize(instance, num)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to resize player."); } EffectAnnouncer.AnnounceCustom(request, (num > 1f) ? "The player grows giant!" : "The player shrinks tiny!", 3.5f); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } public override EffectResponse Stop(EffectRequest request) { MyPlayer instance = MyPlayer.Instance; if ((Object)(object)instance != (Object)null) { ResetPlayerSize(instance); } return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } private static float ResolveMultiplier(string code) { if (!string.Equals(code, "giantPlayer", StringComparison.OrdinalIgnoreCase)) { return 0.5f; } return 2.5f; } private static bool TryApplyPlayerSize(MyPlayer player, float multiplier) { //IL_000d: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) DataManager instance = DataManager.Instance; CharacterData val = ((instance != null) ? instance.GetCharacterData(player.character) : null); if ((Object)(object)val != (Object)null) { player.RefreshSize(val, ((Component)player).transform.forward, multiplier); return true; } if (!s_originalScale.HasValue) { s_originalScale = ((Component)player).transform.localScale; } ((Component)player).transform.localScale = s_originalScale.Value * multiplier; return true; } private static void ResetPlayerSize(MyPlayer player) { //IL_000d: 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_0051: Unknown result type (might be due to invalid IL or missing references) DataManager instance = DataManager.Instance; CharacterData val = ((instance != null) ? instance.GetCharacterData(player.character) : null); if ((Object)(object)val != (Object)null) { player.RefreshSize(val, ((Component)player).transform.forward, 1f); } else if (s_originalScale.HasValue) { ((Component)player).transform.localScale = s_originalScale.Value; } s_originalScale = null; } } [Effect(new string[] { "playerStatus_SlowPlayer", "playerStatus_PoisonPlayer", "playerStatus_BleedPlayer", "playerStatus_BossPoisonPlayer", "playerStatus_FreezePlayer", "playerStatus_WeakPlayer", "playerStatus_ClumsyPlayer", "playerStatus_SickPlayer", "playerStatus_ExhaustedPlayer", "playerStatus_BlindPlayer", "playerStatus_HeavyPlayer", "playerStatus_ShrunkPlayer", "playerStatus_DisarmedPlayer", "playerStatus_CursedPlayer", "playerStatus_DoomedPlayer", "playerStatus_HastePlayer", "playerStatus_RagePlayer", "playerStatus_ShieldPlayer", "playerStatus_StonksPlayer", "playerStatus_TimeFreezePlayer", "playerStatus_InvulnerabilityPlayer", "playerStatus_BerserkerPlayer", "playerStatus_ThornsPlayer", "playerStatus_ArmorPlayer", "playerStatus_EvasionPlayer", "playerStatus_RegenerationPlayer", "playerStatus_GiantPlayer", "playerStatus_SwiftPlayer", "playerStatus_LuckyPlayer", "playerStatus_SharpPlayer", "playerStatus_BouncyPlayer", "playerStatus_JumpPlayer", "playerStatus_FirePlayer", "playerStatus_IcePlayer", "playerStatus_LightningPlayer", "playerStatus_CritPlayer", "playerStatus_LifestealPlayer", "playerStatus_ProjectilePlayer", "playerStatus_HealingPlayer" })] public class PlayerStatusEffect : Effect { public PlayerStatusEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c3: Expected O, but got Unknown //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_06cc: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Expected O, but got Unknown //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_0667: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_06b2: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Expected O, but got Unknown //IL_05bc: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Expected O, but got Unknown //IL_0740: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MyPlayer.Instance == (Object)null || MyPlayer.Instance.inventory == null || MyPlayer.Instance.inventory.statusEffects == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player or status effects not available."); } string[] array = request.code?.Split('_'); if (array == null || array.Length != 2 || array[0] != "playerStatus") { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Invalid effect code."); } string text = array[1]; PlayerStatusEffects statusEffects = MyPlayer.Instance.inventory.statusEffects; float num = (float)request.duration.GetValueOrDefault(30000L) / 1000f; bool flag = default(bool); try { EStatusEffect val = (EStatusEffect)(text switch { "SlowPlayer" => 6, "PoisonPlayer" => 9, "BleedPlayer" => 8, "BossPoisonPlayer" => 10, "FreezePlayer" => 7, "WeakPlayer" => 6, "ClumsyPlayer" => 6, "SickPlayer" => 9, "ExhaustedPlayer" => 6, "BlindPlayer" => 6, "HeavyPlayer" => 6, "ShrunkPlayer" => 6, "DisarmedPlayer" => 6, "CursedPlayer" => 9, "DoomedPlayer" => 10, "HastePlayer" => 0, "RagePlayer" => 1, "ShieldPlayer" => 2, "StonksPlayer" => 3, "TimeFreezePlayer" => 4, "InvulnerabilityPlayer" => 5, "BerserkerPlayer" => 1, "ThornsPlayer" => 0, "ArmorPlayer" => 2, "EvasionPlayer" => 0, "RegenerationPlayer" => 0, "GiantPlayer" => 0, "SwiftPlayer" => 0, "LuckyPlayer" => 3, "SharpPlayer" => 1, "BouncyPlayer" => 0, "JumpPlayer" => 0, "FirePlayer" => 1, "IcePlayer" => 2, "LightningPlayer" => 1, "CritPlayer" => 1, "LifestealPlayer" => 0, "ProjectilePlayer" => 0, "HealingPlayer" => 0, _ => throw new ArgumentException("Unknown playerStatus '" + text + "'"), }); if (HasBuiltInMethod(text)) { ApplyBuiltInMethodEffect(text, num, statusEffects); } else { Il2CppReferenceArray val2 = CreateStatModifiers(text, val); StatusEffect val3 = new StatusEffect(val, num, val2); statusEffects.AddNewEffect(val3, num); } ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val4 = new BepInExMessageLogInterpolatedStringHandler(40, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Applied playerStatus '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") for "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" seconds."); } logger.LogMessage(val4); ManualLogSource logger2 = CrowdControlMod.Instance.Logger; val4 = new BepInExMessageLogInterpolatedStringHandler(56, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Status effect applied to player. Check game for effects!"); } logger2.LogMessage(val4); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { ManualLogSource logger3 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(32, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Error applying playerStatus '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex.Message); } logger3.LogError(val5); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error applying playerStatus: " + ex.Message); } } private bool HasBuiltInMethod(string effectName) { return effectName switch { "SlowPlayer" => true, "PoisonPlayer" => true, "BleedPlayer" => true, "BossPoisonPlayer" => true, "FreezePlayer" => true, _ => false, }; } private void ApplyBuiltInMethodEffect(string effectName, float duration, PlayerStatusEffects status) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Applying built-in method effect: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(effectName); } logger.LogMessage(val); switch (effectName) { case "SlowPlayer": status.SlowPlayer(duration); CrowdControlMod.Instance.Logger.LogMessage((object)"Applied SlowPlayer using built-in method call"); return; case "PoisonPlayer": status.PoisonPlayer(duration); CrowdControlMod.Instance.Logger.LogMessage((object)"Applied PoisonPlayer using built-in method call"); return; case "BleedPlayer": status.BleedPlayer(duration); CrowdControlMod.Instance.Logger.LogMessage((object)"Applied BleedPlayer using built-in method call"); return; case "BossPoisonPlayer": status.BossPoisonPlayer(duration); CrowdControlMod.Instance.Logger.LogMessage((object)"Applied BossPoisonPlayer using built-in method call"); return; case "FreezePlayer": status.FreezePlayer(duration); CrowdControlMod.Instance.Logger.LogMessage((object)"Applied FreezePlayer using built-in method call"); return; } ManualLogSource logger2 = CrowdControlMod.Instance.Logger; val = new BepInExMessageLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("No built-in method found for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(effectName); } logger2.LogMessage(val); } private Il2CppReferenceArray CreateStatModifiers(string effectName, EStatusEffect statusEffectType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0ae6: Unknown result type (might be due to invalid IL or missing references) //IL_0aed: Expected O, but got Unknown //IL_09ac: Unknown result type (might be due to invalid IL or missing references) //IL_09b3: Expected O, but got Unknown //IL_09e7: Unknown result type (might be due to invalid IL or missing references) //IL_09d9: Unknown result type (might be due to invalid IL or missing references) //IL_0a03: Unknown result type (might be due to invalid IL or missing references) //IL_0a0a: Expected O, but got Unknown //IL_0a93: Unknown result type (might be due to invalid IL or missing references) //IL_0a9a: Expected O, but got Unknown //IL_0a31: Unknown result type (might be due to invalid IL or missing references) //IL_0a4a: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { StatModifier val = new StatModifier(); BepInExMessageLogInterpolatedStringHandler val2; switch (effectName) { case "HastePlayer": val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 2f; break; case "RagePlayer": val.stat = (EStat)12; val.modifyType = (EStatModifyType)1; val.modification = 2f; break; case "ShieldPlayer": val.stat = (EStat)2; val.modifyType = (EStatModifyType)0; val.modification = 50f; break; case "StonksPlayer": val.stat = (EStat)31; val.modifyType = (EStatModifyType)1; val.modification = 53f; break; case "TimeFreezePlayer": val.stat = (EStat)15; val.modifyType = (EStatModifyType)1; val.modification = 50.1f; break; case "InvulnerabilityPlayer": val.stat = (EStat)7; val.modifyType = (EStatModifyType)2; val.modification = 51f; break; case "BerserkerPlayer": val.stat = (EStat)12; val.modifyType = (EStatModifyType)1; val.modification = 10f; break; case "ThornsPlayer": val.stat = (EStat)3; val.modifyType = (EStatModifyType)0; val.modification = 100f; break; case "ArmorPlayer": val.stat = (EStat)4; val.modifyType = (EStatModifyType)0; val.modification = 50f; break; case "EvasionPlayer": val.stat = (EStat)5; val.modifyType = (EStatModifyType)0; val.modification = 0.8f; break; case "RegenerationPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = 20f; break; case "GiantPlayer": val.stat = (EStat)9; val.modifyType = (EStatModifyType)1; val.modification = 3f; break; case "SwiftPlayer": val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 8f; break; case "LuckyPlayer": val.stat = (EStat)30; val.modifyType = (EStatModifyType)0; val.modification = 100f; break; case "SharpPlayer": val.stat = (EStat)18; val.modifyType = (EStatModifyType)0; val.modification = 0.5f; break; case "BouncyPlayer": val.stat = (EStat)45; val.modifyType = (EStatModifyType)0; val.modification = 10f; break; case "JumpPlayer": val.stat = (EStat)26; val.modifyType = (EStatModifyType)1; val.modification = 5f; break; case "FirePlayer": val.stat = (EStat)20; val.modifyType = (EStatModifyType)0; val.modification = 50f; break; case "IcePlayer": val.stat = (EStat)21; val.modifyType = (EStatModifyType)0; val.modification = 50f; break; case "LightningPlayer": val.stat = (EStat)22; val.modifyType = (EStatModifyType)0; val.modification = 50f; break; case "CritPlayer": val.stat = (EStat)19; val.modifyType = (EStatModifyType)1; val.modification = 10f; break; case "LifestealPlayer": val.stat = (EStat)17; val.modifyType = (EStatModifyType)0; val.modification = 0.5f; break; case "ProjectilePlayer": val.stat = (EStat)16; val.modifyType = (EStatModifyType)0; val.modification = 5f; break; case "HealingPlayer": val.stat = (EStat)48; val.modifyType = (EStatModifyType)1; val.modification = 5f; break; case "SlowPlayer": val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 0.2f; break; case "WeakPlayer": val.stat = (EStat)12; val.modifyType = (EStatModifyType)1; val.modification = 0.3f; break; case "ClumsyPlayer": val.stat = (EStat)15; val.modifyType = (EStatModifyType)1; val.modification = 0.2f; break; case "PoisonPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -10f; break; case "SickPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -15f; break; case "ExhaustedPlayer": val.stat = (EStat)15; val.modifyType = (EStatModifyType)1; val.modification = 0.1f; break; case "BlindPlayer": val.stat = (EStat)18; val.modifyType = (EStatModifyType)1; val.modification = 0.1f; break; case "HeavyPlayer": val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 0.1f; break; case "ShrunkPlayer": val.stat = (EStat)9; val.modifyType = (EStatModifyType)1; val.modification = 0.3f; break; case "DisarmedPlayer": val.stat = (EStat)16; val.modifyType = (EStatModifyType)1; val.modification = 0.1f; break; case "BleedPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -8f; break; case "CursedPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -12f; break; case "BossPoisonPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -20f; break; case "DoomedPlayer": val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -25f; break; case "FreezePlayer": val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 0.05f; break; default: { ManualLogSource logger = CrowdControlMod.Instance.Logger; val2 = new BepInExMessageLogInterpolatedStringHandler(54, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("No specific modifiers defined for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(effectName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", using default for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(statusEffectType); } logger.LogMessage(val2); return CreateDefaultStatModifiers(statusEffectType); } } ManualLogSource logger2 = CrowdControlMod.Instance.Logger; val2 = new BepInExMessageLogInterpolatedStringHandler(47, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Created StatModifier for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(effectName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": stat="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.stat); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", type="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.modifyType); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", value="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val.modification); } logger2.LogMessage(val2); Il2CppReferenceArray val3 = new Il2CppReferenceArray((StatModifier[])(object)new StatModifier[1] { val }); ManualLogSource logger3 = CrowdControlMod.Instance.Logger; val2 = new BepInExMessageLogInterpolatedStringHandler(56, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Il2CppReferenceArray created successfully with "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Il2CppArrayBase)(object)val3)?.Length ?? 0); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" elements"); } logger3.LogMessage(val2); return val3; } catch (Exception ex) { ManualLogSource logger4 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(35, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Error creating StatModifiers for "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(effectName); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } logger4.LogError(val4); return null; } } private Il2CppReferenceArray CreateDefaultStatModifiers(EStatusEffect statusEffectType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected I4, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) try { StatModifier val = new StatModifier(); switch ((int)statusEffectType) { case 0: val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 2f; break; case 1: val.stat = (EStat)12; val.modifyType = (EStatModifyType)1; val.modification = 2f; break; case 6: val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 0.5f; break; case 8: case 9: case 10: val.stat = (EStat)1; val.modifyType = (EStatModifyType)0; val.modification = -5f; break; case 2: val.stat = (EStat)2; val.modifyType = (EStatModifyType)0; val.modification = 50f; break; case 3: val.stat = (EStat)31; val.modifyType = (EStatModifyType)1; val.modification = 2f; break; case 4: val.stat = (EStat)15; val.modifyType = (EStatModifyType)1; val.modification = 10f; break; case 5: val.stat = (EStat)7; val.modifyType = (EStatModifyType)1; val.modification = 10f; break; case 7: val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 0.1f; break; default: val.stat = (EStat)25; val.modifyType = (EStatModifyType)1; val.modification = 1f; break; } return new Il2CppReferenceArray((StatModifier[])(object)new StatModifier[1] { val }); } catch (Exception ex) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error creating default StatModifiers for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(statusEffectType); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } logger.LogError(val2); return null; } } } [Effect("spawnBoss")] public class SpawnBoss : Effect { public SpawnBoss(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)MyPlayer.Instance).gameObject; if ((Object)(object)gameObject == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } EnemyManager instance = EnemyManager.Instance; if ((Object)(object)instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "EnemyManager not found."); } Vector3 position = gameObject.transform.position; Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; float num = Random.Range(5f, 12f); Vector3 val = position + new Vector3(normalized.x, 0f, normalized.y) * num; EEnemy[] defaultBossEnemies = EnemySpawnHelper.DefaultBossEnemies; EEnemy val2 = defaultBossEnemies[Random.Range(0, defaultBossEnemies.Length)]; bool flag = default(bool); try { Enemy val3 = EnemySpawnHelper.SpawnWithFallback(instance, val, val2, (EEnemyFlag)2, defaultBossEnemies); if ((Object)(object)val3 != (Object)null) { string text = (string.IsNullOrWhiteSpace(request.viewer) ? "CrowdControl" : request.viewer); ((Object)((Component)val3).gameObject).name = "CC_" + text; ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val4 = new BepInExMessageLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Spawned boss "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val2); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" at position "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val); } logger.LogMessage(val4); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to spawn boss."); } catch (Exception ex) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Error spawning boss: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex.Message); } logger2.LogError(val5); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning boss: " + ex.Message); } } } [Effect("spawnChest")] public class SpawnChest : Effect { public SpawnChest(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) bool flag2 = default(bool); try { MyPlayer instance = MyPlayer.Instance; GameObject val = ((instance != null) ? ((Component)instance).gameObject : null); if ((Object)(object)val == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } EffectManager val2 = Object.FindObjectOfType(); if ((Object)(object)val2 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "EffectManager not found."); } Vector3 position = val.transform.position; Vector2 insideUnitCircle = Random.insideUnitCircle; if (((Vector2)(ref insideUnitCircle)).sqrMagnitude < 0.0001f) { ((Vector2)(ref insideUnitCircle))..ctor(1f, 0f); } ((Vector2)(ref insideUnitCircle)).Normalize(); float num = Random.Range(2f, 6f); Vector3 val3 = position + new Vector3(insideUnitCircle.x, 0f, insideUnitCircle.y) * num; GameObject val4 = null; try { Il2CppReferenceArray val5 = GameObject.FindGameObjectsWithTag("Chest"); if (val5 != null && ((Il2CppArrayBase)(object)val5).Length > 0) { val4 = ((Il2CppArrayBase)(object)val5)[0]; } } catch { } if ((Object)(object)val4 == (Object)null) { Il2CppArrayBase val6 = Object.FindObjectsOfType(); GameObject val7 = null; GameObject val8 = null; for (int i = 0; i < val6.Length; i = checked(i + 1)) { GameObject val9 = val6[i]; if ((Object)(object)val9 == (Object)null || !val9.activeInHierarchy) { continue; } string name = ((Object)val9).name; if (!string.IsNullOrEmpty(name)) { if (name.IndexOf("chestfree(clone)", StringComparison.OrdinalIgnoreCase) >= 0) { val7 = val9; break; } if ((Object)(object)val8 == (Object)null && name.IndexOf("chest(clone)", StringComparison.OrdinalIgnoreCase) >= 0) { val8 = val9; } } } val4 = val7 ?? val8; } if ((Object)(object)val4 == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No chest prefab found in scene."); } bool flag = false; try { val2.SpawnChest(val4, val3); flag = true; } catch { if ((Object)(object)Object.Instantiate(val4, val3, Quaternion.identity) != (Object)null) { flag = true; } } if (!flag) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to spawn chest."); } ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val10 = new BepInExMessageLogInterpolatedStringHandler(17, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val10).AppendLiteral("Spawned chest at "); ((BepInExLogInterpolatedStringHandler)val10).AppendFormatted(val3); } logger.LogMessage(val10); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val11 = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val11).AppendLiteral("Error spawning chest: "); ((BepInExLogInterpolatedStringHandler)val11).AppendFormatted(ex.Message); } logger2.LogError(val11); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning chest: " + ex.Message); } } } [Effect(new string[] { "spawnEnemy_Skeleton", "spawnEnemy_GoldenSkeleton", "spawnEnemy_XpSkeleton", "spawnEnemy_ArmoredSkeleton", "spawnEnemy_SkeletonDusty", "spawnEnemy_ArmoredSkeletonDusty", "spawnEnemy_Ghoul", "spawnEnemy_MinibossPig", "spawnEnemy_Mummy", "spawnEnemy_Slime", "spawnEnemy_Goblin", "spawnEnemy_GoblinStrong", "spawnEnemy_GoblinTank", "spawnEnemy_MinibossGolem", "spawnEnemy_Ghost", "spawnEnemy_GreaterGhost", "spawnEnemy_Ent1", "spawnEnemy_Ent2", "spawnEnemy_Ent3", "spawnEnemy_BoomerSpider", "spawnEnemy_Golem", "spawnEnemy_Bee", "spawnEnemy_MinibossGolemSand", "spawnEnemy_Scorpion", "spawnEnemy_MinibossScorpion", "spawnEnemy_Wisp", "spawnEnemy_CactusShooter", "spawnEnemy_ScorpionMedium", "spawnEnemy_MummyTank", "spawnEnemy_MummyAncient", "spawnEnemy_Tumblebone", "spawnEnemy_Pharaoh1", "spawnEnemy_Pharaoh2", "spawnEnemy_Pharaoh3", "spawnEnemy_Bandit", "spawnEnemy_Bush", "spawnEnemy_GhostRed", "spawnEnemy_GhostPurple" })] public class SpawnEnemy : Effect { public SpawnEnemy(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Invalid comparison between Unknown and I4 //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)MyPlayer.Instance).gameObject; if ((Object)(object)gameObject == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } EnemyManager instance = EnemyManager.Instance; if ((Object)(object)instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "EnemyManager not found."); } string[] array = request.code?.Split('_'); if (array == null || array.Length != 2 || array[0] != "spawnEnemy") { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Invalid effect code."); } string text = array[1]; Vector3 position = gameObject.transform.position; Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; float num = Random.Range(3f, 8f); Vector3 val = position + new Vector3(normalized.x, 0f, normalized.y) * num; EEnemy enemyTypeFromString = GetEnemyTypeFromString(text); if ((int)enemyTypeFromString == -1) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unknown enemy type: " + text); } bool flag = default(bool); try { EEnemy[] fallbackPool = (EnemySpawnHelper.IsBoss(enemyTypeFromString) ? EnemySpawnHelper.DefaultBossEnemies : EnemySpawnHelper.DefaultRegularEnemies); if ((Object)(object)EnemySpawnHelper.SpawnWithFallback(instance, val, enemyTypeFromString, (EEnemyFlag)0, fallbackPool) != (Object)null) { ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Spawned enemy "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(enemyTypeFromString); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" at position "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val); } logger.LogMessage(val2); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to spawn enemy."); } catch (Exception ex) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error spawning enemy: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } logger2.LogError(val3); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning enemy: " + ex.Message); } } private EEnemy GetEnemyTypeFromString(string enemyTypeString) { //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05e2: Unknown result type (might be due to invalid IL or missing references) //IL_05d3: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_059c: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) return (EEnemy)(enemyTypeString switch { "Skeleton" => 0, "GoldenSkeleton" => 1, "XpSkeleton" => 2, "ArmoredSkeleton" => 3, "SkeletonDusty" => 4, "ArmoredSkeletonDusty" => 5, "Ghoul" => 6, "MinibossPig" => 7, "Mummy" => 8, "Slime" => 9, "Goblin" => 12, "GoblinStrong" => 13, "GoblinTank" => 14, "MinibossGolem" => 15, "Ghost" => 16, "GreaterGhost" => 17, "SkeletonMage" => 18, "Ent1" => 19, "Ent2" => 20, "Ent3" => 21, "BoomerSpider" => 22, "Golem" => 23, "Bee" => 24, "MinibossGolemSand" => 25, "Scorpion" => 26, "MinibossScorpion" => 27, "Wisp" => 28, "CactusShooter" => 29, "ScorpionMedium" => 30, "MummyTank" => 31, "MummyAncient" => 32, "Tumblebone" => 33, "Pharaoh1" => 34, "Pharaoh2" => 35, "Pharaoh3" => 36, "Bandit" => 37, "Bush" => 38, "GhostRed" => 39, "GhostPurple" => 40, _ => -1, }); } } [Effect("spawnEnemy")] public class SpawnEnemyRandom : Effect { public SpawnEnemyRandom(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)MyPlayer.Instance).gameObject; if ((Object)(object)gameObject == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } EnemyManager instance = EnemyManager.Instance; if ((Object)(object)instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "EnemyManager not found."); } Vector3 position = gameObject.transform.position; Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized; float num = Random.Range(3f, 8f); Vector3 val = position + new Vector3(normalized.x, 0f, normalized.y) * num; EEnemy[] defaultRegularEnemies = EnemySpawnHelper.DefaultRegularEnemies; EEnemy val2 = defaultRegularEnemies[Random.Range(0, defaultRegularEnemies.Length)]; bool flag = default(bool); try { if ((Object)(object)EnemySpawnHelper.SpawnWithFallback(instance, val, val2, (EEnemyFlag)0, defaultRegularEnemies) != (Object)null) { ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val3 = new BepInExMessageLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Spawned enemy "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" at position "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val); } logger.LogMessage(val3); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to spawn enemy."); } catch (Exception ex) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Error spawning enemy: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); } logger2.LogError(val4); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning enemy: " + ex.Message); } } } [Effect("spawnEnemySwarm")] public class SpawnEnemySwarm : Effect { public SpawnEnemySwarm(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00fb: 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_0105: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)MyPlayer.Instance).gameObject; if ((Object)(object)gameObject == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } EnemyManager instance = EnemyManager.Instance; if ((Object)(object)instance == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "EnemyManager not found."); } Vector3 position = gameObject.transform.position; int num = Random.Range(5, 12); float num2 = Random.Range(8f, 15f); EEnemy[] defaultSwarmEnemies = EnemySpawnHelper.DefaultSwarmEnemies; EEnemy val = defaultSwarmEnemies[Random.Range(0, defaultSwarmEnemies.Length)]; int num3 = 0; checked { for (int i = 0; i < num; i++) { float num4 = (360f / (float)num * (float)i + Random.Range(-30f, 30f)) * ((float)Math.PI / 180f); Vector3 val2 = position + new Vector3(Mathf.Cos(num4) * num2, 0f, Mathf.Sin(num4) * num2); val2 += new Vector3(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f)); if ((Object)(object)EnemySpawnHelper.SpawnWithFallback(instance, val2, val, (EEnemyFlag)0, defaultSwarmEnemies) != (Object)null) { num3++; } } if (num3 > 0) { ManualLogSource logger = CrowdControlMod.Instance.Logger; bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val3 = new BepInExMessageLogInterpolatedStringHandler(30, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Spawned enemy swarm: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (type "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")"); } logger.LogMessage(val3); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to spawn any enemies in swarm."); } } } [Effect("spawnItem")] public class SpawnRandomItem : Effect { public SpawnRandomItem(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) MyPlayer instance = MyPlayer.Instance; object obj; if (instance == null) { obj = null; } else { PlayerInventory inventory = instance.inventory; obj = ((inventory != null) ? inventory.itemInventory : null); } ItemInventory val = (ItemInventory)obj; if ((Object)(object)instance == (Object)null || val == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player inventory not available."); } PlayerStatsNew playerStats = instance.inventory.playerStats; ItemData randomItem = ItemUtility.GetRandomItem((playerStats != null) ? playerStats.GetStat((EStat)30) : 0f); if ((Object)(object)randomItem == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No item data available."); } val.AddItem(randomItem.eItem); string name = ((UnlockableBase)randomItem).GetName(); EffectAnnouncer.AnnounceCustom(request, "Item drop: " + name, 4f, ((UnlockableBase)randomItem).GetIcon()); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "spawnItem_Key", "spawnItem_Beer", "spawnItem_SpikyShield", "spawnItem_Bonker", "spawnItem_SlipperyRing", "spawnItem_CowardsCloak", "spawnItem_GymSauce", "spawnItem_Battery", "spawnItem_PhantomShroud", "spawnItem_ForbiddenJuice", "spawnItem_DemonBlade", "spawnItem_GrandmasSecretTonic", "spawnItem_GiantFork", "spawnItem_MoldyCheese", "spawnItem_GoldenSneakers", "spawnItem_SpicyMeatball", "spawnItem_Chonkplate", "spawnItem_LightningOrb", "spawnItem_IceCube", "spawnItem_DemonicBlood", "spawnItem_DemonicSoul", "spawnItem_BeefyRing", "spawnItem_Dragonfire", "spawnItem_GoldenGlove", "spawnItem_GoldenShield", "spawnItem_ZaWarudo", "spawnItem_OverpoweredLamp", "spawnItem_Feathers", "spawnItem_Ghost", "spawnItem_SluttyCannon", "spawnItem_TurboSocks", "spawnItem_ShatteredWisdom", "spawnItem_EchoShard", "spawnItem_SuckyMagnet", "spawnItem_Backpack", "spawnItem_Clover", "spawnItem_Campfire", "spawnItem_Rollerblades", "spawnItem_Skuleg", "spawnItem_EagleClaw", "spawnItem_Scarf", "spawnItem_Anvil", "spawnItem_Oats", "spawnItem_CursedDoll", "spawnItem_EnergyCore", "spawnItem_ElectricPlug", "spawnItem_BobDead", "spawnItem_SoulHarvester", "spawnItem_Mirror", "spawnItem_JoesDagger", "spawnItem_WeebHeadset", "spawnItem_SpeedBoi", "spawnItem_Gasmask", "spawnItem_ToxicBarrel", "spawnItem_HolyBook", "spawnItem_BrassKnuckles", "spawnItem_IdleJuice", "spawnItem_Kevin", "spawnItem_Borgar", "spawnItem_Medkit", "spawnItem_GamerGoggles", "spawnItem_UnstableTransfusion", "spawnItem_BloodyCleaver", "spawnItem_CreditCardRed", "spawnItem_CreditCardGreen", "spawnItem_BossBuster", "spawnItem_LeechingCrystal", "spawnItem_TacticalGlasses", "spawnItem_Cactus", "spawnItem_CageKey", "spawnItem_IceCrystal", "spawnItem_TimeBracelet", "spawnItem_GloveLightning", "spawnItem_GlovePoison", "spawnItem_GloveBlood", "spawnItem_GloveCurse", "spawnItem_GlovePower", "spawnItem_Wrench", "spawnItem_Beacon", "spawnItem_GoldenRing", "spawnItem_QuinsMask", "spawnItem_CryptKey", "spawnItem_OldMask", "spawnItem_Snek", "spawnItem_Pot", "spawnItem_BobsLantern", "spawnItem_Pumpkin", "spawnItem_WizardsHat" })] public class SpawnSpecificItem : Effect { public SpawnSpecificItem(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) MyPlayer instance = MyPlayer.Instance; object obj; if (instance == null) { obj = null; } else { PlayerInventory inventory = instance.inventory; obj = ((inventory != null) ? inventory.itemInventory : null); } ItemInventory val = (ItemInventory)obj; if ((Object)(object)instance == (Object)null || val == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player inventory not available."); } string text = request.code ?? string.Empty; if (!text.StartsWith("spawnItem_", StringComparison.OrdinalIgnoreCase)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Invalid item code."); } string text2 = text.Substring("spawnItem_".Length); if (!Enum.TryParse(text2, ignoreCase: true, out EItem result)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unknown item '" + text2 + "'."); } val.AddItem(result); DataManager instance2 = DataManager.Instance; ItemData val2 = ((instance2 != null) ? instance2.GetItem(result) : null); string text3 = ((val2 != null) ? ((UnlockableBase)val2).GetName() : null) ?? text2; EffectAnnouncer.AnnounceCustom(request, "Item drop: " + text3, 4f, (val2 != null) ? ((UnlockableBase)val2).GetIcon() : null); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("teleportPlayer")] public class TeleportPlayer : Effect { private const int maxAttempts = 12; private const float probeHeight = 200f; private const float maxGroundDrop = 500f; private const float groundOffset = 0.2f; private const float clearanceRadius = 0.4f; private const float clearanceHeight = 1.8f; private static readonly LayerMask groundMask = LayerMask.op_Implicit(-1); public TeleportPlayer(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_00d3: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { MyPlayer instance = MyPlayer.Instance; GameObject val = ((instance != null) ? ((Component)instance).gameObject : null); if ((Object)(object)val == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player not found."); } if (!TryFindSafeTeleportPosition(out var safePos)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to find a safe teleport position."); } Rigidbody component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.velocity = Vector3.zero; } val.transform.position = safePos; ManualLogSource logger = CrowdControlMod.Instance.Logger; BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Teleported player to safe position "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(safePos); } logger.LogMessage(val2); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { ManualLogSource logger2 = CrowdControlMod.Instance.Logger; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error teleporting player: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex); } logger2.LogError(val3); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error teleporting player: " + ex.Message); } } private static bool TryFindSafeTeleportPosition(out Vector3 safePos) { //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); for (int i = 0; i < 12; i = checked(i + 1)) { Vector3 randomSpawnPositionOnMap = SpawnPositions.GetRandomSpawnPositionOnMap(1f); if (!(randomSpawnPositionOnMap == Vector3.zero) && Physics.Raycast(new Vector3(randomSpawnPositionOnMap.x, 200f, randomSpawnPositionOnMap.z), Vector3.down, ref val, 700f, LayerMask.op_Implicit(groundMask), (QueryTriggerInteraction)1)) { Vector3 val2 = ((RaycastHit)(ref val)).point + Vector3.up * 0.2f; if (HasClearanceAt(val2)) { safePos = val2; return true; } } } safePos = Vector3.zero; return false; } private static bool HasClearanceAt(Vector3 feetPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = feetPos + Vector3.up * 0.4f; Vector3 val2 = feetPos + Vector3.up * Mathf.Max(1.4f, 0.4f); return !Physics.CheckCapsule(val, val2, 0.4f, -1, (QueryTriggerInteraction)1); } } [Effect(new string[] { "slowTime", "speedUpTime" }, 15f, new string[] { "slowTime", "speedUpTime" })] public class TimeManipulation : Effect { private float _previousTimeScale = 1f; public TimeManipulation(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { try { if (_previousTimeScale != 1f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Time manipulation effect is already active."); } _previousTimeScale = Time.timeScale; string code = request.code; if (!(code == "slowTime")) { if (!(code == "speedUpTime")) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unknown effect code " + request.code); } Time.timeScale = 2f; CrowdControlMod.LogDebug("Applied Speed Up Time"); } else { Time.timeScale = 0.5f; CrowdControlMod.LogDebug("Applied Slow Time"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception value) { CrowdControlMod.LogDebug($"Time manipulation error: {value}"); return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } } public override EffectResponse Stop(EffectRequest request) { try { Time.timeScale = _previousTimeScale; CrowdControlMod.LogDebug("Restored normal time scale"); } catch (Exception value) { try { Time.timeScale = (_previousTimeScale = 1f); } catch { } CrowdControlMod.LogDebug($"Time manipulation stop error: {value}"); } return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (string)null); } } }