using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using EventsIO; using EventsIO.Interfaces; using HarmonyLib; using Mirror; using ModHelper; using ModHelper.Interfaces; using ModHelper.Wrappers; using ModHelperUnity.Interfaces; using ModHelperUnity.TypedNotify; using ModHelperUnity.Utilities; using Newtonsoft.Json; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; using UnityEngine.SceneManagement; using WebSocketIO; using bft_mod.Commands.Base; using bft_mod.Commands.Interfaces; using bft_mod.Patchers; using bft_mod.Services; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("sbg_bft_mod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("BFT LLC")] [assembly: AssemblyProduct("ChaosTricksMod")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("BFT")] [assembly: ComVisible(false)] [assembly: Guid("95844EA6-4892-4399-9DA6-6B15C259038B")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.1.0.0")] namespace bft_mod { [BepInPlugin("bft.chaostricks", "Chaos Tricks", "1.1.1")] internal class BepInExPlugin : BaseUnityPlugin { public const string GUID = "bft.chaostricks"; public const string NAME = "Chaos Tricks"; private GameObject hookObj; private bool isPatched; public void Awake() { try { SettingsUtils.BaseFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); SceneManager.sceneLoaded += OnSceneLoaded; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)string.Format("{0} v{1} error: {2}", "Chaos Tricks", "1.1.1", arg)); } } private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown try { ((HelperLog)Utils.logger).Log((object)("OnSceneLoaded triggered: " + ((Scene)(ref scene)).name)); if (!isPatched) { ((HelperLog)Utils.logger).LogInfo((object)"Background task: trying to create mod instance"); hookObj = new GameObject(); Object.DontDestroyOnLoad((Object)(object)hookObj); hookObj.AddComponent(); hookObj.SetActive(true); isPatched = true; SceneManager.sceneLoaded -= OnSceneLoaded; } } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)string.Format("{0} v{1} OnSceneLoaded error: {2}", "Chaos Tricks", "1.1.1", arg)); } } } public static class GameUtils { public static IEnumerable Players => GameManager.RemotePlayers.Where((PlayerInfo p) => (Object)(object)p != (Object)null && !IsPlayerSpectator(p)); public static bool IsHost() { try { return NetworkServer.active; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"IsHost, detecting game host error: {arg}"); return true; } } public static ulong GetCurrentPlayerGUID() { try { return GameManager.LocalPlayerId.Guid; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"GetCurrentPlayerGUID error: {arg}"); return ulong.MaxValue; } } public static PlayerInfo GetCurrentPlayer() { try { return GameManager.LocalPlayerInfo; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"GetCurrentNetworkPlayerID, detecting player id error: {arg}"); return null; } } public static string GetPlayerName(PlayerInfo p) { try { return p.PlayerId.PlayerName; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"GetPlayerName error: {arg}"); return ""; } } public static ulong GetPlayerGUID(PlayerInfo p) { try { return p.PlayerId.Guid; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"GetPlayerGUID error: {arg}"); return ulong.MaxValue; } } public static bool IsPlayerSpectator(PlayerInfo p) { PlayerSpectator asSpectator = p.AsSpectator; if ((Object)(object)asSpectator == (Object)null) { return false; } return asSpectator.IsSpectating; } public static PlayerInfo GetPlayerByNetworkID(ulong id) { foreach (PlayerInfo player in Players) { if (GetPlayerGUID(player) == id) { return player; } } return null; } public static void ApplyForceToPlayer(PlayerInfo p, in Vector3 dirForce, in Vector3 dirCartForce) { //IL_0001: 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_0052: Unknown result type (might be due to invalid IL or missing references) GolfCartInfo golfCart = p.ActiveGolfCartSeat.golfCart; if ((Object)(object)golfCart != (Object)null && ((NetworkBehaviour)golfCart).authority && (Object)(object)golfCart.AsEntity != (Object)null) { Rigidbody rigidbody = golfCart.AsEntity.Rigidbody; if ((Object)(object)rigidbody == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"ApplyForceToPlayer cart Rigidbody is null"); } else { rigidbody.AddForce(dirCartForce, (ForceMode)1); } return; } PlayerMovement movement = p.Movement; if ((Object)(object)movement == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"ApplyForceToPlayer movement is null"); return; } Rigidbody component = ((Component)movement).GetComponent(); if ((Object)(object)component == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"ApplyForceToPlayer Rigidbody is null"); } else { component.AddForce(dirForce, (ForceMode)1); } } public static Vector3 GetLocalPlayerForwardOffset(float offsetForward = 1f, float offsetHeight = 0.5f) { //IL_001c: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GetCurrentPlayer() == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"GetLocalPlayerForwardOffset player is null"); return Vector3.zero; } PlayerMovement movement = GetCurrentPlayer().Movement; if ((Object)(object)movement == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"GetLocalPlayerForwardOffset movement is null"); return Vector3.zero; } Transform transform = ((Component)movement).transform; Vector3 position = transform.position; Vector3 forward = transform.forward; return position + ((Vector3)(ref forward)).normalized * offsetForward + new Vector3(0f, offsetHeight, 0f); } public static Vector3 GetLocalPlayerForwardWay() { //IL_002f: 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) PlayerMovement movement = GetCurrentPlayer().Movement; if ((Object)(object)movement == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"GetLocalPlayerForwardOffset movement is null"); return Vector3.forward; } return ((Component)movement).transform.forward; } public static Vector3 GetLocalPlayerRightWay() { //IL_002f: 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) PlayerMovement movement = GetCurrentPlayer().Movement; if ((Object)(object)movement == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"GetLocalPlayerRightWay movement is null"); return Vector3.forward; } return ((Component)movement).transform.right; } public static Vector3 GetLocalPlayerUpWay() { //IL_002f: 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) PlayerMovement movement = GetCurrentPlayer().Movement; if ((Object)(object)movement == (Object)null) { ((HelperLog)Utils.logger).LogWarning((object)"GetLocalPlayerUpWay movement is null"); return Vector3.up; } return ((Component)movement).transform.up; } public static void TeleportPlayer(PlayerInfo p, in Vector3 pos) { //IL_0007: 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) p.Movement.Teleport(pos, p.Movement.Rotation, true); } } public sealed class InteractiveMod : MonoBehaviour { public static InteractiveMod inst; public const string MOD_VERSION = "1.1.1"; private readonly ServiceProvider serviceProvider = ServiceProvider.inst; private readonly BufferedLogger logger = Utils.logger; private ScheduleManager systemScheduleManager; private ScheduleManager scheduleManager; private EventEmitter eventEmitter; private WebSocketEventsReader eventsReader; private IEventsDataParser eventsParser; private ICommandManager commandManager; private IComponentTypedNotify notifyManager; private CommandConsole console; private Dictionary commands; private TranslationService translationService; private LimitedLogWrapper limitedLogger; private LimitedLogWrapper limitedSceneLogger; private const string DEFAULT_LANG = "en"; private string lastUsedLang = "en"; private bool readyToActivateEvents; private readonly List forceEndEvents = new List(); public void Awake() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown inst = this; ((HelperLog)logger).ClearLogBySize(200000, (Action)Debug.LogError); limitedLogger = new LimitedLogWrapper(100, (IDebugLogger)(object)Utils.logger); limitedSceneLogger = new LimitedLogWrapper(50, (IDebugLogger)(object)Utils.logger); ((HelperLog)logger).LogInfo((object)"BFT mod Awake"); ((HelperLog)logger).LogInfo((object)"mod version 1.1.1"); FlushLog(); MainPatcher.InitPatch(); SubscribeOnLangChanged(); } private void SubscribeOnLangChanged() { try { LocalizationManager.LanguageChanged += OnLangChanged; } catch (Exception arg) { ((HelperLog)logger).LogError((object)$"mod lang subscribe error: {arg}"); } } private void UnsubscribeOnLangChanged() { try { LocalizationManager.LanguageChanged -= OnLangChanged; } catch (Exception arg) { ((HelperLog)logger).LogError((object)$"mod lang unsubscribe error: {arg}"); } } private void OnLangChanged() { SetLangBasedOnGame(); ((HelperLog)logger).LogInfo((object)("mod lang is changed to '" + lastUsedLang + "'")); } private void SetLangBasedOnGame() { try { lastUsedLang = LocalizationManager.CurrentLanguage; } catch (Exception arg) { ((HelperLog)logger).LogError((object)$"mod lang initiation error: {arg}"); lastUsedLang = "en"; } } public void Start() { ((HelperLog)logger).LogInfo((object)"BFT mod Start"); try { JsonUtils.RegisterCustomGenerator((Func)(() => (IJsonUtils)(object)new JsonParser())); ((HelperLog)logger).LogInfo((object)"init mod services"); InitServices(); ((HelperLog)logger).LogInfo((object)"init mod readers"); InitReaders(); ((HelperLog)logger).LogInfo((object)"init mod commands"); InitCommands(needValidate: false); ((HelperLog)logger).LogInfo((object)"mod initiation ends"); } catch (Exception arg) { ((HelperLog)logger).LogError((object)$"mod initiation error: {arg}"); } FlushLog(); SetLangBasedOnGame(); } public void OnDestroy() { ((HelperLog)logger).LogInfo((object)"BFT mod OnDestroy"); FlushLog(); SceneManager.sceneLoaded -= SceneLoaded; UnsubscribeOnLangChanged(); ((HelperLog)logger).LogInfo((object)"BFT mod OnDestroy ends"); } private void FlushLog() { logger.Flush(true); } private void InitServices() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown eventEmitter = new EventEmitter(); serviceProvider.RegisterEventEmitter(eventEmitter); systemScheduleManager = new ScheduleManager((ILogger)(object)logger, 0); serviceProvider.RegisterSystemScheduleManager(systemScheduleManager); systemScheduleManager.NewPeriodicTask(new PeriodicTaskData { periodicAction = FlushLog, finishAction = FlushLog, periodInSec = 5f }, false); scheduleManager = new ScheduleManager((ILogger)(object)logger, 0); serviceProvider.RegisterScheduleManager(scheduleManager); translationService = new TranslationService(); translationService.LoadData(); serviceProvider.RegisterTranslationService(translationService); if (notifyManager == null) { notifyManager = (IComponentTypedNotify)(object)((Component)this).gameObject.AddComponent(); } notifyManager.ForcePostInit(Utils.modFolder, (IDebugLogger)(object)Utils.logger, (Func)null); SceneManager.sceneLoaded += SceneLoaded; } private void SceneLoaded(Scene scene, LoadSceneMode mode) { ((HelperLog)Utils.logger).LogInfo((object)("scene loaded: " + ((Scene)(ref scene)).name)); readyToActivateEvents = true; } private void InitReaders() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown console = new CommandConsole((IDebugLogger)(object)logger, (List)null); eventsParser = (IEventsDataParser)new EventsDataParser((Action)((HelperLog)logger).LogWarning); eventsReader = new WebSocketEventsReader((Action)ProcessEvent, eventsParser, (Action)((HelperLog)logger).LogInfo, (Action)((HelperLog)logger).LogInfo, 0.5f, 1f, 0.5f, true); eventsReader.InitDefaultSocket(Utils.modFolder, "chaostricks_sbgolf", 13715, "127.0.0.1"); Action defaultOnConfig = eventsReader.SocketHandler.OnConfigMessage; eventsReader.SocketHandler.OnConfigMessage = delegate(string s) { defaultOnConfig?.Invoke(s); SettingsManager.QueueUpdateSettings(eventsReader.Settings); }; eventsReader.OpenSocket(true); } public void InitCommands(bool needValidate) { //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown forceEndEvents.Clear(); Type type = typeof(IInternalStandaloneCommand); IEnumerable enumerable = from p in Assembly.GetExecutingAssembly().GetTypes() where type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract select p; ((HelperLog)logger).LogInfo((object)$"found {enumerable.Count()} commands"); commands = new Dictionary(); foreach (Type item2 in enumerable) { IInternalStandaloneCommand internalStandaloneCommand = Activator.CreateInstance(item2) as IInternalStandaloneCommand; if (internalStandaloneCommand != null) { console.RegisterCommand((IConsoleCommand)internalStandaloneCommand); if (commands.ContainsKey(((IConsoleCommand)internalStandaloneCommand).Id)) { ((HelperLog)logger).LogWarning((object)("repeated id command " + ((IConsoleCommand)internalStandaloneCommand).Id + ". The command will replace existed.")); } commands[((IConsoleCommand)internalStandaloneCommand).Id] = internalStandaloneCommand; if (internalStandaloneCommand is IForceEnd item) { forceEndEvents.Add(item); } ((HelperLog)logger).LogInfo((object)("init command '" + ((IConsoleCommand)internalStandaloneCommand).Id + "' complete")); } else { ((HelperLog)logger).LogError((object)("init command '" + ((IConsoleCommand)internalStandaloneCommand).Id + "' failed")); } } ((HelperLog)logger).LogInfo((object)$"found {commands.Count} commands and {forceEndEvents.Count} timers"); ((HelperLog)logger).LogInfo((object)"init HelperCommandManager"); commandManager = (ICommandManager)new HelperCommandManagerFormatted((IDebugLogger)(object)logger); commandManager.InitFromFile(Utils.GetRelativeModFilePath("commands.data")); int num = commandManager.GetCommands().Length; ((HelperLog)logger).LogInfo((object)$"found {num} events"); if (!needValidate) { return; } ((HelperLog)logger).LogInfo((object)"validate commands"); string[] array = commandManager.GetCommands(); foreach (string text in array) { if (!console.IsValidCommandLine(text?.Trim())) { ((HelperLog)logger).LogError((object)("Command line '" + text + "' invalid")); } } ((HelperLog)logger).LogInfo((object)"init HelperCommandManager ends"); } private void ProcessEvent(IEventsData data) { if (string.IsNullOrEmpty(data.EventID)) { ((HelperLog)logger).LogError((object)"ProcessEvent eventID is null or empty"); return; } if (!GameUtils.IsHost()) { ChaosModNetwork.ActivateEventOnHostSide(GameUtils.GetCurrentPlayerGUID(), data); return; } ActivateEventLocally(data); ((HelperDebugLog)Utils.logger).LogDebugInfo((object)$"network data, p count {GameUtils.Players.Count()}, all {SettingsManager.Data.applyEffectsToAll}"); if (GameUtils.Players.Count() >= 1) { ChaosModNetwork.ActivateNetworkEventByHost(commandManager, commands, data); } } private void ActivateEventLocally(IEventsData data) { string eventID = data.EventID; if (string.IsNullOrEmpty(eventID)) { ((HelperLog)logger).LogError((object)"ActivateEventLocally eventID is null or empty"); return; } ((HelperLog)logger).LogInfo((object)("Try to execute event: '" + eventID + "'")); string text = commandManager.GetCommandData(eventID, true)?.Trim(); try { ((HelperLog)logger).LogInfo((object)("Command: " + text)); if (console.RunCommand(text, data, (Action)null)) { ((HelperLog)logger).LogInfo((object)("Event '" + data.EventID + "' executing is completed")); if (notifyManager != null) { notifyManager.AddNotifyToQueue(data, translationService.translation, (Func)null, true); } } else { ((HelperDebugLog)logger).LogDebugError((object)("Event '" + data.EventID + "' executing is failed")); } } catch (Exception arg) { ((HelperLog)logger).LogError((object)$"ActivateEventLocally '{data.EventID}' unexpected error: {arg}"); } } private void CancelEvents() { try { ((HelperLog)Utils.logger).LogInfo((object)"CancelEvents triggered"); foreach (IForceEnd forceEndEvent in forceEndEvents) { try { forceEndEvent.ForceEnd(); } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"CancelEvents force end for {((IConsoleCommand)forceEndEvent).Id} error: {arg}"); } } if (notifyManager != null) { notifyManager.ClearNotifyQueue(); notifyManager.StopCurrentNotify(); } } catch (Exception arg2) { ((HelperLog)Utils.logger).LogError((object)$"CancelEvents {arg2}"); } } public void Update() { try { float deltaTime = Time.deltaTime; systemScheduleManager.OnUpdate(deltaTime); SettingsManager.OnUpdate(); scheduleManager.OnUpdate(deltaTime); if (readyToActivateEvents && (Object)(object)GameUtils.GetCurrentPlayer() != (Object)null) { eventEmitter.TriggerOnUpdateEvent(this, deltaTime); ((EventsReaderOnFrame)eventsReader).ReadAndProcessAllWithDelayOnFrame(deltaTime); ChaosModNetwork.ProcessNetworkEvents(commandManager, commands, ActivateEventLocally); } } catch (Exception arg) { limitedLogger.LogError((object)$"OnUpdate error: {arg}"); } } public void ReinitMod() { try { ((HelperLog)logger).LogInfo((object)"ReinitMod starts"); FlushLog(); CancelEvents(); InitCommands(needValidate: false); notifyManager.ForcePostInit(Utils.modFolder, (IDebugLogger)(object)Utils.logger, (Func)null); ((HelperLog)logger).LogInfo((object)"ReinitMod ends"); } catch (Exception arg) { ((HelperLog)logger).LogError((object)$"ReinitMod error: {arg}"); } FlushLog(); } } internal sealed class JsonParser : IJsonUtils { public T FromFile(string path) where T : class { using StreamReader streamReader = new StreamReader(path); return FromString(streamReader.ReadToEnd()); } public T FromString(string s) where T : class { return JsonConvert.DeserializeObject(s); } } public static class Utils { public static readonly string modFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); public static readonly BufferedLogger logger = new BufferedLogger(modFolder, "latest_log.txt", false, 50); public static string GetRelativeModFilePath(string fname) { return Path.Combine(modFolder, fname); } } } namespace bft_mod.Services { public static class ExtensionHelper { public static string ReadStringOrDefault(this IEnumerator e, string defaultVal = null) { if (!e.MoveNext()) { return defaultVal; } return e.Current; } } public class ChaosModNetwork { public struct DataSource { public ulong playerID; public string eventID; public string lang; public string username; public DataSource(ulong id, IEventsData data) { playerID = id; eventID = data.EventID; lang = data.Lang; username = data.Username; } public DataSource(IEnumerator e) { playerID = ulong.Parse(e.ReadStringOrDefault()); eventID = e.ReadStringOrDefault(""); lang = e.ReadStringOrDefault("en"); username = e.ReadStringOrDefault("unknown"); } public EventsData ToEventData() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_002a: Expected O, but got Unknown return new EventsData { Username = username, EventID = eventID, Lang = lang }; } } private static readonly Queue commandQueue = new Queue(); public const ulong ANY_PLAYER_ID = ulong.MaxValue; private const string CHAT_PREFIX = "[CHAOS_TRICKS]"; private const string SIDE_HOST = "1"; private const string SIDE_CLIENT = "2"; private const string CHECK_BLOCK = "ㅤ"; public static bool HandleChatMessage(string msg, PlayerInfo sender) { ((HelperDebugLog)Utils.logger).LogDebugInfo((object)("HandleChatMessage debug: " + msg)); if (msg == null || !msg.StartsWith("[CHAOS_TRICKS]") || !msg.EndsWith("ㅤ")) { return false; } if (msg.Length == "[CHAOS_TRICKS]".Length) { ((HelperLog)Utils.logger).LogWarning((object)"HandleChatMessage warn: wrong msg len"); return true; } IEnumerable enumerable = from x in msg.Substring("[CHAOS_TRICKS]".Length, msg.Length - "[CHAOS_TRICKS]".Length - "ㅤ".Length).Split(new char[1] { '|' }) where !string.IsNullOrWhiteSpace(x) select x.Trim(); if (enumerable.Count() < 3) { ((HelperLog)Utils.logger).LogError((object)$"HandleChatMessage error: wrong items count, got {enumerable.Count()}"); } IEnumerator enumerator = enumerable.GetEnumerator(); string text = enumerator.ReadStringOrDefault(); DataSource data = new DataSource(enumerator); if (!(text == "1")) { if (text == "2") { ActivateClientEvent_ChatCallback(data); } else { ((HelperLog)Utils.logger).LogError((object)("HandleChatMessage error: wrong target side " + text)); } } else { ActivateHostEvent_ChatCallback(data); } return true; } private static void ActivateHostEvent_ChatCallback(DataSource data) { try { if (GameUtils.IsHost()) { ((HelperLog)Utils.logger).LogInfo((object)"ChaosModNetwork->ActivateHostEvent_ChatCallback triggered"); AddEvent(data); } } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ActivateHostEvent_ChatCallback error: {arg}"); } } private static void ActivateClientEvent_ChatCallback(DataSource data) { try { if (!GameUtils.IsHost()) { ((HelperLog)Utils.logger).LogInfo((object)"ChaosModNetwork->ActivateClientEvent_ChatCallback triggered"); AddEvent(data); } } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ActivateClientEvent_ChatCallback error: {arg}"); } } public static void ActivateEventOnHostSide(ulong playerID, IEventsData data) { ((HelperLog)Utils.logger).LogInfo((object)$"ChaosModNetwork->ActivateEventOnHostSide triggered for {playerID} {data.EventID}"); try { TextChatManager.SendChatMessage(string.Format("{0}{1}|{2}|{3}|{4}|{5}{6}", "[CHAOS_TRICKS]", "1", playerID, data.EventID, data.Lang, data.Username, "ㅤ")); } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ActivateEventOnHostSide error: {arg}"); } } public static void ActivateEventForOthers(DataSource data) { ((HelperLog)Utils.logger).LogInfo((object)$"ChaosModNetwork->ActivateEventForOthers triggered for {data.playerID} {data.eventID}"); try { TextChatManager.SendChatMessage(string.Format("{0}{1}|{2}|{3}|{4}|{5}{6}", "[CHAOS_TRICKS]", "2", data.playerID, data.eventID, data.lang, data.username, "ㅤ")); } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ActivateEventForOthers error: {arg}"); } } private static bool AnyCommandRequiresOnlyApplyOnce(string[] eventCommands, Dictionary commands, out bool sendToOtherClients) { for (int i = 0; i < eventCommands.Length; i++) { string key = CommandConsole.ParseArgs(eventCommands[i])[0]; try { if (commands[key] is INetworkApplyOnce networkApplyOnce) { sendToOtherClients = networkApplyOnce.ShouldTriggerClientSideForOthers(); return true; } } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->AnyCommandRequiresNetworkSync: {arg}"); sendToOtherClients = false; return false; } } sendToOtherClients = false; return false; } private static void AddEvent(DataSource data) { ((HelperLog)Utils.logger).LogInfo((object)$"ChaosModNetwork->AddEvent triggered for {data.playerID} {data.eventID}"); if (commandQueue == null) { ((HelperLog)Utils.logger).LogError((object)"ChaosModNetwork->AddEvent an attempt to store events before initiating"); } else { commandQueue.Enqueue(data); } } public static void ProcessNetworkEvents(ICommandManager cm, Dictionary commands, Action activateEventLocally) { bool flag = GameUtils.IsHost(); while (commandQueue.Count > 0) { try { if (flag) { ProcessNetworkEvents_OnHostSide(cm, commands, activateEventLocally); } else { ProcessNetworkEvents_OnClientSide(activateEventLocally); } } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ProcessNetworkEvents (host {flag}): {arg}"); } } } private static void ProcessNetworkEvents_OnHostSide(ICommandManager cm, Dictionary commands, Action activateEventLocally) { DataSource data = commandQueue.Dequeue(); ((HelperLog)Utils.logger).LogInfo((object)$"ChaosModNetwork->ProcessNetworkEvents_OnHostSide event id {data.eventID} for {data.playerID}"); if (data.playerID == ulong.MaxValue || data.playerID == GameUtils.GetCurrentPlayerGUID()) { ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ProcessNetworkEvents_OnHostSide should not get here any player ID or host ID (got {data.playerID})"); return; } string text = cm.GetCommandData(data.eventID, true)?.Trim(); if (string.IsNullOrEmpty(text)) { ((HelperLog)Utils.logger).LogWarning((object)"ChaosModNetwork->ProcessNetworkEvents_OnHostSide can't find commands"); return; } string[] eventCommands = CommandConsole.ParseCommandLine(text); ulong num = (SettingsManager.Data.applyEffectsToAll ? ulong.MaxValue : data.playerID); if (AnyCommandRequiresOnlyApplyOnce(eventCommands, commands, out var sendToOtherClients)) { ulong playerID = data.playerID; if (sendToOtherClients) { data.playerID = ulong.MaxValue; } ActivateEventForOthers(data); ApplyCommandsHostEffectsForOthers(eventCommands, playerID, commands); } else { data.playerID = num; ActivateEventForOthers(data); if (SettingsManager.Data.applyEffectsToAll) { activateEventLocally((IEventsData)(object)data.ToEventData()); } ApplyCommandsHostEffectsForOthers(eventCommands, num, commands); } } public static void ActivateNetworkEventByHost(ICommandManager cm, Dictionary commands, IEventsData data) { string[] eventCommands = CommandConsole.ParseCommandLine(cm.GetCommandData(data.EventID, true)?.Trim()); if (AnyCommandRequiresOnlyApplyOnce(eventCommands, commands, out var sendToOtherClients) && sendToOtherClients) { ActivateEventForOthers(new DataSource(ulong.MaxValue, data)); } else if (SettingsManager.Data.applyEffectsToAll) { ActivateEventForOthers(new DataSource(ulong.MaxValue, data)); ApplyCommandsHostEffectsForOthers(eventCommands, ulong.MaxValue, commands); } } private static void ApplyCommandsHostEffectsForOthers(string[] eventCommands, ulong targetPlayerID, Dictionary commands) { PlayerInfo[] array; if (targetPlayerID == ulong.MaxValue) { PlayerInfo currentPlayer = GameUtils.GetCurrentPlayer(); array = GameUtils.Players.Where((PlayerInfo ch) => (Object)(object)ch != (Object)(object)currentPlayer).ToArray(); } else { if (targetPlayerID == GameUtils.GetCurrentPlayerGUID()) { ((HelperLog)Utils.logger).LogError((object)"ChaosModNetwork->ApplyCommandsHostEffectsForOthers: target player is host"); return; } PlayerInfo playerByNetworkID = GameUtils.GetPlayerByNetworkID(targetPlayerID); if ((Object)(object)playerByNetworkID == (Object)null) { ((HelperLog)Utils.logger).LogError((object)"ChaosModNetwork->ApplyCommandsHostEffectsForOthers: null target"); return; } array = (PlayerInfo[])(object)new PlayerInfo[1] { playerByNetworkID }; } PlayerInfo[] array2 = array; foreach (PlayerInfo val in array2) { foreach (string text in eventCommands) { string[] array3 = CommandConsole.ParseArgs(text); string key = array3[0]; try { if (commands[key] is IHostNetworkCommand hostNetworkCommand) { hostNetworkCommand.ExecuteHostAction(array3.Skip(1), val); } } catch (Exception ex) { string playerName = GameUtils.GetPlayerName(val); ulong playerGUID = GameUtils.GetPlayerGUID(val); ((HelperLog)Utils.logger).LogError((object)$"ChaosModNetwork->ApplyCommandsHostEffectsForOthers cmd {text}, target {playerName}, id {playerGUID}: {ex}"); } } } } private static void ProcessNetworkEvents_OnClientSide(Action activateEventLocally) { DataSource dataSource = commandQueue.Dequeue(); if (dataSource.playerID == ulong.MaxValue || dataSource.playerID == GameUtils.GetCurrentPlayerGUID()) { ((HelperLog)Utils.logger).LogInfo((object)$"ChaosModNetwork->ProcessNetworkEvents_OnClientSide event id {dataSource.eventID} for {dataSource.playerID}"); activateEventLocally((IEventsData)(object)dataSource.ToEventData()); } else { ((HelperLog)Utils.logger).LogInfo((object)$"ChaosModNetwork->ProcessNetworkEvents_OnClientSide event id {dataSource.eventID} for other player {dataSource.playerID}. Skipped."); } } } internal static class ArgsReaderFactory { public static CommandArgsReader NewReader(IEnumerable args) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown return new CommandArgsReader(args, (ILogger)(object)Utils.logger); } } public sealed class EventEmitter { private enum Event { OnUpdate, OnConfigChangedThreadSafe } private class EmitterAction { public string id; public Action action; } private readonly ILogger logger = (ILogger)new LimitedLogWrapper(100, (IDebugLogger)(object)Utils.logger); private readonly Dictionary> eventHandlers; public EventEmitter() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown eventHandlers = new Dictionary>(); foreach (Event item in Enum.GetValues(typeof(Event)).OfType()) { eventHandlers[item] = new List(); } } private void ReplaceOrAddHandler(Event key, string id, Action handler) { if (id != null) { eventHandlers[key].RemoveAll((EmitterAction action) => action.id == id); } eventHandlers[key].Add(new EmitterAction { action = handler, id = id }); } private void TriggerEvent(Event key, object sender, object data) { try { if (!eventHandlers.TryGetValue(key, out var value)) { return; } foreach (EmitterAction item in value) { try { item.action(sender, data); } catch (Exception arg) { logger.LogError((object)$"EventEmitter->TriggerEvent inner {key} error: {arg}"); } } } catch (Exception arg2) { logger.LogError((object)$"EventEmitter->TriggerEvent {key} error: {arg2}"); } } public void ReplaceOrAddOnUpdateHandler(string id, Action handler) { ReplaceOrAddHandler(Event.OnUpdate, id, delegate(object sender, object data) { handler(sender, (float)data); }); } public void TriggerOnUpdateEvent(object sender, float dtInSec) { TriggerEvent(Event.OnUpdate, sender, dtInSec); } public void ReplaceOrAddOnConfigChanged_ThreadSafeHandler(string id, Action handler) { ReplaceOrAddHandler(Event.OnConfigChangedThreadSafe, id, delegate(object sender, object settings) { handler(sender, (SettingsData)settings); }); } public void TriggerOnConfigChangedEvent_ThreadSafe(object sender, SettingsData settings) { TriggerEvent(Event.OnConfigChangedThreadSafe, sender, settings); } } public sealed class ServiceProvider { public static readonly ServiceProvider inst = new ServiceProvider(); public ScheduleManager systemScheduleManager; public ScheduleManager scheduleManager; public EventEmitter eventEmitter; public TranslationService translationService; public void RegisterSystemScheduleManager(ScheduleManager systemScheduleManager) { this.systemScheduleManager = systemScheduleManager; } public void RegisterScheduleManager(ScheduleManager scheduleManager) { this.scheduleManager = scheduleManager; } public void RegisterEventEmitter(EventEmitter eventEmitter) { this.eventEmitter = eventEmitter; } public void RegisterTranslationService(TranslationService translationService) { this.translationService = translationService; } } public sealed class SettingsData { public bool applyEffectsToAll = true; } public static class SettingsManager { private static SettingsData newData; public static SettingsData Data { get; private set; } = new SettingsData(); public static void QueueUpdateSettings(SettingsData data) { newData = data; } public static void OnUpdate() { if (newData != null) { Data = newData; ServiceProvider.inst.eventEmitter.TriggerOnConfigChangedEvent_ThreadSafe(null, newData); newData = null; } } } public class TranslationService { public readonly ITranslation translation; public TranslationService() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown translation = (ITranslation)new HelperLanguagesFormatted((IDebugLogger)(object)Utils.logger); } public void LoadData() { translation.InitFromFile(Utils.GetRelativeModFilePath("langs.data")); } } } namespace bft_mod.Patchers { internal class ChatPatcher { [HarmonyPatch(typeof(TextChatManager), "UserCode_RpcMessage__String__PlayerInfo")] public static class TextChatManagerPatch { [HarmonyPrefix] public static bool Prefix(string message, PlayerInfo sender) { try { return !ChaosModNetwork.HandleChatMessage(message, sender); } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"TextChatManagerPatch unexpecter error: {arg}"); return false; } } } } public static class MainPatcher { private static bool isPatched; public static void InitPatch() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (isPatched) { return; } isPatched = true; try { ((HelperLog)Utils.logger).Log((object)"MainPatcher init"); new Harmony("com.Loki.patch").PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"MainPatcher error: {arg}"); } } } } namespace bft_mod.Commands { internal class ClearInventory : IInternalStandaloneCommand, IConsoleCommand { public string Id => "clear_inventory"; public bool Execute(IEnumerable args) { PlayerInventory inventory = GameUtils.GetCurrentPlayer().Inventory; int count = inventory.slots.Count; for (int i = 0; i < count; i++) { if (inventory.IsItemSlotOccupied(i)) { Traverse.Create((object)inventory).Method("RemoveItemAt", new object[2] { i, false }).GetValue(); } } return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class MinesSurround : IInternalStandaloneCommand, IConsoleCommand, IHostNetworkCommand { private static int minesUseIndex = 15000; public string Id => "mines_surround"; public bool Execute(IEnumerable args) { if (!GameUtils.IsHost()) { return true; } return ExecuteHostAction(args, GameUtils.GetCurrentPlayer()); } public bool ExecuteHostAction(IEnumerable args, PlayerInfo targetPlayer) { //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) //IL_005b: 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_0064: 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_007a: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00c0: 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_00b3: 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_010b: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0140: Unknown result type (might be due to invalid IL or missing references) CommandArgsReader val = ArgsReaderFactory.NewReader(args); float num = Mathf.Max(0, val.ReadInt(0)); float num2 = Mathf.Max(0, val.ReadInt(10)); int num3 = Mathf.Max(1, val.ReadInt(10)); Vector3 position = targetPlayer.Movement.Position; ulong playerGUID = GameUtils.GetPlayerGUID(targetPlayer); PlayerInventory inventory = targetPlayer.Inventory; RaycastHit hit = default(RaycastHit); RaycastHit hit2 = default(RaycastHit); ItemUseId val3 = default(ItemUseId); for (int i = 0; i < num3; i++) { try { Vector3 val2 = UnityMathUtils.FindRandomSpawnPointNearPosition(position, num, num2); int num4 = LayerMask.op_Implicit(GameManager.LayerSettings.TerrainMask) | LayerMask.op_Implicit(GameManager.LayerSettings.PlayerGroundableMask); if (Physics.Raycast(val2 + Vector3.up * 2f, Vector3.down, ref hit, 50f, num4)) { val2 = ValidateHitObject(hit); } else if (Physics.Raycast(val2 + Vector3.up * 25f, Vector3.down, ref hit2, 100f, num4)) { val2 = ValidateHitObject(hit2); } ((ItemUseId)(ref val3))..ctor(playerGUID, minesUseIndex++, (ItemType)8, false); CourseManager.ServerSpawnLandmine(val2, Quaternion.identity, Vector3.zero, Vector3.zero, (LandmineArmType)1, val3, inventory); if (((NetworkBehaviour)inventory).isServer) { VfxManager.ServerPlayPooledVfxForAllClients((VfxType)23, val2, Quaternion.identity, default(Vector3), 0u, false, 0f, (NetworkConnectionToClient)null); } else { VfxManager.ClientPlayPooledVfxForAllClients((VfxType)23, val2, Quaternion.identity, default(Vector3), 0u, false, 0f); } } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"spawn mine error: {arg}"); } } targetPlayer.PlayerAudio.PlayLandminePlantForAllClients(true); return true; } private Vector3 ValidateHitObject(RaycastHit hit) { //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_004a: 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) Vector3 point = ((RaycastHit)(ref hit)).point; int layer = ((Component)((RaycastHit)(ref hit)).transform).gameObject.layer; if (layer == GameManager.LayerSettings.GolfCartLayer || layer == GameManager.LayerSettings.GolfCartPassengersLayer || layer == GameManager.LayerSettings.PlayerLayer) { point.y = ((RaycastHit)(ref hit)).transform.position.y; } return point; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class KnockOut : IInternalStandaloneCommand, IConsoleCommand { public string Id => "knock_out"; public bool Execute(IEnumerable args) { Traverse.Create((object)GameUtils.GetCurrentPlayer().Movement).Method("SetKnockOutState", new object[1] { (object)(KnockoutState)2 }).GetValue(); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ShieldPlayer : IInternalStandaloneCommand, IConsoleCommand { private int shieldUseIndex = 20000; public string Id => "activate_shield"; public bool Execute(IEnumerable args) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) PlayerInfo currentPlayer = GameUtils.GetCurrentPlayer(); ItemUseId val = default(ItemUseId); ((ItemUseId)(ref val))..ctor(GameUtils.GetPlayerGUID(currentPlayer), shieldUseIndex++, (ItemType)10, false); currentPlayer.LocalPlayerActivateElectromagnetShield(val); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class PlayerHeadScaleDown : IInternalStandaloneCommand, IConsoleCommand { public static float scaleCoeff = 1f; private static int counter; private static Vector3 originalBoneScale; private static Vector3 originalBonePos; private static bool saved; public string Id => "head_scale_down"; public bool IsActive { get; private set; } private static bool CanRestoreDefault => counter <= 0; public bool Execute(IEnumerable args) { //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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown CommandArgsReader val = ArgsReaderFactory.NewReader(args); float durationInSec = val.ReadFloat(30f); float num = Mathf.Abs(val.ReadFloat(0.2f)); float num2 = Mathf.Max(0f, Mathf.Abs(val.ReadFloat(0.05f))); scaleCoeff -= num; scaleCoeff = Mathf.Max(scaleCoeff, num2); ApplyScale(scaleCoeff); if (!IsActive) { MarkActive(); IsActive = true; } ServiceProvider.inst.scheduleManager.AppendTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { IsActive = false; RestoreDefault(); } }, true); return true; } public static void RestoreDefault() { //IL_0028: 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) counter--; if (CanRestoreDefault) { scaleCoeff = 1f; PlayerInfo currentPlayer = GameUtils.GetCurrentPlayer(); currentPlayer.HeadBone.localScale = GetPlayerOriginalBoneScale(); currentPlayer.HeadBone.localPosition = GetPlayerOriginalBonePos(); } } public static void MarkActive() { counter++; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } public static void ApplyScale(float scaleCoeff) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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) SavePlayerOriginalSizes(); PlayerInfo currentPlayer = GameUtils.GetCurrentPlayer(); currentPlayer.HeadBone.localScale = GetPlayerOriginalBoneScale() * scaleCoeff; currentPlayer.HeadBone.localPosition = GetPlayerOriginalBonePos() * scaleCoeff; } private static void SavePlayerOriginalSizes() { //IL_0018: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!saved) { saved = true; Transform headBone = GameUtils.GetCurrentPlayer().HeadBone; originalBoneScale = headBone.localScale; originalBonePos = headBone.localPosition; } } public static Vector3 GetPlayerOriginalBoneScale() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return originalBoneScale; } public static Vector3 GetPlayerOriginalBonePos() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return originalBonePos; } } internal class PlayerHeadScaleUp : IInternalStandaloneCommand, IConsoleCommand { public string Id => "head_scale_up"; public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a7: Expected O, but got Unknown CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float durationInSec = obj.ReadFloat(30f); float num = Mathf.Abs(obj.ReadFloat(0.5f)); float num2 = Mathf.Abs(obj.ReadFloat(10f)); PlayerHeadScaleDown.scaleCoeff += num; PlayerHeadScaleDown.scaleCoeff = Mathf.Min(PlayerHeadScaleDown.scaleCoeff, num2); PlayerHeadScaleDown.ApplyScale(PlayerHeadScaleDown.scaleCoeff); if (!IsActive) { PlayerHeadScaleDown.MarkActive(); IsActive = true; } ServiceProvider.inst.scheduleManager.AppendTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { IsActive = false; PlayerHeadScaleDown.RestoreDefault(); } }, true); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ChangeGravity : IInternalStandaloneCommand, IConsoleCommand { private Vector3 originalGravity; private bool saved; public string Id => "change_gravity"; public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //IL_004e: 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_006e: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float durationInSec = obj.ReadFloat(30f); float num = obj.ReadFloat(-3f); if (!saved) { saved = true; originalGravity = Physics.gravity; } Physics.gravity = new Vector3(originalGravity.x, num, originalGravity.z); IsActive = true; ServiceProvider.inst.scheduleManager.AppendTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) IsActive = false; Physics.gravity = originalGravity; } }, true); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class SpeedBoost : IInternalStandaloneCommand, IConsoleCommand { public string Id => "speed_boost"; public bool Execute(IEnumerable args) { float num = ArgsReaderFactory.NewReader(args).ReadFloat(30f); PlayerMovement movement = GameUtils.GetCurrentPlayer().Movement; try { if (movement.IsKnockedOutOrRecovering) { Traverse.Create((object)movement).Method("SetKnockOutState", new object[1] { (object)(KnockoutState)0 }).GetValue(); } Traverse.Create((object)movement).Field("knockoutTimestamp").Value = 0.0; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"fix IsKnockedOutOrRecovering error: {arg}"); } Traverse.Create((object)movement).Method("AddSpeedBoost", new object[1] { num }).GetValue(); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class DropSelectedItem : IInternalStandaloneCommand, IConsoleCommand { public string Id => "drop_item"; public bool Execute(IEnumerable args) { GameUtils.GetCurrentPlayer().Inventory.DropItem(); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class LaserStrikeAutoAim : IInternalStandaloneCommand, IConsoleCommand, IHostNetworkCommand { public string Id => "laser_strike_auto_aim"; public bool Execute(IEnumerable args) { if (!GameUtils.IsHost()) { return true; } return ExecuteHostAction(args, GameUtils.GetCurrentPlayer()); } public bool ExecuteHostAction(IEnumerable args, PlayerInfo targetPlayer) { //IL_0021: 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) ItemUseId val = default(ItemUseId); ((ItemUseId)(ref val))..ctor(GameUtils.GetPlayerGUID(targetPlayer), LaserStrike.GetNextLaserIndex(), (ItemType)10, false); OrbitalLaserManager.ServerActivateLaser(targetPlayer.AsHittable, ((Component)targetPlayer).transform.position, targetPlayer.Inventory, val); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class LaserStrike : IInternalStandaloneCommand, IConsoleCommand, IHostNetworkCommand { private static int laserUseIndex = 10000; public string Id => "laser_strike"; public bool Execute(IEnumerable args) { if (!GameUtils.IsHost()) { return true; } return ExecuteHostAction(args, GameUtils.GetCurrentPlayer()); } public bool ExecuteHostAction(IEnumerable args, PlayerInfo targetPlayer) { CommandArgsReader val = ArgsReaderFactory.NewReader(args); float minRange = Mathf.Max(0f, val.ReadFloat(0f)); float maxRange = Mathf.Max(0f, val.ReadFloat(2f)); int num = Mathf.Max(1, val.ReadInt(1)); for (int i = 0; i < num; i++) { ((MonoBehaviour)InteractiveMod.inst).StartCoroutine(DelayedStrike(0.015f * (float)i, targetPlayer, minRange, maxRange)); } return true; } private IEnumerator DelayedStrike(float waitInSec, PlayerInfo targetPlayer, float minRange, float maxRange) { yield return (object)new WaitForSeconds(waitInSec); ItemUseId val = default(ItemUseId); ((ItemUseId)(ref val))..ctor(GameUtils.GetPlayerGUID(targetPlayer), GetNextLaserIndex(), (ItemType)10, false); OrbitalLaserManager.ServerActivateLaser((Hittable)null, UnityMathUtils.FindRandomSpawnPointNearPosition(((Component)targetPlayer).transform.position, minRange, maxRange), targetPlayer.Inventory, val); } public static int GetNextLaserIndex() { return laserUseIndex++; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class GiveItem : IInternalStandaloneCommand, IConsoleCommand, IHostNetworkCommand { public string Id => "give_item"; public bool Execute(IEnumerable args) { if (!GameUtils.IsHost()) { return true; } return ExecuteHostAction(args, GameUtils.GetCurrentPlayer()); } public bool ExecuteHostAction(IEnumerable args, PlayerInfo targetPlayer) { //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_004d: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00a2: Unknown result type (might be due to invalid IL or missing references) CommandArgsReader obj = ArgsReaderFactory.NewReader(args); string text = obj.ReadString(""); int usageCount = obj.ReadInt(1); ((HelperLog)Utils.logger).LogInfo((object)("try to give '" + text + "'")); if (text == "random") { ItemType randomItem = GetRandomItem(); targetPlayer.Inventory.ServerTryAddItem(randomItem, ValidateMaxUsage(usageCount, randomItem)); ((HelperLog)Utils.logger).LogInfo((object)$"random selected '{randomItem}'"); return true; } if (!Enum.TryParse(text, out ItemType result)) { ((HelperLog)Utils.logger).LogWarning((object)("can't parse '" + text + "', use random")); result = GetRandomItem(); } targetPlayer.Inventory.ServerTryAddItem(result, ValidateMaxUsage(usageCount, result)); return true; } private int ValidateMaxUsage(int usageCount, ItemType item) { //IL_0005: 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) try { ItemData val = default(ItemData); if (!GameManager.AllItems.TryGetItemData(item, ref val)) { return 1; } return Mathf.Min(usageCount, val.MaxUses); } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"ValidateMaxUsage for {item} error: {arg}"); return 1; } } private ItemType GetRandomItem() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) return RandomUtils.GetRandomItemFromList((IList)(from ItemType e in Enum.GetValues(typeof(ItemType)) where (int)e > 0 select e).ToList()); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class LockCamera : IInternalStandaloneCommand, IConsoleCommand, IForceEnd { public string Id => "lock_camera"; public bool IsActive { get; private set; } private string PeriodicId => Id + "_period"; public bool Execute(IEnumerable args) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //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_006d: 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_0090: Expected O, but got Unknown float durationInSec = ArgsReaderFactory.NewReader(args).ReadFloat(30f); IsActive = true; ServiceProvider.inst.scheduleManager.AppendTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) IsActive = false; CameraActions camera = InputManager.Controls.Camera; ((CameraActions)(ref camera)).Enable(); ServiceProvider.inst.scheduleManager.RemovePeriodicTask(PeriodicId); ((HelperLog)Utils.logger).LogInfo((object)(Id + " ends")); } }, false); ServiceProvider.inst.scheduleManager.NewPeriodicTask(new PeriodicTaskData { id = PeriodicId, periodInSec = 0.005f, periodicAction = delegate { //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) if (IsActive) { CameraActions camera = InputManager.Controls.Camera; ((CameraActions)(ref camera)).Disable(); } } }, false); return true; } public void ForceEnd() { ServiceProvider.inst.scheduleManager.FinishImmediatlyTimerTask(Id); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ApplyForceToPlayer_UpWay : IInternalStandaloneCommand, IConsoleCommand { public string Id => "apply_force_to_player_up"; public bool Execute(IEnumerable args) { //IL_0025: 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_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_003e: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float num = obj.ReadFloat(5000f); float num2 = obj.ReadFloat(25000f); int num3 = obj.ReadInt(1); Vector3 val = GameUtils.GetLocalPlayerUpWay() * (float)num3; GameUtils.ApplyForceToPlayer(GameUtils.GetCurrentPlayer(), val * num, val * num2); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ApplyForceToPlayer_ForwardWay : IInternalStandaloneCommand, IConsoleCommand { public string Id => "apply_force_to_player_forward"; public bool Execute(IEnumerable args) { //IL_0025: 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_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_003e: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float num = obj.ReadFloat(5000f); float num2 = obj.ReadFloat(25000f); int num3 = obj.ReadInt(1); Vector3 val = GameUtils.GetLocalPlayerForwardWay() * (float)num3; GameUtils.ApplyForceToPlayer(GameUtils.GetCurrentPlayer(), val * num, val * num2); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ApplyForceToPlayer_RightWay : IInternalStandaloneCommand, IConsoleCommand { public string Id => "apply_force_to_player_right"; public bool Execute(IEnumerable args) { //IL_0025: 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_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_003e: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float num = obj.ReadFloat(5000f); float num2 = obj.ReadFloat(25000f); int num3 = obj.ReadInt(1); Vector3 val = GameUtils.GetLocalPlayerRightWay() * (float)num3; GameUtils.ApplyForceToPlayer(GameUtils.GetCurrentPlayer(), val * num, val * num2); return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ControllerInvertX : MouseInvertBase { public override string Id => "controller_invert_x"; protected override void SetInverted(bool invert) { GameSettings.All.Controls.Controller.invertX = invert; } protected override bool GetInvertSetting() { return GameSettings.All.Controls.Controller.invertX; } } internal class ControllerInvertY : MouseInvertBase { public override string Id => "controller_invert_y"; protected override void SetInverted(bool invert) { GameSettings.All.Controls.Controller.invertY = invert; } protected override bool GetInvertSetting() { return GameSettings.All.Controls.Controller.invertY; } } internal class PlayEmote : IInternalStandaloneCommand, IConsoleCommand, IForceEnd { public string Id => "play_emote"; public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //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_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //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_00ae: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //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) CommandArgsReader obj = ArgsReaderFactory.NewReader(args); string text = obj.ReadString(""); float durationInSec = obj.ReadFloat(2f); PlayerInfo currentPlayer = GameUtils.GetCurrentPlayer(); currentPlayer.ExitGolfCart((GolfCartExitType)0); IsActive = true; GameplayActions gameplay = InputManager.Controls.Gameplay; ((GameplayActions)(ref gameplay)).Disable(); ServiceProvider.inst.scheduleManager.NewTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) IsActive = false; GameplayActions gameplay2 = InputManager.Controls.Gameplay; ((GameplayActions)(ref gameplay2)).Enable(); ((HelperLog)Utils.logger).LogInfo((object)(Id + " ends")); } }, false); ((HelperLog)Utils.logger).LogInfo((object)("try to play emote '" + text + "'")); if (text == "random") { Emote randomEmote = GetRandomEmote(); currentPlayer.SetEmoteToPlay(randomEmote); ((HelperLog)Utils.logger).LogInfo((object)$"random selected '{randomEmote}'"); return true; } if (!Enum.TryParse(text, out Emote result)) { ((HelperLog)Utils.logger).LogWarning((object)("can't parse '" + text + "', use random")); result = GetRandomEmote(); } currentPlayer.SetEmoteToPlay(result); return true; } private Emote GetRandomEmote() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) return RandomUtils.GetRandomItemFromList((IList)(from Emote e in Enum.GetValues(typeof(Emote)) where (int)e > 0 select e).ToList()); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } public void ForceEnd() { ServiceProvider.inst.scheduleManager.FinishImmediatlyTimerTask(Id); } } internal class JumpPower : IInternalStandaloneCommand, IConsoleCommand, IForceEnd { private bool isInitiated; private float lastPower; private float oldBoostedJumpSpeed; private float oldJumpSpeed; public string Id => "jump_power"; public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown if (!isInitiated) { isInitiated = true; oldJumpSpeed = GameManager.PlayerMovementSettings.JumpUpwardsSpeed; oldBoostedJumpSpeed = GameManager.ItemSettings.SpringBootsJumpUpwardsSpeed; } CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float durationInSec = obj.ReadFloat(30f); float num = obj.ReadFloat(0f); bool num2 = lastPower != num; lastPower = num; SetJumpSpeed(oldJumpSpeed * num); SetBoostedJumpSpeed(oldBoostedJumpSpeed * num); IsActive = true; TimerTaskData val = new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { IsActive = false; SetJumpSpeed(oldJumpSpeed); SetBoostedJumpSpeed(oldBoostedJumpSpeed); ((HelperLog)Utils.logger).LogInfo((object)(Id + " ends")); } }; if (num2) { ServiceProvider.inst.scheduleManager.NewTimerTask(val, false); } else { ServiceProvider.inst.scheduleManager.AppendTimerTask(val, false); } return true; } private void SetJumpSpeed(float speed) { Traverse.Create((object)GameManager.PlayerMovementSettings).Property("JumpUpwardsSpeed", (object[])null).SetValue((object)speed); } private void SetBoostedJumpSpeed(float speed) { Traverse.Create((object)GameManager.ItemSettings).Property("SpringBootsJumpUpwardsSpeed", (object[])null).SetValue((object)speed); } public void ForceEnd() { ServiceProvider.inst.scheduleManager.FinishImmediatlyTimerTask(Id); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class ChangeMouseSens : IInternalStandaloneCommand, IConsoleCommand, IForceEnd { private float oldMouseSens; private float oldConstrollerSens; private float lastMouseCommandSens; private bool needStoreOldSettings = true; public string Id => "change_mouse_move_sens"; public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //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_0091: 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_00ac: Expected O, but got Unknown CommandArgsReader obj = ArgsReaderFactory.NewReader(args); float durationInSec = obj.ReadFloat(30f); float num = obj.ReadFloat(2.5f); float sensitivity = obj.ReadFloat(2.5f); float mouseSetting = GetMouseSetting(); float controllerSetting = GetControllerSetting(); if (needStoreOldSettings) { oldMouseSens = mouseSetting; oldConstrollerSens = controllerSetting; needStoreOldSettings = false; } GameSettings.All.Controls.Mouse.sensitivity = num; GameSettings.All.Controls.Controller.sensitivity = sensitivity; TimerTaskData val = new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { IsActive = false; GameSettings.All.Controls.Mouse.sensitivity = oldMouseSens; GameSettings.All.Controls.Controller.sensitivity = oldConstrollerSens; needStoreOldSettings = true; } }; if (lastMouseCommandSens != num) { if (IsActive) { ((HelperLog)Utils.logger).LogInfo((object)"ChangeMouseSens reset timer"); } ServiceProvider.inst.scheduleManager.NewTimerTask(val, false); } else { ServiceProvider.inst.scheduleManager.AppendTimerTask(val, true); } IsActive = true; lastMouseCommandSens = num; return true; } private float GetMouseSetting() { return GameSettings.All.Controls.Mouse.sensitivity; } private float GetControllerSetting() { return GameSettings.All.Controls.Controller.sensitivity; } public void ForceEnd() { ServiceProvider.inst.scheduleManager.FinishImmediatlyTimerTask(Id); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class MouseInvertY : MouseInvertBase { public override string Id => "mouse_invert_y"; protected override void SetInverted(bool invert) { GameSettings.All.Controls.Mouse.invertY = invert; } protected override bool GetInvertSetting() { return GameSettings.All.Controls.Mouse.invertY; } } internal class MouseInvertX : MouseInvertBase { public override string Id => "mouse_invert_x"; protected override void SetInverted(bool invert) { GameSettings.All.Controls.Mouse.invertX = invert; } protected override bool GetInvertSetting() { return GameSettings.All.Controls.Mouse.invertX; } } internal class ShufflePlayerMovement : IInternalStandaloneCommand, IConsoleCommand, IForceEnd { public string Id => "shuffle_player_movement"; public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //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_002c: 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_004b: Expected O, but got Unknown float durationInSec = ArgsReaderFactory.NewReader(args).ReadFloat(30f); ServiceProvider.inst.scheduleManager.AppendTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { IsActive = false; RestoreInput(); ((HelperLog)Utils.logger).LogInfo((object)(Id + " ends")); } }, false); if (ShuffleBinds()) { IsActive = true; return true; } return false; } private bool ShuffleBinds() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) GameplayActions gameplay = PlayerInput.Controls.Gameplay; InputAction move = ((GameplayActions)(ref gameplay)).Move; SwapBinds(move, 1, 2); SwapBinds(move, 3, 4); SwapBinds(move, 6, 7); SwapBinds(move, 8, 9); return true; } private void SwapBinds(InputAction action, int bindIndex1, int bindIndex2) { //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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_010e: 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) ReadOnlyArray bindings = action.bindings; if (bindIndex1 >= bindings.Count || bindIndex2 >= bindings.Count) { ((HelperLog)Utils.logger).LogWarning((object)$"rebind wrong indexes {bindIndex1}, {bindIndex2} of {bindings.Count}"); return; } InputBinding val = bindings[bindIndex1]; InputBinding val2 = bindings[bindIndex2]; ((HelperLog)Utils.logger).LogInfo((object)("rebind " + ((InputBinding)(ref val)).name + " from " + ((InputBinding)(ref val)).path + " to " + ((InputBinding)(ref val2)).path)); ((HelperLog)Utils.logger).LogInfo((object)("rebind " + ((InputBinding)(ref val2)).name + " from " + ((InputBinding)(ref val2)).path + " to " + ((InputBinding)(ref val)).path)); ((InputBinding)(ref val)).overridePath = ((InputBinding)(ref val2)).path; ((InputBinding)(ref val2)).overridePath = ((InputBinding)(ref val)).path; InputActionRebindingExtensions.ApplyBindingOverride(action, bindIndex1, val); InputActionRebindingExtensions.ApplyBindingOverride(action, bindIndex2, val2); } private void RestoreInput() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: Unknown result type (might be due to invalid IL or missing references) GameplayActions gameplay = PlayerInput.Controls.Gameplay; InputAction move = ((GameplayActions)(ref gameplay)).Move; ReadOnlyArray bindings = move.bindings; int count = bindings.Count; for (int i = 0; i < count; i++) { InputBinding val = bindings[i]; ((InputBinding)(ref val)).overridePath = null; ((HelperLog)Utils.logger).LogInfo((object)("reset bind " + ((InputBinding)(ref val)).name + " to " + ((InputBinding)(ref val)).path)); InputActionRebindingExtensions.ApplyBindingOverride(move, i, val); } } public void ForceEnd() { ServiceProvider.inst.scheduleManager.FinishImmediatlyTimerTask(Id); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class TeleportToRandomPlayer : IInternalStandaloneCommand, IConsoleCommand, IHostNetworkCommand, INetworkApplyOnce { private const float DELAY = 0.5f; private DateTime lastTriggerTime = DateTime.MinValue; private bool teleportEnds = true; public string Id => "teleport_to_random_player"; public bool Execute(IEnumerable args) { GameUtils.GetCurrentPlayer().ExitGolfCart((GolfCartExitType)0); if (!GameUtils.IsHost()) { return true; } return ExecuteHostAction(args, GameUtils.GetCurrentPlayer()); } public bool ExecuteHostAction(IEnumerable args, PlayerInfo originalPlayer) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00ab: Expected O, but got Unknown if (!teleportEnds && (DateTime.Now - lastTriggerTime).TotalSeconds < 1.5) { ((HelperLog)Utils.logger).LogWarning((object)(Id + " spams too much. Old teleport is not finished")); return true; } teleportEnds = false; lastTriggerTime = DateTime.Now; ServiceProvider.inst.scheduleManager.NewTimerTask(new TimerTaskData { id = Id, durationInSec = 0.5f, finishAction = delegate { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b7: 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) try { PlayerInfo[] teleportTargets = GetTeleportTargets(originalPlayer); if (teleportTargets == null) { ((HelperLog)Utils.logger).LogWarning((object)(Id + " can't apply teleport, other players doesn't found")); } else { PlayerInfo randomItemFromList = RandomUtils.GetRandomItemFromList((IList)teleportTargets); string playerName = GameUtils.GetPlayerName(randomItemFromList); Vector3 position = originalPlayer.Movement.Position; ((HelperLog)Utils.logger).LogInfo((object)$"{Id} found otherPlayers {teleportTargets.Length}, target {playerName}, base pos {position}"); Vector3 pos = randomItemFromList.Movement.Position + Vector3.up * 1.5f; ((HelperLog)Utils.logger).LogInfo((object)$"selected pos {pos}"); GameUtils.TeleportPlayer(originalPlayer, in pos); } } finally { teleportEnds = true; } } }, false); return true; } private PlayerInfo[] GetTeleportTargets(PlayerInfo originalPlayer) { try { List list = GameUtils.Players.ToList(); list.Add(GameUtils.GetCurrentPlayer()); PlayerInfo[] array = list.Where((PlayerInfo p) => (Object)(object)p != (Object)(object)originalPlayer).ToArray(); if (array.Length == 0) { return null; } return array; } catch (Exception arg) { ((HelperLog)Utils.logger).LogError((object)$"{Id} GetTeleportTargets can't apply teleport, error: {arg}"); return null; } } public bool ShouldTriggerClientSideForOthers() { return false; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } internal class TeleportShufflePlayers : IInternalStandaloneCommand, IConsoleCommand, IHostNetworkCommand, INetworkApplyOnce { public string Id => "teleport_shuffle_players"; public bool Execute(IEnumerable args) { GameUtils.GetCurrentPlayer().ExitGolfCart((GolfCartExitType)0); if (!GameUtils.IsHost()) { return true; } return ExecuteHostAction(args, null); } public bool ExecuteHostAction(IEnumerable args, PlayerInfo targetCharacter) { //IL_003d: 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) //IL_004e: 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_0071: Expected O, but got Unknown if (ServiceProvider.inst.scheduleManager.IsTaskExists(Id)) { ((HelperLog)Utils.logger).LogWarning((object)(Id + " spams too much. Old teleport is not finished")); return true; } ServiceProvider.inst.scheduleManager.NewTimerTask(new TimerTaskData { id = Id, durationInSec = 1f, finishAction = delegate { //IL_00cb: 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) List list = GameUtils.Players.ToList(); list.Add(GameUtils.GetCurrentPlayer()); if (list.Count <= 1) { ((HelperLog)Utils.logger).LogWarning((object)(Id + " can't apply teleport, other players doesn't found")); } else { List list2 = RandomUtils.ShuffleForceRandom(list.Select((PlayerInfo p) => p.Movement.Position)); ((HelperLog)Utils.logger).LogInfo((object)$"{Id} found {list.Count} players and {list2.Count} positions"); if (list2.Count != list.Count) { ((HelperLog)Utils.logger).LogError((object)(Id + " wrong arr sizes")); } else { for (int num = 0; num < list.Count; num++) { GameUtils.TeleportPlayer(list[num], list2[num]); } } } } }, false); return true; } public bool ShouldTriggerClientSideForOthers() { return true; } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } } namespace bft_mod.Commands.Base { internal abstract class MouseInvertBase : IInternalStandaloneCommand, IConsoleCommand, IForceEnd { protected bool oldState; protected bool needStoreOldSettings = true; public abstract string Id { get; } public bool IsActive { get; private set; } public bool Execute(IEnumerable args) { //IL_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown float durationInSec = ArgsReaderFactory.NewReader(args).ReadFloat(30f); bool invertSetting = GetInvertSetting(); if (needStoreOldSettings) { oldState = invertSetting; needStoreOldSettings = false; } SetInverted(!oldState); IsActive = true; ServiceProvider.inst.scheduleManager.AppendTimerTask(new TimerTaskData { id = Id, durationInSec = durationInSec, finishAction = delegate { IsActive = false; SetInverted(oldState); needStoreOldSettings = true; } }, true); return true; } protected abstract void SetInverted(bool invert); protected abstract bool GetInvertSetting(); public void ForceEnd() { ServiceProvider.inst.scheduleManager.FinishImmediatlyTimerTask(Id); } public bool IsValidCommandArgs(IEnumerable args) { throw new NotImplementedException(); } } } namespace bft_mod.Commands.Interfaces { public interface INetworkApplyOnce { bool ShouldTriggerClientSideForOthers(); } public interface IHostNetworkCommand : IConsoleCommand { bool ExecuteHostAction(IEnumerable args, PlayerInfo targetPlayer); } public interface IInternalStandaloneCommand : IConsoleCommand { } public interface IInternalStandaloneCommandWithData : IInternalStandaloneCommand, IConsoleCommand, IConsoleCommandWithData { } public interface IForceEnd : IInternalStandaloneCommand, IConsoleCommand { bool IsActive { get; } void ForceEnd(); } }