using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using BepinControl; using ConnectorLib.JSON; using CrowdControl; using CrowdControl.Delegates.Effects; using CrowdControl.Delegates.Effects.Implementations; using CrowdControl.Delegates.Metadata; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Peak.Afflictions; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class ParamCollectionAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepinControl { public class RPCCommands { 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, IEnumerator, IDisposable { 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, (EffectStatus)((!success) ? 1 : 0)); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static MessageHandler instance; public static PhotonView networkView; private static ConcurrentQueue messageQueue = new ConcurrentQueue(); public static void Initialize() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)instance != (Object)null) { return; } CrowdControlMod.Instance.Logger.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.Instance.Logger.LogInfo((object)$"MessageHandler initialized with PhotonView {networkView.ViewID}"); Object.DontDestroyOnLoad((Object)(object)val); lock (networkLock) { _isNetworkReady = null; _isViewValid = null; return; } } CrowdControlMod.Instance.Logger.LogError((object)"Failed to add PhotonView to MessageHandler"); CrowdControlMod.modActivated = false; } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error in Initialize: " + ex.Message)); CrowdControlMod.Instance.Logger.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 NetworkMessage 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.Instance.Logger.LogError((object)("Failed to send message: " + ex.Message)); CrowdControlMod.Instance.Logger.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.Instance.Logger.LogInfo((object)$"Failed to queue message: {arg}"); } } public static void SendMessageToAll(string type, Dictionary payload = null) { try { if (IsNetworkReady()) { int senderID = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0); NetworkMessage item = new NetworkMessage(type, 0, senderID, 0, payload); messageQueue.Enqueue(item); } } catch (Exception arg) { CrowdControlMod.Instance.Logger.LogInfo((object)$"Failed to queue broadcast 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); CrowdControlMod.Instance.Logger.LogInfo((object)$"[OnNetworkMessageRPC] Received message type: {networkMessage.type}, targetActor: {networkMessage.targetActor}, local ActorNumber: {PhotonNetwork.LocalPlayer.ActorNumber}"); if (networkMessage.type == "revive_self") { CrowdControlMod.Instance.Logger.LogInfo((object)$"[OnNetworkMessageRPC] revive_self: targetActor={networkMessage.targetActor}, local={PhotonNetwork.LocalPlayer.ActorNumber}"); } if (networkMessage == null) { CrowdControlMod.Instance.Logger.LogError((object)"Failed to deserialize message"); return; } if (networkMessage.type == "custom_event") { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HOST] Received custom event message from player {networkMessage.senderID}"); CrowdControlMod.Instance.Logger.LogInfo((object)("[HOST] Message payload: " + JsonConvert.SerializeObject((object)networkMessage.payload))); if (networkMessage.payload.TryGetValue("eventName", out object value)) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HOST] Event name: {value}"); } if (networkMessage.payload.TryGetValue("data", out object value2)) { CrowdControlMod.Instance.Logger.LogInfo((object)("[HOST] Event data: " + JsonConvert.SerializeObject(value2))); } } if (networkMessage.type == "response") { ProcessMessage(jsonMessage); } else if (networkMessage.type == "storm_visual") { StormEffect.HandleStormVisualMessage(networkMessage.payload); } else if (networkMessage.type == "CC_CONNECT") { ModVersionCheck(networkMessage); } else if (networkMessage.type == "override_voice") { CrowdControlMod.Instance.Logger.LogInfo((object)"Voice override effect triggered (not implemented)"); } else if (networkMessage.type == "revive_self" && networkMessage.targetActor == PhotonNetwork.LocalPlayer.ActorNumber) { CrowdControlMod.Instance.Logger.LogInfo((object)"[LOCAL] Received revive_self request from host"); HandleReviveSelf(); } else { if (!PhotonNetwork.IsMasterClient) { return; } if (networkMessage.type == "custom_event") { if (networkMessage.payload.TryGetValue("eventName", out object value3) && networkMessage.payload.TryGetValue("data", out object value4)) { string text = value3.ToString(); JObject val = (JObject)((value4 is JObject) ? value4 : null); Dictionary dictionary2 = ((val != null) ? ((JToken)val).ToObject>() : ((!(value4 is Dictionary dictionary)) ? new Dictionary() : dictionary)); string requestId = networkMessage.id.ToString(); CrowdControlMod.Instance.Logger.LogInfo((object)("[HOST] Processing custom event '" + text + "' with data: " + JsonConvert.SerializeObject((object)dictionary2))); CustomEventSystem.Instance.OnCustomEventRequest(text, dictionary2, requestId, networkMessage.senderID); } else { CrowdControlMod.Instance.Logger.LogError((object)("[HOST] Missing required fields in custom event message. Payload: " + JsonConvert.SerializeObject((object)networkMessage.payload))); } } else { CrowdControlMod.Instance.Logger.LogWarning((object)("Unknown message type: " + networkMessage.type)); } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Failed to process message: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { } public static void SendResponse(int id, int senderID, EffectStatus status, string message = "", Dictionary payload = null) { try { int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; Dictionary dictionary = new Dictionary { { "status", ((object)(EffectStatus)(ref 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.Instance.Logger.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; } private static void HandleReviveSelf() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) try { Character character = Character.localCharacter; if (!Object.op_Implicit((Object)(object)character)) { CrowdControlMod.Instance.Logger.LogError((object)"[HandleReviveSelf] Local character not found"); return; } CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveSelf] State before revive: dead={character.data.dead}, fullyPassedOut={character.data.fullyPassedOut}"); if (!character.data.dead && !character.data.fullyPassedOut) { CrowdControlMod.Instance.Logger.LogWarning((object)"[HandleReviveSelf] Local character is not dead or passed out, forcing revive anyway!"); Character.Revive(); CrowdControlMod.Instance.Logger.LogInfo((object)"[HandleReviveSelf] Forced revive for local player"); return; } Rigidbody component = ((Component)character).GetComponent(); if ((Object)(object)component != (Object)null) { component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.Sleep(); } if (character.data.dead) { CrowdControlMod.Instance.Logger.LogInfo((object)"[HandleReviveSelf] Reviving from dead"); Character.Revive(); } else if (character.data.fullyPassedOut) { CrowdControlMod.Instance.Logger.LogInfo((object)"[HandleReviveSelf] Reviving from fullyPassedOut"); Character.Revive(); } List list = Character.AllCharacters.Where((Character c) => (Object)(object)c != (Object)(object)character && !c.data.dead && !c.data.fullyPassedOut).ToList(); if (list.Count > 0) { Character val = list[Random.Range(0, list.Count)]; Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)val).transform).GetComponentsInChildren(); foreach (Transform val3 in componentsInChildren) { if (((Object)val3).name == "Hip") { val2 = val3.position + val3.forward * 1.5f + Vector3.up; break; } } character.WarpPlayerRPC(val2, true); } if ((Object)(object)component != (Object)null) { component.WakeUp(); } CrowdControlMod.Instance.Logger.LogInfo((object)"[HandleReviveSelf] Successfully revived local player"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("[HandleReviveSelf] Error reviving local player: " + ex.Message)); } } 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 (type == "revive_self") { CrowdControlMod.Instance.Logger.LogInfo((object)$"[SendRequest] Sending revive_self to RpcTarget.All (targetActor: {targetActor})"); networkView.RPC("OnNetworkMessageRPC", (RpcTarget)0, new object[1] { text }); } else { Player player = PhotonNetwork.CurrentRoom.GetPlayer(targetActor, false); networkView.RPC("OnNetworkMessageRPC", player, new object[1] { text }); } } catch (Exception arg) { CrowdControlMod.Instance.Logger.LogInfo((object)$"SEND REQUEST CRASHED {arg}"); } } public static void SendResponse(int id, int senderID, EffectStatus status, Dictionary payload) { try { string text = JsonConvert.SerializeObject((object)new ResponseMessage { id = id, senderID = senderID, status = ((object)(EffectStatus)(ref 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.Instance.Logger.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 Action _); } public static void ProcessMessage(string message) { try { if (string.IsNullOrEmpty(message)) { return; } JObject val = JObject.Parse(message); if (val == null) { CrowdControlMod.Instance.Logger.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()); ResponseMessage responseMessage2 = responseMessage; if (responseMessage2.payload.TryGetValue("custom_event_response", out object _)) { if (responseMessage2.payload.TryGetValue("requestId", out object value2) && responseMessage2.payload.TryGetValue("message", out object value3) && responseMessage2.payload.TryGetValue("data", out object value4)) { string requestId = value2.ToString(); string message2 = value3.ToString(); Dictionary data = (value4 as Dictionary) ?? new Dictionary(); bool success = responseMessage2.status == "Success"; CustomEventSystem.Instance.OnEventResponse(requestId, success, message2, data); } } else { ProcessResponse(responseMessage2); } return; } try { JsonConvert.DeserializeObject(message, jsonSettings); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error processing message2: " + ex.Message)); } } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("Error processing message: " + ex2.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex2.StackTrace)); } } private static void ProcessResponse(ResponseMessage message) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (message.senderID != PhotonNetwork.LocalPlayer.ActorNumber) { return; } if (message.id == 0 && message.version == "1.6.3.0") { CrowdControlMod.modActivated = true; } if (!rspResponders.TryGetValue(message.id, out Action value) || !pendingRequestIDs.Remove(message.id.ToString()) || !Enum.TryParse(message.status, out EffectStatus result)) { return; } try { value(result); } catch (Exception arg) { CrowdControlMod.Instance.Logger.LogInfo((object)$"Error processing response for message ID {message.id}: {arg}"); } } public static async Task ModVersionCheck(NetworkMessage message) { Convert.ToString(message.payload["version"]); _ = message.senderID; } } 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 readonly Dictionary PlayerVersions = new Dictionary(); 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.Instance.Logger.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; } } } } namespace CrowdControl { [BepInPlugin("WarpWorld.CrowdControl", "Crowd Control", "1.6.3.0")] public class CrowdControlMod : BaseUnityPlugin { [CompilerGenerated] private sealed class d__34 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CrowdControlMod <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown int num = <>1__state; CrowdControlMod crowdControlMod = <>4__this; checked { switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; try { Type type = Type.GetType("ItemDatabase, Assembly-CSharp"); if (type == null) { crowdControlMod.Logger.LogWarning((object)"ItemDatabase type not found"); return false; } PropertyInfo property = typeof(SingletonAsset<>).MakeGenericType(type).GetProperty("Instance", BindingFlags.Static | BindingFlags.Public); if (property == null) { crowdControlMod.Logger.LogWarning((object)"ItemDatabase.Instance property not found"); return false; } object value = property.GetValue(null); if (value == null) { crowdControlMod.Logger.LogWarning((object)"ItemDatabase instance is null, cannot log items"); return false; } crowdControlMod.Logger.LogInfo((object)"ItemDatabase instance found, starting to log items..."); FieldInfo field = value.GetType().GetField("itemLookup", BindingFlags.Instance | BindingFlags.Public); if (field == null) { crowdControlMod.Logger.LogWarning((object)"itemLookup field not found"); return false; } object value2 = field.GetValue(value); if (value2 == null) { crowdControlMod.Logger.LogWarning((object)"itemLookup is null"); return false; } crowdControlMod.Logger.LogInfo((object)("itemLookup type: " + value2.GetType().FullName)); Dictionary dictionary = new Dictionary(); int num2 = 0; PropertyInfo property2 = value2.GetType().GetProperty("Keys"); PropertyInfo property3 = value2.GetType().GetProperty("Item", new Type[1] { typeof(ushort) }); if (property2 != null && property3 != null) { if (property2.GetValue(value2) is IEnumerable enumerable) { foreach (object item in enumerable) { ushort key = (ushort)item; object value3 = property3.GetValue(value2, new object[1] { item }); if (value3 == null) { continue; } PropertyInfo property4 = value3.GetType().GetProperty("name"); if (property4 != null) { string value4 = property4.GetValue(value3) as string; if (!string.IsNullOrEmpty(value4)) { dictionary[key] = value4; num2++; } } } } } else { crowdControlMod.Logger.LogWarning((object)$"Could not access dictionary - keysProperty: {property2 != null}, dictIndexer: {property3 != null}"); } PropertyInfo property5 = value.GetType().GetProperty("Objects", BindingFlags.Instance | BindingFlags.Public); if (property5 != null) { object value5 = property5.GetValue(value); if (value5 != null) { PropertyInfo property6 = value5.GetType().GetProperty("Count"); if (property6 != null) { int num3 = (int)property6.GetValue(value5); crowdControlMod.Logger.LogInfo((object)$"Objects list has {num3} items"); PropertyInfo property7 = value5.GetType().GetProperty("Item", new Type[1] { typeof(int) }); if (property7 != null) { for (int i = 0; i < num3; i++) { object value6 = property7.GetValue(value5, new object[1] { i }); if (value6 == null) { continue; } PropertyInfo property8 = value6.GetType().GetProperty("name"); if (!(property8 != null)) { continue; } string value7 = property8.GetValue(value6) as string; ushort key2 = 0; PropertyInfo property9 = value2.GetType().GetProperty("Keys"); PropertyInfo property10 = value2.GetType().GetProperty("Item", new Type[1] { typeof(ushort) }); if (property9 != null && property10 != null && property9.GetValue(value2) is IEnumerable enumerable2) { foreach (object item2 in enumerable2) { ushort num4 = (ushort)item2; object value8 = property10.GetValue(value2, new object[1] { item2 }); if (value8 != null && value8.Equals(value6)) { key2 = num4; break; } } } if (!string.IsNullOrEmpty(value7) && !dictionary.ContainsKey(key2)) { dictionary[key2] = value7; num2++; } } } } } } crowdControlMod.Logger.LogInfo((object)$"Found {dictionary.Count} items in database (itemLookup: {num2})"); if (dictionary.Count == 0) { crowdControlMod.Logger.LogWarning((object)"No items found! Database may not be loaded yet."); return false; } foreach (KeyValuePair item3 in dictionary.OrderBy((KeyValuePair x) => x.Key)) { crowdControlMod.Logger.LogInfo((object)$"Item ID: {item3.Key} - Name: {item3.Value}"); } string text = Path.Combine(Paths.BepInExRootPath, "items_log.csv"); using (StreamWriter streamWriter = new StreamWriter(text, append: false)) { streamWriter.WriteLine("ID,Name"); foreach (KeyValuePair item4 in dictionary.OrderBy((KeyValuePair x) => x.Key)) { string arg = item4.Value.Replace(",", ";"); streamWriter.WriteLine($"{item4.Key},{arg}"); } } crowdControlMod.Logger.LogInfo((object)$"Items logged to CSV: {text} ({dictionary.Count} items)"); } catch (Exception ex) { crowdControlMod.Logger.LogError((object)("Error logging items: " + ex.Message)); crowdControlMod.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); } 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 const string MOD_GUID = "WarpWorld.CrowdControl"; public const string MOD_NAME = "Crowd Control"; public const string MOD_VERSION = "1.6.3.0"; private readonly Harmony harmony = new Harmony("WarpWorld.CrowdControl"); internal static bool modActivated = false; internal static bool modEnabled = true; private const float GAME_STATUS_UPDATE_INTERVAL = 1f; private float m_gameStatusUpdateTimer; public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger; internal static CrowdControlMod Instance { get; private set; } = null; public GameStateManager GameStateManager { get; private set; } public EffectLoader EffectLoader { get; private set; } public bool ClientConnected => Client.Connected; public NetworkClient Client { get; private set; } public Scheduler Scheduler { get; private set; } private void Awake() { Instance = this; Logger.LogInfo((object)"Loaded WarpWorld.CrowdControl. Patching."); harmony.PatchAll(); Logger.LogInfo((object)"Initializing Crowd Control"); try { GameStateManager = new GameStateManager(this); Client = new NetworkClient(this); EffectLoader = new EffectLoader(this, Client); Scheduler = new Scheduler(this, Client); _ = CustomEventSystem.Instance; RPCCommands.MessageHandler.Initialize(); } catch (Exception arg) { Logger.LogError((object)$"Crowd Control Init Error: {arg}"); } Logger.LogInfo((object)"Crowd Control Initialized"); } private void LogAllItems() { try { ((MonoBehaviour)this).StartCoroutine(LogAllItemsDelayed()); } catch (Exception ex) { Logger.LogError((object)("Error starting item logging: " + ex.Message)); } } [IteratorStateMachine(typeof(d__34))] private IEnumerator LogAllItemsDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__34(0) { <>4__this = this }; } private void FixedUpdate() { if (modEnabled) { m_gameStatusUpdateTimer += Time.fixedDeltaTime; if (m_gameStatusUpdateTimer >= 1f) { GameStateManager.UpdateGameState(); GameStateManager.UpdateTeleportRandomPlayerVisibility(); m_gameStatusUpdateTimer = 0f; } Scheduler?.Tick(); } } public void DisableMod() { modEnabled = false; Logger.LogInfo((object)"[HotReload] Mod disabled - safe to replace DLL"); } public void EnableMod() { modEnabled = true; Logger.LogInfo((object)"[HotReload] Mod enabled"); } } public class CustomEventSystem : MonoBehaviourPunCallbacks { public static bool EnableDebugLogging; private static CustomEventSystem _instance; private readonly ConcurrentDictionary _registeredEvents = new ConcurrentDictionary(); private readonly ConcurrentQueue _pendingRequests = new ConcurrentQueue(); private readonly ConcurrentDictionary> _responseCallbacks = new ConcurrentDictionary>(); public static CustomEventSystem Instance { get { //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_0027: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("CustomEventSystem"); _instance = val.AddComponent(); Object.DontDestroyOnLoad((Object)val); } return _instance; } } private void Awake() { if ((Object)(object)_instance == (Object)null) { _instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } else if ((Object)(object)_instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void Update() { EventRequest result; while (_pendingRequests.TryDequeue(out result)) { ProcessEventRequest(result); } } public bool RegisterEvent(string eventName, CustomEventHandler handler) { if (!PhotonNetwork.IsMasterClient) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogWarning((object)("Cannot register event '" + eventName + "' - not the host")); } return false; } if (_registeredEvents.TryAdd(eventName, handler)) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("Registered custom event: " + eventName)); } return true; } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogWarning((object)("Event '" + eventName + "' is already registered")); } return false; } public bool UnregisterEvent(string eventName) { if (!PhotonNetwork.IsMasterClient) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogWarning((object)("Cannot unregister event '" + eventName + "' - not the host")); } return false; } if (_registeredEvents.TryRemove(eventName, out CustomEventHandler _)) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("Unregistered custom event: " + eventName)); } return true; } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogWarning((object)("Event '" + eventName + "' was not registered")); } return false; } public bool TriggerEvent(string eventName, Dictionary data = null, Action callback = null) { if (PhotonNetwork.IsMasterClient) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogWarning((object)("Cannot trigger event '" + eventName + "' - you are the host")); } return false; } int id = Random.Range(1000000, 9999999); string text = id.ToString(); new EventRequest { Id = text, EventName = eventName, Data = (data ?? new Dictionary()), SenderId = PhotonNetwork.LocalPlayer.ActorNumber }; if (callback != null) { _responseCallbacks[text] = callback; } Dictionary dictionary = new Dictionary { ["eventName"] = eventName, ["data"] = data ?? new Dictionary() }; if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Sending event '" + eventName + "' to host with payload: " + JsonConvert.SerializeObject((object)dictionary))); } RPCCommands.MessageHandler.SendMessageToHost("custom_event", id, PhotonNetwork.LocalPlayer.ActorNumber, 0, dictionary); if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("Triggered custom event: " + eventName)); } return true; } private void ProcessEventRequest(EventRequest request) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Processing event request: " + request.EventName)); } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Request data: " + JsonConvert.SerializeObject((object)request.Data))); } if (!PhotonNetwork.IsMasterClient) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogWarning((object)"Received event request but not the host"); } return; } if (!_registeredEvents.TryGetValue(request.EventName, out CustomEventHandler value)) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("[CustomEventSystem] Event '" + request.EventName + "' not found in registered events")); } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Available events: " + string.Join(", ", _registeredEvents.Keys))); } SendEventResponse(request.Id, request.SenderId, success: false, "Event '" + request.EventName + "' not found"); return; } try { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Executing handler for event: " + request.EventName)); } EventResult eventResult = value(request.Data); if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[CustomEventSystem] Handler result: Success={eventResult.Success}, Message={eventResult.Message}"); } SendEventResponse(request.Id, request.SenderId, eventResult.Success, eventResult.Message, eventResult.Data); } catch (Exception ex) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("[CustomEventSystem] Error processing event '" + request.EventName + "': " + ex.Message)); } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("[CustomEventSystem] Stack trace: " + ex.StackTrace)); } SendEventResponse(request.Id, request.SenderId, success: false, "Error: " + ex.Message); } } private void SendEventResponse(string requestId, int senderId, bool success, string message = "", Dictionary data = null) { Dictionary payload = new Dictionary { ["custom_event_response"] = true, ["requestId"] = requestId, ["message"] = message, ["data"] = data ?? new Dictionary() }; RPCCommands.MessageHandler.SendResponse(int.Parse(requestId), senderId, (EffectStatus)((!success) ? 1 : 0), payload); } public void OnEventResponse(string requestId, bool success, string message, Dictionary data) { if (_responseCallbacks.TryRemove(requestId, out Action callback)) { EventResponse response = new EventResponse { Success = success, Message = message, Data = (data ?? new Dictionary()) }; UnityMainThreadDispatcher.Instance.Enqueue(delegate { callback?.Invoke(response); }); } } public void OnCustomEventRequest(string eventName, Dictionary data, string requestId, int senderId) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Received event request: " + eventName)); } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Request ID: " + requestId)); } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[CustomEventSystem] Sender ID: {senderId}"); } if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventSystem] Data: " + JsonConvert.SerializeObject((object)data))); } EventRequest item = new EventRequest { Id = requestId, EventName = eventName, Data = (data ?? new Dictionary()), SenderId = senderId }; _pendingRequests.Enqueue(item); if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)"[CustomEventSystem] Queued event request for processing"); } } public List GetRegisteredEvents() { return new List(_registeredEvents.Keys); } public void ClearAllEvents() { _registeredEvents.Clear(); if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)"Cleared all registered custom events"); } } public override void OnMasterClientSwitched(Player newMasterClient) { if (PhotonNetwork.IsMasterClient) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)"Became host - ready to register custom events"); } HostEventHandlers.RegisterAllHandlers(); } else { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)"No longer host - clearing registered events"); } ClearAllEvents(); } } public override void OnJoinedRoom() { if (PhotonNetwork.IsMasterClient) { if (EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)"Joined room as host - ready to register custom events"); } HostEventHandlers.RegisterAllHandlers(); } } } public delegate EventResult CustomEventHandler(Dictionary data); public class EventRequest { public string Id { get; set; } public string EventName { get; set; } public Dictionary Data { get; set; } public int SenderId { get; set; } } public class EventResult { public bool Success { get; set; } public string Message { get; set; } public Dictionary Data { get; set; } public static EventResult SuccessResult(string message = "", Dictionary data = null) { return new EventResult { Success = true, Message = message, Data = (data ?? new Dictionary()) }; } public static EventResult FailureResult(string message = "", Dictionary data = null) { return new EventResult { Success = false, Message = message, Data = (data ?? new Dictionary()) }; } } public class EventResponse { public bool Success { get; set; } public string Message { get; set; } public Dictionary Data { get; set; } } public class UnityMainThreadDispatcher : MonoBehaviour { private static UnityMainThreadDispatcher _instance; private readonly Queue _executionQueue = new Queue(); public static UnityMainThreadDispatcher Instance { get { //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_0027: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("UnityMainThreadDispatcher"); _instance = val.AddComponent(); Object.DontDestroyOnLoad((Object)val); } return _instance; } } public void Enqueue(Action action) { lock (_executionQueue) { _executionQueue.Enqueue(action); } } private void Update() { lock (_executionQueue) { while (_executionQueue.Count > 0) { _executionQueue.Dequeue()(); } } } } public class DelimitedStreamReader : IDisposable { [CompilerGenerated] private NetworkStream P; private readonly MemoryStream _memory_stream; public DelimitedStreamReader(NetworkStream stream) { P = stream; _memory_stream = new MemoryStream(); base..ctor(); } ~DelimitedStreamReader() { Dispose(disposing: false); } public void Dispose() { Dispose(disposing: true); } protected virtual void Dispose(bool disposing) { if (!disposing) { return; } try { _memory_stream.Dispose(); } catch { } } public string ReadUntilNullTerminator() { int num; while ((num = P.ReadByte()) != -1 && num != 0) { _memory_stream.WriteByte(checked((byte)num)); } if (num == -1) { throw new EndOfStreamException("Reached end of stream without finding a null terminator."); } string @string = Encoding.UTF8.GetString(_memory_stream.ToArray()); _memory_stream.SetLength(0L); return @string; } } internal static class GameNotifications { public static void Show(string message) { string message2 = message; if (string.IsNullOrWhiteSpace(message2)) { return; } UnityMainThreadDispatcher.Instance.Enqueue(delegate { try { UI_Notifications val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null) { val.AddNotification(message2); } else { PlayerConnectionLog val2 = Object.FindObjectOfType(); if ((Object)(object)val2 != (Object)null) { ((object)val2).GetType().GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(val2, new object[1] { message2 }); } } } catch (Exception ex) { CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { instance.Logger.LogWarning((object)("[GameNotifications] Failed to show notification: " + ex.Message)); } } }); } } public class GameStateManager { [CompilerGenerated] private CrowdControlMod P; public static bool? isHostLastStatus; private bool? _teleportRandomPlayerTargetsAvailable; private GameState? _last_game_state; public GameStateManager(CrowdControlMod mod) { P = mod; base..ctor(); } public static async Task DialogMsgAsync(string message, bool playSound) { } public void UpdateTeleportRandomPlayerVisibility() { if (!P.Client.Connected) { return; } bool flag = PlayerTeleport.HasValidRandomPlayerTargets(); if (_teleportRandomPlayerTargetsAvailable != flag) { _teleportRandomPlayerTargetsAvailable = flag; if (flag) { P.Client.ShowEffects("teleport_random_player"); } else { P.Client.HideEffects("teleport_random_player"); } } } public static void updateEffects() { bool isMasterClient = PhotonNetwork.IsMasterClient; if (!isHostLastStatus.HasValue || isHostLastStatus != isMasterClient) { isHostLastStatus = isMasterClient; string[] codes = new string[16] { "spawn_item_rope", "spawn_item_marshmallow", "spawn_item_appleberryred", "spawn_item_appleberryyellow", "spawn_item_appleberrygreen", "spawn_item_bandage", "spawn_item_ropecannon", "spawn_item_backpack", "spawn_item_bugle", "spawn_item_flare", "spawn_item_book", "spawn_item_toy", "spawn_item_energydrink", "spawn_item_compass", "spawn_item_piratecompass", "spawn_item_warpcompass" }; if (isMasterClient) { CrowdControlMod.Instance.Client.ShowEffects(codes); } else { CrowdControlMod.Instance.Client.ShowEffects(codes); } } } public (bool isReady, string? message) IsReady(string code = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 GameState gameState = GetGameState(); if ((int)gameState == 1) { return (true, null); } string text; if ((int)gameState <= -12) { if ((int)gameState != -13) { if ((int)gameState != -12) { goto IL_005c; } text = "Effects do not work in current player state."; } else { text = "Effects do not work in the airport."; } } else if ((int)gameState != -7) { if ((int)gameState != -6) { if ((int)gameState != -1) { goto IL_005c; } text = "Effects cannot be applied due to an error."; } else { text = "Effects do not work while loading."; } } else { text = "Effects do not work while paused."; } goto IL_0062; IL_0062: string item = text; return (false, item); IL_005c: text = "Effects cannot be applied at this time."; goto IL_0062; } public bool IsReadyBool(string code = "") { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)GetGameState() == 1; } public GameState GetGameState() { //IL_00e4: 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_00e7: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) try { if (LoadingScreenHandler.loading) { return (GameState)(-6); } Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return (GameState)(-12); } CharacterAfflictions component = ((Component)localCharacter).GetComponent(); if ((Object)(object)component == (Object)null) { return (GameState)(-13); } FieldInfo field = typeof(CharacterAfflictions).GetField("m_inAirport", BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { return (GameState)(-13); } if ((bool)field.GetValue(component)) { return (GameState)(-13); } if (!Object.op_Implicit((Object)(object)Object.FindObjectOfType())) { return (GameState)(-13); } if (GUIManager.InPauseMenu) { return (GameState)(-7); } if ((Object)(object)RunManager.Instance != (Object)null) { if ((double)RunManager.Instance.timeSinceRunStarted <= 8.0) { return (GameState)(-6); } return (GameState)1; } return (GameState)(-6); } catch (Exception arg) { CrowdControlMod.Instance.Logger.LogError((object)$"ERROR {arg}"); return (GameState)(-1); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool UpdateGameState(bool force = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return UpdateGameState(GetGameState(), force); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool UpdateGameState(GameState newState, bool force) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return UpdateGameState(newState, null, force); } public bool UpdateGameState(GameState newState, string? message = null, bool force = false) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (force || _last_game_state != (GameState?)newState) { _last_game_state = newState; return P.Client.Send((SimpleJSONResponse?)new GameUpdate(newState, message)); } return true; } } public static class HostEventHandlers { private enum StormType { Unknown, Rain, Snow, Wind } [CompilerGenerated] private sealed class d__15 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public StormType stormType; public Component windZone; public GameObject stormObj; 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; try { SetDayNightManagerStormFactor(stormType, activate: false, 0f); Type type = ((object)windZone).GetType(); if ((Object)(object)windZone.gameObject.GetComponent() != (Object)null) { MethodInfo method = type.GetMethod("RPCA_ToggleWind", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { Vector3 val = Vector3.right; FieldInfo field = type.GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { val = (Vector3)field.GetValue(windZone); } method.Invoke(windZone, new object[3] { false, val, 0f }); } } FieldInfo field2 = type.GetField("windActive", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { field2.SetValue(windZone, false); } Object.Destroy((Object)(object)stormObj); StormEffect.SetStormActive(active: false); CrowdControlMod.Instance.Logger.LogInfo((object)"Storm cleaned up"); } catch (Exception ex) { StormEffect.SetStormActive(active: false); CrowdControlMod.Instance.Logger.LogWarning((object)("Error cleaning up storm: " + ex.Message)); } 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__23 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float duration; public GameObject tornadoObj; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 0f; break; case 1: <>1__state = -1; break; } if (5__2 < duration && (Object)(object)tornadoObj != (Object)null) { 5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)tornadoObj != (Object)null) { CrowdControlMod.Instance.Logger.LogInfo((object)"Tornado duration expired, destroying tornado (synchronized)"); if ((Object)(object)tornadoObj.GetComponent() != (Object)null) { PhotonNetwork.Destroy(tornadoObj); } else { Object.Destroy((Object)(object)tornadoObj); } } 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__22 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public GameObject spawnerObj; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)spawnerObj != (Object)null) { Object.Destroy((Object)(object)spawnerObj); CrowdControlMod.Instance.Logger.LogInfo((object)"Cleaned up temporary TornadoSpawner"); } 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__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject scoutmasterObj; public Character target; private Component 5__2; private MethodInfo 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = scoutmasterObj.GetComponent("Scoutmaster"); if ((Object)(object)5__2 == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Scoutmaster component not found."); return false; } 5__3 = ((object)5__2).GetType().GetMethod("SetCurrentTarget", BindingFlags.Instance | BindingFlags.NonPublic); if (5__3 == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"SetCurrentTarget method not found."); return false; } 5__3.Invoke(5__2, new object[2] { null, 0f }); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__3.Invoke(5__2, new object[2] { target, 30f }); <>2__current = (object)new WaitForSeconds(28f); <>1__state = 2; return true; case 2: <>1__state = -1; 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__19 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject scoutmasterObj; public Character target; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(KeepChasing(scoutmasterObj, target)); 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__14 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Component windZone; public Character character; public GameObject stormObj; public float duration; private FieldInfo 5__2; private float 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_008c: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Type type = ((object)windZone).GetType(); 5__2 = type.GetField("windZoneBounds", BindingFlags.Instance | BindingFlags.Public); 5__3 = 0f; break; } case 1: <>1__state = -1; 5__3 += 0.5f; break; } if (5__3 < duration && (Object)(object)stormObj != (Object)null && (Object)(object)windZone != (Object)null) { if ((Object)(object)character != (Object)null && (Object)(object)((Component)character).gameObject != (Object)null && 5__2 != null) { Bounds val = (Bounds)5__2.GetValue(windZone); Bounds val2 = default(Bounds); ((Bounds)(ref val2))..ctor(character.Center, ((Bounds)(ref val)).size); 5__2.SetValue(windZone, val2); stormObj.transform.position = character.Center; } <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static void RegisterAllHandlers() { if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Cannot register host handlers - not the host"); return; } CustomEventSystem.Instance.RegisterEvent("spawn_item", HandleSpawnItem); CustomEventSystem.Instance.RegisterEvent("spawn_hazard", HandleSpawnHazard); CustomEventSystem.Instance.RegisterEvent("custom_effect", HandleCustomEffect); CustomEventSystem.Instance.RegisterEvent("revive_player", HandleRevivePlayer); CustomEventSystem.Instance.RegisterEvent("spawn_scoutmaster", HandleSpawnScoutmaster); CustomEventSystem.Instance.RegisterEvent("spawn_tornado", HandleSpawnTornado); CustomEventSystem.Instance.RegisterEvent("spawn_ticks", HandleSpawnTicks); CustomEventSystem.Instance.RegisterEvent("revive_random_player", HandleReviveRandomPlayer); CustomEventSystem.Instance.RegisterEvent("spawn_zombie", HandleSpawnZombie); CustomEventSystem.Instance.RegisterEvent("create_storm", HandleCreateStorm); CrowdControlMod.Instance.Logger.LogInfo((object)"Registered all host event handlers"); } public static void UnregisterAllHandlers() { if (PhotonNetwork.IsMasterClient) { CustomEventSystem.Instance.UnregisterEvent("spawn_item"); CustomEventSystem.Instance.UnregisterEvent("spawn_hazard"); CustomEventSystem.Instance.UnregisterEvent("custom_effect"); CustomEventSystem.Instance.UnregisterEvent("revive_player"); CustomEventSystem.Instance.UnregisterEvent("spawn_scoutmaster"); CustomEventSystem.Instance.UnregisterEvent("spawn_tornado"); CustomEventSystem.Instance.UnregisterEvent("spawn_ticks"); CustomEventSystem.Instance.UnregisterEvent("spawn_zombie"); CustomEventSystem.Instance.UnregisterEvent("create_storm"); CrowdControlMod.Instance.Logger.LogInfo((object)"Unregistered all host event handlers"); } } private static EventResult HandleSpawnItem(Dictionary data) { //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0360: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0190: Unknown result type (might be due to invalid IL or missing references) if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleSpawnItem called with data: " + JsonConvert.SerializeObject((object)data))); } try { if (!data.TryGetValue("prefabPath", out object value)) { if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("[HostEventHandlers] Missing prefabPath parameter. Available keys: " + string.Join(", ", data.Keys))); } return EventResult.FailureResult("Missing prefabPath parameter"); } string text = value.ToString(); if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] Prefab path: " + text)); } Vector3 val; object value2; if (SpawnedItemProtection.TryResolveTargetCharacter(data, out Character character)) { val = SpawnedItemProtection.GetGroundedSpawnPosition(character); if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HostEventHandlers] Using live position for player {((Object)character).name}: {val}"); } } else if (data.TryGetValue("spawnPosition", out value2)) { Dictionary dictionary = null; JObject val2 = (JObject)((value2 is JObject) ? value2 : null); if (val2 != null) { dictionary = ((JToken)val2).ToObject>(); } else if (value2 is Dictionary dictionary2) { dictionary = dictionary2; } if (dictionary != null && dictionary.TryGetValue("x", out var value3) && dictionary.TryGetValue("y", out var value4) && dictionary.TryGetValue("z", out var value5)) { val = SpawnedItemProtection.GroundPoint(new Vector3(Convert.ToSingle(value3), Convert.ToSingle(value4), Convert.ToSingle(value5))); if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HostEventHandlers] Using provided spawn position: {val}"); } } else { val = Vector3.up * 2f; if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)"[HostEventHandlers] spawnPosition present but could not parse x/y/z."); } } } else { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter != (Object)null) { val = SpawnedItemProtection.GetGroundedSpawnPosition(localCharacter); if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HostEventHandlers] Using default spawn position: {val}"); } } else { val = Vector3.up * 2f; if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HostEventHandlers] Using fallback spawn position: {val}"); } } } if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HostEventHandlers] Attempting to spawn item '{text}' at {val}"); } bool flag = text.Contains("BeeSwarm"); GameObject val3; if (flag) { val3 = PhotonNetwork.InstantiateRoomObject(text, val, Quaternion.identity, (byte)0, (object[])null); try { BeeSwarm component = val3.GetComponent(); typeof(BeeSwarm).GetMethod("GetAngry", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(component, new object[1] { 15f }); } catch (Exception) { } } else { val3 = PhotonNetwork.InstantiateItemRoom(text, val, Quaternion.identity); } if ((Object)(object)val3 == (Object)null) { if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("[HostEventHandlers] Failed to instantiate item: " + text)); } return EventResult.FailureResult("Failed to instantiate item: " + text); } if (!flag) { val = SpawnedItemProtection.GroundPoint(val); val3.transform.position = val; SpawnedItemProtection.Apply(val3); } if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"Host spawned item '{text}' at {val} for client"); } if (string.Equals(text, "TumbleWeed", StringComparison.OrdinalIgnoreCase)) { GameNotifications.Show("Spawned hazard: Tumbleweed"); } return EventResult.SuccessResult("Successfully spawned " + text, new Dictionary { ["spawnedItem"] = text, ["position"] = val }); } catch (Exception ex2) { if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleSpawnItem: " + ex2.Message)); } if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex2.StackTrace)); } return EventResult.FailureResult("Error: " + ex2.Message); } } private static EventResult HandleSpawnHazard(Dictionary data) { //IL_0028: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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_01c3: 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_0148: Unknown result type (might be due to invalid IL or missing references) try { if (!data.TryGetValue("prefabPath", out object value)) { return EventResult.FailureResult("Missing prefabPath parameter"); } string text = value.ToString(); Vector3 zero = Vector3.zero; Quaternion rotation = Quaternion.identity; if (data.TryGetValue("spawnPosition", out object value2)) { Dictionary dictionary = null; JObject val = (JObject)((value2 is JObject) ? value2 : null); if (val != null) { dictionary = ((JToken)val).ToObject>(); } else if (value2 is Dictionary dictionary2) { dictionary = dictionary2; } if (dictionary != null && dictionary.TryGetValue("x", out var value3) && dictionary.TryGetValue("y", out var value4) && dictionary.TryGetValue("z", out var value5)) { ((Vector3)(ref zero))..ctor(Convert.ToSingle(value3), Convert.ToSingle(value4), Convert.ToSingle(value5)); } } if (data.TryGetValue("rotation", out object value6)) { Dictionary dictionary3 = null; JObject val2 = (JObject)((value6 is JObject) ? value6 : null); if (val2 != null) { dictionary3 = ((JToken)val2).ToObject>(); } else if (value6 is Dictionary dictionary4) { dictionary3 = dictionary4; } if (dictionary3 != null && dictionary3.TryGetValue("x", out var value7) && dictionary3.TryGetValue("y", out var value8) && dictionary3.TryGetValue("z", out var value9)) { rotation = Quaternion.Euler(Convert.ToSingle(value7), Convert.ToSingle(value8), Convert.ToSingle(value9)); } } if (!SpawnHazardEffect.TryResolveHazardPrefab(text, out GameObject prefab)) { return EventResult.FailureResult("Failed to resolve hazard prefab: " + text); } if ((Object)(object)SpawnHazardEffect.TryInstantiateHazard(prefab, zero, rotation) == (Object)null) { return EventResult.FailureResult("Failed to instantiate hazard: " + text); } GameNotifications.Show("Spawned hazard: " + text); return EventResult.SuccessResult("Successfully spawned " + text, new Dictionary { ["spawnedItem"] = text, ["position"] = zero }); } catch (Exception ex) { return EventResult.FailureResult("Error: " + ex.Message); } } private static EventResult HandleCustomEffect(Dictionary data) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) try { if (!data.TryGetValue("effectType", out object value)) { return EventResult.FailureResult("Missing effectType parameter"); } string text = value.ToString(); string text2 = text.ToLower(); if (!(text2 == "explosion")) { if (text2 == "weather") { if (data.TryGetValue("weatherType", out object value2)) { string text3 = value2.ToString(); CrowdControlMod.Instance.Logger.LogInfo((object)("Host changed weather to " + text3)); return EventResult.SuccessResult("Weather changed to " + text3); } return EventResult.FailureResult("Missing weatherType parameter"); } return EventResult.FailureResult("Unknown effect type: " + text); } Vector3 zero = Vector3.zero; if (data.TryGetValue("position", out object value3) && value3 is Dictionary dictionary) { ((Vector3)(ref zero))..ctor(float.Parse(dictionary["x"].ToString()), float.Parse(dictionary["y"].ToString()), float.Parse(dictionary["z"].ToString())); } CrowdControlMod.Instance.Logger.LogInfo((object)$"Host created explosion effect at {zero}"); return EventResult.SuccessResult("Explosion effect created"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleCustomEffect: " + ex.Message)); return EventResult.FailureResult("Error: " + ex.Message); } } private static EventResult HandleRevivePlayer(Dictionary data) { //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f5: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_063a: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043c: 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_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: 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) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleRevivePlayer called with data: " + JsonConvert.SerializeObject((object)data))); } try { if (!data.TryGetValue("targetPlayerId", out object value)) { if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("[HostEventHandlers] Missing targetPlayerId parameter. Available keys: " + string.Join(", ", data.Keys))); } return EventResult.FailureResult("Missing targetPlayerId parameter"); } int targetPlayerId = Convert.ToInt32(value); if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[HostEventHandlers] Target player ID: {targetPlayerId}"); } Character val = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component2 = ((Component)c).GetComponent(); if (component2 == null) { return false; } Player owner2 = component2.Owner; return ((owner2 != null) ? new int?(owner2.ActorNumber) : null) == targetPlayerId; }); if ((Object)(object)val == (Object)null) { if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)$"[HostEventHandlers] Target player with ID {targetPlayerId} not found"); } return EventResult.FailureResult($"Target player with ID {targetPlayerId} not found"); } PhotonView component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)("[HostEventHandlers] Target player " + ((Object)val).name + " has no PhotonView")); return EventResult.FailureResult("Target player " + ((Object)val).name + " has no PhotonView"); } bool dead = val.data.dead; bool fullyPassedOut = val.data.fullyPassedOut; bool passedOut = val.data.passedOut; bool flag = (Object)(object)val.Ghost != (Object)null; int viewID = component.ViewID; Player owner = component.Owner; int num = ((owner != null) ? owner.ActorNumber : (-1)); bool isMine = component.IsMine; CrowdControlMod.Instance.Logger.LogInfo((object)("[HandleRevivePlayer] Player: " + ((Object)val).name)); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - dead: {dead}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - fullyPassedOut: {fullyPassedOut}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - passedOut: {passedOut}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - isGhost: {flag}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - PhotonView ID: {viewID}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - Owner ID: {num}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] - IsMine: {isMine}"); if (!val.data.dead && !val.data.fullyPassedOut) { CrowdControlMod.Instance.Logger.LogWarning((object)("[HostEventHandlers] Target player " + ((Object)val).name + " is not dead or passed out")); return EventResult.FailureResult("Target player " + ((Object)val).name + " is not dead or passed out"); } if (val.data.dead) { PlayerGhost ghost = val.Ghost; Vector3 val2; if ((Object)(object)ghost != (Object)null) { if ((Object)(object)ghost.m_target != (Object)null) { val2 = ghost.m_target.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Using target player's head + 4 up for revive: {val2}"); } else if ((Object)(object)((Component)ghost).transform != (Object)null) { Vector3 position = ((Component)ghost).transform.position; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(position, Vector3.down, ref val3, 100f)) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Using ground level + 4 up below ghost: {val2} (ghost was at {position}, ground at {((RaycastHit)(ref val3)).point})"); } else { val2 = new Vector3(position.x, position.y - 10f, position.z) + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] No ground found, using ghost position lowered + 4 up: {val2}"); } } else { val2 = val.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Ghost transform is null, using head position + 4 up: {val2}"); } } else { val2 = val.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Ghost is null, using head position + 4 up: {val2}"); } CrowdControlMod.Instance.Logger.LogInfo((object)"[HandleRevivePlayer] Attempting to revive from dead state using RPCA_ReviveAtPosition"); try { component.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val2, false, -1 }); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Successfully sent RPCA_ReviveAtPosition RPC to player {((Object)val).name} (ID: {targetPlayerId}) at position {val2}"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("[HandleRevivePlayer] RPC failed: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("[HandleRevivePlayer] Stack trace: " + ex.StackTrace)); return EventResult.FailureResult("RPC failed: " + ex.Message); } } else if (val.data.fullyPassedOut) { Vector3 val4 = val.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Attempting to revive from fullyPassedOut state at position: {val4}"); try { component.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val4, false, -1 }); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleRevivePlayer] Successfully sent RPCA_ReviveAtPosition RPC to player {((Object)val).name} (ID: {targetPlayerId}) at position {val4}"); } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("[HandleRevivePlayer] RPC failed: " + ex2.Message)); CrowdControlMod.Instance.Logger.LogError((object)("[HandleRevivePlayer] Stack trace: " + ex2.StackTrace)); return EventResult.FailureResult("RPC failed: " + ex2.Message); } } return EventResult.SuccessResult("Revived player " + ((Object)val).name, new Dictionary { ["revivedPlayer"] = ((Object)val).name, ["targetPlayerId"] = targetPlayerId }); } catch (Exception ex3) { if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleRevivePlayer: " + ex3.Message)); } if (CustomEventSystem.EnableDebugLogging) { CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex3.StackTrace)); } return EventResult.FailureResult("Error: " + ex3.Message); } } private static EventResult HandleReviveRandomPlayer(Dictionary data) { //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: 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_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038e: 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) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0420: 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_042a: Unknown result type (might be due to invalid IL or missing references) //IL_043b: 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_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) CrowdControlMod.Instance.Logger.LogInfo((object)"[HostEventHandlers] HandleReviveRandomPlayer called"); try { foreach (Character allCharacter in Character.AllCharacters) { string name = ((Object)allCharacter).name; bool dead = allCharacter.data.dead; bool fullyPassedOut = allCharacter.data.fullyPassedOut; bool flag = (Object)(object)allCharacter.Ghost != (Object)null; CrowdControlMod.Instance.Logger.LogInfo((object)$"[ReviveRandomPlayer] Character: {name}, dead: {dead}, fullyPassedOut: {fullyPassedOut}, isGhost: {flag}"); } List list = Character.AllCharacters.Where((Character c) => c.data.dead || c.data.fullyPassedOut).ToList(); if (list.Count == 0) { CrowdControlMod.Instance.Logger.LogWarning((object)"No revivable players (dead or fullyPassedOut) found"); return EventResult.FailureResult("No revivable players (dead or fullyPassedOut) found"); } Character val = list[Random.Range(0, list.Count)]; PhotonView component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Target player has no network view"); return EventResult.FailureResult("Target player has no network view"); } Player owner = component.Owner; int num = ((owner != null) ? owner.ActorNumber : (-1)); if (num == -1) { CrowdControlMod.Instance.Logger.LogWarning((object)"Target player's PhotonView has no owner"); return EventResult.FailureResult("Target player's PhotonView has no owner"); } bool dead2 = val.data.dead; bool fullyPassedOut2 = val.data.fullyPassedOut; bool passedOut = val.data.passedOut; bool flag2 = (Object)(object)val.Ghost != (Object)null; int viewID = component.ViewID; Player owner2 = component.Owner; int num2 = ((owner2 != null) ? owner2.ActorNumber : (-1)); bool isMine = component.IsMine; CrowdControlMod.Instance.Logger.LogInfo((object)("[HandleReviveRandomPlayer] Selected player: " + ((Object)val).name)); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - dead: {dead2}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - fullyPassedOut: {fullyPassedOut2}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - passedOut: {passedOut}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - isGhost: {flag2}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - PhotonView ID: {viewID}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - Owner ID: {num2}"); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] - IsMine: {isMine}"); if (val.data.dead) { PlayerGhost ghost = val.Ghost; Vector3 val2; if ((Object)(object)ghost != (Object)null) { if ((Object)(object)ghost.m_target != (Object)null) { val2 = ghost.m_target.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] Using target player's head + 4 up for revive: {val2}"); } else if ((Object)(object)((Component)ghost).transform != (Object)null) { Vector3 position = ((Component)ghost).transform.position; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(position, Vector3.down, ref val3, 100f)) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] Using ground level + 4 up below ghost: {val2} (ghost was at {position}, ground at {((RaycastHit)(ref val3)).point})"); } else { val2 = new Vector3(position.x, position.y - 10f, position.z) + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] No ground found, using ghost position lowered + 4 up: {val2}"); } } else { val2 = val.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] Ghost transform is null, using head position + 4 up: {val2}"); } } else { val2 = val.Head + Vector3.up * 4f; CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] Ghost is null, using head position + 4 up: {val2}"); } CrowdControlMod.Instance.Logger.LogInfo((object)"[HandleReviveRandomPlayer] Attempting to revive from dead state using RPCA_ReviveAtPosition"); try { component.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val2, false, -1 }); CrowdControlMod.Instance.Logger.LogInfo((object)$"[HandleReviveRandomPlayer] Successfully sent RPCA_ReviveAtPosition RPC to player {((Object)val).name} (ID: {num}) at position {val2}"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("[HandleReviveRandomPlayer] RPC failed: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("[HandleReviveRandomPlayer] Stack trace: " + ex.StackTrace)); return EventResult.FailureResult("RPC failed: " + ex.Message); } return EventResult.SuccessResult("Sent revive request to player " + ((Object)val).name, new Dictionary { ["revivedPlayer"] = ((Object)val).name, ["targetPlayerId"] = num }); } CrowdControlMod.Instance.Logger.LogWarning((object)("Player " + ((Object)val).name + " is not dead or passed out")); return EventResult.FailureResult("Player " + ((Object)val).name + " is not dead or passed out"); } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleReviveRandomPlayer: " + ex2.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex2.StackTrace)); return EventResult.FailureResult("Error: " + ex2.Message); } } private static Vector3 GetSpawnPosition(Character character) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_0069: 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_007d: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0119: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)character).transform.position + ((Component)character).transform.forward * 1.5f + Vector3.up; bool flag = false; bool flag2 = false; Transform[] componentsInChildren = ((Component)((Component)character).transform).GetComponentsInChildren(); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "Hip") { val = val2.position + val2.forward * 1.5f + Vector3.up; flag = true; break; } } Transform val3 = ((Component)character).transform.Find("Hip"); if ((Object)(object)val3 != (Object)null) { val = val3.position + val3.forward * 1.5f + Vector3.up; flag2 = true; } if (CustomEventSystem.EnableDebugLogging) { if (flag2) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[GetSpawnPosition] Used hip transform for spawn position: {val}"); } else if (flag) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[GetSpawnPosition] Used child Hip for spawn position: {val}"); } else { CrowdControlMod.Instance.Logger.LogInfo((object)$"[GetSpawnPosition] Used default spawn position: {val}"); } } return val; } private static EventResult HandleSpawnScoutmaster(Dictionary data) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleSpawnScoutmaster called with data: " + JsonConvert.SerializeObject((object)data))); try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn Scoutmaster."); return EventResult.FailureResult("Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn Scoutmaster."); return EventResult.FailureResult("Only the Master Client can spawn Scoutmaster"); } Vector3 val = Vector3.zero; bool flag = false; if (data.TryGetValue("spawnPosition", out object value)) { Dictionary dictionary = null; JObject val2 = (JObject)((value is JObject) ? value : null); if (val2 != null) { dictionary = ((JToken)val2).ToObject>(); } else if (value is Dictionary dictionary2) { dictionary = dictionary2; } if (dictionary != null && dictionary.TryGetValue("x", out var value2) && dictionary.TryGetValue("y", out var value3) && dictionary.TryGetValue("z", out var value4)) { ((Vector3)(ref val))..ctor(Convert.ToSingle(value2), Convert.ToSingle(value3), Convert.ToSingle(value4)); flag = true; } } int targetPlayerId = -1; if (data.TryGetValue("targetPlayerId", out object value5)) { targetPlayerId = Convert.ToInt32(value5); } Character val3 = null; if (targetPlayerId != -1) { val3 = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component = ((Component)c).GetComponent(); if (component == null) { return false; } Player owner = component.Owner; return ((owner != null) ? new int?(owner.ActorNumber) : null) == targetPlayerId; }); } if (!flag) { CrowdControlMod.Instance.Logger.LogWarning((object)"No spawnPosition provided, using Vector3.up * 2f as fallback"); val = Vector3.up * 2f; } if ((Object)(object)val3 == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"No valid chase target found, Scoutmaster will not chase anyone"); } Quaternion identity = Quaternion.identity; GameObject scoutmasterObj = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", val, identity, (byte)0, (object[])null); CrowdControlMod.Instance.Logger.LogInfo((object)string.Format("Spawned Scoutmaster at {0}, targeting playerId: {1} ({2})", val, targetPlayerId, ((val3 != null) ? ((Object)val3).name : null) ?? "null")); if ((Object)(object)val3 != (Object)null) { ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(StartChasingNextFrame(scoutmasterObj, val3)); } return EventResult.SuccessResult($"Successfully spawned Scoutmaster at {val}", new Dictionary { ["spawnedScoutmaster"] = true, ["spawnPosition"] = val, ["targetPlayerId"] = targetPlayerId, ["targetPlayerName"] = ((val3 != null) ? ((Object)val3).name : null) ?? "null" }); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleSpawnScoutmaster: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); return EventResult.FailureResult("Error: " + ex.Message); } } private static EventResult HandleSpawnTornado(Dictionary data) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_0286: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleSpawnTornado called with data: " + JsonConvert.SerializeObject((object)data))); try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn Tornado."); return EventResult.FailureResult("Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn Tornado."); return EventResult.FailureResult("Only the Master Client can spawn Tornado"); } Vector3 val = Vector3.zero; bool flag = false; if (data.TryGetValue("spawnPosition", out object value)) { Dictionary dictionary = null; JObject val2 = (JObject)((value is JObject) ? value : null); if (val2 != null) { dictionary = ((JToken)val2).ToObject>(); } else if (value is Dictionary dictionary2) { dictionary = dictionary2; } if (dictionary != null && dictionary.TryGetValue("x", out var value2) && dictionary.TryGetValue("y", out var value3) && dictionary.TryGetValue("z", out var value4)) { ((Vector3)(ref val))..ctor(Convert.ToSingle(value2), Convert.ToSingle(value3), Convert.ToSingle(value4)); flag = true; } } if (!flag) { CrowdControlMod.Instance.Logger.LogWarning((object)"No spawnPosition provided, using Vector3.up * 2f as fallback"); val = Vector3.up * 2f; } Character val3 = null; if (data.TryGetValue("targetPlayerId", out object value5)) { int targetPlayerId = Convert.ToInt32(value5); val3 = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component = ((Component)c).GetComponent(); if (component == null) { return false; } Player owner = component.Owner; return ((owner != null) ? new int?(owner.ActorNumber) : null) == targetPlayerId; }); CrowdControlMod.Instance.Logger.LogInfo((object)$"Looking for target character with ActorNumber {targetPlayerId} for tornado"); } if ((Object)(object)val3 == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find target character for tornado, using local character"); val3 = Character.localCharacter; } if ((Object)(object)val3 == (Object)null) { return EventResult.FailureResult("Could not find target character"); } if (!flag) { val = GetSpawnPosition(val3); CrowdControlMod.Instance.Logger.LogInfo((object)$"No spawnPosition provided, using target character position: {val}"); } Quaternion identity = Quaternion.identity; GameObject tornadoObj = PhotonNetwork.InstantiateRoomObject("Tornado", val, identity, (byte)0, (object[])null); InitializeTornado(tornadoObj, val3); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupTornadoAfterDuration(tornadoObj, 30f)); CrowdControlMod.Instance.Logger.LogInfo((object)$"Spawned Tornado at {val}"); return EventResult.SuccessResult($"Successfully spawned Tornado at {val}", new Dictionary { ["spawnedTornado"] = true, ["spawnPosition"] = val }); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleSpawnTornado: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); return EventResult.FailureResult("Error: " + ex.Message); } } private static EventResult HandleSpawnTicks(Dictionary data) { //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_0085: 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_013f: 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) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleSpawnTicks called with data: " + JsonConvert.SerializeObject((object)data))); try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn Ticks."); return EventResult.FailureResult("Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn Ticks."); return EventResult.FailureResult("Only the Master Client can spawn Ticks"); } Vector3 val = Vector3.zero; bool flag = false; if (data.TryGetValue("spawnPosition", out object value)) { Dictionary dictionary = null; JObject val2 = (JObject)((value is JObject) ? value : null); if (val2 != null) { dictionary = ((JToken)val2).ToObject>(); } else if (value is Dictionary dictionary2) { dictionary = dictionary2; } if (dictionary != null && dictionary.TryGetValue("x", out var value2) && dictionary.TryGetValue("y", out var value3) && dictionary.TryGetValue("z", out var value4)) { ((Vector3)(ref val))..ctor(Convert.ToSingle(value2), Convert.ToSingle(value3), Convert.ToSingle(value4)); flag = true; } } if (!flag) { CrowdControlMod.Instance.Logger.LogWarning((object)"No spawnPosition provided, using Vector3.up * 2f as fallback"); val = Vector3.up * 2f; } Quaternion identity = Quaternion.identity; CrowdControlMod.Instance.Logger.LogInfo((object)"TickTrigger prefab not found, spawning BugfixOnYou directly to simulate tick effect"); GameObject val3 = PhotonNetwork.InstantiateRoomObject("BugfixOnYou", val, identity, (byte)0, (object[])null); if ((Object)(object)val3 == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)"Failed to spawn BugfixOnYou prefab"); return EventResult.FailureResult("Failed to spawn BugfixOnYou prefab"); } CrowdControlMod.Instance.Logger.LogInfo((object)$"Successfully spawned BugfixOnYou at {val}"); if (data.TryGetValue("targetPlayerId", out object value5)) { try { int targetPlayerId = Convert.ToInt32(value5); Character val4 = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component2 = ((Component)c).GetComponent(); if (component2 == null) { return false; } Player owner = component2.Owner; return ((owner != null) ? new int?(owner.ActorNumber) : null) == targetPlayerId; }); if ((Object)(object)val4 != (Object)null && (Object)(object)((MonoBehaviourPun)val4).photonView != (Object)null) { PhotonView component = val3.GetComponent(); if ((Object)(object)component != (Object)null) { component.RPC("AttachBug", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)val4).photonView.ViewID }); CrowdControlMod.Instance.Logger.LogInfo((object)("Called AttachBug RPC to attach bug to player " + ((Object)val4).name)); } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error calling AttachBug RPC: " + ex.Message)); } } return EventResult.SuccessResult($"Successfully spawned Tick at {val}", new Dictionary { ["spawnedTick"] = true, ["spawnPosition"] = val }); } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleSpawnTicks: " + ex2.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex2.StackTrace)); return EventResult.FailureResult("Error: " + ex2.Message); } } private static EventResult HandleSpawnZombie(Dictionary data) { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_028f: 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) CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleSpawnZombie called with data: " + JsonConvert.SerializeObject((object)data))); try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn Zombie."); return EventResult.FailureResult("Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn Zombie."); return EventResult.FailureResult("Only the Master Client can spawn Zombie"); } Character val = null; if (data.TryGetValue("targetPlayerId", out object value)) { int targetPlayerId = Convert.ToInt32(value); val = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component = ((Component)c).GetComponent(); if (component == null) { return false; } Player owner = component.Owner; return ((owner != null) ? new int?(owner.ActorNumber) : null) == targetPlayerId; }); CrowdControlMod.Instance.Logger.LogInfo((object)$"Looking for target character with ActorNumber {targetPlayerId}"); } if ((Object)(object)val == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find target character for zombie spawn, using local character"); val = Character.localCharacter; } if ((Object)(object)val == (Object)null) { return EventResult.FailureResult("Could not find target character"); } Vector3 val2 = Vector3.zero; bool flag = false; if (data.TryGetValue("spawnPosition", out object value2)) { Dictionary dictionary = null; JObject val3 = (JObject)((value2 is JObject) ? value2 : null); if (val3 != null) { dictionary = ((JToken)val3).ToObject>(); } else if (value2 is Dictionary dictionary2) { dictionary = dictionary2; } if (dictionary != null && dictionary.TryGetValue("x", out var value3) && dictionary.TryGetValue("y", out var value4) && dictionary.TryGetValue("z", out var value5)) { ((Vector3)(ref val2))..ctor(Convert.ToSingle(value3), Convert.ToSingle(value4), Convert.ToSingle(value5)); flag = true; CrowdControlMod.Instance.Logger.LogInfo((object)$"Using provided spawn position: {val2}"); } } if (!flag) { val2 = GetSpawnPosition(val); CrowdControlMod.Instance.Logger.LogInfo((object)$"No spawnPosition provided, using target character position: {val2}"); } Quaternion identity = Quaternion.identity; if ((Object)(object)PhotonNetwork.Instantiate("MushroomZombie", val2, identity, (byte)0, (object[])null) == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)"Failed to instantiate zombie prefab"); return EventResult.FailureResult("Failed to instantiate zombie prefab"); } CrowdControlMod.Instance.Logger.LogInfo((object)$"Spawned Zombie at {val2}"); return EventResult.SuccessResult($"Successfully spawned Zombie at {val2}", new Dictionary { ["spawnedZombie"] = true, ["spawnPosition"] = val2 }); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleSpawnZombie: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); return EventResult.FailureResult("Error: " + ex.Message); } } private static EventResult HandleCreateStorm(Dictionary data) { //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) CrowdControlMod.Instance.Logger.LogInfo((object)("[HostEventHandlers] HandleCreateStorm called with data: " + JsonConvert.SerializeObject((object)data))); try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot create storm."); return EventResult.FailureResult("Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can create storms."); return EventResult.FailureResult("Only the Master Client can create storms"); } if (StormEffect.IsStormActive) { CrowdControlMod.Instance.Logger.LogInfo((object)"A storm is already active, cannot create another one"); return EventResult.FailureResult("A storm is already active"); } if (!data.TryGetValue("stormType", out object value)) { return EventResult.FailureResult("Missing stormType parameter"); } string text = value.ToString(); StormType stormType = StormType.Unknown; switch (text) { case "Rain": stormType = StormType.Rain; break; case "Snow": stormType = StormType.Snow; break; case "Wind": stormType = StormType.Wind; break; } if (stormType == StormType.Unknown) { return EventResult.FailureResult("Unknown storm type: " + text); } Character val = null; if (data.TryGetValue("targetPlayerId", out object value2)) { int targetPlayerId = Convert.ToInt32(value2); val = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component3 = ((Component)c).GetComponent(); if (component3 == null) { return false; } Player owner2 = component3.Owner; return ((owner2 != null) ? new int?(owner2.ActorNumber) : null) == targetPlayerId; }); CrowdControlMod.Instance.Logger.LogInfo((object)$"Looking for target character with ActorNumber {targetPlayerId} for storm"); } if ((Object)(object)val == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find target character for storm, trying to find by PhotonPlayer"); if (data.TryGetValue("targetPlayerId", out object value3)) { int num = Convert.ToInt32(value3); if (PhotonNetwork.CurrentRoom.GetPlayer(num, false) != null) { foreach (Character allCharacter in Character.AllCharacters) { PhotonView component = ((Component)allCharacter).GetComponent(); if ((Object)(object)component != (Object)null && component.Owner != null && component.Owner.ActorNumber == num) { val = allCharacter; break; } } } } } if ((Object)(object)val == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Still could not find target character, using local character as fallback"); val = Character.localCharacter; } if ((Object)(object)val == (Object)null) { return EventResult.FailureResult("Could not find target character"); } CrowdControlMod.Instance.Logger.LogInfo((object)$"Found target character: {((Object)val).name} at {val.Center}"); if (!CrowdControlMod.Instance.EffectLoader.Effects.TryGetValue("storm_rain", out Effect value4) || !(value4 is StormEffect stormEffect)) { return EventResult.FailureResult("Storm effect not available"); } CrowdControlMod.Instance.Logger.LogInfo((object)$"Created {stormType} storm at {val.Center}"); StormEffect.StormType stormType2 = stormType switch { StormType.Rain => StormEffect.StormType.Rain, StormType.Snow => StormEffect.StormType.Snow, StormType.Wind => StormEffect.StormType.Wind, _ => StormEffect.StormType.Unknown, }; if (!stormEffect.TryCreateStormAtCharacter(val, stormType2, 30f, out string errorMessage)) { return EventResult.FailureResult(errorMessage); } PhotonView component2 = ((Component)val).GetComponent(); int? obj; if (component2 == null) { obj = null; } else { Player owner = component2.Owner; obj = ((owner != null) ? new int?(owner.ActorNumber) : null); } int? num2 = obj; StormEffect.BroadcastStormVisual(stormType2, 30f, num2.GetValueOrDefault()); return EventResult.SuccessResult($"Successfully created {stormType} storm", new Dictionary { ["stormType"] = text, ["position"] = val.Center }); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error in HandleCreateStorm: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); return EventResult.FailureResult("Error: " + ex.Message); } } private static GameObject CreateStormAtCharacter(Character character, StormType stormType) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0214: 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_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = new GameObject($"Storm_{stormType}_{Guid.NewGuid()}"); val.transform.position = character.Center; if (stormType == StormType.Rain) { val.tag = "Rain"; } else { val.tag = "Storm"; } Type type = Type.GetType("WindChillZone"); if (type == null) { type = Type.GetType("WindChillZone, Assembly-CSharp"); } if (type == null) { Object.Destroy((Object)(object)val); CrowdControlMod.Instance.Logger.LogError((object)"WindChillZone type not found"); return null; } Component val2 = val.AddComponent(type); Component val3 = null; try { if ((Object)(object)val.GetComponent() == (Object)null) { PhotonView obj = val.AddComponent(); obj.ViewID = Random.Range(1000, 9999); obj.Synchronization = (ViewSynchronization)3; } if ((Object)(object)val.GetComponent() == (Object)null) { SphereCollider obj2 = val.AddComponent(); obj2.radius = 50f; ((Collider)obj2).isTrigger = true; } FieldInfo field = type.GetField("observedCharacterInsideBounds", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(val2, true); } FieldInfo field2 = type.GetField("hasBeenActiveFor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(val2, 0f); } FieldInfo field3 = type.GetField("windZoneBounds", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { Bounds val4 = default(Bounds); ((Bounds)(ref val4))..ctor(character.Center, new Vector3(200f, 200f, 200f)); field3.SetValue(val2, val4); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set wind zone bounds: center={((Bounds)(ref val4)).center}, size={((Bounds)(ref val4)).size}"); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"windZoneBounds field not found!"); } val.transform.position = character.Center; Vector3 val5 = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val5)).normalized; FieldInfo field4 = type.GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field4 != null) { field4.SetValue(val2, normalized); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set wind direction to {normalized}"); } FieldInfo field5 = type.GetField("windIntensity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field5 != null) { field5.SetValue(val2, 1f); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set wind intensity to {1f}"); } FieldInfo field6 = type.GetField("windTimeRangeOn", BindingFlags.Instance | BindingFlags.Public); if (field6 != null) { field6.SetValue(val2, (object)new Vector2(30f, 30f)); } FieldInfo field7 = type.GetField("windTimeRangeOff", BindingFlags.Instance | BindingFlags.Public); if (field7 != null) { field7.SetValue(val2, (object)new Vector2(0f, 0f)); } FieldInfo field8 = type.GetField("windForce", BindingFlags.Instance | BindingFlags.Public); if (field8 != null) { field8.SetValue(val2, 15f); } FieldInfo field9 = type.GetField("windMovesItems", BindingFlags.Instance | BindingFlags.Public); if (field9 != null) { field9.SetValue(val2, true); } FieldInfo field10 = type.GetField("statusType", BindingFlags.Instance | BindingFlags.Public); if (field10 != null) { Type type2 = Type.GetType("CharacterAfflictions+STATUSTYPE"); if (type2 != null) { try { object obj3 = Enum.Parse(type2, "Cold"); if (obj3 != null) { field10.SetValue(val2, obj3); } } catch { } } } FieldInfo field11 = type.GetField("statusApplicationPerSecond", BindingFlags.Instance | BindingFlags.Public); if (field11 != null) { field11.SetValue(val2, 0.01f); } FieldInfo field12 = type.GetField("lightVolumeSampleThreshold_lower", BindingFlags.Instance | BindingFlags.Public); if (field12 != null) { field12.SetValue(val2, 0f); } FieldInfo field13 = type.GetField("lightVolumeSampleThreshold_margin", BindingFlags.Instance | BindingFlags.Public); if (field13 != null) { field13.SetValue(val2, 1f); } FieldInfo field14 = type.GetField("windIntensityCurve", BindingFlags.Instance | BindingFlags.Public); if (field14 != null) { AnimationCurve value = AnimationCurve.Linear(0f, 0f, 1f, 1f); field14.SetValue(val2, value); CrowdControlMod.Instance.Logger.LogInfo((object)"Set windIntensityCurve to linear curve"); } FieldInfo field15 = type.GetField("useIntensityCurve", BindingFlags.Instance | BindingFlags.Public); if (field15 != null) { field15.SetValue(val2, false); CrowdControlMod.Instance.Logger.LogInfo((object)"Disabled useIntensityCurve"); } FieldInfo field16 = type.GetField("untilSwitch", BindingFlags.Instance | BindingFlags.NonPublic); if (field16 != null) { field16.SetValue(val2, 30f); } FieldInfo field17 = type.GetField("timeUntilNextWind", BindingFlags.Instance | BindingFlags.NonPublic); if (field17 != null) { field17.SetValue(val2, 30f); } MethodInfo method = type.GetMethod("RPCA_ToggleWind", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(val2, new object[3] { true, normalized, 30f }); CrowdControlMod.Instance.Logger.LogInfo((object)"Activated wind zone via RPC"); } else { FieldInfo field18 = type.GetField("windActive", BindingFlags.Instance | BindingFlags.Public); if (field18 != null) { field18.SetValue(val2, true); } } val3 = SetupStormVisual(val, val2, stormType); if ((Object)(object)val3 != (Object)null) { MethodInfo method2 = ((object)val3).GetType().GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method2 != null) { method2.Invoke(val3, null); CrowdControlMod.Instance.Logger.LogInfo((object)"Manually called StormVisual.Start()"); } } SetDayNightManagerStormFactor(stormType, activate: true, 1.5f); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting up wind zone: " + ex.Message)); } StormEffect.SetStormActive(active: true); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(UpdateStormBounds(val, val2, character, 30f)); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupStormAfterDelay(val, val2, 30f, stormType)); return val; } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("Error creating storm: " + ex2.Message)); return null; } } [IteratorStateMachine(typeof(d__14))] private static IEnumerator UpdateStormBounds(GameObject stormObj, Component windZone, Character character, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { stormObj = stormObj, windZone = windZone, character = character, duration = duration }; } [IteratorStateMachine(typeof(d__15))] private static IEnumerator CleanupStormAfterDelay(GameObject stormObj, Component windZone, float delay, StormType stormType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { stormObj = stormObj, windZone = windZone, delay = delay, stormType = stormType }; } private static Component SetupStormVisual(GameObject stormObj, Component windZone, StormType stormType) { Component val = null; try { Type type = Type.GetType("StormVisual, Assembly-CSharp"); if (type == null) { type = Type.GetType("StormVisual"); } if (type == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"StormVisual type not found"); return null; } val = stormObj.AddComponent(type); FieldInfo field = type.GetField("zone", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, windZone); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.zone field"); } FieldInfo field2 = type.GetField("part", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { Type type2 = Type.GetType("UnityEngine.ParticleSystem, UnityEngine.ParticleSystemModule"); if (type2 != null) { Array value = Array.CreateInstance(type2, 0); field2.SetValue(val, value); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.part array to empty (no particle systems)"); } else { field2.SetValue(val, null); CrowdControlMod.Instance.Logger.LogWarning((object)"Could not create particle system array type, setting to null"); } } FieldInfo field3 = type.GetField("stormType", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { Type type3 = Type.GetType("StormVisual+StormType, Assembly-CSharp"); if (type3 == null) { type3 = Type.GetType("StormVisual+StormType"); } if (type3 != null) { object value2 = Enum.Parse(type3, stormType.ToString()); field3.SetValue(val, value2); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set StormVisual.stormType to {stormType}"); } } FieldInfo field4 = type.GetField("useWindChillZoneIntensity", BindingFlags.Instance | BindingFlags.Public); if (field4 != null) { field4.SetValue(val, true); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.useWindChillZoneIntensity to true"); } FieldInfo field5 = type.GetField("windchillZoneMult", BindingFlags.Instance | BindingFlags.Public); if (field5 != null) { field5.SetValue(val, 1f); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.windchillZoneMult to 1f"); } FieldInfo field6 = type.GetField("windFactor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field6 != null) { field6.SetValue(val, 1f); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.windFactor to 1.0f"); } if (stormType == StormType.Wind) { FieldInfo field7 = type.GetField("windParticleMult", BindingFlags.Instance | BindingFlags.Public); if (field7 != null) { field7.SetValue(val, 50f); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.windParticleMult to 50f"); } FieldInfo field8 = type.GetField("particleForceField", BindingFlags.Instance | BindingFlags.Public); if (field8 != null) { Type type4 = Type.GetType("UnityEngine.ParticleSystemForceField, UnityEngine.ParticleSystemModule"); if (type4 != null) { Component value3 = stormObj.AddComponent(type4); field8.SetValue(val, value3); CrowdControlMod.Instance.Logger.LogInfo((object)"Added particle force field for wind storm"); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find particle force field type, setting to null"); field8.SetValue(val, null); } } } CrowdControlMod.Instance.Logger.LogInfo((object)"StormVisual component added and configured (note: particle systems needed for full visual effects)"); return val; } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting up StormVisual: " + ex.Message)); CrowdControlMod.Instance.Logger.LogWarning((object)("Stack trace: " + ex.StackTrace)); return null; } } private static void SetDayNightManagerStormFactor(StormType stormType, bool activate, float intensity = 1f) { try { Type type = Type.GetType("DayNightManager"); if (type == null) { type = Type.GetType("DayNightManager, Assembly-CSharp"); } if (type == null) { return; } FieldInfo field = type.GetField("instance", BindingFlags.Static | BindingFlags.Public); if (field == null) { return; } object value = field.GetValue(null); if (value == null) { return; } float num = (activate ? intensity : 0f); switch (stormType) { case StormType.Rain: { FieldInfo field3 = type.GetField("rainstormWindFactor", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { field3.SetValue(value, num); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set DayNightManager.rainstormWindFactor to {num}"); } break; } case StormType.Snow: { FieldInfo field4 = type.GetField("snowstormWindFactor", BindingFlags.Instance | BindingFlags.Public); if (field4 != null) { field4.SetValue(value, num); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set DayNightManager.snowstormWindFactor to {num}"); } break; } case StormType.Wind: { FieldInfo field2 = type.GetField("rainstormWindFactor", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { field2.SetValue(value, num); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set DayNightManager.rainstormWindFactor (for wind) to {num}"); } break; } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting DayNightManager storm factor: " + ex.Message)); } } [IteratorStateMachine(typeof(d__19))] private static IEnumerator StartChasingNextFrame(GameObject scoutmasterObj, Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__19(0) { scoutmasterObj = scoutmasterObj, target = target }; } [IteratorStateMachine(typeof(d__20))] private static IEnumerator KeepChasing(GameObject scoutmasterObj, Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { scoutmasterObj = scoutmasterObj, target = target }; } private static void InitializeTornado(GameObject tornadoObj, Character targetCharacter) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) try { Type type = Type.GetType("TornadoSpawner, Assembly-CSharp"); if (type == null) { type = Type.GetType("TornadoSpawner"); } GameObject val = null; if (type != null) { Object[] array = Object.FindObjectsOfType(type); if (array != null && array.Length != 0) { Object obj = array[0]; Object obj2 = ((obj is Component) ? obj : null); val = ((obj2 != null) ? ((Component)obj2).gameObject : null); if ((Object)(object)val != (Object)null) { CrowdControlMod.Instance.Logger.LogInfo((object)"Found existing TornadoSpawner, using it for initialization"); } } } if ((Object)(object)val == (Object)null) { val = new GameObject("TempTornadoSpawner_" + Guid.NewGuid()); val.transform.position = targetCharacter.Center; PhotonView obj3 = val.AddComponent(); obj3.ViewID = Random.Range(1000, 9999); obj3.Synchronization = (ViewSynchronization)3; GameObject val2 = new GameObject("TornadoPoints"); val2.transform.SetParent(val.transform); val2.transform.localPosition = Vector3.zero; Vector3 localPosition = default(Vector3); for (int i = 0; i < 8; i = checked(i + 1)) { float num = 45f * (float)i * (MathF.PI / 180f); float num2 = 20f; ((Vector3)(ref localPosition))..ctor(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2); GameObject val3 = new GameObject($"Point_{i}"); val3.transform.SetParent(val2.transform); val3.transform.localPosition = localPosition; } ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupTornadoSpawner(val, 35f)); CrowdControlMod.Instance.Logger.LogInfo((object)"Created temporary TornadoSpawner with TornadoPoints"); } PhotonView component = val.GetComponent(); PhotonView component2 = tornadoObj.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component2.RPC("RPCA_InitTornado", (RpcTarget)0, new object[1] { component.ViewID }); CrowdControlMod.Instance.Logger.LogInfo((object)$"Initialized tornado with TornadoSpawner ViewID: {component.ViewID}"); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find PhotonView on tornado or spawner, tornado may not work correctly"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error initializing tornado: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); } } [IteratorStateMachine(typeof(d__22))] private static IEnumerator CleanupTornadoSpawner(GameObject spawnerObj, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(0) { spawnerObj = spawnerObj, delay = delay }; } [IteratorStateMachine(typeof(d__23))] private static IEnumerator CleanupTornadoAfterDuration(GameObject tornadoObj, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__23(0) { tornadoObj = tornadoObj, duration = duration }; } } public class NetworkClient : IDisposable { private const bool PROCESS_LOOKUP_FALLBACK = true; private static readonly SITimeSpan TIMEOUT_NO_PROCESS = 5.0; private static readonly SITimeSpan TIMEOUT_NO_CONNECTION = 2.0; public static readonly string CV_HOST = "127.0.0.1"; public static readonly int CV_PORT = 51337; private TcpClient? m_client; private DelimitedStreamReader? m_streamReader; private readonly CrowdControlMod m_mod; private readonly CancellationTokenSource m_quitting = new CancellationTokenSource(); private readonly Thread m_readLoop; private readonly Thread m_maintenanceLoop; private static readonly EmptyResponse KEEPALIVE = new EmptyResponse { type = (ResponseType)255 }; public bool Connected => m_client?.Connected ?? false; ~NetworkClient() { Dispose(disposing: false); } public void Dispose() { Dispose(disposing: true); } protected virtual void Dispose(bool disposing) { try { m_client?.Dispose(); } catch { } try { m_quitting.Cancel(); } catch { } GC.SuppressFinalize(this); } public NetworkClient(CrowdControlMod mod) { m_mod = mod; (m_readLoop = new Thread(NetworkLoop)).Start(); (m_maintenanceLoop = new Thread(MaintenanceLoop)).Start(); } private void NetworkLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (!m_quitting.IsCancellationRequested) { if (!IsCrowdControlSemaphorePresent() && !IsCrowdControlProcessRunning()) { CrowdControlMod.Instance.Logger.LogInfo((object)"No CrowdControl process found, skipping connection attempt..."); Thread.Sleep((TimeSpan)TIMEOUT_NO_PROCESS); continue; } CrowdControlMod.Instance.Logger.LogInfo((object)"Attempting to connect to Crowd Control"); try { m_client = new TcpClient(); m_client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, optionValue: true); m_client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, optionValue: true); if (m_client.BeginConnect(CV_HOST, CV_PORT, null, null).AsyncWaitHandle.WaitOne(2000, exitContext: true) && m_client.Connected) { ClientLoop(); } else { CrowdControlMod.Instance.Logger.LogInfo((object)"Failed to connect to Crowd Control"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); CrowdControlMod.Instance.Logger.LogError((object)"Failed to connect to Crowd Control"); } finally { try { m_client?.Close(); } catch { } } Thread.Sleep((TimeSpan)TIMEOUT_NO_CONNECTION); } } private void MaintenanceLoop() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; while (!m_quitting.IsCancellationRequested) { try { TcpClient? client = m_client; if (client != null && client.Connected) { KeepAlive(); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); } Thread.Sleep(2000); } } private void ClientLoop() { m_streamReader = new DelimitedStreamReader(m_client.GetStream()); CrowdControlMod.Instance.Logger.LogInfo((object)"Connected to Crowd Control"); try { while (!m_quitting.IsCancellationRequested) { string text = m_streamReader.ReadUntilNullTerminator(); OnMessage(text.Trim()); } } catch (EndOfStreamException) { CrowdControlMod.Instance.Logger.LogInfo((object)"Disconnected from Crowd Control"); m_client?.Close(); } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)ex2); m_client?.Close(); } } private void OnMessage(string message) { if (string.IsNullOrWhiteSpace(message)) { return; } try { SimpleJSONRequest request = default(SimpleJSONRequest); if (SimpleJSONRequest.TryParse(message, ref request)) { m_mod.Scheduler.ProcessRequest(request); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); } } public bool Send(SimpleJSONResponse? response) { try { if (response == null) { return false; } if (!Connected) { return false; } byte[] bytes = Encoding.UTF8.GetBytes(((SimpleJSONMessage)response).Serialize()); int num = 0; byte[] array = new byte[1 + bytes.Length]; ReadOnlySpan readOnlySpan = new ReadOnlySpan(bytes); readOnlySpan.CopyTo(new Span(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; array[num] = 0; byte[] array2 = array; m_client.GetStream().Write(array2, 0, array2.Length); return true; } catch (Exception arg) { CrowdControlMod.Instance.Logger.LogError((object)$"Error sending a message to the Crowd Control client: {arg}"); return false; } } public Task SendAsync(SimpleJSONResponse? response) { SimpleJSONResponse response2 = response; return Task.Run(() => Send(response2)); } public void Stop(string? message = null) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (message != null) { Send((SimpleJSONResponse?)new MessageResponse { type = (ResponseType)254, message = message }); } m_client?.Close(); } public Task StopAsync(string? message = null) { string message2 = message; return Task.Run(delegate { Stop(message2); }); } public bool KeepAlive() { return Send((SimpleJSONResponse?)(object)KEEPALIVE); } public Task KeepAliveAsync() { return Task.Run((Func)KeepAlive); } private static bool IsCrowdControlSemaphorePresent() { Semaphore result; return Semaphore.TryOpenExisting("CrowdControl", out result); } private static bool IsCrowdControlProcessRunning() { checked { try { Process[] processes = Process.GetProcesses(); int num = 0; Process[] array = processes; foreach (Process process in array) { try { if (process.ProcessName.IndexOf("crowdcontrol", StringComparison.OrdinalIgnoreCase) >= 0) { CrowdControlMod.Instance.Logger.LogInfo((object)$"Found CrowdControl process: {process.ProcessName} (PID: {process.Id})"); return true; } } catch (UnauthorizedAccessException) { num++; } catch (Exception) { num++; } } if (num > 0) { CrowdControlMod.Instance.Logger.LogInfo((object)$"Found {num} inaccessible processes; CrowdControl may be running with elevated permissions."); return true; } return false; } catch (Exception ex3) { CrowdControlMod.Instance.Logger.LogError((object)("Error checking for CrowdControl processes: " + ex3.Message)); return true; } } } public void AttachMetadata(EffectResponse response) { response.metadata = new Dictionary(); string[] commonMetadata = MetadataDelegates.CommonMetadata; foreach (string text in commonMetadata) { if (MetadataLoader.Metadata.TryGetValue(text, out MetadataDelegate value)) { response.metadata.Add(text, value(m_mod)); } else { CrowdControlMod.Instance.Logger.LogError((object)("Metadata delegate \"" + text + "\" could not be found. Available delegates: " + string.Join(", ", MetadataLoader.Metadata.Keys))); } } } public bool ShowEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public bool ShowEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public Task ShowEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public Task ShowEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)128, (string)null)); } public bool ShowAllEffects() { return ShowEffects(m_mod.EffectLoader.Effects.Keys); } public Task ShowAllEffectsAsync() { return ShowEffectsAsync(m_mod.EffectLoader.Effects.Keys); } public bool HideEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public bool HideEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public Task HideEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public Task HideEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)129, (string)null)); } public bool HideAllEffects() { return HideEffects(m_mod.EffectLoader.Effects.Keys); } public Task HideAllEffectsAsync() { return HideEffectsAsync(m_mod.EffectLoader.Effects.Keys); } public bool EnableEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public bool EnableEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public Task EnableEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public Task EnableEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)130, (string)null)); } public bool EnableAllEffects() { return ShowEffects(m_mod.EffectLoader.Effects.Keys); } public Task EnableAllEffectsAsync() { return ShowEffectsAsync(m_mod.EffectLoader.Effects.Keys); } public bool DisableEffects(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public bool DisableEffects([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return Send((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public Task DisableEffectsAsync(params string[] codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public Task DisableEffectsAsync([ParamCollection] IEnumerable codes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return SendAsync((SimpleJSONResponse?)new EffectUpdate(codes, (EffectStatus)131, (string)null)); } public bool DisableAllEffects() { return ShowEffects(m_mod.EffectLoader.Effects.Keys); } public Task DisableAllEffectsAsync() { return ShowEffectsAsync(m_mod.EffectLoader.Effects.Keys); } } internal static class ReflectionEx { private const BindingFlags BINDING_FLAGS = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static void SetField(this object obj, string prop, object val) { obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, val); } public static T GetField(this object obj, string prop) { return (T)obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(obj); } public static void SetProperty(this object obj, string prop, object val) { obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, val); } public static T GetProperty(this object obj, string prop) { return (T)obj.GetType().GetField(prop, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).GetValue(obj); } public static void CallMethod(this object obj, string methodName, params object[] vals) { obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, vals); } public static T CallMethod(this object obj, string methodName, params object[] vals) { return (T)obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Invoke(obj, vals); } } public class Scheduler { private class RequestState { private IEnumerator? m_enumerator; public EffectRequest Request { get; } public Effect Effect { get; } public TimedEffectState? TimedEffectState { get; } public bool MoveNext() { if (m_enumerator != null) { if (m_enumerator.MoveNext()) { return true; } (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; } switch (TimedEffectState?.State) { case CrowdControl.Delegates.Effects.TimedEffectState.EffectState.NotStarted: if (m_enumerator == null) { m_enumerator = TimedEffectState.Start(); } break; case CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Running: if (m_enumerator == null) { m_enumerator = TimedEffectState.Tick(); } break; case CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Finished: return false; } if (m_enumerator != null && m_enumerator.MoveNext()) { return true; } (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue) { TimedEffectState.EffectState valueOrDefault = effectState.GetValueOrDefault(); if ((uint)valueOrDefault <= 2u) { return true; } } return false; } public void Pause() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue && effectState.GetValueOrDefault() == CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Running) { m_enumerator = TimedEffectState.Pause(); } } public void Resume() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue && effectState.GetValueOrDefault() == CrowdControl.Delegates.Effects.TimedEffectState.EffectState.Paused) { m_enumerator = TimedEffectState.Resume(); } } public void Stop() { (m_enumerator as IDisposable)?.Dispose(); m_enumerator = null; TimedEffectState.EffectState? effectState = TimedEffectState?.State; if (effectState.HasValue) { TimedEffectState.EffectState valueOrDefault = effectState.GetValueOrDefault(); if ((uint)(valueOrDefault - 1) <= 1u) { m_enumerator = TimedEffectState.Stop(); } } } public RequestState(EffectRequest request, Effect effect) { Request = request; Effect = effect; if (Effect.IsTimed) { TimedEffectState = new TimedEffectState(effect, request, SITimeSpan.FromMilliseconds(request.duration.GetValueOrDefault())); } } } private CrowdControlMod m_mod; private NetworkClient m_networkClient; private readonly ConcurrentQueue m_requestQueue; private readonly ConcurrentDictionary m_runningEffects; public Scheduler(CrowdControlMod mod, NetworkClient networkClient) { m_mod = mod; m_networkClient = networkClient; m_requestQueue = new ConcurrentQueue(); m_runningEffects = new ConcurrentDictionary(); base..ctor(); } public bool IsRunning(string id) { foreach (TimedEffectState item in m_requestQueue.Select((RequestState p) => p.TimedEffectState).OfType()) { if (item.Effect.EffectAttribute.IDs.Contains(id)) { return true; } } return false; } public void ProcessRequest(SimpleJSONRequest? request) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected I4, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown RequestType? val = request?.type; if (!val.HasValue) { return; } RequestType valueOrDefault = val.GetValueOrDefault(); switch ((int)valueOrDefault) { default: if ((int)valueOrDefault == 253) { m_mod.GameStateManager.UpdateGameState(force: true); } break; case 0: { EffectRequest val5 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val5 == null) { break; } EffectRequest val4 = val5; if (val4.code == null) { val4.code = string.Empty; } if (!m_mod.EffectLoader.Effects.ContainsKey(val5.code)) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val5).id, (EffectStatus)2, (StandardErrors)4097)); CrowdControlMod.Instance.Logger.LogError((object)(StandardErrors)4097); break; } var (flag, text) = m_mod.GameStateManager.IsReady(val5.code); if (flag) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val5).id, (EffectStatus)0, (string)null)); } else { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val5).id, (EffectStatus)1, text)); } break; } case 1: { EffectRequest val3 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val3 != null) { EffectRequest val4 = val3; if (val4.code == null) { val4.code = string.Empty; } if (!m_mod.EffectLoader.Effects.TryGetValue(val3.code, out Effect value2)) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val3).id, (EffectStatus)2, (StandardErrors)4097)); CrowdControlMod.Instance.Logger.LogError((object)(StandardErrors)4097); } else { m_requestQueue.Enqueue(new RequestState(val3, value2)); } } break; } case 2: { EffectRequest val2 = (EffectRequest)(object)((request is EffectRequest) ? request : null); if (val2 != null) { if (!m_runningEffects.TryGetValue(((SimpleJSONRequest)val2).id, out RequestState value)) { m_networkClient.Send((SimpleJSONResponse?)new EffectResponse(((SimpleJSONRequest)val2).id, (EffectStatus)1, (StandardErrors)16899)); CrowdControlMod.Instance.Logger.LogError((object)(StandardErrors)16899); } else { value.Stop(); } } break; } } } public void Enqueue(EffectRequest request, Effect effect) { m_requestQueue.Enqueue(new RequestState(request, effect)); } public void PauseAll() { foreach (KeyValuePair runningEffect in m_runningEffects) { runningEffect.Value.Pause(); } } public void ResumeAll() { foreach (KeyValuePair runningEffect in m_runningEffects) { runningEffect.Value.Resume(); } } public void Tick() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown RequestState result; while (m_requestQueue.TryDequeue(out result)) { var (flag, text) = m_mod.GameStateManager.IsReady(result.Request.code); if (!flag) { EffectResponse response = new EffectResponse(((SimpleJSONRequest)result.Request).id, (EffectStatus)1, text); m_networkClient.SendAsync((SimpleJSONResponse?)(object)response).Forget(); continue; } if (result.TimedEffectState != null) { m_runningEffects.TryAdd(((SimpleJSONRequest)result.Request).id, result); continue; } EffectResponse response2; try { response2 = result.Effect.Start(result.Request); } catch (Exception ex) { response2 = EffectResponse.Failure(((SimpleJSONRequest)result.Request).id, (StandardErrors)1); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); } m_networkClient.AttachMetadata(response2); m_networkClient.SendAsync((SimpleJSONResponse?)(object)response2).Forget(); } ConsumeEnumerators(); } private void ConsumeEnumerators() { foreach (KeyValuePair runningEffect in m_runningEffects) { if (!runningEffect.Value.MoveNext()) { m_runningEffects.TryRemove(runningEffect.Key, out RequestState _); } } } } [Serializable] [JsonConverter(typeof(Converter))] public struct SITimeSpan : IEquatable, IEquatable, IEquatable, IComparable, IComparable, IComparable, IFormattable { private class Converter : JsonConverter { public override void WriteJson(JsonWriter writer, SITimeSpan value, JsonSerializer serializer) { writer.WriteValue(value._value.TotalSeconds); } public override SITimeSpan ReadJson(JsonReader reader, Type objectType, SITimeSpan existingValue, bool hasExistingValue, JsonSerializer serializer) { if (reader.Value is TimeSpan timeSpan) { return timeSpan; } if (reader.Value is string s) { if (TimeSpan.TryParse(s, out var result)) { return result; } if (double.TryParse(s, out var result2)) { return result2; } } return Convert.ToDouble(reader.Value); } } public static readonly SITimeSpan Zero = new SITimeSpan(TimeSpan.Zero); public static readonly SITimeSpan MinValue = new SITimeSpan(TimeSpan.MinValue); public static readonly SITimeSpan MaxValue = new SITimeSpan(TimeSpan.MaxValue); private readonly TimeSpan _value; public long Ticks => _value.Ticks; public int Milliseconds => _value.Milliseconds; public int Seconds => _value.Seconds; public int Minutes => _value.Minutes; public int Hours => _value.Hours; public int Days => _value.Days; public double TotalMilliseconds => _value.TotalMilliseconds; public double TotalSeconds => _value.TotalSeconds; public double TotalMinutes => _value.TotalMinutes; public double TotalHours => _value.TotalHours; public double TotalDays => _value.TotalDays; public override string ToString() { return _value.ToString(); } public string ToString(string? format) { return _value.ToString(format); } public string ToString(string? format, IFormatProvider? formatProvider) { return _value.ToString(format, formatProvider); } public static SITimeSpan Parse(string input) { if (input.Contains('.')) { return new SITimeSpan(TimeSpan.ParseExact(input, "mm\\:ss\\.fff", null)); } return new SITimeSpan(TimeSpan.Parse(input)); } public static bool TryParse(string s, out SITimeSpan result) { TimeSpan result2; bool result3 = TimeSpan.TryParse(s, out result2); result = new SITimeSpan(result2); return result3; } public static int Compare(SITimeSpan t1, SITimeSpan t2) { return TimeSpan.Compare(t1._value, t2._value); } public static int Compare(TimeSpan t1, SITimeSpan t2) { return TimeSpan.Compare(t1, t2._value); } public static int Compare(SITimeSpan t1, TimeSpan t2) { return TimeSpan.Compare(t1._value, t2); } public static int Compare(double t1, SITimeSpan t2) { if (t1 > t2.TotalSeconds) { return 1; } if (!(t1 < t2.TotalSeconds)) { return 0; } return -1; } public static int Compare(SITimeSpan t1, double t2) { if (t1.TotalSeconds > t2) { return 1; } if (!(t1.TotalSeconds < t2)) { return 0; } return -1; } public static bool Equals(SITimeSpan t1, SITimeSpan t2) { return TimeSpan.Equals(t1._value, t2._value); } public static bool Equals(TimeSpan t1, SITimeSpan t2) { return TimeSpan.Equals(t1, t2._value); } public static bool Equals(SITimeSpan t1, TimeSpan t2) { return TimeSpan.Equals(t1._value, t2); } public static bool Equals(double t1, SITimeSpan t2) { return object.Equals(t1, (double)t2); } public static bool Equals(SITimeSpan t1, double t2) { return object.Equals((double)t1, t2); } public static SITimeSpan FromTicks(long value) { return new SITimeSpan(TimeSpan.FromTicks(value)); } public static SITimeSpan FromMilliseconds(double value) { return new SITimeSpan(TimeSpan.FromMilliseconds(value)); } public static SITimeSpan FromSeconds(double value) { return new SITimeSpan(TimeSpan.FromSeconds(value)); } public static SITimeSpan FromMinutes(double value) { return new SITimeSpan(TimeSpan.FromMinutes(value)); } public static SITimeSpan FromHours(double value) { return new SITimeSpan(TimeSpan.FromHours(value)); } public static SITimeSpan FromDays(double value) { return new SITimeSpan(TimeSpan.FromDays(value)); } public SITimeSpan Duration() { return new SITimeSpan(_value.Duration()); } public SITimeSpan Add(SITimeSpan other) { return new SITimeSpan(_value.Add(other._value)); } public SITimeSpan Subtract(SITimeSpan other) { return new SITimeSpan(_value.Subtract(other._value)); } public SITimeSpan Negate() { return new SITimeSpan(_value.Negate()); } private SITimeSpan(TimeSpan value) { _value = value; } private SITimeSpan(double value) { _value = TimeSpan.FromSeconds(value); } private SITimeSpan(long value) { _value = TimeSpan.FromSeconds(value); } public SITimeSpan? NullIfZero() { if (!(_value == TimeSpan.Zero)) { return this; } return null; } public static implicit operator SITimeSpan(double value) { return new SITimeSpan(value); } public static implicit operator SITimeSpan?(double? value) { if (!value.HasValue) { return null; } return new SITimeSpan(value.Value); } public static implicit operator SITimeSpan(TimeSpan value) { return new SITimeSpan(value); } public static implicit operator SITimeSpan?(TimeSpan? value) { if (!value.HasValue) { return null; } return new SITimeSpan(value.Value); } public static implicit operator SITimeSpan(Func value) { return new SITimeSpan(value()); } public static implicit operator SITimeSpan?(Func? value) { if (value == null) { return null; } return new SITimeSpan(value()); } public static implicit operator SITimeSpan(Func value) { return new SITimeSpan(value()._value); } public static implicit operator SITimeSpan?(Func? value) { if (value == null) { return null; } return new SITimeSpan(value()._value); } public static explicit operator double(SITimeSpan value) { return value._value.TotalSeconds; } public static explicit operator double?(SITimeSpan? value) { return value?._value.TotalSeconds; } public static explicit operator float(SITimeSpan value) { return (float)value._value.TotalSeconds; } public static explicit operator float?(SITimeSpan? value) { return (float?)value?._value.TotalSeconds; } public static explicit operator long(SITimeSpan value) { return checked((long)value._value.TotalSeconds); } public static explicit operator long?(SITimeSpan? value) { return checked((long?)value?._value.TotalSeconds); } public static explicit operator TimeSpan(SITimeSpan value) { return value._value; } public static explicit operator TimeSpan?(SITimeSpan? value) { return value?._value; } public static explicit operator Func(SITimeSpan value) { return () => value._value; } public static explicit operator Func(SITimeSpan? value) { return () => value?._value; } public static explicit operator Func(SITimeSpan value) { return () => value; } public static explicit operator Func(SITimeSpan? value) { return () => value; } public override bool Equals(object? obj) { if (obj is SITimeSpan other) { return Equals(other); } if (obj is TimeSpan other2) { return Equals(other2); } if (obj is double other3) { return Equals(other3); } return false; } public override int GetHashCode() { return _value.GetHashCode(); } public bool Equals(SITimeSpan other) { return _value.Equals(other._value); } public int CompareTo(SITimeSpan other) { return _value.CompareTo(other._value); } public static bool operator ==(SITimeSpan a, SITimeSpan b) { return a._value.Equals(b._value); } public static bool operator !=(SITimeSpan a, SITimeSpan b) { return !a._value.Equals(b._value); } public static bool operator <(SITimeSpan a, SITimeSpan b) { return a._value < b._value; } public static bool operator <=(SITimeSpan a, SITimeSpan b) { return a._value <= b._value; } public static bool operator >(SITimeSpan a, SITimeSpan b) { return a._value > b._value; } public static bool operator >=(SITimeSpan a, SITimeSpan b) { return a._value >= b._value; } public bool Equals(TimeSpan other) { return _value.Equals(other); } public int CompareTo(TimeSpan other) { return _value.CompareTo(other); } public static bool operator ==(SITimeSpan a, TimeSpan b) { return a.Equals(b); } public static bool operator ==(TimeSpan a, SITimeSpan b) { return b.Equals(a); } public static bool operator !=(SITimeSpan a, TimeSpan b) { return !a.Equals(b); } public static bool operator !=(TimeSpan a, SITimeSpan b) { return !b.Equals(a); } public static bool operator <(SITimeSpan a, TimeSpan b) { return a._value < b; } public static bool operator <(TimeSpan a, SITimeSpan b) { return a < b._value; } public static bool operator <=(SITimeSpan a, TimeSpan b) { return a._value <= b; } public static bool operator <=(TimeSpan a, SITimeSpan b) { return a <= b._value; } public static bool operator >(SITimeSpan a, TimeSpan b) { return a._value > b; } public static bool operator >(TimeSpan a, SITimeSpan b) { return a > b._value; } public static bool operator >=(SITimeSpan a, TimeSpan b) { return a._value >= b; } public static bool operator >=(TimeSpan a, SITimeSpan b) { return a >= b._value; } public static SITimeSpan operator -(SITimeSpan a) { return -a._value; } public static SITimeSpan operator +(TimeSpan a, SITimeSpan b) { return a + b._value; } public static SITimeSpan operator -(TimeSpan a, SITimeSpan b) { return a - b._value; } public static SITimeSpan operator +(SITimeSpan a, TimeSpan b) { return a._value + b; } public static SITimeSpan operator -(SITimeSpan a, TimeSpan b) { return a._value - b; } public static SITimeSpan operator +(SITimeSpan a, SITimeSpan b) { return a._value + b._value; } public static SITimeSpan operator -(SITimeSpan a, SITimeSpan b) { return a._value - b._value; } public static DateTime operator +(DateTime a, SITimeSpan b) { return a + b._value; } public static DateTime operator -(DateTime a, SITimeSpan b) { return a - b._value; } public static DateTimeOffset operator +(DateTimeOffset a, SITimeSpan b) { return a + b._value; } public static DateTimeOffset operator -(DateTimeOffset a, SITimeSpan b) { return a - b._value; } public static SITimeSpan operator +(double a, SITimeSpan b) { return a + b._value.TotalSeconds; } public static SITimeSpan operator -(double a, SITimeSpan b) { return a - b._value.TotalSeconds; } public static SITimeSpan operator *(double a, SITimeSpan b) { return a * b._value.TotalSeconds; } public static SITimeSpan operator +(SITimeSpan a, double b) { return a._value.TotalSeconds + b; } public static SITimeSpan operator -(SITimeSpan a, double b) { return a._value.TotalSeconds - b; } public static SITimeSpan operator *(SITimeSpan a, double b) { return a._value.TotalSeconds * b; } public static SITimeSpan operator /(SITimeSpan a, double b) { return a._value.TotalSeconds / b; } public static SITimeSpan operator %(SITimeSpan a, double b) { return a._value.TotalSeconds % b; } public bool Equals(double other) { return _value.TotalSeconds.Equals(other); } public int CompareTo(double other) { return _value.TotalSeconds.CompareTo(other); } public static bool operator ==(SITimeSpan a, double b) { return a.Equals(b); } public static bool operator ==(double a, SITimeSpan b) { return b.Equals(a); } public static bool operator !=(SITimeSpan a, double b) { return !a.Equals(b); } public static bool operator !=(double a, SITimeSpan b) { return !b.Equals(a); } public static bool operator <(SITimeSpan a, double b) { return a._value.TotalSeconds < b; } public static bool operator <(double a, SITimeSpan b) { return a < b._value.TotalSeconds; } public static bool operator <=(SITimeSpan a, double b) { return a._value.TotalSeconds <= b; } public static bool operator >=(SITimeSpan a, double b) { return a._value.TotalSeconds >= b; } public static bool operator >(SITimeSpan a, double b) { return a._value.TotalSeconds > b; } public static bool operator >(double a, SITimeSpan b) { return a > b._value.TotalSeconds; } public static bool operator <=(double a, SITimeSpan b) { return a <= b._value.TotalSeconds; } public static bool operator >=(double a, SITimeSpan b) { return a >= b._value.TotalSeconds; } } public static class SpawnedItemProtection { [CompilerGenerated] private sealed class d__10 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject obj; private Item 5__2; private Breakable 5__3; private Rigidbody 5__4; private bool 5__5; private bool 5__6; private Vector3 5__7; private Quaternion 5__8; private float 5__9; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = null; <>1__state = 2; return true; case 2: <>1__state = -1; if ((Object)(object)obj == (Object)null) { return false; } 5__2 = obj.GetComponent(); 5__3 = obj.GetComponent(); 5__4 = obj.GetComponent(); 5__5 = false; 5__6 = false; if ((Object)(object)5__3 != (Object)null) { 5__6 = 5__3.breakOnCollision; 5__3.breakOnCollision = false; 5__5 = true; } 5__7 = obj.transform.position; 5__8 = obj.transform.rotation; SetHeldInPlace(5__2, 5__4, 5__7, 5__8, kinematic: true); 5__9 = 0f; break; case 3: <>1__state = -1; break; } if (5__9 < 4f && (Object)(object)obj != (Object)null) { SetHeldInPlace(5__2, 5__4, 5__7, 5__8, kinematic: true); 5__9 += Time.deltaTime; <>2__current = null; <>1__state = 3; return true; } if ((Object)(object)obj == (Object)null) { return false; } SetHeldInPlace(5__2, 5__4, 5__7, 5__8, kinematic: false); if (5__5 && (Object)(object)5__3 != (Object)null) { 5__3.breakOnCollision = 5__6; } 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 const float ProtectionDurationSeconds = 4f; private const float SpawnForwardDistance = 1.5f; private const float GroundClearance = 0.35f; private const float RaycastHeight = 50f; private const float RaycastDistance = 120f; public static Vector3 GetGroundedSpawnPosition(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0051: 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_0061: 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_0028: 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) Vector3 val = character.Center; float y = ((Component)character).transform.eulerAngles.y; if (TryGetHipTransform(character, out Transform hip)) { val = hip.position; y = hip.eulerAngles.y; } Vector3 val2 = Quaternion.Euler(0f, y, 0f) * Vector3.forward; return GroundPoint(val + val2 * 1.5f); } public static bool TryResolveTargetCharacter(Dictionary data, out Character character) { character = null; if (!data.TryGetValue("targetPlayerId", out object value)) { return false; } int targetPlayerId = Convert.ToInt32(value); character = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component = ((Component)c).GetComponent(); if (component == null) { return false; } Player owner = component.Owner; return ((owner != null) ? new int?(owner.ActorNumber) : null) == targetPlayerId; }); return (Object)(object)character != (Object)null; } private static bool TryGetHipTransform(Character character, out Transform hip) { hip = ((Component)character).transform.Find("Hip"); if ((Object)(object)hip != (Object)null) { return true; } Transform[] componentsInChildren = ((Component)((Component)character).transform).GetComponentsInChildren(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Hip") { hip = val; return true; } } hip = null; return false; } public static Vector3 GroundPoint(Vector3 approximatePosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_003b: 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) RaycastHit val = default(RaycastHit); if (Physics.Raycast(approximatePosition + Vector3.up * 50f, Vector3.down, ref val, 120f, -1, (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val)).point + Vector3.up * 0.35f; } return approximatePosition + Vector3.up * 0.35f; } public static void Apply(GameObject obj) { if (!((Object)(object)obj == (Object)null)) { ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(ProtectCoroutine(obj)); } } [IteratorStateMachine(typeof(d__10))] private static IEnumerator ProtectCoroutine(GameObject obj) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { obj = obj }; } private static void SetHeldInPlace(Item? item, Rigidbody? rb, Vector3 position, Quaternion rotation, bool kinematic) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item != (Object)null) { if (kinematic) { item.SetKinematicNetworked(true, position, rotation); } else { item.SetKinematicNetworked(false); } } else if (!((Object)(object)rb == (Object)null)) { rb.isKinematic = kinematic; if (kinematic) { rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.position = position; rb.rotation = rotation; } } } } public static class TaskEx { public static async void Forget(this Task task) { try { await task.ConfigureAwait(continueOnCapturedContext: false); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); } } public static async void Forget(this Task task, bool silent) { try { await task.ConfigureAwait(continueOnCapturedContext: false); } catch (Exception ex) { if (!silent) { CrowdControlMod.Instance.Logger.LogError((object)ex); } } } } } namespace CrowdControl.Harmony { [HarmonyPatch] public static class Player { } [HarmonyPatch(typeof(CharacterInput), "Sample")] public static class ReverseControlsPatch { private static void Postfix(CharacterInput __instance, bool playerMovementActive) { //IL_000d: 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_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_0028: Unknown result type (might be due to invalid IL or missing references) if (playerMovementActive && ReverseControlsEffect.IsActive) { __instance.movementInput = -__instance.movementInput; __instance.lookInput = -__instance.lookInput; } } } } namespace CrowdControl.Delegates.Metadata { [AttributeUsage(AttributeTargets.Method)] public class MetadataAttribute : Attribute { public string[] IDs { get; } public MetadataAttribute(params string[] ids) { IDs = ids; base..ctor(); } public MetadataAttribute(string ids) : this(new string[1] { ids }) { } public MetadataAttribute([ParamCollection] IEnumerable ids) : this(ids.ToArray()) { } } public delegate DataResponse MetadataDelegate(CrowdControlMod mod); public static class MetadataDelegates { public static readonly string[] CommonMetadata = Array.Empty(); } public static class MetadataLoader { private const BindingFlags BINDING_FLAGS = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static readonly Dictionary Metadata; static MetadataLoader() { Metadata = new Dictionary(); Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { try { MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { try { foreach (MetadataAttribute customAttribute in methodInfo.GetCustomAttributes()) { string[] iDs = customAttribute.IDs; foreach (string key in iDs) { try { Metadata[key] = (MetadataDelegate)Delegate.CreateDelegate(typeof(MetadataDelegate), methodInfo); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); } } } } catch { } } } catch { } } } } } namespace CrowdControl.Delegates.Effects { public abstract class Effect { public EffectAttribute EffectAttribute { get; } public bool IsTimed => EffectAttribute.DefaultDuration > 0.0; public CrowdControlMod Mod { get; } public NetworkClient Client { get; } protected Effect(CrowdControlMod mod, NetworkClient client) { Mod = mod; Client = client; EffectAttribute = GetType().GetCustomAttributes(inherit: false).First(); } public abstract EffectResponse Start(EffectRequest request); public virtual EffectResponse? Tick(EffectRequest request) { return null; } public virtual EffectResponse? Pause(EffectRequest request) { return null; } public virtual EffectResponse? Resume(EffectRequest request) { return null; } public virtual EffectResponse? Stop(EffectRequest request) { return null; } } [AttributeUsage(AttributeTargets.Class)] public class EffectAttribute : Attribute { public IReadOnlyList IDs { get; } public SITimeSpan DefaultDuration { get; } public IReadOnlyList Conflicts { get; } public EffectAttribute(string[] ids, SITimeSpan defaultDuration, string[] conflicts) { IDs = ids; DefaultDuration = defaultDuration; Conflicts = conflicts; base..ctor(); } public EffectAttribute([ParamCollection] IEnumerable ids) : this(ids.ToArray(), SITimeSpan.Zero, Array.Empty()) { } public EffectAttribute(params string[] ids) : this(ids.ToArray(), SITimeSpan.Zero, Array.Empty()) { } public EffectAttribute(string[] ids, float defaultDuration, string[] conflicts) : this(ids, (SITimeSpan)defaultDuration, conflicts) { } public EffectAttribute(string[] ids, float defaultDuration, string conflict) : this(ids, defaultDuration, new string[1] { conflict }) { } public EffectAttribute(string id) : this(new string[1] { id }, SITimeSpan.Zero, Array.Empty()) { } public EffectAttribute(string id, float defaultDuration) : this(new string[1] { id }, defaultDuration, (!(SITimeSpan.Zero > 0.0)) ? Array.Empty() : new string[1] { id }) { } public EffectAttribute(string id, float defaultDuration, string conflict) : this(new string[1] { id }, defaultDuration, new string[1] { conflict }) { } public EffectAttribute(string id, float defaultDuration, string[] conflicts) : this(new string[1] { id }, defaultDuration, conflicts) { } public EffectAttribute(string id, float defaultDuration, bool selfConflict) : this(new string[1] { id }, defaultDuration, (!selfConflict) ? Array.Empty() : new string[1] { id }) { } public EffectAttribute(string[] ids, float defaultDuration, bool selfConflict) : this(ids, defaultDuration, selfConflict ? ids : Array.Empty()) { } public EffectAttribute(string id, bool selfConflict) : this(new string[1] { id }, SITimeSpan.Zero, (!selfConflict) ? Array.Empty() : new string[1] { id }) { } public EffectAttribute(string[] ids, bool selfConflict) : this(ids, SITimeSpan.Zero, selfConflict ? ids : Array.Empty()) { } } public class EffectLoader { private const BindingFlags BINDING_FLAGS = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public readonly Dictionary Effects = new Dictionary(); public EffectLoader(CrowdControlMod mod, NetworkClient client) { foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes() where type.IsSubclassOf(typeof(Effect)) select type) { try { foreach (EffectAttribute customAttribute in item.GetCustomAttributes()) { foreach (string iD in customAttribute.IDs) { try { Effects[iD] = (Effect)Activator.CreateInstance(item, mod, client); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)ex); } } } } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)ex2); } } } } public class TimedEffectState { public enum EffectState { NotStarted, Running, Paused, Finished, Errored } [CompilerGenerated] private sealed class d__15 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != EffectState.Running) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Pause(timedEffectState.Request); timedEffectState.State = EffectState.Paused; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__16 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != EffectState.Paused) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Resume(timedEffectState.Request); timedEffectState.State = EffectState.Running; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__14 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != 0) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Start(timedEffectState.Request); timedEffectState.TimeRemaining = timedEffectState.Duration; timedEffectState.State = EffectState.Running; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__17 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State == EffectState.Finished) { result = false; <>m__Finally1(); } else { try { 5__2 = timedEffectState.Effect.Stop(timedEffectState.Request); timedEffectState.State = EffectState.Finished; } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__18 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimedEffectState <>4__this; private EffectResponse 5__2; private bool 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { int num = <>1__state; TimedEffectState timedEffectState = <>4__this; switch (num) { default: result = false; goto end_IL_0000; case 0: <>1__state = -1; 5__2 = null; 5__3 = false; <>1__state = -3; break; case 1: <>1__state = -3; break; } if (!(5__3 = timedEffectState.TryGetLock())) { <>2__current = null; <>1__state = 1; result = true; } else if (timedEffectState.State != EffectState.Running) { result = false; <>m__Finally1(); } else { try { if (timedEffectState.TimeRemaining > 0.0) { 5__2 = timedEffectState.Effect.Tick(timedEffectState.Request); timedEffectState.TimeRemaining -= (double)Time.fixedDeltaTime; } else { 5__2 = timedEffectState.Effect.Stop(timedEffectState.Request); timedEffectState.State = EffectState.Finished; timedEffectState.TimeRemaining = SITimeSpan.Zero; } } catch (Exception ex) { 5__2 = EffectResponse.Failure(((SimpleJSONRequest)timedEffectState.Request).id, (StandardErrors)1); CrowdControlMod.Instance.Logger.LogError((object)ex.Message); timedEffectState.State = EffectState.Errored; } <>m__Finally1(); result = false; } end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; TimedEffectState timedEffectState = <>4__this; if (5__3) { timedEffectState.ReleaseLock(); timedEffectState.Client.Send((SimpleJSONResponse?)(object)5__2); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public readonly EffectRequest Request; public readonly SITimeSpan Duration; public readonly Effect Effect; public readonly NetworkClient Client; public SITimeSpan TimeRemaining; private int m_stateLock; public EffectState State { get; private set; } private bool TryGetLock() { return Interlocked.CompareExchange(ref m_stateLock, 1, 0) == 0; } private void ReleaseLock() { m_stateLock = 0; } public TimedEffectState(Effect effect, EffectRequest request, SITimeSpan duration) { Effect = effect; Client = effect.Client; Request = request; Duration = duration; TimeRemaining = duration; } [IteratorStateMachine(typeof(d__14))] public IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__14(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__15))] public IEnumerator Pause() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__16))] public IEnumerator Resume() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__16(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__17))] public IEnumerator Stop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__17(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__18))] public IEnumerator Tick() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0) { <>4__this = this }; } } } namespace CrowdControl.Delegates.Effects.Implementations { [Effect(new string[] { "add_balloon" }, 0f, false)] public class AddBalloonEffect : Effect { public AddBalloonEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } CharacterBalloons component = ((Component)localCharacter).GetComponent(); if ((Object)(object)component == (Object)null && ((object)localCharacter).GetType().GetField("balloons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(localCharacter) == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to add balloon!"); } try { MethodInfo methodInfo = ((object)component)?.GetType().GetMethod("TieNewBalloon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (methodInfo != null) { int num = Random.Range(0, 4); methodInfo.Invoke(component, new object[1] { num }); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unable to add balloon!"); } catch (Exception ex) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to add balloon: " + ex.Message); } } } public class AggressiveTumbleweed : MonoBehaviour { [CompilerGenerated] private sealed class d__13 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AggressiveTumbleweed <>4__this; public Character target; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown int num = <>1__state; AggressiveTumbleweed aggressiveTumbleweed = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; aggressiveTumbleweed.ignored.Add(target); <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; aggressiveTumbleweed.ignored.Remove(target); 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 Rigidbody rig; public float rollForce = 15f; public float collisionForce = 20f; private float maxAngle = 180f; private PhotonView photonView; private List ignored = new List(); private Character currentTarget; private float targetUpdateInterval = 0.5f; private float lastTargetUpdate; private void Start() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) photonView = ((Component)this).GetComponent(); rig = ((Component)this).GetComponent(); rollForce = Mathf.Lerp(12f, 20f, Mathf.Pow(Random.value, 2f)); collisionForce = Mathf.Lerp(15f, 25f, Mathf.Pow(Random.value, 2f)); Vector3 val = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val)).normalized; if ((Object)(object)rig != (Object)null) { rig.AddForce(normalized * rollForce * 0.5f, (ForceMode)1); } } private void FixedUpdate() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0083: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_00f8: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if (!photonView.IsMine) { return; } if (Time.time - lastTargetUpdate > targetUpdateInterval) { currentTarget = GetTarget(); lastTargetUpdate = Time.time; } Vector3 val = -Vector3.right; Vector3 val2; if ((Object)(object)currentTarget != (Object)null) { val2 = currentTarget.Center - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; normalized.y = 0f; val = normalized; val += new Vector3(Random.Range(-0.3f, 0.3f), 0f, Random.Range(-0.3f, 0.3f)); ((Vector3)(ref val)).Normalize(); } else if (Random.value < 0.1f) { val2 = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); val = ((Vector3)(ref val2)).normalized; } if ((Object)(object)rig != (Object)null) { rig.AddForce(val * rollForce, (ForceMode)5); val2 = rig.velocity; if (((Vector3)(ref val2)).magnitude > 25f) { Rigidbody obj = rig; val2 = rig.velocity; obj.velocity = ((Vector3)(ref val2)).normalized * 25f; } } } private Character GetTarget() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) float num = 50f; Character result = null; foreach (Character allCharacter in Character.AllCharacters) { if ((Object)(object)allCharacter == (Object)null || allCharacter.data.dead || allCharacter.data.fullyPassedOut) { continue; } float num2 = Vector3.Distance(allCharacter.Center, ((Component)this).transform.position); if (num2 < num && !ignored.Contains(allCharacter)) { Vector3 val = allCharacter.Center - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; if (Vector3.Angle(((Component)this).transform.forward, normalized) <= maxAngle) { num = num2; result = allCharacter; } } } return result; } public void OnCollisionEnter(Collision collision) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) Character componentInParent = collision.gameObject.GetComponentInParent(); if (!Object.op_Implicit((Object)(object)componentInParent) || ignored.Contains(componentInParent)) { return; } ((MonoBehaviour)this).StartCoroutine(IgnoreTarget(componentInParent)); float num; Vector3 velocity; if (!((Object)(object)rig != (Object)null)) { num = 10f; } else { velocity = rig.velocity; num = ((Vector3)(ref velocity)).magnitude; } float num2 = Mathf.Clamp01(num / 20f); if (num2 < 0.1f) { return; } if ((Object)(object)rig != (Object)null) { Rigidbody component = ((Component)componentInParent).GetComponent(); if ((Object)(object)component != (Object)null) { velocity = rig.velocity; component.AddForce(((Vector3)(ref velocity)).normalized * collisionForce * num2, (ForceMode)1); } try { MethodInfo method = ((object)componentInParent).GetType().GetMethod("Fall", BindingFlags.Instance | BindingFlags.Public); if (method != null) { method.Invoke(componentInParent, new object[2] { 2f * num2, 0f }); } } catch { } } try { MethodInfo method2 = ((object)componentInParent).GetType().GetMethod("AddStatus", BindingFlags.Instance | BindingFlags.Public); if (method2 != null) { method2.Invoke(componentInParent, new object[3] { "Injury", num2 * 0.1f, false }); } } catch { } CrowdControlMod instance = CrowdControlMod.Instance; if (instance != null) { instance.Logger.LogInfo((object)$"[AggressiveTumbleweed] Attacked {((Object)componentInParent).name} with damage multiplier {num2:F2}"); } } [IteratorStateMachine(typeof(d__13))] public IEnumerator IgnoreTarget(Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__13(0) { <>4__this = this, target = target }; } public void MakeMoreAggressive() { rollForce *= 1.5f; collisionForce *= 1.3f; maxAngle = 360f; } } [Effect("bananaSlip", 0f, true)] public class BananaSlip : Effect { private static MethodInfo getBodypartRigMethod; public BananaSlip(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public static Rigidbody GetBodypartRigReflection(Character character, BodypartType part) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return null; } if (getBodypartRigMethod == null) { getBodypartRigMethod = typeof(Character).GetMethod("GetBodypartRig", BindingFlags.Instance | BindingFlags.NonPublic); if (getBodypartRigMethod == null) { return null; } } object? obj = getBodypartRigMethod.Invoke(character, new object[1] { part }); return (Rigidbody)((obj is Rigidbody) ? obj : null); } public override EffectResponse Start(EffectRequest request) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } localCharacter.RPCA_Fall(2f); Vector3 lookDirection_Flat = localCharacter.data.lookDirection_Flat; Rigidbody bodypartRigReflection = GetBodypartRigReflection(localCharacter, (BodypartType)16); Rigidbody bodypartRigReflection2 = GetBodypartRigReflection(localCharacter, (BodypartType)13); Rigidbody bodypartRigReflection3 = GetBodypartRigReflection(localCharacter, (BodypartType)0); Rigidbody bodypartRigReflection4 = GetBodypartRigReflection(localCharacter, (BodypartType)4); if (bodypartRigReflection != null) { bodypartRigReflection.AddForce((lookDirection_Flat + Vector3.up) * 200f, (ForceMode)1); } if (bodypartRigReflection2 != null) { bodypartRigReflection2.AddForce((lookDirection_Flat + Vector3.up) * 200f, (ForceMode)1); } if (bodypartRigReflection3 != null) { bodypartRigReflection3.AddForce(Vector3.up * 1500f, (ForceMode)1); } if (bodypartRigReflection4 != null) { bodypartRigReflection4.AddForce(lookDirection_Flat * -300f, (ForceMode)1); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect("beeSwarm", 0f, true)] public class BeeSwarm : Effect { public BeeSwarm(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } BeeSwarm component = PhotonNetwork.InstantiateRoomObject("BeeSwarm", ((Component)localCharacter).transform.position, ((Component)localCharacter).transform.rotation, (byte)0, (object[])null).GetComponent(); typeof(BeeSwarm).GetMethod("GetAngry", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(component, new object[1] { 15f }); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "big_player" }, 0f, true)] public class BigPlayerEffect : Effect { private static bool _active = false; private static Vector3 _originalScale = Vector3.one; public BigPlayerEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (_active) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Transform transform = ((Component)localCharacter).transform; if ((Object)(object)transform == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Character transform not found"); } _active = true; _originalScale = transform.localScale; transform.localScale = _originalScale * 1.4f; ResetSizeAfterDelay(transform, request); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private async Task ResetSizeAfterDelay(Transform transform, EffectRequest request) { await Task.Delay(checked((int)request.duration.Value)); transform.localScale = _originalScale; _active = false; } } [Effect(new string[] { "test_custom_event", "test_host_effect" }, 0f, false)] public class CustomEventTestEffect : Effect { public CustomEventTestEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (PhotonNetwork.IsMasterClient) { return ExecuteHostEffect(request); } return RequestHostEffect(request); } private EffectResponse ExecuteHostEffect(EffectRequest request) { try { CrowdControlMod.Instance.Logger.LogInfo((object)"[CustomEventTestEffect] Host executing custom effect"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("[CustomEventTestEffect] Host effect failed: " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } } private EffectResponse RequestHostEffect(EffectRequest request) { Dictionary data = new Dictionary { ["effectType"] = "test_effect", ["playerName"] = PhotonNetwork.LocalPlayer.NickName, ["timestamp"] = DateTime.Now.ToString() }; if (CustomEventSystem.Instance.TriggerEvent("custom_effect", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)("[CustomEventTestEffect] Host executed effect successfully: " + response.Message)); } else { CrowdControlMod.Instance.Logger.LogError((object)("[CustomEventTestEffect] Host failed to execute effect: " + response.Message)); } })) { CrowdControlMod.Instance.Logger.LogInfo((object)"[CustomEventTestEffect] Requested host to execute custom effect"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } CrowdControlMod.Instance.Logger.LogError((object)"[CustomEventTestEffect] Failed to send request to host"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } } [Effect(new string[] { "drop_item", "drop_all_items", "drop_all_items_backpack" }, 0f, true)] public class DropItemEffect : Effect { public DropItemEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0107: 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_011c: 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_0126: 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) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } CharacterItems items = localCharacter.refs.items; if (!Object.op_Implicit((Object)(object)items)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } bool flag = true; for (int i = 0; i < localCharacter.player.itemSlots.Length; i = checked(i + 1)) { if (!localCharacter.player.itemSlots[i].IsEmpty()) { flag = false; break; } } if (request.code == "drop_item") { if (flag) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player does not have any items to drop!"); } if (!items.currentSelectedSlot.IsSome) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } if (localCharacter.player.GetItemSlot(items.currentSelectedSlot.Value) == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } Vector3 val = ((Component)localCharacter).transform.position + ((Component)localCharacter).transform.forward * 1.5f + Vector3.up; ((MonoBehaviourPun)localCharacter.refs.items).photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty()); ((MonoBehaviourPun)localCharacter.refs.items).photonView.RPC("DropItemFromSlotRPC", (RpcTarget)0, new object[2] { items.currentSelectedSlot.Value, val }); } else { bool flag2 = request.code == "drop_all_items_backpack"; if (flag2 && ((ItemSlot)localCharacter.player.backpackSlot).IsEmpty()) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player does not have a backpack. Use drop all items instead!"); } if (flag && (!flag2 || ((ItemSlot)localCharacter.player.backpackSlot).IsEmpty())) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player does not have any items to drop!"); } MethodInfo method = typeof(CharacterItems).GetMethod("DropAllItems", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(method != null)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } method.Invoke(items, new object[1] { flag2 }); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "remove_item_airplanefood", "remove_item_antirope", "remove_item_antidote", "remove_item_appleberrygreen", "remove_item_appleberryred", "remove_item_appleberryyellow", "remove_item_book", "remove_item_backpack", "remove_item_bandage", "remove_item_beehive", "remove_item_berrynanablue", "remove_item_berrynanabrown", "remove_item_berrynanapink", "remove_item_berrynanayellow", "remove_item_bingbong", "remove_item_binoculars", "remove_item_bugle", "remove_item_buglemagic", "remove_item_buglescoutmaster", "remove_item_climbingspike", "remove_item_clusterberryblack", "remove_item_clusterberryred", "remove_item_clusterberryyellow", "remove_item_clusterberryunused", "remove_item_chaincannon", "remove_item_compass", "remove_item_cureall", "remove_item_cursedskull", "remove_item_egg", "remove_item_energydrink", "remove_item_firewood", "remove_item_firstaidkit", "remove_item_flagseagull", "remove_item_flagturtle", "remove_item_flare", "remove_item_granolabar", "remove_item_guidebook", "remove_item_heatpack", "remove_item_coconut", "remove_item_coconuthalf", "remove_item_honeycomb", "remove_item_kingberrygreen", "remove_item_kingberrypurple", "remove_item_kingberryyellow", "remove_item_lantern", "remove_item_lanternfaerie", "remove_item_lollipop", "remove_item_magicbean", "remove_item_marshmellow", "remove_item_medicinalroot", "remove_item_mushroomchubby", "remove_item_mushroomcluster", "remove_item_mushroomclusterpoison", "remove_item_mushroomglow", "remove_item_mushroomlace", "remove_item_mushroomlacepoison", "remove_item_mushroomnormie", "remove_item_mushroomnormiepoison", "remove_item_napberry", "remove_item_nestegg", "remove_item_pandorasbox", "remove_item_passport", "remove_item_pepperberry", "remove_item_piratecompass", "remove_item_stove", "remove_item_ropecannon", "remove_item_ropecannonanti", "remove_item_rope", "remove_item_scoutcookies", "remove_item_scouteffigy", "remove_item_shelfshroom", "remove_item_shellbig", "remove_item_stone", "remove_item_toy", "remove_item_toyscout", "remove_item_trailmix", "remove_item_warpcompass", "remove_item_winterberryorange", "remove_item_winterberryyellow", "remove_item_bounce", "remove_item_healingdart", "remove_item_guidepage", "remove_item_guidepage0", "remove_item_guidepage1", "remove_item_guidepage2", "remove_item_guidepage3", "remove_item_guidepage4", "remove_item_guidepage5", "remove_item_guidepage6", "remove_item_guidepage7", "remove_item_guidepage8", "remove_item_guidepagescroll", "remove_item_healingpuff", "remove_item_peelblue", "remove_item_peelbrown", "remove_item_peelpink", "remove_item_peelyellow", "remove_item_bugfix" }, 0f, true)] public class RemoveItemEffect : Effect { private static readonly Dictionary ItemMap = new Dictionary { { "airplanefood", "Airplane Food" }, { "antirope", "Anti-Rope Spool" }, { "antidote", "Antidote" }, { "appleberrygreen", "Apple Berry Green" }, { "appleberryred", "Apple Berry Red" }, { "appleberryyellow", "Apple Berry Yellow" }, { "backpack", "Backpack" }, { "bandage", "Bandages" }, { "beehive", "Beehive" }, { "berrynanablue", "Berrynana Blue" }, { "berrynanabrown", "Berrynana Brown" }, { "berrynanapink", "Berrynana Pink" }, { "berrynanayellow", "Berrynana Yellow" }, { "bingbong", "BingBong" }, { "toy", "BingBong" }, { "binoculars", "Binoculars" }, { "bugle", "Bugle" }, { "buglemagic", "Bugle_Magic" }, { "buglescoutmaster", "Bugle_Scoutmaster Variant" }, { "climbingspike", "ClimbingSpike" }, { "clusterberryblack", "Clusterberry Black" }, { "clusterberryred", "Clusterberry Red" }, { "clusterberryyellow", "Clusterberry Yellow" }, { "clusterberryunused", "Clusterberry_UNUSED" }, { "chaincannon", "ChainShooter" }, { "compass", "Compass" }, { "cureall", "Cure-All" }, { "cursedskull", "Cursed Skull" }, { "egg", "Egg" }, { "energydrink", "Energy Drink" }, { "firewood", "FireWood" }, { "firstaidkit", "FirstAidKit" }, { "flagseagull", "Flag_Plantable_Seagull" }, { "flagturtle", "Flag_Plantable_Turtle" }, { "flare", "Flare" }, { "granolabar", "Granola Bar" }, { "guidebook", "Guidebook" }, { "heatpack", "Heat Pack" }, { "coconut", "Item_Coconut" }, { "coconuthalf", "Item_Coconut_half" }, { "honeycomb", "Item_Honeycomb" }, { "kingberrygreen", "Kingberry Green" }, { "kingberrypurple", "Kingberry Purple" }, { "kingberryyellow", "Kingberry Yellow" }, { "lantern", "Lantern" }, { "lanternfaerie", "Lantern_Faerie" }, { "lollipop", "Lollipop" }, { "magicbean", "MagicBean" }, { "marshmellow", "Marshmallow" }, { "medicinalroot", "MedicinalRoot" }, { "mushroomchubby", "Mushroom Chubby" }, { "mushroomcluster", "Mushroom Cluster" }, { "mushroomclusterpoison", "Mushroom Cluster Poison" }, { "mushroomglow", "Mushroom Glow" }, { "mushroomlace", "Mushroom Lace" }, { "mushroomlacepoison", "Mushroom Lace Poison" }, { "mushroomnormie", "Mushroom Normie" }, { "mushroomnormiepoison", "Mushroom Normie Poison" }, { "napberry", "Napberry" }, { "nestegg", "NestEgg" }, { "pandorasbox", "PandorasBox" }, { "passport", "Passport" }, { "pepperberry", "Pepper Berry" }, { "piratecompass", "Pirate Compass" }, { "stove", "PortableStovetopItem" }, { "ropecannon", "RopeShooter" }, { "ropecannonanti", "RopeShooterAnti" }, { "rope", "RopeSpool" }, { "scoutcookies", "ScoutCookies" }, { "scouteffigy", "ScoutEffigy" }, { "shelfshroom", "ShelfShroom" }, { "shellbig", "Shell Big" }, { "stone", "Stone" }, { "toyscout", "Toy" }, { "trailmix", "TrailMix" }, { "warpcompass", "Warp Compass" }, { "winterberryorange", "Winterberry Orange" }, { "winterberryyellow", "Winterberry Yellow" }, { "bounce", "BounceShroom" }, { "healingdart", "HealingDart Variant" }, { "guidepage", "GuidebookPage" }, { "guidepage0", "GuidebookPage_0_Intro" }, { "guidepage1", "GuidebookPage_1_Mushrooms" }, { "guidepage2", "GuidebookPage_2_Campfire" }, { "guidepage3", "GuidebookPage_3_Revival" }, { "guidepage4", "GuidebookPage_4_BodyHeat Variant" }, { "guidepage5", "GuidebookPage_5_Sleepy Variant" }, { "guidepage6", "GuidebookPage_6_Awake Variant" }, { "guidepage7", "GuidebookPage_7_Crashout Variant" }, { "guidepage8", "GuidebookPage_8_FirstTeams" }, { "guidepagescroll", "GuidebookPageScroll Variant" }, { "healingpuff", "HealingPuffShroom" }, { "peelblue", "Berrynana Peel Blue Variant" }, { "peelbrown", "Berrynana Peel Brown Variant" }, { "peelpink", "Berrynana Peel Pink Variant" }, { "peelyellow", "Berrynana Peel Yellow" }, { "bugfix", "Bugfix" } }; public RemoveItemEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Item currentItem = localCharacter.data.currentItem; string text = (Object.op_Implicit((Object)(object)currentItem) ? ((Object)currentItem).name : null); if (request.code == "remove_item_backpack") { if (((ItemSlot)localCharacter.player.backpackSlot).IsEmpty()) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Vector3 val = ((Component)localCharacter).transform.position + ((Component)localCharacter).transform.forward * 1.5f + Vector3.up; ((MonoBehaviourPun)localCharacter.refs.items).photonView.RPC("DropItemFromSlotRPC", (RpcTarget)0, new object[2] { 3, val }); } string[] array = request.code.Split('_'); if (array.Length < 3) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } string text2 = array[2].ToLowerInvariant(); if (!ItemMap.TryGetValue(text2, out string value)) { CrowdControlMod.Instance.Logger.LogWarning((object)("[RemoveItemEffect] No mapping found for slug '" + text2 + "'")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } checked { for (int i = 0; i < localCharacter.player.itemSlots.Length; i++) { ItemSlot val2 = localCharacter.player.itemSlots[i]; if (val2.IsEmpty() || !(val2.GetPrefabName() == value)) { continue; } if (!string.IsNullOrEmpty(text) && text.Contains(value)) { ((MonoBehaviourPun)localCharacter.refs.items).photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty()); } Vector3 val3 = ((Component)localCharacter).transform.position + ((Component)localCharacter).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)Character.localCharacter).transform).GetComponentsInChildren(); foreach (Transform val4 in componentsInChildren) { if (((Object)val4).name == "Hip") { val3 = ((Component)val4).transform.position + ((Component)val4).transform.forward * 0.5f + Vector3.up; } } Transform val5 = ((Component)Character.localCharacter).transform.Find("Hip"); if ((Object)(object)val5 != (Object)null) { val3 = val5.position + val5.forward * 1.5f + Vector3.up; } ((MonoBehaviourPun)localCharacter.refs.items).photonView.RPC("DropItemFromSlotRPC", (RpcTarget)0, new object[2] { (byte)i, val3 }); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } } } [Effect(new string[] { "force_emote" }, 0f, true)] public class ForceEmoteEffect : Effect { private static readonly string[] Emotes = new string[2] { "A_Scout_Emote_BackFlip", "A_Scout_Emote_PlayDead" }; public ForceEmoteEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (localCharacter.data.isClimbing || localCharacter.data.isRopeClimbing || localCharacter.data.isVineClimbing) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Cannot emote while climbing."); } if ((Object)(object)localCharacter.refs?.animations == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } string text = Emotes[Random.Range(0, Emotes.Length)]; try { MethodInfo method = ((object)localCharacter.refs.animations).GetType().GetMethod("PlayEmote", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } method.Invoke(localCharacter.refs.animations, new object[1] { text }); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("[ForceEmoteEffect] Failed to play emote " + text + ": " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } } } [Effect(new string[] { "giant_player" }, 0f, true)] public class GiantPlayerEffect : Effect { [CompilerGenerated] private CrowdControlMod P; private static bool _active = false; private static List _originalScales = new List(); private static List _scaledObjects = new List(); public GiantPlayerEffect(CrowdControlMod mod, NetworkClient client) { P = mod; base..ctor(P, client); } public override EffectResponse Start(EffectRequest request) { if (_active) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } _active = true; _originalScales.Clear(); _scaledObjects.Clear(); ScaleVisualModelOnly(localCharacter, 4f); ResetSizeAfterDelay(localCharacter, request); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private async Task ResetSizeAfterDelay(Character character, EffectRequest request) { checked { await Task.Delay((int)request.duration.Value); for (int i = 0; i < _scaledObjects.Count && i < _originalScales.Count; i++) { if ((Object)(object)_scaledObjects[i] != (Object)null) { _scaledObjects[i].localScale = _originalScales[i]; } } _active = false; _originalScales.Clear(); _scaledObjects.Clear(); } } private void ScaleVisualModelOnly(Character character, float scaleMultiplier) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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) Renderer[] componentsInChildren = ((Component)character).GetComponentsInChildren(); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).transform != (Object)(object)((Component)character).transform) { _originalScales.Add(((Component)val).transform.localScale); _scaledObjects.Add(((Component)val).transform); ((Component)val).transform.localScale = ((Component)val).transform.localScale * scaleMultiplier; P.Logger.LogInfo((object)("[GiantPlayerEffect] Scaled visual model: " + ((Object)val).name)); } } Transform[] componentsInChildren2 = ((Component)character).GetComponentsInChildren(); foreach (Transform val2 in componentsInChildren2) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)((Component)character).transform && !_scaledObjects.Contains(val2) && (Object)(object)((Component)val2).GetComponent() == (Object)null && (Object)(object)((Component)val2).GetComponent() == (Object)null && (Object)(object)((Component)val2).GetComponent() == (Object)null) { _originalScales.Add(val2.localScale); _scaledObjects.Add(val2); val2.localScale *= scaleMultiplier; P.Logger.LogInfo((object)("[GiantPlayerEffect] Scaled accessory: " + ((Object)val2).name)); } } P.Logger.LogInfo((object)$"[GiantPlayerEffect] Scaled {_scaledObjects.Count} visual objects to {scaleMultiplier}x size"); } } [Effect(new string[] { "player_gravity_floaty", "player_gravity_heavy", "player_gravity_zero", "player_gravity_superjump", "player_gravity_reverse", "player_gravity_moonjump" }, 0f, true)] public class PlayerGravity : Effect { [CompilerGenerated] private CrowdControlMod P; public static bool IsActive = false; public static float JumpMultiplier = 1f; public static string CurrentEffect = ""; private static bool _active = false; private static float _jumpImpulse = 1f; private static float _jumpGravity = 1f; private static float _maxGravity = 1f; private static float _gravityCurveSpeed = 1f; public PlayerGravity(CrowdControlMod mod, NetworkClient client) { P = mod; base..ctor(P, client); } public override EffectResponse Start(EffectRequest request) { if (_active) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } string[] array = request.code.Split('_'); P.Logger.LogInfo((object)("[PlayerGravity] Request code: '" + request.code + "', Parts: [" + string.Join(", ", array) + "]")); if (array.Length < 3) { P.Logger.LogWarning((object)$"[PlayerGravity] Invalid parts length: {array.Length}, expected 3+"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } string text = array[2].ToLowerInvariant(); P.Logger.LogInfo((object)("[PlayerGravity] Parsed effect: '" + text + "'")); CharacterMovement component = ((Component)localCharacter).GetComponent(); if ((Object)(object)component == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "CharacterMovement component not found"); } _active = true; IsActive = true; CurrentEffect = text; JumpMultiplier = text switch { "superjump" => 3f, "moonjump" => 5f, "floaty" => 1.5f, "heavy" => 0.5f, "zero" => 1.2f, "reverse" => 2f, _ => 1f, }; P.Logger.LogInfo((object)$"[PlayerGravity] Set static fields - IsActive: {IsActive}, CurrentEffect: {CurrentEffect}, JumpMultiplier: {JumpMultiplier}x"); _jumpImpulse = component.jumpImpulse; _jumpGravity = component.jumpGravity; _maxGravity = component.maxGravity; _gravityCurveSpeed = component.gravityCurveSpeed; switch (text) { case "floaty": component.jumpImpulse = _jumpImpulse; component.jumpGravity = 0f; component.maxGravity = 0f; component.gravityCurveSpeed = 0.01f; break; case "heavy": component.jumpImpulse = 25f; component.jumpGravity = 15f; component.maxGravity = -50f; component.gravityCurveSpeed = 1f; break; case "zero": component.jumpImpulse = _jumpImpulse; component.jumpGravity = 2f; component.maxGravity = -5f; component.gravityCurveSpeed = 0.1f; break; case "reverse": component.jumpImpulse = _jumpImpulse; component.jumpGravity = -2f; component.maxGravity = 50f; component.gravityCurveSpeed = 1f; break; case "superjump": component.jumpGravity = 100f; component.maxGravity = -1000f; break; case "moonjump": component.jumpGravity = 150f; component.maxGravity = -200f; break; } ResetGravityAfterDelay(component, request); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private async Task ResetGravityAfterDelay(CharacterMovement movement, EffectRequest request) { await Task.Delay(checked((int)request.duration.Value)); movement.jumpImpulse = _jumpImpulse; movement.jumpGravity = _jumpGravity; movement.maxGravity = _maxGravity; movement.gravityCurveSpeed = _gravityCurveSpeed; _active = false; IsActive = false; JumpMultiplier = 1f; CurrentEffect = ""; P.Logger.LogInfo((object)"[PlayerGravity] Cleared static fields"); } } [Effect(new string[] { "player_status_poison", "player_status_cold", "player_status_curse", "player_status_drowsy", "player_status_hot", "player_status_hunger", "player_status_injury", "player_status_die", "player_status_crab", "player_status_fast", "player_status_infinite", "player_status_glow", "player_status_exhausted" }, 0f, true)] public class PlayerStatus : Effect { private static readonly Dictionary StatusMap = new Dictionary { { "poison", (STATUSTYPE)3 }, { "cold", (STATUSTYPE)2 }, { "curse", (STATUSTYPE)5 }, { "drowsy", (STATUSTYPE)6 }, { "hot", (STATUSTYPE)8 }, { "die", (STATUSTYPE)0 }, { "hunger", (STATUSTYPE)1 }, { "injury", (STATUSTYPE)0 }, { "crab", (STATUSTYPE)4 } }; private static readonly Dictionary AfflictionMap = new Dictionary { { "infinite", (AfflictionType)1 }, { "fast", (AfflictionType)2 }, { "glow", (AfflictionType)4 }, { "exhausted", (AfflictionType)3 }, { "chaos", (AfflictionType)6 }, { "adjust", (AfflictionType)7 }, { "adjusttick", (AfflictionType)12 }, { "cleareffects", (AfflictionType)8 } }; public PlayerStatus(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } string[] array = request.code.Split('_'); if (array.Length < 3) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } string text = array[2].ToLowerInvariant(); if (StatusMap.TryGetValue(text, out var value)) { CharacterAfflictions afflictions = localCharacter.refs.afflictions; if ((Object)(object)afflictions == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } float currentStatus = afflictions.GetCurrentStatus(value); float statusCap = afflictions.GetStatusCap(value); if (currentStatus >= statusCap - 0.0001f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } float num = ((text == "die") ? 1f : 0.2f); if (currentStatus + num > statusCap) { num = statusCap - currentStatus; if (num <= 0f) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16645); } } if (!TryAddStatus(localCharacter.refs.afflictions, value, num)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } localCharacter.refs.afflictions.PushAfflictions(PhotonNetwork.LocalPlayer); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } if (AfflictionMap.TryGetValue(text, out var value2)) { Affliction val = Affliction.CreateBlankAffliction(value2); val.totalTime = 15f; val.character = localCharacter; localCharacter.refs.afflictions.afflictionList.Add(val); localCharacter.refs.afflictions.PushAfflictions(PhotonNetwork.LocalPlayer); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } private static bool TryAddStatus(CharacterAfflictions afflictions, STATUSTYPE statusType, float amount) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)afflictions == (Object)null) { return false; } MethodInfo[] methods = ((object)afflictions).GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (string.Equals(methodInfo.Name, "AddStatus")) { ParameterInfo[] parameters = methodInfo.GetParameters(); try { return parameters.Length switch { 5 => (bool)methodInfo.Invoke(afflictions, new object[5] { statusType, amount, false, true, true }), 4 => (bool)methodInfo.Invoke(afflictions, new object[4] { statusType, amount, false, true }), 3 => (bool)methodInfo.Invoke(afflictions, new object[3] { statusType, amount, false }), _ => false, }; } catch { return false; } } } return false; } } [Effect(new string[] { "remove_balloon" }, 0f, false)] public class RemoveBalloonEffect : Effect { public RemoveBalloonEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } CharacterBalloons component = ((Component)localCharacter).GetComponent(); if ((Object)(object)component == (Object)null && ((object)localCharacter).GetType().GetField("balloons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(localCharacter) == null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Character balloons component not found"); } try { FieldInfo fieldInfo = ((object)component)?.GetType().GetField("tiedBalloons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo != null) { if (fieldInfo.GetValue(component) is List list && list.Count > 0) { list[0].Pop(); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player doesn't have any balloons to remove"); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "TiedBalloons field not found"); } catch (Exception ex) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to remove balloon: " + ex.Message); } } } [Effect(new string[] { "reverse_controls" }, 20f, true)] public class ReverseControlsEffect : Effect { internal static bool IsActive { get; private set; } public ReverseControlsEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } IsActive = true; GameNotifications.Show("Controls inverted!"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } public override EffectResponse? Pause(EffectRequest request) { IsActive = false; return EffectResponse.Paused(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } public override EffectResponse? Resume(EffectRequest request) { IsActive = true; return EffectResponse.Resumed(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } public override EffectResponse? Stop(EffectRequest request) { IsActive = false; GameNotifications.Show("Controls restored."); return EffectResponse.Finished(((SimpleJSONMessage)request).ID, (StandardErrors)16384); } } [Effect("player_revive", 0f, true)] public class PlayerRevive : Effect { [CompilerGenerated] private CrowdControlMod P; public PlayerRevive(CrowdControlMod mod, NetworkClient client) { P = mod; base..ctor(P, client); } public override EffectResponse Start(EffectRequest request) { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_013f: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_010f: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (localCharacter.data.fullyPassedOut || localCharacter.data.dead) { if (localCharacter.data.dead) { PlayerGhost ghost = localCharacter.Ghost; Vector3 val; if ((Object)(object)ghost != (Object)null) { if ((Object)(object)ghost.m_target != (Object)null) { val = ghost.m_target.Head + Vector3.up * 4f; } else if ((Object)(object)((Component)ghost).transform != (Object)null) { Vector3 position = ((Component)ghost).transform.position; RaycastHit val2 = default(RaycastHit); val = ((!Physics.Raycast(position, Vector3.down, ref val2, 100f)) ? (new Vector3(position.x, position.y - 10f, position.z) + Vector3.up * 4f) : (((RaycastHit)(ref val2)).point + Vector3.up * 4f)); } else { val = localCharacter.Head + Vector3.up * 4f; } } else { val = localCharacter.Head + Vector3.up * 4f; } localCharacter.refs.afflictions.ClearAllStatus(false); ((MonoBehaviourPun)localCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val, false, -1 }); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } if (localCharacter.data.fullyPassedOut) { Vector3 val = localCharacter.Head + Vector3.up * 4f; P.Logger.LogInfo((object)$"[RevivePlayer] Reviving from fullyPassedOut at position: {val}"); localCharacter.refs.afflictions.ClearAllStatus(false); ((MonoBehaviourPun)localCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val, false, -1 }); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is not dead"); } } [Effect("revive_random_player", 0f, true)] public class ReviveRandomPlayer : Effect { [CompilerGenerated] private CrowdControlMod P; public ReviveRandomPlayer(CrowdControlMod mod, NetworkClient client) { P = mod; base..ctor(P, client); } public override EffectResponse Start(EffectRequest request) { //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) P.Logger.LogInfo((object)"[ReviveRandomPlayer] Starting revive random player effect"); List list = Character.AllCharacters.Where((Character c) => (Object)(object)c != (Object)null && (c.data.dead || c.data.fullyPassedOut)).ToList(); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Found {list.Count} revivable players"); if (list.Count == 0) { P.Logger.LogWarning((object)"[ReviveRandomPlayer] No revivable players found"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No revivable players found"); } Character val = list[Random.Range(0, list.Count)]; PhotonView photonView = ((MonoBehaviourPun)val).photonView; if ((Object)(object)photonView == (Object)null) { P.Logger.LogError((object)("[ReviveRandomPlayer] Chosen player " + ((Object)val).name + " has no PhotonView")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Chosen player has no PhotonView"); } bool dead = val.data.dead; bool fullyPassedOut = val.data.fullyPassedOut; bool passedOut = val.data.passedOut; bool flag = (Object)(object)val.Ghost != (Object)null; int viewID = photonView.ViewID; Player owner = photonView.Owner; int num = ((owner != null) ? owner.ActorNumber : (-1)); bool isMine = photonView.IsMine; P.Logger.LogInfo((object)("[ReviveRandomPlayer] Chosen player: " + ((Object)val).name)); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - dead: {dead}"); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - fullyPassedOut: {fullyPassedOut}"); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - passedOut: {passedOut}"); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - isGhost: {flag}"); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - PhotonView ID: {viewID}"); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - Owner ID: {num}"); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] - IsMine: {isMine}"); if (val.data.dead) { P.Logger.LogInfo((object)"[ReviveRandomPlayer] Attempting to revive from dead state"); try { val.refs.afflictions.ClearAllStatus(false); P.Logger.LogInfo((object)"[ReviveRandomPlayer] Cleared all status effects"); PlayerGhost ghost = val.Ghost; Vector3 val2; if ((Object)(object)ghost != (Object)null) { if ((Object)(object)ghost.m_target != (Object)null) { val2 = ghost.m_target.Head + Vector3.up * 4f; P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Using target player's head + 4 up for revive: {val2}"); } else if ((Object)(object)((Component)ghost).transform != (Object)null) { Vector3 position = ((Component)ghost).transform.position; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(position, Vector3.down, ref val3, 100f)) { val2 = ((RaycastHit)(ref val3)).point + Vector3.up * 4f; P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Using ground level + 4 up below ghost: {val2} (ghost was at {position}, ground at {((RaycastHit)(ref val3)).point})"); } else { val2 = new Vector3(position.x, position.y - 10f, position.z) + Vector3.up * 4f; P.Logger.LogInfo((object)$"[ReviveRandomPlayer] No ground found, using ghost position lowered + 4 up: {val2}"); } } else { val2 = val.Head + Vector3.up * 4f; P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Ghost transform is null, using head position + 4 up: {val2}"); } } else { val2 = val.Head + Vector3.up * 4f; P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Ghost is null, using head position + 4 up: {val2}"); } photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val2, false, -1 }); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Successfully sent RPCA_ReviveAtPosition RPC to player {((Object)val).name} at position {val2}"); } catch (Exception ex) { P.Logger.LogError((object)("[ReviveRandomPlayer] RPC failed: " + ex.Message)); P.Logger.LogError((object)("[ReviveRandomPlayer] Stack trace: " + ex.StackTrace)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "RPC failed: " + ex.Message); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } if (val.data.fullyPassedOut) { P.Logger.LogInfo((object)"[ReviveRandomPlayer] Attempting to revive from fullyPassedOut state"); try { val.refs.afflictions.ClearAllStatus(false); P.Logger.LogInfo((object)"[ReviveRandomPlayer] Cleared all status effects"); Vector3 val4 = val.Head + Vector3.up * 4f; P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Using head position + 4 up for revive: {val4}"); photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val4, false, -1 }); P.Logger.LogInfo((object)$"[ReviveRandomPlayer] Successfully sent RPCA_ReviveAtPosition RPC to player {((Object)val).name} at position {val4}"); } catch (Exception ex2) { P.Logger.LogError((object)("[ReviveRandomPlayer] RPC failed: " + ex2.Message)); P.Logger.LogError((object)("[ReviveRandomPlayer] Stack trace: " + ex2.StackTrace)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "RPC failed: " + ex2.Message); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } P.Logger.LogWarning((object)("[ReviveRandomPlayer] Player " + ((Object)val).name + " is not dead or passed out")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Player is not dead"); } } [Effect(new string[] { "spawn_vine_plane", "spawn_shaky_rock", "spawn_scorpion" }, 0f, true)] public class SpawnHazardEffect : Effect { private static readonly Dictionary HazardPrefabs = new Dictionary { { "spawn_vine_plane", "VinePlane" }, { "spawn_shaky_rock", "ShakyRock" }, { "spawn_scorpion", "Scorpion" } }; private static readonly Dictionary CachedPrefabs = new Dictionary(); public SpawnHazardEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (!HazardPrefabs.TryGetValue(request.code, out string value)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } if (PhotonNetwork.IsMasterClient) { return SpawnHazardDirectly(value, localCharacter, request); } return SpawnHazardViaHost(value, localCharacter, request); } private EffectResponse SpawnHazardDirectly(string prefabPath, Character character, EffectRequest request) { //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_0045: 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) Quaternion rotation; Vector3 spawnPosition = GetSpawnPosition(character, out rotation); try { if (!TryResolveHazardPrefab(prefabPath, out GameObject prefab)) { CrowdControlMod.Instance.Logger.LogWarning((object)("[SpawnHazardEffect] Could not resolve prefab for " + prefabPath)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } GameObject val = TryInstantiateHazard(prefab, spawnPosition, rotation); if ((Object)(object)val == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } ConfigureHazard(val, prefabPath); GameNotifications.Show("Spawned hazard: " + prefabPath); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("[SpawnHazardEffect] Failed to spawn " + prefabPath + ": " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } } private EffectResponse SpawnHazardViaHost(string prefabPath, Character character, EffectRequest request) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) string prefabPath2 = prefabPath; Quaternion rotation; Vector3 spawnPosition = GetSpawnPosition(character, out rotation); Dictionary data = new Dictionary { ["prefabPath"] = prefabPath2, ["spawnPosition"] = new Dictionary { ["x"] = spawnPosition.x, ["y"] = spawnPosition.y, ["z"] = spawnPosition.z }, ["rotation"] = new Dictionary { ["x"] = ((Quaternion)(ref rotation)).eulerAngles.x, ["y"] = ((Quaternion)(ref rotation)).eulerAngles.y, ["z"] = ((Quaternion)(ref rotation)).eulerAngles.z } }; if (!CustomEventSystem.Instance.TriggerEvent("spawn_hazard", data, delegate(EventResponse response) { if (!response.Success) { CrowdControlMod.Instance.Logger.LogWarning((object)("[SpawnHazardEffect] Host failed to spawn " + prefabPath2 + ": " + response.Message)); } })) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } internal static bool TryResolveHazardPrefab(string prefabPath, out GameObject prefab) { if (CachedPrefabs.TryGetValue(prefabPath, out prefab)) { return (Object)(object)prefab != (Object)null; } prefab = Resources.Load(prefabPath); if ((Object)(object)prefab != (Object)null) { CachedPrefabs[prefabPath] = prefab; return true; } try { GameObject[] array = Resources.FindObjectsOfTypeAll(); foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null) && (Object)(object)val.GetComponent(prefabPath) != (Object)null) { prefab = val; CachedPrefabs[prefabPath] = prefab; return true; } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("[SpawnHazardEffect] Prefab search failed for " + prefabPath + ": " + ex.Message)); } prefab = null; CachedPrefabs[prefabPath] = null; return false; } internal static GameObject TryInstantiateHazard(GameObject prefab, Vector3 position, Quaternion rotation) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_002d: 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) GameObject val = null; bool flag = false; try { flag = (Object)(object)prefab.GetComponent("Item") != (Object)null; } catch { flag = false; } if (PhotonNetwork.InRoom) { if (flag) { try { val = PhotonNetwork.InstantiateItemRoom(((Object)prefab).name, position, rotation); } catch { } } if ((Object)(object)val == (Object)null) { try { val = PhotonNetwork.InstantiateRoomObject(((Object)prefab).name, position, rotation, (byte)0, (object[])null); } catch { } } if ((Object)(object)val == (Object)null) { try { val = PhotonNetwork.Instantiate(((Object)prefab).name, position, rotation, (byte)0, (object[])null); } catch { return null; } } return val; } try { val = PhotonNetwork.InstantiateRoomObject(((Object)prefab).name, position, rotation, (byte)0, (object[])null); } catch { } if ((Object)(object)val == (Object)null) { try { val = PhotonNetwork.Instantiate(((Object)prefab).name, position, rotation, (byte)0, (object[])null); } catch { } } if ((Object)(object)val == (Object)null) { try { val = Object.Instantiate(prefab, position, rotation); } catch { return null; } } return val; } private static Vector3 GetSpawnPosition(Character character, out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002a: 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_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) //IL_0037: 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_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) //IL_0093: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0088: 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) Vector3 val = character.Center + ((Component)character).transform.forward * 2f + Vector3.up; rotation = Quaternion.identity; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val + Vector3.up * 2f, Vector3.down, ref val2, 10f, -1, (QueryTriggerInteraction)1)) { rotation = Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val2)).normal); return ((RaycastHit)(ref val2)).point + Vector3.up * 0.1f; } return val; } private static void ConfigureHazard(GameObject obj, string prefabPath) { switch (prefabPath) { case "VinePlane": { Component component2 = obj.GetComponent("VinePlane"); if ((Object)(object)component2 == (Object)null) { break; } FieldInfo field5 = ((object)component2).GetType().GetField("vineType"); if (field5 != null) { try { object value2 = Enum.Parse(field5.FieldType, "Normal"); field5.SetValue(component2, value2); } catch { } } ((object)component2).GetType().GetField("liveEdit")?.SetValue(component2, false); ((object)component2).GetType().GetMethod("Blast")?.Invoke(component2, null); break; } case "ShakyRock": { PhotonView component3 = obj.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.RPC("ShakeRock", (RpcTarget)0, Array.Empty()); break; } Component component4 = obj.GetComponent("ShakyRock"); (((object)component4)?.GetType().GetMethod("ShakeRock", BindingFlags.Instance | BindingFlags.NonPublic))?.Invoke(component4, null); break; } case "Scorpion": { Component component = obj.GetComponent("Scorpion"); if ((Object)(object)component == (Object)null) { break; } MethodInfo method = ((object)component).GetType().GetMethod("SetForcedTarget"); if (method != null && (Object)(object)Character.localCharacter != (Object)null) { method.Invoke(component, new object[1] { Character.localCharacter }); } FieldInfo field = ((object)component).GetType().GetField("sleeping"); if (field != null) { field.SetValue(component, false); } FieldInfo field2 = ((object)component).GetType().GetField("forceNoMovement"); if (field2 != null) { field2.SetValue(component, false); } FieldInfo field3 = ((object)component).GetType().GetField("aggroDistance"); if (field3 != null) { field3.SetValue(component, 25f); } ((object)component).GetType().GetMethod("UpdateSleeping")?.Invoke(component, null); FieldInfo field4 = ((object)component).GetType().GetField("_mobState", BindingFlags.Instance | BindingFlags.NonPublic); Type nestedType = ((object)component).GetType().GetNestedType("MobState", BindingFlags.NonPublic); if (!(field4 != null) || !(nestedType != null)) { break; } try { object value = Enum.Parse(nestedType, "Walking"); field4.SetValue(component, value); break; } catch { break; } } } } } [Effect(new string[] { "spawn_item_airplanefood", "spawn_item_antirope", "spawn_item_antidote", "spawn_item_appleberrygreen", "spawn_item_appleberryred", "spawn_item_appleberryyellow", "spawn_item_backpack", "spawn_item_bandage", "spawn_item_beehive", "spawn_item_berrynanablue", "spawn_item_berrynanabrown", "spawn_item_berrynanapink", "spawn_item_berrynanayellow", "spawn_item_bingbong", "spawn_item_binoculars", "spawn_item_bugle", "spawn_item_book", "spawn_item_buglemagic", "spawn_item_buglescoutmaster", "spawn_item_climbingspike", "spawn_item_clusterberryblack", "spawn_item_clusterberryred", "spawn_item_clusterberryyellow", "spawn_item_clusterberryunused", "spawn_item_chaincannon", "spawn_item_compass", "spawn_item_cureall", "spawn_item_cursedskull", "spawn_item_egg", "spawn_item_energydrink", "spawn_item_firewood", "spawn_item_firstaidkit", "spawn_item_flagseagull", "spawn_item_flagturtle", "spawn_item_flare", "spawn_item_granolabar", "spawn_item_guidebook", "spawn_item_heatpack", "spawn_item_coconut", "spawn_item_coconuthalf", "spawn_item_honeycomb", "spawn_item_kingberrygreen", "spawn_item_kingberrypurple", "spawn_item_kingberryyellow", "spawn_item_lantern", "spawn_item_lanternfaerie", "spawn_item_lollipop", "spawn_item_magicbean", "spawn_item_marshmellow", "spawn_item_medicinalroot", "spawn_item_mushroomchubby", "spawn_item_mushroomcluster", "spawn_item_mushroomclusterpoison", "spawn_item_mushroomglow", "spawn_item_mushroomlace", "spawn_item_mushroomlacepoison", "spawn_item_mushroomnormie", "spawn_item_mushroomnormiepoison", "spawn_item_napberry", "spawn_item_nestegg", "spawn_item_pandorasbox", "spawn_item_passport", "spawn_item_pepperberry", "spawn_item_piratecompass", "spawn_item_stove", "spawn_item_ropecannon", "spawn_item_ropecannonanti", "spawn_item_rope", "spawn_item_scoutcookies", "spawn_item_scouteffigy", "spawn_item_shelfshroom", "spawn_item_shellbig", "spawn_item_stone", "spawn_item_toy", "spawn_item_toyscout", "spawn_item_trailmix", "spawn_item_warpcompass", "spawn_item_winterberryorange", "spawn_item_winterberryyellow", "spawn_item_bounce", "spawn_item_healingdart", "spawn_item_guidepage", "spawn_item_guidepage0", "spawn_item_guidepage1", "spawn_item_guidepage2", "spawn_item_guidepage3", "spawn_item_guidepage4", "spawn_item_guidepage5", "spawn_item_guidepage6", "spawn_item_guidepage7", "spawn_item_guidepage8", "spawn_item_guidepagescroll", "spawn_item_healingpuff", "spawn_item_peelblue", "spawn_item_peelbrown", "spawn_item_peelpink", "spawn_item_peelyellow", "spawn_item_bugfix", "spawn_item_balloon", "spawn_item_balloonbunch", "spawn_item_scoutcannon", "spawn_item_parasol", "spawn_item_sunscreen", "spawn_item_aloeveral", "spawn_item_dynamite", "spawn_item_frisbee", "spawn_beeswarm", "spawn_item_checkpointflag", "spawn_item_rescuehook" }, 0f, true)] public class SpawnItemEffect : Effect { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject obj; public HashSet existing; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) 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; Scoutmaster[] array = Object.FindObjectsOfType(); Vector3 position = obj.transform.position; Scoutmaster[] array2 = array; Vector3 val2 = default(Vector3); foreach (Scoutmaster val in array2) { if (!existing.Contains(val)) { ((Vector3)(ref val2))..ctor(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f)); ((Component)val).transform.position = position + val2; CrowdControlMod.Instance.Logger.LogInfo((object)$"[TOOT TOOT] Teleported NEW Scoutmaster to {((Component)val).transform.position}"); Object.Destroy((Object)(object)obj); } } 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 Dictionary ItemMap = new Dictionary { { "airplanefood", "Airplane Food" }, { "antirope", "Anti-Rope Spool" }, { "antidote", "Antidote" }, { "appleberrygreen", "Apple Berry Green" }, { "appleberryred", "Apple Berry Red" }, { "appleberryyellow", "Apple Berry Yellow" }, { "backpack", "Backpack" }, { "bandage", "Bandages" }, { "beehive", "Beehive" }, { "berrynanablue", "Berrynana Blue" }, { "berrynanabrown", "Berrynana Brown" }, { "berrynanapink", "Berrynana Pink" }, { "berrynanayellow", "Berrynana Yellow" }, { "bingbong", "BingBong" }, { "toy", "BingBong" }, { "binoculars", "Binoculars" }, { "bugle", "Bugle" }, { "buglemagic", "Bugle_Magic" }, { "buglescoutmaster", "Bugle_Scoutmaster Variant" }, { "climbingspike", "ClimbingSpike" }, { "clusterberryblack", "Clusterberry Black" }, { "clusterberryred", "Clusterberry Red" }, { "clusterberryyellow", "Clusterberry Yellow" }, { "clusterberryunused", "Clusterberry_UNUSED" }, { "chaincannon", "ChainShooter" }, { "compass", "Compass" }, { "cureall", "Cure-All" }, { "cursedskull", "Cursed Skull" }, { "egg", "Egg" }, { "energydrink", "Energy Drink" }, { "firewood", "FireWood" }, { "firstaidkit", "FirstAidKit" }, { "flagseagull", "Flag_Plantable_Seagull" }, { "flagturtle", "Flag_Plantable_Turtle" }, { "flare", "Flare" }, { "granolabar", "Granola Bar" }, { "book", "Guidebook" }, { "heatpack", "Heat Pack" }, { "coconut", "Item_Coconut" }, { "coconuthalf", "Item_Coconut_half" }, { "honeycomb", "Item_Honeycomb" }, { "kingberrygreen", "Kingberry Green" }, { "kingberrypurple", "Kingberry Purple" }, { "kingberryyellow", "Kingberry Yellow" }, { "lantern", "Lantern" }, { "lanternfaerie", "Lantern_Faerie" }, { "lollipop", "Lollipop" }, { "magicbean", "MagicBean" }, { "marshmellow", "Marshmallow" }, { "medicinalroot", "MedicinalRoot" }, { "mushroomchubby", "Mushroom Chubby" }, { "mushroomcluster", "Mushroom Cluster" }, { "mushroomclusterpoison", "Mushroom Cluster Poison" }, { "mushroomglow", "Mushroom Glow" }, { "mushroomlace", "Mushroom Lace" }, { "mushroomlacepoison", "Mushroom Lace Poison" }, { "mushroomnormie", "Mushroom Normie" }, { "mushroomnormiepoison", "Mushroom Normie Poison" }, { "napberry", "Napberry" }, { "nestegg", "NestEgg" }, { "pandorasbox", "PandorasBox" }, { "passport", "Passport" }, { "pepperberry", "Pepper Berry" }, { "piratecompass", "Pirate Compass" }, { "stove", "PortableStovetopItem" }, { "ropecannon", "RopeShooter" }, { "ropecannonanti", "RopeShooterAnti" }, { "rope", "RopeSpool" }, { "scoutcookies", "ScoutCookies" }, { "scouteffigy", "ScoutEffigy" }, { "shelfshroom", "ShelfShroom" }, { "shellbig", "Shell Big" }, { "stone", "Stone" }, { "toyscout", "Toy" }, { "trailmix", "TrailMix" }, { "warpcompass", "Warp Compass" }, { "winterberryorange", "Winterberry Orange" }, { "winterberryyellow", "Winterberry Yellow" }, { "bounce", "BounceShroom" }, { "healingdart", "HealingDart Variant" }, { "guidepage", "GuidebookPage" }, { "guidepage0", "GuidebookPage_0_Intro" }, { "guidepage1", "GuidebookPage_1_Mushrooms" }, { "guidepage2", "GuidebookPage_2_Campfire" }, { "guidepage3", "GuidebookPage_3_Revival" }, { "guidepage4", "GuidebookPage_4_BodyHeat Variant" }, { "guidepage5", "GuidebookPage_5_Sleepy Variant" }, { "guidepage6", "GuidebookPage_6_Awake Variant" }, { "guidepage7", "GuidebookPage_7_Crashout Variant" }, { "guidepage8", "GuidebookPage_8_FirstTeams" }, { "guidepagescroll", "GuidebookPageScroll Variant" }, { "healingpuff", "HealingPuffShroom" }, { "peelblue", "Berrynana Peel Blue Variant" }, { "peelbrown", "Berrynana Peel Brown Variant" }, { "peelpink", "Berrynana Peel Pink Variant" }, { "peelyellow", "Berrynana Peel Yellow" }, { "bugfix", "Bugfix" }, { "balloon", "Balloon" }, { "balloonbunch", "BalloonBunch" }, { "scoutcannon", "ScoutCannonItem" }, { "beeswarm", "BeeSwarm" }, { "parasol", "Parasol" }, { "sunscreen", "Sunscreen" }, { "aloeveral", "AloeVera" }, { "dynamite", "Dynamite" }, { "frisbee", "Frisbee" }, { "checkpointflag", "Flag_Plantable_Checkpoint" }, { "rescuehook", "RescueHook" } }; public SpawnItemEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } [IteratorStateMachine(typeof(d__1))] private static IEnumerator HandleNewScoutmasters(HashSet existing, GameObject obj) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { existing = existing, obj = obj }; } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter != (Object)(object)Character.localCharacter || !((Behaviour)localCharacter).isActiveAndEnabled || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } string[] array = request.code.Split('_'); if (array.Length < 2) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } string text = array[^1].ToLowerInvariant(); if (!ItemMap.TryGetValue(text, out string value)) { CrowdControlMod.Instance.Logger.LogWarning((object)("[SpawnItemEffect] No mapping for item '" + text + "'")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } if (PhotonNetwork.IsMasterClient) { return SpawnItemDirectly(value, localCharacter, request); } return SpawnItemViaHost(value, localCharacter, request); } private EffectResponse SpawnItemDirectly(string prefabPath, Character character, EffectRequest request) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) Vector3 groundedSpawnPosition = SpawnedItemProtection.GetGroundedSpawnPosition(character); bool flag = prefabPath.Contains("BeeSwarm"); GameObject val = null; try { if (flag) { if (prefabPath.Contains("BeeSwarm")) { _ = Quaternion.identity; Quaternion val2 = Quaternion.LookRotation(Vector3.forward); val = PhotonNetwork.InstantiateRoomObject("BeeSwarm", groundedSpawnPosition, val2, (byte)0, (object[])null); BeeSwarm component = val.GetComponent(); try { typeof(BeeSwarm).GetMethod("GetAngry", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(component, new object[1] { 15f }); } catch (Exception) { } } } else { val = PhotonNetwork.InstantiateItemRoom(prefabPath, groundedSpawnPosition, Quaternion.identity); } } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnItemEffect] Failed to instantiate '" + prefabPath + "': " + ex2.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } if ((Object)(object)val == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnItemEffect] Instantiation returned null for '" + prefabPath + "'")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } SpawnedItemProtection.Apply(val); CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnItemEffect] Spawned '{prefabPath}' at {groundedSpawnPosition}"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private EffectResponse SpawnItemViaHost(string prefabPath, Character character, EffectRequest request) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) string prefabPath2 = prefabPath; Vector3 groundedSpawnPosition = SpawnedItemProtection.GetGroundedSpawnPosition(character); Dictionary dictionary = new Dictionary { ["prefabPath"] = prefabPath2, ["spawnPosition"] = new Dictionary { ["x"] = groundedSpawnPosition.x, ["y"] = groundedSpawnPosition.y, ["z"] = groundedSpawnPosition.z }, ["targetPlayerId"] = PhotonNetwork.LocalPlayer.ActorNumber, ["requestId"] = ((SimpleJSONMessage)request).ID.ToString() }; CrowdControlMod.Instance.Logger.LogInfo((object)("[SpawnItemEffect] Sending event data to host: " + JsonConvert.SerializeObject((object)dictionary))); if (CustomEventSystem.Instance.TriggerEvent("spawn_item", dictionary, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)("[SpawnItemEffect] Host spawned '" + prefabPath2 + "' successfully")); } else { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnItemEffect] Host failed to spawn '" + prefabPath2 + "': " + response.Message)); } })) { CrowdControlMod.Instance.Logger.LogInfo((object)("[SpawnItemEffect] Requested host to spawn '" + prefabPath2 + "'")); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } CrowdControlMod.Instance.Logger.LogError((object)"[SpawnItemEffect] Failed to send spawn request to host"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } } [Effect(new string[] { "spawn_food" }, 0f, true)] public class SpawnFoodItemEffect : Effect { private static readonly Dictionary ItemMap = new Dictionary { { "airplanefood", "Airplane Food" }, { "appleberrygreen", "Apple Berry Green" }, { "appleberryred", "Apple Berry Red" }, { "appleberryyellow", "Apple Berry Yellow" }, { "berrynanablue", "Berrynana Blue" }, { "berrynanabrown", "Berrynana Brown" }, { "berrynanapink", "Berrynana Pink" }, { "berrynanayellow", "Berrynana Yellow" }, { "clusterberryblack", "Clusterberry Black" }, { "clusterberryred", "Clusterberry Red" }, { "clusterberryyellow", "Clusterberry Yellow" }, { "egg", "Egg" }, { "energydrink", "Energy Drink" }, { "granolabar", "Granola Bar" }, { "coconut", "Item_Coconut" }, { "coconuthalf", "Item_Coconut_half" }, { "honeycomb", "Item_Honeycomb" }, { "kingberrygreen", "Kingberry Green" }, { "kingberrypurple", "Kingberry Purple" }, { "kingberryyellow", "Kingberry Yellow" }, { "lollipop", "Lollipop" }, { "marshmellow", "Marshmallow" }, { "napberry", "Napberry" }, { "nestegg", "NestEgg" }, { "pepperberry", "Pepper Berry" }, { "scoutcookies", "ScoutCookies" }, { "shellbig", "Shell Big" }, { "trailmix", "TrailMix" }, { "winterberryorange", "Winterberry Orange" }, { "winterberryyellow", "Winterberry Yellow" }, { "EggTurkey", "EggTurkey" } }; public SpawnFoodItemEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } int index = new Random().Next(ItemMap.Count); string prefabPath = new List(ItemMap.Values)[index]; if (PhotonNetwork.IsMasterClient) { return SpawnItemDirectly(prefabPath, localCharacter, request); } return SpawnItemViaHost(prefabPath, localCharacter, request); } private EffectResponse SpawnItemDirectly(string prefabPath, Character character, EffectRequest request) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) Vector3 groundedSpawnPosition = SpawnedItemProtection.GetGroundedSpawnPosition(character); GameObject val; try { val = PhotonNetwork.InstantiateItemRoom(prefabPath, groundedSpawnPosition, Quaternion.identity); } catch (Exception) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } if ((Object)(object)val == (Object)null) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } SpawnedItemProtection.Apply(val); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private EffectResponse SpawnItemViaHost(string prefabPath, Character character, EffectRequest request) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0055: Unknown result type (might be due to invalid IL or missing references) Vector3 groundedSpawnPosition = SpawnedItemProtection.GetGroundedSpawnPosition(character); Dictionary data = new Dictionary { ["prefabPath"] = prefabPath, ["spawnPosition"] = new Dictionary { ["x"] = groundedSpawnPosition.x, ["y"] = groundedSpawnPosition.y, ["z"] = groundedSpawnPosition.z }, ["targetPlayerId"] = PhotonNetwork.LocalPlayer.ActorNumber, ["requestId"] = ((SimpleJSONMessage)request).ID.ToString() }; if (CustomEventSystem.Instance.TriggerEvent("spawn_item", data, delegate(EventResponse response) { _ = response.Success; })) { return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } } [Effect("spawn_scoutmaster", 0f, true)] public class SpawnScoutmasterEffect : Effect { [CompilerGenerated] private sealed class d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject scoutmasterObj; public Character target; private Component 5__2; private MethodInfo 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = scoutmasterObj.GetComponent("Scoutmaster"); if ((Object)(object)5__2 == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Scoutmaster component not found."); return false; } 5__3 = ((object)5__2).GetType().GetMethod("SetCurrentTarget", BindingFlags.Instance | BindingFlags.NonPublic); if (5__3 == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"SetCurrentTarget method not found."); return false; } goto IL_009d; case 1: <>1__state = -1; 5__3.Invoke(5__2, new object[2] { target, 15f }); <>2__current = (object)new WaitForSeconds(13f); <>1__state = 2; return true; case 2: { <>1__state = -1; goto IL_009d; } IL_009d: CrowdControlMod.Instance.Logger.LogInfo((object)$"Refreshing chase on target Character [{target.characterName} : ViewID {((MonoBehaviourPun)target).photonView.ViewID}]."); 5__3.Invoke(5__2, new object[2] { null, 0f }); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } } 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__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject scoutmasterObj; public Character target; private Component 5__2; private MethodInfo 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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; 5__2 = scoutmasterObj.GetComponent("Scoutmaster"); if ((Object)(object)5__2 == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Scoutmaster component not found."); return false; } 5__3 = ((object)5__2).GetType().GetMethod("SetCurrentTarget", BindingFlags.Instance | BindingFlags.NonPublic); if (5__3 == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"SetCurrentTarget method not found."); return false; } 5__3.Invoke(5__2, new object[2] { null, 0f }); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; case 2: <>1__state = -1; 5__3.Invoke(5__2, new object[2] { target, 15f }); <>2__current = (object)new WaitForSeconds(13f); <>1__state = 3; return true; case 3: <>1__state = -1; 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 const float forcedChaseDuration = 15f; public SpawnScoutmasterEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0021: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Vector3 spawnPosition = GetSpawnPosition(localCharacter); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; if (PhotonNetwork.IsMasterClient) { GameObject scoutmasterObj = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", spawnPosition, Quaternion.identity, (byte)0, (object[])null); CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnScoutmasterEffect] Spawned Scoutmaster at {spawnPosition}, targeting playerId: {actorNumber} ({((Object)localCharacter).name})"); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(StartChasingNextFrame(scoutmasterObj, localCharacter)); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } Dictionary data = new Dictionary { ["spawnPosition"] = new Dictionary { ["x"] = spawnPosition.x, ["y"] = spawnPosition.y, ["z"] = spawnPosition.z }, ["targetPlayerId"] = actorNumber }; if (!CustomEventSystem.Instance.TriggerEvent("spawn_scoutmaster", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"Successfully requested host to spawn scoutmaster"); } else { CrowdControlMod.Instance.Logger.LogError((object)("Host failed to spawn scoutmaster: " + response.Message)); } })) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send scoutmaster spawn request to host"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private EffectResponse SpawnScoutmasterDirectly(EffectRequest request, Vector3 spawnPos) { //IL_0133: 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_0139: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn Scoutmaster."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn Scoutmaster."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Only the Master Client can spawn Scoutmaster"); } Player[] playerList = PhotonNetwork.PlayerList; if (playerList.Length == 0) { CrowdControlMod.Instance.Logger.LogWarning((object)"No players in the room."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No players in the room"); } Player val = playerList[Random.Range(0, playerList.Length)]; Character val2 = null; if (!PlayerHandler.TryGetCharacter(val.ActorNumber, ref val2)) { CrowdControlMod.Instance.Logger.LogWarning((object)("Target player character not found for player " + val.NickName + ".")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Target player character not found for player " + val.NickName); } Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Random.Range(-3f, 3f), 0f, Random.Range(-3f, 3f)); Vector3 val4 = ((Component)val2).transform.position + val3; Quaternion identity = Quaternion.identity; GameObject scoutmasterObj = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", val4, identity, (byte)0, (object[])null); CrowdControlMod.Instance.Logger.LogInfo((object)("Spawned Scoutmaster near player " + val.NickName + ".")); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(StartChasingNextFrame(scoutmasterObj, val2)); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error spawning scoutmaster: " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning scoutmaster: " + ex.Message); } } private EffectResponse SpawnScoutmasterViaHost(EffectRequest request, Vector3 spawnPos) { //IL_0016: 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_0042: Unknown result type (might be due to invalid IL or missing references) try { Dictionary data = new Dictionary { ["spawnPosition"] = new Dictionary { ["x"] = spawnPos.x, ["y"] = spawnPos.y, ["z"] = spawnPos.z } }; if (CustomEventSystem.Instance.TriggerEvent("spawn_scoutmaster", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"Successfully requested host to spawn scoutmaster"); } else { CrowdControlMod.Instance.Logger.LogError((object)("Host failed to spawn scoutmaster: " + response.Message)); } })) { return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send scoutmaster spawn request to host"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error requesting scoutmaster spawn: " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error requesting scoutmaster spawn: " + ex.Message); } } [IteratorStateMachine(typeof(d__5))] private IEnumerator StartChasingNextFrame(GameObject scoutmasterObj, Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { scoutmasterObj = scoutmasterObj, target = target }; } [IteratorStateMachine(typeof(d__6))] private IEnumerator KeepChasing(GameObject scoutmasterObj, Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { scoutmasterObj = scoutmasterObj, target = target }; } private Vector3 GetSpawnPosition(Character character) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)character).transform.position + ((Component)character).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)character).transform).GetComponentsInChildren(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Hip") { result = val.position + val.forward * 1.5f + Vector3.up; } } Transform val2 = ((Component)character).transform.Find("Hip"); if ((Object)(object)val2 != (Object)null) { result = val2.position + val2.forward * 1.5f + Vector3.up; } return result; } } [Effect("spawn_ticks", 0f, true)] public class SpawnTicksEffect : Effect { public SpawnTicksEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0021: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Vector3 spawnPosition = GetSpawnPosition(localCharacter); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; if (PhotonNetwork.IsMasterClient) { try { CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTicksEffect] Attempting to spawn TickTrigger at {spawnPosition}"); CrowdControlMod.Instance.Logger.LogInfo((object)"[SpawnTicksEffect] TickTrigger prefab not found, spawning BugfixOnYou directly to simulate tick effect"); try { GameObject val = PhotonNetwork.InstantiateRoomObject("BugfixOnYou", spawnPosition, Quaternion.identity, (byte)0, (object[])null); if ((Object)(object)val == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)"[SpawnTicksEffect] Failed to spawn BugfixOnYou prefab"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to spawn BugfixOnYou prefab"); } CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTicksEffect] Successfully spawned BugfixOnYou at {spawnPosition}"); try { PhotonView component = val.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)((MonoBehaviourPun)localCharacter).photonView != (Object)null) { component.RPC("AttachBug", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)localCharacter).photonView.ViewID }); CrowdControlMod.Instance.Logger.LogInfo((object)("[SpawnTicksEffect] Called AttachBug RPC to attach bug to player " + ((Object)localCharacter).name)); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"[SpawnTicksEffect] Could not find PhotonView components for RPC call"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("[SpawnTicksEffect] Error calling AttachBug RPC: " + ex.Message)); } } catch (Exception ex2) { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTicksEffect] Error spawning BugfixOnYou: " + ex2.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning BugfixOnYou: " + ex2.Message); } CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTicksEffect] Successfully spawned Tick at {spawnPosition}"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex3) { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTicksEffect] Exception during tick spawning: " + ex3.Message)); CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTicksEffect] Stack trace: " + ex3.StackTrace)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Exception during tick spawning: " + ex3.Message); } } try { CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTicksEffect] Client requesting host to spawn ticks at {spawnPosition}"); Dictionary data = new Dictionary { ["spawnPosition"] = new Dictionary { ["x"] = spawnPosition.x, ["y"] = spawnPosition.y, ["z"] = spawnPosition.z }, ["targetPlayerId"] = actorNumber }; if (CustomEventSystem.Instance.TriggerEvent("spawn_ticks", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"[SpawnTicksEffect] Successfully requested host to spawn ticks"); } else { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTicksEffect] Host failed to spawn ticks: " + response.Message)); } })) { CrowdControlMod.Instance.Logger.LogInfo((object)"[SpawnTicksEffect] Successfully sent ticks spawn request to host"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } CrowdControlMod.Instance.Logger.LogError((object)"[SpawnTicksEffect] Failed to send ticks spawn request to host"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send ticks spawn request to host"); } catch (Exception ex4) { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTicksEffect] Exception during client event triggering: " + ex4.Message)); CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTicksEffect] Stack trace: " + ex4.StackTrace)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Exception during client event triggering: " + ex4.Message); } } private Vector3 GetSpawnPosition(Character character) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)character).transform.position + ((Component)character).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)character).transform).GetComponentsInChildren(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Hip") { result = val.position + val.forward * 1.5f + Vector3.up; } } Transform val2 = ((Component)character).transform.Find("Hip"); if ((Object)(object)val2 != (Object)null) { result = val2.position + val2.forward * 1.5f + Vector3.up; } return result; } } [Effect("spawn_tornado", 0f, true)] public class SpawnTornadoEffect : Effect { [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public GameObject spawnerObj; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)spawnerObj != (Object)null) { Object.Destroy((Object)(object)spawnerObj); CrowdControlMod.Instance.Logger.LogInfo((object)"Cleaned up temporary TornadoSpawner"); } 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__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObject tornadoObj; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 0f; if ((Object)(object)tornadoObj.GetComponent("Tornado") == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Tornado component not found, tornado will persist until game destroys it."); return false; } break; case 1: <>1__state = -1; break; } if (5__2 < 30f) { 5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } CrowdControlMod.Instance.Logger.LogInfo((object)"Tornado duration expired, destroying tornado"); if ((Object)(object)tornadoObj != (Object)null) { if ((Object)(object)tornadoObj.GetComponent() != (Object)null) { PhotonNetwork.Destroy(tornadoObj); } else { Object.Destroy((Object)(object)tornadoObj); } } 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__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SpawnTornadoEffect <>4__this; public GameObject scoutmasterObj; public Character target; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; SpawnTornadoEffect spawnTornadoEffect = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(spawnTornadoEffect.KeepChasing(scoutmasterObj, target)); 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 const float forcedChaseDuration = 15f; public SpawnTornadoEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0021: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Vector3 spawnPosition = GetSpawnPosition(localCharacter); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; if (PhotonNetwork.IsMasterClient) { GameObject val = PhotonNetwork.Instantiate("Tornado", spawnPosition, Quaternion.identity, (byte)0, (object[])null); InitializeTornado(val, localCharacter); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(StartChasingNextFrame(val, localCharacter)); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } Dictionary data = new Dictionary { ["spawnPosition"] = new Dictionary { ["x"] = spawnPosition.x, ["y"] = spawnPosition.y, ["z"] = spawnPosition.z }, ["targetPlayerId"] = actorNumber }; if (!CustomEventSystem.Instance.TriggerEvent("spawn_tornado", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"Successfully requested host to spawn tornado"); } else { CrowdControlMod.Instance.Logger.LogError((object)("Host failed to spawn tornado: " + response.Message)); } })) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send tornado spawn request to host"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private EffectResponse SpawnTornadoDirectly(EffectRequest request, Vector3 spawnPos) { //IL_0133: 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_0139: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn tornado."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn tornado."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Only the Master Client can spawn tornado"); } Player[] playerList = PhotonNetwork.PlayerList; if (playerList.Length == 0) { CrowdControlMod.Instance.Logger.LogWarning((object)"No players in the room."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No players in the room"); } Player val = playerList[Random.Range(0, playerList.Length)]; Character val2 = null; if (!PlayerHandler.TryGetCharacter(val.ActorNumber, ref val2)) { CrowdControlMod.Instance.Logger.LogWarning((object)("Target player character not found for player " + val.NickName + ".")); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Target player character not found for player " + val.NickName); } Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Random.Range(-3f, 3f), 0f, Random.Range(-3f, 3f)); Vector3 val4 = ((Component)val2).transform.position + val3; Quaternion identity = Quaternion.identity; GameObject scoutmasterObj = PhotonNetwork.InstantiateRoomObject("Character_Scoutmaster", val4, identity, (byte)0, (object[])null); CrowdControlMod.Instance.Logger.LogInfo((object)("Spawned Scoutmaster near player " + val.NickName + ".")); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(StartChasingNextFrame(scoutmasterObj, val2)); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error spawning scoutmaster: " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning scoutmaster: " + ex.Message); } } private EffectResponse SpawnScoutmasterViaHost(EffectRequest request, Vector3 spawnPos) { //IL_0016: 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_0042: Unknown result type (might be due to invalid IL or missing references) try { Dictionary data = new Dictionary { ["spawnPosition"] = new Dictionary { ["x"] = spawnPos.x, ["y"] = spawnPos.y, ["z"] = spawnPos.z } }; if (CustomEventSystem.Instance.TriggerEvent("spawn_scoutmaster", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"Successfully requested host to spawn scoutmaster"); } else { CrowdControlMod.Instance.Logger.LogError((object)("Host failed to spawn scoutmaster: " + response.Message)); } })) { return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send scoutmaster spawn request to host"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error requesting scoutmaster spawn: " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error requesting scoutmaster spawn: " + ex.Message); } } [IteratorStateMachine(typeof(d__5))] private IEnumerator StartChasingNextFrame(GameObject scoutmasterObj, Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { <>4__this = this, scoutmasterObj = scoutmasterObj, target = target }; } [IteratorStateMachine(typeof(d__6))] private IEnumerator KeepChasing(GameObject tornadoObj, Character target) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { tornadoObj = tornadoObj }; } private void InitializeTornado(GameObject tornadoObj, Character targetCharacter) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) try { Type type = Type.GetType("TornadoSpawner, Assembly-CSharp"); if (type == null) { type = Type.GetType("TornadoSpawner"); } GameObject val = null; if (type != null) { Object[] array = Object.FindObjectsOfType(type); if (array != null && array.Length != 0) { Object obj = array[0]; Object obj2 = ((obj is Component) ? obj : null); val = ((obj2 != null) ? ((Component)obj2).gameObject : null); if ((Object)(object)val != (Object)null) { CrowdControlMod.Instance.Logger.LogInfo((object)"Found existing TornadoSpawner, using it for initialization"); } } } if ((Object)(object)val == (Object)null) { val = new GameObject("TempTornadoSpawner_" + Guid.NewGuid()); val.transform.position = targetCharacter.Center; PhotonView obj3 = val.AddComponent(); obj3.ViewID = Random.Range(1000, 9999); obj3.Synchronization = (ViewSynchronization)3; GameObject val2 = new GameObject("TornadoPoints"); val2.transform.SetParent(val.transform); val2.transform.localPosition = Vector3.zero; Vector3 localPosition = default(Vector3); for (int i = 0; i < 8; i = checked(i + 1)) { float num = 45f * (float)i * (MathF.PI / 180f); float num2 = 20f; ((Vector3)(ref localPosition))..ctor(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2); GameObject val3 = new GameObject($"Point_{i}"); val3.transform.SetParent(val2.transform); val3.transform.localPosition = localPosition; } ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupTornadoSpawner(val, 35f)); CrowdControlMod.Instance.Logger.LogInfo((object)"Created temporary TornadoSpawner with TornadoPoints"); } PhotonView component = val.GetComponent(); PhotonView component2 = tornadoObj.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component2.RPC("RPCA_InitTornado", (RpcTarget)0, new object[1] { component.ViewID }); CrowdControlMod.Instance.Logger.LogInfo((object)$"Initialized tornado with TornadoSpawner ViewID: {component.ViewID}"); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find PhotonView on tornado or spawner, tornado may not work correctly"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error initializing tornado: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); } } [IteratorStateMachine(typeof(d__8))] private IEnumerator CleanupTornadoSpawner(GameObject spawnerObj, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { spawnerObj = spawnerObj, delay = delay }; } private Vector3 GetSpawnPosition(Character character) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)character).transform.position + ((Component)character).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)character).transform).GetComponentsInChildren(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Hip") { result = val.position + val.forward * 1.5f + Vector3.up; } } Transform val2 = ((Component)character).transform.Find("Hip"); if ((Object)(object)val2 != (Object)null) { result = val2.position + val2.forward * 1.5f + Vector3.up; } return result; } } [Effect(new string[] { "spawn_tumbleweed" }, 0f, true)] public class SpawnTumbleweedEffect : Effect { public SpawnTumbleweedEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { CrowdControlMod.Instance.Logger.LogInfo((object)"[SpawnTumbleweedEffect] Effect started"); Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter != (Object)(object)Character.localCharacter || !((Behaviour)localCharacter).isActiveAndEnabled || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { CrowdControlMod.Instance.Logger.LogWarning((object)"[SpawnTumbleweedEffect] Character validation failed"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (PhotonNetwork.IsMasterClient) { return SpawnTumbleweedDirectly(localCharacter, request); } return SpawnTumbleweedViaHost(localCharacter, request); } private EffectResponse SpawnTumbleweedDirectly(Character character, EffectRequest request) { //IL_0002: 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_0008: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) Vector3 spawnPosition = GetSpawnPosition(character); try { Quaternion identity = Quaternion.identity; CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTumbleweedEffect] Attempting to spawn TumbleWeed at {spawnPosition}"); GameObject val = PhotonNetwork.InstantiateRoomObject("TumbleWeed", spawnPosition, identity, (byte)0, (object[])null); if ((Object)(object)val == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)"[SpawnTumbleweedEffect] Instantiation returned null for TumbleWeed"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } if ((Object)(object)val.GetComponent("TumbleWeed") != (Object)null) { CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTumbleweedEffect] Spawned TumbleWeed at {spawnPosition}"); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"[SpawnTumbleweedEffect] TumbleWeed component not found on spawned object"); } GameNotifications.Show("Spawned hazard: Tumbleweed"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTumbleweedEffect] Failed to instantiate TumbleWeed: " + ex.Message)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private EffectResponse SpawnTumbleweedViaHost(Character character, EffectRequest request) { //IL_0002: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Vector3 spawnPosition = GetSpawnPosition(character); Dictionary dictionary = new Dictionary { ["prefabPath"] = "TumbleWeed", ["spawnPosition"] = new Dictionary { ["x"] = spawnPosition.x, ["y"] = spawnPosition.y, ["z"] = spawnPosition.z }, ["requestId"] = ((SimpleJSONMessage)request).ID.ToString() }; CrowdControlMod.Instance.Logger.LogInfo((object)("[SpawnTumbleweedEffect] Sending event data to host: " + JsonConvert.SerializeObject((object)dictionary))); if (CustomEventSystem.Instance.TriggerEvent("spawn_item", dictionary, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"[SpawnTumbleweedEffect] Host spawned TumbleWeed successfully"); } else { CrowdControlMod.Instance.Logger.LogError((object)("[SpawnTumbleweedEffect] Host failed to spawn TumbleWeed: " + response.Message)); } })) { CrowdControlMod.Instance.Logger.LogInfo((object)"[SpawnTumbleweedEffect] Requested host to spawn TumbleWeed"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } CrowdControlMod.Instance.Logger.LogError((object)"[SpawnTumbleweedEffect] Failed to send spawn request to host"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)4097); } private Vector3 GetSpawnPosition(Character character) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) //IL_003b: 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) Vector3 val = ((Component)character).transform.position + Vector3.up; Transform val2 = ((Component)character).transform.Find("Hip"); if ((Object)(object)val2 != (Object)null) { val = val2.position + Vector3.up; } val += new Vector3(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f)); CrowdControlMod.Instance.Logger.LogInfo((object)$"[SpawnTumbleweedEffect] Calculated spawn position: {val} for character at {((Component)character).transform.position}"); return val; } } [Effect("spawn_zombie", 0f, true)] public class SpawnZombieEffect : Effect { public SpawnZombieEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { //IL_0021: 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_0059: 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_0085: 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) Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } Vector3 spawnPosition = GetSpawnPosition(localCharacter); int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber; if (PhotonNetwork.IsMasterClient) { return SpawnZombieDirectly(spawnPosition, localCharacter, request); } Dictionary data = new Dictionary { ["spawnPosition"] = new Dictionary { ["x"] = spawnPosition.x, ["y"] = spawnPosition.y, ["z"] = spawnPosition.z }, ["targetPlayerId"] = actorNumber }; if (!CustomEventSystem.Instance.TriggerEvent("spawn_zombie", data, delegate(EventResponse response) { if (response.Success) { CrowdControlMod.Instance.Logger.LogInfo((object)"Successfully requested host to spawn zombie"); } else { CrowdControlMod.Instance.Logger.LogError((object)("Host failed to spawn zombie: " + response.Message)); } })) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send zombie spawn request to host"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private EffectResponse SpawnZombieDirectly(Vector3 spawnPos, Character targetCharacter, EffectRequest request) { //IL_006e: 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_00bc: Unknown result type (might be due to invalid IL or missing references) try { if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot spawn zombie."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Not connected to Photon room"); } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can spawn zombie."); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Only the Master Client can spawn zombie"); } if ((Object)(object)PhotonNetwork.Instantiate("MushroomZombie", spawnPos, Quaternion.identity, (byte)0, (object[])null) == (Object)null) { CrowdControlMod.Instance.Logger.LogError((object)"Failed to instantiate zombie prefab"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to instantiate zombie prefab"); } CrowdControlMod.Instance.Logger.LogInfo((object)$"Spawned zombie at {spawnPos}"); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error spawning zombie: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error spawning zombie: " + ex.Message); } } private Vector3 GetSpawnPosition(Character character) { //IL_0006: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_002f: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)character).transform.position + ((Component)character).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)character).transform).GetComponentsInChildren(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Hip") { result = val.position + val.forward * 1.5f + Vector3.up; } } Transform val2 = ((Component)character).transform.Find("Hip"); if ((Object)(object)val2 != (Object)null) { result = val2.position + val2.forward * 1.5f + Vector3.up; } return result; } } [Effect(new string[] { "player_speed_fast", "player_speed_slow" }, 0f, true)] public class PlayerSpeed : Effect { private static bool _active = false; private static float _movementModifier = 1f; private static float _sprintMultiplier = 1f; public PlayerSpeed(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public override EffectResponse Start(EffectRequest request) { if (_active) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } CharacterMovement component = ((Component)localCharacter).GetComponent(); _active = true; _movementModifier = component.movementModifier; _sprintMultiplier = component.sprintMultiplier; if (request.code == "player_speed_fast") { component.movementModifier = 2f; component.sprintMultiplier = 2f; } else if (request.code == "player_speed_slow") { component.movementModifier = 0.8f; component.sprintMultiplier = 0.8f; } ResetSpeedAfterDelay(component, request); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } private async Task ResetSpeedAfterDelay(CharacterMovement movement, EffectRequest request) { await Task.Delay(checked((int)request.duration.Value)); movement.movementModifier = _movementModifier; movement.sprintMultiplier = _sprintMultiplier; _active = false; } } [Effect(new string[] { "storm_rain", "storm_snow", "storm_wind" }, 30f, true)] public class StormEffect : Effect { private struct VisualState { public GameObject VisualObject; public bool WasActive; } public enum StormType { Unknown, Rain, Snow, Wind } [CompilerGenerated] private sealed class d__30 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public StormEffect <>4__this; public StormType stormType; public WindChillZone zone; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; StormEffect stormEffect = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; try { stormEffect.SetDayNightManagerStormFactor(stormType, activate: false, 0f); PhotonView component = ((Component)zone).GetComponent(); MethodInfo method = ((object)zone).GetType().GetMethod("RPCA_ToggleWind", BindingFlags.Instance | BindingFlags.NonPublic); if ((Object)(object)component != (Object)null && method != null && PhotonNetwork.IsMasterClient) { Vector3 val = Vector3.right; FieldInfo field = ((object)zone).GetType().GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { val = (Vector3)field.GetValue(zone); } method.Invoke(zone, new object[3] { false, val, delay }); } else { zone.windActive = false; } FieldInfo field2 = ((object)zone).GetType().GetField("untilSwitch", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(zone, delay); } FieldInfo field3 = ((object)zone).GetType().GetField("timeUntilNextWind", BindingFlags.Instance | BindingFlags.NonPublic); if (field3 != null) { field3.SetValue(zone, delay); } stormEffect.RestoreZoneStormVisuals(zone); stormEffect.CleanupExistingZoneVisual(zone); stormEffect.ForceCleanupAllStorms(); SetStormActive(active: false); SetLocalVisualActive(active: false); GameNotifications.Show($"{stormType} storm ended."); } catch (Exception ex) { SetStormActive(active: false); SetLocalVisualActive(active: false); CrowdControlMod.Instance.Logger.LogWarning((object)("Error cleaning up existing storm: " + ex.Message)); } 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__35 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public Component windZone; public GameObject stormObj; public StormType stormType; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__35(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; try { if ((Object)(object)windZone != (Object)null) { ((object)windZone).GetType().GetField("windActive", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, false); } if ((Object)(object)stormObj != (Object)null) { Object.Destroy((Object)(object)stormObj); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error cleaning up host local overlay: " + ex.Message)); } finally { if (HostLocalOverlays.TryGetValue(stormType, out GameObject value) && (Object)(object)value == (Object)(object)stormObj) { HostLocalOverlays.Remove(stormType); } SetLocalVisualActive(active: false); } 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__60 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public StormEffect <>4__this; public StormType stormType; public Component windZone; public GameObject stormObj; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; StormEffect stormEffect = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; try { stormEffect.SetDayNightManagerStormFactor(stormType, activate: false, 0f); Type type = ((object)windZone).GetType(); if ((Object)(object)windZone.gameObject.GetComponent() != (Object)null) { MethodInfo method = type.GetMethod("RPCA_ToggleWind", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { Vector3 val = Vector3.right; FieldInfo field = type.GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { val = (Vector3)field.GetValue(windZone); } method.Invoke(windZone, new object[3] { false, val, delay }); } } FieldInfo field2 = type.GetField("windActive", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { field2.SetValue(windZone, false); } FieldInfo field3 = type.GetField("untilSwitch", BindingFlags.Instance | BindingFlags.NonPublic); if (field3 != null) { field3.SetValue(windZone, delay); } FieldInfo field4 = type.GetField("timeUntilNextWind", BindingFlags.Instance | BindingFlags.NonPublic); if (field4 != null) { field4.SetValue(windZone, delay); } Object.Destroy((Object)(object)stormObj); SetStormActive(active: false); SetLocalVisualActive(active: false); stormEffect.ForceCleanupAllStorms(); GameNotifications.Show($"{stormType} storm ended."); CrowdControlMod.Instance.Logger.LogInfo((object)"Storm cleaned up"); } catch (Exception ex) { SetStormActive(active: false); SetLocalVisualActive(active: false); stormEffect.ForceCleanupAllStorms(); CrowdControlMod.Instance.Logger.LogWarning((object)("Error cleaning up storm: " + ex.Message)); } 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__42 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public StormEffect <>4__this; public StormType stormType; public Component windZone; public GameObject stormObj; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__42(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown int num = <>1__state; StormEffect stormEffect = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; try { stormEffect.SetDayNightManagerStormFactor(stormType, activate: false, 0f); Type type = ((object)windZone).GetType(); type.GetField("windActive", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, false); FieldInfo field = type.GetField("untilSwitch", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(windZone, delay); } FieldInfo field2 = type.GetField("timeUntilNextWind", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(windZone, delay); } Object.Destroy((Object)(object)stormObj); SetStormActive(active: false); SetLocalVisualActive(active: false); stormEffect.ForceCleanupAllStorms(); GameNotifications.Show($"{stormType} storm ended."); } catch (Exception ex) { SetStormActive(active: false); SetLocalVisualActive(active: false); CrowdControlMod.Instance.Logger.LogWarning((object)("Error cleaning up local storm: " + ex.Message)); } 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__59 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Component windZone; public Character character; public GameObject stormObj; public float duration; private FieldInfo 5__2; private float 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__59(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_008c: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: { <>1__state = -1; Type type = ((object)windZone).GetType(); 5__2 = type.GetField("windZoneBounds", BindingFlags.Instance | BindingFlags.Public); 5__3 = 0f; break; } case 1: <>1__state = -1; 5__3 += 0.5f; break; } if (5__3 < duration && (Object)(object)stormObj != (Object)null && (Object)(object)windZone != (Object)null) { if ((Object)(object)character != (Object)null && (Object)(object)((Component)character).gameObject != (Object)null && 5__2 != null) { Bounds val = (Bounds)5__2.GetValue(windZone); Bounds val2 = default(Bounds); ((Bounds)(ref val2))..ctor(character.Center, ((Bounds)(ref val)).size); 5__2.SetValue(windZone, val2); stormObj.transform.position = character.Center; } <>2__current = (object)new WaitForSeconds(0.5f); <>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 const float STORM_DURATION = 30f; private const float WIND_INTENSITY = 1f; private const float WIND_ZONE_RADIUS = 50f; private static bool isStormActive = false; private static readonly object stormLock = new object(); private static bool isLocalVisualActive = false; private static readonly object visualLock = new object(); private static readonly HashSet PendingStormRequests = new HashSet(); private static readonly object pendingStormLock = new object(); private static readonly Dictionary ExistingZoneVisuals = new Dictionary(); private static readonly Dictionary> ZoneVisualStates = new Dictionary>(); private static readonly Dictionary HostLocalOverlays = new Dictionary(); private static readonly HashSet StormAudioBaselineIds = new HashSet(); private static bool stormAudioBaselineCaptured = false; public static bool IsStormActive { get { lock (stormLock) { return isStormActive; } } } private static bool IsLocalVisualActive { get { lock (visualLock) { return isLocalVisualActive; } } } public StormEffect(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public static void SetStormActive(bool active) { lock (stormLock) { isStormActive = active; } } private static void SetLocalVisualActive(bool active) { lock (visualLock) { isLocalVisualActive = active; } } public override EffectResponse Start(EffectRequest request) { Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (IsStormActive) { CrowdControlMod.Instance.Logger.LogInfo((object)"A storm is already active, cannot create another one"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "A storm is already active"); } StormType stormType = GetStormType(request.code); if (stormType == StormType.Unknown) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Unknown storm type"); } if (PhotonNetwork.IsMasterClient) { return CreateStormDirectly(localCharacter, stormType, request); } if (IsStormActive) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "A storm is already active"); } Dictionary data = new Dictionary { ["stormType"] = stormType.ToString(), ["targetPlayerId"] = PhotonNetwork.LocalPlayer.ActorNumber }; if (!CustomEventSystem.Instance.TriggerEvent("create_storm", data)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to send storm creation request to host"); } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } internal static void BroadcastStormVisual(StormType stormType, float duration, int targetActor) { if (PhotonNetwork.IsMasterClient) { Dictionary payload = new Dictionary { ["stormType"] = stormType.ToString(), ["duration"] = duration, ["targetActor"] = targetActor }; RPCCommands.MessageHandler.SendMessageToAll("storm_visual", payload); } } internal static void HandleStormVisualMessage(object payloadObj) { Dictionary dictionary = payloadObj as Dictionary; if (dictionary == null) { JObject val = (JObject)((payloadObj is JObject) ? payloadObj : null); if (val != null) { dictionary = ((JToken)val).ToObject>(); } } if (dictionary == null || !dictionary.TryGetValue("stormType", out var value) || !CrowdControlMod.Instance.EffectLoader.Effects.TryGetValue("storm_rain", out Effect value2) || !(value2 is StormEffect stormEffect) || IsLocalVisualActive || !Enum.TryParse(value.ToString(), out var result)) { return; } float duration = 30f; if (dictionary.TryGetValue("duration", out var value3)) { try { duration = Convert.ToSingle(value3); } catch { duration = 30f; } } int targetActor = 0; if (dictionary.TryGetValue("targetActor", out var value4)) { try { targetActor = Convert.ToInt32(value4); } catch { targetActor = 0; } } Character targetCharacter = null; if (targetActor != 0) { targetCharacter = ((IEnumerable)Character.AllCharacters).FirstOrDefault((Func)delegate(Character c) { PhotonView component = ((Component)c).GetComponent(); if (component == null) { return false; } Player owner = component.Owner; return ((owner != null) ? new int?(owner.ActorNumber) : null) == targetActor; }); } stormEffect.CreateStormVisualOnly(result, duration, targetCharacter); } private StormType GetStormType(string effectCode) { if (effectCode.Contains("rain")) { return StormType.Rain; } if (effectCode.Contains("snow")) { return StormType.Snow; } if (effectCode.Contains("wind")) { return StormType.Wind; } return StormType.Unknown; } private EffectResponse CreateStormDirectly(Character character, StormType stormType, EffectRequest request) { try { if (!TryCreateStormAtCharacter(character, stormType, 30f, out string errorMessage)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, errorMessage); } Player localPlayer = PhotonNetwork.LocalPlayer; BroadcastStormVisual(stormType, 30f, (localPlayer != null) ? localPlayer.ActorNumber : 0); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogError((object)("Error creating storm: " + ex.Message)); CrowdControlMod.Instance.Logger.LogError((object)("Stack trace: " + ex.StackTrace)); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Error creating storm: " + ex.Message); } } internal bool TryCreateStormAtCharacter(Character character, StormType stormType, float duration, out string errorMessage) { //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) errorMessage = string.Empty; if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom) { CrowdControlMod.Instance.Logger.LogWarning((object)"Not connected to Photon room, cannot create storm."); errorMessage = "Not connected to Photon room"; return false; } if (!PhotonNetwork.IsMasterClient) { CrowdControlMod.Instance.Logger.LogWarning((object)"Only the Master Client can create storms."); errorMessage = "Only the Master Client can create storms"; return false; } if (TryUseExistingWindChillZone(character, stormType, duration, out WindChillZone zone)) { SetStormActive(active: true); CaptureStormAudioBaseline(); SetStormAudioObjectsActive(active: true); CrowdControlMod.Instance.Logger.LogInfo((object)$"Activated existing {stormType} storm at {character.Center}"); GameNotifications.Show($"{stormType} storm started!"); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(UpdateStormBounds(((Component)zone).gameObject, (Component)(object)zone, character, duration)); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupExistingZoneAfterDelay(zone, duration, stormType)); return true; } GameObject val = new GameObject($"Storm_{stormType}_{Guid.NewGuid()}"); val.transform.position = character.Center; val.tag = "Untagged"; Type type = Type.GetType("WindChillZone"); if (type == null) { type = Type.GetType("WindChillZone, Assembly-CSharp"); } if (type == null) { Object.Destroy((Object)(object)val); CrowdControlMod.Instance.Logger.LogError((object)"WindChillZone type not found"); errorMessage = "WindChillZone type not found"; return false; } Component windZone = val.AddComponent(type); SetupWindZone(windZone, character, stormType); Component val2 = SetupStormVisual(val, windZone, stormType); ActivateWindZone(windZone, stormType); if ((Object)(object)val2 != (Object)null && val2.gameObject == val) { ((object)val2).GetType().GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val2, null); } SetStormActive(active: true); CaptureStormAudioBaseline(); SetStormAudioObjectsActive(active: true); CrowdControlMod.Instance.Logger.LogInfo((object)$"Created {stormType} storm at {character.Center}"); GameNotifications.Show($"{stormType} storm started!"); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(UpdateStormBounds(val, windZone, character, duration)); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupStormAfterDelay(val, windZone, duration, stormType)); return true; } private bool TryUseExistingWindChillZone(Character character, StormType stormType, float duration, out WindChillZone zone) { //IL_005f: 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_0080: 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_008f: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_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_011c: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) zone = FindExistingWindChillZoneForType(stormType); if ((Object)(object)zone == (Object)null) { return false; } try { CrowdControlMod.Instance.Logger.LogInfo((object)$"Using existing WindChillZone: name={((Object)zone).name}, requestedStormType={stormType}"); if (!((Component)zone).gameObject.activeInHierarchy) { ((Component)zone).gameObject.SetActive(true); } Bounds windZoneBounds = default(Bounds); ((Bounds)(ref windZoneBounds))..ctor(character.Center, new Vector3(200f, 200f, 200f)); zone.windZoneBounds = windZoneBounds; ((Component)zone).transform.position = character.Center; zone.observedCharacterInsideBounds = true; Vector3 val = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val)).normalized; FieldInfo field = ((object)zone).GetType().GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); field?.SetValue(zone, normalized); zone.windIntensity = 1f; zone.windTimeRangeOn = new Vector2(duration, duration); zone.windTimeRangeOff = new Vector2(duration, duration); zone.windForce = ((stormType == StormType.Wind) ? 15f : 0f); zone.windMovesItems = true; zone.windIntensityCurve = AnimationCurve.Linear(0f, 0f, 1f, 1f); zone.useIntensityCurve = false; zone.lightVolumeSampleThreshold_lower = 0f; zone.lightVolumeSampleThreshold_margin = 1f; if (stormType == StormType.Snow) { zone.statusType = (STATUSTYPE)2; zone.statusApplicationPerSecond = 0.01f; } else { zone.statusApplicationPerSecond = 0f; } PhotonView component = ((Component)zone).GetComponent(); MethodInfo method = ((object)zone).GetType().GetMethod("RPCA_ToggleWind", BindingFlags.Instance | BindingFlags.NonPublic); if ((Object)(object)component != (Object)null && method != null && PhotonNetwork.IsMasterClient) { Vector3 val2 = normalized; if (field != null) { val2 = (Vector3)field.GetValue(zone); } method.Invoke(zone, new object[3] { true, val2, duration }); } else { zone.windActive = true; } zone.windActive = true; SetDayNightManagerStormFactor(stormType, activate: true, 1.5f); bool flag = EnsureStormVisualForExistingZone(zone, stormType); if (flag) { SetLocalVisualActive(active: true); } if (PhotonNetwork.IsMasterClient && flag && (stormType == StormType.Rain || stormType == StormType.Snow)) { CreateHostVisualOverlay(zone, stormType); CreateHostLocalStormOverlay(character, stormType, duration); } return true; } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to use existing WindChillZone: " + ex.Message)); return false; } } private WindChillZone FindExistingWindChillZoneForType(StormType stormType) { string text = stormType switch { StormType.Snow => "SnowStorm", StormType.Rain => "RainStorm", StormType.Wind => "WindStorm", _ => null, }; if (!string.IsNullOrEmpty(text)) { WindChillZone[] array = Object.FindObjectsOfType(true); if (array != null) { WindChillZone[] array2 = array; foreach (WindChillZone val in array2) { if ((Object)(object)val != (Object)null && ((Object)val).name == text) { return val; } } } } return WindChillZone.instance ?? Object.FindObjectOfType(); } [IteratorStateMachine(typeof(d__30))] private IEnumerator CleanupExistingZoneAfterDelay(WindChillZone zone, float delay, StormType stormType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__30(0) { <>4__this = this, zone = zone, delay = delay, stormType = stormType }; } private bool EnsureStormVisualForExistingZone(WindChillZone zone, StormType stormType) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zone == (Object)null) { return false; } int instanceID = ((Object)zone).GetInstanceID(); if (ExistingZoneVisuals.TryGetValue(instanceID, out GameObject value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); ExistingZoneVisuals.Remove(instanceID); } if (TryUseZoneStormVisual(zone, stormType)) { return true; } GameObject val = new GameObject($"StormVisual_{stormType}_{Guid.NewGuid()}"); val.transform.position = ((Component)zone).transform.position; val.transform.SetParent(((Component)zone).transform, true); val.tag = "Untagged"; Component val2 = SetupStormVisual(val, (Component)(object)zone, stormType); if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)val); return false; } if (val2.gameObject != val) { Object.Destroy((Object)(object)val); return false; } ((object)val2).GetType().GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val2, null); ExistingZoneVisuals[instanceID] = val; return true; } private void CreateHostVisualOverlay(WindChillZone zone, StormType stormType) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)zone == (Object)null)) { int instanceID = ((Object)zone).GetInstanceID(); if (ExistingZoneVisuals.TryGetValue(instanceID, out GameObject value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); ExistingZoneVisuals.Remove(instanceID); } GameObject val = new GameObject($"StormVisualOverlay_{stormType}_{Guid.NewGuid()}"); val.transform.position = ((Component)zone).transform.position; val.transform.SetParent(((Component)zone).transform, true); val.tag = "Untagged"; Component val2 = SetupStormVisual(val, (Component)(object)zone, stormType); if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)val); return; } if (val2.gameObject != val) { Object.Destroy((Object)(object)val); return; } ((object)val2).GetType().GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val2, null); ExistingZoneVisuals[instanceID] = val; SetLocalVisualActive(active: true); CrowdControlMod.Instance.Logger.LogInfo((object)$"Created host visual overlay: stormType={stormType}, zone={((Object)zone).name}"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to create host visual overlay: " + ex.Message)); } } private void CreateHostLocalStormOverlay(Character character, StormType stormType, float duration) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)character == (Object)null) { return; } if (HostLocalOverlays.TryGetValue(stormType, out GameObject value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); HostLocalOverlays.Remove(stormType); } GameObject val = new GameObject($"StormLocal_{stormType}_{Guid.NewGuid()}"); val.transform.position = character.Center; val.tag = "Untagged"; Type type = Type.GetType("WindChillZone, Assembly-CSharp") ?? Type.GetType("WindChillZone"); if (type == null) { Object.Destroy((Object)(object)val); return; } Component windZone = val.AddComponent(type); SetupWindZoneLocal(windZone, character, stormType, duration); Component val2 = SetupStormVisual(val, windZone, stormType); ActivateWindZoneLocalOverlay(windZone); if ((Object)(object)val2 != (Object)null && val2.gameObject == val) { ((object)val2).GetType().GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val2, null); } HostLocalOverlays[stormType] = val; SetLocalVisualActive(active: true); CrowdControlMod.Instance.Logger.LogInfo((object)$"Created host local overlay: stormType={stormType}"); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(UpdateStormBounds(val, windZone, character, duration)); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupHostLocalOverlayAfterDelay(val, windZone, duration, stormType)); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to create host local overlay: " + ex.Message)); } } private void ActivateWindZoneLocalOverlay(Component windZone) { try { ((object)windZone).GetType().GetField("windActive", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, true); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error activating host local overlay: " + ex.Message)); } } [IteratorStateMachine(typeof(d__35))] private IEnumerator CleanupHostLocalOverlayAfterDelay(GameObject stormObj, Component windZone, float delay, StormType stormType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__35(0) { stormObj = stormObj, windZone = windZone, delay = delay, stormType = stormType }; } private bool TryUseZoneStormVisual(WindChillZone zone, StormType stormType) { try { StormVisual[] componentsInChildren = ((Component)zone).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return false; } string text = stormType switch { StormType.Rain => "Rain", StormType.Wind => "Wind", _ => "Storm", }; List list = new List(); StormVisual[] array = componentsInChildren; foreach (StormVisual val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && ((Component)val).gameObject.CompareTag(text) && HasStormVisualRenderers(val)) { list.Add(val); } } if (list.Count == 0) { array = componentsInChildren; foreach (StormVisual val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null) && HasStormVisualRenderers(val2)) { list.Add(val2); } } } if (list.Count == 0) { return false; } int instanceID = ((Object)zone).GetInstanceID(); List list2 = new List(); foreach (StormVisual item in list) { GameObject gameObject = ((Component)item).gameObject; if (!((Object)(object)gameObject == (Object)null)) { list2.Add(new VisualState { VisualObject = gameObject, WasActive = gameObject.activeSelf }); if (!gameObject.activeInHierarchy) { gameObject.SetActive(true); } if (!((Behaviour)item).enabled) { ((Behaviour)item).enabled = true; } ConfigureStormVisual((Component)(object)item, (Component)(object)zone, stormType); } } if (list2.Count > 0) { ZoneVisualStates[instanceID] = list2; CrowdControlMod.Instance.Logger.LogInfo((object)$"Using zone StormVisual(s): count={list2.Count}, stormType={stormType}, zone={((Object)zone).name}"); return true; } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to use zone StormVisuals: " + ex.Message)); } return false; } private void RestoreZoneStormVisuals(WindChillZone zone) { if ((Object)(object)zone == (Object)null) { return; } int instanceID = ((Object)zone).GetInstanceID(); if (!ZoneVisualStates.TryGetValue(instanceID, out List value) || value == null) { return; } foreach (VisualState item in value) { if (!((Object)(object)item.VisualObject == (Object)null)) { StormVisual component = item.VisualObject.GetComponent(); if ((Object)(object)component != (Object)null) { StopStormVisualParticles((Component)(object)component); } if (item.VisualObject.activeSelf != item.WasActive) { item.VisualObject.SetActive(item.WasActive); } } } ZoneVisualStates.Remove(instanceID); } private void CleanupExistingZoneVisual(WindChillZone zone) { if (!((Object)(object)zone == (Object)null)) { int instanceID = ((Object)zone).GetInstanceID(); if (ExistingZoneVisuals.TryGetValue(instanceID, out GameObject value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } ExistingZoneVisuals.Remove(instanceID); } } private void CreateStormVisualOnly(StormType stormType, float duration, Character targetCharacter) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (IsLocalVisualActive) { return; } Character val = (Character)(((Object)(object)targetCharacter != (Object)null) ? ((object)targetCharacter) : ((object)Character.localCharacter)); if (!Object.op_Implicit((Object)(object)val)) { return; } GameObject val2 = new GameObject($"StormVisual_{stormType}_{Guid.NewGuid()}"); val2.transform.position = val.Center; val2.tag = "Untagged"; CaptureStormAudioBaseline(); SetStormAudioObjectsActive(active: true); Type type = Type.GetType("WindChillZone, Assembly-CSharp") ?? Type.GetType("WindChillZone"); if (type == null) { Object.Destroy((Object)(object)val2); return; } Component windZone = val2.AddComponent(type); SetupWindZoneLocal(windZone, val, stormType, duration); Component val3 = SetupStormVisual(val2, windZone, stormType); ActivateWindZoneLocal(windZone, stormType); if ((Object)(object)val3 != (Object)null && val3.gameObject == val2) { ((object)val3).GetType().GetMethod("Start", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(val3, null); } SetStormActive(active: true); SetLocalVisualActive(active: true); GameNotifications.Show($"{stormType} storm started!"); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(UpdateStormBounds(val2, windZone, val, duration)); ((MonoBehaviour)CrowdControlMod.Instance).StartCoroutine(CleanupStormVisualAfterDelay(val2, windZone, duration, stormType)); } private void SetupWindZoneLocal(Component windZone, Character character, StormType stormType, float duration) { //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) try { Type type = ((object)windZone).GetType(); if ((Object)(object)windZone.gameObject.GetComponent() == (Object)null) { SphereCollider obj = windZone.gameObject.AddComponent(); obj.radius = 50f; ((Collider)obj).isTrigger = true; } type.GetField("observedCharacterInsideBounds", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(windZone, true); type.GetField("hasBeenActiveFor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(windZone, 0f); FieldInfo field = type.GetField("windZoneBounds", BindingFlags.Instance | BindingFlags.Public); if (field != null) { Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(character.Center, new Vector3(200f, 200f, 200f)); field.SetValue(windZone, val); windZone.gameObject.transform.position = character.Center; } Vector3 val2 = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val2)).normalized; type.GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(windZone, normalized); type.GetField("windIntensity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(windZone, 1f); type.GetField("windFactor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(windZone, 1f); type.GetField("windTimeRangeOn", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, (object)new Vector2(duration, duration)); type.GetField("windTimeRangeOff", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, (object)new Vector2(duration, duration)); type.GetField("windForce", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, (stormType == StormType.Wind) ? 15f : 0f); type.GetField("windMovesItems", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, true); FieldInfo field2 = type.GetField("statusApplicationPerSecond", BindingFlags.Instance | BindingFlags.Public); if (stormType == StormType.Snow) { FieldInfo field3 = type.GetField("statusType", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { Type type2 = Type.GetType("CharacterAfflictions+STATUSTYPE"); if (type2 != null) { try { object value = Enum.Parse(type2, "Cold"); field3.SetValue(windZone, value); } catch { } } } field2?.SetValue(windZone, 0.01f); } else { field2?.SetValue(windZone, 0f); } FieldInfo field4 = type.GetField("windIntensityCurve", BindingFlags.Instance | BindingFlags.Public); if (field4 != null) { AnimationCurve value2 = AnimationCurve.Linear(0f, 0f, 1f, 1f); field4.SetValue(windZone, value2); } type.GetField("useIntensityCurve", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, false); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting up local wind zone: " + ex.Message)); } } private void ActivateWindZoneLocal(Component windZone, StormType stormType) { try { ((object)windZone).GetType().GetField("windActive", BindingFlags.Instance | BindingFlags.Public)?.SetValue(windZone, true); SetDayNightManagerStormFactor(stormType, activate: true, 1.5f); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error activating local wind zone: " + ex.Message)); } } [IteratorStateMachine(typeof(d__42))] private IEnumerator CleanupStormVisualAfterDelay(GameObject stormObj, Component windZone, float delay, StormType stormType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__42(0) { <>4__this = this, stormObj = stormObj, windZone = windZone, delay = delay, stormType = stormType }; } private void SetupWindZone(Component windZone, Character character, StormType stormType) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_011e: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) try { Type type = ((object)windZone).GetType(); if ((Object)(object)windZone.gameObject.GetComponent() == (Object)null) { PhotonView obj = windZone.gameObject.AddComponent(); obj.ViewID = Random.Range(1000, 9999); obj.Synchronization = (ViewSynchronization)3; } if ((Object)(object)windZone.gameObject.GetComponent() == (Object)null) { SphereCollider obj2 = windZone.gameObject.AddComponent(); obj2.radius = 50f; ((Collider)obj2).isTrigger = true; } FieldInfo field = type.GetField("observedCharacterInsideBounds", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(windZone, true); } FieldInfo field2 = type.GetField("hasBeenActiveFor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(windZone, 0f); } FieldInfo field3 = type.GetField("windZoneBounds", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(character.Center, new Vector3(200f, 200f, 200f)); field3.SetValue(windZone, val); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set wind zone bounds: center={((Bounds)(ref val)).center}, size={((Bounds)(ref val)).size}"); windZone.gameObject.transform.position = character.Center; } else { CrowdControlMod.Instance.Logger.LogWarning((object)"windZoneBounds field not found!"); } Vector3 val2 = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)); Vector3 normalized = ((Vector3)(ref val2)).normalized; FieldInfo field4 = type.GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field4 != null) { field4.SetValue(windZone, normalized); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set wind direction to {normalized}"); } FieldInfo field5 = type.GetField("windIntensity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field5 != null) { field5.SetValue(windZone, 1f); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set wind intensity to {1f}"); } FieldInfo field6 = type.GetField("windFactor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field6 != null) { field6.SetValue(windZone, 1f); } FieldInfo field7 = type.GetField("windTimeRangeOn", BindingFlags.Instance | BindingFlags.Public); if (field7 != null) { field7.SetValue(windZone, (object)new Vector2(30f, 30f)); } FieldInfo field8 = type.GetField("windTimeRangeOff", BindingFlags.Instance | BindingFlags.Public); if (field8 != null) { field8.SetValue(windZone, (object)new Vector2(30f, 30f)); } FieldInfo field9 = type.GetField("windForce", BindingFlags.Instance | BindingFlags.Public); if (field9 != null) { field9.SetValue(windZone, (stormType == StormType.Wind) ? 15f : 0f); } FieldInfo field10 = type.GetField("windMovesItems", BindingFlags.Instance | BindingFlags.Public); if (field10 != null) { field10.SetValue(windZone, true); } FieldInfo field11 = type.GetField("statusType", BindingFlags.Instance | BindingFlags.Public); FieldInfo field12 = type.GetField("statusApplicationPerSecond", BindingFlags.Instance | BindingFlags.Public); if (stormType == StormType.Snow) { if (field11 != null) { Type type2 = Type.GetType("CharacterAfflictions+STATUSTYPE"); if (type2 != null) { try { object obj3 = Enum.Parse(type2, "Cold"); if (obj3 != null) { field11.SetValue(windZone, obj3); } } catch { } } } if (field12 != null) { field12.SetValue(windZone, 0.01f); } } else if (field12 != null) { field12.SetValue(windZone, 0f); } FieldInfo field13 = type.GetField("lightVolumeSampleThreshold_lower", BindingFlags.Instance | BindingFlags.Public); if (field13 != null) { field13.SetValue(windZone, 0f); } FieldInfo field14 = type.GetField("lightVolumeSampleThreshold_margin", BindingFlags.Instance | BindingFlags.Public); if (field14 != null) { field14.SetValue(windZone, 1f); } FieldInfo field15 = type.GetField("windIntensityCurve", BindingFlags.Instance | BindingFlags.Public); if (field15 != null) { AnimationCurve value = AnimationCurve.Linear(0f, 0f, 1f, 1f); field15.SetValue(windZone, value); CrowdControlMod.Instance.Logger.LogInfo((object)"Set windIntensityCurve to linear curve"); } FieldInfo field16 = type.GetField("useIntensityCurve", BindingFlags.Instance | BindingFlags.Public); if (field16 != null) { field16.SetValue(windZone, false); CrowdControlMod.Instance.Logger.LogInfo((object)"Disabled useIntensityCurve"); } FieldInfo field17 = type.GetField("untilSwitch", BindingFlags.Instance | BindingFlags.NonPublic); if (field17 != null) { field17.SetValue(windZone, 30f); } FieldInfo field18 = type.GetField("timeUntilNextWind", BindingFlags.Instance | BindingFlags.NonPublic); if (field18 != null) { field18.SetValue(windZone, 30f); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting up wind zone: " + ex.Message)); } } private Component SetupStormVisual(GameObject stormObj, Component windZone, StormType stormType) { try { string tag = stormType switch { StormType.Rain => "Rain", StormType.Wind => "Wind", _ => "Storm", }; Component val = FindExistingStormVisual(stormType); if ((Object)(object)val != (Object)null) { Component val2 = TryInstantiateStormVisualFromSource(val, stormObj.transform, tag); if ((Object)(object)val2 != (Object)null) { ConfigureStormVisual(val2, windZone, stormType); return val2; } } Component val3 = TryInstantiateStormVisualPrefab(stormType, stormObj.transform); if ((Object)(object)val3 != (Object)null) { ConfigureStormVisual(val3, windZone, stormType); return val3; } Type type = Type.GetType("StormVisual, Assembly-CSharp"); if (type == null) { type = Type.GetType("StormVisual"); } if (type == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"StormVisual type not found"); return null; } stormObj.tag = tag; Component val4 = stormObj.AddComponent(type); ConfigureStormVisual(val4, windZone, stormType); FieldInfo field = type.GetField("part", BindingFlags.Instance | BindingFlags.Public); if (field != null) { Type type2 = Type.GetType("UnityEngine.ParticleSystem, UnityEngine.ParticleSystemModule"); if (type2 != null) { Array value = Array.CreateInstance(type2, 0); field.SetValue(val4, value); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.part array to empty (no particle systems)"); } else { field.SetValue(val4, null); CrowdControlMod.Instance.Logger.LogWarning((object)"Could not create particle system array type, setting to null"); } } CrowdControlMod.Instance.Logger.LogInfo((object)"StormVisual component added and configured (note: particle systems needed for full visual effects)"); return val4; } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting up StormVisual: " + ex.Message)); CrowdControlMod.Instance.Logger.LogWarning((object)("Stack trace: " + ex.StackTrace)); return null; } } private Component TryInstantiateStormVisualPrefab(StormType stormType, Transform parent) { string text = stormType switch { StormType.Rain => "Rain", StormType.Wind => "Wind", _ => "Storm", }; try { Component val = TryGetStormAudioVisualTemplate(stormType); StormVisual val2 = (StormVisual)(object)((val is StormVisual) ? val : null); if ((Object)(object)val2 != (Object)null && MatchesStormType(val2, stormType) && HasStormVisualRenderers(val2)) { Component val3 = TryInstantiateStormVisualFromSource(val, parent, text); if ((Object)(object)val3 != (Object)null) { return val3; } } else { GameObject val4 = GameObject.FindGameObjectWithTag(text); if ((Object)(object)val4 != (Object)null) { StormVisual component = val4.GetComponent(); if ((Object)(object)component != (Object)null && MatchesStormType(component, stormType) && HasStormVisualRenderers(component)) { Component val5 = TryInstantiateStormVisualFromSource((Component)(object)component, parent, text); if ((Object)(object)val5 != (Object)null) { return val5; } } } } Object[] array = Object.FindObjectsOfTypeAll(typeof(StormVisual)); Object[] array2 = array; foreach (Object obj in array2) { StormVisual val6 = (StormVisual)(object)((obj is StormVisual) ? obj : null); if (!((Object)(object)val6 == (Object)null) && ((Component)val6).gameObject.CompareTag(text) && MatchesStormType(val6, stormType) && HasStormVisualRenderers(val6)) { Component val7 = TryInstantiateStormVisualFromSource((Component)(object)val6, parent, text); if ((Object)(object)val7 != (Object)null) { return val7; } } } if (stormType == StormType.Snow) { array2 = array; foreach (Object obj2 in array2) { StormVisual val8 = (StormVisual)(object)((obj2 is StormVisual) ? obj2 : null); if (!((Object)(object)val8 == (Object)null) && ((Component)val8).gameObject.CompareTag(text) && HasStormVisualRenderers(val8)) { Component val9 = TryInstantiateStormVisualFromSource((Component)(object)val8, parent, text); if ((Object)(object)val9 != (Object)null) { GameObject gameObject = ((Component)val8).gameObject; string text2 = (((Object)(object)gameObject != (Object)null) ? ((Object)gameObject).name : "(null)"); CrowdControlMod.Instance.Logger.LogInfo((object)("Using snow visual fallback (ignoring stormType): name=" + text2 + ", tag=" + text)); return val9; } } } } array2 = array; foreach (Object obj3 in array2) { StormVisual val10 = (StormVisual)(object)((obj3 is StormVisual) ? obj3 : null); if (!((Object)(object)val10 == (Object)null) && MatchesStormType(val10, stormType) && HasStormVisualRenderers(val10) && !((Object)(object)((Component)val10).gameObject == (Object)null)) { Component val11 = TryInstantiateStormVisualFromSource((Component)(object)val10, parent, text); if ((Object)(object)val11 != (Object)null) { return val11; } } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to clone storm visual prefab: " + ex.Message)); } LogStormVisualCandidates(text, stormType); return null; } private Component TryInstantiateStormVisualFromSource(Component stormVisual, Transform parent, string tag) { if ((Object)(object)stormVisual == (Object)null) { return null; } GameObject gameObject = stormVisual.gameObject; if ((Object)(object)gameObject == (Object)null) { return null; } if (!gameObject.CompareTag(tag)) { return null; } GameObject val = Object.Instantiate(gameObject, parent); val.tag = tag; if (!val.activeInHierarchy) { val.SetActive(true); } return val.GetComponent("StormVisual"); } private bool HasStormVisualRenderers(StormVisual visual) { if ((Object)(object)visual == (Object)null) { return false; } try { FieldInfo field = ((object)visual).GetType().GetField("part"); if (field != null && field.GetValue(visual) is Array array && array.Length > 0) { return true; } FieldInfo field2 = ((object)visual).GetType().GetField("quadRend"); if (field2 != null && field2.GetValue(visual) != null) { return true; } } catch { return false; } return false; } private bool MatchesStormType(StormVisual visual, StormType stormType) { if ((Object)(object)visual == (Object)null) { return false; } try { FieldInfo field = ((object)visual).GetType().GetField("stormType"); if (field == null) { return true; } object value = field.GetValue(visual); if (value == null) { return true; } return string.Equals(value.ToString(), stormType.ToString(), StringComparison.OrdinalIgnoreCase); } catch { return true; } } private void LogStormVisualCandidates(string tag, StormType stormType) { try { StormAudio val = null; if ((Object)(object)Character.observedCharacter != (Object)null) { val = Character.observedCharacter.refs?.animations?.stormAudio; } if ((Object)(object)val == (Object)null) { val = Object.FindObjectOfType(); } CrowdControlMod.Instance.Logger.LogInfo((object)$"StormVisual lookup: stormType={stormType}, tag={tag}"); if ((Object)(object)val != (Object)null) { LogStormVisual("stormAudio.stormVisual", val.stormVisual); LogStormVisual("stormAudio.rainVisual", val.rainVisual); LogStormVisual("stormAudio.windVisual", val.windVisual); } else { CrowdControlMod.Instance.Logger.LogInfo((object)"StormVisual lookup: StormAudio not found"); } Object[] array = Object.FindObjectsOfTypeAll(typeof(StormVisual)); foreach (Object obj in array) { StormVisual val2 = (StormVisual)(object)((obj is StormVisual) ? obj : null); if (!((Object)(object)val2 == (Object)null)) { LogStormVisual("StormVisual candidate", val2); } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("StormVisual lookup logging failed: " + ex.Message)); } } private void LogStormVisual(string label, StormVisual visual) { //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) if ((Object)(object)visual == (Object)null) { CrowdControlMod.Instance.Logger.LogInfo((object)(label + ": null")); return; } GameObject gameObject = ((Component)visual).gameObject; string text = (((Object)(object)gameObject != (Object)null) ? ((Object)gameObject).name : "(no gameObject)"); string text2 = (((Object)(object)gameObject != (Object)null) ? gameObject.tag : "(no tag)"); int num; if ((Object)(object)gameObject != (Object)null) { Scene scene = gameObject.scene; num = (((Scene)(ref scene)).IsValid() ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; bool flag2 = (Object)(object)gameObject != (Object)null && gameObject.activeInHierarchy; bool flag3 = HasStormVisualRenderers(visual); string text3 = "(unknown)"; try { FieldInfo field = ((object)visual).GetType().GetField("stormType"); if (field != null) { object value = field.GetValue(visual); text3 = ((value != null) ? value.ToString() : "(null)"); } } catch { text3 = "(error)"; } CrowdControlMod.Instance.Logger.LogInfo((object)$"{label}: name={text}, tag={text2}, scene={flag}, active={flag2}, stormType={text3}, hasRenderers={flag3}"); } private Component TryGetStormAudioVisualTemplate(StormType stormType) { StormAudio val = null; if ((Object)(object)Character.observedCharacter != (Object)null) { val = Character.observedCharacter.refs?.animations?.stormAudio; } if ((Object)(object)val == (Object)null) { val = Object.FindObjectOfType(); } if ((Object)(object)val == (Object)null) { return null; } return (Component)(stormType switch { StormType.Rain => val.rainVisual, StormType.Wind => val.windVisual, _ => val.stormVisual, }); } private Component FindExistingStormVisual(StormType stormType) { string text = stormType switch { StormType.Rain => "Rain", StormType.Wind => "Wind", _ => "Storm", }; try { Object[] array = Object.FindObjectsOfTypeAll(typeof(StormVisual)); Object[] array2 = array; foreach (Object val in array2) { if (val == (Object)null) { continue; } StormVisual val2 = (StormVisual)(object)((val is StormVisual) ? val : null); if (!((Object)(object)val2 == (Object)null)) { GameObject gameObject = ((Component)val2).gameObject; if (!((Object)(object)gameObject == (Object)null) && gameObject.CompareTag(text) && MatchesStormType(val2, stormType) && HasStormVisualRenderers(val2)) { return (Component)(object)val2; } } } if (stormType == StormType.Snow) { array2 = array; foreach (Object val3 in array2) { if (val3 == (Object)null) { continue; } StormVisual val4 = (StormVisual)(object)((val3 is StormVisual) ? val3 : null); if (!((Object)(object)val4 == (Object)null)) { GameObject gameObject2 = ((Component)val4).gameObject; if (!((Object)(object)gameObject2 == (Object)null) && gameObject2.CompareTag(text) && HasStormVisualRenderers(val4)) { CrowdControlMod.Instance.Logger.LogInfo((object)("Using snow visual fallback (ignoring stormType): name=" + ((Object)gameObject2).name + ", tag=" + text)); return (Component)(object)val4; } } } } GameObject val5 = GameObject.FindGameObjectWithTag(text); if ((Object)(object)val5 == (Object)null) { return null; } Component component = val5.GetComponent("StormVisual"); if ((Object)(object)component == (Object)null) { return null; } return component; } catch { return null; } } private void ConfigureStormVisual(Component stormVisual, Component windZone, StormType stormType) { Type type = ((object)stormVisual).GetType(); PropertyInfo property = type.GetProperty("enabled"); if (property != null) { property.SetValue(stormVisual, true); } FieldInfo field = type.GetField("zone", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(stormVisual, windZone); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.zone field"); } FieldInfo field2 = type.GetField("stormType", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { Type type2 = Type.GetType("StormVisual+StormType, Assembly-CSharp"); if (type2 == null) { type2 = Type.GetType("StormVisual+StormType"); } if (type2 != null) { object value = Enum.Parse(type2, stormType.ToString()); field2.SetValue(stormVisual, value); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set StormVisual.stormType to {stormType}"); } } FieldInfo field3 = type.GetField("useWindChillZoneIntensity", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { field3.SetValue(stormVisual, true); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.useWindChillZoneIntensity to true"); } FieldInfo field4 = type.GetField("windchillZoneMult", BindingFlags.Instance | BindingFlags.Public); if (field4 != null) { field4.SetValue(stormVisual, 1f); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.windchillZoneMult to 1f"); } FieldInfo field5 = type.GetField("windFactor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field5 != null) { field5.SetValue(stormVisual, 1f); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.windFactor to 1.0f"); } if (stormType == StormType.Wind) { FieldInfo field6 = type.GetField("windParticleMult", BindingFlags.Instance | BindingFlags.Public); if (field6 != null) { field6.SetValue(stormVisual, 50f); CrowdControlMod.Instance.Logger.LogInfo((object)"Set StormVisual.windParticleMult to 50f"); } FieldInfo field7 = type.GetField("particleForceField", BindingFlags.Instance | BindingFlags.Public); if (field7 != null && field7.GetValue(stormVisual) == null) { Type type3 = Type.GetType("UnityEngine.ParticleSystemForceField, UnityEngine.ParticleSystemModule"); if (type3 != null) { Component value2 = stormVisual.gameObject.AddComponent(type3); field7.SetValue(stormVisual, value2); CrowdControlMod.Instance.Logger.LogInfo((object)"Added particle force field for wind storm"); } else { CrowdControlMod.Instance.Logger.LogWarning((object)"Could not find particle force field type, leaving null"); } } } LogStormVisualSelection(stormVisual, stormType, "configure"); ForceStormVisualParticles(stormVisual, stormType); } private void ForceStormVisualParticles(Component stormVisual, StormType stormType) { try { if ((Object)(object)stormVisual == (Object)null || !(((object)stormVisual).GetType().GetField("part")?.GetValue(stormVisual) is Array array) || array.Length == 0) { return; } int num = 0; foreach (object item in array) { if (item == null) { continue; } Type type = item.GetType(); if (string.Equals(type.FullName, "UnityEngine.ParticleSystem", StringComparison.Ordinal)) { object? obj = type.GetProperty("gameObject")?.GetValue(item); GameObject val = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)val != (Object)null && !val.activeInHierarchy) { val.SetActive(true); } object obj2 = type.GetProperty("emission")?.GetValue(item); obj2?.GetType().GetProperty("enabled")?.SetValue(obj2, true); MethodInfo method = type.GetMethod("Clear", new Type[1] { typeof(bool) }); if (method != null) { method.Invoke(item, new object[1] { true }); } MethodInfo method2 = type.GetMethod("Play", new Type[1] { typeof(bool) }); if (method2 != null) { method2.Invoke(item, new object[1] { true }); } num = checked(num + 1); } } if (num > 0) { CrowdControlMod.Instance.Logger.LogInfo((object)$"Forced StormVisual particles to play: stormType={stormType}, count={num}"); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to force StormVisual particles: " + ex.Message)); } } private void StopStormVisualParticles(Component stormVisual) { try { if ((Object)(object)stormVisual == (Object)null || !(((object)stormVisual).GetType().GetField("part")?.GetValue(stormVisual) is Array array) || array.Length == 0) { return; } foreach (object item in array) { if (item == null) { continue; } Type type = item.GetType(); if (string.Equals(type.FullName, "UnityEngine.ParticleSystem", StringComparison.Ordinal)) { MethodInfo method = type.GetMethod("Stop", new Type[1] { typeof(bool) }); if (method != null) { method.Invoke(item, new object[1] { true }); } else { type.GetMethod("Stop", Type.EmptyTypes)?.Invoke(item, null); } type.GetMethod("Clear", new Type[1] { typeof(bool) })?.Invoke(item, new object[1] { true }); } } FieldInfo field = ((object)stormVisual).GetType().GetField("quadRend"); if (field != null) { object? value = field.GetValue(stormVisual); MeshRenderer val = (MeshRenderer)((value is MeshRenderer) ? value : null); if ((Object)(object)val != (Object)null) { ((Renderer)val).enabled = false; } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to stop StormVisual particles: " + ex.Message)); } } private void LogStormVisualSelection(Component stormVisual, StormType stormType, string source) { try { GameObject val = (((Object)(object)stormVisual != (Object)null) ? stormVisual.gameObject : null); string text = (((Object)(object)val != (Object)null) ? ((Object)val).name : "(null)"); string text2 = (((Object)(object)val != (Object)null) ? val.tag : "(null)"); int num = 0; bool flag = false; bool flag2 = false; if ((Object)(object)stormVisual != (Object)null) { FieldInfo field = ((object)stormVisual).GetType().GetField("part"); if (field != null) { num = ((field.GetValue(stormVisual) is Array array) ? array.Length : 0); } FieldInfo field2 = ((object)stormVisual).GetType().GetField("quadRend"); if (field2 != null) { flag = field2.GetValue(stormVisual) != null; } flag2 = num > 0 || flag; } CrowdControlMod.Instance.Logger.LogInfo((object)$"StormVisual selected ({source}): stormType={stormType}, name={text}, tag={text2}, partLen={num}, hasQuad={flag}, hasRenderers={flag2}"); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("StormVisual selection log failed: " + ex.Message)); } } private void ActivateWindZone(Component windZone, StormType stormType) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0087: Unknown result type (might be due to invalid IL or missing references) try { Type type = ((object)windZone).GetType(); if ((Object)(object)windZone.gameObject.GetComponent() == (Object)null) { CrowdControlMod.Instance.Logger.LogWarning((object)"Wind zone has no PhotonView, cannot activate via RPC"); return; } FieldInfo field = type.GetField("currentWindDirection", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Vector3 val = Vector3.right; if (field != null) { val = (Vector3)field.GetValue(windZone); } MethodInfo method = type.GetMethod("RPCA_ToggleWind", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(windZone, new object[3] { true, val, 30f }); CrowdControlMod.Instance.Logger.LogInfo((object)"Activated wind zone via RPC"); } else { FieldInfo field2 = type.GetField("windActive", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { field2.SetValue(windZone, true); } } SetDayNightManagerStormFactor(stormType, activate: true, 1.5f); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error activating wind zone: " + ex.Message)); } } private void SetDayNightManagerStormFactor(StormType stormType, bool activate, float intensity = 1f) { try { Type type = Type.GetType("DayNightManager"); if (type == null) { type = Type.GetType("DayNightManager, Assembly-CSharp"); } if (type == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"DayNightManager type not found"); return; } PropertyInfo property = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public); object obj = null; if (property != null) { obj = property.GetValue(null); } else { FieldInfo field = type.GetField("instance", BindingFlags.Static | BindingFlags.Public); if (field != null) { obj = field.GetValue(null); } } if (obj == null) { CrowdControlMod.Instance.Logger.LogWarning((object)"DayNightManager.instance is null"); return; } float num = (activate ? intensity : 0f); switch (stormType) { case StormType.Rain: { FieldInfo field3 = type.GetField("rainstormWindFactor", BindingFlags.Instance | BindingFlags.Public); if (field3 != null) { field3.SetValue(obj, num); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set DayNightManager.rainstormWindFactor to {num}"); } break; } case StormType.Snow: { FieldInfo field4 = type.GetField("snowstormWindFactor", BindingFlags.Instance | BindingFlags.Public); if (field4 != null) { field4.SetValue(obj, num); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set DayNightManager.snowstormWindFactor to {num}"); } break; } case StormType.Wind: { FieldInfo field2 = type.GetField("rainstormWindFactor", BindingFlags.Instance | BindingFlags.Public); if (field2 != null) { field2.SetValue(obj, num); CrowdControlMod.Instance.Logger.LogInfo((object)$"Set DayNightManager.rainstormWindFactor (for wind) to {num}"); } break; } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Error setting DayNightManager storm factor: " + ex.Message)); } } [IteratorStateMachine(typeof(d__59))] private IEnumerator UpdateStormBounds(GameObject stormObj, Component windZone, Character character, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__59(0) { stormObj = stormObj, windZone = windZone, character = character, duration = duration }; } [IteratorStateMachine(typeof(d__60))] private IEnumerator CleanupStormAfterDelay(GameObject stormObj, Component windZone, float delay, StormType stormType) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__60(0) { <>4__this = this, stormObj = stormObj, windZone = windZone, delay = delay, stormType = stormType }; } private void DisableAllStormVisuals() { try { Object[] array = Object.FindObjectsOfTypeAll(typeof(StormVisual)); foreach (Object obj in array) { StormVisual val = (StormVisual)(object)((obj is StormVisual) ? obj : null); if ((Object)(object)val == (Object)null) { continue; } GameObject gameObject = ((Component)val).gameObject; if (!((Object)(object)gameObject == (Object)null)) { StopStormVisualParticles((Component)(object)val); if (gameObject.activeSelf) { gameObject.SetActive(false); } } } Shader.SetGlobalFloat("GlobalWind", 0f); } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to disable storm visuals: " + ex.Message)); } } private void ForceCleanupAllStorms() { //IL_0072: 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_0090: Unknown result type (might be due to invalid IL or missing references) try { DisableAllStormVisuals(); CleanupNewStormAudioObjects(); SetStormAudioObjectsActive(active: false); Shader.SetGlobalFloat("GlobalWind", 0f); Shader.SetGlobalFloat("_WeatherBlend", 0f); Shader.SetGlobalFloat("WindSkyBrightnessValue", 1f); Shader.SetGlobalFloat("WindFogDensity", 0f); Shader.SetGlobalFloat("WindFogTextureDensity", 0f); Shader.SetGlobalFloat("WindMixInfluence", 0f); Shader.SetGlobalColor("WindTint", Color.white); Shader.SetGlobalVector("WindSpeed", Vector4.zero); Shader.SetGlobalVector("WindRotationAxis", Vector4.zero); Shader.SetGlobalFloat("WindRotationAngle", 0f); Shader.SetGlobalFloat("WindSphereScale", 0f); SetDayNightManagerStormFactor(StormType.Rain, activate: false, 0f); SetDayNightManagerStormFactor(StormType.Snow, activate: false, 0f); SetDayNightManagerStormFactor(StormType.Wind, activate: false, 0f); WindChillZone[] array = Object.FindObjectsOfType(true); foreach (WindChillZone val in array) { if (!((Object)(object)val == (Object)null)) { val.windActive = false; val.windIntensity = 0f; val.windForce = 0f; } } Type type = Type.GetType("FogConfig, Assembly-CSharp") ?? Type.GetType("FogConfig"); if (type != null) { type.GetField("currentFog", BindingFlags.Static | BindingFlags.Public)?.SetValue(null, null); } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to force cleanup storms: " + ex.Message)); } } private void CaptureStormAudioBaseline() { try { if (stormAudioBaselineCaptured) { return; } StormAudioBaselineIds.Clear(); Object[] array = Object.FindObjectsOfTypeAll(typeof(StormAudio)); foreach (Object val in array) { if (val != (Object)null) { StormAudioBaselineIds.Add(val.GetInstanceID()); } } stormAudioBaselineCaptured = true; } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to capture StormAudio baseline: " + ex.Message)); } } private void CleanupNewStormAudioObjects() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) try { Object[] array = Object.FindObjectsOfTypeAll(typeof(StormAudio)); foreach (Object val in array) { if (!(val == (Object)null) && !StormAudioBaselineIds.Contains(val.GetInstanceID())) { GameObject gameObject = ((Component)(StormAudio)val).gameObject; if ((Object)(object)gameObject != (Object)null) { Object.Destroy((Object)(object)gameObject); } } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to clean new StormAudio objects: " + ex.Message)); } finally { StormAudioBaselineIds.Clear(); stormAudioBaselineCaptured = false; } } private void SetStormAudioObjectsActive(bool active) { try { Object[] array = Object.FindObjectsOfTypeAll(typeof(StormAudio)); foreach (Object obj in array) { StormAudio val = (StormAudio)(object)((obj is StormAudio) ? obj : null); if (!((Object)(object)val == (Object)null)) { GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject != (Object)null) { gameObject.SetActive(active); } } } } catch (Exception ex) { CrowdControlMod.Instance.Logger.LogWarning((object)("Failed to set StormAudio objects active: " + ex.Message)); } } } [Effect(new string[] { "teleport_random_player", "teleport_host_player" }, 0f, true)] public class PlayerTeleport : Effect { public PlayerTeleport(CrowdControlMod mod, NetworkClient client) : base(mod, client) { } public static bool HasValidRandomPlayerTargets() { Character character = Character.localCharacter; if ((Object)(object)character == (Object)null || !((Behaviour)character).isActiveAndEnabled) { return false; } return Character.AllCharacters.Any((Character c) => (Object)(object)c != (Object)(object)character && !c.data.dead && !c.data.fullyPassedOut); } public override EffectResponse Start(EffectRequest request) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) Character character = Character.localCharacter; if ((Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)Character.localCharacter || !((Behaviour)character).isActiveAndEnabled) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (!Object.op_Implicit((Object)(object)character)) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } if (request.code == "teleport_random_player") { List list = Character.AllCharacters.Where((Character c) => (Object)(object)c != (Object)(object)character && !c.data.dead && !c.data.fullyPassedOut).ToList(); if (list.Count == 0) { CrowdControlMod.Instance.Client.HideEffects("teleport_random_player"); return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "No other players to teleport to"); } Character val = list[Random.Range(0, list.Count)]; Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 1.5f + Vector3.up; Transform[] componentsInChildren = ((Component)((Component)val).transform).GetComponentsInChildren(); foreach (Transform val3 in componentsInChildren) { if (((Object)val3).name == "Hip") { val2 = val3.position + val3.forward * 1.5f + Vector3.up; } } Rigidbody component = ((Component)character).GetComponent(); if ((Object)(object)component != (Object)null) { component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; component.Sleep(); } character.WarpPlayerRPC(val2, true); if ((Object)(object)component != (Object)null) { component.WakeUp(); } } return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } } [Effect(new string[] { "turn_into_ghost" }, 0f, true)] public class TurnIntoGhostEffect : Effect { [CompilerGenerated] private CrowdControlMod P; private static bool _active; public TurnIntoGhostEffect(CrowdControlMod mod, NetworkClient client) { P = mod; base..ctor(P, client); } public override EffectResponse Start(EffectRequest request) { if (_active) { return EffectResponse.Retry(((SimpleJSONMessage)request).ID, (string)null); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EffectResponse.Failure(((SimpleJSONMessage)request).ID, (StandardErrors)16642); } _active = true; if (TryTurnIntoGhost(localCharacter)) { ResetGhostAfterDelay(localCharacter, request); return EffectResponse.Success(((SimpleJSONMessage)request).ID, (string)null); } _active = false; return EffectResponse.Failure(((SimpleJSONMessage)request).ID, "Failed to turn into ghost"); } private async Task ResetGhostAfterDelay(Character character, EffectRequest request) { await Task.Delay(checked((int)request.duration.Value)); TryTurnBackToNormal(character); _active = false; } private bool TryTurnIntoGhost(Character character) { try { PropertyInfo property = ((object)character).GetType().GetProperty("Ghost"); if (property != null && property.GetValue(character) != null) { P.Logger.LogInfo((object)"[TurnIntoGhostEffect] Character is already a ghost"); return true; } GameObject val = FindGhostPrefab(); if ((Object)(object)val != (Object)null) { PlayerGhost component = Object.Instantiate(val).GetComponent(); if ((Object)(object)component != (Object)null) { MethodInfo method = ((object)component).GetType().GetMethod("RPCA_InitGhost", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { PhotonView component2 = ((Component)character).GetComponent(); if ((Object)(object)component2 != (Object)null) { method.Invoke(component, new object[2] { component2, component2 }); if (property != null) { property.SetValue(character, component); P.Logger.LogInfo((object)"[TurnIntoGhostEffect] Successfully turned character into ghost"); return true; } } } } } MakeCharacterGhostlike(character); return true; } catch (Exception ex) { P.Logger.LogError((object)("[TurnIntoGhostEffect] Error turning into ghost: " + ex.Message)); return false; } } private void MakeCharacterGhostlike(Character character) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)character).GetComponentsInChildren(); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val != (Object)null)) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 != (Object)null) { Color color = val2.color; color.a = 0.5f; val2.color = color; if (val2.HasProperty("_Mode")) { val2.SetFloat("_Mode", 3f); } } } } P.Logger.LogInfo((object)"[TurnIntoGhostEffect] Made character ghostlike with transparency"); } private GameObject FindGhostPrefab() { GameObject[] array = Object.FindObjectsOfType(); foreach (GameObject val in array) { if (((Object)val).name.ToLower().Contains("ghost") && (Object)(object)val.GetComponent() != (Object)null) { return val; } } return null; } private void TryTurnBackToNormal(Character character) { //IL_007d: 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_0092: Unknown result type (might be due to invalid IL or missing references) try { PropertyInfo property = ((object)character).GetType().GetProperty("Ghost"); if (property != null) { object value = property.GetValue(character); if (value != null) { Object val = (Object)((value is Object) ? value : null); if (val != null) { Object.Destroy(val); } property.SetValue(character, null); } } Renderer[] componentsInChildren = ((Component)character).GetComponentsInChildren(); foreach (Renderer val2 in componentsInChildren) { if (!((Object)(object)val2 != (Object)null)) { continue; } Material[] materials = val2.materials; foreach (Material val3 in materials) { if ((Object)(object)val3 != (Object)null) { Color color = val3.color; color.a = 1f; val3.color = color; if (val3.HasProperty("_Mode")) { val3.SetFloat("_Mode", 0f); } } } } P.Logger.LogInfo((object)"[TurnIntoGhostEffect] Character returned to normal"); } catch (Exception ex) { P.Logger.LogError((object)("[TurnIntoGhostEffect] Error returning to normal: " + ex.Message)); } } } }