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; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BepinControl.Effects; using HarmonyLib; using Microsoft.CodeAnalysis; using MyBox; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("LethalCompanyCrowdControlMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LethalCompanyCrowdControlMod")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d4f6b961-e8ae-4e4b-950c-37644e42d4ca")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } } namespace BepinControl { public class EffectUpdateModern { public enum Status { STATUS_VISIBLE = 128, STATUS_NOTVISIBLE, STATUS_SELECTABLE, STATUS_NOTSELECTABLE } public readonly string idType = "effect"; public string[]? ids; public int status; public readonly int type = 1; public EffectUpdateModern(Status status, params string[] ids) { this.status = (int)status; this.ids = ids; } public void Send(Socket socket) { byte[] bytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject((object)this)); byte[] array = new byte[bytes.Length + 1]; Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length); array[bytes.Length] = 0; socket.Send(array); } } public class HelperUtils { public static async Task FindPlayerHealthByAvatarNumber(int targetActor) { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); await Task.Yield(); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerHealth[] array = Object.FindObjectsOfType(); List list = new List(); if (array == null) { tcs.TrySetResult(null); } else { PlayerHealth[] array2 = array; foreach (PlayerHealth val in array2) { PhotonView component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && component.Owner.ActorNumber == targetActor) { list.Add(val); } } tcs.TrySetResult(list.FirstOrDefault()); } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error in FindPlayerHealthByAvatarNumber: " + ex.Message)); tcs.TrySetResult(null); } }); return await tcs.Task; } public static async Task FindPlayerDeathHeadByAvatarNumber(int targetActor) { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); await Task.Yield(); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerDeathHead[] array = Object.FindObjectsOfType(); List list = new List(); if (array == null) { tcs.TrySetResult(null); } else { PlayerDeathHead[] array2 = array; foreach (PlayerDeathHead val in array2) { PhotonView component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && component.Owner.ActorNumber == targetActor) { list.Add(val); } } tcs.TrySetResult(list.FirstOrDefault()); } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error in FindPlayerDeathHeadByAvatarNumber: " + ex.Message)); tcs.TrySetResult(null); } }); return await tcs.Task; } public static async Task FindPlayerAvatarByNumber(int actorNumber, bool alive = true, bool random = false) { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); await Task.Yield(); CrowdControlMod.ActionQueue.Enqueue(delegate { try { List list = new List(); foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { PhotonView component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null)) { FieldInfo field = typeof(PlayerAvatar).GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic); if (!(field != null && (bool)field.GetValue(player) && alive)) { if (random) { if (component.Owner.ActorNumber != actorNumber) { list.Add(player); } } else if (component.Owner.ActorNumber == actorNumber) { tcs.TrySetResult(player); return; } } } } if (random && list.Count > 0) { int index = Random.Range(0, list.Count); PlayerAvatar result = list[index]; tcs.TrySetResult(result); } else { tcs.TrySetResult(null); } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error in FindPlayerAvatarByNumber: " + ex.Message)); tcs.TrySetResult(null); } }); return await tcs.Task; } public static async Task FindRandomAvatar(int actorNumber) { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); await Task.Yield(); CrowdControlMod.ActionQueue.Enqueue(delegate { try { List list = new List(); foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { PhotonView component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null) && component.Owner.ActorNumber != actorNumber) { list.Add(player); } } if (list.Count > 0) { int index = Random.Range(0, list.Count); PlayerAvatar result = list[index]; tcs.TrySetResult(result); } else { tcs.TrySetResult(null); } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error in FindRandomAvatar: " + ex.Message)); tcs.TrySetResult(null); } }); return await tcs.Task; } public static async Task FindRandomExtractionPoint() { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); await Task.Yield(); CrowdControlMod.ActionQueue.Enqueue(delegate { try { ExtractionPoint[] source = Object.FindObjectsOfType(); FieldInfo stateField = typeof(ExtractionPoint).GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic); if (stateField == null) { CrowdControlMod.mls.LogError((object)"FindRandomExtractionPoint: Could not find 'currentState' field."); tcs.TrySetResult(null); } else { ExtractionPoint[] array = source.Where(delegate(ExtractionPoint point) { object value = stateField.GetValue(point); return value != null && (value.Equals((object)(State)2) || value.Equals((object)(State)7)); }).ToArray(); if (array.Length != 0) { int num = Random.Range(0, array.Length); ExtractionPoint result = array[num]; tcs.TrySetResult(result); } else { tcs.TrySetResult(null); } } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error in FindRandomExtractionPoint: " + ex.Message)); tcs.TrySetResult(null); } }); return await tcs.Task; } } public class StatusEffect { public string Name { get; private set; } public float Duration { get; private set; } public float RemainingTime { get; set; } public GameObject UIElement { get; set; } public StatusEffect(string name, float duration) { Name = name; Duration = duration; RemainingTime = duration; } } public class StatusEffectUI { private GameObject uiObject; private TextMeshProUGUI nameText; private TextMeshProUGUI durationText; private Image timerCircle; private float duration; private float startTime; private bool isActive = true; public StatusEffectUI(GameObject uiObject, string effectName, float duration) { this.uiObject = uiObject; this.duration = duration; startTime = Time.time; Transform obj = uiObject.transform.Find("EffectName"); nameText = ((obj != null) ? ((Component)obj).GetComponent() : null); Transform obj2 = uiObject.transform.Find("DurationText"); durationText = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); Transform obj3 = uiObject.transform.Find("TimerCircle"); timerCircle = ((obj3 != null) ? ((Component)obj3).GetComponent() : null); if (!((Object)(object)nameText == (Object)null) && !((Object)(object)timerCircle == (Object)null) && !((Object)(object)durationText == (Object)null)) { Initialize(effectName); } } public void Initialize(string effectName) { ((TMP_Text)nameText).text = effectName; UpdateDurationText(duration); if ((Object)(object)timerCircle != (Object)null) { timerCircle.type = (Type)3; timerCircle.fillMethod = (FillMethod)4; timerCircle.fillOrigin = 2; timerCircle.fillClockwise = false; timerCircle.fillAmount = 1f; Canvas.ForceUpdateCanvases(); } } private void UpdateDurationText(float remainingTime) { if ((Object)(object)durationText != (Object)null) { ((TMP_Text)durationText).text = remainingTime.ToString("F1") + "s"; } } public void UpdateTimer() { if (isActive && !((Object)(object)timerCircle == (Object)null)) { float num = Time.time - startTime; float num2 = duration - num; if (num2 <= 0f) { isActive = false; Object.Destroy((Object)(object)uiObject); return; } float fillAmount = Mathf.Clamp01(num2 / duration); UpdateDurationText(num2); timerCircle.fillAmount = fillAmount; ((Graphic)timerCircle).SetAllDirty(); LayoutRebuilder.ForceRebuildLayoutImmediate(((Graphic)timerCircle).rectTransform); Canvas.ForceUpdateCanvases(); } } public bool IsActive() { return isActive; } public void Destroy() { if ((Object)(object)uiObject != (Object)null) { Object.Destroy((Object)(object)uiObject); } isActive = false; } } public class StatusEffectUIComponent : MonoBehaviour { private StatusEffectUI ui; public void Initialize(string effectName, float duration) { ui = new StatusEffectUI(((Component)this).gameObject, effectName, duration); } private void Update() { if (ui != null) { ui.UpdateTimer(); } } private void OnDestroy() { ui?.Destroy(); } } public class StatusEffectSystem : MonoBehaviour { private static StatusEffectSystem _instance; private List activeEffects = new List(); private GameObject effectPrefab; private RectTransform container; private bool isAnchored; private const string ENERGY_OBJECT_NAME = "Energy"; public static StatusEffectSystem Instance { get { if ((Object)(object)_instance == (Object)null) { GameObject val = GameObject.Find("StatusEffectSystem"); if ((Object)(object)val != (Object)null) { _instance = val.GetComponent(); } else { CreateInstance(); } } return _instance; } } private static void CreateInstance() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _instance = new GameObject("StatusEffectSystem").AddComponent(); _instance.Initialize(); } private void Initialize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown GameObject val = new GameObject("StatusEffectCanvas"); val.transform.SetParent(((Component)this).transform); Canvas obj = val.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 100; val.AddComponent(); val.AddComponent(); GameObject val2 = new GameObject("EffectsContainer"); val2.transform.SetParent(val.transform, false); container = val2.AddComponent(); container.anchorMin = new Vector2(0f, 1f); container.anchorMax = new Vector2(0f, 1f); container.pivot = new Vector2(0.5f, 1f); container.anchoredPosition = new Vector2(-5000f, -5000f); container.sizeDelta = new Vector2(250f, 500f); VerticalLayoutGroup obj2 = val2.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 0f; ((LayoutGroup)obj2).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((LayoutGroup)obj2).padding = new RectOffset(5, 5, 0, 0); CreateEffectPrefab(); } private void CreateEffectPrefab() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0025: 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: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) effectPrefab = new GameObject("StatusEffectUI"); effectPrefab.AddComponent().sizeDelta = new Vector2(240f, 30f); LayoutElement obj = effectPrefab.AddComponent(); obj.minHeight = 30f; obj.minWidth = 240f; obj.preferredHeight = 30f; obj.preferredWidth = 240f; obj.flexibleWidth = 0f; obj.flexibleHeight = 0f; GameObject val = new GameObject("TimerCircle"); val.transform.SetParent(effectPrefab.transform, false); RectTransform obj2 = val.AddComponent(); obj2.sizeDelta = new Vector2(16f, 16f); obj2.anchoredPosition = new Vector2(45f, 0f); Image val2 = val.AddComponent(); Texture2D val3 = new Texture2D(32, 32); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(16f, 16f); float num = 15.5f; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num2 = ((Vector2.Distance(new Vector2((float)j, (float)i), val4) <= num) ? 1f : 0f); val3.SetPixel(j, i, new Color(1f, 1f, 1f, num2)); } } val3.Apply(); Sprite sprite = Sprite.Create(val3, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f)); val2.sprite = sprite; val2.type = (Type)3; val2.fillMethod = (FillMethod)4; val2.fillOrigin = 2; val2.fillClockwise = false; val2.fillAmount = 1f; ((Graphic)val2).color = new Color(0.2f, 1f, 0.2f, 0.9f); ((Graphic)val2).raycastTarget = false; Outline val5 = val.AddComponent(); ((Shadow)val5).effectColor = new Color(0f, 1f, 0.2f, 0.6f); ((Shadow)val5).effectDistance = new Vector2(1f, 1f); ((Shadow)val5).useGraphicAlpha = true; Outline val6 = val.AddComponent(); ((Shadow)val6).effectColor = new Color(0.2f, 1f, 0.2f, 0.3f); ((Shadow)val6).effectDistance = new Vector2(2f, 2f); ((Shadow)val6).useGraphicAlpha = true; GameObject val7 = new GameObject("EffectName"); val7.transform.SetParent(effectPrefab.transform, false); RectTransform val8 = val7.AddComponent(); val8.sizeDelta = new Vector2(180f, 30f); val8.anchoredPosition = new Vector2(80f, 0f); GameObject val9 = new GameObject("Text"); val9.transform.SetParent((Transform)(object)val8, false); RectTransform obj3 = val9.AddComponent(); obj3.sizeDelta = new Vector2(180f, 30f); obj3.anchoredPosition = Vector2.zero; TextMeshProUGUI val10 = val9.AddComponent(); ((TMP_Text)val10).alignment = (TextAlignmentOptions)513; ((TMP_Text)val10).margin = new Vector4(70f, 0f, 0f, 0f); ((TMP_Text)val10).fontSize = 16f; GameObject val11 = GameObject.Find("Health"); if ((Object)(object)val11 != (Object)null) { Transform obj4 = val11.transform.Find("HealthMax"); TextMeshProUGUI val12 = ((obj4 != null) ? ((Component)obj4).GetComponent() : null); if ((Object)(object)val12 != (Object)null) { ((TMP_Text)val10).font = ((TMP_Text)val12).font; ((Graphic)val10).color = ((Graphic)val12).color; ((Graphic)val2).color = ((Graphic)val12).color; if ((Object)(object)val5 != (Object)null) { Color color = ((Graphic)val12).color; color.a = 0.6f; ((Shadow)val5).effectColor = color; } if ((Object)(object)val6 != (Object)null) { Color color2 = ((Graphic)val12).color; color2.a = 0.3f; ((Shadow)val6).effectColor = color2; } } } ((TMP_Text)val10).enableVertexGradient = false; Outline obj5 = val9.AddComponent(); ((Shadow)obj5).effectColor = new Color(((Graphic)val10).color.r, ((Graphic)val10).color.g, ((Graphic)val10).color.b, 0.4f); ((Shadow)obj5).effectDistance = new Vector2(1f, 1f); ((Shadow)obj5).useGraphicAlpha = true; effectPrefab.AddComponent(); effectPrefab.SetActive(false); Object.DontDestroyOnLoad((Object)(object)effectPrefab); } public void AddEffect(string name, float duration) { isAnchored = false; StatusEffect statusEffect = new StatusEffect(name, duration); GameObject val = Object.Instantiate(effectPrefab, (Transform)(object)container); val.SetActive(true); statusEffect.UIElement = val; val.GetComponent().Initialize(name, duration); TextMeshProUGUI componentInChildren = val.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)componentInChildren).text = name; } activeEffects.Add(statusEffect); } public void RemoveEffect(StatusEffect effect) { if (activeEffects.Contains(effect)) { activeEffects.Remove(effect); if ((Object)(object)effect.UIElement != (Object)null) { Object.Destroy((Object)(object)effect.UIElement); } } } public void ClearAllEffects() { foreach (StatusEffect item in new List(activeEffects)) { RemoveEffect(item); } activeEffects.Clear(); } private void Update() { if (!isAnchored) { TryAnchorToEnergyUI(); } } private GameObject FindActiveEnergyObject() { Transform[] array = Object.FindObjectsOfType(true); List list = new List(); Transform[] array2 = array; foreach (Transform val in array2) { if (((Object)((Component)val).gameObject).name == "Energy") { list.Add(((Component)val).gameObject); } } foreach (GameObject item in list) { if (item.activeInHierarchy) { return item; } } return null; } private void TryAnchorToEnergyUI() { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) GameObject val = FindActiveEnergyObject(); if ((Object)(object)val == (Object)null || !((Object)(object)val != (Object)null)) { return; } RectTransform component = val.GetComponent(); if (!((Object)(object)component != (Object)null)) { return; } Transform obj = val.transform.Find("HealthMax"); TextMeshProUGUI val2 = ((obj != null) ? ((Component)obj).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { TextMeshProUGUI[] componentsInChildren = ((Component)container).GetComponentsInChildren(true); foreach (TextMeshProUGUI obj2 in componentsInChildren) { ((TMP_Text)obj2).font = ((TMP_Text)val2).font; ((Graphic)obj2).color = ((Graphic)val2).color; ((TMP_Text)obj2).enableVertexGradient = false; } Image[] componentsInChildren2 = ((Component)container).GetComponentsInChildren(true); foreach (Image val3 in componentsInChildren2) { if (((Object)val3).name == "TimerCircle") { ((Graphic)val3).color = ((Graphic)val2).color; } } } ((Component)container).transform.SetParent(((Transform)component).parent, false); Vector2 anchoredPosition = component.anchoredPosition; ref float x = ref anchoredPosition.x; float num = x; Rect rect = component.rect; float num2 = ((Rect)(ref rect)).width * 0.5f; rect = container.rect; x = num + (num2 - ((Rect)(ref rect)).width * 0.5f + 10f); ref float y = ref anchoredPosition.y; float num3 = y; rect = component.rect; y = num3 - (((Rect)(ref rect)).height - 10f); container.anchoredPosition = anchoredPosition; isAnchored = true; } } public enum TimedType { INVINCIBLE, INFINITE_STAMINA, ANTI_GRAVITY, DISABLE_CROUCH, DISABLE_INPUT, FEATHER, SPEED, SLOW, PRAISE, KILL, PITCH } public class Timed { public TimedType type; private float old; public int duration; private static Dictionary customVariables = new Dictionary(); private static int frames = 0; public static T GetCustomVariable(string key) { if (customVariables.TryGetValue(key, out var value)) { return (T)value; } throw new KeyNotFoundException("Custom variable with key '" + key + "' not found."); } public void SetCustomVariables(Dictionary variables) { customVariables = variables; } public Timed(TimedType t, int duration) { type = t; this.duration = duration; } public void addEffect() { float durationInSeconds = (float)duration / 1000f; switch (type) { case TimedType.INVINCIBLE: CrowdControlMod.infiniteHealth = true; CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Infinite Health", durationInSeconds); MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Infinite Health activated", Color.green, Color.green, 1f); } }); break; case TimedType.INFINITE_STAMINA: CrowdControlMod.infiniteStamina = true; CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Infinite Stamina", durationInSeconds); MissionUI instance2 = Singleton.Instance; if (instance2 != null) { instance2.MissionText("CC Infinite Energy activated", Color.green, Color.green, 1f); } }); break; case TimedType.SPEED: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Fast Player", durationInSeconds); MissionUI instance3 = Singleton.Instance; if (instance3 != null) { instance3.MissionText("CC Increased Speed activated", Color.green, Color.green, 1f); } }); break; case TimedType.SLOW: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Slow Player", durationInSeconds); MissionUI instance4 = Singleton.Instance; if (instance4 != null) { instance4.MissionText("CC Decreased Speed activated", Color.green, Color.green, 1f); } }); break; case TimedType.ANTI_GRAVITY: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Anti-Gravity", durationInSeconds); MissionUI instance5 = Singleton.Instance; if (instance5 != null) { instance5.MissionText("CC Anti-Gravity activated", Color.green, Color.green, 1f); } }); break; case TimedType.DISABLE_CROUCH: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Crouch Disabled", durationInSeconds); MissionUI instance6 = Singleton.Instance; if (instance6 != null) { instance6.MissionText("CC Crouch is disabled", Color.red, Color.red, 1f); } }); break; case TimedType.DISABLE_INPUT: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Inputs Disabled", durationInSeconds); MissionUI instance7 = Singleton.Instance; if (instance7 != null) { instance7.MissionText("CC All inputs disabled", Color.red, Color.red, 1f); } }); break; case TimedType.FEATHER: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Low Gravity", durationInSeconds); MissionUI instance8 = Singleton.Instance; if (instance8 != null) { instance8.MissionText("CC Feather activated", Color.green, Color.green, 1f); } }); break; case TimedType.PITCH: CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) StatusEffectSystem.Instance.AddEffect("Funny Voice", durationInSeconds); MissionUI instance9 = Singleton.Instance; if (instance9 != null) { instance9.MissionText("CC Your voice feels funny.", Color.green, Color.green, 1f); } }); break; case TimedType.PRAISE: case TimedType.KILL: break; } } public static bool removeEffect(TimedType etype) { try { switch (etype) { case TimedType.INVINCIBLE: CrowdControlMod.infiniteHealth = false; CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance2 = Singleton.Instance; if (instance2 != null) { instance2.MissionText("CC Infinite Health deactivated", Color.red, Color.red, 1f); } }); break; case TimedType.INFINITE_STAMINA: CrowdControlMod.infiniteStamina = false; CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance8 = Singleton.Instance; if (instance8 != null) { instance8.MissionText("CC Infinite Energy deactivated", Color.red, Color.red, 1f); } }); break; case TimedType.SPEED: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Increased Speed deactivated", Color.red, Color.red, 1f); } }); break; case TimedType.SLOW: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance4 = Singleton.Instance; if (instance4 != null) { instance4.MissionText("CC Decrease Speed deactivated", Color.red, Color.red, 1f); } }); break; case TimedType.ANTI_GRAVITY: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance5 = Singleton.Instance; if (instance5 != null) { instance5.MissionText("CC Anti-Gravity deactivated", Color.red, Color.red, 1f); } }); break; case TimedType.DISABLE_CROUCH: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance7 = Singleton.Instance; if (instance7 != null) { instance7.MissionText("CC Crouch is re-enabled", Color.green, Color.green, 1f); } }); break; case TimedType.DISABLE_INPUT: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance3 = Singleton.Instance; if (instance3 != null) { instance3.MissionText("CC All inputs recovered", Color.green, Color.green, 1f); } }); break; case TimedType.FEATHER: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance6 = Singleton.Instance; if (instance6 != null) { instance6.MissionText("CC Feather deactivated", Color.red, Color.red, 1f); } }); break; case TimedType.PITCH: CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance9 = Singleton.Instance; if (instance9 != null) { instance9.MissionText("CC Your voice pitch has returned to normal.", Color.green, Color.green, 1f); } }); break; case TimedType.PRAISE: case TimedType.KILL: break; } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); return false; } return true; } public void tick() { frames++; _ = type; _ = 1; } } public class TimedThread { public static List threads = new List(); public readonly Timed effect; public int duration; public int remain; public int id; public bool paused; public static bool isRunning(TimedType t) { foreach (TimedThread thread in threads) { if (thread.effect.type == t) { return true; } } return false; } public static void tick() { foreach (TimedThread thread in threads) { if (!thread.paused) { thread.effect.tick(); } } } public static void addTime(int duration) { try { lock (threads) { foreach (TimedThread thread in threads) { Interlocked.Add(ref thread.duration, duration + 5); if (!thread.paused) { int dur = Volatile.Read(ref thread.remain); new TimedResponse(thread.id, dur, CrowdResponse.Status.STATUS_PAUSE).Send(ControlClient.Socket); thread.paused = true; } } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public static void tickTime(int duration) { try { lock (threads) { foreach (TimedThread thread in threads) { int num = Volatile.Read(ref thread.remain); num -= duration; if (num < 0) { num = 0; } Volatile.Write(ref thread.remain, num); } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public static void unPause() { try { lock (threads) { foreach (TimedThread thread in threads) { if (thread.paused) { int dur = Volatile.Read(ref thread.remain); new TimedResponse(thread.id, dur, CrowdResponse.Status.STATUS_RESUME).Send(ControlClient.Socket); thread.paused = false; } } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public TimedThread(int id, TimedType type, int duration, Dictionary customVariables = null) { effect = new Timed(type, duration); this.duration = duration; remain = duration; this.id = id; paused = false; if (customVariables == null) { customVariables = new Dictionary(); } effect.SetCustomVariables(customVariables); try { lock (threads) { threads.Add(this); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } public void Run() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; effect.addEffect(); bool flag = false; try { do { flag = false; for (int num = Volatile.Read(ref duration); num > 0; num = Volatile.Read(ref duration)) { Interlocked.Add(ref duration, -num); Thread.Sleep(num); } if (Timed.removeEffect(effect.type)) { lock (threads) { threads.Remove(this); } new TimedResponse(id, 0, CrowdResponse.Status.STATUS_STOP).Send(ControlClient.Socket); } else { flag = true; } } while (flag); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.ToString()); } } } [BepInPlugin("WarpWorld.CrowdControl", "Crowd Control", "1.5.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CrowdControlMod : BaseUnityPlugin { internal class CrowdControlConfig { public static ConfigEntry ccEnabled; public static ConfigEntry customPrefabs; public static ConfigEntry spawnEnemyMsg; public static ConfigEntry enemySpawnOnPatrolPath; public static ConfigEntry spawnedItemsRemainPurchased; public static ConfigEntry ssStoreSpawn; public CrowdControlConfig(ConfigFile cfg) { cfg.SaveOnConfigSet = false; ccEnabled = cfg.Bind("General", "Enabled", true, ""); customPrefabs = cfg.Bind("General", "Mod Required By All", true, ""); spawnEnemyMsg = cfg.Bind("General", "Spawn Enemy Messages", true, ""); enemySpawnOnPatrolPath = cfg.Bind("Enemy", "Spawn on patrol path", false, "When enabled, enemies spawn at patrol-path points near you (not at your feet). Uses the trigger player's setting. Shows a short 'spawned nearby' message with no countdown."); spawnedItemsRemainPurchased = cfg.Bind("General", "Given items persist btwn levels", true, ""); cfg.SaveOnConfigSet = true; ccEnabled.SettingChanged += delegate { mls.LogInfo((object)(ccEnabled.Value ? "Crowd Control is now enabled!" : "Crowd Control has been disabled!")); }; customPrefabs.SettingChanged += delegate { if (customPrefabsInitialized && !customPrefabs.Value) { ShowExitModal(); } if (!customPrefabsInitialized && customPrefabs.Value) { ShowExitModal(); } }; } } public class ExitHandler : MonoBehaviour { [CompilerGenerated] private sealed class d__0 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } if (MenuManager.instance.PageCheck((MenuPageIndex)9)) { <>2__current = null; <>1__state = 2; return true; } Application.Quit(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(d__0))] private IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0); } } [HarmonyPatch(typeof(GameDirector), "gameStateEnd")] private class Patch_GameDirector_End { private static void Prefix() { ControlClient.updatedEffects = false; } } [HarmonyPatch(typeof(RunManager))] [HarmonyPatch("OnApplicationQuit")] public class OnApplicationQuitPatch { private static bool Prefix() { try { if (ControlClient.Socket != null && ControlClient.Socket.Connected) { ControlClient.Socket.Shutdown(SocketShutdown.Both); ControlClient.Socket.Close(); ControlClient.Socket.Dispose(); } ControlClient.connected = false; new ControlClient().Stop(); mls.LogInfo((object)"ControlClient stopped successfully."); } catch (Exception arg) { mls.LogError((object)$"Error during application quit: {arg}"); } return true; } } [HarmonyPatch(typeof(PlayerHealth))] internal class PlayerHealthPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch(PlayerHealth __instance) { if (CrowdControlConfig.ccEnabled.Value) { Traverse.Create((object)__instance).Field("godMode").SetValue((object)infiniteHealth); } } } [HarmonyPatch(typeof(HealthUI), "Update")] public class Patch_HealthUI_Update { private static bool Prefix(HealthUI __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if (!CrowdControlConfig.ccEnabled.Value) { return true; } if (!infiniteHealth) { return true; } FieldInfo fieldInfo = AccessTools.Field(typeof(HealthUI), "Text"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(HealthUI), "textMaxHealth"); if (fieldInfo != null) { TextMeshProUGUI val = (TextMeshProUGUI)fieldInfo.GetValue(__instance); if ((Object)(object)val != (Object)null) { ((TMP_Text)val).text = "INFINITE"; } } if (fieldInfo2 != null) { TextMeshProUGUI val2 = (TextMeshProUGUI)fieldInfo2.GetValue(__instance); if ((Object)(object)val2 != (Object)null) { ((TMP_Text)val2).text = ""; } } return false; } } [HarmonyPatch(typeof(MissionUI), "MissionText")] public class MissionUITextPatch { private static void Postfix(MissionUI __instance) { if (!CrowdControlConfig.ccEnabled.Value) { return; } FieldInfo field = typeof(MissionUI).GetField("Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object? value = field.GetValue(__instance); TMP_Text val = (TMP_Text)((value is TMP_Text) ? value : null); if ((Object)(object)val != (Object)null && val.text.StartsWith("FOCUS > CC ")) { val.text = val.text.Replace("FOCUS >", "CrowdControl:").Replace("CC ", " "); } } } } [HarmonyPatch(typeof(EnergyUI), "Update")] public class Patch_EnergyUI_Update { private static bool Prefix(EnergyUI __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown if (!CrowdControlConfig.ccEnabled.Value) { return true; } if (!infiniteStamina) { return true; } FieldInfo fieldInfo = AccessTools.Field(typeof(EnergyUI), "Text"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(EnergyUI), "textEnergyMax"); if (fieldInfo != null) { TextMeshProUGUI val = (TextMeshProUGUI)fieldInfo.GetValue(__instance); if ((Object)(object)val != (Object)null) { ((TMP_Text)val).text = "INFINITE"; } } if (fieldInfo2 != null) { TextMeshProUGUI val2 = (TextMeshProUGUI)fieldInfo2.GetValue(__instance); if ((Object)(object)val2 != (Object)null) { ((TMP_Text)val2).text = ""; } } return false; } } [HarmonyPatch(typeof(MenuPageLobby), "PlayerAdd")] public static class PlayerAddPatch { private static void Postfix(PlayerAvatar player) { FieldInfo field = typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { _ = field.GetValue(player) is string; } PhotonNetwork.CurrentRoom.GetPlayer(PhotonNetwork.LocalPlayer.ActorNumber, false); RPCCommands.MessageHandler.SendMessageToHost("CC_CONNECT", 0, PhotonNetwork.LocalPlayer.ActorNumber, PhotonNetwork.LocalPlayer.ActorNumber, new Dictionary { { "version", "1.5.0.0" } }); } } [HarmonyPatch(typeof(MenuPageLobby), "Update")] public static class MenuPageLobbyPatch { private static void Postfix(MenuPageLobby __instance) { if (!CrowdControlConfig.ccEnabled.Value) { return; } FieldInfo field = typeof(MenuPageLobby).GetField("listObjects", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null || !(field.GetValue(__instance) is List list)) { return; } foreach (GameObject item in list) { MenuPlayerListed component = item.GetComponent(); if ((Object)(object)component == (Object)null) { continue; } FieldInfo field2 = typeof(MenuPlayerListed).GetField("playerAvatar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null) { continue; } object? value = field2.GetValue(component); PlayerAvatar val = (PlayerAvatar)((value is PlayerAvatar) ? value : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.photonView == (Object)null)) { string key = (typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(val) as string) ?? "0"; string value2; bool flag = PlayerVersions.TryGetValue(key, out value2); string text = (flag ? ("Crowd Control v" + value2) : ((CrowdControlConfig.customPrefabs.Value || customPrefabsInitialized) ? "Crowd Control Not Found and is Required" : "Crowd Control Not Found")); string text2 = ((flag && value2 == "1.5.0.0") ? "00FF00" : "FF0000"); string text3 = "" + text + ""; string text4 = (typeof(PlayerAvatar).GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(val) as string) ?? "Unknown Player"; if (val.photonView.Owner == PhotonNetwork.MasterClient) { ((TMP_Text)component.playerName).richText = true; ((TMP_Text)component.playerName).text = (flag ? ("CrowdControl v" + value2 + "\n" + text4 + " [HOST]") : ("HOST REQUIRES CROWD CONTROL\n" + text4 + " [HOST]")); } else { ((TMP_Text)component.playerName).richText = true; ((TMP_Text)component.playerName).text = "" + text3 + "\n" + text4; } } } } } [HarmonyPatch(typeof(MenuPageMain))] internal class MenuPageNamePatch { [HarmonyPatch("ButtonEventSinglePlayer")] [HarmonyPostfix] private static void ButtonEventSinglePlayerPatch() { if (!hasSeenWarning && CrowdControlConfig.ccEnabled.Value && ControlClient.connected) { ShowCrowdControlEnabledModal(); hasSeenWarning = true; } } } [HarmonyPatch(typeof(PlayerController))] internal class PlayerStaminaPatch { [HarmonyPatch("Update")] [HarmonyPatch("FixedUpdate")] [HarmonyPostfix] private static void InfiniteStaminaPatch(PlayerController __instance) { if (CrowdControlConfig.ccEnabled.Value) { if (__instance.sprinting && infiniteStamina) { __instance.EnergyCurrent = __instance.EnergyStart; } else if (__instance.Sliding && infiniteStamina) { __instance.EnergyCurrent = __instance.EnergyStart; } } } } private const string modGUID = "WarpWorld.CrowdControl"; private const string modName = "Crowd Control"; public const string modVersion = "1.5.0.0"; private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl"); public static ManualLogSource mls; internal static CrowdControlMod Instance = null; private ControlClient client; public static bool customPrefabsInitialized = false; public static bool clientMissingCrowdControl = false; public static bool isFocused = true; public static bool modActivated = false; public static bool infiniteHealth = false; public static bool infiniteStamina = false; public static GameObject breadPrefab = null; public static GameObject milkPrefab = null; public static GameObject eggsPrefab = null; public static Dictionary PlayerVersions = new Dictionary(); public static GameObject hypeTrainPrefab = null; public static Queue ActionQueue = new Queue(); private static bool hasSeenWarning = false; internal CrowdControlConfig BoundConfig { get; private set; } public static void ShowPopUpMessage(string header, string message) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MenuManager.instance == (Object)null) { Debug.LogError((object)"MenuManager is not available!"); return; } Color red = Color.red; string text = "Okay"; MenuManager.instance.PagePopUp(header, red, message, text, false); } public static void ShowExitModal() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)MenuManager.instance == (Object)null)) { string text = "Game Restart Required"; Color red = Color.red; string text2 = "Please close and reopen the game for changes to take effect."; string text3 = "Okay"; MenuManager.instance.PagePopUp(text, red, text2, text3, false); new GameObject("ExitHandler").AddComponent(); } } public static void ShowCrowdControlEnabledModal() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)MenuManager.instance == (Object)null)) { string text = "Crowd Control Enabled"; Color yellow = Color.yellow; string text2 = "Crowd Control only works in multiplayer. Please go back and select Multiplayer if you are looking to use it."; string text3 = "Okay"; MenuManager.instance.PagePopUp(text, yellow, text2, text3, false); } } private void Awake() { Instance = this; BoundConfig = new CrowdControlConfig(((BaseUnityPlugin)this).Config); mls = Logger.CreateLogSource("Crowd Control"); mls.LogInfo((object)"Loaded WarpWorld.CrowdControl. Patching."); harmony.PatchAll(typeof(CrowdControlMod)); harmony.PatchAll(); if (CrowdControlConfig.customPrefabs.Value) { customPrefabsInitialized = true; mls.LogInfo((object)"Custom Prefabs Enabled"); } if (CrowdControlConfig.ccEnabled.Value) { mls.LogInfo((object)"Initializing Crowd Control"); } if (!CrowdControlConfig.ccEnabled.Value) { mls.LogWarning((object)"Crowd Control Mod Not Enabled"); } string? directoryName = Path.GetDirectoryName(typeof(CrowdControlMod).Assembly.Location); string text = Path.Combine(directoryName, "food"); Path.Combine(directoryName, "warpworld.hypetrain"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { mls.LogError((object)("Failed to load AssetBundle from " + text)); } if ((Object)(object)val != (Object)null && CrowdControlConfig.customPrefabs.Value) { string text2 = "assets/repo/mods/collectables/milk.prefab"; string text3 = "assets/repo/mods/collectables/bread.prefab"; string text4 = "assets/repo/mods/collectables/eggs.prefab"; breadPrefab = val.LoadAsset(text3); if ((Object)(object)breadPrefab == (Object)null) { mls.LogError((object)$"Failed to load '{text3}' from asset bundle {val}"); } milkPrefab = val.LoadAsset(text2); if ((Object)(object)milkPrefab == (Object)null) { mls.LogError((object)$"Failed to load '{text2}' from asset bundle {val}"); } eggsPrefab = val.LoadAsset(text4); if ((Object)(object)eggsPrefab == (Object)null) { mls.LogError((object)$"Failed to load '{text4}' from asset bundle {val}"); } if ((Object)(object)breadPrefab != (Object)null) { Valuables.RegisterValuable(breadPrefab); } if ((Object)(object)milkPrefab != (Object)null) { Valuables.RegisterValuable(milkPrefab); } if ((Object)(object)eggsPrefab != (Object)null) { Valuables.RegisterValuable(eggsPrefab); } } try { client = new ControlClient(); new Thread(client.NetworkLoop).Start(); new Thread(client.RequestLoop).Start(); } catch (Exception ex) { mls.LogInfo((object)("CC Init Error: " + ex.ToString())); } mls = ((BaseUnityPlugin)this).Logger; } [HarmonyPatch(typeof(PunManager), "Update")] [HarmonyPrefix] private static void RunEffects() { while (ActionQueue.Count > 0) { ActionQueue.Dequeue()(); } lock (TimedThread.threads) { foreach (TimedThread thread in TimedThread.threads) { if (!thread.paused) { thread.effect.tick(); } } } } } public class ControlClient { public static readonly string CV_HOST = "127.0.0.1"; public static readonly int CV_PORT = 51337; private bool paused; public static bool connected = false; public static bool setName = false; public static bool resetName = false; public static bool disableLogging = true; public bool inGame = true; public bool questMessage; public static string currentLevel = ""; public static int playerCount = 0; public static bool updatedEffects = false; public static bool customPrefabsEffectsUpdate = false; private Dictionary Delegate { get; set; } private IPEndPoint Endpoint { get; set; } private Queue Requests { get; set; } private bool Running { get; set; } public static Socket Socket { get; set; } public ControlClient() { Endpoint = new IPEndPoint(IPAddress.Parse(CV_HOST), CV_PORT); Requests = new Queue(); Running = true; Socket = null; Delegate = new Dictionary { { "player_invincible", (ControlClient client, CrowdRequest req) => new PlayerInvincibleEffect(client, req).Execute() }, { "player_infinitestam", (ControlClient client, CrowdRequest req) => new PlayerInfiniteStaminaEffect(client, req).Execute() }, { "player_antigravity", (ControlClient client, CrowdRequest req) => new PlayerAntiGravityEffect(client, req).Execute() }, { "player_disablecrouch", (ControlClient client, CrowdRequest req) => new PlayerDisableCrouchEffect(client, req).Execute() }, { "player_disableinput", (ControlClient client, CrowdRequest req) => new PlayerDisableInputEffect(client, req).Execute() }, { "player_feather", (ControlClient client, CrowdRequest req) => new PlayerFeatherEffect(client, req).Execute() }, { "player_fast", (ControlClient client, CrowdRequest req) => new PlayerSpeedEffect(client, req).Execute() }, { "player_slow", (ControlClient client, CrowdRequest req) => new PlayerSpeedSlowEffect(client, req).Execute() }, { "player_drain_energy", (ControlClient client, CrowdRequest req) => new PlayerDrainEnergyEffect(client, req).Execute() }, { "player_refill_energy", (ControlClient client, CrowdRequest req) => new PlayerRefillEnergyEffect(client, req).Execute() }, { "randomPlayer_heal", (ControlClient client, CrowdRequest req) => new PlayerHealEffect(client, req).Execute() }, { "randomPlayer_hurt", (ControlClient client, CrowdRequest req) => new PlayerHurtEffect(client, req).Execute() }, { "randomPlayer_revive", (ControlClient client, CrowdRequest req) => new PlayerReviveEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ItemRubberDuck", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableWizardDumgolfsStaff", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableBottle", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableChompBook", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableClown", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableFan", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableFrog", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableMusicBox", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableArcticPropaneTank", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableGramophone", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableRadio", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableTelevision", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableToyMonkey", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableAnimalCrate", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableGrandfatherClock", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableIceSaw", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableArcticBarrel", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawnActivatedItem_ValuableWizardBroom", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "randomSpawncustom_Bread", (ControlClient client, CrowdRequest req) => new SpawnCustomItemEffect(client, req).Execute() }, { "randomSpawncustom_Milk", (ControlClient client, CrowdRequest req) => new SpawnCustomItemEffect(client, req).Execute() }, { "randomSpawncustom_Eggs", (ControlClient client, CrowdRequest req) => new SpawnCustomItemEffect(client, req).Execute() }, { "randomPlayerupgrade_energy", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_health", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_map", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_jump", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_grabrange", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_grabstrength", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_sprint", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_throw", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayerupgrade_tumble", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "randomPlayer_teleport", (ControlClient client, CrowdRequest req) => new PlayerTeleportEffect(client, req).Execute() }, { "randomPlayer_teleport_extraction", (ControlClient client, CrowdRequest req) => new PlayerTeleportToExtractionEffect(client, req).Execute() }, { "player_heal", (ControlClient client, CrowdRequest req) => new PlayerHealEffect(client, req).Execute() }, { "player_hurt", (ControlClient client, CrowdRequest req) => new PlayerHurtEffect(client, req).Execute() }, { "player_revive", (ControlClient client, CrowdRequest req) => new PlayerReviveEffect(client, req).Execute() }, { "praise_crowd_control", (ControlClient client, CrowdRequest req) => new PraiseCrowdControlEffect(client, req).Execute() }, { "player_teleport", (ControlClient client, CrowdRequest req) => new PlayerTeleportEffect(client, req).Execute() }, { "player_teleport_extraction", (ControlClient client, CrowdRequest req) => new PlayerTeleportToExtractionEffect(client, req).Execute() }, { "destroy_random_item", (ControlClient client, CrowdRequest req) => new DamageRandomValuableEffect(client, req).Execute() }, { "playerPitch_high", (ControlClient client, CrowdRequest req) => new PlayerVoiceOverrideEffect(client, req).Execute() }, { "playerPitch_low", (ControlClient client, CrowdRequest req) => new PlayerVoiceOverrideEffect(client, req).Execute() }, { "closeAllDoors", (ControlClient client, CrowdRequest req) => new CloseAllDoors(client, req).Execute() }, { "increase_loot_goal", (ControlClient client, CrowdRequest req) => new UpdateHaulGoalEffect(client, req).Execute() }, { "decrease_loot_goal", (ControlClient client, CrowdRequest req) => new UpdateHaulGoalEffect(client, req).Execute() }, { "playerupgrade_energy", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_health", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_map", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_jump", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_grabrange", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_grabstrength", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_sprint", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_throw", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "playerupgrade_tumble", (ControlClient client, CrowdRequest req) => new UpgradePlayerEffect(client, req).Execute() }, { "killplayer", (ControlClient client, CrowdRequest req) => new PlayerKillEffect(client, req).Execute() }, { "spawnenemy", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawncustom_Bread", (ControlClient client, CrowdRequest req) => new SpawnCustomItemEffect(client, req).Execute() }, { "spawncustom_Milk", (ControlClient client, CrowdRequest req) => new SpawnCustomItemEffect(client, req).Execute() }, { "spawncustom_Eggs", (ControlClient client, CrowdRequest req) => new SpawnCustomItemEffect(client, req).Execute() }, { "spawncollectable_ItemCartMedium", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemCartSmall", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemDroneBattery", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemDroneFeather", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemDroneIndestructible", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemDroneTorque", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemDroneZeroGravity", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemExtractionTracker", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGrenadeDuctTaped", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGrenadeExplosive", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGrenadeHuman", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGrenadeShockwave", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGrenadeStun", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGunHandgun", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGunShotgun", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemGunTranq", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemHealthPackLarge", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemHealthPackMedium", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemHealthPackSmall", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMeleeBaseballBat", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMeleeFryingPan", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMeleeInflatableHammer", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMeleeSledgeHammer", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMeleeSword", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMineExplosive", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMineShockwave", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemMineStun", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemOrbZeroGravity", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemPowerCrystal", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemRubberDuck", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradeMapPlayerCount", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerEnergy", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerExtraJump", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerGrabRange", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerGrabStrength", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerGrabThrow", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerHealth", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerSprintSpeed", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemUpgradePlayerTumbleLaunch", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ItemValuableTracker", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableDiamond", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableEmeraldBracelet", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableGoblet", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableOcarina", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuablePocketWatch", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableUraniumMug", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticBonsai", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticHDD", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableChompBook", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableCrown", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableDoll", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableFrog", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableGemBox", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableGlobe", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableLovePotion", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableMoney", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableMusicBox", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableToyMonkey", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableUraniumPlate", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableVaseSmall", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArctic3DPrinter", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticLaptop", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticPropaneTank", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticSampleSixPack", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticSample", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableBottle", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableClown", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableComputer", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableFan", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableGramophone", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableMarbleTable", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableRadio", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableShipInBottle", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableTrophy", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableVase", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardGoblinHead", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardPowerCrystal", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardTimeGlass", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticBarrel", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticBigSample", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticCreatureLeg", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticFlamethrower", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticGuitar", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticSampleCooler", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableDiamondDisplay", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableIceSaw", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableScreamDoll", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableTelevision", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableVaseBig", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardCubeOfKnowledge", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardMasterPotion", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableAnimalCrate", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticIceBlock", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableDinosaur", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuablePiano", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardGriffinStatue", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticScienceStation", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableHarp", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuablePainting", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardDumgolfsStaff", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardSword", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableArcticServerRack", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableGoldenStatue", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableGrandfatherClock", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawncollectable_ValuableWizardBroom", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ItemRubberDuck", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableWizardDumgolfsStaff", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableBottle", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableChompBook", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableClown", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableFan", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableFrog", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableMusicBox", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableArcticPropaneTank", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableGramophone", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableRadio", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableTelevision", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableToyMonkey", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableAnimalCrate", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableGrandfatherClock", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableIceSaw", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableArcticBarrel", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnActivatedItem_ValuableWizardBroom", (ControlClient client, CrowdRequest req) => new SpawnCollectableEffect(client, req).Execute() }, { "spawnEnemy_Robe", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Duck", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Head", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Runner", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Animal", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Floater", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Tumbler", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Bowtie", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Hunter", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Beamer", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Upscream", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_SlowMouth", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_ValuableThrower", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_ThinMan", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_SlowWalker", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Banger", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Gnome", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Peeper", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Hidden", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Tick", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Elsa", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_BombThrower", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Birthdayboy", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_HeadGrabber", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_HeartHugger", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Oogly", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Tricycle", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Spinny", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemy_Shadow", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Robe", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Duck", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Head", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Runner", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Animal", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Floater", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Tumbler", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Bowtie", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Hunter", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Beamer", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Upscream", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_SlowMouth", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_ValuableThrower", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_ThinMan", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_SlowWalker", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Banger", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Gnome", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Peeper", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() }, { "spawnEnemyRandom_Hidden", (ControlClient client, CrowdRequest req) => new SpawnEnemyEffect(client, req).Execute() } }; } public static bool IsExcludedLevel(Level currentLevel) { if ((Object)(object)currentLevel == (Object)null || (Object)(object)RunManager.instance == (Object)null) { return false; } HashSet excludedLevels = new HashSet(); AddExcluded(RunManager.instance.levelShop); AddExcluded(RunManager.instance.levelLobby); AddExcluded(RunManager.instance.levelArena); AddExcluded(RunManager.instance.levelTutorial); AddExcluded(RunManager.instance.levelLobbyMenu); AddExcluded(RunManager.instance.levelMainMenu); AddExcluded(RunManager.instance.levelRecording); return excludedLevels.Contains(currentLevel); void AddExcluded(object value) { if (value != null) { if (value is List list) { foreach (Level item in list) { if ((Object)(object)item != (Object)null) { excludedLevels.Add(item); } } return; } Level val = (Level)((value is Level) ? value : null); if (val != null) { excludedLevels.Add(val); } } } } public static void updateEffects() { updatedEffects = true; string[] collection = new string[36] { "randomPlayer_heal", "randomPlayer_hurt", "randomPlayer_revive", "randomPlayerupgrade_energy", "randomPlayerupgrade_health", "randomPlayerupgrade_map", "randomPlayerupgrade_jump", "randomPlayerupgrade_grabrange", "randomPlayerupgrade_grabstrength", "randomPlayerupgrade_sprint", "randomPlayerupgrade_throw", "randomPlayerupgrade_tumble", "randomSpawnActivatedItem_ItemRubberDuck", "randomSpawnActivatedItem_ValuableBottle", "randomSpawnActivatedItem_ValuableWizardDumgolfsStaff", "randomSpawnActivatedItem_ValuableChompBook", "randomSpawnActivatedItem_ValuableClown", "randomSpawnActivatedItem_ValuableFan", "randomSpawnActivatedItem_ValuableFrog", "randomSpawnActivatedItem_ValuableMusicBox", "randomSpawnActivatedItem_ValuableArcticPropaneTank", "randomSpawnActivatedItem_ValuableGramophone", "randomSpawnActivatedItem_ValuableRadio", "randomSpawnActivatedItem_ValuableTelevision", "randomSpawnActivatedItem_ValuableToyMonkey", "randomSpawnActivatedItem_ValuableAnimalCrate", "randomSpawnActivatedItem_ValuableGrandfatherClock", "randomSpawnActivatedItem_ValuableIceSaw", "randomSpawnActivatedItem_ValuableArcticBarrel", "randomSpawnActivatedItem_ValuableWizardBroom", "randomSpawncustom_Bread", "randomSpawncustom_Milk", "randomSpawncustom_Eggs", "player_teleport", "randomPlayer_teleport", "randomPlayer_teleport_extraction" }; string[] collection2 = new string[2] { "playerPitch_high", "playerPitch_low" }; string[] codes = new string[3] { "spawncustom_Bread", "spawncustom_Milk", "spawncustom_Eggs" }; if (!customPrefabsEffectsUpdate) { if (CrowdControlMod.customPrefabsInitialized) { ShowEffect(codes); } else { HideEffect(codes); } customPrefabsEffectsUpdate = true; } if (playerCount == GameDirector.instance.PlayerList.Count) { return; } playerCount = GameDirector.instance.PlayerList.Count; if (GameDirector.instance.PlayerList.Count == 1) { List list = new List(collection); list.AddRange(collection2); HideEffect(list.ToArray()); return; } List list2 = new List(collection); if (CrowdControlMod.customPrefabsInitialized) { list2.AddRange(collection2); } ShowEffect(list2.ToArray()); } public static (bool status, string? message) IsReady() { if (!CrowdControlMod.CrowdControlConfig.ccEnabled.Value) { return (false, "Crowd Control not enabled in Mods menu."); } if (!Object.op_Implicit((Object)(object)RunManager.instance)) { return (false, "Game is not ready."); } if (currentLevel != ((object)RunManager.instance.levelCurrent).ToString() && !CrowdControlMod.modActivated) { RPCCommands.MessageHandler.SendMessageToHost("CC_CONNECT", 0, PhotonNetwork.LocalPlayer.ActorNumber, 0, new Dictionary { { "version", "1.5.0.0" } }); } currentLevel = ((object)RunManager.instance.levelCurrent).ToString(); if (IsExcludedLevel(RunManager.instance.levelCurrent)) { return (false, "Not in supported level."); } if (!GameManager.Multiplayer()) { return (false, "Only available in Multiplayer."); } if (!CrowdControlMod.modActivated) { return (false, "Version does not match host."); } TruckScreenText instance = TruckScreenText.instance; FieldInfo field = typeof(TruckScreenText).GetField("started", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return (false, null); } if (!(bool)field.GetValue(instance)) { return (false, ""); } if (!disableLogging) { CrowdControlMod.mls.LogInfo((object)"Success: All checks passed"); } if (!updatedEffects) { updateEffects(); } return (true, ""); } public static void HideEffect(params string[] codes) { new EffectUpdateModern(EffectUpdateModern.Status.STATUS_NOTVISIBLE, codes).Send(Socket); } public static void ShowEffect(params string[] codes) { new EffectUpdateModern(EffectUpdateModern.Status.STATUS_VISIBLE, codes).Send(Socket); } public static void DisableEffect(params string[] codes) { new EffectUpdateModern(EffectUpdateModern.Status.STATUS_NOTSELECTABLE, codes).Send(Socket); } public static void EnableEffect(params string[] codes) { new EffectUpdateModern(EffectUpdateModern.Status.STATUS_SELECTABLE, codes).Send(Socket); } private void ClientLoop() { if (CrowdControlMod.CrowdControlConfig.ccEnabled.Value) { CrowdControlMod.mls.LogInfo((object)"Connected to Crowd Control"); } Timer timer = new Timer(timeUpdate, null, 0, 200); try { while (Running && CrowdControlMod.CrowdControlConfig.ccEnabled.Value) { try { if (Socket == null || !Socket.Connected) { break; } connected = true; CrowdControlMod.CrowdControlConfig.ccEnabled.Value = true; CrowdRequest crowdRequest = CrowdRequest.Recieve(this, Socket); if (crowdRequest != null && !crowdRequest.IsKeepAlive()) { lock (Requests) { Requests.Enqueue(crowdRequest); } } continue; } catch (ObjectDisposedException) { break; } catch (SocketException) { break; } catch (ThreadAbortException) { Thread.ResetAbort(); break; } catch (Exception) { } } } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Critical Error: {arg}"); } finally { if (CrowdControlMod.CrowdControlConfig.ccEnabled.Value) { CrowdControlMod.mls.LogInfo((object)"Disconnected from Crowd Control."); } connected = false; try { if (Socket != null) { Socket.Dispose(); } timer.Dispose(); } catch (Exception) { } } } public void timeUpdate(object state) { inGame = true; if (!IsReady().status) { inGame = false; } if (!inGame) { TimedThread.addTime(200); paused = true; } else if (paused) { paused = false; TimedThread.unPause(); TimedThread.tickTime(200); } else { TimedThread.tickTime(200); } } public bool IsRunning() { return Running; } public void NetworkLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (Running) { if (CrowdControlMod.CrowdControlConfig.ccEnabled.Value) { CrowdControlMod.mls.LogInfo((object)"Attempting to connect to Crowd Control"); } connected = false; try { Socket = new Socket(Endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, optionValue: true); if (Socket.BeginConnect(Endpoint, null, null).AsyncWaitHandle.WaitOne(10000, exitContext: true) && Socket.Connected) { ClientLoop(); } else { CrowdControlMod.mls.LogInfo((object)"Failed to connect to Crowd Control"); connected = false; } Socket.Close(); } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)ex.GetType().Name); CrowdControlMod.mls.LogInfo((object)"Failed to connect to Crowd Control"); connected = false; } Thread.Sleep(10000); } } public void RequestLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (Running) { try { CrowdRequest crowdRequest = null; lock (Requests) { if (Requests.Count == 0) { continue; } crowdRequest = Requests.Dequeue(); goto IL_0052; } IL_0052: string reqCode = crowdRequest.GetReqCode(); try { (bool status, string? message) tuple = IsReady(); bool item = tuple.status; string item2 = tuple.message; CrowdResponse crowdResponse = (item ? Delegate[reqCode](this, crowdRequest) : new CrowdResponse(crowdRequest.GetReqID(), (!(item2 == "")) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_RETRY, item2)); if (crowdResponse == null) { new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Request error for '" + reqCode + "'").Send(Socket); } crowdResponse.Send(Socket); } catch (KeyNotFoundException) { new CrowdResponse(crowdRequest.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Request error for '" + reqCode + "'").Send(Socket); } } catch (Exception) { if (CrowdControlMod.CrowdControlConfig.ccEnabled.Value) { CrowdControlMod.mls.LogInfo((object)"Disconnected from Crowd Control."); } connected = false; Socket.Close(); } } } public void Stop() { Running = false; } } public delegate CrowdResponse CrowdDelegate(ControlClient client, CrowdRequest req); public class CrowdDelegates { public static Random rnd = new Random(); public static readonly TimeSpan SERVER_TIMEOUT = TimeSpan.FromSeconds(5.0); public static void setProperty(object a, string prop, object val) { PropertyInfo property = a.GetType().GetProperty(prop, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(a, val); } } public static object getProperty(object a, string prop) { return a.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(a); } public static void setSubProperty(object a, string prop, string prop2, object val) { FieldInfo field = a.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic); field.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(field, val); } public static void callSubFunc(object a, string prop, string func, object val) { callSubFunc(a, prop, func, new object[1] { val }); } public static void callSubFunc(object a, string prop, string func, object[] vals) { FieldInfo field = a.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.NonPublic); field.GetType().GetMethod(func, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy).Invoke(field, vals); } public static void callFunc(object a, string func, object val) { callFunc(a, func, new object[1] { val }); } public static void callFunc(object a, string func, object[] vals) { a.GetType().GetMethod(func, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(a, vals); } public static object callAndReturnFunc(object a, string func, object val) { return callAndReturnFunc(a, func, new object[1] { val }); } public static object callAndReturnFunc(object a, string func, object[] vals) { return a.GetType().GetMethod(func, BindingFlags.Instance | BindingFlags.NonPublic).Invoke(a, vals); } } public class CrowdRequest { public enum Type { REQUEST_TEST = 0, REQUEST_START = 1, REQUEST_STOP = 2, REQUEST_KEEPALIVE = 255 } public class Target { public string service; public string id; public string name; public string avatar; } public class SourceDetails { public class Contribution { public string user_id; public string user_login; public string user_name; public string type; public int total; } public int total; public int progress; public int goal; public Contribution[] top_contributions; public Contribution last_contribution; public int level; } public static readonly int RECV_BUF = 4096; public static readonly int RECV_TIME = 5000000; public string code; public int id; public int duration; public string type; public string viewer; public Target[] targets; public SourceDetails sourceDetails; public static CrowdRequest Recieve(ControlClient client, Socket socket) { byte[] array = new byte[RECV_BUF]; string text = ""; int num = 0; do { if (!client.IsRunning()) { return null; } if (socket.Poll(RECV_TIME, SelectMode.SelectRead)) { num = socket.Receive(array); if (num < 0) { return null; } text += Encoding.ASCII.GetString(array); } else { CrowdResponse.KeepAlive(socket); } } while (num == 0 || (num == RECV_BUF && array[RECV_BUF - 1] != 0)); return JsonConvert.DeserializeObject(text); } public string GetReqCode() { return code; } public int GetReqID() { return id; } public int GetReqDuration() { return duration; } public Type GetReqType() { string text = type; if (text == "1") { return Type.REQUEST_START; } if (text == "2") { return Type.REQUEST_STOP; } return Type.REQUEST_TEST; } public string GetReqViewer() { return viewer; } public bool IsKeepAlive() { if (id == 0) { return type == "255"; } return false; } } public class CrowdResponse { public enum Status { STATUS_SUCCESS = 0, STATUS_FAILURE = 1, STATUS_UNAVAIL = 2, STATUS_RETRY = 3, STATUS_START = 5, STATUS_PAUSE = 6, STATUS_RESUME = 7, STATUS_STOP = 8, STATUS_KEEPALIVE = 255 } public int id; public string message; public string code; public int status; public int type; public CrowdResponse(int id, Status status = Status.STATUS_SUCCESS, string message = "") { type = 0; code = ""; this.id = id; this.message = message; this.status = (int)status; } public static void KeepAlive(Socket socket) { new CrowdResponse(0, Status.STATUS_KEEPALIVE).Send(socket); } public void Send(Socket socket) { byte[] bytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject((object)this)); byte[] array = new byte[bytes.Length + 1]; Buffer.BlockCopy(bytes, 0, array, 0, bytes.Length); array[bytes.Length] = 0; socket.Send(array); } } public class RPCCommands { [HarmonyPatch(typeof(NetworkManager))] [HarmonyPatch("Start")] public class NetworkManagerPatch { public static void Postfix() { MessageHandler.Initialize(); } } public class MessageHandler : MonoBehaviourPunCallbacks, IPunObservable { public class NetworkMessage { public string type; public int id; public int targetActor; public int senderID; public Dictionary payload; public NetworkMessage(string type, int id = 0, int senderID = 0, int targetActor = 0, Dictionary payload = null) { this.type = type; this.payload = payload ?? new Dictionary(); this.id = id; this.senderID = senderID; this.targetActor = targetActor; } } private class RequestMessage { public string type { get; set; } public Dictionary payload { get; set; } public int id { get; set; } public int senderID { get; set; } public int targetActor { get; set; } public bool random { get; set; } } private class ResponseMessage { public string type { get; set; } = "response"; public int id { get; set; } public int senderID { get; set; } public int targetActor { get; set; } public string status { get; set; } public string message { get; set; } public string version { get; set; } public Dictionary payload { get; set; } } [CompilerGenerated] private sealed class d__15 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public int id; public int senderID; public bool success; 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() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; SendResponse(id, senderID, (!success) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static MessageHandler instance; public static PhotonView networkView; private static ConcurrentQueue messageQueue = new ConcurrentQueue(); public static void Initialize() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)instance != (Object)null) { return; } CrowdControlMod.mls.LogInfo((object)"Initializing MessageHandler..."); GameObject val = new GameObject("MessageHandler"); instance = val.AddComponent(); networkView = val.AddComponent(); if ((Object)(object)networkView != (Object)null) { networkView.ViewID = 6767; networkView.Synchronization = (ViewSynchronization)3; networkView.ObservedComponents = new List { (Component)(object)instance }; CrowdControlMod.mls.LogInfo((object)$"MessageHandler initialized with PhotonView {networkView.ViewID}"); Object.DontDestroyOnLoad((Object)(object)val); lock (networkLock) { _isNetworkReady = null; _isViewValid = null; return; } } CrowdControlMod.mls.LogError((object)"Failed to add PhotonView to MessageHandler"); CrowdControlMod.modActivated = false; } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error in Initialize: " + ex.Message)); CrowdControlMod.mls.LogError((object)("Stack trace: " + ex.StackTrace)); } } private void OnLevelWasLoaded(int level) { lock (networkLock) { _isNetworkReady = null; _isViewValid = null; } if ((Object)(object)networkView == (Object)null || !networkView.ViewID.Equals(6767)) { Initialize(); } } private void Update() { if (messageQueue.TryDequeue(out var result)) { SendQueuedMessage(result); } } private static void SendQueuedMessage(NetworkMessage message) { if (IsNetworkReady()) { try { string text = JsonConvert.SerializeObject((object)message); PhotonNetwork.CurrentRoom.GetPlayer(message.senderID, false); networkView.RPC("OnNetworkMessageRPC", (RpcTarget)0, new object[1] { text }); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Failed to send message: " + ex.Message)); CrowdControlMod.mls.LogError((object)("Stack trace: " + ex.StackTrace)); } } } public static void SendMessageToHost(string type, int id = 0, int senderID = 0, int targetActor = 0, Dictionary payload = null) { try { if (!IsNetworkReady()) { return; } NetworkMessage item = new NetworkMessage(type, id, senderID, targetActor, payload); if (id > 0) { lock (pendingRequestIDs) { pendingRequestIDs.Add(id.ToString()); } } messageQueue.Enqueue(item); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to queue message: {arg}"); } } public override void OnEnable() { ((MonoBehaviourPunCallbacks)this).OnEnable(); } public override void OnJoinedRoom() { ((MonoBehaviourPunCallbacks)this).OnJoinedRoom(); lock (networkLock) { _isNetworkReady = null; _isViewValid = null; } CrowdControlMod.modActivated = false; if (PhotonNetwork.IsMasterClient) { CrowdControlMod.modActivated = true; } } [PunRPC] public void OnNetworkMessageRPC(string jsonMessage) { try { NetworkMessage networkMessage = JsonConvert.DeserializeObject(jsonMessage); if (networkMessage == null) { CrowdControlMod.mls.LogError((object)"Failed to deserialize message"); return; } if (networkMessage.type == "response") { ProcessMessage(jsonMessage); return; } if (networkMessage.type == "CC_CONNECT") { ModVersionCheck(networkMessage); return; } if (networkMessage.type == "override_voice") { PlayerVoiceOverrideEffect.Trigger(networkMessage); } if (PhotonNetwork.IsMasterClient) { switch (networkMessage.type) { case "spawn_collectable": SpawnCollectableEffect.Trigger(networkMessage); break; case "spawn_custom": SpawnCustomItemEffect.Trigger(networkMessage); break; case "player_heal": PlayerHealEffect.Trigger(networkMessage); break; case "player_hurt": PlayerHurtEffect.Trigger(networkMessage); break; case "player_revive": PlayerReviveEffect.Trigger(networkMessage); break; case "destroy_random_item": DamageRandomValuableEffect.Trigger(networkMessage); break; case "player_teleport": PlayerTeleportEffect.Trigger(networkMessage); break; case "close_doors": CloseAllDoors.Trigger(networkMessage); break; case "update_haul": UpdateHaulGoalEffect.Trigger(networkMessage); break; case "upgrade_player": UpgradePlayerEffect.Trigger(networkMessage); break; case "spawn_enemy": SpawnEnemyEffect.Trigger(networkMessage); break; default: CrowdControlMod.mls.LogWarning((object)("Unknown message type: " + networkMessage.type)); break; case "override_voice": break; } } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Failed to process message: " + ex.Message)); CrowdControlMod.mls.LogError((object)("Stack trace: " + ex.StackTrace)); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { } public static async Task ModVersionCheck(NetworkMessage message) { string version = Convert.ToString(message.payload["version"]); int senderID = message.senderID; PlayerAvatar obj = await HelperUtils.FindPlayerAvatarByNumber(senderID); FieldInfo field = typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); string key = ((field != null) ? ((field.GetValue(obj) as string) ?? "0") : "0"); PhotonNetwork.CurrentRoom.GetPlayer(senderID, false); CrowdControlMod.PlayerVersions[key] = version; if (PhotonNetwork.IsMasterClient) { SendResponse(0, message.senderID, CrowdResponse.Status.STATUS_SUCCESS, "", new Dictionary { { "version", "1.5.0.0" } }); } } public static void SendResponse(int id, int senderID, CrowdResponse.Status status, string message = "", Dictionary payload = null) { try { int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; Dictionary dictionary = new Dictionary { { "status", status.ToString() }, { "message", message.ToString() }, { "cmd", "response" } }; if (payload != null && payload.ContainsKey("version") && payload["version"] != null) { dictionary["version"] = payload["version"].ToString(); } string text = JsonConvert.SerializeObject((object)new NetworkMessage("response", id, senderID, actorNumber, dictionary)); Player player = PhotonNetwork.CurrentRoom.GetPlayer(senderID, false); if (id == 0) { networkView.RPC("OnNetworkMessageRPC", (RpcTarget)0, new object[1] { text }); } else { networkView.RPC("OnNetworkMessageRPC", player, new object[1] { text }); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("SEND RESPONSE CRASHED " + ex)); } } [IteratorStateMachine(typeof(d__15))] private IEnumerator SendDelayedResponse(int id, int senderID, bool success) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { id = id, senderID = senderID, success = success }; } public static bool IsHost() { return PhotonNetwork.IsMasterClient; } public static void SendRequest(string type, int id, int senderID, int targetActor, Dictionary payload) { try { string text = JsonConvert.SerializeObject((object)new RequestMessage { type = type, id = id, senderID = senderID, targetActor = targetActor, payload = payload }, jsonSettings); if ((Object)(object)networkView != (Object)null) { pendingRequestIDs.Add(id.ToString()); networkView.RPC("OnNetworkMessageRPC", (RpcTarget)2, new object[1] { text }); } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("SEND REQUEST " + ex)); } } public static void SendResponse(int id, int senderID, CrowdResponse.Status status, Dictionary payload) { try { string text = JsonConvert.SerializeObject((object)new ResponseMessage { id = id, senderID = senderID, status = status.ToString(), payload = payload }, jsonSettings); if ((Object)(object)networkView != (Object)null) { Player player = PhotonNetwork.CurrentRoom.GetPlayer(senderID, false); if (id == 0) { networkView.RPC("OnNetworkMessageRPC", (RpcTarget)3, new object[1] { text }); } else { networkView.RPC("OnNetworkMessageRPC", player, new object[1] { text }); } } } catch (Exception ex) { CrowdControlMod.mls.LogInfo((object)("SEND RESPONSE2 " + ex)); } } public static void AddResponder(int msgID, Action responder) { rspResponders[msgID] = responder; } public static void RemoveResponder(int msgID) { rspResponders.TryRemove(msgID, out var _); } public static void ProcessMessage(string message) { try { if (string.IsNullOrEmpty(message)) { return; } JObject val = JObject.Parse(message); if (val == null) { CrowdControlMod.mls.LogWarning((object)("Received malformed message: " + message)); return; } if (((object)val["type"])?.ToString() == "response") { ResponseMessage responseMessage = new ResponseMessage(); JToken obj = val["id"]; responseMessage.id = ((obj != null) ? Extensions.Value((IEnumerable)obj) : 0); JToken obj2 = val["senderID"]; responseMessage.senderID = ((obj2 != null) ? Extensions.Value((IEnumerable)obj2) : 0); JToken obj3 = val["targetActor"]; responseMessage.targetActor = ((obj3 != null) ? Extensions.Value((IEnumerable)obj3) : 0); JToken obj4 = val["payload"]; responseMessage.payload = ((obj4 != null) ? obj4.ToObject>() : null) ?? new Dictionary(); JToken obj5 = val["payload"]; responseMessage.status = ((obj5 == null) ? null : ((object)obj5[(object)"status"])?.ToString()); JToken obj6 = val["payload"]; responseMessage.version = ((obj6 == null) ? null : ((object)obj6[(object)"version"])?.ToString()); ProcessResponse(responseMessage); return; } try { JsonConvert.DeserializeObject(message, jsonSettings); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error processing message2: " + ex.Message)); } } catch (Exception ex2) { CrowdControlMod.mls.LogError((object)("Error processing message: " + ex2.Message)); CrowdControlMod.mls.LogError((object)("Stack trace: " + ex2.StackTrace)); } } private static void ProcessResponse(ResponseMessage message) { if (message.senderID != PhotonNetwork.LocalPlayer.ActorNumber) { return; } if (message.id == 0 && message.version == "1.5.0.0") { CrowdControlMod.modActivated = true; } if (!rspResponders.TryGetValue(message.id, out var value) || !pendingRequestIDs.Remove(message.id.ToString()) || !Enum.TryParse(message.status, out var result)) { return; } try { value(result); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Error processing response for message ID {message.id}: {arg}"); } } } internal static HashSet pendingRequestIDs = new HashSet(); private static readonly ConcurrentDictionary> rspResponders = new ConcurrentDictionary>(); private static readonly JsonSerializerSettings jsonSettings = new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1, ReferenceLoopHandling = (ReferenceLoopHandling)1 }; private static readonly object networkLock = new object(); private static bool? _isNetworkReady = null; private static bool? _isViewValid = null; private static bool IsViewValid() { lock (networkLock) { if (_isViewValid.HasValue) { return _isViewValid.Value; } PhotonView networkView = MessageHandler.networkView; if ((Object)(object)networkView == (Object)null) { _isViewValid = false; CrowdControlMod.mls.LogWarning((object)"NetworkView is null"); return false; } _isViewValid = networkView.ViewID != 0; return _isViewValid.Value; } } private static bool IsNetworkReady() { lock (networkLock) { if (_isNetworkReady.HasValue) { return _isNetworkReady.Value; } bool flag = IsViewValid(); _isNetworkReady = PhotonNetwork.IsConnected && PhotonNetwork.InRoom && flag && MessageHandler.networkView.ObservedComponents != null; return _isNetworkReady.Value; } } } public class TimedResponse : CrowdResponse { public int timeRemaining; public TimedResponse(int id, int dur, Status status = Status.STATUS_SUCCESS, string message = "") : base(id, status, message) { timeRemaining = dur; } } } namespace BepinControl.Effects { public class PlayerSpeedSlowEffect : BaseEffect { public PlayerSpeedSlowEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int dur = 30; if (request.duration > 0) { dur = request.duration / 1000; } if (TimedThread.isRunning(TimedType.SPEED)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot Decrease Speed while Increase Speed is active."); } if (TimedThread.isRunning(TimedType.SLOW)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Decrease Player Speed is already active."); } if (TimedThread.isRunning(TimedType.DISABLE_INPUT)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot Increase Speed while Disable Input is active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); _ = HelperUtils.FindPlayerAvatarByNumber(num, alive: false).Result; CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { instance.OverrideSpeed(0.5f, (float)dur); instance.OverrideLookSpeed(0.5f, 2f, 1f, (float)dur); instance.OverrideAnimationSpeed(0.2f, 1f, 2f, (float)dur); instance.OverrideTimeScale(0.1f, (float)dur); tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error OverrideSpeed: {arg2}"); tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if (ControlClient.playerCount > 1) { try { RPCCommands.MessageHandler.SendMessageToHost("override_voice", 0, num, num, new Dictionary { { "pitch", "low" }, { "duration", dur } }); } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error sending message to host: {arg}"); } } new Thread(new TimedThread(request.GetReqID(), TimedType.SLOW, dur * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), dur * 1000); } } public class PlayerVoiceOverrideEffect : BaseEffect { public PlayerVoiceOverrideEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { try { int targetActor = message.targetActor; string text = Convert.ToString(message.payload["pitch"]); float pitch = (text.Contains("low") ? 0.65f : 1.35f); float duration = Convert.ToInt32(message.payload["duration"]); PlayerAvatar playerAvatar = await HelperUtils.FindPlayerAvatarByNumber(targetActor, alive: false); if ((Object)(object)playerAvatar == (Object)null) { return; } CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_003a: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)playerAvatar != (Object)null) { FieldInfo field = typeof(PlayerAvatar).GetField("voiceChat", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { ((PlayerVoiceChat)field.GetValue(playerAvatar)).OverridePitch(pitch, 1f, 2f, duration, 0f, 0f); } } } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error overriding voice: {arg2}"); } }); } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error overriding voice: {arg}!"); } } public override CrowdResponse Execute() { int num = 30; if (request.duration > 0) { num = request.duration / 1000; } if (TimedThread.isRunning(TimedType.SPEED)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot change pitch while Fast Player is active."); } if (TimedThread.isRunning(TimedType.SLOW)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot change pitch while Slow Player is active."); } if (TimedThread.isRunning(TimedType.PITCH)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot change pitch while it is already active."); } string value = (request.code.ToLowerInvariant().Contains("high") ? "high" : "low"); Player localPlayer = PhotonNetwork.LocalPlayer; int num2 = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); _ = HelperUtils.FindPlayerAvatarByNumber(num2, alive: false).Result; try { RPCCommands.MessageHandler.SendMessageToHost("override_voice", 0, num2, num2, new Dictionary { { "pitch", value }, { "duration", num } }); } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error sending message to host: {arg}"); } new Thread(new TimedThread(request.GetReqID(), TimedType.PITCH, num * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), num * 1000); } } public class CloseAllDoors : BaseEffect { public CloseAllDoors(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); int doorsClosed = 0; string[] validDoorNames = new string[4] { "Wizard Door", "Arctic Door", "Manor Door", "Museum Door" }; try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) try { List list = Resources.FindObjectsOfTypeAll().ToList(); if (list.Count == 0) { tcs.TrySetResult(result: false); } else { FieldInfo field = typeof(PhysGrabHinge).GetField("closed", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo method = typeof(PhysGrabHinge).GetMethod("CloseImpulse", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PhysGrabHinge).GetField("physGrabObject", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null || method == null || field2 == null) { tcs.TrySetResult(result: false); } else { foreach (PhysGrabHinge item in list) { Transform parent = ((Component)item).transform.parent; GameObject parentDoor = ((parent != null) ? ((Component)parent).gameObject : null); if (!((Object)(object)parentDoor == (Object)null) && validDoorNames.Any((string name) => ((Object)parentDoor).name.Contains(name))) { bool num = (bool)field.GetValue(item); object? value = field2.GetValue(item); PhysGrabObject val = (PhysGrabObject)((value is PhysGrabObject) ? value : null); if (!num) { if ((Object)(object)val != (Object)null) { val.rb.velocity = Vector3.zero; val.rb.angularVelocity = Vector3.zero; } method.Invoke(item, new object[1] { false }); doorsClosed++; } } } if (doorsClosed == 0) { tcs.TrySetResult(result: false); } else { tcs.TrySetResult(result: true); } } } } catch (Exception) { tcs.TrySetResult(result: false); } }); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Unexpected error: " + ex.Message)); tcs.TrySetResult(result: false); } bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS, "No open doors to close!"); } public override CrowdResponse Execute() { int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); try { RPCCommands.MessageHandler.SendMessageToHost("close_doors", request.id, actorNumber, actorNumber); if (!tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "No open doors to close!"); } CrowdResponse.Status result = tcs.Task.Result; RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(result); } catch (Exception) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "No open doors to close!"); } } } public class SpawnCustomItemEffect : BaseEffect { public SpawnCustomItemEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 1; try { int targetActor = message.targetActor; string item = Convert.ToString(message.payload["item"]); PlayerAvatar playerAvatar = await HelperUtils.FindPlayerAvatarByNumber(targetActor); if ((Object)(object)playerAvatar == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, "Unable to find player."); return; } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0011: 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_0031: Unknown result type (might be due to invalid IL or missing references) try { SpawnItem(item, ((Component)playerAvatar).transform.position, ((Component)playerAvatar).transform.forward, ((Component)playerAvatar).transform.rotation); tcs.TrySetResult(result: true); } catch (Exception arg2) { CrowdControlMod.mls.LogInfo((object)$"Failed to spawn item: {arg2}"); tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to process spawn data: {arg}"); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; if (!CrowdControlMod.customPrefabsInitialized) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Unable to Spawn custom items. All players require the mod for this."); } string item = ((request.code.Split(new char[1] { '_' }).Length > 1) ? request.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(item)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Invalid item code"); } bool random = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: true, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Cannot Spawn Items when player is dead!"); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Cannot Spawn Items when player is dead!"); } int actorNumber2 = photonView.Owner.ActorNumber; try { TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.GetReqID(), delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); RPCCommands.MessageHandler.SendMessageToHost("spawn_custom", request.GetReqID(), actorNumber, actorNumber2, new Dictionary { { "item", item } }); status = (tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); RPCCommands.MessageHandler.RemoveResponder(request.GetReqID()); } catch (Exception) { status = CrowdResponse.Status.STATUS_FAILURE; message = "Failed to spawn item"; } if (status == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0043: 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) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Spawned " + item + (random ? ("on " + photonView.Owner.NickName) : ""), Color.green, Color.green, 1f); } }); } return CreateResponse(status, message); } public static bool SpawnItem(string item, Vector3 playerPosition, Vector3 playerForward, Quaternion rotation) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) bool success = false; CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) try { float num = 1f; RaycastHit val = default(RaycastHit); if (Physics.Raycast(playerPosition, playerForward, ref val, num + 0.5f)) { num = -1f; } Vector3 val2 = playerPosition + playerForward * num; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2 + Vector3.up * 2f, Vector3.down, ref val3, 10f)) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 0.1f; } Quaternion identity = Quaternion.identity; GameObject val4 = null; string text = ""; switch (item) { case "Bread": val4 = CrowdControlMod.breadPrefab; text = "Valuables/Bread"; break; case "Milk": val4 = CrowdControlMod.milkPrefab; text = "Valuables/Milk"; break; case "Eggs": val4 = CrowdControlMod.eggsPrefab; text = "Valuables/Eggs"; break; } val4.GetComponent(); GameObject val5 = PhotonNetwork.InstantiateRoomObject(text, val2, identity, (byte)0, (object[])null); success = (Object)(object)val5 != (Object)null; } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to spawn item: {arg}"); } }); return success; } } public class SpawnEnemyEffect : BaseEffect { public static Dictionary> EnemySpawnList = new Dictionary>(); public SpawnEnemyEffect(ControlClient client, CrowdRequest request) : base(client, request) { } private static bool TryGetPatrolPathSpawnNearPlayer(Vector3 playerPosition, out Vector3 spawnPosition, out Quaternion spawnRotation) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) spawnPosition = playerPosition; spawnRotation = Quaternion.identity; EnemyDirector instance = EnemyDirector.instance; if ((Object)(object)instance == (Object)null) { return false; } FieldInfo field = typeof(EnemyDirector).GetField("enemyFirstSpawnPoints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return false; } if (!(field.GetValue(instance) is IList list) || list.Count == 0) { return false; } List list2 = new List(); foreach (object item in list) { LevelPoint val = (LevelPoint)((item is LevelPoint) ? item : null); if (val != null && (Object)(object)val != (Object)null) { list2.Add(val); } } list2 = list2.OrderBy(delegate(LevelPoint p) { //IL_0006: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 val3 = ((Component)p).transform.position - playerPosition; return ((Vector3)(ref val3)).sqrMagnitude; }).ToList(); if (list2.Count == 0) { return false; } int count = list2.Count; List list3 = ((count >= 4) ? list2.Skip(1).Take(Math.Min(7, count - 1)).ToList() : (count switch { 3 => list2.Skip(1).ToList(), 2 => new List { list2[Random.Range(0, 2)] }, _ => new List { list2[0] }, })); LevelPoint val2 = list3[Random.Range(0, list3.Count)]; spawnPosition = ((Component)val2).transform.position; spawnRotation = ((Component)val2).transform.rotation; return true; } private static bool ReadSpawnOnPatrolPathFromPayload(Dictionary payload) { if (payload == null || !payload.TryGetValue("spawnOnPatrolPath", out var value)) { return false; } try { return Convert.ToBoolean(value); } catch { return false; } } public override CrowdResponse Execute() { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; bool flag = request.code.ToLowerInvariant().Contains("random_"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; string enemy = ((request.code.Split(new char[1] { '_' }).Length > 1) ? request.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(enemy)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Invalid enemy name"); } PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Cannot Spawn Enemies when player is dead!"); } PhotonView component = ((Component)result).GetComponent(); int actorNumber2 = component.Owner.ActorNumber; if (enemy == "ValuableThrower") { enemy = "Valuable Thrower"; } if (enemy == "SlowWalker") { enemy = "Slow Walker"; } if (enemy == "SlowMouth") { enemy = "Slow Mouth"; } if (enemy == "ThinMan") { enemy = "Thin Man"; } if (enemy == "Birthdayboy") { enemy = "Birthday boy"; } if (enemy == "HeadGrabber") { enemy = "Head Grabber"; } if (enemy == "HeartHugger") { enemy = "Heart Hugger"; } if (enemy == "BombThrower") { enemy = "Bomb Thrower"; } try { TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.GetReqID(), delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); bool value = CrowdControlMod.CrowdControlConfig.enemySpawnOnPatrolPath.Value; RPCCommands.MessageHandler.SendMessageToHost("spawn_enemy", request.id, actorNumber, actorNumber2, new Dictionary { { "enemy", enemy }, { "spawnOnPatrolPath", value } }); status = (tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); RPCCommands.MessageHandler.RemoveResponder(request.GetReqID()); } catch (Exception) { status = CrowdResponse.Status.STATUS_FAILURE; message = "Failed to spawn enemy."; } if (enemy == "Duck") { enemy = "Apex Predator"; } if (enemy == "Head") { enemy = "Headman"; } if (enemy == "Runner") { enemy = "Reaper"; } if (enemy == "Floater") { enemy = "Mentalist"; } if (enemy == "Tumbler") { enemy = "Chef"; } if (enemy == "Hunter") { enemy = "Huntsman"; } if (enemy == "Beamer") { enemy = "Clown"; } if (enemy == "Valuable Thrower") { enemy = "Rugrat"; } if (enemy == "Slow Walker") { enemy = "Trudge"; } if (enemy == "Slow Mouth") { enemy = "Spewer"; } if (enemy == "Thin Man") { enemy = "Shadow Child"; } if (enemy == "Peeper") { enemy = "Ceiling Eye"; } if (enemy == "Banger") { enemy = "Bang"; } if (status == CrowdResponse.Status.STATUS_SUCCESS && CrowdControlMod.CrowdControlConfig.spawnEnemyMsg.Value) { bool value2 = CrowdControlMod.CrowdControlConfig.enemySpawnOnPatrolPath.Value; string randomSuffix = (flag ? (" (" + component.Owner.NickName + ")") : ""); if (value2) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) MissionUI instance4 = Singleton.Instance; if (instance4 != null) { instance4.MissionText("CC Spawned " + enemy + " nearby." + randomSuffix, Color.green, Color.green, 4f); } }); } else { TaskCompletionSource taskCompletionSource = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance3 = Singleton.Instance; if (instance3 != null) { instance3.MissionText("CC Enemy spawn incomming...", Color.green, Color.green, 2f); } }); taskCompletionSource.Task.Wait(2005); CrowdControlMod.ActionQueue.Enqueue(delegate { //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) MissionUI instance2 = Singleton.Instance; if (instance2 != null) { instance2.MissionText("CC You should run or hide.", Color.green, Color.green, 1f); } }); taskCompletionSource.Task.Wait(1005); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Spawned " + enemy + randomSuffix, Color.green, Color.green, 4f); } }); } } return CreateResponse(status, message); } public static async void Trigger(RPCCommands.MessageHandler.NetworkMessage message) { try { PlayerAvatar playerAvatar = await HelperUtils.FindPlayerAvatarByNumber(message.targetActor); if ((Object)(object)playerAvatar == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); return; } if (!PhotonNetwork.IsConnected) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); return; } string enemy = Convert.ToString(message.payload["enemy"]); bool spawnOnPatrolPath = ReadSpawnOnPatrolPathFromPayload(message.payload); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) try { string search = "Enemy - " + enemy; CrowdControlMod.mls.LogInfo((object)("spawning " + enemy + " : " + search)); List list = Enemies.AllEnemies.Where((EnemySetup p) => p.spawnObjects[0].PrefabName == search).ToList(); foreach (EnemySetup allEnemy in Enemies.AllEnemies) { CrowdControlMod.mls.LogInfo((object)("entry " + allEnemy.spawnObjects[0].PrefabName)); } if (list.Count == 0) { CrowdControlMod.mls.LogInfo((object)"could not find enemy"); throw new Exception(); } Vector3 val = ((Component)playerAvatar).transform.position; Quaternion val2 = ((Component)playerAvatar).transform.rotation; if (spawnOnPatrolPath) { if (!TryGetPatrolPathSpawnNearPlayer(((Component)playerAvatar).transform.position, out var spawnPosition, out var spawnRotation)) { CrowdControlMod.mls.LogWarning((object)"Patrol path spawn requested but no path points; spawning at player."); } else { val = spawnPosition; val2 = spawnRotation; } } CrowdControlMod.mls.LogInfo((object)("calling spawnenemy at " + (spawnOnPatrolPath ? "patrol path" : "player"))); Enemies.SpawnEnemy(list[0], val, val2, false); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_SUCCESS); } catch (Exception) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } }); } catch (Exception) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } } public class PlayerKillEffect : BaseEffect { public PlayerKillEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { request.code.ToLowerInvariant().Contains("random_"); bool flag = false; Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); if (num == -1) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if (TimedThread.isRunning(TimedType.KILL)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot Kill Player when they are already dead."); } if (TimedThread.isRunning(TimedType.INVINCIBLE)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot Kill Player while they are invincible."); } if (TimedThread.isRunning(TimedType.PRAISE)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } try { PlayerHealth result = HelperUtils.FindPlayerHealthByAvatarNumber(num).Result; if ((Object)(object)result == (Object)null) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if (!((Behaviour)result).isActiveAndEnabled) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if ((Object)(object)((Component)result).GetComponent() == (Object)null) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if ((Object)(object)ChatManager.instance != (Object)null) { ChatManager.instance.PossessSelfDestruction(); flag = true; } } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error executing KillPlayer: " + ex.Message)); flag = false; } new Thread(new TimedThread(request.GetReqID(), TimedType.KILL, 4000).Run).Start(); return new TimedResponse(request.GetReqID(), 4000, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } } public class UpgradePlayerEffect : BaseEffect { public UpgradePlayerEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 1; try { string upgradeType = Convert.ToString(message.payload["upgrade"]); PlayerAvatar val = await HelperUtils.FindPlayerAvatarByNumber(message.targetActor); if ((Object)(object)val == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); return; } FieldInfo field = typeof(PlayerAvatar).GetField("steamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || field.GetValue(val) == null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); return; } string steamID = field.GetValue(val).ToString(); TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PunManager punManager = Singleton.Instance; if (new Dictionary { { "energy", delegate { punManager.UpgradePlayerEnergy(steamID, 1); } }, { "health", delegate { punManager.UpgradePlayerHealth(steamID, 1); } }, { "map", delegate { punManager.UpgradeMapPlayerCount(steamID, 1); } }, { "jump", delegate { punManager.UpgradePlayerExtraJump(steamID, 1); } }, { "grabrange", delegate { punManager.UpgradePlayerGrabRange(steamID, 1); } }, { "grabstrength", delegate { punManager.UpgradePlayerGrabStrength(steamID, 1); } }, { "sprint", delegate { punManager.UpgradePlayerSprintSpeed(steamID, 1); } }, { "throw", delegate { punManager.UpgradePlayerThrowStrength(steamID, 1); } }, { "tumble", delegate { punManager.UpgradePlayerTumbleLaunch(steamID, 1); } } }.TryGetValue(upgradeType.ToLower(), out var value)) { value(); tcs.TrySetResult(result: true); } else { CrowdControlMod.mls.LogError((object)("Unknown upgrade type: " + upgradeType)); tcs.TrySetResult(result: false); } } catch (Exception ex2) { CrowdControlMod.mls.LogError((object)("Error applying upgrade: " + ex2.Message)); tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Player upgrade error: " + ex.Message)); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { bool random = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: true, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be upgraded."); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be upgraded."); } string text = ((request.code.Split(new char[1] { '_' }).Length > 1) ? request.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(text)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Invalid upgrade type"); } int actorNumber2 = photonView.Owner.ActorNumber; if (!new Dictionary { { "energy", "Energy" }, { "health", "Health" }, { "map", "Map Power" }, { "jump", "Jumps" }, { "grabrange", "Pick-up Range" }, { "grabstrength", "Strength" }, { "sprint", "Sprint Speed" }, { "throw", "Throw Power" }, { "tumble", "Tumble Distance" } }.TryGetValue(text, out var upgrade)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Invalid upgrade type"); } try { TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); RPCCommands.MessageHandler.SendMessageToHost("upgrade_player", request.id, actorNumber, actorNumber2, new Dictionary { { "upgrade", text } }); if (tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { CrowdResponse.Status result2 = tcs.Task.Result; RPCCommands.MessageHandler.RemoveResponder(request.id); if (result2 == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Upgraded " + upgrade + (random ? ("on " + photonView.Owner.NickName + "!") : ""), Color.green, Color.green, 1f); } }); } return CreateResponse(result2); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } catch (Exception) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Unable to update haul goal."); } } } public abstract class BaseEffect { protected readonly ControlClient client; protected readonly CrowdRequest request; protected BaseEffect(ControlClient client, CrowdRequest request) { this.client = client; this.request = request; } public abstract CrowdResponse Execute(); protected CrowdResponse CreateResponse(CrowdResponse.Status status, string message = "") { return new CrowdResponse(request.GetReqID(), status, message); } } public class DamageRandomValuableEffect : BaseEffect { public DamageRandomValuableEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 1; try { int targetActor = message.targetActor; TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); string responseMessage = ""; PlayerHealth playerHealth = await HelperUtils.FindPlayerHealthByAvatarNumber(targetActor); if ((Object)(object)playerHealth == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, "Unable to find valuable to damage."); return; } PhotonView component = ((Component)playerHealth).GetComponent(); if ((Object)(object)component == (Object)null || component.Owner.ActorNumber != targetActor) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, "Unable to find valuable to damage."); return; } CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_000b: 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) try { Collider[] array = Physics.OverlapSphere(((Component)playerHealth).transform.position, 5f); HashSet hashSet = new HashSet(); Collider[] array2 = array; foreach (Collider val in array2) { if (((Component)val).CompareTag("Phys Grab Object")) { Transform root = ((Component)val).transform.root; if (((Object)root).name.Contains("Valuable")) { hashSet.Add(((Component)root).gameObject); } } } if (hashSet.Count > 0) { List list = hashSet.ToList(); int index = Random.Range(0, list.Count); GameObject val2 = list[index]; PhysGrabObjectImpactDetector component2 = val2.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.BreakHeavy(val2.transform.position, false, 0f); tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } else { responseMessage = "Unable to find valuable to damage."; tcs.TrySetResult(result: false); } } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error damaging valuable: {arg2}"); tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS, responseMessage); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to process damage effect: {arg}"); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { request.code.ToLowerInvariant().Contains("random_"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; int targetActor = actorNumber; try { TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); RPCCommands.MessageHandler.SendMessageToHost("destroy_random_item", request.id, actorNumber, targetActor); if (tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { CrowdResponse.Status result = tcs.Task.Result; RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(result); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } catch (Exception) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Unable to destory item."); } } } public class UpdateHaulGoalEffect : BaseEffect { public UpdateHaulGoalEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); try { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) try { bool flag2 = Convert.ToString(message.payload["decrease"]).ToLower() == "true"; ExtractionPoint[] array = Object.FindObjectsOfType(); FieldInfo stateField = typeof(ExtractionPoint).GetField("currentState", BindingFlags.Instance | BindingFlags.NonPublic); IEnumerable source = array; if (stateField != null) { ExtractionPoint[] array2 = array.Where(delegate(ExtractionPoint ep) { object value = stateField.GetValue(ep); return value != null && (value.Equals((object)(State)2) || value.Equals((object)(State)7)); }).ToArray(); if (array2.Length != 0) { source = array2; } } ExtractionPoint val = source.FirstOrDefault((Func)((ExtractionPoint ep) => ep.haulGoal != 0)); if ((Object)(object)val == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); tcs.TrySetResult(result: false); } else if (val.haulGoal == 0) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, "Extraction Goal not set yet!"); tcs.TrySetResult(result: false); } else { float num = 0.1f; int num2 = Mathf.CeilToInt((float)val.haulGoal * num) * ((!flag2) ? 1 : (-1)); int num3 = Mathf.Max(0, val.haulGoal + num2); if (num3 < 1 || num3 >= 100000000) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, flag2 ? "Cannot decrease the goal past $1" : "Cannot increase the goal past $100,000,000"); tcs.TrySetResult(result: false); } else { MethodInfo method = typeof(ExtractionPoint).GetMethod("HaulGoalSet", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(val, new object[1] { num3 }); } else { val.HaulGoalSetRPC(num3, default(PhotonMessageInfo)); } tcs.TrySetResult(result: true); } } } catch (Exception ex2) { CrowdControlMod.mls.LogError((object)("Error updating extraction goal: " + ex2.Message)); tcs.TrySetResult(result: false); } }); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Unexpected error in extraction goal trigger: " + ex.Message)); tcs.TrySetResult(result: false); } bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } public override CrowdResponse Execute() { request.code.ToLowerInvariant().Contains("random_"); bool decrease = request.code.ToLowerInvariant().Contains("decrease_"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; int targetActor = actorNumber; try { TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); RPCCommands.MessageHandler.SendMessageToHost("update_haul", request.id, actorNumber, targetActor, new Dictionary { { "decrease", decrease } }); if (tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { CrowdResponse.Status result = tcs.Task.Result; RPCCommands.MessageHandler.RemoveResponder(request.id); if (result == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText(decrease ? "CC Haul Goal Decreased!" : "CC Haul Goal Increased!", decrease ? Color.green : Color.red, decrease ? Color.green : Color.red, 1f); } }); } return CreateResponse(result); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } catch (Exception) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Unable to update haul goal."); } } } public class PlayerAntiGravityEffect : BaseEffect { public PlayerAntiGravityEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int dur = 30; if (request.duration > 0) { dur = request.duration / 1000; } if (TimedThread.isRunning(TimedType.ANTI_GRAVITY)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Anti-Gravity is already active."); } if (TimedThread.isRunning(TimedType.DISABLE_INPUT)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot enable Anti-Gravity while Disable Input is active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { instance.AntiGravity((float)dur); tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error ANTI_GRAVITY: {arg}"); tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } new Thread(new TimedThread(request.GetReqID(), TimedType.ANTI_GRAVITY, dur * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), dur * 1000); } } public class PlayerDisableCrouchEffect : BaseEffect { public PlayerDisableCrouchEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int dur = 30; if (request.duration > 0) { dur = request.duration / 1000; } if (TimedThread.isRunning(TimedType.DISABLE_CROUCH)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Disable Crouch is already enabled."); } if (TimedThread.isRunning(TimedType.DISABLE_INPUT)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot disable Crouch when Disable Input is active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { if (instance.Crouching) { tcs.TrySetResult(result: false); } else { instance.CrouchDisable((float)dur); tcs.TrySetResult(result: true); } } else { tcs.TrySetResult(result: false); } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error DISABLE_CROUCH: {arg}"); tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } new Thread(new TimedThread(request.GetReqID(), TimedType.DISABLE_CROUCH, dur * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), dur * 1000); } } public class PlayerDisableInputEffect : BaseEffect { public PlayerDisableInputEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int dur = 30; if (request.duration > 0) { dur = request.duration / 1000; } if (TimedThread.isRunning(TimedType.DISABLE_INPUT)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Disable input is already active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { instance.InputDisable((float)dur); tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error DISABLE_INPUT: {arg}"); tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } new Thread(new TimedThread(request.GetReqID(), TimedType.DISABLE_INPUT, dur * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), dur * 1000); } } public class PlayerDrainEnergyEffect : BaseEffect { public PlayerDrainEnergyEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { if (TimedThread.isRunning(TimedType.INFINITE_STAMINA)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot drain energy while Infinite Energy is active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); string responseMessage = ""; CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0049: 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) try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && instance.EnergyCurrent != 0f && ((Component)instance).gameObject.activeInHierarchy) { instance.EnergyCurrent = 0f; MissionUI instance2 = Singleton.Instance; if ((Object)(object)instance2 != (Object)null) { instance2.MissionText("CC Energy Drained", Color.red, Color.red, 1f); } tcs.TrySetResult(result: true); } else { responseMessage = "Energy is already drained."; tcs.TrySetResult(result: false); } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error Drained Energy: {arg}"); tcs.TrySetResult(result: false); } }); bool result = tcs.Task.Result; return new CrowdResponse(request.GetReqID(), (!result) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS, responseMessage); } } public class PlayerFeatherEffect : BaseEffect { public PlayerFeatherEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int dur = 30; if (request.duration > 0) { dur = request.duration / 1000; } if (TimedThread.isRunning(TimedType.FEATHER)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY, "Low Gravity is already active."); } if (TimedThread.isRunning(TimedType.DISABLE_INPUT)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot activate Low Gravity while Disabled Input is active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { instance.Feather((float)dur); tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error FEATHER: {arg}"); tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } new Thread(new TimedThread(request.GetReqID(), TimedType.FEATHER, dur * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), dur * 1000); } } public class PlayerHealEffect : BaseEffect { public PlayerHealEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 1; try { int amount = Convert.ToInt32(message.payload["amount"]); int targetActor = message.targetActor; TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); string responseMessage = ""; try { PlayerHealth playerHealth = await HelperUtils.FindPlayerHealthByAvatarNumber(targetActor); if ((Object)(object)playerHealth != (Object)null) { CrowdControlMod.ActionQueue.Enqueue(delegate { FieldInfo? field = typeof(PlayerHealth).GetField("health", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PlayerHealth).GetField("maxHealth", BindingFlags.Instance | BindingFlags.NonPublic); int num = (int)field.GetValue(playerHealth); if ((int)field2.GetValue(playerHealth) != num) { playerHealth.HealOther(amount, true); tcs.TrySetResult(result: true); } else { responseMessage = "Player is already at full health."; tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS, responseMessage); return; } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"PlayerHealEffect error: {arg}"); } RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Player Heal error: " + ex.Message + "\n" + ex.StackTrace)); RPCCommands.MessageHandler.SendResponse(message?.id ?? 0, message?.senderID ?? 0, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { bool random = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: true, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be healed."); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be healed."); } int actorNumber2 = photonView.Owner.ActorNumber; TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); try { RPCCommands.MessageHandler.SendMessageToHost("player_heal", request.id, actorNumber, actorNumber2, new Dictionary { { "amount", 100f } }); if (!tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } CrowdResponse.Status result2 = tcs.Task.Result; if (result2 == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (random) { if (instance != null) { instance.MissionText("CC Healed " + photonView.Owner.NickName + "!", Color.red, Color.red, 1f); } } else if (instance != null) { instance.MissionText("CC Healed", Color.green, Color.green, 1f); } }); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(result2); } catch (Exception) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to heal player"); } } } public class PlayerHurtEffect : BaseEffect { public PlayerHurtEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 1; try { int amount = Convert.ToInt32(message.payload["amount"]); int targetActor = message.targetActor; string responseMessage = ""; TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); try { PlayerHealth playerHealth = await HelperUtils.FindPlayerHealthByAvatarNumber(targetActor); if ((Object)(object)playerHealth != (Object)null) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0047: Unknown result type (might be due to invalid IL or missing references) try { if ((int)typeof(PlayerHealth).GetField("health", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(playerHealth) - amount >= 1) { playerHealth.HurtOther(amount, ((Component)playerHealth).transform.position, false, -1, false); tcs.TrySetResult(result: true); } else { responseMessage = "Player requires at least 26 health."; tcs.TrySetResult(result: false); } } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error healing player: {arg2}"); tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS, responseMessage); return; } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"PlayerHurtEffect error: {arg}"); } RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Player Hurt error: " + ex.Message + "\n" + ex.StackTrace)); RPCCommands.MessageHandler.SendResponse(message?.id ?? 0, message?.senderID ?? 0, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { bool random = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; if (!random && TimedThread.isRunning(TimedType.INVINCIBLE)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: true, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be hurt."); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be hurt."); } int actorNumber2 = photonView.Owner.ActorNumber; TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); try { RPCCommands.MessageHandler.SendMessageToHost("player_hurt", request.id, actorNumber, actorNumber2, new Dictionary { { "amount", 25f } }); if (!tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } CrowdResponse.Status result2 = tcs.Task.Result; if (result2 == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (random) { if (instance != null) { instance.MissionText("CC Damage " + photonView.Owner.NickName + "!", Color.red, Color.red, 1f); } } else if (instance != null) { instance.MissionText("CC Damage Taken", Color.red, Color.red, 1f); } }); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(result2); } catch (Exception) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to hurt player"); } } } public class PlayerInfiniteStaminaEffect : BaseEffect { public PlayerInfiniteStaminaEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int num = 30; if (request.duration > 0) { num = request.duration / 1000; } if (TimedThread.isRunning(TimedType.KILL)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Player is dead, unable to process effect."); } Player localPlayer = PhotonNetwork.LocalPlayer; if (((localPlayer != null) ? localPlayer.ActorNumber : (-1)) == -1) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Player is dead, unable to process effect."); } if (TimedThread.isRunning(TimedType.INFINITE_STAMINA)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception) { tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Player is dead, unable to process effect."); } new Thread(new TimedThread(request.GetReqID(), TimedType.INFINITE_STAMINA, num * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), num * 1000); } } public class PlayerInvincibleEffect : BaseEffect { public PlayerInvincibleEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int num = 30; if (request.duration > 0) { num = request.duration / 1000; } if (TimedThread.isRunning(TimedType.KILL)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot make player invincible when they are dead."); } Player localPlayer = PhotonNetwork.LocalPlayer; if (((localPlayer != null) ? localPlayer.ActorNumber : (-1)) == -1) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot make player invincible when they are dead."); } if (TimedThread.isRunning(TimedType.INVINCIBLE)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception) { tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot make player invincible when they are dead."); } new Thread(new TimedThread(request.GetReqID(), TimedType.INVINCIBLE, num * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), num * 1000); } } public class PlayerRefillEnergyEffect : BaseEffect { public PlayerRefillEnergyEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); if (TimedThread.isRunning(TimedType.INFINITE_STAMINA)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0046: 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) try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && instance.EnergyStart != instance.EnergyCurrent && ((Component)instance).gameObject.activeInHierarchy) { instance.EnergyCurrent = instance.EnergyStart; MissionUI instance2 = Singleton.Instance; if (instance2 != null) { instance2.MissionText("CC Energy Refilled", Color.green, Color.green, 1f); } tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error Energy Refilled: {arg}"); tcs.TrySetResult(result: false); } }); bool result = tcs.Task.Result; return new CrowdResponse(request.GetReqID(), (!result) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS, "Cannot refill energy when it is full."); } } public class PlayerReviveEffect : BaseEffect { public PlayerReviveEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 2; try { int targetActor = message.targetActor; TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); PlayerAvatar playerAvatar = await HelperUtils.FindPlayerAvatarByNumber(targetActor, alive: false); if ((Object)(object)playerAvatar == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, "Player is not dead."); return; } CrowdControlMod.ActionQueue.Enqueue(delegate { try { playerAvatar.Revive(true); tcs.TrySetResult(result: true); } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error reviving player: {arg2}"); tcs.TrySetResult(result: false); } }); PlayerHealth playerHealth = await HelperUtils.FindPlayerHealthByAvatarNumber(targetActor); CrowdControlMod.ActionQueue.Enqueue(delegate { try { if ((Object)(object)playerHealth != (Object)null) { FieldInfo? field3 = typeof(PlayerHealth).GetField("health", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field4 = typeof(PlayerHealth).GetField("maxHealth", BindingFlags.Instance | BindingFlags.NonPublic); _ = (int)field3.GetValue(playerHealth); int num2 = (int)field4.GetValue(playerHealth); playerHealth.HealOther(num2, true); } } catch (Exception) { } }); CrowdControlMod.ActionQueue.Enqueue(delegate { try { if ((Object)(object)playerHealth != (Object)null) { FieldInfo? field = typeof(PlayerHealth).GetField("health", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(PlayerHealth).GetField("maxHealth", BindingFlags.Instance | BindingFlags.NonPublic); _ = (int)field.GetValue(playerHealth); int num = (int)field2.GetValue(playerHealth); playerHealth.HealOther(num, true); } } catch (Exception) { } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to revive player: {arg}"); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { bool flag = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: false, flag).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to find player, are they alive?"); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to find player, are they alive?"); } if (((Behaviour)photonView).isActiveAndEnabled) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is not dead. Cannot revive the living."); } int actorNumber2 = photonView.Owner.ActorNumber; TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); try { RPCCommands.MessageHandler.SendMessageToHost("player_revive", request.id, actorNumber, actorNumber2); if (!tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } CrowdResponse.Status result2 = tcs.Task.Result; RPCCommands.MessageHandler.RemoveResponder(request.id); if (flag) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0024: 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) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Revived " + photonView.Owner.NickName, Color.green, Color.green, 1f); } }); } return CreateResponse(result2); } catch (Exception) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to revive player"); } } } public class PlayerSpeedEffect : BaseEffect { public PlayerSpeedEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { int dur = 30; if (request.duration > 0) { dur = request.duration / 1000; } if (TimedThread.isRunning(TimedType.SLOW)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot Increase Speed while Decrease Speed is active."); } if (TimedThread.isRunning(TimedType.SPEED)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Increse Player Speed is already active."); } if (TimedThread.isRunning(TimedType.DISABLE_INPUT)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE, "Cannot Increase Speed while Disable Input is active."); } TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); CrowdControlMod.ActionQueue.Enqueue(delegate { try { PlayerController instance = Singleton.Instance; if ((Object)(object)instance != (Object)null && ((Component)instance).gameObject.activeInHierarchy) { instance.OverrideSpeed(2.5f, (float)dur); tcs.TrySetResult(result: true); } else { tcs.TrySetResult(result: false); } } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error OverrideSpeed: {arg2}"); tcs.TrySetResult(result: false); } }); if (!tcs.Task.Result) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if (ControlClient.playerCount > 1) { try { RPCCommands.MessageHandler.SendMessageToHost("override_voice", 0, num, num, new Dictionary { { "pitch", "high" }, { "duration", dur } }); } catch (Exception arg) { CrowdControlMod.mls.LogError((object)$"Error sending message to host: {arg}"); } } new Thread(new TimedThread(request.GetReqID(), TimedType.SPEED, dur * 1000).Run).Start(); return new TimedResponse(request.GetReqID(), dur * 1000); } } public class PlayerTeleportEffect : BaseEffect { public PlayerTeleportEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static async Task Trigger(RPCCommands.MessageHandler.NetworkMessage message) { _ = 1; try { int targetActor = message.targetActor; JObject val = (JObject)message.payload["position"]; Vector3 position = new Vector3((float)val["x"], (float)val["y"], (float)val["z"]); TaskCompletionSource tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); PlayerAvatar playerAvatar = await HelperUtils.FindPlayerAvatarByNumber(targetActor, alive: false); if ((Object)(object)playerAvatar == (Object)null) { RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE, "Player could not be teleported."); return; } FieldInfo field = typeof(PlayerAvatar).GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic); bool isDead = field != null && (bool)field.GetValue(playerAvatar); PlayerDeathHead playerDeathHead = default(PlayerDeathHead); ref PlayerDeathHead reference = ref playerDeathHead; object? obj = typeof(PlayerAvatar).GetField("playerDeathHead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(playerAvatar); reference = (PlayerDeathHead)((obj is PlayerDeathHead) ? obj : null); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_004e: 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_002d: 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) try { if (isDead && (Object)(object)playerDeathHead != (Object)null) { PhysGrabObject component2 = ((Component)playerDeathHead).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.Teleport(position, ((Component)playerAvatar).transform.rotation); } } playerAvatar.Spawn(position, ((Component)playerAvatar).transform.rotation); tcs.TrySetResult(result: true); } catch (Exception arg3) { CrowdControlMod.mls.LogError((object)$"Error reviving player: {arg3}"); tcs.TrySetResult(result: false); } }); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_004e: 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_002d: 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) try { if (isDead && (Object)(object)playerDeathHead != (Object)null) { PhysGrabObject component = ((Component)playerDeathHead).GetComponent(); if ((Object)(object)component != (Object)null) { component.Teleport(position, ((Component)playerAvatar).transform.rotation); } } playerAvatar.Spawn(position, ((Component)playerAvatar).transform.rotation); tcs.TrySetResult(result: true); } catch (Exception arg2) { CrowdControlMod.mls.LogError((object)$"Error reviving player: {arg2}"); tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to revive player: {arg}"); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) bool random = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: false, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be teleported."); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be teleported."); } int actorNumber2 = photonView.Owner.ActorNumber; PlayerAvatar result2 = HelperUtils.FindRandomAvatar(actorNumber2).Result; if ((Object)(object)result2 == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be teleported."); } PhotonView photonViewTarget = ((Component)result2).GetComponent(); if ((Object)(object)photonViewTarget == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be teleported."); } Vector3 position = ((Component)result2).transform.position; _ = ((Component)result2).transform.rotation; TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); try { RPCCommands.MessageHandler.SendMessageToHost("player_teleport", request.id, actorNumber, actorNumber2, new Dictionary { { "position", new { position.x, position.y, position.z } } }); if (!tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } CrowdResponse.Status result3 = tcs.Task.Result; if (result3 == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_005b: 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) MissionUI instance = Singleton.Instance; if (random && instance != null) { instance.MissionText("CC Teleported " + photonView.Owner.NickName + " to " + photonViewTarget.Owner.NickName + "!", Color.red, Color.red, 1f); } }); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(result3); } catch (Exception) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to heal player"); } } } public class PlayerTeleportToExtractionEffect : BaseEffect { public PlayerTeleportToExtractionEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) bool random = request.code.ToLowerInvariant().Contains("random"); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: false, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be teleported."); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Player is unable to be teleported."); } int actorNumber2 = photonView.Owner.ActorNumber; TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.id, delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); try { ExtractionPoint result2 = HelperUtils.FindRandomExtractionPoint().Result; if ((Object)(object)result2 == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "No Extraction Points found."); } Vector3 position = ((Component)result2).transform.position; position.y += 5f; RPCCommands.MessageHandler.SendMessageToHost("player_teleport", request.id, actorNumber, actorNumber2, new Dictionary { { "position", new { position.x, position.y, position.z } } }); if (!tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT)) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_RETRY); } CrowdResponse.Status result3 = tcs.Task.Result; if (result3 == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (random && instance != null) { instance.MissionText("CC Teleported " + photonView.Owner.NickName + " to Extractor!", Color.red, Color.red, 1f); } }); } RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(result3); } catch (Exception) { RPCCommands.MessageHandler.RemoveResponder(request.id); return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Failed to heal player"); } } } public class PraiseCrowdControlEffect : BaseEffect { public PraiseCrowdControlEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public override CrowdResponse Execute() { //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) if (TimedThread.isRunning(TimedType.KILL)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } if (TimedThread.isRunning(TimedType.PRAISE)) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_RETRY); } request.code.ToLowerInvariant().Contains("random_"); bool flag = false; Player localPlayer = PhotonNetwork.LocalPlayer; int num = ((localPlayer != null) ? localPlayer.ActorNumber : (-1)); if (num == -1) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } try { PlayerHealth result = HelperUtils.FindPlayerHealthByAvatarNumber(num).Result; if ((Object)(object)result == (Object)null) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if (!((Behaviour)result).isActiveAndEnabled) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } if ((Object)(object)((Component)result).GetComponent() == (Object)null) { return new CrowdResponse(request.GetReqID(), CrowdResponse.Status.STATUS_FAILURE); } List list = new List { "I LOVE CROWD CONTROL!", "CROWD CONTROL IS THE BEST!", "THANK YOU CROWD CONTROL!", "CROWD CONTROL MAKES THIS GAME SO MUCH BETTER!", "I CAN'T PLAY WITHOUT CROWD CONTROL!", "CROWD CONTROL IS AMAZING!" }; string text = list[Random.Range(0, list.Count)]; if ((Object)(object)ChatManager.instance != (Object)null) { ChatManager.instance.PossessChatScheduleStart(2); ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, Color.magenta, 0f, false, 0, (UnityEvent)null); ChatManager.instance.PossessChatScheduleEnd(); } if (result != null) { result.EyeMaterialOverride((EyeOverrideState)3, 0.25f, 0); } if (result != null) { result.EyeMaterialOverrideRPC((EyeOverrideState)3, true, default(PhotonMessageInfo)); } flag = true; } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("Error executing PraiseCrowdControlEffect: " + ex.Message)); flag = false; } new Thread(new TimedThread(request.GetReqID(), TimedType.PRAISE, 3000).Run).Start(); return new TimedResponse(request.GetReqID(), 3000, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } } public class SpawnCollectableEffect : BaseEffect { public class CoroutineRunner : MonoBehaviour { private static CoroutineRunner _instance; public static CoroutineRunner Instance { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_instance)) { GameObject val = new GameObject("CoroutineRunner"); _instance = val.AddComponent(); Object.DontDestroyOnLoad((Object)val); } return _instance; } } public static void RunCoroutine(IEnumerator routine) { ((MonoBehaviour)Instance).StartCoroutine(routine); } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GameObject spawnedItem; public PhotonView itemPhotonView; public string itemPathForLog; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 3; return true; case 3: <>1__state = -1; if (!Object.op_Implicit((Object)(object)spawnedItem)) { return false; } ActivateTrapValuableAfterSpawn(spawnedItem, itemPhotonView, itemPathForLog); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ItemRubberDuck rubberDuck; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; if (Object.op_Implicit((Object)(object)rubberDuck)) { rubberDuck.Quack(); } 5__2++; break; } if (5__2 < 8) { <>2__current = (object)new WaitForSeconds(0.05f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly HashSet DistributedSpawnItems = new HashSet(StringComparer.OrdinalIgnoreCase) { "items/Item Cart Medium", "items/Item Cart Small" }; private static readonly HashSet ValuablePathsWithTrapActivation = new HashSet(StringComparer.OrdinalIgnoreCase) { "valuables/03 medium/Valuable Manor Bottle", "valuables/02 small/Valuable Wizard Chomp Book", "valuables/03 medium/Valuable Manor Clown", "valuables/03 medium/Valuable Arctic Fan", "valuables/02 small/Valuable Manor Frog", "valuables/02 small/Valuable Manor Music Box", "valuables/03 medium/Valuable Arctic Propane Tank", "valuables/03 medium/Valuable Manor Gramophone", "valuables/03 medium/Valuable Manor Radio", "valuables/04 big/Valuable Manor Television", "valuables/02 small/Valuable Manor Toy Monkey", "valuables/05 wide/Valuable Manor Animal Crate", "valuables/07 very tall/Valuable Manor Grandfather Clock", "valuables/04 big/Valuable Arctic Ice Saw", "valuables/04 big/Valuable Arctic Barrel", "valuables/07 very tall/Valuable Wizard Broom" }; private static readonly Dictionary ItemHalfExtentsOverrides = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "items/Item Cart Medium", new Vector3(0.6f, 0.6f, 0.9f) }, { "items/Item Cart Small", new Vector3(0.5f, 0.5f, 0.8f) } }; private const float PlayerClearanceRadius = 1.1f; private const float FrontConeDegrees = 110f; private const float FrontMaxRadius = 2.8f; private const float FrontSpacing = 0.75f; private const int FrontMaxSamples = 48; private const float RingMaxRadius = 4f; private const float RingBaseRadius = 1.4f; private const float RingSpacing = 0.85f; private const int RingMaxSamples = 80; private const float GroundProbeHeight = 4f; private const float GroundProbeDown = 8f; private static readonly Dictionary ItemPaths = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "ItemCartMedium", "items/Item Cart Medium" }, { "ItemCartSmall", "items/Item Cart Small" }, { "ItemDroneBattery", "items/Item Drone Battery" }, { "ItemDroneFeather", "items/Item Drone Feather" }, { "ItemDroneIndestructible", "items/Item Drone Indestructible" }, { "ItemDroneTorque", "items/Item Drone Torque" }, { "ItemDroneZeroGravity", "items/Item Drone Zero Gravity" }, { "ItemExtractionTracker", "items/Item Extraction Tracker" }, { "ItemGrenadeDuctTaped", "items/Item Grenade Duct Taped" }, { "ItemGrenadeExplosive", "items/Item Grenade Explosive" }, { "ItemGrenadeHuman", "items/Item Grenade Human" }, { "ItemGrenadeShockwave", "items/Item Grenade Shockwave" }, { "ItemGrenadeStun", "items/Item Grenade Stun" }, { "ItemGunHandgun", "items/Item Gun Handgun" }, { "ItemGunShotgun", "items/Item Gun Shotgun" }, { "ItemGunTranq", "items/Item Gun Tranq" }, { "ItemHealthPackLarge", "items/Item Health Pack Large" }, { "ItemHealthPackMedium", "items/Item Health Pack Medium" }, { "ItemHealthPackSmall", "items/Item Health Pack Small" }, { "ItemMeleeBaseballBat", "items/Item Melee Baseball Bat" }, { "ItemMeleeFryingPan", "items/Item Melee Frying Pan" }, { "ItemMeleeInflatableHammer", "items/Item Melee Inflatable Hammer" }, { "ItemMeleeSledgeHammer", "items/Item Melee Sledge Hammer" }, { "ItemMeleeSword", "items/Item Melee Sword" }, { "ItemMineExplosive", "items/Item Mine Explosive" }, { "ItemMineShockwave", "items/Item Mine Shockwave" }, { "ItemMineStun", "items/Item Mine Stun" }, { "ItemOrbZeroGravity", "items/Item Orb Zero Gravity" }, { "ItemPowerCrystal", "items/Item Power Crystal" }, { "ItemRubberDuck", "items/Item Rubber Duck" }, { "ItemUpgradeMapPlayerCount", "items/Item Upgrade Map Player Count" }, { "ItemUpgradePlayerEnergy", "items/Item Upgrade Player Energy" }, { "ItemUpgradePlayerExtraJump", "items/Item Upgrade Player Extra Jump" }, { "ItemUpgradePlayerGrabRange", "items/Item Upgrade Player Grab Range" }, { "ItemUpgradePlayerGrabStrength", "items/Item Upgrade Player Grab Strength" }, { "ItemUpgradePlayerGrabThrow", "items/Item Upgrade Player Grab Throw" }, { "ItemUpgradePlayerHealth", "items/Item Upgrade Player Health" }, { "ItemUpgradePlayerSprintSpeed", "items/Item Upgrade Player Sprint Speed" }, { "ItemUpgradePlayerTumbleLaunch", "items/Item Upgrade Player Tumble Launch" }, { "ItemValuableTracker", "items/Item Valuable Tracker" }, { "ValuableDiamond", "Valuables/01 Tiny/Valuable Wizard Diamond" }, { "ValuableEmeraldBracelet", "valuables/01 tiny/Valuable Manor Emerald Bracelet" }, { "ValuableGoblet", "valuables/01 tiny/Valuable Manor Goblet" }, { "ValuableOcarina", "valuables/01 tiny/Valuable Manor Ocarina" }, { "ValuablePocketWatch", "valuables/01 tiny/Valuable Manor Pocket Watch" }, { "ValuableUraniumMug", "valuables/01 tiny/Valuable Manor Uranium Mug" }, { "ValuableArcticBonsai", "valuables/02 small/Valuable Arctic Bonsai" }, { "ValuableArcticHDD", "valuables/02 small/Valuable Arctic HDD" }, { "ValuableChompBook", "valuables/02 small/Valuable Wizard Chomp Book" }, { "ValuableCrown", "valuables/02 small/Valuable Wizard Crown" }, { "ValuableDoll", "valuables/02 small/Valuable Manor Doll" }, { "ValuableFrog", "valuables/02 small/Valuable Manor Frog" }, { "ValuableGemBox", "valuables/02 small/Valuable Wizard Gem Box" }, { "ValuableGlobe", "valuables/02 small/Valuable Manor Globe" }, { "ValuableLovePotion", "valuables/02 small/Valuable Wizard Love Potion" }, { "ValuableMoney", "valuables/02 small/Valuable Manor Money" }, { "ValuableMusicBox", "valuables/02 small/Valuable Manor Music Box" }, { "ValuableToyMonkey", "valuables/02 small/Valuable Manor Toy Monkey" }, { "ValuableUraniumPlate", "valuables/02 small/Valuable Manor Uranium Plate" }, { "ValuableVaseSmall", "valuables/02 small/Valuable Manor Vase Small" }, { "ValuableArctic3DPrinter", "valuables/03 medium/Valuable Arctic 3D Printer" }, { "ValuableArcticLaptop", "valuables/03 medium/Valuable Arctic Laptop" }, { "ValuableArcticPropaneTank", "valuables/03 medium/Valuable Arctic Propane Tank" }, { "ValuableArcticSampleSixPack", "valuables/03 medium/Valuable Arctic Sample Six Pack" }, { "ValuableArcticSample", "valuables/03 medium/Valuable Arctic Sample" }, { "ValuableBottle", "valuables/03 medium/Valuable Manor Bottle" }, { "ValuableClown", "valuables/03 medium/Valuable Manor Clown" }, { "ValuableComputer", "valuables/03 medium/Valuable Arctic Computer" }, { "ValuableFan", "valuables/03 medium/Valuable Arctic Fan" }, { "ValuableGramophone", "valuables/03 medium/Valuable Manor Gramophone" }, { "ValuableMarbleTable", "valuables/03 medium/Valuable Marble Table" }, { "ValuableRadio", "valuables/03 medium/Valuable Manor Radio" }, { "ValuableShipInBottle", "valuables/03 medium/Valuable Manor Ship in a bottle" }, { "ValuableTrophy", "valuables/03 medium/Valuable Manor Trophy" }, { "ValuableVase", "valuables/03 medium/Valuable Manor Vase" }, { "ValuableWizardGoblinHead", "valuables/03 medium/Valuable Wizard Goblin Head" }, { "ValuableWizardPowerCrystal", "valuables/03 medium/Valuable Wizard Power Crystal" }, { "ValuableWizardTimeGlass", "valuables/03 medium/Valuable Wizard Time Glass" }, { "ValuableArcticBarrel", "valuables/04 big/Valuable Arctic Barrel" }, { "ValuableArcticBigSample", "valuables/04 big/Valuable Arctic Big Sample" }, { "ValuableArcticCreatureLeg", "valuables/04 big/Valuable Arctic Creature Leg" }, { "ValuableArcticFlamethrower", "valuables/04 big/Valuable Arctic Flamethrower" }, { "ValuableArcticGuitar", "valuables/04 big/Valuable Arctic Guitar" }, { "ValuableArcticSampleCooler", "valuables/04 big/Valuable Arctic Sample Cooler" }, { "ValuableDiamondDisplay", "valuables/04 big/Valuable Manor Diamond Display" }, { "ValuableIceSaw", "valuables/04 big/Valuable Arctic Ice Saw" }, { "ValuableScreamDoll", "valuables/04 big/Valuable Manor Scream Doll" }, { "ValuableTelevision", "valuables/04 big/Valuable Manor Television" }, { "ValuableVaseBig", "valuables/04 big/Valuable Manor Vase Big" }, { "ValuableWizardCubeOfKnowledge", "valuables/04 big/Valuable Wizard Cube of Knowledge" }, { "ValuableWizardMasterPotion", "valuables/04 big/Valuable Wizard Master Potion" }, { "ValuableAnimalCrate", "valuables/05 wide/Valuable Manor Animal Crate" }, { "ValuableArcticIceBlock", "valuables/05 wide/Valuable Arctic Ice Block" }, { "ValuableDinosaur", "valuables/05 wide/Valuable Manor Dinosaur" }, { "ValuablePiano", "valuables/05 wide/Valuable Manor Piano" }, { "ValuableWizardGriffinStatue", "valuables/05 wide/Valuable Wizard Griffin Statue" }, { "ValuableArcticScienceStation", "valuables/06 tall/Valuable Arctic Science Station" }, { "ValuableHarp", "valuables/06 tall/Valuable Manor Harp" }, { "ValuablePainting", "valuables/06 tall/Valuable Manor Painting" }, { "ValuableWizardDumgolfsStaff", "valuables/06 tall/Valuable Wizard Dumgolfs Staff" }, { "ValuableWizardSword", "valuables/06 tall/Valuable Wizard Sword" }, { "ValuableArcticServerRack", "valuables/07 very tall/Valuable Arctic Server Rack" }, { "ValuableGoldenStatue", "valuables/07 very tall/Valuable Manor Golden Statue" }, { "ValuableGrandfatherClock", "valuables/07 very tall/Valuable Manor Grandfather Clock" }, { "ValuableWizardBroom", "valuables/07 very tall/Valuable Wizard Broom" } }; private static void TryRpcTrapStartForActivatedValuable(GameObject spawnedItem, PhotonView itemPhotonView, string itemPathForLog) { CoroutineRunner.RunCoroutine(ActivateTrapValuableRoutine(spawnedItem, itemPhotonView, itemPathForLog)); } [IteratorStateMachine(typeof(d__3))] private static IEnumerator ActivateTrapValuableRoutine(GameObject spawnedItem, PhotonView itemPhotonView, string itemPathForLog) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { spawnedItem = spawnedItem, itemPhotonView = itemPhotonView, itemPathForLog = itemPathForLog }; } private static void ActivateTrapValuableAfterSpawn(GameObject spawnedItem, PhotonView itemPhotonView, string itemPathForLog) { Trap val = spawnedItem.GetComponent() ?? spawnedItem.GetComponentInChildren(true); if ((Object)(object)val == (Object)null) { CrowdControlMod.mls.LogWarning((object)("Activated trap valuable (" + itemPathForLog + "): no Trap on spawned prefab.")); return; } PhotonView val2 = ((Component)val).GetComponent() ?? ((Component)val).GetComponentInParent(); if (val2 == null) { val2 = itemPhotonView; } bool flag = itemPathForLog.Equals("valuables/03 medium/Valuable Manor Bottle", StringComparison.OrdinalIgnoreCase); if ((Object)(object)val2 != (Object)null) { try { val2.RPC("TrapStartRPC", (RpcTarget)0, Array.Empty()); return; } catch (Exception ex) { Exception ex2 = ex.InnerException ?? ex; CrowdControlMod.mls.LogWarning((object)("TrapStartRPC failed for " + itemPathForLog + ": " + ex2.Message)); } } try { if (flag) { BottleTrap val3 = (BottleTrap)(object)((val is BottleTrap) ? val : null); if (val3 != null) { val3.TrapActivate(); return; } } val.TrapStart(); } catch (Exception ex3) { CrowdControlMod.mls.LogError((object)("Trap fallback activation failed for " + itemPathForLog + ": " + ex3.Message)); } } private static Vector3 GetHalfExtentsFor(string itemPath) { //IL_0020: 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) if (ItemHalfExtentsOverrides.TryGetValue(itemPath, out var value)) { return value; } return new Vector3(0.5f, 0.5f, 0.5f); } private static bool TryFindSpawnPose(string itemPath, Vector3 playerPos, Vector3 playerForward, Quaternion desiredRotation, out Vector3 spawnPos, out Quaternion spawnRot, LayerMask groundMask = default(LayerMask)) { //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_000a: 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_0013: 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_001a: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_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_005d: 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_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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) //IL_007b: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if (LayerMask.op_Implicit(groundMask) == 0) { groundMask = LayerMask.op_Implicit(-5); } Vector3 val = Vector3.ProjectOnPlane(playerForward, Vector3.up); Vector3 val2 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f) { val2 = Vector3.forward; } val = Vector3.Cross(Vector3.up, val2); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 halfExtentsFor = GetHalfExtentsFor(itemPath); Vector3 inflated = halfExtentsFor * 1.15f; float num = 0.9599311f; int num2 = Mathf.Max(1, Mathf.CeilToInt(num / 0.17453292f)); int num3 = 0; for (int i = 0; i < 6; i++) { if (num3 >= 48) { break; } float num4 = Mathf.Min(2.8f, 0.9f + 0.75f * Mathf.Sqrt((float)(i + 1))); for (int j = 0; j <= num2; j++) { if (num3 >= 48) { break; } for (int k = ((j != 0) ? (-1) : 0); k <= 1; k += 2) { if (num3 >= 48) { break; } if (j == 0 && k != 0) { break; } float num5 = (float)j * 0.17453292f * ((k == 0) ? 1f : ((float)k)); if (!(Mathf.Abs(num5) > num)) { val = val2 * Mathf.Cos(num5) + normalized * Mathf.Sin(num5); Vector3 normalized2 = ((Vector3)(ref val)).normalized; Vector3 candidateXZ2 = playerPos + normalized2 * num4; num3++; if (Accept(candidateXZ2, out var hitPos2)) { spawnPos = hitPos2; spawnRot = desiredRotation; return true; } } } } } float num6 = (float)Math.PI / 2f; for (int l = 0; l < 80; l++) { float num7 = Mathf.Min(4f, 1.4f + 0.85f * Mathf.Sqrt((float)l)); Vector3 val3 = (Mathf.Cos(num6) * normalized + Mathf.Sin(num6) * val2) * num7; if (Accept(playerPos + val3, out var hitPos3)) { spawnPos = hitPos3; spawnRot = desiredRotation; return true; } num6 += 2.3999631f; } spawnPos = default(Vector3); spawnRot = default(Quaternion); return false; bool Accept(Vector3 candidateXZ, out Vector3 hitPos) { //IL_0001: 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: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0081: 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_0084: 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_009b: 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) hitPos = default(Vector3); Vector3 val4 = candidateXZ - playerPos; if (((Vector3)(ref val4)).sqrMagnitude < 1.21f) { return false; } RaycastHit val5 = default(RaycastHit); if (!Physics.Raycast(candidateXZ + Vector3.up * 4f, Vector3.down, ref val5, 12f, LayerMask.op_Implicit(groundMask), (QueryTriggerInteraction)1)) { return false; } Vector3 val6 = ((RaycastHit)(ref val5)).point + Vector3.up * (inflated.y + 0.05f); if (Physics.CheckBox(val6, inflated, desiredRotation, -1, (QueryTriggerInteraction)1)) { return false; } hitPos = val6; return true; } } [IteratorStateMachine(typeof(d__21))] public static IEnumerator QuackSequence(ItemRubberDuck rubberDuck) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__21(0) { rubberDuck = rubberDuck }; } public SpawnCollectableEffect(ControlClient client, CrowdRequest request) : base(client, request) { } public static string FormatItemName(string item) { string text = Regex.Replace(item, "(? tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0011: 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_0031: Unknown result type (might be due to invalid IL or missing references) try { SpawnItem(item, ((Component)playerAvatar).transform.position, ((Component)playerAvatar).transform.forward, ((Component)playerAvatar).transform.rotation, activated); tcs.TrySetResult(result: true); } catch (Exception arg2) { CrowdControlMod.mls.LogInfo((object)$"Failed to spawn item: {arg2}"); tcs.TrySetResult(result: false); } }); bool flag = await tcs.Task; RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, (!flag) ? CrowdResponse.Status.STATUS_FAILURE : CrowdResponse.Status.STATUS_SUCCESS); } catch (Exception arg) { CrowdControlMod.mls.LogInfo((object)$"Failed to process spawn data: {arg}"); RPCCommands.MessageHandler.SendResponse(message.id, message.senderID, CrowdResponse.Status.STATUS_FAILURE); } } public override CrowdResponse Execute() { CrowdResponse.Status status = CrowdResponse.Status.STATUS_SUCCESS; string message = ""; string item = ((request.code.Split(new char[1] { '_' }).Length > 1) ? request.code.Split(new char[1] { '_' })[1] : string.Empty); if (string.IsNullOrEmpty(item)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Invalid item code"); } bool activated = request.code.Contains("ActivatedItem"); bool random = request.code.ToLowerInvariant().Contains("random"); if (!ItemPaths.TryGetValue(item, out var value)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Unknown item"); } int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; PlayerAvatar result = HelperUtils.FindPlayerAvatarByNumber(actorNumber, alive: true, random).Result; if ((Object)(object)result == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Cannot Spawn Items when player is dead!"); } PhotonView photonView = ((Component)result).GetComponent(); if ((Object)(object)photonView == (Object)null) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Cannot Spawn Items when player is dead!"); } int actorNumber2 = photonView.Owner.ActorNumber; FieldInfo field = typeof(PlayerAvatar).GetField("isDisabled", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null && (bool)field.GetValue(result)) { return CreateResponse(CrowdResponse.Status.STATUS_FAILURE, "Cannot Spawn Items when player is dead!"); } try { TaskCompletionSource tcs = new TaskCompletionSource(); RPCCommands.MessageHandler.AddResponder(request.GetReqID(), delegate(CrowdResponse.Status s) { tcs.SetResult(s); }); RPCCommands.MessageHandler.SendMessageToHost("spawn_collectable", request.GetReqID(), actorNumber, actorNumber2, new Dictionary { { "item", value }, { "activated", activated } }); status = (tcs.Task.Wait(CrowdDelegates.SERVER_TIMEOUT) ? tcs.Task.Result : CrowdResponse.Status.STATUS_RETRY); RPCCommands.MessageHandler.RemoveResponder(request.GetReqID()); } catch (Exception) { status = CrowdResponse.Status.STATUS_FAILURE; message = "Failed to spawn collectable"; } if (status == CrowdResponse.Status.STATUS_SUCCESS) { CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) MissionUI instance = Singleton.Instance; if (instance != null) { instance.MissionText("CC Spawned " + (activated ? "Activated " : "") + FormatItemName(item) + (random ? ("on " + photonView.Owner.NickName) : ""), Color.green, Color.green, 1f); } }); } return CreateResponse(status, message); } public static bool SpawnItem(string item, Vector3 playerPosition, Vector3 playerForward, Quaternion rotation, bool activated = false) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) bool success = false; try { if (string.IsNullOrEmpty(item)) { CrowdControlMod.mls.LogError((object)"SpawnItem: Item path is null or empty"); return false; } if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.mls.LogError((object)"SpawnItem: Not connected to network or room"); return false; } CrowdControlMod.ActionQueue.Enqueue(delegate { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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) try { bool flag = true; Vector3 val = playerPosition + Vector3.up * 1f; Quaternion val2 = rotation; if (DistributedSpawnItems.Contains(item)) { if (!TryFindSpawnPose(item, playerPosition, playerForward, rotation, out var spawnPos, out var spawnRot)) { CrowdControlMod.mls.LogInfo((object)("SpawnItem: No safe spot for " + item + "; skipping spawn.")); flag = false; success = false; } else { val = spawnPos; val2 = spawnRot; } } if (flag) { GameObject val3 = PhotonNetwork.InstantiateRoomObject(item, val, val2, (byte)0, (object[])null); if ((Object)(object)val3 == (Object)null) { CrowdControlMod.mls.LogError((object)("SpawnItem: Failed to instantiate " + item)); success = false; } else { success = true; } if (item.Contains("items/") && CrowdControlMod.CrowdControlConfig.spawnedItemsRemainPurchased.Value) { StatsManager instance = Singleton.Instance; string text = item.Substring(item.IndexOf("items/") + "items/".Length); try { instance.ItemPurchase(text); } catch { } } if (item == "items/Item Gun Shotgun" && success) { ItemGun val4 = ((val3 != null) ? val3.GetComponent() : null); if (Object.op_Implicit((Object)(object)val4) && val4.numberOfBullets != 6) { CrowdControlMod.mls.LogError((object)$"Shotgun spawned with {val4.numberOfBullets} shells; respawning."); PhotonNetwork.InstantiateRoomObject(item, val, val2, (byte)0, (object[])null); } } if (activated && Object.op_Implicit((Object)(object)val3) && success) { PhotonView val5 = val3.GetComponent() ?? val3.GetComponentInChildren(true); if (item == "items/Item Rubber Duck") { CoroutineRunner.RunCoroutine(QuackSequence(val3.GetComponent())); } if (item == "valuables/06 tall/Valuable Wizard Dumgolfs Staff" && (Object)(object)val5 != (Object)null) { val5.RPC("StaffLaserRPC", (RpcTarget)0, new object[1] { 10f }); } if (ValuablePathsWithTrapActivation.Contains(item)) { TryRpcTrapStartForActivatedValuable(val3, val5, item); } } } } catch (Exception ex2) { CrowdControlMod.mls.LogError((object)("SpawnItem action queue error: " + ex2.Message + "\n" + ex2.StackTrace)); success = false; } }); return success; } catch (Exception ex) { CrowdControlMod.mls.LogError((object)("SpawnItem outer error: " + ex.Message + "\n" + ex.StackTrace)); return false; } } } }