using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BepinControl; using ControlValley; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Steamworks; using TMPro; using TwitchChatAPI; using TwitchChatAPI.Enums; using TwitchChatAPI.Objects; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.UI; using Zeekerss.Core.Singletons; using com.github.zehsteam.ImmersiveEntrance.MonoBehaviours; using com.github.zehsteam.MonsterHotkeys.Dependencies; using com.github.zehsteam.MonsterHotkeys.Dependencies.CrowdControlMod; using com.github.zehsteam.MonsterHotkeys.Dependencies.CrowdControlMod.Patches; using com.github.zehsteam.MonsterHotkeys.Dependencies.ImmersiveEntranceMod; using com.github.zehsteam.MonsterHotkeys.Enums; using com.github.zehsteam.MonsterHotkeys.Extensions; using com.github.zehsteam.MonsterHotkeys.Helpers; using com.github.zehsteam.MonsterHotkeys.Managers; using com.github.zehsteam.MonsterHotkeys.MonoBehaviours; using com.github.zehsteam.MonsterHotkeys.MonoBehaviours.Audio; using com.github.zehsteam.MonsterHotkeys.MonoBehaviours.UI; using com.github.zehsteam.MonsterHotkeys.MonoBehaviours.Utils; using com.github.zehsteam.MonsterHotkeys.NetcodePatcher; using com.github.zehsteam.MonsterHotkeys.Objects; using com.github.zehsteam.MonsterHotkeys.Objects.Enemies; using com.github.zehsteam.MonsterHotkeys.Objects.Network; using com.github.zehsteam.MonsterHotkeys.Patches; using com.github.zehsteam.MonsterHotkeys.Twitch; using com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands; using com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Developer; using com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Moderator; using com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Public; using com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Special; using com.github.zehsteam.MonsterHotkeys.Twitch.Managers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyDescription("Let Twitch chat spawn monsters with subs, bits, raids, and spawn points. Highly configurable, easy to use, no extension or app needed. (Twitch and CrowdControl integration)")] [assembly: AssemblyFileVersion("3.2.0.0")] [assembly: AssemblyInformationalVersion("3.2.0+4bae85c51a3e8f63a1762b26436a14cfccb9ca8f")] [assembly: AssemblyProduct("MonsterHotkeys")] [assembly: AssemblyTitle("com.github.zehsteam.MonsterHotkeys")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] [CompilerGenerated] internal sealed class <>z__ReadOnlyList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Count; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Count; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Count; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyList(List items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return _items.Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { _items.CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return _items.IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator { object IEnumerator.Current => _item; T IEnumerator.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => 1; T IReadOnlyList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection.Count => 1; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return EqualityComparer.Default.Equals(_item, item); } void ICollection.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { if (!EqualityComparer.Default.Equals(_item, item)) { return -1; } return 0; } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 com.github.zehsteam.MonsterHotkeys { internal static class Assets { public static readonly string AssetBundleFileName = "monsterhotkeys_assets"; public static AssetBundle AssetBundle { get; private set; } public static bool IsLoaded { get; private set; } public static GameObject PluginNetworkHandlerPrefab { get; private set; } public static GameObject PluginHUDPrefab { get; private set; } public static EnemyDatabase EnemyDatabase { get; private set; } public static void Load() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = Path.Combine(directoryName, AssetBundleFileName); if (!File.Exists(text)) { Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text + "\". Make sure the \"" + AssetBundleFileName + "\" file is in the same folder as the mod's DLL file."); } else { AssetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)AssetBundle == (Object)null) { Logger.LogFatal("Failed to load assets. AssetBundle is null."); return; } OnAssetBundleLoaded(AssetBundle); IsLoaded = true; } } private static void OnAssetBundleLoaded(AssetBundle assetBundle) { PluginNetworkHandlerPrefab = LoadAsset("PluginNetworkHandler", assetBundle); PluginHUDPrefab = LoadAsset("PluginHUD", assetBundle); EnemyDatabase = LoadAsset("EnemyDatabase", assetBundle); } private static T LoadAsset(string name, AssetBundle assetBundle) where T : Object { if (string.IsNullOrWhiteSpace(name)) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace."); return default(T); } if ((Object)(object)assetBundle == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null."); return default(T); } T val = assetBundle.LoadAsset(name); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name."); return default(T); } return val; } private static bool TryLoadAsset(string name, AssetBundle assetBundle, out T asset) where T : Object { asset = LoadAsset(name, assetBundle); return (Object)(object)asset != (Object)null; } } internal class HotkeyInputClass : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction MonsterPrefixKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction PlushiePrefixKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnRandomKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnBaboonHawkKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnBarberKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnBlobKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnBrackenKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnBunkerSpiderKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnButlerKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnCoilHeadKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnEarthLeviathanKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnEyelessDogKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnForestGiantKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnGhostGirlKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnHoardingBugKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnJesterKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnKidnapperFoxKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnManeaterKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnManticoilKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnMaskedKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnNutcrackerKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnOldBirdKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnSnareFleaKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnSporeLizardKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnThumperKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction SpawnTulipSnakeKey { get; set; } } public static class HotkeyListener { public static bool DisableHotkeys; public static bool IsMonsterPrefixKeyPressed => Plugin.InputActionsInstance.MonsterPrefixKey.IsPressed(); public static bool IsPlushiePrefixKeyPressed => Plugin.InputActionsInstance.PlushiePrefixKey.IsPressed(); internal static void SetupKeybindCallbacks() { Plugin.InputActionsInstance.SpawnRandomKey.performed += OnSpawnRandomKeyPressed; Plugin.InputActionsInstance.SpawnBaboonHawkKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnBarberKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnBlobKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnBrackenKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnBunkerSpiderKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnButlerKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnCoilHeadKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnEarthLeviathanKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnEyelessDogKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnForestGiantKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnGhostGirlKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnHoardingBugKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnJesterKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnKidnapperFoxKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnManeaterKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnManticoilKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnMaskedKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnNutcrackerKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnOldBirdKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnSnareFleaKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnSporeLizardKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnThumperKey.performed += OnSpawnKeyPressed; Plugin.InputActionsInstance.SpawnTulipSnakeKey.performed += OnSpawnKeyPressed; Logger.LogInfo("Setup keybind callbacks."); } private static void OnSpawnKeyPressed(CallbackContext context) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!((CallbackContext)(ref context)).performed || !CanPerformHotkeys()) { return; } string name = ((CallbackContext)(ref context)).action.name; Logger.LogInfo(name + " key pressed.", extended: true); if (DisableHotkeys && (IsMonsterPrefixKeyPressed || IsPlushiePrefixKeyPressed)) { MessageManger instance = MessageManger.Instance; if (instance != null) { Color? color = Color.red; instance.ShowMessage_LocalClient("Hotkeys have been disabled by another mod", new MessageSettings(null, color)); } Logger.LogInfo("Hotkeys have been disabled by another mod."); return; } string name2 = name.Replace("Spawn", "").Replace("Key", ""); if (!Assets.EnemyDatabase.TryGetDataByName(name2, out var enemyData)) { Logger.LogError("Failed to find EnemyData from key name \"" + name + "\""); return; } if (Plugin.InputActionsInstance.MonsterPrefixKey.IsPressed()) { EnemyHelper.SpawnEnemy(enemyData); } if (Plugin.InputActionsInstance.PlushiePrefixKey.IsPressed()) { PlushieManager.Instance.SpawnPlushies(enemyData.Name, PlayerUtils.LocalPlayerScript); } } private static void OnSpawnRandomKeyPressed(CallbackContext context) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!((CallbackContext)(ref context)).performed || !CanPerformHotkeys()) { return; } Logger.LogInfo(((CallbackContext)(ref context)).action.name + " key pressed.", extended: true); if (DisableHotkeys && (IsMonsterPrefixKeyPressed || IsPlushiePrefixKeyPressed)) { MessageManger instance = MessageManger.Instance; if (instance != null) { Color? color = Color.red; instance.ShowMessage_LocalClient("Hotkeys have been disabled by another mod", new MessageSettings(null, color)); } Logger.LogInfo("Hotkeys have been disabled by another mod."); } else { if (IsMonsterPrefixKeyPressed) { EnemyHelper.SpawnRandomEnemy(); } if (IsPlushiePrefixKeyPressed) { PlushieManager.Instance?.SpawnRandomPlushies(PlayerUtils.LocalPlayerScript); } } } public static bool CanPerformHotkeys() { PlayerControllerB localPlayerScript = PlayerUtils.LocalPlayerScript; if ((Object)(object)localPlayerScript == (Object)null) { return false; } if (localPlayerScript.isPlayerDead) { return false; } if (localPlayerScript.isTypingChat) { return false; } if (localPlayerScript.quickMenuManager.isMenuOpen) { return false; } return true; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static bool IsExtendedLoggingEnabled => ConfigManager.Misc_ExtendedLogging?.Value ?? false; public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } } [BepInPlugin("com.github.zehsteam.MonsterHotkeys", "MonsterHotkeys", "3.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("com.github.zehsteam.MonsterHotkeys"); internal static Plugin Instance { get; private set; } internal static HotkeyInputClass InputActionsInstance { get; private set; } internal static JsonSave GlobalSave { get; private set; } internal static JsonSave LocalSave { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.MonsterHotkeys")); Logger.LogInfo("MonsterHotkeys has awoken!"); ((Object)this).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)this); _harmony.PatchAll(typeof(GameNetworkManager_Patches)); _harmony.PatchAll(typeof(StartOfRound_Patches)); _harmony.PatchAll(typeof(RoundManager_Patches)); _harmony.PatchAll(typeof(HUDManager_Patches)); _harmony.PatchAll(typeof(EnemyAI_Patches)); _harmony.PatchAll(typeof(RadMechAI_Patches)); _harmony.PatchAll(typeof(ButlerEnemyAI_Patches)); _harmony.PatchAll(typeof(Landmine_Patches)); if (CrowdControlProxy.IsInstalled) { CrowdControlProxy.PatchAll(_harmony); } GlobalSave = new JsonSave(Utils.GetPluginPersistentDataPath(), "GlobalSave"); LocalSave = new JsonSave(Paths.ConfigPath, "MonsterHotkeys_Save.json"); Assets.Load(); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); InputActionsInstance = new HotkeyInputClass(); HotkeyListener.SetupKeybindCallbacks(); TwitchIntegrationManager.Initialize(); NetworkUtils.NetcodePatcherAwake(); PluginHelper.OnStart = (Action)Delegate.Combine(PluginHelper.OnStart, (Action)delegate { PlayerDamagePatcher.PatchAll(_harmony); }); PluginHelper.Spawn(); } private void Start() { PlayerDamagePatcher.PatchAll(_harmony); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.MonsterHotkeys"; public const string PLUGIN_NAME = "MonsterHotkeys"; public const string PLUGIN_VERSION = "3.2.0"; } } namespace com.github.zehsteam.MonsterHotkeys.Twitch { internal static class TwitchIntegrationManager { public static bool IsEnabled => ConfigManager.TwitchIntegration_Enabled.Value; public static bool IsCheerEventEnabled { get { if (IsEnabled) { return ConfigManager.TwitchCheerEvent_Enabled.Value; } return false; } } public static bool IsSubEventEnabled { get { if (IsEnabled) { return ConfigManager.TwitchSubEvent_Enabled.Value; } return false; } } public static bool IsRaidEventEnabled { get { if (IsEnabled) { return ConfigManager.TwitchRaidEvent_Enabled.Value; } return false; } } public static string[] TwitchBotUsernames { get; private set; } = new string[24] { "streamelements", "nightbot", "sery_bot", "wizebot", "kofistreambot", "botrixoficial", "tangiabot", "moobot", "fyow", "creatisbot", "frostytoolsdotcom", "own3d", "streamlabs", "pokemoncommunitygame", "fossabot", "lurxx", "blerp", "streamstickers", "wzbot", "botbandera", "soundalerts", "overlayexpert", "trackerggbot", "lumiastream" }; public static void Initialize() { TwitchEventHandler.Initialize(); TwitchEventQueue.Initialize(); AccumulatedBitManger.Initialize(); SpawnPointManager.Initialize(); TwitchCommandManager.Initialize(); } public static void OnDayEnded() { SpawnPointManager.OnDayEnded(); } public static void OnLocalDisconnect() { SpawnPointManager.OnLocalDisconnect(); } public static bool IsBotUser(TwitchUser twitchUser) { return TwitchBotUsernames.Contains(((TwitchUser)(ref twitchUser)).Username); } } } namespace com.github.zehsteam.MonsterHotkeys.Twitch.Managers { internal static class AccumulatedBitManger { private static Dictionary _accumulatedBits = new Dictionary(StringComparer.OrdinalIgnoreCase); public static IReadOnlyDictionary AccumulatedBits => _accumulatedBits; public static void Initialize() { LoadData(); Application.quitting += SaveData; } private static void LoadData() { try { if (Plugin.GlobalSave.TryLoad("AccumulatedBits", out var value)) { Logger.LogInfo("[AccumulatedBitManger] Loaded JSON data:\n\n" + value, extended: true); _accumulatedBits = JsonConvert.DeserializeObject>(value); } } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to load JSON data: {1}", "AccumulatedBitManger", arg)); } } private static void SaveData() { if (Plugin.GlobalSave.Save("AccumulatedBits", JsonConvert.SerializeObject((object)_accumulatedBits))) { Logger.LogInfo("[AccumulatedBitManger] Saved JSON data.", extended: true); } else { Logger.LogError("[AccumulatedBitManger] Failed to save JSON data."); } } public static int Get(string username) { return _accumulatedBits.GetValueOrDefault(username.ToLower(), 0); } public static int Get(ViewerData viewer) { if (viewer == null) { return 0; } return Get(viewer.Username); } public static void Set(string username, int value) { if (value <= 0) { _accumulatedBits.Remove(username.ToLower()); } else { _accumulatedBits[username.ToLower()] = value; } SaveData(); } public static void Set(ViewerData viewer, int value) { if (viewer != null) { Set(viewer.Username, value); } } public static void Add(string username, int amount) { int num = Get(username); int value = num + amount; Set(username, value); } public static void Add(ViewerData viewer, int amount) { if (viewer != null) { Add(viewer.Username, amount); } } public static void Remove(string username, int amount) { Add(username, -amount); } public static void Remove(ViewerData viewer, int amount) { Add(viewer, -amount); } } internal static class SpawnPointManager { private static Dictionary _spawnPoints = new Dictionary(StringComparer.OrdinalIgnoreCase); public static int EnemiesSpawnedUsingPointsThisDay; public static bool IsEnabled { get { if (TwitchIntegrationManager.IsEnabled) { return ConfigManager.SpawnPoints_Enabled.Value; } return false; } } public static IReadOnlyDictionary SpawnPoints => _spawnPoints; public static string UseSpawnPointText => $"Use !spawn = {PriceForEnemy}, !plushies = {PriceForPlushies}".RichColor("#00FF00"); public static float PriceForEnemy => ConfigManager.SpawnPoints_PriceForEnemy.Value; public static float PriceForPlushies => ConfigManager.SpawnPoints_PriceForPlushies.Value; public static int MaxEnemySpawnsPerDay => ConfigManager.SpawnPoints_MaxEnemySpawnsPerDay.Value; public static float RewardPointsPerDeath => ConfigManager.SpawnPoints_RewardPointsPerDeath.Value; public static float RewardPointsPerCrewmateDeath => ConfigManager.SpawnPoints_RewardPointsPerCrewmateDeath.Value; public static void Initialize() { LoadData(); Application.quitting += SaveData; } private static void LoadData() { try { if (Plugin.GlobalSave.TryLoad("SpawnPoints", out var value)) { Logger.LogInfo("[SpawnPointManager] Loaded JSON data:\n\n" + value, extended: true); _spawnPoints = JsonConvert.DeserializeObject>(value); } } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to load JSON data: {1}", "SpawnPointManager", arg)); } } private static void SaveData() { if (Plugin.GlobalSave.Save("SpawnPoints", JsonConvert.SerializeObject((object)_spawnPoints))) { Logger.LogInfo("[SpawnPointManager] Saved JSON data.", extended: true); } else { Logger.LogError("[SpawnPointManager] Failed to save JSON data."); } } public static float Get(string username) { return _spawnPoints.GetValueOrDefault(username.ToLower(), 0f); } public static float Get(ViewerData viewer) { if (viewer == null) { return 0f; } return Get(viewer.Username); } public static void Set(string username, float value, bool saveImmediately = true) { if (value <= 0f) { _spawnPoints.Remove(username.ToLower()); } else { _spawnPoints[username.ToLower()] = value; } if (saveImmediately) { SaveData(); } } public static void Set(ViewerData viewer, float value, bool saveImmediately = true) { if (viewer != null) { Set(viewer.Username, value, saveImmediately); } } public static void Add(string username, float amount, bool saveImmediately = true) { float num = Get(username); float value = num + amount; Set(username, value, saveImmediately); } public static void Add(ViewerData viewer, float amount, bool saveImmediately = true) { if (viewer != null) { Add(viewer.Username, amount, saveImmediately); } } public static void Remove(string username, float amount, bool saveImmediately = false) { Add(username, 0f - amount, saveImmediately); } public static void Remove(ViewerData viewer, float amount, bool saveImmediately = false) { Add(viewer, 0f - amount, saveImmediately); } public static void ResetAllSpawnPoints() { _spawnPoints.Clear(); SaveData(); Logger.LogInfo("Reset all spawn points."); } public static void OnDayEnded() { EnemiesSpawnedUsingPointsThisDay = 0; SaveData(); } public static void OnLocalDisconnect() { EnemiesSpawnedUsingPointsThisDay = 0; LoadData(); } public static void SpawnEnemiesUsingPoints(ViewerData viewer, int requestedSpawnCount, PlayerControllerB targetPlayerScript) { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled || viewer == null || requestedSpawnCount <= 0 || !TwitchEventHandler.CanPlayEventsOnPlayer(targetPlayerScript)) { return; } float num = Get(viewer); if (num <= 0f) { return; } int maxEnemySpawnsPerDay = MaxEnemySpawnsPerDay; int num2 = maxEnemySpawnsPerDay - EnemiesSpawnedUsingPointsThisDay; if (num2 <= 0) { MessageManger.Instance?.ShowMessage_LocalClient($"The max amount of enemies ({maxEnemySpawnsPerDay}) have been spawned using spawn points for this day"); return; } if (requestedSpawnCount > maxEnemySpawnsPerDay) { requestedSpawnCount = maxEnemySpawnsPerDay; } if (requestedSpawnCount > num2) { requestedSpawnCount = num2; } float num3 = PriceForEnemy * (float)requestedSpawnCount; float num4; if (num3 > num) { requestedSpawnCount = (int)Mathf.Floor(num / PriceForEnemy); if (requestedSpawnCount <= 1) { return; } if (requestedSpawnCount > num2) { requestedSpawnCount = num2; } num4 = PriceForEnemy * (float)requestedSpawnCount; } else { num4 = num3; } Remove(viewer, num4); EnemiesSpawnedUsingPointsThisDay += requestedSpawnCount; float num5 = Get(viewer); string arg = ((num4 == 1f) ? "" : "s"); string spawnReason = $"by redeeming {num4} spawn point{arg} ({num5} remaining)"; int spawnCount = requestedSpawnCount; ulong? spawnedOnClientId = targetPlayerScript.actualClientId; SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, spawnCount, spawnReason, "", null, spawnedOnClientId); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); } public static void SpawnPlusheisUsingPoints(ViewerData viewer, PlayerControllerB targetPlayerScript) { //IL_00bf: 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) if (IsEnabled && viewer != null && !((Object)(object)PlushieManager.Instance == (Object)null) && PlushieManager.Instance.CanSpawnPlushiesOnPlayer(targetPlayerScript)) { float num = Get(viewer); if (!(num <= 0f) && !(num < PriceForPlushies)) { Remove(viewer, PriceForPlushies); float num2 = Get(viewer); string arg = ((PriceForPlushies == 1f) ? "" : "s"); string spawnReason = $"by redeeming {PriceForPlushies} spawn point{arg} ({num2} remaining)"; ulong? spawnedOnClientId = targetPlayerScript.actualClientId; SpawnPlushiesData spawnPlushiesData = new SpawnPlushiesData(viewer, SpawnSource.Twitch, spawnReason, "", null, spawnedOnClientId); SpawnEventHandler.Instance?.ExecuteSpawnPlushiesData_ServerRpc(spawnPlushiesData); } } } public static void RewardFromDeath(NametagData nametagData) { if (!IsEnabled) { return; } SpawnEnemyData spawnEnemyData = nametagData.SpawnEnemyData; if (!spawnEnemyData.IsFromViewer) { return; } bool value = ConfigManager.CrowdControl_RewardSpawnPoints.Value; if (spawnEnemyData.SpawnSource != SpawnSource.CrowdControl || value) { float rewardPointsPerDeath = RewardPointsPerDeath; if (!(rewardPointsPerDeath <= 0f)) { ViewerData viewer = spawnEnemyData.Viewer; Add(viewer, rewardPointsPerDeath); float num = Get(viewer); string displayNameWithReadableColor = viewer.GetDisplayNameWithReadableColor(); string text = ((rewardPointsPerDeath == 1f) ? "" : "s"); string message = $"{displayNameWithReadableColor} just earned {rewardPointsPerDeath} spawn point{text} ({num} total) {UseSpawnPointText}"; MessageManger.Instance?.ShowMessage_LocalClient(message); } } } public static void RewardFromCrewmateDeath(ulong crewmateClientId, NametagData nametagData) { if (!IsEnabled) { return; } SpawnEnemyData spawnEnemyData = nametagData.SpawnEnemyData; if (!spawnEnemyData.IsFromViewer || NetworkUtils.IsLocalClientId(crewmateClientId) || !NetworkUtils.IsLocalClientId(spawnEnemyData.SpawnedFromClientId)) { return; } bool value = ConfigManager.CrowdControl_RewardSpawnPoints.Value; if (spawnEnemyData.SpawnSource == SpawnSource.CrowdControl && !value) { return; } float rewardPointsPerCrewmateDeath = RewardPointsPerCrewmateDeath; if (!(rewardPointsPerCrewmateDeath <= 0f)) { PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(crewmateClientId); if (!((Object)(object)playerScriptByClientId == (Object)null)) { ViewerData viewer = spawnEnemyData.Viewer; Add(viewer, rewardPointsPerCrewmateDeath); float num = Get(viewer); string displayNameWithReadableColor = viewer.GetDisplayNameWithReadableColor(); string text = ((rewardPointsPerCrewmateDeath == 1f) ? "" : "s"); string message = $"{displayNameWithReadableColor} just earned {rewardPointsPerCrewmateDeath} spawn point{text} by killing {playerScriptByClientId.playerUsername} ({num} total) {UseSpawnPointText}"; MessageManger.Instance?.ShowMessage_LocalClient(message); } } } } internal static class TargetPlayerManager { private static readonly Dictionary _targets = new Dictionary(StringComparer.OrdinalIgnoreCase); public static IReadOnlyDictionary Targets => _targets; public static PlayerControllerB GetTarget(string username) { return _targets.GetValueOrDefault(username.ToLower()); } public static bool TryGetTarget(string username, out PlayerControllerB playerScript) { return _targets.TryGetValue(username.ToLower(), out playerScript); } public static void SetTarget(string username, PlayerControllerB playerScript) { _targets[username.ToLower()] = playerScript; } public static void RemoveTarget(string username) { _targets.Remove(username.ToLower()); } } internal static class TwitchCheerHandler { public static int PriceForEnemy => ConfigManager.TwitchCheerEvent_AmountToSpawnEnemy.Value; public static int PriceForPlushies => ConfigManager.TwitchCheerEvent_AmountToSpawnPlushies.Value; public static void HandleCheer(TwitchCheerEvent cheerEvent) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!TwitchIntegrationManager.IsCheerEventEnabled) { return; } if (cheerEvent == null) { Logger.LogError("[TwitchCheerHandler] Failed to handle cheer. TwitchCheerEvent is null."); return; } if (!TwitchEventHandler.CanPlayEventsOnLocalPlayer()) { TwitchEventQueue.Enqueue(cheerEvent); return; } int cheerAmount = cheerEvent.CheerAmount; ViewerData viewer = new ViewerData(((TwitchEvent)cheerEvent).User); if (PriceForEnemy == PriceForPlushies && cheerAmount == PriceForEnemy) { if (Utils.RollPercentChance(50f)) { SpawnEnemyFromExactAmount(cheerEvent, viewer); } else { SpawnPlushiesFromExactAmount(cheerEvent, viewer); } } else if (cheerAmount == PriceForEnemy) { SpawnEnemyFromExactAmount(cheerEvent, viewer); } else if (cheerAmount == PriceForPlushies) { SpawnPlushiesFromExactAmount(cheerEvent, viewer); } else { TrySpawnEnemies(cheerEvent, viewer); } } private static void SpawnPlushiesFromExactAmount(TwitchCheerEvent cheerEvent, ViewerData viewer) { SpawnPlushiesData spawnPlushiesData = new SpawnPlushiesData(viewer, SpawnSource.Twitch, $"by cheering {cheerEvent.CheerAmount} bits"); PlushieManager.Instance?.SpawnPlushiesFromData(spawnPlushiesData); } private static void SpawnEnemyFromExactAmount(TwitchCheerEvent cheerEvent, ViewerData viewer) { //IL_0044: 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) string spawnReason = $"by cheering {cheerEvent.CheerAmount} bits"; SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, 1, spawnReason); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); } private static void TrySpawnEnemies(TwitchCheerEvent cheerEvent, ViewerData viewer) { int cheerAmount = cheerEvent.CheerAmount; int num = Mathf.FloorToInt((float)(cheerAmount / PriceForEnemy)); int num2 = AccumulatedBitManger.Get(viewer); int num3 = cheerAmount + num2; int num4 = Mathf.FloorToInt((float)(num3 / PriceForEnemy)); if (num4 > num) { SpawnEnemiesWithAccumulatedBits(cheerEvent, viewer); return; } if (num >= 1) { SpawnEnemiesFromExactOrExtraBits(cheerEvent, viewer); return; } AccumulatedBitManger.Add(viewer, cheerAmount); num2 = AccumulatedBitManger.Get(viewer); MessageManger.Instance?.ShowMessage_LocalClient($"{viewer.GetDisplayNameWithReadableColor()} didn't cheer enough to spawn anything. {cheerAmount} bits have been added to their accumulation pool ({num2} total / {PriceForEnemy})"); } private static void SpawnEnemiesFromExactOrExtraBits(TwitchCheerEvent cheerEvent, ViewerData viewer) { //IL_0085: 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) int cheerAmount = cheerEvent.CheerAmount; int spawnCount = Mathf.FloorToInt((float)(cheerAmount / PriceForEnemy)); int num = cheerAmount % PriceForEnemy; int num2 = cheerAmount - num; string spawnReason = ((num <= 0) ? $"by cheering {num2} bits" : $"by cheering {num2} bits + {num} extra bits"); SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, spawnCount, spawnReason); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); if (num > 0) { AccumulatedBitManger.Add(viewer, num); int num3 = AccumulatedBitManger.Get(viewer); MessageManger.Instance?.ShowMessage_LocalClient($"{num} extra bits have been added to {viewer.GetDisplayNameWithReadableColor()}'s accumulation pool ({num3} total / {PriceForEnemy})"); } } private static void SpawnEnemiesWithAccumulatedBits(TwitchCheerEvent cheerEvent, ViewerData viewer) { //IL_0082: 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) int cheerAmount = cheerEvent.CheerAmount; int num = AccumulatedBitManger.Get(viewer); int num2 = cheerAmount + num; int spawnCount = Mathf.FloorToInt((float)(num2 / PriceForEnemy)); int num3 = num2 % PriceForEnemy; int num4 = Mathf.Max(num - num3, 0); string spawnReason = $"by cheering {cheerAmount} bits + {num4} accumulated bits"; SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, spawnCount, spawnReason); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); AccumulatedBitManger.Remove(viewer, num4); int num5 = AccumulatedBitManger.Get(viewer); MessageManger.Instance?.ShowMessage_LocalClient($"{viewer.GetDisplayNameWithReadableColor()} has {num5} / {PriceForEnemy} accumulated bits remaining"); } } internal static class TwitchEventHandler { public static void Initialize() { try { API.OnMessage += HandleMessage; API.OnCheer += HandleCheer; API.OnSub += HandleSub; API.OnRaid += HandleRaid; Application.quitting += delegate { API.OnMessage -= HandleMessage; API.OnCheer -= HandleCheer; API.OnSub -= HandleSub; API.OnRaid -= HandleRaid; }; } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to initialize. {1}", "TwitchEventHandler", arg)); } } public static void HandleMessage(TwitchMessage twitchMessage) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (TwitchIntegrationManager.IsEnabled) { TwitchCommandManager.Dispatch(twitchMessage); } } public static void HandleCheer(TwitchCheerEvent cheerEvent) { TwitchCheerHandler.HandleCheer(cheerEvent); } public static void HandleSub(TwitchSubEvent subEvent) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_0071: 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_00b9: Unknown result type (might be due to invalid IL or missing references) if (!TwitchIntegrationManager.IsSubEventEnabled) { return; } if (subEvent == null) { Logger.LogError("[TwitchEventHandler] Failed to handle sub. TwitchSubEvent is null."); return; } if (!CanPlayEventsOnLocalPlayer()) { TwitchEventQueue.Enqueue(subEvent); return; } int num = ConfigManager.TwitchSubEvent_EnemiesPerSub.Value; if ((int)subEvent.Type == 3) { num *= subEvent.GiftCount; } if ((int)subEvent.Tier == 2) { num *= ConfigManager.TwitchSubEvent_Tier2EnemyMultiplier.Value; } else if ((int)subEvent.Tier == 3) { num *= ConfigManager.TwitchSubEvent_Tier3EnemyMultiplier.Value; } ViewerData viewer = new ViewerData(((TwitchEvent)subEvent).User); string spawnReason = GetSpawnReason(subEvent); SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, num, spawnReason); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); } public static void HandleRaid(TwitchRaidEvent raidEvent) { //IL_004c: 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_00a7: Unknown result type (might be due to invalid IL or missing references) if (TwitchIntegrationManager.IsRaidEventEnabled) { if (raidEvent == null) { Logger.LogError("[TwitchEventHandler] Failed to handle raid. TwitchRaidEvent is null."); return; } if (!CanPlayEventsOnLocalPlayer()) { TwitchEventQueue.Enqueue(raidEvent); return; } int value = ConfigManager.TwitchRaidEvent_ViewersPerEnemy.Value; int value2 = ConfigManager.TwitchRaidEvent_MaxSpawnCount.Value; int spawnCount = Mathf.Clamp(raidEvent.ViewerCount / value, 1, value2); ViewerData viewer = new ViewerData(((TwitchEvent)raidEvent).User); string spawnReason = $"by raiding with {raidEvent.ViewerCount} viewers"; SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, spawnCount, spawnReason); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); } } private static string GetSpawnReason(TwitchSubEvent subEvent) { //IL_0010: 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_004c: Invalid comparison between Unknown and I4 //IL_0018: 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_0098: Invalid comparison between Unknown and I4 //IL_004f: 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_003a: Expected I4, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected I4, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected I4, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected I4, but got Unknown if (subEvent == null) { return string.Empty; } string result = string.Empty; if ((int)subEvent.Type == 0) { result = (((int)subEvent.Tier != 0) ? $"by subbing at tier {(int)subEvent.Tier}" : "by subbing with prime"); } else if ((int)subEvent.Type == 1) { result = (((int)subEvent.Tier != 0) ? $"by resubbing at tier {(int)subEvent.Tier} for {subEvent.CumulativeMonths} months" : $"by resubbing with prime for {subEvent.CumulativeMonths} months"); } else if ((int)subEvent.Type == 2) { result = $"by gifting a tier {(int)subEvent.Tier} sub to {subEvent.RecipientUser}"; } else if ((int)subEvent.Type == 3) { result = $"by gifting {subEvent.GiftCount} tier {(int)subEvent.Tier} subs"; } return result; } public static bool CanPlayEventsOnPlayer(PlayerControllerB playerScript) { if (!TwitchIntegrationManager.IsEnabled) { return false; } return EnemyHelper.CanSpawnEnemiesOnPlayer(playerScript); } public static bool CanPlayEventsOnLocalPlayer() { return CanPlayEventsOnPlayer(PlayerUtils.LocalPlayerScript); } } internal static class TwitchEventQueue { [CompilerGenerated] private sealed class d__18 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TimeSpan initialDelay; private TimeSpan 5__2; 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() { <>1__state = -2; } private bool MoveNext() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown TwitchSubEvent result; TwitchCheerEvent result2; switch (<>1__state) { default: return false; case 0: <>1__state = -1; Logger.LogInfo(string.Format("[{0}] Playing queued events after {1} seconds.", "TwitchEventQueue", (float)initialDelay.TotalSeconds), extended: true); <>2__current = (object)new WaitForSeconds((float)initialDelay.TotalSeconds); <>1__state = 1; return true; case 1: <>1__state = -1; if (!TwitchEventHandler.CanPlayEventsOnLocalPlayer()) { Logger.LogWarning("[TwitchEventQueue] Failed to play queued events. You are not allowed to play events at this time."); return false; } if (!HasQueuedEvents()) { Logger.LogInfo("[TwitchEventQueue] No events in the queue to play.", extended: true); return false; } MessageManger.Instance?.ShowMessage_LocalClient("Playing Twitch events from the queue"); 5__2 = TimeSpan.FromSeconds(0.5); goto IL_00c8; case 2: <>1__state = -1; goto IL_00c8; case 3: <>1__state = -1; goto IL_0115; case 4: { <>1__state = -1; break; } IL_0115: if (TwitchIntegrationManager.IsSubEventEnabled && _subQueue.TryDequeue(out result)) { if (!TwitchEventHandler.CanPlayEventsOnLocalPlayer()) { return false; } TwitchEventHandler.HandleSub(result); <>2__current = (object)new WaitForSeconds((float)5__2.TotalSeconds); <>1__state = 3; return true; } break; IL_00c8: if (TwitchIntegrationManager.IsCheerEventEnabled && _cheerQueue.TryDequeue(out result2)) { if (!TwitchEventHandler.CanPlayEventsOnLocalPlayer()) { return false; } TwitchEventHandler.HandleCheer(result2); <>2__current = (object)new WaitForSeconds((float)5__2.TotalSeconds); <>1__state = 2; return true; } goto IL_0115; } if (TwitchIntegrationManager.IsRaidEventEnabled && _raidQueue.TryDequeue(out var result3)) { if (!TwitchEventHandler.CanPlayEventsOnLocalPlayer()) { return false; } TwitchEventHandler.HandleRaid(result3); <>2__current = (object)new WaitForSeconds((float)5__2.TotalSeconds); <>1__state = 4; return true; } Logger.LogInfo("[TwitchEventQueue] Finished plyaing queued events.", extended: true); SaveData(); _playQueuedEventsCoroutine = null; 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 Queue _cheerQueue = new Queue(); private static Queue _subQueue = new Queue(); private static Queue _raidQueue = new Queue(); private static Coroutine _playQueuedEventsCoroutine; public static IReadOnlyCollection CheerQueue => _cheerQueue; public static IReadOnlyCollection SubQueue => _subQueue; public static IReadOnlyCollection RaidQueue => _raidQueue; public static void Initialize() { LoadData(); Application.quitting += SaveData; } private static void LoadData() { Logger.LogInfo("[TwitchEventQueue] Loading saved data..."); try { if (Plugin.GlobalSave.TryLoad("CheerQueue", out var value)) { _cheerQueue = QueueJsonConverterHelper.DeserializeQueue(value); Logger.LogInfo("[TwitchEventQueue] Loaded CheerQueue JSON data:\n\n" + value, extended: true); } if (Plugin.GlobalSave.TryLoad("SubQueue", out value)) { _subQueue = QueueJsonConverterHelper.DeserializeQueue(value); Logger.LogInfo("[TwitchEventQueue] Loaded SubQueue JSON data:\n\n" + value, extended: true); } if (Plugin.GlobalSave.TryLoad("RaidQueue", out value)) { _raidQueue = QueueJsonConverterHelper.DeserializeQueue(value); Logger.LogInfo("[TwitchEventQueue] Loaded RaidQueue JSON data:\n\n" + value, extended: true); } Logger.LogInfo("[TwitchEventQueue] Finished loading saved data."); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to load saved data. {1}", "TwitchEventQueue", arg)); } } private static void SaveData() { Logger.LogInfo("[TwitchEventQueue] Saving data...", extended: true); try { SaveCheerQueue(); SaveSubQueue(); SaveRaidQueue(); Logger.LogInfo("[TwitchEventQueue] Saved data.", extended: true); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Failed to save data. {1}", "TwitchEventQueue", arg)); } } private static void SaveCheerQueue() { try { Plugin.GlobalSave.Save("CheerQueue", QueueJsonConverterHelper.SerializeQueue(_cheerQueue)); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] {1}: Failed to save data. {2}", "TwitchEventQueue", "SaveCheerQueue", arg)); } } private static void SaveSubQueue() { try { Plugin.GlobalSave.Save("SubQueue", QueueJsonConverterHelper.SerializeQueue(_subQueue)); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] {1}: Failed to save data. {2}", "TwitchEventQueue", "SaveSubQueue", arg)); } } private static void SaveRaidQueue() { try { Plugin.GlobalSave.Save("RaidQueue", QueueJsonConverterHelper.SerializeQueue(_raidQueue)); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] {1}: Failed to save data. {2}", "TwitchEventQueue", "SaveRaidQueue", arg)); } } public static void PlayQueuedEvents() { PlayQueuedEvents(TimeSpan.Zero); } public static void PlayQueuedEvents(TimeSpan initialDelay) { if (!TwitchIntegrationManager.IsEnabled) { Logger.LogWarning("[TwitchEventQueue] Failed to play queued events. Twitch integration is not enabled."); return; } if ((Object)(object)SpawnEventHandler.Instance == (Object)null) { Logger.LogWarning("[TwitchEventQueue] Failed to play queued events. ViewerSpawnEventHandler instance is null."); return; } if (_playQueuedEventsCoroutine != null) { CoroutineRunner.Stop(_playQueuedEventsCoroutine); } _playQueuedEventsCoroutine = CoroutineRunner.Start(PlayQueuedEventsCoroutine(initialDelay)); } [IteratorStateMachine(typeof(d__18))] private static IEnumerator PlayQueuedEventsCoroutine(TimeSpan initialDelay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0) { initialDelay = initialDelay }; } public static bool HasQueuedEvents() { if (_cheerQueue.Count <= 0 && _subQueue.Count <= 0) { return _raidQueue.Count > 0; } return true; } public static void Enqueue(TwitchCheerEvent cheerEvent) { if (!_cheerQueue.Contains(cheerEvent)) { _cheerQueue.Enqueue(cheerEvent); SaveCheerQueue(); ShowEnqueueMessage((TwitchEvent)(object)cheerEvent, "cheer"); } } public static void Enqueue(TwitchSubEvent subEvent) { if (!_subQueue.Contains(subEvent)) { _subQueue.Enqueue(subEvent); SaveSubQueue(); ShowEnqueueMessage((TwitchEvent)(object)subEvent, "sub"); } } public static void Enqueue(TwitchRaidEvent raidEvent) { if (!_raidQueue.Contains(raidEvent)) { _raidQueue.Enqueue(raidEvent); SaveRaidQueue(); ShowEnqueueMessage((TwitchEvent)(object)raidEvent, "raid"); } } private static void ShowEnqueueMessage(TwitchEvent twitchEvent, string eventName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) string displayNameWithReadableColor = twitchEvent.User.GetDisplayNameWithReadableColor(); string message = "Added Twitch " + eventName + " event from " + displayNameWithReadableColor + " to queue"; MessageManger.Instance?.ShowMessage_LocalClient(message); } } } namespace com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands { public class ParsedArgs { private readonly Dictionary _named; private readonly List _positional; public IReadOnlyDictionary Named => _named; public IReadOnlyList Positional => _positional; public ParsedArgs(Dictionary named, List positional) { _named = named; _positional = positional; } public bool HasFlag(string key) { return _named.ContainsKey(key); } public bool TryGet(string key, out string value) { return _named.TryGetValue(key, out value); } public string Get(string key, string defaultValue = "") { if (!TryGet(key, out var value)) { return defaultValue; } return value; } public bool TryGetInt(string key, out int value) { return int.TryParse(Get(key), out value); } public int GetInt(string key, int defaultValue = 0) { if (!TryGetInt(key, out var value)) { return defaultValue; } return value; } public bool TryGetFloat(string key, out float value) { return float.TryParse(Get(key), out value); } public float GetFloat(string key, float defaultValue = 0f) { if (!TryGetFloat(key, out var value)) { return defaultValue; } return value; } public bool TryGetPositional(int index, out string value) { if (index >= _positional.Count) { value = null; return false; } value = _positional[index]; return true; } public string GetPositional(int index, string defaultValue = "") { if (!TryGetPositional(index, out var value)) { return defaultValue; } return value; } public bool TryGetPositionalInt(int index, out int value) { if (!TryGetPositional(index, out var value2)) { value = 0; return false; } return int.TryParse(value2, out value); } public int GetPositionalInt(int index, int defaultValue = 0) { if (!TryGetPositionalInt(index, out var value)) { return defaultValue; } return value; } public bool TryGetPositionalFloat(int index, out float value) { if (!TryGetPositional(index, out var value2)) { value = 0f; return false; } return float.TryParse(value2, out value); } public float GetPositionalFloat(int index, float defaultValue = 0f) { if (!TryGetPositionalFloat(index, out var value)) { return defaultValue; } return value; } public static ParsedArgs Parse(string[] args) { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); List list = new List(); int num = 0; while (num < args.Length) { string text = args[num]; if (text.StartsWith("--")) { string text2 = text; string key = text2.Substring(2, text2.Length - 2); if (num + 1 >= args.Length || args[num + 1].StartsWith("--")) { dictionary[key] = "true"; num++; } else { dictionary[key] = args[num + 1]; num += 2; } } else { list.Add(text); num++; } } return new ParsedArgs(dictionary, list); } } internal abstract class TwitchCommand { private ConfigEntry _enabled; private bool _boundConfigs; public abstract string Name { get; } public abstract bool EnabledByDefault { get; } public abstract bool EnableConfigs { get; } public bool IsEnabled => _enabled?.Value ?? EnabledByDefault; public abstract void Execute(TwitchMessage twitchMessage, string[] args); public void PreBindConfigs() { if (!_boundConfigs) { _boundConfigs = true; string section = "Command: " + Name; _enabled = ConfigHelper.Bind(section, "Enabled", EnabledByDefault, "Enable " + Name + " Twitch chat command."); BindConfigs(section); } } protected virtual void BindConfigs(string section) { } protected string ParseUsername(string input) { return input.Replace("@", ""); } } internal static class TwitchCommandManager { private static readonly Dictionary _commands = new Dictionary(StringComparer.OrdinalIgnoreCase); public static bool IsEnabled => ConfigManager.TwitchChatCommands_Enabled.Value; public static string Prefix => ConfigManager.TwitchChatCommands_Prefix.Value; public static IReadOnlyDictionary Commands => _commands; public static void Initialize() { Register(new DevSpawnCommand()); Register(new DevPlushiesCommand()); Register(new DevCheerCommand()); Register(new DevSubCommand()); Register(new DevRaidCommand()); Register(new PlayQueueCommand()); Register(new ViewConfigCommand()); Register(new SetConfigCommand()); Register(new GiveSpawnCommand()); Register(new GiveSpawnRandomCommand()); Register(new InfoCommand()); Register(new ViewPlayersCommand()); Register(new ViewAllSpawnCommand()); Register(new ViewAllBitsCommand()); Register(new LustySpawnCommand()); Register(new SpawnCommand()); Register(new CrewSpawnCommand()); Register(new PlushiesCommand()); Register(new CrewPlushiesCommand()); Register(new ViewSpawnCommand()); Register(new ViewBitsCommand()); Register(new TargetCommand()); Register(new ClearTargetCommand()); Register(new ViewTargetCommand()); } public static void Register(TwitchCommand command) { _commands[command.Name] = command; if (command.EnableConfigs) { command.PreBindConfigs(); } } public static void Dispatch(TwitchMessage twitchMessage) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled) { return; } string message = ((TwitchMessage)(ref twitchMessage)).Message; if (string.IsNullOrWhiteSpace(message) || !message.StartsWith(Prefix)) { return; } string[] array = Tokenize(message.Trim()); if (array.Length == 0) { return; } string key = array[0].Substring(Prefix.Length); if (!_commands.TryGetValue(key, out var value) || !value.IsEnabled) { return; } string[] subArray = array[1..]; try { value.Execute(twitchMessage, subArray); } catch (Exception arg) { Logger.LogError(string.Format("[{0}] Error running command \"{1}\". {2}", "TwitchCommandManager", value.GetType().Name, arg)); } } private static string[] Tokenize(string input) { List list = new List(); StringBuilder stringBuilder = new StringBuilder(); bool flag = false; char c = '"'; foreach (char c2 in input) { if (flag) { if (c2 == c) { flag = false; } else { stringBuilder.Append(c2); } } else if (c2 == '"' || c2 == '\'') { flag = true; c = c2; } else if (char.IsWhiteSpace(c2)) { if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString()); stringBuilder.Clear(); } } else { stringBuilder.Append(c2); } } if (stringBuilder.Length > 0) { list.Add(stringBuilder.ToString()); } return list.ToArray(); } } } namespace com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Special { internal class LustySpawnCommand : TwitchCommand { public override string Name => "lustyspawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //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_0020: 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) TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; if (((TwitchUser)(ref user)).Username.Equals_OrdinalIgnoreCase("LustStings") || ((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { ParsedArgs parsedArgs = ParsedArgs.Parse(args); string targetEnemyName = parsedArgs.GetPositional(0, "Blob"); int spawnCount = parsedArgs.GetPositionalInt(1, 69); string targetPlayerUsername = parsedArgs.GetPositional(2); string spawnReason = "by being susty"; if (parsedArgs.TryGet("enemy", out var value)) { targetEnemyName = value; } if (parsedArgs.TryGetInt("count", out var value2)) { spawnCount = value2; } if (parsedArgs.TryGetInt("amount", out value2)) { spawnCount = value2; } if (parsedArgs.TryGet("target", out value)) { targetPlayerUsername = value; } if (parsedArgs.TryGet("reason", out value)) { spawnReason = value; } ViewerData viewer = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); DevSpawnCommand.SpawnEnemy(viewer, spawnCount, spawnReason, targetEnemyName, targetPlayerUsername, null, 69); } } } } namespace com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Public { internal class ClearTargetCommand : TwitchCommand { public override string Name => "cleartarget"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; PlayerControllerB target = TargetPlayerManager.GetTarget(((TwitchUser)(ref user)).Username); if ((Object)(object)target == (Object)null) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " is not targeting anyone"); return; } user = ((TwitchMessage)(ref twitchMessage)).User; TargetPlayerManager.RemoveTarget(((TwitchUser)(ref user)).Username); MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " has stopped targeting " + target.playerUsername); } } internal class CrewPlushiesCommand : TwitchCommand { public override string Name => "crewplushies"; public override bool EnabledByDefault => true; public override bool EnableConfigs => true; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (!SpawnPointManager.IsEnabled) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); string positional = parsedArgs.GetPositional(0); string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); PlayerControllerB playerScript; if (!string.IsNullOrWhiteSpace(positional)) { if (!PlayerUtils.TryGetPlayerScriptByUsername(positional, out playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " no player was found with the name \"" + positional + "\""); return; } if (PlayerUtils.IsLocalPlayer(playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " you can not target the local player"); return; } } else { TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; if (!TargetPlayerManager.TryGetTarget(((TwitchUser)(ref user)).Username, out playerScript)) { playerScript = PlayerUtils.GetRandomPlayerScript(PlayerUtils.AlivePlayerScripts, excludeLocal: true); } } if (!((Object)(object)playerScript == (Object)null)) { ViewerData viewer = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); SpawnPointManager.SpawnPlusheisUsingPoints(viewer, playerScript); } } } internal class CrewSpawnCommand : TwitchCommand { public override string Name => "crewspawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => true; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if (!SpawnPointManager.IsEnabled) { return; } int num = 1; string text = string.Empty; ParsedArgs parsedArgs = ParsedArgs.Parse(args); if (parsedArgs.TryGetPositionalInt(0, out var value)) { num = value; } else { text = ParseUsername(parsedArgs.GetPositional(0)); } string value2; if (parsedArgs.TryGetPositionalInt(1, out value)) { num = value; } else if (string.IsNullOrWhiteSpace(text) && parsedArgs.TryGetPositional(1, out value2)) { text = value2; } if (num <= 0) { return; } string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); PlayerControllerB playerScript; if (!string.IsNullOrWhiteSpace(text)) { if (!PlayerUtils.TryGetPlayerScriptByUsername(text, out playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " no player was found with the name \"" + text + "\""); return; } if (PlayerUtils.IsLocalPlayer(playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " you can not target the local player"); return; } } else { TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; if (!TargetPlayerManager.TryGetTarget(((TwitchUser)(ref user)).Username, out playerScript)) { playerScript = PlayerUtils.GetRandomPlayerScript(PlayerUtils.AlivePlayerScripts, excludeLocal: true); } } if (!((Object)(object)playerScript == (Object)null)) { ViewerData viewer = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); SpawnPointManager.SpawnEnemiesUsingPoints(viewer, num, playerScript); } } } internal class PlushiesCommand : TwitchCommand { public override string Name => "plushies"; public override bool EnabledByDefault => true; public override bool EnableConfigs => true; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (SpawnPointManager.IsEnabled) { ViewerData viewer = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); SpawnPointManager.SpawnPlusheisUsingPoints(viewer, PlayerUtils.LocalPlayerScript); } } } internal class SpawnCommand : TwitchCommand { public override string Name => "spawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => true; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (SpawnPointManager.IsEnabled) { ParsedArgs parsedArgs = ParsedArgs.Parse(args); int positionalInt = parsedArgs.GetPositionalInt(0, 1); if (positionalInt > 0) { ViewerData viewer = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); SpawnPointManager.SpawnEnemiesUsingPoints(viewer, positionalInt, PlayerUtils.LocalPlayerScript); } } } } internal class TargetCommand : TwitchCommand { private ConfigEntry _excludePlayers; public override string Name => "target"; public override bool EnabledByDefault => true; public override bool EnableConfigs => true; public string[] ExcludePlayersArray => _excludePlayers.Value.StringToCollection().ToArray(); public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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) string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); if (args.Length < 1) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " must specify a target username in the command. Partial usernames will work too. " + TwitchCommandManager.Prefix + Name + " "); return; } string text = ParseUsername(args[0]); if (!PlayerUtils.TryGetPlayerScriptByUsername(text, out var playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " no player was found with the name \"" + text + "\""); return; } if (ExcludePlayersArray.Contains(playerScript.playerUsername, StringComparer.OrdinalIgnoreCase)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " you are not able to target " + playerScript.playerUsername); return; } if (PlayerUtils.IsLocalPlayer(playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " you can not target the local player"); return; } TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; TargetPlayerManager.SetTarget(((TwitchUser)(ref user)).Username, playerScript); string message = displayNameWithReadableColor + " is now targeting " + playerScript.playerUsername; MessageManger.Instance?.ShowMessage_LocalClient(message); } protected override void BindConfigs(string section) { _excludePlayers = ConfigHelper.Bind(section, "ExcludePlayers", "", "List of players to exclude from being targeted. Comma-separated list of player usernames."); } } internal class ViewBitsCommand : TwitchCommand { public override string Name => "viewbits"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //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_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) ParsedArgs parsedArgs = ParsedArgs.Parse(args); string text = ParseUsername(parsedArgs.GetPositional(0)); string text2; string colorHex; if (!string.IsNullOrWhiteSpace(text) && text.Length >= 4) { TwitchUser val = default(TwitchUser); if (API.TryGetUserByUsername(text, ref val)) { text2 = ((TwitchUser)(ref val)).DisplayName; colorHex = ((TwitchUser)(ref val)).Color; } else { text2 = text; colorHex = "#FFFFFF"; } } else { TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; text2 = ((TwitchUser)(ref user)).DisplayName; user = ((TwitchMessage)(ref twitchMessage)).User; colorHex = ((TwitchUser)(ref user)).Color; } int num = AccumulatedBitManger.Get(text2); string arg = ((num == 1) ? "" : "s"); MessageManger.Instance?.ShowMessage_LocalClient($"{text2.RichReadableColor(colorHex)} has {num} accumulated bit{arg}"); } } internal class ViewSpawnCommand : TwitchCommand { public override string Name => "viewspawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //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_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) if (!SpawnPointManager.IsEnabled) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); string text = ParseUsername(parsedArgs.GetPositional(0)); string text2; string colorHex; if (!string.IsNullOrWhiteSpace(text) && text.Length >= 4) { TwitchUser val = default(TwitchUser); if (API.TryGetUserByUsername(text, ref val)) { text2 = ((TwitchUser)(ref val)).DisplayName; colorHex = ((TwitchUser)(ref val)).Color; } else { text2 = text; colorHex = "#FFFFFF"; } } else { TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; text2 = ((TwitchUser)(ref user)).DisplayName; user = ((TwitchMessage)(ref twitchMessage)).User; colorHex = ((TwitchUser)(ref user)).Color; } float num = SpawnPointManager.Get(text2); string arg = ((num == 1f) ? "" : "s"); MessageManger.Instance?.ShowMessage_LocalClient($"{text2.RichReadableColor(colorHex)} has {num} spawn point{arg}"); } } internal class ViewTargetCommand : TwitchCommand { public override string Name => "viewtarget"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0018: 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_0007: Unknown result type (might be due to invalid IL or missing references) if (args.Length > 1) { ExecuteForViewer(twitchMessage, ParseUsername(args[0])); return; } TwitchMessage twitchMessage2 = twitchMessage; TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; ExecuteForViewer(twitchMessage2, ((TwitchUser)(ref user)).Username); } private void ExecuteForViewer(TwitchMessage twitchMessage, string targetViewerUsername) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: Unknown result type (might be due to invalid IL or missing references) string s = targetViewerUsername; string colorHex = "#FFFFFF"; TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; TwitchUser val = default(TwitchUser); if (((TwitchUser)(ref user)).Username == targetViewerUsername) { user = ((TwitchMessage)(ref twitchMessage)).User; s = ((TwitchUser)(ref user)).DisplayName; user = ((TwitchMessage)(ref twitchMessage)).User; colorHex = ((TwitchUser)(ref user)).Color; } else if (API.TryGetUserByUsername(targetViewerUsername, ref val)) { s = ((TwitchUser)(ref val)).DisplayName; colorHex = ((TwitchUser)(ref val)).Color; } string text = s.RichReadableColor(colorHex); PlayerControllerB target = TargetPlayerManager.GetTarget(targetViewerUsername); if ((Object)(object)target == (Object)null) { MessageManger.Instance?.ShowMessage_LocalClient(text + " is not targeting anyone"); } else { MessageManger.Instance?.ShowMessage_LocalClient(text + " is targeting " + target.playerUsername); } } } } namespace com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Moderator { internal class GiveSpawnCommand : TwitchCommand { public override string Name => "givespawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_000a: 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) if (!SpawnPointManager.IsEnabled || !((TwitchMessage)(ref twitchMessage)).User.IsModeratorOrHigher()) { return; } string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); ParsedArgs parsedArgs = ParsedArgs.Parse(args); string text = ParseUsername(parsedArgs.GetPositional(0)); if (string.IsNullOrWhiteSpace(text) || text.Length < 4) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " command usage is " + TwitchCommandManager.Prefix + Name + " "); return; } float positionalFloat = parsedArgs.GetPositionalFloat(1, SpawnPointManager.PriceForEnemy); string s = text; string colorHex = "#FFFFFF"; TwitchUser val = default(TwitchUser); if (API.TryGetUserByUsername(text, ref val)) { s = ((TwitchUser)(ref val)).DisplayName; colorHex = ((TwitchUser)(ref val)).Color; } string text2 = s.RichReadableColor(colorHex); SpawnPointManager.Add(text, positionalFloat); float num = SpawnPointManager.Get(text); string text3 = ((positionalFloat > 0f) ? "gave" : "removed"); string text4 = ((positionalFloat == 1f) ? "" : "s"); MessageManger.Instance?.ShowMessage_LocalClient($"{displayNameWithReadableColor} {text3} {text2} {Mathf.Abs(positionalFloat)} spawn point{text4} ({num} total) {SpawnPointManager.UseSpawnPointText}"); } } internal class GiveSpawnRandomCommand : TwitchCommand { public override string Name => "givespawnrandom"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //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_001b: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) if (SpawnPointManager.IsEnabled && ((TwitchMessage)(ref twitchMessage)).User.IsModeratorOrHigher()) { string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); ParsedArgs parsedArgs = ParsedArgs.Parse(args); float positionalFloat = parsedArgs.GetPositionalFloat(0, SpawnPointManager.PriceForEnemy); int positionalInt = parsedArgs.GetPositionalInt(1, 1); TwitchUser[] array = (from user in API.GetUsersSeenWithin(TimeSpan.FromMinutes(positionalInt)) where IsUserAllowedForGiveaway(user, ((TwitchMessage)(ref twitchMessage)).User) select user).ToArray(); if (array.Length == 0) { string arg = ((positionalInt == 1) ? "" : "s"); MessageManger.Instance?.ShowMessage_LocalClient($"Could not find any active Twitch users within {positionalInt} minute{arg} for the giveaway"); return; } TwitchUser twitchUser = array[Random.Range(0, array.Length)]; MessageManger.Instance?.ShowMessage_LocalClient(twitchUser.GetDisplayNameWithReadableColor() + " won the spawn points giveaway!"); SpawnPointManager.Add(((TwitchUser)(ref twitchUser)).Username, positionalFloat); float num = SpawnPointManager.Get(((TwitchUser)(ref twitchUser)).Username); string text = ((positionalFloat == 1f) ? "" : "s"); MessageManger.Instance?.ShowMessage_LocalClient($"{twitchUser.GetDisplayNameWithReadableColor()} received {positionalFloat} spawn point{text} ({num} total) {SpawnPointManager.UseSpawnPointText}"); } } private static bool IsUserAllowedForGiveaway(TwitchUser twitchUser, TwitchUser executingTwitchUser) { //IL_0005: 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_0020: Unknown result type (might be due to invalid IL or missing references) if (false && twitchUser == executingTwitchUser) { return false; } if (true && ((TwitchUser)(ref twitchUser)).IsBroadcaster) { return false; } if (TwitchIntegrationManager.IsBotUser(twitchUser)) { return false; } return true; } } internal class InfoCommand : TwitchCommand { public override string Name => "info"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsModeratorOrHigher()) { return; } bool isSubEventEnabled = TwitchIntegrationManager.IsSubEventEnabled; bool isCheerEventEnabled = TwitchIntegrationManager.IsCheerEventEnabled; bool isRaidEventEnabled = TwitchIntegrationManager.IsRaidEventEnabled; bool isEnabled = SpawnPointManager.IsEnabled; MessageSettings messageSettings = new MessageSettings(25f); MessageManger.Instance?.ShowMessage_LocalClient("--- MonsterHotkeys v3.2.0 Info ---", messageSettings); if (!isSubEventEnabled && !isCheerEventEnabled && !isRaidEventEnabled && !isEnabled) { MessageManger.Instance?.ShowMessage_LocalClient("subs/cheers/raids/spawn-points are not enabled", messageSettings); return; } if (isSubEventEnabled) { int num = 1; int value = ConfigManager.TwitchSubEvent_Tier2EnemyMultiplier.Value; int value2 = ConfigManager.TwitchSubEvent_Tier3EnemyMultiplier.Value; MessageManger.Instance?.ShowMessage_LocalClient($"Tier 1 sub/gift = {num} Random Enemy", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"Tier 2 sub/gift = {num * value} Random Enemy", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"Tier 3 sub/gift = {num * value2} Random Enemy", messageSettings); } if (isCheerEventEnabled) { MessageManger.Instance?.ShowMessage_LocalClient($"{TwitchCheerHandler.PriceForEnemy} bits = Random Enemy", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"{TwitchCheerHandler.PriceForPlushies} bits = Random Plushies", messageSettings); } if (isRaidEventEnabled) { int value3 = ConfigManager.TwitchRaidEvent_ViewersPerEnemy.Value; int value4 = ConfigManager.TwitchRaidEvent_MaxSpawnCount.Value; MessageManger.Instance?.ShowMessage_LocalClient($"Raids: Every {value3} viewers = Random Enemy ({value4} max)", messageSettings); } if (SpawnPointManager.IsEnabled) { MessageManger.Instance?.ShowMessage_LocalClient($"{SpawnPointManager.PriceForEnemy} spawn points = Random Enemy", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"{SpawnPointManager.PriceForPlushies} spawn points = Random Plushies", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"Death = {SpawnPointManager.RewardPointsPerDeath} spawn points reward", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"Crewmate Death = {SpawnPointManager.RewardPointsPerCrewmateDeath} spawn points reward", messageSettings); MessageManger.Instance?.ShowMessage_LocalClient($"{SpawnPointManager.MaxEnemySpawnsPerDay} max enemy spawns from spawn points per in-game day", messageSettings); } MessageManger.Instance?.ShowMessage_LocalClient($"DEBUG: {PlayerDamagePatcher.TranspilersCreated} transpilers created", messageSettings); } } internal class ViewAllBitsCommand : TwitchCommand { public override string Name => "viewallbits"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsModeratorOrHigher()) { return; } if (AccumulatedBitManger.AccumulatedBits.Count == 0) { MessageManger.Instance?.ShowMessage_LocalClient("Nobody has accumulated any bits"); return; } int columns = 1; if (AccumulatedBitManger.AccumulatedBits.Count >= 20) { columns = 3; } else if (AccumulatedBitManger.AccumulatedBits.Count >= 10) { columns = 2; } Dictionary keyValuePair = AccumulatedBitManger.AccumulatedBits.OrderByDescending((KeyValuePair x) => x.Value).ToDictionary((KeyValuePair a) => a.Key, (KeyValuePair b) => b.Value); MessageManger.Instance?.ShowMessage_LocalClient(Utils.GetFormattedKeyValuePairMessage(keyValuePair, columns, "{key} {value} bits")); } } internal class ViewAllSpawnCommand : TwitchCommand { public override string Name => "viewallspawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!SpawnPointManager.IsEnabled || !((TwitchMessage)(ref twitchMessage)).User.IsModeratorOrHigher()) { return; } if (SpawnPointManager.SpawnPoints.Count == 0) { MessageManger.Instance?.ShowMessage_LocalClient("Nobody has spawn points"); return; } int columns = 1; if (SpawnPointManager.SpawnPoints.Count >= 20) { columns = 3; } else if (SpawnPointManager.SpawnPoints.Count >= 10) { columns = 2; } Dictionary keyValuePair = SpawnPointManager.SpawnPoints.OrderByDescending((KeyValuePair x) => x.Value).ToDictionary((KeyValuePair a) => a.Key, (KeyValuePair b) => b.Value); MessageManger.Instance?.ShowMessage_LocalClient(Utils.GetFormattedKeyValuePairMessage(keyValuePair, columns, "{key} {value} sp")); } } internal class ViewPlayersCommand : TwitchCommand { public override string Name => "viewplayers"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsModeratorOrHigher()) { return; } PlayerControllerB[] connectedPlayerScripts = PlayerUtils.ConnectedPlayerScripts; if (connectedPlayerScripts.Length != 0) { MessageManger.Instance?.ShowMessage_LocalClient("Players in the lobby:"); PlayerControllerB[] array = connectedPlayerScripts; foreach (PlayerControllerB val in array) { MessageManger.Instance?.ShowMessage_LocalClient(val.playerUsername ?? ""); } } } } } namespace com.github.zehsteam.MonsterHotkeys.Twitch.ChatCommands.Commands.Developer { internal class DevCheerCommand : TwitchCommand { public override string Name => "devcheer"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: 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_0051: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); int num = parsedArgs.GetPositionalInt(0, TwitchCheerHandler.PriceForEnemy); if (parsedArgs.TryGetInt("count", out var value)) { num = value; } if (parsedArgs.TryGetInt("amount", out value)) { num = value; } if (num <= 0) { return; } TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; if (parsedArgs.TryGet("viewer", out var value2)) { value2 = ParseUsername(value2); TwitchUser val = default(TwitchUser); if (!API.TryGetUserByUsername(value2, ref val)) { return; } user = val; } TwitchCheerEvent cheerEvent = new TwitchCheerEvent { Channel = ((TwitchMessage)(ref twitchMessage)).Channel, User = user, Message = $"cheer{num}", Tags = ((TwitchMessage)(ref twitchMessage)).Tags, CheerAmount = num }; TwitchEventHandler.HandleCheer(cheerEvent); } } internal class DevPlushiesCommand : TwitchCommand { public override string Name => "devplushies"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsDeveloper() || (Object)(object)PlushieManager.Instance == (Object)null) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); string text = parsedArgs.GetPositional(0); string text2 = parsedArgs.GetPositional(1); string text3 = "by being the mod developer"; if (parsedArgs.TryGet("id", out var value)) { text = value; } if (parsedArgs.TryGet("target", out value)) { text2 = value; } if (parsedArgs.TryGet("reason", out value)) { text3 = value; } string displayNameWithReadableColor = ((TwitchMessage)(ref twitchMessage)).User.GetDisplayNameWithReadableColor(); PlayerControllerB playerScript; if (!string.IsNullOrWhiteSpace(text2)) { if (!PlayerUtils.TryGetPlayerScriptByUsername(text2, out playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " no player was found with the name \"" + text2 + "\""); return; } } else { playerScript = PlayerUtils.LocalPlayerScript; } if ((Object)(object)playerScript == (Object)null) { return; } if (!PlushieManager.Instance.CanSpawnPlushiesOnPlayer(playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " cannot spawn plushies on " + playerScript.playerUsername + " right now"); return; } if (!string.IsNullOrWhiteSpace(text) && !PlushieManager.Instance.PoolExists(text)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " there are no plushies with the id of \"" + text + "\""); return; } ViewerData viewerData; if (parsedArgs.TryGet("viewer", out var value2)) { value2 = ParseUsername(value2); TwitchUser user = default(TwitchUser); viewerData = ((!API.TryGetUserByUsername(value2, ref user)) ? new ViewerData(value2, value2, value2, "#FFFFFF") : new ViewerData(user)); } else { viewerData = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); } ViewerData viewer = viewerData; string spawnReason = text3; string targetPoolId = text; ulong? spawnedOnClientId = playerScript.actualClientId; SpawnPlushiesData spawnPlushiesData = new SpawnPlushiesData(viewer, SpawnSource.Twitch, spawnReason, targetPoolId, null, spawnedOnClientId); PlushieManager.Instance?.SpawnPlushiesFromData(spawnPlushiesData); } } internal class DevRaidCommand : TwitchCommand { public override string Name => "devraid"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_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_0091: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_0072: 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) if (!((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); int num = parsedArgs.GetPositionalInt(0, 1); if (parsedArgs.TryGetInt("count", out var value)) { num = value; } if (parsedArgs.TryGetInt("amount", out value)) { num = value; } if (num <= 0) { return; } TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; if (parsedArgs.TryGet("viewer", out var value2)) { value2 = ParseUsername(value2); TwitchUser val = default(TwitchUser); if (!API.TryGetUserByUsername(value2, ref val)) { return; } user = val; } TwitchRaidEvent raidEvent = new TwitchRaidEvent { Channel = ((TwitchMessage)(ref twitchMessage)).Channel, User = user, Message = $"cheer{num}", Tags = ((TwitchMessage)(ref twitchMessage)).Tags, ViewerCount = num }; TwitchEventHandler.HandleRaid(raidEvent); } } internal class DevSpawnCommand : TwitchCommand { public override string Name => "devspawn"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if (((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { ParsedArgs parsedArgs = ParsedArgs.Parse(args); string targetEnemyName = parsedArgs.GetPositional(0); int spawnCount = parsedArgs.GetPositionalInt(1, 1); string targetPlayerUsername = parsedArgs.GetPositional(2); string spawnReason = "by being the mod developer"; if (parsedArgs.TryGet("enemy", out var value)) { targetEnemyName = value; } if (parsedArgs.TryGetInt("count", out var value2)) { spawnCount = value2; } if (parsedArgs.TryGetInt("amount", out value2)) { spawnCount = value2; } if (parsedArgs.TryGet("target", out value)) { targetPlayerUsername = value; } if (parsedArgs.TryGet("reason", out value)) { spawnReason = value; } ViewerData viewer; if (parsedArgs.TryGet("viewer", out var value3)) { value3 = ParseUsername(value3); TwitchUser user = default(TwitchUser); viewer = ((!API.TryGetUserByUsername(value3, ref user)) ? new ViewerData(value3, value3, value3, "#FFFFFF") : new ViewerData(user)); } else { viewer = new ViewerData(((TwitchMessage)(ref twitchMessage)).User); } SpawnEnemy(viewer, spawnCount, spawnReason, targetEnemyName, targetPlayerUsername); } } public static void SpawnEnemy(ViewerData viewer, int spawnCount, string spawnReason, string targetEnemyName = "", string targetPlayerUsername = "", ulong? spawnedFromClientId = null, int maxSpawnCount = 25) { //IL_014c: 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) if (spawnCount <= 0) { return; } string displayNameWithReadableColor = viewer.GetDisplayNameWithReadableColor(); PlayerControllerB playerScript; if (!string.IsNullOrWhiteSpace(targetPlayerUsername)) { if (!PlayerUtils.TryGetPlayerScriptByUsername(targetPlayerUsername, out playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " no player was found with the name \"" + targetPlayerUsername + "\""); return; } } else { playerScript = PlayerUtils.LocalPlayerScript; } if ((Object)(object)playerScript == (Object)null) { return; } if (!EnemyHelper.CanSpawnEnemiesOnPlayer(playerScript)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " enemies can not be spawned on " + playerScript.playerUsername + " right now"); return; } if (!string.IsNullOrWhiteSpace(targetEnemyName)) { if (!Assets.EnemyDatabase.TryGetDataByName(targetEnemyName, out var enemyData)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " no enemy was found with the name \"" + targetEnemyName + "\""); return; } if (!enemyData.CanSpawnOnPlayer(playerScript, SpawnSource.Twitch)) { MessageManger.Instance?.ShowMessage_LocalClient(displayNameWithReadableColor + " cannot spawn " + enemyData.DisplayName.RichColor("#FF0000") + " on " + playerScript.playerUsername + " right now"); return; } } spawnCount = Mathf.Min(spawnCount, maxSpawnCount); SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewer, SpawnSource.Twitch, spawnCount, spawnReason, targetEnemyName, spawnedFromClientId, playerScript.actualClientId); SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); } } internal class DevSubCommand : TwitchCommand { public override string Name => "devsub"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: 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_00a8: 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_00ca: 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_0123: 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_0131: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_0178: Expected O, but got Unknown //IL_00e6: 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_005f: 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_0119: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); int num = parsedArgs.GetPositionalInt(0, 1); SubTier tier = (SubTier)1; string text = parsedArgs.GetPositional(1, "1"); if (parsedArgs.TryGetInt("count", out var value)) { num = value; } if (parsedArgs.TryGetInt("amount", out value)) { num = value; } if (num <= 0) { return; } SubType type = (SubType)((num > 1) ? 3 : 0); if (parsedArgs.TryGet("tier", out var value2)) { text = value2; } int result2; if (Enum.TryParse(text, out SubTier result)) { tier = result; } else if (int.TryParse(text, out result2)) { try { tier = (SubTier)result2; } catch { } } int @int = parsedArgs.GetInt("months", 1); if (@int > 1) { type = (SubType)1; } string text2 = parsedArgs.Get("recipient"); if (num == 1 && !string.IsNullOrWhiteSpace(text2)) { type = (SubType)2; } if (parsedArgs.TryGet("type", out value2) && Enum.TryParse(value2, out SubType result3)) { type = result3; } TwitchUser user = ((TwitchMessage)(ref twitchMessage)).User; if (parsedArgs.TryGet("viewer", out var value3)) { value3 = ParseUsername(value3); TwitchUser val = default(TwitchUser); if (!API.TryGetUserByUsername(value3, ref val)) { return; } user = val; } TwitchSubEvent subEvent = new TwitchSubEvent { Channel = ((TwitchMessage)(ref twitchMessage)).Channel, User = user, Message = "", Tags = ((TwitchMessage)(ref twitchMessage)).Tags, Type = type, Tier = tier, CumulativeMonths = @int, RecipientUser = text2, GiftCount = num }; TwitchEventHandler.HandleSub(subEvent); } } internal class PlayQueueCommand : TwitchCommand { public override string Name => "playqueue"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { TwitchEventQueue.PlayQueuedEvents(); } } } internal class SetConfigCommand : TwitchCommand { public override string Name => "setconfig"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); if (parsedArgs.TryGetPositional(0, out var value) && parsedArgs.TryGetPositional(1, out var value2) && parsedArgs.TryGetPositional(2, out var value3)) { ConfigEntryBase configBySectionAndKey = ConfigHelper.GetConfigBySectionAndKey(value, value2); if (configBySectionAndKey != null) { string serializedValue = configBySectionAndKey.GetSerializedValue(); configBySectionAndKey.SetSerializedValue(value3); string serializedValue2 = configBySectionAndKey.GetSerializedValue(); string text = ((!(configBySectionAndKey.SettingType == typeof(string))) ? (serializedValue + " -> " + serializedValue2) : ("\"" + serializedValue + "\" -> \"" + serializedValue2 + "\"")); MessageManger.Instance?.ShowMessage_LocalClient("ConfigEntry<" + configBySectionAndKey.SettingType.Name + "> [" + configBySectionAndKey.Definition.Section + "] " + configBySectionAndKey.Definition.Key + " set " + text); } } } } internal class ViewConfigCommand : TwitchCommand { public override string Name => "viewconfig"; public override bool EnabledByDefault => true; public override bool EnableConfigs => false; public override void Execute(TwitchMessage twitchMessage, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchMessage)(ref twitchMessage)).User.IsDeveloper()) { return; } ParsedArgs parsedArgs = ParsedArgs.Parse(args); string positional = parsedArgs.GetPositional(0); string positional2 = parsedArgs.GetPositional(1); if (string.IsNullOrEmpty(positional)) { return; } if (!string.IsNullOrEmpty(positional2)) { ConfigEntryBase configBySectionAndKey = ConfigHelper.GetConfigBySectionAndKey(positional, positional2); if (configBySectionAndKey != null) { MessageManger.Instance?.ShowMessage_LocalClient(GetConfigHeader(configBySectionAndKey) + " " + GetConfigSection(configBySectionAndKey) + " " + GetConfigKey(configBySectionAndKey) + " = " + GetConfigValue(configBySectionAndKey)); } return; } ConfigEntryBase[] configsBySection = ConfigHelper.GetConfigsBySection(positional); if (configsBySection.Length == 0) { return; } List> list = new List>(); ConfigEntryBase[] array = configsBySection; foreach (ConfigEntryBase configEntry in array) { List list2 = new List(); list2.Add(GetConfigHeader(configEntry)); list2.Add(GetConfigSection(configEntry)); list2.Add(GetConfigKey(configEntry)); list2.Add("= " + GetConfigValue(configEntry)); list.Add(list2); } List list3 = Utils.FormatAsGrid(list); foreach (string item in list3) { MessageManger.Instance?.ShowMessage_LocalClient(item); } } public string GetConfigHeader(ConfigEntryBase configEntry) { return "ConfigEntry<" + configEntry.SettingType.Name + ">"; } public string GetConfigSection(ConfigEntryBase configEntry) { return "[" + configEntry.Definition.Section + "]"; } public string GetConfigKey(ConfigEntryBase configEntry) { return configEntry.Definition.Key; } private string GetConfigValue(ConfigEntryBase configEntry) { string serializedValue = configEntry.GetSerializedValue(); if (!(configEntry.SettingType == typeof(string))) { return serializedValue; } return "\"" + serializedValue + "\""; } } } namespace com.github.zehsteam.MonsterHotkeys.Patches { [HarmonyPatch(typeof(ButlerEnemyAI))] internal static class ButlerEnemyAI_Patches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable ButlerBlowUpAndPop_Transpiler(IEnumerable instructions) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown MethodInfo method = typeof(RoundManager).GetMethod("SpawnEnemyGameObject"); MethodInfo method2 = typeof(ButlerHelper).GetMethod("SpawnButlerBees"); if (method == null || method2 == null) { Logger.LogError("[ButlerEnemyAIPatch] Failed to find required methods for transpiler."); return instructions; } List list = new List(); foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && instruction.operand is MethodInfo methodInfo && methodInfo == method) { list.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Add(new CodeInstruction(OpCodes.Call, (object)method2)); Logger.LogInfo("[ButlerEnemyAIPatch] Replaced " + method.Name + " call with " + method2.Name + ".", extended: true); } else { list.Add(instruction); } } return list.AsEnumerable(); } } [HarmonyPatch(typeof(EnemyAI))] internal static class EnemyAI_Patches { private static bool _skipNextEnemyNestCheck; [HarmonyPatch("Start")] [HarmonyPrefix] private static void Start_Prefix_Patch(EnemyAI __instance) { if (_skipNextEnemyNestCheck) { if (!__instance.enemyType.requireNestObjectsToSpawn) { _skipNextEnemyNestCheck = false; } else { __instance.enemyType.requireNestObjectsToSpawn = false; } } } [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Postfix_Patch(EnemyAI __instance) { if (_skipNextEnemyNestCheck) { _skipNextEnemyNestCheck = false; __instance.enemyType.requireNestObjectsToSpawn = true; } } public static void SkipNextEnemyNestCheck() { _skipNextEnemyNestCheck = true; } [HarmonyPatch("KillEnemy")] [HarmonyPrefix] private static void KillEnemy_Prefix_Patch(EnemyAI __instance) { if (__instance.enemyType.canDie) { EnemyNametagManager.Instance?.DisableNametag_LocalClient(__instance); } } [HarmonyPatch("OnDestroy")] [HarmonyPostfix] private static void OnDestroy_Patch(EnemyAI __instance) { EnemyNametagManager.Instance?.DespawnNametag_LocalClient(__instance); } } [HarmonyPatch(typeof(GameNetworkManager))] internal static class GameNetworkManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch() { AddNetworkPrefabs(); } private static void AddNetworkPrefabs() { NetworkUtils.AddNetworkPrefab(Assets.PluginNetworkHandlerPrefab); } } [HarmonyPatch(typeof(HUDManager))] internal static class HUDManager_Patches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void Start_Patch() { PluginHUD.Spawn(); } } [HarmonyPatch(typeof(Landmine))] internal static class Landmine_Patches { [HarmonyPatch("SpawnExplosion")] [HarmonyTranspiler] private static IEnumerable SpawnExplosion_Transpiler(IEnumerable instructions) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(PlayerControllerB), "DamagePlayer", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(PlayerControllerB), "KillPlayer", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(PlayerHelper), "DamagePlayerWithCaller", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(PlayerHelper), "KillPlayerWithCaller", (Type[])null, (Type[])null); MethodInfo methodInfo5 = AccessTools.PropertyGetter(typeof(LandmineHelper), "SpawnExplosionCaller"); if (methodInfo == null || methodInfo2 == null || methodInfo3 == null || methodInfo4 == null || methodInfo5 == null) { Logger.LogError("[Landmine_Patches] Failed to find required methods for transpiler."); return instructions; } List list = new List(); foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && instruction.operand is MethodInfo methodInfo6) { if (methodInfo6 == methodInfo) { list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo5)); list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo3)); Logger.LogInfo("[Landmine_Patches] Replaced DamagePlayer call with " + methodInfo3.Name + ".", extended: true); continue; } if (methodInfo6 == methodInfo2) { list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo5)); list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo4)); Logger.LogInfo("[Landmine_Patches] Replaced KillPlayer call with " + methodInfo4.Name + ".", extended: true); continue; } } list.Add(instruction); } return list.AsEnumerable(); } } internal static class PlayerDamagePatcher { private static readonly MethodInfo _originalDamagePlayer = typeof(PlayerControllerB).GetMethod("DamagePlayer"); private static readonly MethodInfo _originalKillPlayer = typeof(PlayerControllerB).GetMethod("KillPlayer"); private static readonly MethodInfo _replacementDamagePlayer = typeof(PlayerHelper).GetMethod("DamagePlayerWithCaller"); private static readonly MethodInfo _replacementKillPlayer = typeof(PlayerHelper).GetMethod("KillPlayerWithCaller"); private static int _transpilersCreated; private static bool _patched; public static int TranspilersCreated => _transpilersCreated; public static void PatchAll(Harmony harmony) { if (_patched) { return; } _patched = true; LogInfo("Running patcher..."); if (_originalDamagePlayer == null || _originalKillPlayer == null || _replacementDamagePlayer == null || _replacementKillPlayer == null) { LogError("Required methods not found for patcher."); return; } IEnumerable validAssemblies = GetValidAssemblies(); LogInfo($"Found {validAssemblies.Count()} valid assemblies."); foreach (Assembly item in validAssemblies) { LogInfoExtended("Found assembly: " + item.FullName); } _transpilersCreated = 0; Parallel.ForEach(validAssemblies, delegate(Assembly assembly) { PatchAssembly(assembly, harmony); }); LogInfo($"Created {_transpilersCreated} transpilers."); LogInfo("Patcher finished."); } private static void PatchAssembly(Assembly assembly, Harmony harmony) { LogInfoExtended("Patching assembly: " + assembly.FullName); IEnumerable validClasses = GetValidClasses(assembly); Parallel.ForEach(validClasses, delegate(Type type) { PatchClass(type, harmony); }); } private static void PatchClass(Type type, Harmony harmony) { LogInfoExtended("Patching class: " + type.FullName); IEnumerable validMethods = GetValidMethods(type); Parallel.ForEach(validMethods, delegate(MethodInfo method) { PatchMethod(method, harmony); }); } private static void PatchMethod(MethodInfo method, Harmony harmony) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown try { if (ReflectionHelper.IsCoroutineMethod(method)) { MethodInfo coroutineMoveNextMethod = ReflectionHelper.GetCoroutineMoveNextMethod(method); if (coroutineMoveNextMethod == null) { return; } harmony.Patch((MethodBase)coroutineMoveNextMethod, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PlayerDamagePatcher), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); LogInfoExtended($"Patched coroutine: {coroutineMoveNextMethod}"); } else { harmony.Patch((MethodBase)method, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(PlayerDamagePatcher), "Transpiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); LogInfoExtended("Patched method: " + method.Name); } Interlocked.Increment(ref _transpilersCreated); } catch (Exception arg) { LogError($"Failed to patch method: {method}\n\n{arg}"); } } private static IEnumerable Transpiler(IEnumerable instructions) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown if (_originalDamagePlayer == null || _originalKillPlayer == null || _replacementDamagePlayer == null || _replacementKillPlayer == null) { LogError("Required methods not found for transpiler."); return instructions; } List list = new List(); foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && instruction.operand is MethodInfo methodInfo) { if (methodInfo == _originalDamagePlayer) { list.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Add(new CodeInstruction(OpCodes.Call, (object)_replacementDamagePlayer)); LogInfoExtended("Replaced " + _originalDamagePlayer.Name + " call with " + _replacementDamagePlayer.Name + "."); continue; } if (methodInfo == _originalKillPlayer) { list.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Add(new CodeInstruction(OpCodes.Call, (object)_replacementKillPlayer)); LogInfoExtended("Replaced " + _originalKillPlayer.Name + " call with " + _replacementKillPlayer.Name + "."); continue; } } list.Add(instruction); } return list.AsEnumerable(); } private static IEnumerable GetValidAssemblies() { List list = new List(); list.Add(typeof(StartOfRound).Assembly); list.AddRange(DependencyHelper.GetModAssemblies()); return new <>z__ReadOnlyList(list); } private static IEnumerable GetValidClasses(Assembly assembly) { if (assembly == null) { return Array.Empty(); } try { return assembly.GetLoadableTypes().Where(IsValidClass); } catch (ReflectionTypeLoadException ex) { LogWarningExtended("Error loading types from assembly " + assembly.FullName + ": " + ex.Message); return Array.Empty(); } } private static bool IsValidClass(Type type) { try { if (type == null) { return false; } if (!type.IsClass || type.IsAbstract) { return false; } if (type == typeof(PlayerControllerB)) { return false; } if (type.FullName.StartsWithAny(new string[2] { "DunGen.", "DigitalRuby.ThunderAndLightning." }, StringComparison.OrdinalIgnoreCase)) { return false; } if (type.Name.Contains("TurretBehaviour")) { return true; } if (typeof(EnemyAI).IsAssignableFrom(type) || typeof(ShotgunItem).IsAssignableFrom(type)) { return true; } return false; } catch (Exception ex) { LogWarningExtended("Error loading type " + type.FullName + " from assembly " + type.Assembly.FullName + ": " + ex.Message); return false; } } private static IEnumerable GetValidMethods(Type type) { return type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(IsValidMethod); } private static bool IsValidMethod(MethodInfo method) { if (method == null) { return false; } if (method.IsGenericMethod || method.DeclaringType.IsGenericType) { return false; } return ILHelper.MethodCallsEitherMethods(method, new MethodInfo[2] { _originalDamagePlayer, _originalKillPlayer }); } private static void LogInfo(object data) { Log((LogLevel)16, data); } private static void LogError(object data) { Log((LogLevel)2, data); } private static void Log(LogLevel logLevel, object data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Logger.Log(logLevel, string.Format("[{0}] {1}", "PlayerDamagePatcher", data)); } private static void LogInfoExtended(object data) { LogExtended((LogLevel)16, data); } private static void LogWarningExtended(object data) { LogExtended((LogLevel)4, data); } private static void LogExtended(LogLevel logLevel, object data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Logger.Log(logLevel, string.Format("[{0}] {1}", "PlayerDamagePatcher", data), extended: true); } } [HarmonyPatch(typeof(RadMechAI))] internal static class RadMechAI_Patches { [HarmonyPatch("SetExplosion")] [HarmonyTranspiler] private static IEnumerable SetExplosion_Transpiler(IEnumerable instructions) { return ReplaceLandmineSpawnExplosionTranspiler(instructions); } [HarmonyPatch("DoFootstepCycle")] [HarmonyTranspiler] private static IEnumerable DoFootstepCycle_Transpiler(IEnumerable instructions) { return ReplaceLandmineSpawnExplosionTranspiler(instructions); } private static IEnumerable ReplaceLandmineSpawnExplosionTranspiler(IEnumerable instructions) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown MethodInfo method = typeof(Landmine).GetMethod("SpawnExplosion"); MethodInfo method2 = typeof(LandmineHelper).GetMethod("SpawnExplosionWithCaller"); if (method == null || method2 == null) { Logger.LogError("[RadMechAIPatch] Failed to find required methods for transpiler."); return instructions; } List list = new List(); foreach (CodeInstruction instruction in instructions) { if ((instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt) && instruction.operand is MethodInfo methodInfo && methodInfo == method) { list.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list.Add(new CodeInstruction(OpCodes.Call, (object)method2)); Logger.LogInfo("[RadMechAIPatch] Replaced " + method.Name + " call with " + method2.Name + ".", extended: true); } else { list.Add(instruction); } } return list.AsEnumerable(); } } [HarmonyPatch(typeof(RoundManager))] internal static class RoundManager_Patches { private static bool _shipArrived; private static float _timeSinceShipArrived; [HarmonyPatch("LoadNewLevel")] [HarmonyPostfix] private static void LoadNewLevel_Patch() { EnemyNametagManager.Instance?.Reset(); MoldHelper.Reset(); } [HarmonyPatch("GenerateNewLevelClientRpc")] [HarmonyPrefix] private static void GenerateNewLevelClientRpc_Patch() { if (!NetworkUtils.IsServer) { EnemyNametagManager.Instance?.Reset(); MoldHelper.Reset(); } } [HarmonyPatch("FinishGeneratingNewLevelClientRpc")] [HarmonyPostfix] private static void FinishGeneratingNewLevelClientRpc_Patch() { if (Time.realtimeSinceStartup - _timeSinceShipArrived > 5f) { _shipArrived = false; } if (!_shipArrived) { _shipArrived = true; _timeSinceShipArrived = Time.realtimeSinceStartup; TwitchEventQueue.PlayQueuedEvents(TimeSpan.FromSeconds(15.0)); } } [HarmonyPatch("SpawnRandomWeedEnemy")] [HarmonyPrefix] private static bool SpawnRandomWeedEnemy_Patch() { return !MoldHelper.BlockNaturalWeedEnemySpawns; } } [HarmonyPatch(typeof(StartOfRound))] internal static class StartOfRound_Patches { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake_Patch() { SpawnNetworkHandler(); } private static void SpawnNetworkHandler() { //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 (NetworkUtils.IsServer) { GameObject val = Object.Instantiate(Assets.PluginNetworkHandlerPrefab, Vector3.zero, Quaternion.identity); val.GetComponent().Spawn(false); } } [HarmonyPatch("Start")] [HarmonyPostfix] [HarmonyPriority(0)] private static void Start_Patch() { Assets.EnemyDatabase?.Initialize(); ConfigManager.SetConfigSettingsForSpecificPlayers(); } [HarmonyPatch("OnClientConnect")] [HarmonyPrefix] private static void OnClientConnect_Patch(ref ulong clientId) { if (NetworkUtils.IsServer) { SyncedConfigEntryBase.SendConfigsToClient(clientId); } } [HarmonyPatch("EndOfGame")] [HarmonyPostfix] private static void EndOfGame_Patch() { TwitchIntegrationManager.OnDayEnded(); } [HarmonyPatch("OnLocalDisconnect")] [HarmonyPostfix] private static void OnLocalDisconnect_Patch() { TwitchIntegrationManager.OnLocalDisconnect(); } } } namespace com.github.zehsteam.MonsterHotkeys.Objects { internal class JsonSave { private JObject _data; public string DirectoryPath { get; private set; } public string FileName { get; private set; } public string FilePath => Path.Combine(DirectoryPath, FileName); public JsonSave(string directoryPath, string fileName) { DirectoryPath = directoryPath; FileName = fileName; _data = ReadFile(); } public bool KeyExists(string key) { if (_data == null) { Logger.LogError("KeyExists: Data is null. Ensure the save file is properly loaded."); return false; } return _data.ContainsKey(key); } public T Load(string key, T defaultValue = default(T), bool readFile = false) { if (TryLoad(key, out var value, readFile)) { return value; } return defaultValue; } public bool TryLoad(string key, out T value, bool readFile = false) { //IL_0057: Expected O, but got Unknown value = default(T); if (readFile) { _data = ReadFile(); } if (_data == null) { Logger.LogError("Load: Data is null. Returning default value for key: " + key + "."); return false; } JToken val = default(JToken); if (_data.TryGetValue(key, ref val)) { try { value = val.ToObject(); return true; } catch (JsonException val2) { JsonException val3 = val2; Logger.LogError("Load: JSON Conversion Error for key: " + key + ". " + ((Exception)(object)val3).Message); } catch (ArgumentNullException ex) { Logger.LogError("Load: Argument Null Error for key: " + key + ". " + ex.Message); } catch (Exception ex2) { Logger.LogError("Load: Unexpected Error for key: " + key + ". " + ex2.Message); } return false; } Logger.LogWarning("Load: Key '" + key + "' does not exist. Returning default value.", extended: true); return false; } public bool Save(string key, T value) { if (_data == null) { Logger.LogError("Save: Data is null. Cannot save key: " + key + "."); return false; } try { JToken val = JToken.FromObject((object)value); if (_data.ContainsKey(key)) { _data[key] = val; } else { _data.Add(key, val); } return WriteFile(_data); } catch (Exception ex) { Logger.LogError("Save: Error saving key: " + key + ". " + ex.Message); return false; } } private JObject ReadFile() { //IL_0070: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown try { if (!File.Exists(FilePath)) { Logger.LogWarning("ReadFile: Save file does not exist at \"" + FilePath + "\". Initializing with an empty file."); return new JObject(); } using FileStream stream = new FileStream(FilePath, FileMode.Open, FileAccess.Read); using StreamReader streamReader = new StreamReader(stream, Encoding.UTF8); return JObject.Parse(streamReader.ReadToEnd()); } catch (JsonException val) { JsonException val2 = val; Logger.LogError("ReadFile: JSON Parsing Error for file: \"" + FilePath + "\". " + ((Exception)(object)val2).Message); } catch (Exception ex) { Logger.LogError("ReadFile: Unexpected Error for file: \"" + FilePath + "\". " + ex.Message); } return new JObject(); } private bool WriteFile(JObject data) { try { if (!Directory.Exists(DirectoryPath)) { Directory.CreateDirectory(DirectoryPath); } File.WriteAllText(FilePath, ((object)data).ToString(), Encoding.UTF8); return true; } catch (Exception ex) { Logger.LogError("WriteFile: Unexpected Error for file: \"" + FilePath + "\". " + ex.Message); } return false; } } public class QueueJsonConverter : JsonConverter { public override bool CanConvert(Type objectType) { return objectType == typeof(Queue); } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { Queue source = (Queue)value; serializer.Serialize(writer, (object)source.ToList()); } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { List collection = serializer.Deserialize>(reader); return new Queue(collection); } } public static class QueueJsonConverterHelper { public static string SerializeQueue(Queue queue) { if (queue == null) { queue = new Queue(); } return JsonConvert.SerializeObject((object)queue, (JsonConverter[])(object)new JsonConverter[1] { new QueueJsonConverter() }); } public static Queue DeserializeQueue(string value) { if (string.IsNullOrEmpty(value)) { return new Queue(); } return JsonConvert.DeserializeObject>(value, (JsonConverter[])(object)new JsonConverter[1] { new QueueJsonConverter() }); } } public class SyncedConfigEntry : SyncedConfigEntryBase { private ConfigEntry _configEntry; private T _serverValue; public T Value { get { return GetValue(); } set { SetValue(value); } } public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue; public override ConfigDefinition Definition => ((ConfigEntryBase)_configEntry).Definition; public event Action SettingChanged; public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null) { SyncedConfigEntryBase.AddInstance(this); base.SettingType = typeof(T); _configEntry = ConfigHelper.Bind(section, key, defaultValue, description, requiresRestart: false, acceptableValues, null, configFile); _configEntry.SettingChanged += SettingChangedInternal; Application.quitting += delegate { _configEntry.SettingChanged -= SettingChangedInternal; }; } public T GetValue() { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { return _serverValue; } return _configEntry.Value; } public void SetValue(T value) { if (!NetworkUtils.IsConnected || NetworkUtils.IsServer) { _configEntry.Value = value; } } public void ResetToDefault() { if (!NetworkUtils.IsConnected || NetworkUtils.IsServer) { _configEntry.Value = DefaultValue; } } private void SettingChangedInternal(object sender, EventArgs e) { if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { this.SettingChanged?.Invoke(Value); SendConfigToClients(); } } private void SendConfigToClients() { //IL_003b: 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) if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { PluginNetworkHandler.Instance?.SetSyncedConfigValue_ClientRpc(base.Section, base.Key, Value.ToString()); } } public override void SendConfigToClient(ulong clientId) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (NetworkUtils.IsConnected && NetworkUtils.IsServer) { ClientRpcParams val = default(ClientRpcParams); val.Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList(clientId) }; ClientRpcParams clientRpcParams = val; PluginNetworkHandler.Instance?.SetSyncedConfigValue_ClientRpc(base.Section, base.Key, Value.ToString(), clientRpcParams); } } public override void SetValueFromServer(string value) { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { if (!value.TryConvertTo(out var result)) { throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}"); } _serverValue = result; Logger.LogInfo("Set synced config entry value from server. (Section: \"" + base.Section + "\", Key: \"" + base.Key + "\", Value: \"" + value + "\")", extended: true); this.SettingChanged?.Invoke(result); } } } public abstract class SyncedConfigEntryBase { private static readonly object _instancesLock = new object(); public static List Instances { get; private set; } = new List(); public abstract ConfigDefinition Definition { get; } public string Section => Definition.Section; public string Key => Definition.Key; public Type SettingType { get; protected set; } public static void AddInstance(SyncedConfigEntryBase instance) { lock (_instancesLock) { Instances.Add(instance); } } public static void RemoveInstance(SyncedConfigEntryBase instance) { lock (_instancesLock) { Instances.Remove(instance); } } public abstract void SendConfigToClient(ulong clientId); public abstract void SetValueFromServer(string value); public static void SendConfigsToClient(ulong clientId) { if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId)) { return; } foreach (SyncedConfigEntryBase instance in Instances) { instance.SendConfigToClient(clientId); } } public static void SetValueFromServer(string section, string key, string value) { if (NetworkUtils.IsConnected && !NetworkUtils.IsServer) { SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key); if (syncedConfigEntryBase == null) { Logger.LogWarning("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\""); } else { syncedConfigEntryBase.SetValueFromServer(value); } } } } } namespace com.github.zehsteam.MonsterHotkeys.Objects.Network { public struct MessageSettings : INetworkSerializable { public float Duration; public Color Color; public static float DefaultDuration => ConfigManager.Message_Duration.Value; public static Color DefaultColor => Color.white; public MessageSettings() { //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) Duration = DefaultDuration; Color = DefaultColor; } public MessageSettings(float? duration = null, Color? color = null) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_004f: Unknown result type (might be due to invalid IL or missing references) Duration = DefaultDuration; Color = DefaultColor; Duration = duration ?? DefaultDuration; Color = (Color)(((??)color) ?? DefaultColor); } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: 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) ((BufferSerializer*)(&serializer))->SerializeValue(ref Duration, default(ForPrimitives)); serializer.SerializeValue(ref Color); } } public class NametagData : INetworkSerializable { public SpawnEnemyData SpawnEnemyData; public string EnemyDisplayName; public NametagData() { } public NametagData(SpawnEnemyData spawnEnemyData, string enemyDisplayName) { SpawnEnemyData = spawnEnemyData; EnemyDisplayName = enemyDisplayName; } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(ref SpawnEnemyData); serializer.SerializeValue(ref EnemyDisplayName, false); } public string GetDisplayName() { if (SpawnEnemyData.IsFromViewer) { return SpawnEnemyData.Viewer.DisplayName; } return SpawnEnemyData.NonViewer.DisplayName; } public string GetDisplayNameWithReadableColor() { if (SpawnEnemyData.IsFromViewer) { return SpawnEnemyData.Viewer.GetDisplayNameWithReadableColor(); } return SpawnEnemyData.NonViewer.DisplayName; } } [Serializable] public class NonViewerData : INetworkSerializable { public string DisplayName; public string Phrase; public NonViewerData() { } public NonViewerData(string displayName, string phrase = "") { DisplayName = displayName; Phrase = phrase; } public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { serializer.SerializeValue(ref DisplayName, false); serializer.SerializeValue(ref Phrase, false); } } [Serializable] public class SpawnEnemyData : INetworkSerializable { public bool IsFromViewer; public ViewerData Viewer; public NonViewerData NonViewer; public SpawnSource SpawnSource; public int SpawnCount; public int SpawnedCount; public string SpawnReason; public string TargetEnemyName; public ulong SpawnedFromClientId; public ulong SpawnedOnClientId; public SpawnEnemyData() { } public SpawnEnemyData(ViewerData viewer, SpawnSource spawnSource, int spawnCount, string spawnReason, string targetEnemyName = "", ulong? spawnedFromClientId = null, ulong? spawnedOnClientId = null) { IsFromViewer = true; Viewer = viewer; SpawnSource = spawnSource; SpawnCount = spawnCount; SpawnedCount = spawnCount; SpawnReason = spawnReason; TargetEnemyName = targetEnemyName; SpawnedFromClientId = spawnedFromClientId ?? NetworkUtils.LocalClientId; SpawnedOnClientId = spawnedOnClientId ?? NetworkUtils.LocalClientId; } public SpawnEnemyData(NonViewerData nonViewer, SpawnSource spawnSource, int spawnCount, string spawnReason, string targetEnemyName = "", ulong? spawnedFromClientId = null, ulong? spawnedOnClientId = null) { IsFromViewer = false; NonViewer = nonViewer; SpawnSource = spawnSource; SpawnCount = spawnCount; SpawnedCount = spawnCount; SpawnReason = spawnReason; TargetEnemyName = targetEnemyName; SpawnedFromClientId = spawnedFromClientId ?? NetworkUtils.LocalClientId; SpawnedOnClientId = spawnedOnClientId ?? NetworkUtils.LocalClientId; } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: 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_0044: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00b8: 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) ((BufferSerializer*)(&serializer))->SerializeValue(ref IsFromViewer, default(ForPrimitives)); if (IsFromViewer) { ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(ref Viewer); } else { ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(ref NonViewer); } ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnSource, default(ForEnums)); ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnCount, default(ForPrimitives)); ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnedCount, default(ForPrimitives)); serializer.SerializeValue(ref SpawnReason, false); serializer.SerializeValue(ref TargetEnemyName, false); ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnedFromClientId, default(ForPrimitives)); ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnedOnClientId, default(ForPrimitives)); } public string GetDisplayName() { if (IsFromViewer) { return Viewer.DisplayName; } return NonViewer.DisplayName; } public string GetDisplayNameWithReadableColor() { if (IsFromViewer) { return Viewer.GetDisplayNameWithReadableColor(); } return NonViewer.DisplayName; } } [Serializable] public class SpawnPlushiesData : INetworkSerializable { public bool IsFromViewer; public ViewerData Viewer; public NonViewerData NonViewer; public SpawnSource SpawnSource; public string SpawnReason; public string TargetPoolId; public ulong SpawnedFromClientId; public ulong SpawnedOnClientId; public SpawnPlushiesData() { } public SpawnPlushiesData(ViewerData viewer, SpawnSource spawnSource, string spawnReason, string targetPoolId = "", ulong? spawnedFromClientId = null, ulong? spawnedOnClientId = null) { IsFromViewer = true; Viewer = viewer; SpawnSource = spawnSource; SpawnReason = spawnReason; TargetPoolId = targetPoolId; SpawnedFromClientId = spawnedFromClientId ?? NetworkUtils.LocalClientId; SpawnedOnClientId = spawnedOnClientId ?? NetworkUtils.LocalClientId; } public SpawnPlushiesData(NonViewerData nonViewer, SpawnSource spawnSource, string spawnReason, string targetPoolId = "", ulong? spawnedFromClientId = null, ulong? spawnedOnClientId = null) { IsFromViewer = false; NonViewer = nonViewer; SpawnSource = spawnSource; SpawnReason = spawnReason; TargetPoolId = targetPoolId; SpawnedFromClientId = spawnedFromClientId ?? NetworkUtils.LocalClientId; SpawnedOnClientId = spawnedOnClientId ?? NetworkUtils.LocalClientId; } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: 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_0044: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) ((BufferSerializer*)(&serializer))->SerializeValue(ref IsFromViewer, default(ForPrimitives)); if (IsFromViewer) { ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(ref Viewer); } else { ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(ref NonViewer); } ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnSource, default(ForEnums)); serializer.SerializeValue(ref TargetPoolId, false); serializer.SerializeValue(ref SpawnReason, false); ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnedFromClientId, default(ForPrimitives)); ((BufferSerializer*)(&serializer))->SerializeValue(ref SpawnedOnClientId, default(ForPrimitives)); } public string GetDisplayName() { if (IsFromViewer) { return Viewer.DisplayName; } return NonViewer.DisplayName; } public string GetDisplayNameWithReadableColor() { if (IsFromViewer) { return Viewer.GetDisplayNameWithReadableColor(); } return NonViewer.DisplayName; } } [Serializable] public class ViewerData : INetworkSerializable { public string UserId; public string Username; public string DisplayName; public string Color; public ViewerData() { } public ViewerData(string userId, string username, string displayName, string color) { UserId = userId; Username = username; DisplayName = displayName; Color = color; } public ViewerData(TwitchUser user) { UserId = ((TwitchUser)(ref user)).UserId; Username = ((TwitchUser)(ref user)).Username; DisplayName = ((TwitchUser)(ref user)).DisplayName; Color = ((TwitchUser)(ref user)).Color; } public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { serializer.SerializeValue(ref UserId, false); serializer.SerializeValue(ref Username, false); serializer.SerializeValue(ref DisplayName, false); serializer.SerializeValue(ref Color, false); } public string GetDisplayNameWithReadableColor(string backgroundColorHex = "#000000") { return DisplayName.RichReadableColor(Color, backgroundColorHex); } } } namespace com.github.zehsteam.MonsterHotkeys.Objects.Enemies { [Serializable] public class EnemyData { public string DisplayName; public string Name; public AudioClip SpawnSFX; public GameObject PlushiePrefab; public NametagSettings NametagSettings; public EnemyDataConfig Config; [HideInInspector] public EnemyType EnemyType; public EnemyData(EnemyType enemyType, string displayName, AudioClip spawnSFX = null, GameObject plushiePrefab = null, NametagSettings nametagSettings = null, EnemyDataConfigDefault defaultConfigValues = null) { if (!((Object)(object)enemyType == (Object)null)) { EnemyType = enemyType; Name = enemyType.enemyName; DisplayName = displayName; SpawnSFX = spawnSFX; PlushiePrefab = plushiePrefab; NametagSettings = nametagSettings ?? new NametagSettings(); Config = new EnemyDataConfig(defaultConfigValues); } } public void BindConfigs() { if (Config == null) { Config = new EnemyDataConfig(); } Config.BindConfigs(this); } public bool CanSpawnOnPlayer(PlayerControllerB playerScript, SpawnSource spawnSource) { if (Config == null) { return false; } return Config.CanSpawnOnPlayer(playerScript, spawnSource); } } [CreateAssetMenu(fileName = "EnemyDatabase", menuName = "MonsterHotkeys/EnemyDatabase")] public class EnemyDatabase : ScriptableObject { private readonly Dictionary _entries = new Dictionary(); [SerializeField] private List _predefinedEntries = new List(); public List BlockedEnemyNames = new List(5) { "Butler Bees", "Docile Locust Bees", "Lasso", "Red Locust Bees", "Red pill" }; public IReadOnlyDictionary Entries => _entries; internal void Initialize() { foreach (EnemyType enemyType in EnemyHelper.GetEnemyTypes(EnemySpawnType.Inside)) { AddEntry(enemyType, EnemySpawnType.Inside); } foreach (EnemyType enemyType2 in EnemyHelper.GetEnemyTypes(EnemySpawnType.Outside)) { AddEntry(enemyType2, EnemySpawnType.Outside); } foreach (EnemyType enemyType3 in EnemyHelper.GetEnemyTypes(EnemySpawnType.Daytime)) { AddEntry(enemyType3, EnemySpawnType.Daytime); } IOrderedEnumerable orderedEnumerable = _entries.Values.OrderBy((EnemyData x) => x.DisplayName); foreach (EnemyData item in orderedEnumerable) { item.BindConfigs(); } } public bool AddEntry(EnemyType enemyType, EnemySpawnType spawnType, AudioClip spawnSFX = null, GameObject plushiePrefab = null, NametagSettings nametagSettings = null, EnemyDataConfigDefault defaultConfigValues = null) { if ((Object)(object)enemyType == (Object)null) { Logger.LogError("[EnemyDatabase] Failed to add entry. EnemyType is null."); return false; } if (HasData(enemyType)) { return false; } if (!enemyType.IsValid()) { Logger.LogError("[EnemyDatabase] Failed to add entry. EnemyType is not valid."); return false; } if (!NetworkUtils.IsNetworkPrefab(enemyType.enemyPrefab)) { Logger.LogError("[EnemyDatabase] Failed to add entry. Enemy prefab is not a network prefab."); return false; } if (BlockedEnemyNames.Contains(enemyType.enemyName, StringComparer.OrdinalIgnoreCase)) { return false; } EnemyData enemyData = _predefinedEntries.FirstOrDefault((EnemyData x) => x.Name.Equals_OrdinalIgnoreCase(enemyType.enemyName)); if (enemyData != null) { enemyData.EnemyType = enemyType; _entries.Add(enemyType, enemyData); Logger.LogInfo("[EnemyDatabase] Added \"" + enemyData.DisplayName + "\""); return true; } if (defaultConfigValues == null) { defaultConfigValues = new EnemyDataConfigDefault(); if (spawnType == EnemySpawnType.Inside) { defaultConfigValues.AllowSpawnInside = true; defaultConfigValues.AllowSpawnOutside = enemyType.isOutsideEnemy || enemyType.isDaytimeEnemy; } if (spawnType == EnemySpawnType.Outside || spawnType == EnemySpawnType.Daytime) { defaultConfigValues.AllowSpawnInside = false; defaultConfigValues.AllowSpawnOutside = true; } } string text = enemyType.enemyName.FormatCapitalization(); EnemyData value = new EnemyData(enemyType, text, spawnSFX, plushiePrefab, nametagSettings, defaultConfigValues); _entries.Add(enemyType, value); Logger.LogInfo("[EnemyDatabase] Added \"" + text + "\""); return true; } public EnemyData GetData(EnemyType enemyType) { return _entries.GetValueOrDefault(enemyType); } public bool TryGetData(EnemyType enemyType, out EnemyData enemyData) { return _entries.TryGetValue(enemyType, out enemyData); } public bool HasData(EnemyType enemyType) { return _entries.ContainsKey(enemyType); } public IEnumerable GetSpawnableEnemiesForPlayer(PlayerControllerB playerScript, SpawnSource spawnSource) { if ((Object)(object)playerScript == (Object)null || playerScript.isPlayerDead) { return Array.Empty(); } return _entries.Values.Where((EnemyData x) => x.CanSpawnOnPlayer(playerScript, spawnSource)); } public EnemyData GetRandomSpawnableEnemyForPlayer(PlayerControllerB playerScript, SpawnSource spawnSource) { EnemyData[] array = GetSpawnableEnemiesForPlayer(playerScript, spawnSource).ToArray(); if (array == null || array.Length == 0) { return null; } return array[Random.Range(0, array.Length)]; } public bool TryGetRandomSpawnableEnemyForPlayer(PlayerControllerB playerScript, SpawnSource spawnSource, out EnemyData enemyData) { enemyData = GetRandomSpawnableEnemyForPlayer(playerScript, spawnSource); return enemyData != null; } public EnemyData GetDataByName(string name, bool includeDisplayName = true, bool ignoreSpaces = true) { return _entries.Values.FirstOrDefault(delegate(EnemyData enemyData) { if (enemyData.Name.Equals_OrdinalIgnoreCase(name)) { return true; } if (includeDisplayName && enemyData.DisplayName.Equals_OrdinalIgnoreCase(name)) { return true; } if (ignoreSpaces && enemyData.Name.RemoveSpaces().Equals_OrdinalIgnoreCase(name.RemoveSpaces())) { return true; } return (ignoreSpaces && includeDisplayName && enemyData.DisplayName.RemoveSpaces().Equals_OrdinalIgnoreCase(name.RemoveSpaces())) ? true : false; }); } public bool TryGetDataByName(string name, out EnemyData enemyData) { enemyData = GetDataByName(name); return enemyData != null; } } [Serializable] public class EnemyDataConfig { public static List EnemiesToDisable = new List(10) { "Maggie", "Crystal Ray", "Boomba", "WaxSoldier", "Ogopogo", "BellCrab", "BigMouth", "Scary", "Horse", "LeafBoy" }; public EnemyDataConfigDefault DefaultValues; private bool _boundConfigs; public EnemyData EnemyData { get; private set; } public ConfigEntry Enabled { get; private set; } public ConfigEntry SpawnCount { get; private set; } public ConfigEntry AllowSpawnInside { get; private set; } public ConfigEntry AllowSpawnOutside { get; private set; } public ConfigEntry SpawnPosition { get; private set; } public ConfigEntry MinDistance { get; private set; } public ConfigEntry MaxDistance { get; private set; } public ConfigEntry SpawnSFXVolume { get; private set; } public EnemyDataConfig() { DefaultValues = new EnemyDataConfigDefault(); } public EnemyDataConfig(EnemyDataConfigDefault defaultValues) { DefaultValues = defaultValues ?? new EnemyDataConfigDefault(); } public void BindConfigs(EnemyData enemyData) { if (enemyData != null && !_boundConfigs) { _boundConfigs = true; EnemyData = enemyData; if (DefaultValues == null) { DefaultValues = new EnemyDataConfigDefault(); } if (EnemiesToDisable.Contains(EnemyData.Name)) { DefaultValues.Enabled = false; } string section = "Enemy: " + EnemyData.DisplayName; Enabled = ConfigHelper.Bind(section, "Enabled", DefaultValues.Enabled, "Enable " + EnemyData.DisplayName + " to be able to spawn."); SpawnCount = ConfigHelper.Bind(section, "SpawnCount", DefaultValues.SpawnCount, "The amount of " + EnemyData.DisplayName + " to spawn.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(1, 50)); AllowSpawnInside = ConfigHelper.Bind(section, "AllowSpawnInside", DefaultValues.AllowSpawnInside, "If enabled, " + EnemyData.DisplayName + " can spawn in the interior."); AllowSpawnOutside = ConfigHelper.Bind(section, "AllowSpawnOutside", DefaultValues.AllowSpawnOutside, "If enabled, " + EnemyData.DisplayName + " can spawn outside."); SpawnPosition = ConfigHelper.Bind(section, "SpawnPosition", DefaultValues.SpawnPosition, "The type of position " + EnemyData.DisplayName + " will spawn in."); MinDistance = ConfigHelper.Bind(section, "MinDistance", DefaultValues.MinDistance, "The minimum distance to spawn " + EnemyData.DisplayName + " from the player.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0f, 150f)); MaxDistance = ConfigHelper.Bind(section, "MaxDistance", DefaultValues.MaxDistance, "The maximum distance to spawn " + EnemyData.DisplayName + " from the player.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0f, 150f)); SpawnSFXVolume = ConfigHelper.Bind(section, "SpawnSFXVolume", DefaultValues.SpawnSFXVolume, "The volume of the " + EnemyData.DisplayName + " spawn sfx.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0, 100)); } } public bool CanSpawnOnPlayer(PlayerControllerB playerScript, SpawnSource spawnSource) { if ((Object)(object)playerScript == (Object)null) { return false; } if (playerScript.isPlayerDead) { return false; } if (spawnSource != SpawnSource.CrowdControl && !Enabled.Value) { return false; } if (SpawnCount.Value <= 0) { return false; } if (!AllowSpawnInside.Value && !AllowSpawnOutside.Value) { return false; } if (playerScript.isInsideFactory && !AllowSpawnInside.Value) { return false; } if (!playerScript.isInsideFactory && !AllowSpawnOutside.Value) { return false; } return true; } } [Serializable] public class EnemyDataConfigDefault { public bool Enabled = true; [Range(1f, 50f)] public int SpawnCount = 1; public bool AllowSpawnInside = true; public bool AllowSpawnOutside = true; public EnemySpawnPositionType SpawnPosition; [Range(0f, 150f)] public float MinDistance = 10f; [Range(0f, 150f)] public float MaxDistance = 30f; [Range(0f, 100f)] public int SpawnSFXVolume = 80; public EnemyDataConfigDefault() { } public EnemyDataConfigDefault(bool enabled, int spawnCount, bool allowSpawnInside, bool allowSpawnOutside, EnemySpawnPositionType spawnPosition = EnemySpawnPositionType.Random) { Enabled = enabled; SpawnCount = spawnCount; AllowSpawnInside = allowSpawnInside; AllowSpawnOutside = allowSpawnOutside; SpawnPosition = spawnPosition; } } [Serializable] public class NametagSettings { public bool UseSettings; public float YOffset; [Range(1f, 10f)] public float ScaleMultiplier = 1f; public NametagSettings() { } public NametagSettings(float yOffset, float scaleMultiplier) { UseSettings = true; YOffset = yOffset; ScaleMultiplier = scaleMultiplier; } } } namespace com.github.zehsteam.MonsterHotkeys.MonoBehaviours { public class PluginNetworkHandler : NetworkBehaviour { public static PluginNetworkHandler Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { if (((NetworkBehaviour)this).IsServer) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } else { Instance = this; } } [ClientRpc] public void SetSyncedConfigValue_ClientRpc(string section, string key, string value, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1218369902u, clientRpcParams, (RpcDelivery)0); bool flag = section != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(section, false); } bool flag2 = key != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val)).WriteValueSafe(key, false); } bool flag3 = value != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag3, default(ForPrimitives)); if (flag3) { ((FastBufferWriter)(ref val)).WriteValueSafe(value, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1218369902u, clientRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { SyncedConfigEntryBase.SetValueFromServer(section, key, value); } } } [ClientRpc] public void SetMaskedEnemyProperties_ClientRpc(NetworkObjectReference networkObjectReference, ulong targetClientId, int maskTypeId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Invalid comparison between Unknown and I4 //IL_005f: 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_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0103: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2961906559u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref networkObjectReference, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, targetClientId); BytePacker.WriteValueBitPacked(val2, maskTypeId); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2961906559u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { MaskedEnemyHelper.SetMaskedEnemyProperties_Client(networkObjectReference, targetClientId, maskTypeId); } } } [ClientRpc] public void GenerateMold_ClientRpc(Vector3 position, int iterations) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: 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_007e: 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_00db: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1510582698u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); BytePacker.WriteValueBitPacked(val2, iterations); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1510582698u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { MoldHelper.GenerateMold_Local(position, iterations); } } } [ServerRpc(RequireOwnership = false)] public void ShowMessage_ServerRpc(string message, MessageSettings messageSettings) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_00c1: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2284586051u, val, (RpcDelivery)0); bool flag = message != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(message, false); } ((FastBufferWriter)(ref val2)).WriteValueSafe(ref messageSettings, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2284586051u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ShowMessage_ClientRpc(message, messageSettings); MessageManger.Instance.ShowMessage_LocalClient(message, messageSettings); } } [ClientRpc] public void ShowMessage_ClientRpc(string message, MessageSettings messageSettings) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_00c1: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1053630981u, val, (RpcDelivery)0); bool flag = message != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(message, false); } ((FastBufferWriter)(ref val2)).WriteValueSafe(ref messageSettings, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1053630981u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { MessageManger.Instance.ShowMessage_LocalClient(message, messageSettings); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(1218369902u, new RpcReceiveHandler(__rpc_handler_1218369902), "SetSyncedConfigValue_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(2961906559u, new RpcReceiveHandler(__rpc_handler_2961906559), "SetMaskedEnemyProperties_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(1510582698u, new RpcReceiveHandler(__rpc_handler_1510582698), "GenerateMold_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(2284586051u, new RpcReceiveHandler(__rpc_handler_2284586051), "ShowMessage_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(1053630981u, new RpcReceiveHandler(__rpc_handler_1053630981), "ShowMessage_ClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1218369902(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_009f: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string section = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref section, false); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); string key = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref key, false); } bool flag3 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag3, default(ForPrimitives)); string value = null; if (flag3) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref value, false); } ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).SetSyncedConfigValue_ClientRpc(section, key, value, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2961906559(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_005e: 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_0080: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference networkObjectReference = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe(ref networkObjectReference, default(ForNetworkSerializable)); ulong targetClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId); int maskTypeId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref maskTypeId); target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).SetMaskedEnemyProperties_ClientRpc(networkObjectReference, targetClientId, maskTypeId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1510582698(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0030: 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_004e: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); int iterations = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref iterations); target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).GenerateMold_ClientRpc(position, iterations); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2284586051(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_007c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string message = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref message, false); } MessageSettings messageSettings = default(MessageSettings); ((FastBufferReader)(ref reader)).ReadValueSafe(ref messageSettings, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).ShowMessage_ServerRpc(message, messageSettings); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1053630981(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_007c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string message = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref message, false); } MessageSettings messageSettings = default(MessageSettings); ((FastBufferReader)(ref reader)).ReadValueSafe(ref messageSettings, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((PluginNetworkHandler)(object)target).ShowMessage_ClientRpc(message, messageSettings); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "PluginNetworkHandler"; } } public class Plushie : MonoBehaviour { [CompilerGenerated] private sealed class d__15 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float duration; public Plushie <>4__this; 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown int num = <>1__state; Plushie plushie = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(duration); <>1__state = 1; return true; case 1: <>1__state = -1; ((Component)plushie).gameObject.SetActive(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(); } } private static List _instances = new List(); [SerializeField] public AudioSource _audioSource; private Coroutine _disableAfterTimeCoroutine; private static float _timeSincePlayingAudibleNoise; public static float DespawnDuration => ConfigManager.Plushie_DespawnDuration.Value; public static float DefaultVolume01 => ConfigManager.Plushie_SFXVolume.Value * 0.01f; public static bool PlaySFXOnCollision => ConfigManager.Plushie_PlaySFXOnCollision.Value; public static bool AttractDogs => ConfigManager.Plushie_AttractDogs.Value; private void OnEnable() { if (!_instances.Contains(this)) { _instances.Add(this); } if (_disableAfterTimeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_disableAfterTimeCoroutine); } _disableAfterTimeCoroutine = ((MonoBehaviour)this).StartCoroutine(DisableAfterTime_Coroutine(ConfigManager.Plushie_DespawnDuration.Value)); } private void OnDisable() { _instances.Remove(this); if (_disableAfterTimeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_disableAfterTimeCoroutine); } } private void Start() { ApplyConfigSettings(); } [IteratorStateMachine(typeof(d__15))] private IEnumerator DisableAfterTime_Coroutine(float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this, duration = duration }; } private void OnCollisionEnter(Collision collision) { //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_0034: Unknown result type (might be due to invalid IL or missing references) Vector3 relativeVelocity = collision.relativeVelocity; if (((Vector3)(ref relativeVelocity)).magnitude > 2f) { if (PlaySFXOnCollision) { _audioSource.Play(); } if (AttractDogs) { PlayAudibleNoiseLimited(((Component)this).transform.position, 65f, 1f, 0, PlayerUtils.LocalPlayerScript.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed); } } } public static void PlayAudibleNoiseLimited(Vector3 noisePosition, float noiseRange = 10f, float noiseLoudness = 0.5f, int timesPlayedInSameSpot = 0, bool noiseIsInsideClosedShip = false, int noiseID = 0, float timeout = 0.1f) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)RoundManager.Instance == (Object)null) && !(Time.realtimeSinceStartup - _timeSincePlayingAudibleNoise < timeout)) { Logger.LogInfo("PlayAudibleNoiseLimited!!!", extended: true); _timeSincePlayingAudibleNoise = Time.realtimeSinceStartup; RoundManager.Instance.PlayAudibleNoise(noisePosition, noiseRange, noiseLoudness, timesPlayedInSameSpot, noiseIsInsideClosedShip, noiseID); } } private void ApplyConfigSettings() { AudioSource audioSource = _audioSource; if (audioSource != null) { audioSource.volume = DefaultVolume01; } } public static void OnConfigSettingsChanged() { foreach (Plushie instance in _instances) { instance.ApplyConfigSettings(); } } } public class PlushieManager : NetworkBehaviour { [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Transform targetTransform; public string targetPoolId; public float duration; public PlushieManager <>4__this; private int 5__2; private float 5__3; private float 5__4; private int 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_008d: 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_0096: 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_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_00c1: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_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_00fa: 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) int num = <>1__state; PlushieManager plushieManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)targetTransform == (Object)null) { Logger.LogError("Failed to spawn plushie from pool. Target Transform is null. (PoolId: " + targetPoolId + ")"); return false; } 5__2 = ConfigManager.Plushie_SpawnCount.Value; 5__3 = duration / (float)5__2; 5__4 = ConfigManager.Plushie_Scale.Value; 5__5 = 0; break; case 1: <>1__state = -1; 5__5++; break; } if (5__5 < 5__2) { try { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(0.75f, 1.25f) * 5__4; Vector3 position = targetTransform.position + new Vector3(val.x, Random.Range(2.5f, 3.5f), val.y); Quaternion rotation = Random.rotation; plushieManager.SpawnFromPool(targetPoolId, position, rotation, 5__4); } catch (Exception arg) { Logger.LogError($"Failed to spawn plushie from pool. (PoolId: {targetPoolId}) {arg}"); } <>2__current = (object)new WaitForSeconds(5__3); <>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 List AdditionalPlushies = new List(); private Dictionary> _poolDictionary = new Dictionary>(StringComparer.OrdinalIgnoreCase); public static PlushieManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { CreatePools(); } public void CreatePools() { ClearPools(); int value = ConfigManager.Plushie_SpawnCount.Value; foreach (EnemyData value2 in Assets.EnemyDatabase.Entries.Values) { if (!((Object)(object)value2.PlushiePrefab == (Object)null)) { CreatePool(value2.DisplayName, value2.PlushiePrefab, value); } } foreach (PlushiePoolData additionalPlushy in AdditionalPlushies) { if (!((Object)(object)additionalPlushy.Prefab == (Object)null)) { CreatePool(additionalPlushy.PoolId, additionalPlushy.Prefab, value); } } if (_poolDictionary.Count == 0) { Logger.LogError("PlushieManager: Failed to create plushie pools!"); } } private void CreatePool(string poolId, GameObject prefab, int spawnCount) { Queue queue = new Queue(); for (int i = 0; i < spawnCount; i++) { GameObject val = Object.Instantiate(prefab); val.transform.SetParent(((Component)this).transform); Plushie component = val.GetComponent(); val.SetActive(false); queue.Enqueue(component); } _poolDictionary.Add(poolId, queue); Logger.LogInfo($"Created plushie pool. (poolId: \"{poolId}\", spawnCount: {spawnCount})", extended: true); } internal void ClearPools() { if (_poolDictionary.Count == 0) { return; } foreach (KeyValuePair> item in _poolDictionary) { foreach (Plushie item2 in item.Value) { Object.Destroy((Object)(object)((Component)item2).gameObject); } } _poolDictionary.Clear(); Logger.LogInfo("Cleared all plushie pools.", extended: true); } public bool PoolExists(string poolId) { return _poolDictionary.ContainsKey(poolId); } [IteratorStateMachine(typeof(d__12))] private IEnumerator SpawnPlushiesOverTime_Coroutine(string targetPoolId, Transform targetTransform, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this, targetPoolId = targetPoolId, targetTransform = targetTransform, duration = duration }; } private Plushie SpawnFromPool(string targetPoolId, Vector3 position, Quaternion rotation, float scale = 1f) { //IL_00ad: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (_poolDictionary == null) { Logger.LogError("Failed to spawn plushie from pool. Pool dictionary is null."); return null; } bool flag = string.IsNullOrWhiteSpace(targetPoolId); if (!flag && !_poolDictionary.ContainsKey(targetPoolId)) { Logger.LogError("Failed to spawn plushie from pool. Could not find pool with id \"" + targetPoolId + "\""); return null; } try { Queue queue = ((!flag) ? _poolDictionary[targetPoolId] : _poolDictionary.ElementAt(Random.Range(0, _poolDictionary.Count)).Value); Plushie plushie = queue.Dequeue(); if ((Object)(object)plushie == (Object)null) { Logger.LogError("Failed to spawn plushie from pool. Plushie is null. (PoolId: " + targetPoolId + ")"); return null; } Logger.LogInfo($"Spawning plushie at position {position} with rotation {rotation}", extended: true); ((Component)plushie).gameObject.SetActive(false); ((Component)plushie).gameObject.SetActive(true); ((Component)plushie).transform.SetPositionAndRotation(position, rotation); ((Component)plushie).transform.localScale = new Vector3(scale, scale, scale); queue.Enqueue(plushie); return plushie; } catch (Exception arg) { Logger.LogError($"Failed to spawn plushie from pool. (PoolId: {targetPoolId}) {arg}"); return null; } } public void SpawnPlushiesFromData(SpawnPlushiesData spawnPlushiesData) { bool flag = NetworkUtils.IsLocalClientId(spawnPlushiesData.SpawnedFromClientId); bool flag2 = NetworkUtils.IsLocalClientId(spawnPlushiesData.SpawnedOnClientId); PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(spawnPlushiesData.SpawnedOnClientId); if ((Object)(object)playerScriptByClientId == (Object)null || !CanSpawnPlushiesOnPlayer(playerScriptByClientId)) { return; } PlayerControllerB playerScriptByClientId2 = PlayerUtils.GetPlayerScriptByClientId(spawnPlushiesData.SpawnedFromClientId); if ((Object)(object)playerScriptByClientId2 == (Object)null) { return; } string text = spawnPlushiesData.TargetPoolId; string s = text + " plushies"; if (!PoolExists(text)) { text = string.Empty; s = "random plushies"; } string displayNameWithReadableColor = spawnPlushiesData.Viewer.GetDisplayNameWithReadableColor(); string text2 = (flag ? string.Empty : ("[" + playerScriptByClientId2.playerUsername + "]")); string text3 = text2 + " " + displayNameWithReadableColor + " spawned " + s.RichColor("#FFFF00"); if (!flag2 || !flag) { text3 = text3 + " on " + playerScriptByClientId.playerUsername; } if (ConfigManager.Message_ShowDetailedTwitchEventSpawnEnemyMessages.Value) { text3 = text3 + " " + spawnPlushiesData.SpawnReason; } MessageManger.Instance?.ShowMessage_LocalClient(text3); if (flag2) { if (string.IsNullOrEmpty(text) || !PoolExists(text)) { SpawnRandomPlushies(PlayerUtils.LocalPlayerScript); } else { SpawnPlushies(text, PlayerUtils.LocalPlayerScript); } } } public void SpawnRandomPlushies(PlayerControllerB targetPlayerScript) { if (_poolDictionary == null) { Logger.LogError("Failed to spawn random plushies from pool. Pool dictionary is null."); } else if (_poolDictionary.Count == 0) { Logger.LogError("Failed to spawn random plushies from pool. Pool dictionary is empty."); } else { SpawnPlushies(string.Empty, targetPlayerScript); } } public void SpawnPlushies(string targetPoolId, PlayerControllerB targetPlayerScript) { if ((Object)(object)targetPlayerScript == (Object)null) { Logger.LogError("Failed to spawn plushies from pool. PlayerControllerB is null."); } else if (CanSpawnPlushiesOnPlayer(targetPlayerScript)) { if (_poolDictionary == null) { Logger.LogError("Failed to spawn plushies from pool. Pool dictionary is null."); return; } if (!string.IsNullOrWhiteSpace(targetPoolId) && !_poolDictionary.ContainsKey(targetPoolId)) { Logger.LogError("Failed to spawn plushies from pool. Could not find pool with id \"" + targetPoolId + "\""); return; } Logger.LogInfo($"Spawning plushies. (poolId: \"{targetPoolId}\", spawnCount: {ConfigManager.Plushie_SpawnCount.Value})", extended: true); ((MonoBehaviour)this).StartCoroutine(SpawnPlushiesOverTime_Coroutine(targetPoolId, ((Component)targetPlayerScript).transform, 0.25f)); } } public bool CanSpawnPlushiesOnPlayer(PlayerControllerB playerScript) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return false; } if (StartOfRound.Instance.inShipPhase) { return false; } if (StartOfRound.Instance.shipIsLeaving) { return false; } if ((Object)(object)playerScript == (Object)null) { return false; } if (playerScript.isPlayerDead) { return false; } return true; } private void UpdateSettings() { CreatePools(); } public static void OnConfigSettingsChanged() { Instance?.UpdateSettings(); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } protected internal override string __getTypeName() { return "PlushieManager"; } } public class SpawnEventHandler : NetworkBehaviour { public static SpawnEventHandler Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } [ServerRpc(RequireOwnership = false)] public void ExecuteSpawnEnemyData_ServerRpc(SpawnEnemyData spawnEnemyData, ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_00c7: 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_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(964588582u, serverRpcParams, (RpcDelivery)0); bool flag = spawnEnemyData != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(ref spawnEnemyData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val, 964588582u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = serverRpcParams.Receive.SenderClientId; if (NetworkUtils.HasClient(senderClientId) && (!ConfigManager.Enemy_OnlyHostSpawnEnemies.Value || NetworkUtils.IsLocalClientId(senderClientId))) { EnemyHelper.SpawnEnemiesFromData_Server(spawnEnemyData); } } } [ClientRpc] public void ShowSpawnEnemyDataMessage_ClientRpc(SpawnEnemyData viewerSpawnEvent, string spawnedEnemyDisplayName) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_00d9: 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_00b2: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4211844711u, val, (RpcDelivery)0); bool flag = viewerSpawnEvent != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref viewerSpawnEvent, default(ForNetworkSerializable)); } bool flag2 = spawnedEnemyDisplayName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe(spawnedEnemyDisplayName, false); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4211844711u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (!ConfigManager.Message_ShowSpawnEnemyMessages.Value || (Object)(object)MessageManger.Instance == (Object)null) { return; } PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(viewerSpawnEvent.SpawnedFromClientId); if ((Object)(object)playerScriptByClientId == (Object)null) { return; } bool flag3 = PlayerUtils.IsLocalPlayer(playerScriptByClientId); if (flag3 && !ConfigManager.Message_ShowLocalSpawnEnemyMessages.Value) { return; } PlayerControllerB playerScriptByClientId2 = PlayerUtils.GetPlayerScriptByClientId(viewerSpawnEvent.SpawnedOnClientId); if (!((Object)(object)playerScriptByClientId2 == (Object)null)) { string displayNameWithReadableColor = viewerSpawnEvent.Viewer.GetDisplayNameWithReadableColor(); string text = (flag3 ? string.Empty : ("[" + playerScriptByClientId.playerUsername + "]")); string s = (string.IsNullOrWhiteSpace(spawnedEnemyDisplayName) ? "random enemies" : spawnedEnemyDisplayName); string text2 = string.Format("{0} {1} spawned {2}x {3}", text, displayNameWithReadableColor, viewerSpawnEvent.SpawnedCount, s.RichColor("#FF0000")); if (!PlayerUtils.IsLocalPlayer(playerScriptByClientId2) || !flag3) { text2 = text2 + " on " + playerScriptByClientId2.playerUsername; } if (ConfigManager.Message_ShowDetailedTwitchEventSpawnEnemyMessages.Value) { text2 = text2 + " " + viewerSpawnEvent.SpawnReason; } MessageManger.Instance.ShowMessage_LocalClient(text2); } } [ServerRpc(RequireOwnership = false)] public void ExecuteSpawnPlushiesData_ServerRpc(SpawnPlushiesData spawnPlushiesData, ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_00c7: 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_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4094674813u, serverRpcParams, (RpcDelivery)0); bool flag = spawnPlushiesData != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(ref spawnPlushiesData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val, 4094674813u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = serverRpcParams.Receive.SenderClientId; if (NetworkUtils.HasClient(senderClientId)) { ExecuteSpawnPlushiesData_ClientRpc(spawnPlushiesData); } } } [ClientRpc] private void ExecuteSpawnPlushiesData_ClientRpc(SpawnPlushiesData spawnPlushiesData) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_00ac: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3724533460u, val, (RpcDelivery)0); bool flag = spawnPlushiesData != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnPlushiesData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3724533460u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; PlushieManager.Instance?.SpawnPlushiesFromData(spawnPlushiesData); } } [ServerRpc(RequireOwnership = false)] public void RewardSpawnPointsFromCrewmateDeath_ServerRpc(NametagData nametagData, ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_00c7: 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_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(100894905u, serverRpcParams, (RpcDelivery)0); bool flag = nametagData != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(ref nametagData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val, 100894905u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = serverRpcParams.Receive.SenderClientId; if (NetworkUtils.HasClient(senderClientId)) { RewardSpawnPointsFromCrewmateDeath_ClientRpc(senderClientId, nametagData); } } } [ClientRpc] private void RewardSpawnPointsFromCrewmateDeath_ClientRpc(ulong crewmateClientId, NametagData nametagData) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Invalid comparison between Unknown and I4 //IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) //IL_00d4: 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_00bf: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(232026498u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, crewmateClientId); bool flag = nametagData != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref nametagData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 232026498u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; SpawnPointManager.RewardFromCrewmateDeath(crewmateClientId, nametagData); } } [ServerRpc(RequireOwnership = false)] public void ShowCrewmateDeathMessage_ServerRpc(NametagData nametagData, ServerRpcParams serverRpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_00c7: 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_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1731615439u, serverRpcParams, (RpcDelivery)0); bool flag = nametagData != null; ((FastBufferWriter)(ref val)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe(ref nametagData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val, 1731615439u, serverRpcParams, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ulong senderClientId = serverRpcParams.Receive.SenderClientId; if (NetworkUtils.HasClient(senderClientId)) { ShowCrewmateDeathMessage_ClientRpc(senderClientId, nametagData); } } } [ClientRpc] private void ShowCrewmateDeathMessage_ClientRpc(ulong crewmateClientId, NametagData nametagData) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Invalid comparison between Unknown and I4 //IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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) //IL_00d4: 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_00bf: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2709687186u, val, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val2, crewmateClientId); bool flag = nametagData != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref nametagData, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2709687186u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (ConfigManager.Message_ShowDeathMessages.Value) { PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(crewmateClientId); if (!((Object)(object)playerScriptByClientId == (Object)null) && (ConfigManager.Message_ShowCrewmateDeathMessages.Value || NetworkUtils.IsLocalClientId(crewmateClientId))) { string text = nametagData.EnemyDisplayName.RichColor("#FF0000"); string displayNameWithReadableColor = nametagData.GetDisplayNameWithReadableColor(); string platformSpriteText = EnemyNametag.GetPlatformSpriteText(nametagData.SpawnEnemyData.SpawnSource); string message = playerScriptByClientId.playerUsername + " was killed by " + text + " from " + displayNameWithReadableColor + " " + platformSpriteText; MessageManger.Instance?.ShowMessage_LocalClient(message, new MessageSettings(15f)); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(964588582u, new RpcReceiveHandler(__rpc_handler_964588582), "ExecuteSpawnEnemyData_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(4211844711u, new RpcReceiveHandler(__rpc_handler_4211844711), "ShowSpawnEnemyDataMessage_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(4094674813u, new RpcReceiveHandler(__rpc_handler_4094674813), "ExecuteSpawnPlushiesData_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(3724533460u, new RpcReceiveHandler(__rpc_handler_3724533460), "ExecuteSpawnPlushiesData_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(100894905u, new RpcReceiveHandler(__rpc_handler_100894905), "RewardSpawnPointsFromCrewmateDeath_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(232026498u, new RpcReceiveHandler(__rpc_handler_232026498), "RewardSpawnPointsFromCrewmateDeath_ClientRpc"); ((NetworkBehaviour)this).__registerRpc(1731615439u, new RpcReceiveHandler(__rpc_handler_1731615439), "ShowCrewmateDeathMessage_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(2709687186u, new RpcReceiveHandler(__rpc_handler_2709687186), "ShowCrewmateDeathMessage_ClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_964588582(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0078: 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_0096: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); SpawnEnemyData spawnEnemyData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnEnemyData, default(ForNetworkSerializable)); } ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4211844711(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0058: 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_00a6: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); SpawnEnemyData viewerSpawnEvent = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref viewerSpawnEvent, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); string spawnedEnemyDisplayName = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnedEnemyDisplayName, false); } target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).ShowSpawnEnemyDataMessage_ClientRpc(viewerSpawnEvent, spawnedEnemyDisplayName); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_4094674813(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0078: 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_0096: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); SpawnPlushiesData spawnPlushiesData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPlushiesData, default(ForNetworkSerializable)); } ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).ExecuteSpawnPlushiesData_ServerRpc(spawnPlushiesData, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3724533460(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0058: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); SpawnPlushiesData spawnPlushiesData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnPlushiesData, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).ExecuteSpawnPlushiesData_ClientRpc(spawnPlushiesData); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_100894905(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0078: 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_0096: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); NametagData nametagData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref nametagData, default(ForNetworkSerializable)); } ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).RewardSpawnPointsFromCrewmateDeath_ServerRpc(nametagData, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_232026498(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0042: 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_0099: 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_006b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong crewmateClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref crewmateClientId); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); NametagData nametagData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref nametagData, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).RewardSpawnPointsFromCrewmateDeath_ClientRpc(crewmateClientId, nametagData); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1731615439(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0078: 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_0096: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); NametagData nametagData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref nametagData, default(ForNetworkSerializable)); } ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).ShowCrewmateDeathMessage_ServerRpc(nametagData, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2709687186(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0042: 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_0099: 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_006b: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong crewmateClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref crewmateClientId); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); NametagData nametagData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref nametagData, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((SpawnEventHandler)(object)target).ShowCrewmateDeathMessage_ClientRpc(crewmateClientId, nametagData); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "SpawnEventHandler"; } } } namespace com.github.zehsteam.MonsterHotkeys.MonoBehaviours.Utils { internal class CoroutineRunner : MonoBehaviour { public static CoroutineRunner Instance { get; private set; } public static CoroutineRunner Spawn() { //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_0039: Expected O, but got Unknown if ((Object)(object)Instance != (Object)null) { return Instance; } GameObject val = new GameObject("MonsterHotkeys CoroutineRunner", new Type[1] { typeof(CoroutineRunner) }) { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)val); return val.GetComponent(); } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public static Coroutine Start(IEnumerator routine) { if ((Object)(object)Instance == (Object)null) { CoroutineRunner coroutineRunner = Spawn(); return ((coroutineRunner != null) ? ((MonoBehaviour)coroutineRunner).StartCoroutine(routine) : null) ?? null; } CoroutineRunner instance = Instance; return ((instance != null) ? ((MonoBehaviour)instance).StartCoroutine(routine) : null) ?? null; } public static void Stop(IEnumerator routine) { CoroutineRunner instance = Instance; if (instance != null) { ((MonoBehaviour)instance).StopCoroutine(routine); } } public static void Stop(Coroutine routine) { CoroutineRunner instance = Instance; if (instance != null) { ((MonoBehaviour)instance).StopCoroutine(routine); } } } internal class PluginHelper : MonoBehaviour { private static PluginHelper _instance; public static Action OnStart; public static void Spawn() { //IL_0026: 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_0034: Expected O, but got Unknown if (!((Object)(object)_instance != (Object)null)) { GameObject val = new GameObject("MonsterHotkeys PluginHelper", new Type[1] { typeof(PluginHelper) }) { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)val); } } private void Awake() { if ((Object)(object)_instance != (Object)null && (Object)(object)_instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { _instance = this; } } private void Start() { OnStart?.Invoke(); } } } namespace com.github.zehsteam.MonsterHotkeys.MonoBehaviours.UI { public class DeathMessage : MonoBehaviour { [CompilerGenerated] private sealed class d__11 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DeathMessage <>4__this; public float delay; public float fadeOutDuration; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown int num = <>1__state; DeathMessage deathMessage = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; deathMessage._canvasGroup.alpha = 1f; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; 5__2 = 0f; break; case 2: <>1__state = -1; 5__2 += Time.deltaTime; break; } if (5__2 < fadeOutDuration) { float num2 = 1f / fadeOutDuration * 5__2; float alpha = 1f + -1f * num2; deathMessage._canvasGroup.alpha = alpha; <>2__current = null; <>1__state = 2; return true; } deathMessage._canvasGroup.alpha = 0f; 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(); } } [SerializeField] private TextMeshProUGUI _messageText; [SerializeField] private CanvasGroup _canvasGroup; private Coroutine _fadeOutCoroutine; public static DeathMessage Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { _canvasGroup.alpha = 0f; } public void Show(EnemyNametag enemyNametag) { NametagData nametagData = enemyNametag.NametagData; SpawnEnemyData spawnEnemyData = nametagData.SpawnEnemyData; string text = ((!spawnEnemyData.IsFromViewer) ? spawnEnemyData.NonViewer.DisplayName : spawnEnemyData.Viewer.GetDisplayNameWithReadableColor()); string text2 = ("You died to " + nametagData.EnemyDisplayName.RichReadableColor("#FF0000") + " from " + text + " " + enemyNametag.GetPlatformSpriteText()).Trim(); if (!PlayerUtils.IsLocalPlayer(enemyNametag.SpawnedOnPlayerScript) && (Object)(object)enemyNametag.SpawnedOnPlayerScript != (Object)null) { text2 += (" (Spawned on " + enemyNametag.SpawnedOnPlayerScript.playerUsername + ")").RichColor("#9c9c9c"); } Show(text2); } public void Show(string message) { ((TMP_Text)_messageText).text = message; if (_fadeOutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_fadeOutCoroutine); } _fadeOutCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeOut_Coroutine(15f)); } [IteratorStateMachine(typeof(d__11))] private IEnumerator FadeOut_Coroutine(float delay, float fadeOutDuration = 1f) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { <>4__this = this, delay = delay, fadeOutDuration = fadeOutDuration }; } } public class EnemyNametag : MonoBehaviour { [CompilerGenerated] private sealed class d__27 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemyNametag <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__27(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; EnemyNametag enemyNametag = <>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; enemyNametag.LateStart(); 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(); } } [SerializeField] private TextMeshProUGUI _usernameText; [SerializeField] private Image _backgroundImage; [SerializeField] private CanvasGroup _canvasGroup; [CompilerGenerated] private PlayerControllerB k__BackingField; [CompilerGenerated] private PlayerControllerB k__BackingField; private float _baseScale = 2f; public EnemyAI EnemyAI { get; private set; } public NametagSettings Settings { get; private set; } public NametagData NametagData { get; private set; } public SpawnEnemyData SpawnEnemyData => NametagData.SpawnEnemyData; public PlayerControllerB SpawnedFromPlayerScript { get { if (k__BackingField == null) { k__BackingField = PlayerUtils.GetPlayerScriptByClientId(SpawnEnemyData.SpawnedFromClientId); } return k__BackingField; } } public PlayerControllerB SpawnedOnPlayerScript { get { if (k__BackingField == null) { k__BackingField = PlayerUtils.GetPlayerScriptByClientId(SpawnEnemyData.SpawnedOnClientId); } return k__BackingField; } } public SpawnSource SpawnSource => SpawnEnemyData.SpawnSource; private void Start() { if ((Object)(object)((Component)this).transform.parent == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } EnemyAI = ((Component)((Component)this).transform.parent).GetComponent(); if ((Object)(object)EnemyAI == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (!EnemyAI.enemyType.TryGetData(out var enemyData)) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Settings = enemyData.NametagSettings; SetPosition(); ((MonoBehaviour)this).StartCoroutine(LateStart_Coroutine()); } [IteratorStateMachine(typeof(d__27))] private IEnumerator LateStart_Coroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__27(0) { <>4__this = this }; } private void LateStart() { string enemyName = EnemyAI.enemyType.enemyName; if (!(enemyName == "Manticoil")) { if (enemyName == "RadMech") { EnemyAI enemyAI = EnemyAI; OldBird_LateStart((RadMechAI)(object)((enemyAI is RadMechAI) ? enemyAI : null)); } } else { EnemyAI enemyAI2 = EnemyAI; Manticoil_LateStart((DoublewingAI)(object)((enemyAI2 is DoublewingAI) ? enemyAI2 : null)); } SetScale(); } public void SetData(NametagData nametagData) { NametagData = nametagData; UpdateUsernameText(); } private void UpdateUsernameText() { if (!((Object)(object)_usernameText == (Object)null)) { ((TMP_Text)_usernameText).text = (GetPlatformSpriteText() + " " + NametagData.GetDisplayName()).Trim(); } } public string GetPlatformSpriteText() { return GetPlatformSpriteText(SpawnSource); } public static string GetPlatformSpriteText(SpawnSource spawnSource) { if (!ConfigManager.EnemyNametag_ShowPlatform.Value) { return string.Empty; } int num = -1; switch (spawnSource) { case SpawnSource.Twitch: num = 0; break; case SpawnSource.CrowdControl: num = 1; break; } if (num < 0) { return string.Empty; } return $""; } private void Manticoil_LateStart(DoublewingAI doublewingAI) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)doublewingAI == (Object)null)) { ((Component)this).transform.SetParent(doublewingAI.Body); ((Component)this).transform.localPosition = new Vector3(0f, 3f, 0f); } } private void OldBird_LateStart(RadMechAI radMechAI) { if ((Object)(object)radMechAI == (Object)null) { return; } try { Transform parent = ((Component)radMechAI).transform.Find("MeshContainer").Find("AnimContainer").Find("metarig"); ((Component)this).transform.SetParent(parent); } catch { } } private void Update() { if ((Object)(object)EnemyAI == (Object)null || EnemyAI.isEnemyDead) { Object.Destroy((Object)(object)((Component)this).gameObject); } switch (EnemyAI.enemyType.enemyName) { case "Clay Surgeon": { EnemyAI enemyAI3 = EnemyAI; Barber_Update((ClaySurgeonAI)(object)((enemyAI3 is ClaySurgeonAI) ? enemyAI3 : null)); break; } case "Earth Leviathan": { EnemyAI enemyAI2 = EnemyAI; EarthLeviathan_Update((SandWormAI)(object)((enemyAI2 is SandWormAI) ? enemyAI2 : null)); break; } case "Girl": { EnemyAI enemyAI = EnemyAI; GhostGirl_Update((DressGirlAI)(object)((enemyAI is DressGirlAI) ? enemyAI : null)); break; } } } private void Barber_Update(ClaySurgeonAI claySurgeonAI) { //IL_0028: 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) if (!((Object)(object)claySurgeonAI == (Object)null)) { PlayerControllerB localPlayerScript = PlayerUtils.LocalPlayerScript; if ((Object)(object)localPlayerScript == (Object)null) { SetVisible(value: false); } else { SetVisible(Vector3.Distance(((Component)claySurgeonAI).transform.position, ((Component)localPlayerScript).transform.position) <= claySurgeonAI.maxDistance); } } } private void EarthLeviathan_Update(SandWormAI sandWormAI) { if (!((Object)(object)sandWormAI == (Object)null)) { SetVisible(sandWormAI.emerged); } } private void GhostGirl_Update(DressGirlAI dressGirlAI) { if (!((Object)(object)dressGirlAI == (Object)null)) { if (!PlayerUtils.IsLocalPlayer(dressGirlAI.hauntingPlayer)) { SetVisible(value: false); } else if (((EnemyAI)dressGirlAI).skinnedMeshRenderers == null || ((EnemyAI)dressGirlAI).skinnedMeshRenderers.Length == 0) { SetVisible(value: true); } else { SetVisible(((Component)((EnemyAI)dressGirlAI).skinnedMeshRenderers[0]).gameObject.layer == 19); } } } private void SetVisible(bool value) { _canvasGroup.alpha = (value ? 1f : 0f); } private void LateUpdate() { //IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references) Camera targetCamera = GetTargetCamera(); if (!((Object)(object)targetCamera == (Object)null)) { ((Component)this).transform.LookAt(((Component)this).transform.position + ((Component)targetCamera).transform.forward); } } private Camera GetTargetCamera() { if (!ImmersiveEntranceProxy.IsInstalled) { return PlayerUtils.GetLocalPlayerCamera(); } bool isOutside = EnemyAI.isOutside; bool flag = !PlayerUtils.IsLocalPlayerCameraInsideInterior(); if (isOutside != flag && ImmersiveEntranceProxy.TryGetRenderingCamera(out var camera)) { return camera; } return PlayerUtils.GetLocalPlayerCamera(); } private Vector3 GetEnemyScale(bool original = false) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (original) { return EnemyAI.enemyType.enemyPrefab.transform.localScale; } return ((Component)EnemyAI).transform.localScale; } private Vector3 GetNormalizedEnemyScale() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return GetNormalized(GetEnemyScale(), GetEnemyScale(original: true)); } private Vector3 GetNormalized(Vector3 a, Vector3 b) { //IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) return new Vector3(a.x / b.x, a.y / b.y, a.z / b.z); } private void SetScale() { float num = 1f; if (Settings != null && Settings.UseSettings) { num = Settings.ScaleMultiplier; } SetScale(_baseScale * num); } private void SetScale(float scaleMultiplier) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_004a: 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_005b: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = GetNormalized(GetNormalizedEnemyScale(), GetEnemyScale()); float num = Mathf.Max(new float[3] { normalized.x, normalized.y, 0.75f }); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num, num); ((Component)this).transform.localScale = val * scaleMultiplier * ConfigManager.EnemyNametag_ScaleMultiplier.Value; } private void SetPosition() { //IL_0092: 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_00b7: 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) //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_00ec: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EnemyAI == (Object)null) { return; } if (Settings != null && Settings.UseSettings && Settings.YOffset != 0f) { SetPosition(new Vector3(0f, Settings.YOffset, 0f)); return; } float num = 0f; float num2 = 0f; float num3 = 0f; if ((Object)(object)EnemyAI.eye != (Object)null) { num = Mathf.Abs(((Component)EnemyAI).transform.InverseTransformPoint(EnemyAI.eye.position).y - ((Component)EnemyAI).transform.InverseTransformPoint(((Component)EnemyAI).transform.position).y); } SkinnedMeshRenderer componentInChildren = ((Component)EnemyAI).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { Bounds localBounds = ((Renderer)componentInChildren).localBounds; num2 = ((Bounds)(ref localBounds)).max.y; } MeshRenderer componentInChildren2 = ((Component)EnemyAI).GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { Bounds localBounds2 = ((Renderer)componentInChildren2).localBounds; num3 = ((Bounds)(ref localBounds2)).max.y; } float num4 = Mathf.Max(new float[3] { num, num2, num3 }); if (num4 == 0f) { ((Component)this).transform.localPosition = new Vector3(0f, 2f, 0f); return; } num4 += 1f; SetPosition(new Vector3(0f, num4, 0f)); } private void SetPosition(Vector3 position) { //IL_0011: 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) ((Component)this).transform.position = ((Component)EnemyAI).transform.TransformPoint(position); } private void SetBackgroundTransparency(int value) { //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_002b: 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) Color32 val = Color32.op_Implicit(((Graphic)_backgroundImage).color); val.a = (byte)Mathf.Clamp(value, 0, 255); ((Graphic)_backgroundImage).color = Color32.op_Implicit(val); } private void ApplyConfigSettings() { SetScale(); UpdateUsernameText(); SetBackgroundTransparency(ConfigManager.EnemyNametag_BackgroundTransparency.Value); } public static void OnConfigSettingsChanged() { if ((Object)(object)EnemyNametagManager.Instance == (Object)null) { return; } foreach (EnemyNametag value in EnemyNametagManager.Instance.EnemyNametagPairs.Values) { value.ApplyConfigSettings(); } } } public class EnemyNametagManager : NetworkBehaviour { [CompilerGenerated] private sealed class <>c__DisplayClass17_0 { public float startTime; public float maxWaitTime; public NetworkObjectReference networkObjectReference; public NetworkObject networkObject; internal bool b__0() { if (!(Time.realtimeSinceStartup - startTime > maxWaitTime)) { return ((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref networkObject, (NetworkManager)null); } return true; } } [CompilerGenerated] private sealed class d__17 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkObjectReference networkObjectReference; private <>c__DisplayClass17_0 <>8__1; public EnemyNametagManager <>4__this; public SpawnEnemyData spawnEnemyData; 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() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown int num = <>1__state; EnemyNametagManager enemyNametagManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass17_0(); <>8__1.networkObjectReference = networkObjectReference; if (((NetworkObjectReference)(ref <>8__1.networkObjectReference)).NetworkObjectId == 0L) { return false; } <>8__1.startTime = Time.realtimeSinceStartup; <>8__1.networkObject = null; <>8__1.maxWaitTime = 20f; <>2__current = (object)new WaitUntil((Func)(() => Time.realtimeSinceStartup - <>8__1.startTime > <>8__1.maxWaitTime || ((NetworkObjectReference)(ref <>8__1.networkObjectReference)).TryGet(ref <>8__1.networkObject, (NetworkManager)null))); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)<>8__1.networkObject == (Object)null) { return false; } enemyNametagManager.SpawnNametag_LocalClient(spawnEnemyData, <>8__1.networkObject); 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(); } } [SerializeField] private GameObject _enemyNametagPrefab; public static EnemyNametagManager Instance { get; private set; } public Dictionary EnemyNametagPairs { get; private set; } = new Dictionary(); private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } public void Reset() { EnemyNametagPairs.Clear(); } [ServerRpc(RequireOwnership = false)] public void SpawnNametags_ServerRpc(SpawnEnemyData spawnEnemyData, NetworkObjectReference[] networkObjectReferences) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_00d9: 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_00b2: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4164734534u, val, (RpcDelivery)0); bool flag = spawnEnemyData != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnEnemyData, default(ForNetworkSerializable)); } bool flag2 = networkObjectReferences != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe(networkObjectReferences, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4164734534u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; SpawnNametags_ClientRpc(spawnEnemyData, networkObjectReferences); SpawnNametags_LocalClient(spawnEnemyData, networkObjectReferences); } } [ClientRpc] private void SpawnNametags_ClientRpc(SpawnEnemyData spawnEnemyData, NetworkObjectReference[] networkObjectReferences) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_00d9: 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_00b2: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1339106667u, val, (RpcDelivery)0); bool flag = spawnEnemyData != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(ref spawnEnemyData, default(ForNetworkSerializable)); } bool flag2 = networkObjectReferences != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe(networkObjectReferences, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1339106667u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { SpawnNametagsWithDelay_LocalClient(spawnEnemyData, networkObjectReferences); } } } private void SpawnNametags_LocalClient(SpawnEnemyData spawnEnemyData, NetworkObjectReference[] networkObjectReferences) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (ConfigManager.EnemyNametag_Enabled.Value) { foreach (NetworkObjectReference networkObjectReference in networkObjectReferences) { SpawnNametag_LocalClient(spawnEnemyData, networkObjectReference); } } } private void SpawnNametag_LocalClient(SpawnEnemyData spawnEnemyData, NetworkObjectReference networkObjectReference) { NetworkObject networkObject = default(NetworkObject); if (!((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref networkObject, (NetworkManager)null)) { Logger.LogError("Failed to set EnemyNametag. NetworkObject is null."); } else { SpawnNametag_LocalClient(spawnEnemyData, networkObject); } } private void SpawnNametag_LocalClient(SpawnEnemyData spawnEnemyData, NetworkObject networkObject) { if ((Object)(object)networkObject == (Object)null) { Logger.LogError("Failed to set EnemyNametag. NetworkObject is null."); return; } EnemyAI val = default(EnemyAI); if (!((Component)networkObject).TryGetComponent(ref val)) { Logger.LogError("Failed to set EnemyNametag. EnemyAI is null."); return; } string enemyName = val.enemyType.enemyName; if (EnemyNametagPairs.ContainsKey(val)) { Logger.LogError("Failed to set EnemyNametag on \"" + enemyName + "\". EnemyAI already has an EnemyNametag."); return; } if (!val.enemyType.TryGetData(out var enemyData)) { Logger.LogError("Failed to set EnemyNametag on \"" + enemyName + "\". Could not find EnemyData."); return; } NametagData data = new NametagData(spawnEnemyData, enemyData.DisplayName); GameObject val2 = Object.Instantiate(_enemyNametagPrefab, ((Component)val).transform); EnemyNametag enemyNametag = default(EnemyNametag); if (val2.TryGetComponent(ref enemyNametag)) { enemyNametag.SetData(data); EnemyNametagPairs.Add(val, enemyNametag); } } private void SpawnNametagsWithDelay_LocalClient(SpawnEnemyData spawnEnemyData, NetworkObjectReference[] networkObjectReferences) { //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_0011: Unknown result type (might be due to invalid IL or missing references) foreach (NetworkObjectReference networkObjectReference in networkObjectReferences) { ((MonoBehaviour)this).StartCoroutine(SpawnNametagWithDelay_LocalClient(spawnEnemyData, networkObjectReference)); } } [IteratorStateMachine(typeof(d__17))] private IEnumerator SpawnNametagWithDelay_LocalClient(SpawnEnemyData spawnEnemyData, NetworkObjectReference networkObjectReference) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__17(0) { <>4__this = this, spawnEnemyData = spawnEnemyData, networkObjectReference = networkObjectReference }; } public void DisableNametag_LocalClient(EnemyAI enemyAI) { if (!((Object)(object)enemyAI == (Object)null) && EnemyNametagPairs.TryGetValue(enemyAI, out var value) && !((Object)(object)value == (Object)null)) { ((Component)value).gameObject.SetActive(false); } } public void DespawnNametag_LocalClient(EnemyAI enemyAI) { if (!((Object)(object)enemyAI == (Object)null) && EnemyNametagPairs.TryGetValue(enemyAI, out var value)) { EnemyNametagPairs.Remove(enemyAI); if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(4164734534u, new RpcReceiveHandler(__rpc_handler_4164734534), "SpawnNametags_ServerRpc"); ((NetworkBehaviour)this).__registerRpc(1339106667u, new RpcReceiveHandler(__rpc_handler_1339106667), "SpawnNametags_ClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_4164734534(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0058: 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_00b3: 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_009d: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); SpawnEnemyData spawnEnemyData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnEnemyData, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); NetworkObjectReference[] networkObjectReferences = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref networkObjectReferences, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((EnemyNametagManager)(object)target).SpawnNametags_ServerRpc(spawnEnemyData, networkObjectReferences); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1339106667(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0058: 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_00b3: 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_009d: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); SpawnEnemyData spawnEnemyData = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref spawnEnemyData, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); NetworkObjectReference[] networkObjectReferences = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref networkObjectReferences, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((EnemyNametagManager)(object)target).SpawnNametags_ClientRpc(spawnEnemyData, networkObjectReferences); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "EnemyNametagManager"; } } public class MessageItem : MonoBehaviour { [CompilerGenerated] private sealed class d__11 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MessageItem <>4__this; public float delay; public float fadeOutDuration; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown int num = <>1__state; MessageItem messageItem = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; messageItem._canvasGroup.alpha = 1f; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; 5__2 = 0f; goto IL_00c2; case 2: <>1__state = -1; 5__2 += Time.deltaTime; goto IL_00c2; case 3: { <>1__state = -1; ((Component)messageItem).gameObject.SetActive(false); return false; } IL_00c2: if (5__2 < fadeOutDuration) { float num2 = 1f / fadeOutDuration * 5__2; float alpha = 1f + -1f * num2; messageItem._canvasGroup.alpha = alpha; <>2__current = null; <>1__state = 2; return true; } messageItem._canvasGroup.alpha = 0f; <>2__current = null; <>1__state = 3; 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(); } } private static readonly List _instances = new List(); [SerializeField] private TextMeshProUGUI _messageText; [SerializeField] private Image _backgroundImage; [SerializeField] private CanvasGroup _canvasGroup; [SerializeField] private RectTransform _containerTransform; private MessageSettings _messageSettings; private Coroutine _fadeOutCoroutine; private void OnEnable() { if (!_instances.Contains(this)) { _instances.Add(this); } ApplyConfigSettings(); if (_fadeOutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_fadeOutCoroutine); } _fadeOutCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeOut_Coroutine(_messageSettings.Duration)); } private void OnDisable() { _instances.Remove(this); if (_fadeOutCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_fadeOutCoroutine); } } public void ApplySettings(MessageSettings messageSettings) { _messageSettings = messageSettings; } public void SetText(string message) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)_messageText).text = message.Trim(); ((Graphic)_messageText).color = _messageSettings.Color; } [IteratorStateMachine(typeof(d__11))] private IEnumerator FadeOut_Coroutine(float delay, float fadeOutDuration = 1f) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { <>4__this = this, delay = delay, fadeOutDuration = fadeOutDuration }; } private void ApplyConfigSettings() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)_messageText).fontSize = ConfigManager.Message_FontSize.Value; _backgroundImage.SetAlpha(ConfigManager.Message_BackgroundTransparency.Value); ScreenAnchor value = ConfigManager.Message_ScreenAnchor.Value; Vector2 pivot = default(Vector2); ((Vector2)(ref pivot))..ctor(1f, 0.5f); switch (value) { case ScreenAnchor.BottomLeft: pivot.x = 0f; break; case ScreenAnchor.TopLeft: pivot.x = 0f; break; } _containerTransform.pivot = pivot; } public static void OnConfigSettingsChanged() { foreach (MessageItem instance in _instances) { instance.ApplyConfigSettings(); } } } public class MessageManger : MonoBehaviour { [SerializeField] private RectTransform _messageListTransform; [SerializeField] private MessageItem _messageItemPrefab; private readonly Queue _messageItemPool = new Queue(); public static MessageManger Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { ApplyConfigSettings(); CreateMessageItemPool(); } private void CreateMessageItemPool() { ClearMessageItemPool(); for (int i = 0; i < 30; i++) { MessageItem messageItem = Object.Instantiate(_messageItemPrefab, (Transform)(object)_messageListTransform); ((Component)messageItem).gameObject.SetActive(false); _messageItemPool.Enqueue(messageItem); } } private void ClearMessageItemPool() { if (_messageItemPool.Count == 0) { return; } foreach (MessageItem item in _messageItemPool) { Object.Destroy((Object)(object)((Component)item).gameObject); } _messageItemPool.Clear(); Logger.LogInfo("Cleared MessageItem pool.", extended: true); } public void ShowMessage(string message) { ShowMessage(message, new MessageSettings()); } public void ShowMessage(string message, MessageSettings messageSettings) { if (NetworkUtils.IsServer) { PluginNetworkHandler.Instance.ShowMessage_ClientRpc(message, messageSettings); ShowMessage_LocalClient(message, messageSettings); } else { PluginNetworkHandler.Instance.ShowMessage_ServerRpc(message, messageSettings); } } public void ShowMessage_LocalClient(string message) { ShowMessage_LocalClient(message, new MessageSettings()); } public void ShowMessage_LocalClient(string message, MessageSettings messageSettings) { if (ConfigManager.Message_ShowMessages.Value) { SpawnMessageItemFromPool(message, messageSettings); } } private MessageItem SpawnMessageItemFromPool(string text, MessageSettings messageSettings) { if (_messageItemPool.Count == 0) { Logger.LogError("Failed to spawn MessageItem from pool. MessageItem pool is empty."); return null; } MessageItem messageItem = _messageItemPool.Dequeue(); if ((Object)(object)messageItem == (Object)null) { return null; } ((Component)messageItem).gameObject.SetActive(false); messageItem.ApplySettings(messageSettings); messageItem.SetText(text); ((Component)messageItem).gameObject.SetActive(true); ((Component)messageItem).transform.SetAsLastSibling(); _messageItemPool.Enqueue(messageItem); return messageItem; } private void ApplyConfigSettings() { ApplyMessageListSettings(); } private void ApplyMessageListSettings() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0142: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_messageListTransform == (Object)null) { return; } VerticalLayoutGroup component = ((Component)_messageListTransform).GetComponent(); if (!((Object)(object)component == (Object)null)) { ScreenAnchor value = ConfigManager.Message_ScreenAnchor.Value; float value2 = ConfigManager.Message_XOffset.Value; float value3 = ConfigManager.Message_YOffset.Value; float num = value2; float num2 = value3; switch (value) { case ScreenAnchor.BottomRight: num = (value2 + 20f) * -1f; break; case ScreenAnchor.TopRight: num = (value2 + 20f) * -1f; num2 = value3 * -1f; break; case ScreenAnchor.TopLeft: num2 = value3 * -1f; break; } switch (value) { case ScreenAnchor.BottomRight: ((LayoutGroup)component).childAlignment = (TextAnchor)8; break; case ScreenAnchor.BottomLeft: ((LayoutGroup)component).childAlignment = (TextAnchor)6; break; case ScreenAnchor.TopRight: ((LayoutGroup)component).childAlignment = (TextAnchor)2; break; case ScreenAnchor.TopLeft: ((LayoutGroup)component).childAlignment = (TextAnchor)0; break; } Vector2 val = default(Vector2); Vector2 val2; switch (value) { case ScreenAnchor.BottomRight: ((Vector2)(ref val))..ctor(1f, 0f); val2 = val; break; case ScreenAnchor.BottomLeft: ((Vector2)(ref val))..ctor(0f, 0f); val2 = val; break; case ScreenAnchor.TopRight: ((Vector2)(ref val))..ctor(1f, 1f); val2 = val; break; default: ((Vector2)(ref val))..ctor(0f, 1f); val2 = val; break; } _messageListTransform.anchorMin = val2; _messageListTransform.anchorMax = val; _messageListTransform.pivot = val2; _messageListTransform.anchoredPosition = new Vector2(num, num2); } } public static void OnConfigSettingsChanged() { Instance?.ApplyConfigSettings(); } } public class PluginHUD : MonoBehaviour { public static PluginHUD Instance { get; private set; } public static void Spawn() { if (!((Object)(object)Instance != (Object)null)) { Object.Instantiate(Assets.PluginHUDPrefab); } } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; ((Object)((Component)this).gameObject).name = "MonsterHotkeys PluginHUD"; Logger.LogInfo("Instantiated \"" + ((Object)((Component)this).gameObject).name + "\"", extended: true); } } } namespace com.github.zehsteam.MonsterHotkeys.MonoBehaviours.Audio { public class AudioPlayer : MonoBehaviour { [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AudioClip spawnSFX; public AudioPlayer <>4__this; public float volumeScale; 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() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown int num = <>1__state; AudioPlayer audioPlayer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if ((Object)(object)spawnSFX == (Object)null) { spawnSFX = audioPlayer._genericSpawnSFX; } audioPlayer._audioSource.PlayOneShot(audioPlayer._beforeSpawnSFX, volumeScale); <>2__current = (object)new WaitForSeconds(audioPlayer._beforeSpawnSFX.length + 0.25f); <>1__state = 1; return true; case 1: <>1__state = -1; audioPlayer._audioSource.PlayOneShot(spawnSFX, volumeScale); <>2__current = (object)new WaitForSeconds(spawnSFX.length); <>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(); } } [SerializeField] public AudioSource _audioSource; [SerializeField] public AudioClip _beforeSpawnSFX; [SerializeField] public AudioClip _genericSpawnSFX; private Coroutine _playSoundCoroutine; public void PlaySound(AudioClip spawnSFX, float volumeScale) { if (_playSoundCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_playSoundCoroutine); } _playSoundCoroutine = ((MonoBehaviour)this).StartCoroutine(PlaySound_Coroutine(spawnSFX, volumeScale)); } [IteratorStateMachine(typeof(d__5))] private IEnumerator PlaySound_Coroutine(AudioClip spawnSFX, float volumeScale) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { <>4__this = this, spawnSFX = spawnSFX, volumeScale = volumeScale }; } } public class AudioPlayerManager : NetworkBehaviour { [SerializeField] public GameObject _audioPlayerPrefab; private Queue _pool = new Queue(); public static AudioPlayerManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Start() { ApplyConfigSettings(); } private void CreatePool() { ClearPool(); int num = 100; for (int i = 0; i < num; i++) { GameObject val = Object.Instantiate(_audioPlayerPrefab); val.transform.SetParent(((Component)this).transform); AudioPlayer component = val.GetComponent(); val.SetActive(false); _pool.Enqueue(component); } Logger.LogInfo($"Created AudioPlayer pool. (amount: {num})", extended: true); } private void ClearPool() { if (_pool.Count == 0) { return; } foreach (AudioPlayer item in _pool) { Object.Destroy((Object)(object)((Component)item).gameObject); } _pool.Clear(); Logger.LogInfo("Cleared AudioPlayer pool.", extended: true); } private AudioPlayer SpawnFromPool(Vector3 position, AudioClip spawnSFX, float volumeScale) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = _pool.Dequeue(); ((Component)audioPlayer).gameObject.SetActive(false); ((Component)audioPlayer).gameObject.SetActive(true); ((Component)audioPlayer).transform.position = position; audioPlayer.PlaySound(spawnSFX, volumeScale); _pool.Enqueue(audioPlayer); return audioPlayer; } public void Spawn_Server(string enemyName, Vector3[] positions, bool inFactory) { if (NetworkUtils.IsServer) { SpawnClientRpc(enemyName, positions, inFactory); Spawn_LocalClient(enemyName, positions, inFactory); } } [ClientRpc] public void SpawnClientRpc(string enemyName, Vector3[] positions, bool inFactory) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_00cc: 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_00fe: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4134231816u, val, (RpcDelivery)0); bool flag = enemyName != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe(enemyName, false); } bool flag2 = positions != null; ((FastBufferWriter)(ref val2)).WriteValueSafe(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe(positions); } ((FastBufferWriter)(ref val2)).WriteValueSafe(ref inFactory, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4134231816u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; if (!NetworkUtils.IsServer) { Spawn_LocalClient(enemyName, positions, inFactory); } } } private void Spawn_LocalClient(string enemyName, Vector3[] positions, bool inFactory) { //IL_009f: 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_00a7: Unknown result type (might be due to invalid IL or missing references) if (_pool.Count == 0) { return; } PlayerControllerB localPlayerScript = PlayerUtils.LocalPlayerScript; if ((Object)(object)localPlayerScript == (Object)null) { return; } bool flag = true; if (localPlayerScript.isPlayerDead) { if ((Object)(object)localPlayerScript.spectatedPlayerScript != (Object)null && localPlayerScript.spectatedPlayerScript.isInsideFactory && !inFactory) { flag = false; } } else if (localPlayerScript.isInsideFactory && !inFactory) { flag = false; } if (flag) { AudioClip spawnSFX = null; float volumeScale = 0.8f; if (Assets.EnemyDatabase.TryGetDataByName(enemyName, out var enemyData)) { spawnSFX = enemyData.SpawnSFX; volumeScale = (float)enemyData.Config.SpawnSFXVolume.Value * 0.01f; } foreach (Vector3 position in positions) { SpawnFromPool(position, spawnSFX, volumeScale); } } } public void ApplyConfigSettings() { if (ConfigManager.Enemy_MuteSpawnSFX.Value) { ClearPool(); } else { CreatePool(); } } public static void OnConfigSettingsChanged() { if (!((Object)(object)Instance == (Object)null)) { Instance.ApplyConfigSettings(); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(4134231816u, new RpcReceiveHandler(__rpc_handler_4134231816), "SpawnClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_4134231816(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_009e: 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_00b3: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag, default(ForPrimitives)); string enemyName = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref enemyName, false); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flag2, default(ForPrimitives)); Vector3[] positions = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe(ref positions); } bool inFactory = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref inFactory, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((AudioPlayerManager)(object)target).SpawnClientRpc(enemyName, positions, inFactory); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "AudioPlayerManager"; } } } namespace com.github.zehsteam.MonsterHotkeys.Managers { internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry Misc_ExtendedLogging { get; private set; } public static ConfigEntry Enemy_OnlyHostSpawnEnemies { get; private set; } public static ConfigEntry Enemy_MuteSpawnSFX { get; private set; } public static ConfigEntry Enemy_SpawnStunned { get; private set; } public static ConfigEntry Enemy_StunDuration { get; private set; } public static SyncedConfigEntry Plushie_SpawnCount { get; private set; } public static SyncedConfigEntry Plushie_DespawnDuration { get; private set; } public static ConfigEntry Plushie_SFXVolume { get; private set; } public static ConfigEntry Plushie_PlaySFXOnCollision { get; private set; } public static SyncedConfigEntry Plushie_AttractDogs { get; private set; } public static SyncedConfigEntry Plushie_Scale { get; private set; } public static ConfigEntry Message_ShowMessages { get; private set; } public static ConfigEntry Message_ShowSpawnEnemyMessages { get; private set; } public static ConfigEntry Message_ShowLocalSpawnEnemyMessages { get; private set; } public static ConfigEntry Message_ShowDetailedTwitchEventSpawnEnemyMessages { get; private set; } public static ConfigEntry Message_ShowDeathMessages { get; private set; } public static ConfigEntry Message_ShowCrewmateDeathMessages { get; private set; } public static ConfigEntry Message_Duration { get; private set; } public static ConfigEntry Message_FontSize { get; private set; } public static ConfigEntry Message_BackgroundTransparency { get; private set; } public static ConfigEntry Message_ScreenAnchor { get; private set; } public static ConfigEntry Message_XOffset { get; private set; } public static ConfigEntry Message_YOffset { get; private set; } public static ConfigEntry CrowdControl_Enabled { get; private set; } public static ConfigEntry CrowdControl_RewardSpawnPoints { get; private set; } public static ConfigEntry TwitchIntegration_Enabled { get; private set; } public static ConfigEntry TwitchIntegration_SpawnAllOfTheSameEnemy { get; private set; } public static ConfigEntry TwitchSubEvent_Enabled { get; private set; } public static ConfigEntry TwitchSubEvent_EnemiesPerSub { get; private set; } public static ConfigEntry TwitchSubEvent_Tier2EnemyMultiplier { get; private set; } public static ConfigEntry TwitchSubEvent_Tier3EnemyMultiplier { get; private set; } public static ConfigEntry TwitchCheerEvent_Enabled { get; private set; } public static ConfigEntry TwitchCheerEvent_AmountToSpawnEnemy { get; private set; } public static ConfigEntry TwitchCheerEvent_AmountToSpawnPlushies { get; private set; } public static ConfigEntry TwitchRaidEvent_Enabled { get; private set; } public static ConfigEntry TwitchRaidEvent_ViewersPerEnemy { get; private set; } public static ConfigEntry TwitchRaidEvent_MaxSpawnCount { get; private set; } public static ConfigEntry SpawnPoints_Enabled { get; private set; } public static ConfigEntry SpawnPoints_PriceForEnemy { get; private set; } public static ConfigEntry SpawnPoints_PriceForPlushies { get; private set; } public static ConfigEntry SpawnPoints_MaxEnemySpawnsPerDay { get; private set; } public static ConfigEntry SpawnPoints_RewardPointsPerDeath { get; private set; } public static ConfigEntry SpawnPoints_RewardPointsPerCrewmateDeath { get; private set; } public static ConfigEntry EnemyNametag_Enabled { get; private set; } public static ConfigEntry EnemyNametag_ShowPlatform { get; private set; } public static ConfigEntry EnemyNametag_ScaleMultiplier { get; private set; } public static ConfigEntry EnemyNametag_BackgroundTransparency { get; private set; } public static ConfigEntry TwitchChatCommands_Enabled { get; private set; } public static ConfigEntry TwitchChatCommands_Prefix { get; private set; } public static ConfigEntry TwitchChatCommands_ExtraModerators { get; private set; } public static string[] TwitchChatCommands_ExtraModerators_Array => TwitchChatCommands_ExtraModerators.Value.StringToCollection().ToArray(); public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); MigrateOldConfigEntries(); } private static void BindConfigs() { ConfigHelper.SkipAutoGen(); Misc_ExtendedLogging = ConfigHelper.Bind("- Misc -", "ExtendedLogging", defaultValue: false, "Enable extended logging."); Enemy_OnlyHostSpawnEnemies = ConfigHelper.Bind("- Enemy -", "OnlyHostSpawnEnemies", defaultValue: false, "If enabled, only the host can spawn enemies."); Enemy_MuteSpawnSFX = ConfigHelper.Bind("- Enemy -", "MuteSpawnSFX", defaultValue: false, "If enabled, the enemy spawn sfx will not play."); Enemy_SpawnStunned = ConfigHelper.Bind("- Enemy -", "SpawnStunned", defaultValue: false, "If enabled, spawned enemies will be stunned for StunDuration seconds."); Enemy_StunDuration = ConfigHelper.Bind("- Enemy -", "StunDuration", 6f, "The duration enemies will be stunned for in seconds."); Enemy_MuteSpawnSFX.SettingChanged += delegate { AudioPlayerManager.OnConfigSettingsChanged(); }; Plushie_SpawnCount = ConfigHelper.BindSynced("- Plushie -", "SpawnCount", 30, "The amount of plushies to spawn.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100)); Plushie_DespawnDuration = ConfigHelper.BindSynced("- Plushie -", "DespawnDuration", 15f, "The duration in seconds until a plushie gets despawned."); Plushie_SFXVolume = ConfigHelper.Bind("- Plushie -", "SFXVolume", 25f, "The volume of the plushie's squeak sound effect.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0f, 100f)); Plushie_PlaySFXOnCollision = ConfigHelper.Bind("- Plushie -", "PlaySFXOnCollision", defaultValue: true, "If enabled, the plushies will play a sound effect when colliding with the environment."); Plushie_AttractDogs = ConfigHelper.BindSynced("- Plushie -", "AttractDogs", defaultValue: true, "If enabled, the plushies will attract dogs when making noise."); Plushie_Scale = ConfigHelper.BindSynced("- Plushie -", "Scale", 4f, "The size of the plushies."); Plushie_SFXVolume.SettingChanged += delegate { Plushie.OnConfigSettingsChanged(); }; Plushie_SpawnCount.SettingChanged += delegate { PlushieManager.OnConfigSettingsChanged(); }; Message_ShowMessages = ConfigHelper.Bind("- Message -", "ShowMessages", defaultValue: true, "If enabled, will show messages in the bottom right."); Message_ShowSpawnEnemyMessages = ConfigHelper.Bind("- Message -", "ShowSpawnEnemyMessages", defaultValue: true, "If enabled, will show a message when someone else spawns an enemy."); Message_ShowLocalSpawnEnemyMessages = ConfigHelper.Bind("- Message -", "ShowLocalSpawnEnemyMessages", defaultValue: true, "If enabled, will show a message when you spawn an enemy."); Message_ShowDetailedTwitchEventSpawnEnemyMessages = ConfigHelper.Bind("- Message -", "ShowDetailedTwitchEventSpawnEnemyMessages", defaultValue: true, "If enabled, will show a detailed Twitch event spawn enemy messages."); Message_ShowDeathMessages = ConfigHelper.Bind("- Message -", "ShowDeathMessages", defaultValue: true, "If enabled, will show death messages."); Message_ShowCrewmateDeathMessages = ConfigHelper.Bind("- Message -", "ShowCrewmateDeathMessages", defaultValue: true, "If enabled, will show death messages for crewmates."); Message_Duration = ConfigHelper.Bind("- Message -", "Duration", 10f, "The duration of a message in seconds."); Message_FontSize = ConfigHelper.Bind("- Message -", "FontSize", 25, "The font size of the messages."); Message_BackgroundTransparency = ConfigHelper.Bind("- Message -", "BackgroundTransparency", 192, "The transparency of the message background.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0, 255)); Message_ScreenAnchor = ConfigHelper.Bind("- Message -", "ScreenAnchor", ScreenAnchor.BottomRight, "The anchor for where the messages will show up on your screen."); Message_XOffset = ConfigHelper.Bind("- Message -", "XOffset", 65f, "The X position offset the messages will show up from the edge of the screen."); Message_YOffset = ConfigHelper.Bind("- Message -", "YOffset", 50f, "The Y position offset the messages will show up from the edge of the screen."); Message_ScreenAnchor.SettingChanged += delegate { MessageManger.OnConfigSettingsChanged(); }; Message_XOffset.SettingChanged += delegate { MessageManger.OnConfigSettingsChanged(); }; Message_YOffset.SettingChanged += delegate { MessageManger.OnConfigSettingsChanged(); }; Message_FontSize.SettingChanged += delegate { MessageItem.OnConfigSettingsChanged(); }; Message_BackgroundTransparency.SettingChanged += delegate { MessageItem.OnConfigSettingsChanged(); }; CrowdControl_Enabled = ConfigHelper.Bind("- Crowd Control Integration -", "Enabled", defaultValue: true, "If enabled, Crowd Control will be able to spawn enemies anywhere and spawned enemies will have a nametag with the name of the viewer that spawned that enemy."); CrowdControl_RewardSpawnPoints = ConfigHelper.Bind("- Crowd Control Integration -", "RewardSpawnPoints", defaultValue: true, "If you die to an enemy spawned by a viewer, they will gain a spawn point to spawn a free enemy by writing !spawn in your Twitch chat. (Requries Spawn Points and Twitch Integration to be enabled)"); TwitchIntegration_Enabled = ConfigHelper.Bind("- Twitch Integration -", "Enabled", defaultValue: true, "If enabled, Twitch integration will be enabled to spawn enemies from Subs, Cheers, and Raids. (Requires the TwitchChatAPI mod)"); TwitchIntegration_SpawnAllOfTheSameEnemy = ConfigHelper.Bind("- Twitch Integration -", "SpawnAllOfTheSameEnemy", defaultValue: false, "If enabled, when spawning multiple enemies from a single event, all enemies spawned will be of the same type."); TwitchSubEvent_Enabled = ConfigHelper.Bind("- Twitch Sub Event -", "Enabled", defaultValue: true, "If enabled, Twitch subs will be able to spawn enemies. (Requires Twitch Integration to be enabled)"); TwitchSubEvent_EnemiesPerSub = ConfigHelper.Bind("- Twitch Sub Event -", "EnemiesPerSub", 1, "The amount of enemies that will spawn per sub."); TwitchSubEvent_Tier2EnemyMultiplier = ConfigHelper.Bind("- Twitch Sub Event -", "Tier2EnemyMultiplier", 5, "The amount to multiply the enemy spawn count for tier 2 subs."); TwitchSubEvent_Tier3EnemyMultiplier = ConfigHelper.Bind("- Twitch Sub Event -", "Tier3EnemyMultiplier", 10, "The amount to multiply the enemy spawn count for tier 3 subs."); TwitchCheerEvent_Enabled = ConfigHelper.Bind("- Twitch Cheer Event -", "Enabled", defaultValue: true, "If enabled, Twitch cheers will be able to spawn enemies. (Requires Twitch Integration to be enabled)"); TwitchCheerEvent_AmountToSpawnEnemy = ConfigHelper.Bind("- Twitch Cheer Event -", "PriceForEnemy", 350, "The amount of bits to spawn an enemy."); TwitchCheerEvent_AmountToSpawnPlushies = ConfigHelper.Bind("- Twitch Cheer Event -", "PriceForPlushies", 100, "The amount of bits to spawn plushies that create noise and block your view."); TwitchRaidEvent_Enabled = ConfigHelper.Bind("- Twitch Raid Event -", "Enabled", defaultValue: true, "If enabled, Twitch raids will be able to spawn enemies. (Requires Twitch Integration to be enabled)"); TwitchRaidEvent_ViewersPerEnemy = ConfigHelper.Bind("- Twitch Raid Event -", "ViewersPerEnemy", 5, "The amount of viewers for each enemy spawn."); TwitchRaidEvent_MaxSpawnCount = ConfigHelper.Bind("- Twitch Raid Event -", "MaxSpawnCount", 20, "The max amount of enemies that can spawn."); SpawnPoints_Enabled = ConfigHelper.Bind("- Spawn Points -", "Enabled", defaultValue: true, "If you die to an enemy spawned by a viewer, they will gain a spawn point to spawn a free enemy by writing !spawn in your Twitch chat. (Requires Twitch Integration to be enabled)"); SpawnPoints_PriceForEnemy = ConfigHelper.Bind("- Spawn Points -", "PriceForEnemy", 1f, "The price in spawn points to spawn an enemy."); SpawnPoints_PriceForPlushies = ConfigHelper.Bind("- Spawn Points -", "PriceForPlushies", 0.25f, "The price in spawn points to spawn random plushies around the player."); SpawnPoints_MaxEnemySpawnsPerDay = ConfigHelper.Bind("- Spawn Points -", "MaxEnemySpawnsPerDay", 100, "The max amount of enemies that can be spawned from spawn points per in-game day."); SpawnPoints_RewardPointsPerDeath = ConfigHelper.Bind("- Spawn Points -", "RewardPointsPerDeath", 1f, "The amount of spawn points a viewer will receive from your death."); SpawnPoints_RewardPointsPerCrewmateDeath = ConfigHelper.Bind("- Spawn Points -", "RewardPointsPerCrewmateDeath", 0.25f, "The amount of spawn points a viewer will receive from a crewmate's death."); ConfigHelper.AddButton("- Spawn Points -", "Reset all spawn points", "Reset", "Reset all viewers spawn points.", SpawnPointManager.ResetAllSpawnPoints); EnemyNametag_Enabled = ConfigHelper.Bind("- Enemy Nametag -", "Enabled", defaultValue: true, "If enabled, enemies will spawn with a nametag of the viewer that spawned that enemy."); EnemyNametag_ShowPlatform = ConfigHelper.Bind("- Enemy Nametag -", "ShowPlatform", defaultValue: true, "If enabled, nametags will show which platform the enemy was spawned from."); EnemyNametag_ScaleMultiplier = ConfigHelper.Bind("- Enemy Nametag -", "ScaleMultiplier", 1f, "The scale multiplier for enemy nametags.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0.25f, 5f)); EnemyNametag_BackgroundTransparency = ConfigHelper.Bind("- Enemy Nametag -", "BackgroundTransparency", 192, "The transparency of the nametag background.", requiresRestart: false, (AcceptableValueBase)(object)new AcceptableValueRange(0, 255)); EnemyNametag_ScaleMultiplier.SettingChanged += delegate { EnemyNametag.OnConfigSettingsChanged(); }; EnemyNametag_ShowPlatform.SettingChanged += delegate { EnemyNametag.OnConfigSettingsChanged(); }; EnemyNametag_BackgroundTransparency.SettingChanged += delegate { EnemyNametag.OnConfigSettingsChanged(); }; TwitchChatCommands_Enabled = ConfigHelper.Bind("- Twitch Chat Commands -", "Enabled", defaultValue: true, "Enable Twitch chat commands."); TwitchChatCommands_Prefix = ConfigHelper.Bind("- Twitch Chat Commands -", "Prefix", "!", "The prefix used for the commands."); TwitchChatCommands_ExtraModerators = ConfigHelper.Bind("- Twitch Chat Commands -", "ExtraModerators", "PsychoHypnotic", "List of viewer names that will gain moderator premissions when using Twitch chat commands for this mod. Comma-separated list of Twitch usernames."); } private static void MigrateOldConfigEntries() { ConfigSectionMigration[] migrations = new ConfigSectionMigration[11] { new ConfigSectionMigration("General", "- General -"), new ConfigSectionMigration("Enemy", "- Enemy -"), new ConfigSectionMigration("Plushie", "- Plushie -"), new ConfigSectionMigration("Message", "- Message -"), new ConfigSectionMigration("Crowd Control Integration", "- Crowd Control Integration -"), new ConfigSectionMigration("Twitch Integration", "- Twitch Integration -"), new ConfigSectionMigration("Twitch Sub Event", "- Twitch Sub Event -"), new ConfigSectionMigration("Twitch Cheer Event", "- Twitch Cheer Event -"), new ConfigSectionMigration("Twitch Raid Event", "- Twitch Raid Event -"), new ConfigSectionMigration("Spawn Points", "- Spawn Points -"), new ConfigSectionMigration("Enemy Nametag", "- Enemy Nametag -") }; ConfigFile.MigrateConfigEntries(migrations); } public static void SetConfigSettingsForSpecificPlayers() { SetConfigSettingsForPlayerTakerst(); } private static void SetConfigSettingsForPlayerTakerst() { if (PlayerIdentityUtils.IsLocalPlayer(PlayerIdentityUtils.TakerstIdentity)) { string key = "SetCustomSettingsForTakerst3"; if (!Plugin.LocalSave.Load(key, defaultValue: false)) { Plugin.LocalSave.Save(key, value: true); SpawnPoints_RewardPointsPerCrewmateDeath.Value = (float)((ConfigEntryBase)SpawnPoints_RewardPointsPerCrewmateDeath).DefaultValue; } } } } } namespace com.github.zehsteam.MonsterHotkeys.Helpers { public enum AINodeType { Outside, Inside } internal static class AINodeHelper { public static bool TryGetPositionInRadius(AINodeType nodeType, Vector3 origin, float minDistance, float maxDistance, out Vector3 position) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_007f: 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) Transform[] array = GetAINodes(nodeType).ToArray(); if (array.Length == 0) { position = Vector3.zero; return false; } List list = array.Select((Transform t) => t.position).Where(delegate(Vector3 pos) { //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) float num = Vector3.Distance(origin, pos); return num >= minDistance && num <= maxDistance; }).ToList(); if (list.Count == 0) { position = Vector3.zero; return false; } position = list[Random.Range(0, list.Count)]; return true; } public static IEnumerable GetAINodes(AINodeType nodeType) { if ((Object)(object)RoundManager.Instance == (Object)null) { return Array.Empty(); } return (from x in ((IEnumerable)(nodeType switch { AINodeType.Outside => RoundManager.Instance.outsideAINodes, AINodeType.Inside => RoundManager.Instance.insideAINodes, _ => null, }))?.Where((GameObject x) => (Object)(object)x != (Object)null) select x.transform) ?? Array.Empty(); } } internal static class ButlerHelper { public static void SpawnButlerBees(Vector3 position, float yRot, int enemyNumber, EnemyType enemyType = null, object caller = null) { //IL_000d: 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_009b: Unknown result type (might be due to invalid IL or missing references) Logger.LogInfo("\n\nSpawnButlerBees called!\n", extended: true); EnemyAI val = EnemyHelper.SpawnEnemyAtPosition_Server(enemyType, null, position, yRot); if ((Object)(object)val == (Object)null) { return; } object classInstanceFromCaller = ReflectionHelper.GetClassInstanceFromCaller(caller); if (classInstanceFromCaller != null) { Logger.LogInfo("\n\nCaller: " + classInstanceFromCaller.GetType().FullName + "\n", extended: true); EnemyAI val2 = (EnemyAI)((classInstanceFromCaller is EnemyAI) ? classInstanceFromCaller : null); NetworkObject val3 = default(NetworkObject); if (val2 != null && EnemyNametagManager.Instance.EnemyNametagPairs.TryGetValue(val2, out var value) && ((Component)val).TryGetComponent(ref val3)) { EnemyNametagManager.Instance?.SpawnNametags_ServerRpc(value.SpawnEnemyData, (NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(val3) }); } } } } public static class ColorHelper { private const float MinContrastRatio = 4.5f; public static Color GetReadableColor(string colorHex, string backgroundColorHex = "#000000") { //IL_001f: 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_004b: 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) //IL_0055: 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_0053: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_009e: 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_00a6: 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) if (!TryParseHex(colorHex, out var color)) { Debug.LogWarning((object)("[ColorHelper] Could not parse colorHex '" + colorHex + "'. Returning white.")); return Color.white; } if (!TryParseHex(backgroundColorHex, out var color2)) { Debug.LogWarning((object)("[ColorHelper] Could not parse backgroundColorHex '" + backgroundColorHex + "'. Using black.")); color2 = Color.black; } if (MeetsContrastRatio(color, color2)) { return color; } float relativeLuminance = GetRelativeLuminance(color2); bool flag = relativeLuminance < 0.5f; RGBToHSL(color, out var h, out var s, out var l); for (int i = 0; i < 100; i++) { l = Mathf.Clamp01(l + (flag ? 0.01f : (-0.01f))); Color val = HSLToRGB(h, s, l); if (MeetsContrastRatio(val, color2)) { return val; } if (l <= 0f || l >= 1f) { break; } } Color result = (flag ? Color.white : Color.black); Debug.LogWarning((object)("[ColorHelper] Could not find a readable shade for '" + colorHex + "' on '" + backgroundColorHex + "'. Returning " + (flag ? "white" : "black") + ".")); return result; } public static string GetReadableColorHex(string colorHex, string backgroundColorHex = "#000000") { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ColorToHex(GetReadableColor(colorHex, backgroundColorHex)); } public static string ColorToHex(Color color) { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) Color32 val = Color32.op_Implicit(color); return $"#{val.r:X2}{val.g:X2}{val.b:X2}"; } private static bool MeetsContrastRatio(Color foreground, Color background) { //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) return GetContrastRatio(foreground, background) >= 4.5f; } public static float GetContrastRatio(Color a, Color b) { //IL_0000: 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) float relativeLuminance = GetRelativeLuminance(a); float relativeLuminance2 = GetRelativeLuminance(b); float num = Mathf.Max(relativeLuminance, relativeLuminance2); float num2 = Mathf.Min(relativeLuminance, relativeLuminance2); return (num + 0.05f) / (num2 + 0.05f); } public static float GetRelativeLuminance(Color c) { //IL_0000: 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_0018: Unknown result type (might be due to invalid IL or missing references) float num = SRGBToLinear(c.r); float num2 = SRGBToLinear(c.g); float num3 = SRGBToLinear(c.b); return 0.2126f * num + 0.7152f * num2 + 0.0722f * num3; } private static float SRGBToLinear(float channel) { if (!(channel <= 0.03928f)) { return Mathf.Pow((channel + 0.055f) / 1.055f, 2.4f); } return channel / 12.92f; } public static void RGBToHSL(Color color, out float h, out float s, out float l) { //IL_0000: 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_000e: Unknown result type (might be due to invalid IL or missing references) float r = color.r; float g = color.g; float b = color.b; float num = Mathf.Max(r, Mathf.Max(g, b)); float num2 = Mathf.Min(r, Mathf.Min(g, b)); float num3 = num - num2; l = (num + num2) * 0.5f; if (num3 < 1E-06f) { h = 0f; s = 0f; return; } s = ((l > 0.5f) ? (num3 / (2f - num - num2)) : (num3 / (num + num2))); if (Mathf.Approximately(num, r)) { h = ((g - b) / num3 + ((g < b) ? 6f : 0f)) / 6f; } else if (Mathf.Approximately(num, g)) { h = ((b - r) / num3 + 2f) / 6f; } else { h = ((r - g) / num3 + 4f) / 6f; } } public static Color HSLToRGB(float h, float s, float l) { //IL_000b: 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) if (s < 1E-06f) { return new Color(l, l, l); } float num = ((l < 0.5f) ? (l * (1f + s)) : (l + s - l * s)); float p = 2f * l - num; return new Color(HueToRGB(p, num, h + 1f / 3f), HueToRGB(p, num, h), HueToRGB(p, num, h - 1f / 3f)); } private static float HueToRGB(float p, float q, float t) { if (t < 0f) { t += 1f; } if (t > 1f) { t -= 1f; } if (t < 1f / 6f) { return p + (q - p) * 6f * t; } if (t < 0.5f) { return q; } if (t < 2f / 3f) { return p + (q - p) * (2f / 3f - t) * 6f; } return p; } public static bool TryParseHex(string hex, out Color color) { //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_00f0: 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_00fa: Unknown result type (might be due to invalid IL or missing references) color = Color.white; if (string.IsNullOrWhiteSpace(hex)) { return false; } string text = hex.TrimStart('#'); if (text.Length == 3) { text = $"{text[0]}{text[0]}{text[1]}{text[1]}{text[2]}{text[2]}"; } if (text.Length != 6 && text.Length != 8) { return false; } if (!TryParseByte(text, 0, out var value)) { return false; } if (!TryParseByte(text, 2, out var value2)) { return false; } if (!TryParseByte(text, 4, out var value3)) { return false; } byte value4 = byte.MaxValue; if (text.Length == 8 && !TryParseByte(text, 6, out value4)) { return false; } color = Color32.op_Implicit(new Color32(value, value2, value3, value4)); return true; } private static bool TryParseByte(string hex, int offset, out byte value) { value = 0; try { value = Convert.ToByte(hex.Substring(offset, 2), 16); return true; } catch { return false; } } } internal static class ConfigHelper { private static readonly List _allConfigEntries = new List(); public static IReadOnlyList AllConfigEntries => _allConfigEntries; public static void SkipAutoGen() { if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.SkipAutoGen(); } } public static void AddButton(string section, string name, string buttonText, string description, Action callback) { if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.AddButton(section, name, buttonText, description, callback); } } public static ConfigEntry Bind(string section, string key, T defaultValue, string description, bool requiresRestart = false, AcceptableValueBase acceptableValues = null, Action settingChanged = null, ConfigFile configFile = null) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (configFile == null) { configFile = ((BaseUnityPlugin)Plugin.Instance).Config; } ConfigEntry configEntry = ((acceptableValues == null) ? configFile.Bind(section, key, defaultValue, description) : configFile.Bind(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty()))); if (settingChanged != null) { configEntry.SettingChanged += delegate { settingChanged?.Invoke(configEntry.Value); }; } if (LethalConfigProxy.IsInstalled) { LethalConfigProxy.AddConfig(configEntry, requiresRestart); } _allConfigEntries.Add((ConfigEntryBase)(object)configEntry); return configEntry; } public static SyncedConfigEntry BindSynced(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, Action settingChanged = null, ConfigFile configFile = null) { SyncedConfigEntry syncedConfigEntry = new SyncedConfigEntry(section, key, defaultValue, description, acceptableValues, configFile); if (settingChanged != null) { syncedConfigEntry.SettingChanged += settingChanged; } return syncedConfigEntry; } public static ConfigEntryBase[] GetConfigsBySection(string section) { return AllConfigEntries.Where((ConfigEntryBase x) => x.Definition.Section.Equals_OrdinalIgnoreCase(section)).ToArray(); } public static ConfigEntryBase GetConfigBySectionAndKey(string section, string key) { ConfigEntryBase[] configsBySection = GetConfigsBySection(section); return ((IEnumerable)configsBySection).FirstOrDefault((Func)((ConfigEntryBase x) => x.Definition.Key.Equals_OrdinalIgnoreCase(key))); } } public static class DependencyHelper { public static bool HasMod(string pluginGuid) { return Chainloader.PluginInfos.ContainsKey(pluginGuid); } public static IEnumerable GetModAssemblies() { List list = new List(); foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value == null || (Object)(object)value.Instance == (Object)null) { continue; } try { Assembly assembly = ((object)value.Instance).GetType().Assembly; if (!(assembly == null)) { list.Add(assembly); } } catch (Exception arg) { Logger.LogError($"Failed to get loaded assembly: {arg}"); } } return list; } } public enum EnemySpawnPositionType { Random, InFrontOfPlayer } public enum EnemySpawnType { All, Inside, Outside, Daytime } public static class EnemyHelper { public static void SpawnRandomEnemy(string phrase = "") { if (CanSpawnEnemiesOnLocalPlayer() && Assets.EnemyDatabase.TryGetRandomSpawnableEnemyForPlayer(PlayerUtils.LocalPlayerScript, SpawnSource.Default, out var enemyData)) { SpawnEnemy(enemyData, phrase); } } public static void SpawnEnemy(EnemyData enemyData, string phrase = "") { //IL_0087: 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) if (!CanSpawnEnemiesOnLocalPlayer()) { return; } if (enemyData == null) { Logger.LogError("Failed to spawn enemy. EnemyData is null."); return; } string spawnReason = string.Empty; if (!string.IsNullOrWhiteSpace(phrase)) { spawnReason = "by saying \"" + phrase + "\""; } string playerUsername = PlayerUtils.LocalPlayerScript.playerUsername; NonViewerData nonViewer = new NonViewerData(playerUsername, phrase); SpawnEnemyData spawnEnemyData = new SpawnEnemyData(nonViewer, SpawnSource.Default, 1, spawnReason); if (NetworkUtils.IsServer) { SpawnEnemiesFromData_Server(spawnEnemyData); } else { SpawnEventHandler.Instance?.ExecuteSpawnEnemyData_ServerRpc(spawnEnemyData); } } public static void SpawnEnemiesFromData_Server(SpawnEnemyData spawnEnemyData) { //IL_0119: 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_013f: Unknown result type (might be due to invalid IL or missing references) if (!NetworkUtils.IsServer) { return; } PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(spawnEnemyData.SpawnedOnClientId); if ((Object)(object)playerScriptByClientId == (Object)null) { Logger.LogError("Failed to spawn enemies from SpawnEnemyData. PlayerControllerB is null."); return; } if (!CanSpawnEnemiesOnPlayer(playerScriptByClientId)) { Logger.LogError("Failed to spawn enemies from SpawnEnemyData. You can not spawn enemies on " + playerScriptByClientId.playerUsername + " right now."); return; } Logger.LogInfo(string.Format("Trying to spawn {0} enemies from {1} on player \"{2}\"", spawnEnemyData.SpawnCount, "SpawnEnemyData", playerScriptByClientId.playerUsername)); List enemyDataList = GetEnemyDataListForSpawnData(spawnEnemyData, spawnEnemyData.SpawnSource); if (enemyDataList.Count == 0) { Logger.LogError("Failed to spawn enemies from SpawnEnemyData. No EnemyData found."); return; } bool value = ConfigManager.Enemy_SpawnStunned.Value; float value2 = ConfigManager.Enemy_StunDuration.Value; List list = new List(); List list2 = new List(); NetworkObject val2 = default(NetworkObject); foreach (EnemyData item in enemyDataList) { int value3 = item.Config.SpawnCount.Value; for (int i = 0; i < value3; i++) { if (!TryGetSpawnPosition(playerScriptByClientId, item, out var position)) { Logger.LogError("Failed to spawn enemy from SpawnEnemyData. Could not find a valid spawn position."); continue; } EnemyAI val = SpawnEnemyAtPosition_Server(item.EnemyType, playerScriptByClientId, position, value, value2); if (((Component)val).TryGetComponent(ref val2)) { list.Add(NetworkObjectReference.op_Implicit(val2)); list2.Add(position); } } } spawnEnemyData.SpawnedCount = list.Count; string text = string.Empty; if (enemyDataList.All((EnemyData x) => x.Name == enemyDataList[0].Name)) { text = enemyDataList[0].DisplayName; } SpawnEventHandler.Instance?.ShowSpawnEnemyDataMessage_ClientRpc(spawnEnemyData, text); if (!ConfigManager.Enemy_MuteSpawnSFX.Value) { AudioPlayerManager.Instance.Spawn_Server(text, list2.ToArray(), playerScriptByClientId.isInsideFactory); } EnemyNametagManager.Instance.SpawnNametags_ServerRpc(spawnEnemyData, list.ToArray()); } public static List GetEnemyDataListForSpawnData(SpawnEnemyData spawnEnemyData, SpawnSource spawnSource) { PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(spawnEnemyData.SpawnedOnClientId); if ((Object)(object)playerScriptByClientId == (Object)null) { return new List(); } int spawnCount = spawnEnemyData.SpawnCount; if (!string.IsNullOrWhiteSpace(spawnEnemyData.TargetEnemyName) && Assets.EnemyDatabase.TryGetDataByName(spawnEnemyData.TargetEnemyName, out var enemyData) && enemyData.CanSpawnOnPlayer(playerScriptByClientId, spawnSource)) { return Enumerable.Repeat(enemyData, spawnCount).ToList(); } if (ConfigManager.TwitchIntegration_SpawnAllOfTheSameEnemy.Value && Assets.EnemyDatabase.TryGetRandomSpawnableEnemyForPlayer(playerScriptByClientId, spawnSource, out var enemyData2)) { return Enumerable.Repeat(enemyData2, spawnCount).ToList(); } EnemyData[] array = Assets.EnemyDatabase.GetSpawnableEnemiesForPlayer(playerScriptByClientId, spawnSource).ToArray(); if (array.Length == 0) { return new List(); } List list = new List(); for (int i = 0; i < spawnCount; i++) { list.Add(array[Random.Range(0, array.Length)]); } return list; } public static EnemyAI SpawnEnemyAtPosition_Server(EnemyType enemyType, PlayerControllerB targetPlayerScript, Vector3 position, bool spawnStunned = false, float stunDuration = 0f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return SpawnEnemyAtPosition_Server(enemyType, targetPlayerScript, position, Random.Range(0f, 360f), spawnStunned, stunDuration); } public static EnemyAI SpawnEnemyAtPosition_Server(EnemyType enemyType, PlayerControllerB targetPlayerScript, Vector3 position, float yRot, bool spawnStunned = false, float stunDuration = 0f) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!NetworkUtils.IsServer) { return null; } if (enemyType.enemyName.Equals_OrdinalIgnoreCase("RadMech")) { EnemyAI_Patches.SkipNextEnemyNestCheck(); } if (enemyType.enemyName.Equals_OrdinalIgnoreCase("Bush Wolf")) { MoldHelper.GenerateMold_Server(position); } enemyType.enemyName.Equals_OrdinalIgnoreCase("Feiopar"); GameObject val = Object.Instantiate(enemyType.enemyPrefab, position, Quaternion.Euler(new Vector3(0f, yRot, 0f))); val.GetComponent().Spawn(true); EnemyAI component = val.GetComponent(); RoundManager.Instance.SpawnedEnemies.Add(component); MaskedPlayerEnemy val2 = (MaskedPlayerEnemy)(object)((component is MaskedPlayerEnemy) ? component : null); if (val2 != null) { MaskedEnemyHelper.SetMaskedEnemyProperties_Server(val2, targetPlayerScript); } if (spawnStunned) { component.stunNormalizedTimer = stunDuration; } return component; } public static bool CanSpawnEnemiesOnPlayer(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null || playerScript.isPlayerDead) { return false; } if ((Object)(object)StartOfRound.Instance == (Object)null) { return false; } if (StartOfRound.Instance.inShipPhase || StartOfRound.Instance.shipIsLeaving) { return false; } if (!StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap) { return false; } return true; } public static bool CanSpawnEnemiesOnLocalPlayer() { return CanSpawnEnemiesOnPlayer(PlayerUtils.LocalPlayerScript); } public static bool TryGetSpawnPosition(PlayerControllerB playerScript, EnemyData enemyData, out Vector3 position) { EnemySpawnPositionType value = enemyData.Config.SpawnPosition.Value; float value2 = enemyData.Config.MinDistance.Value; float value3 = enemyData.Config.MaxDistance.Value; return TryGetSpawnPosition(playerScript, value, value2, value3, out position); } public static bool TryGetSpawnPosition(PlayerControllerB playerScript, EnemySpawnPositionType positionType, float minDistance, float maxDistance, out Vector3 position) { //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_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_0026: 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_0044: 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)playerScript == (Object)null) { position = Vector3.zero; return false; } Vector3 position2 = ((Component)playerScript).transform.position; switch (positionType) { case EnemySpawnPositionType.Random: if (NavMeshHelper.TryGetPositionInRadius(position2, minDistance, maxDistance, out position)) { return true; } break; case EnemySpawnPositionType.InFrontOfPlayer: { Vector3 forward = ((Component)playerScript).transform.forward; if (NavMeshHelper.TryGetPositionInDirection(position2, forward, minDistance, maxDistance, out position)) { return true; } break; } } return TryGetSpawnPosition(playerScript, out position); } public static bool TryGetSpawnPosition(PlayerControllerB playerScript, out Vector3 position) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_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)playerScript == (Object)null) { position = Vector3.zero; return false; } Vector3 position2 = ((Component)playerScript).transform.position; AINodeType nodeType = AINodeType.Outside; float maxDistance = 150f; if (playerScript.isInsideFactory) { nodeType = AINodeType.Inside; maxDistance = 100f; } if (AINodeHelper.TryGetPositionInRadius(nodeType, position2, 5f, maxDistance, out position)) { return true; } if (AINodeHelper.TryGetPositionInRadius(nodeType, position2, 5f, float.MaxValue, out position)) { return true; } position = Vector3.zero; return false; } public static EnemyType GetEnemyType(string enemyName) { return GetEnemyTypes().FirstOrDefault((Func)((EnemyType x) => x.enemyName.Equals_OrdinalIgnoreCase(enemyName))); } public static IEnumerable GetEnemyTypes(EnemySpawnType spawnType = EnemySpawnType.All) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return Array.Empty(); } HashSet hashSet = new HashSet(new EnemyTypeComparer()); SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { List list = new List(); if (spawnType == EnemySpawnType.Inside || spawnType == EnemySpawnType.All) { list.AddRange(val.Enemies); } if (spawnType == EnemySpawnType.Outside || spawnType == EnemySpawnType.All) { list.AddRange(val.OutsideEnemies); if ((Object)(object)RoundManager.Instance != (Object)null) { list.AddRange(RoundManager.Instance.WeedEnemies); } } if (spawnType == EnemySpawnType.Daytime || spawnType == EnemySpawnType.All) { list.AddRange(val.DaytimeEnemies); } IEnumerable enumerable = from enemyWithRarity in list select enemyWithRarity.enemyType into enemyType where enemyType.IsValid() select enemyType; foreach (EnemyType item in enumerable) { hashSet.Add(item); } } return hashSet; } } public class EnemyTypeComparer : IEqualityComparer { public bool Equals(EnemyType x, EnemyType y) { if ((Object)(object)x == (Object)null || (Object)(object)y == (Object)null) { return false; } return x.enemyName == y.enemyName; } public int GetHashCode(EnemyType obj) { return obj.enemyName?.GetHashCode() ?? 0; } } internal static class ILHelper { private static DefaultAssemblyResolver _cachedResolver; private static Dictionary _cachedModules = new Dictionary(); private static DefaultAssemblyResolver GetCachedResolver() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (_cachedResolver != null) { return _cachedResolver; } DefaultAssemblyResolver val = new DefaultAssemblyResolver(); ((BaseAssemblyResolver)val).AddSearchDirectory(Paths.ManagedPath); ((BaseAssemblyResolver)val).AddSearchDirectory(Paths.BepInExAssemblyDirectory); ((BaseAssemblyResolver)val).AddSearchDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string[] directories = Directory.GetDirectories(Paths.PluginPath, "*", SearchOption.AllDirectories); foreach (string text in directories) { ((BaseAssemblyResolver)val).AddSearchDirectory(text); } _cachedResolver = val; return _cachedResolver; } public static IEnumerable GetInstructions(MethodInfo method) { if (method == null) { return Array.Empty(); } try { ModuleDefinition moduleDefinition = GetModuleDefinition(method.DeclaringType.Assembly); if (moduleDefinition == null) { return Array.Empty(); } TypeDefinition type = moduleDefinition.GetType(method.DeclaringType.FullName); MethodDefinition val = ((type != null) ? ((IEnumerable)type.Methods).FirstOrDefault((Func)((MethodDefinition m) => ((MemberReference)m).Name == method.Name)) : null); if (val == null || val.Body == null) { Logger.LogWarning("Failed to get IL for method: " + method.Name, extended: true); return Array.Empty(); } return (IEnumerable)val.Body.Instructions; } catch (Exception arg) { Logger.LogWarning($"Exception while processing method {method.Name}: {arg}", extended: true); return Array.Empty(); } } public static IEnumerable GetCoroutineInstructions(MethodInfo method) { if (method == null) { return Array.Empty(); } try { ModuleDefinition moduleDefinition = GetModuleDefinition(method.DeclaringType.Assembly); if (moduleDefinition == null) { return Array.Empty(); } TypeDefinition type = moduleDefinition.GetType(method.DeclaringType.FullName); TypeDefinition val = ((IEnumerable)type.NestedTypes).FirstOrDefault((Func)((TypeDefinition t) => ((MemberReference)t).Name.Contains("<" + method.Name + ">"))); if (val == null) { Logger.LogWarning("State machine type for " + method.Name + " not found.", extended: true); return Array.Empty(); } MethodDefinition val2 = ((IEnumerable)val.Methods).FirstOrDefault((Func)((MethodDefinition m) => ((MemberReference)m).Name == "MoveNext")); if (val2 == null) { Logger.LogWarning("MoveNext method not found in state machine: " + ((MemberReference)val).Name, extended: true); return Array.Empty(); } return (IEnumerable)val2.Body.Instructions; } catch (Exception arg) { Logger.LogWarning($"Exception while processing coroutine method {method.Name}: {arg}", extended: true); return Array.Empty(); } } public static ModuleDefinition GetModuleDefinition(Assembly assembly) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //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) //IL_0055: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Expected O, but got Unknown if (assembly == null) { return null; } try { if (TryGetCachedModuleDefinition(assembly, out var module)) { return module; } DefaultAssemblyResolver cachedResolver = GetCachedResolver(); if (!string.IsNullOrEmpty(assembly.Location) && File.Exists(assembly.Location)) { ModuleDefinition val = ModuleDefinition.ReadModule(assembly.Location, new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)cachedResolver }); CacheModuleDefinition(assembly, val); return val; } string text = assembly.GetName().Name + ".dll"; string text2 = Path.Combine(Paths.ManagedPath, text); if (File.Exists(text2)) { Logger.LogInfo("Attempting to load " + text + " from Managed path: " + text2, extended: true); ModuleDefinition val2 = ModuleDefinition.ReadModule(text2, new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)cachedResolver }); CacheModuleDefinition(assembly, val2); return val2; } Logger.LogWarning("Assembly location for " + assembly.FullName + " is null or invalid. Attempting to load from memory.", extended: true); if (assembly.IsDynamic) { Logger.LogWarning("Cannot process dynamic assembly: " + assembly.FullName, extended: true); return null; } byte[] buffer = File.ReadAllBytes(assembly.ManifestModule.FullyQualifiedName); using MemoryStream memoryStream = new MemoryStream(buffer); ModuleDefinition val3 = ModuleDefinition.ReadModule((Stream)memoryStream, new ReaderParameters { AssemblyResolver = (IAssemblyResolver)(object)cachedResolver }); CacheModuleDefinition(assembly, val3); return val3; } catch (Exception arg) { Logger.LogWarning($"Failed to get ModuleDefinition for assembly {assembly.FullName}. {arg}", extended: true); return null; } } private static ModuleDefinition GetCachedModuleDefinition(Assembly assembly) { if (assembly == null) { return null; } if (_cachedModules.TryGetValue(assembly.FullName, out var value)) { return value; } return null; } private static bool TryGetCachedModuleDefinition(Assembly assembly, out ModuleDefinition module) { module = GetCachedModuleDefinition(assembly); return module != null; } private static void CacheModuleDefinition(Assembly assembly, ModuleDefinition module) { if (!(assembly == null) && module != null && assembly.FullName.StartsWith("Assembly-CSharp")) { _cachedModules[assembly.FullName] = module; } } public static bool MethodCallsMethod(MethodInfo method, MethodInfo targetMethod) { return InstructionsCallsMethod(GetInstructions(method), targetMethod); } public static bool MethodCallsEitherMethods(MethodInfo method, MethodInfo[] targetMethods) { if (ReflectionHelper.IsCoroutineMethod(method)) { return InstructionsCallsEitherMethods(GetCoroutineInstructions(method), targetMethods); } return InstructionsCallsEitherMethods(GetInstructions(method), targetMethods); } public static bool InstructionsCallsMethod(IEnumerable instructions, MethodInfo targetMethod) { return InstructionsCallsEitherMethods(instructions, new MethodInfo[1] { targetMethod }); } public static bool InstructionsCallsEitherMethods(IEnumerable instructions, MethodInfo[] targetMethods) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 if (instructions == null || targetMethods == null || targetMethods.Length == 0) { return false; } foreach (Instruction instruction in instructions) { OpCode opCode = instruction.OpCode; if ((int)((OpCode)(ref opCode)).Code != 39) { opCode = instruction.OpCode; if ((int)((OpCode)(ref opCode)).Code != 110) { continue; } } object operand = instruction.Operand; MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null); if (val == null) { continue; } try { MethodDefinition val2 = val.Resolve(); if (val2 == null) { continue; } foreach (MethodInfo methodInfo in targetMethods) { if (!(methodInfo == null) && ((MemberReference)val2).Name == methodInfo.Name && ((MemberReference)val2.DeclaringType).FullName == methodInfo.DeclaringType.FullName) { return true; } } } catch (Exception arg) { Logger.LogWarning($"Error while processing IL instructions. {arg}", extended: true); } } return false; } } internal static class LandmineHelper { public static object SpawnExplosionCaller { get; private set; } public static void SpawnExplosionWithCaller(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null, bool goThroughCar = false, object caller = null) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) Logger.LogInfo("\n\nSpawnExplosion called!\n", extended: true); object obj = null; if (caller != null) { obj = ReflectionHelper.GetClassInstanceFromCaller(caller); Logger.LogInfo("\n\nCaller: " + obj.GetType().FullName + "\n", extended: true); } SpawnExplosionCaller = obj; Landmine.SpawnExplosion(explosionPosition, spawnExplosionEffect, killRange, damageRange, nonLethalDamage, physicsForce, overridePrefab, goThroughCar); SpawnExplosionCaller = null; } } internal static class MaskedEnemyHelper { [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public NetworkObjectReference networkObjectReference; public NetworkObject networkObject; public float startTime; public float timeoutDuration; internal bool b__0() { if (!((NetworkObjectReference)(ref networkObjectReference)).TryGet(ref networkObject, (NetworkManager)null)) { return Time.realtimeSinceStartup - startTime > timeoutDuration; } return true; } } [CompilerGenerated] private sealed class d__2 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public NetworkObjectReference networkObjectReference; private <>c__DisplayClass2_0 <>8__1; public ulong targetClientId; public int maskTypeId; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass2_0(); <>8__1.networkObjectReference = networkObjectReference; <>8__1.networkObject = null; <>8__1.startTime = Time.realtimeSinceStartup; <>8__1.timeoutDuration = 20f; <>2__current = (object)new WaitUntil((Func)(() => ((NetworkObjectReference)(ref <>8__1.networkObjectReference)).TryGet(ref <>8__1.networkObject, (NetworkManager)null) || Time.realtimeSinceStartup - <>8__1.startTime > <>8__1.timeoutDuration)); <>1__state = 1; return true; case 1: { <>1__state = -1; if ((Object)(object)<>8__1.networkObject == (Object)null) { Logger.LogError(string.Format("[{0}] Failed to set masked enemy properties. NetworkObject is null. (networkObjectReference: {1}, targetPlayerId: {2}, maskTypeId: {3})", "MaskedEnemyHelper", ((NetworkObjectReference)(ref <>8__1.networkObjectReference)).NetworkObjectId, targetClientId, maskTypeId)); return false; } MaskedPlayerEnemy component = ((Component)<>8__1.networkObject).GetComponent(); PlayerControllerB playerScriptByClientId = PlayerUtils.GetPlayerScriptByClientId(targetClientId); SetMaskedEnemyProperties_Local(component, playerScriptByClientId, maskTypeId); 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 SetMaskedEnemyProperties_Server(MaskedPlayerEnemy maskedPlayerEnemy, PlayerControllerB targetPlayerScript) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) int maskTypeId = (Utils.RollPercentChance(50f) ? 4 : 5); PluginNetworkHandler.Instance?.SetMaskedEnemyProperties_ClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)maskedPlayerEnemy).NetworkObject), targetPlayerScript.actualClientId, maskTypeId); SetMaskedEnemyProperties_Local(maskedPlayerEnemy, targetPlayerScript, maskTypeId); } public static void SetMaskedEnemyProperties_Client(NetworkObjectReference networkObjectReference, ulong targetClientId, int maskTypeId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) CoroutineRunner.Start(SetMaskedEnemyProperties_Client_Coroutine(networkObjectReference, targetClientId, maskTypeId)); } [IteratorStateMachine(typeof(d__2))] private static IEnumerator SetMaskedEnemyProperties_Client_Coroutine(NetworkObjectReference networkObjectReference, ulong targetClientId, int maskTypeId) { //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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { networkObjectReference = networkObjectReference, targetClientId = targetClientId, maskTypeId = maskTypeId }; } private static void SetMaskedEnemyProperties_Local(MaskedPlayerEnemy maskedPlayerEnemy, PlayerControllerB targetPlayerScript, int maskTypeId) { if (!((Object)(object)maskedPlayerEnemy == (Object)null) && !((Object)(object)targetPlayerScript == (Object)null)) { maskedPlayerEnemy.mimickingPlayer = targetPlayerScript; maskedPlayerEnemy.SetSuit(targetPlayerScript.currentSuitID); ((EnemyAI)maskedPlayerEnemy).SetEnemyOutside(!targetPlayerScript.isInsideFactory); maskedPlayerEnemy.SetVisibilityOfMaskedEnemy(); maskedPlayerEnemy.SetMaskType(maskTypeId); } } } internal static class MoldHelper { private static float _timeSpawnedMold; public static MoldSpreadManager MoldSpreadManager => Singleton.Instance; public static bool BlockNaturalWeedEnemySpawns { get; private set; } public static void Reset() { BlockNaturalWeedEnemySpawns = false; } public static void GenerateMold_Server(Vector3 position, int iterations = 20) { //IL_0020: 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) float num = Time.realtimeSinceStartup - _timeSpawnedMold; if (!(num < 5f)) { PluginNetworkHandler.Instance?.GenerateMold_ClientRpc(position, iterations); GenerateMold_Local(position, iterations); } } public static void GenerateMold_Local(Vector3 position, int iterations) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) BlockNaturalWeedEnemySpawns = true; _timeSpawnedMold = Time.realtimeSinceStartup; MoldSpreadManager.finishedGeneratingMold = false; MoldSpreadManager.GenerateMold(position, iterations); } } internal static class NavMeshHelper { private static int _attempts = 25; public static bool TryGetPositionInRadius(Vector3 origin, float minDistance, float maxDistance, out Vector3 position) { //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_000d: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0034: 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_0046: 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_0077: 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) Vector3 val2 = default(Vector3); NavMeshHit val3 = default(NavMeshHit); for (int i = 0; i < _attempts; i++) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(minDistance, maxDistance); ((Vector3)(ref val2))..ctor(origin.x + val.x, origin.y, origin.z + val.y); if (NavMesh.SamplePosition(val2, ref val3, 2f, -1)) { position = ((NavMeshHit)(ref val3)).position; return true; } } position = Vector3.zero; return false; } public static bool TryGetPositionInDirection(Vector3 origin, Vector3 direction, float minDistance, float maxDistance, out Vector3 position) { //IL_000c: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < _attempts; i++) { float num = Random.Range(minDistance, maxDistance); Vector3 val = origin + ((Vector3)(ref direction)).normalized * num; if (NavMesh.SamplePosition(val, ref val2, 2f, -1)) { position = ((NavMeshHit)(ref val2)).position; return true; } } position = Vector3.zero; return false; } } internal static class NetworkUtils { private static readonly FieldInfo _rpcExecStageField = AccessTools.Field(typeof(NetworkBehaviour), "__rpc_exec_stage"); public static bool IsConnected { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsConnectedClient; } } public static bool IsServer { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return false; } return singleton.IsServer; } } public static ulong LocalClientId { get { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null) { return 0uL; } return singleton.LocalClientId; } } public static int ConnectedPlayerCount => GameNetworkManager.Instance?.connectedPlayers ?? 0; public static bool IsLocalClientId(ulong clientId) { return clientId == LocalClientId; } public static bool HasClient(ulong clientId) { if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } return NetworkManager.Singleton.ConnectedClients.ContainsKey(clientId); } public static bool IsNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return false; } if ((Object)(object)NetworkManager.Singleton == (Object)null) { return false; } IReadOnlyList prefabs = NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs; return prefabs.Any((NetworkPrefab x) => (Object)(object)x.Prefab == (Object)(object)prefab); } public static bool AddNetworkPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { Logger.LogError("Failed to register network prefab. GameObject is null."); return false; } if ((Object)(object)NetworkManager.Singleton == (Object)null) { Logger.LogError("Failed to register network prefab. NetworkManager Singleton is null."); return false; } NetworkManager.Singleton.AddNetworkPrefab(prefab); Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab."); return true; } public static void NetcodePatcherAwake() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); IEnumerable loadableTypes = executingAssembly.GetLoadableTypes(); foreach (Type item in loadableTypes) { MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (TargetInvocationException ex) { Logger.LogWarning("[NetworkUtils] Failed to invoke method " + methodInfo.Name + ": " + ex.Message); } } } catch (Exception ex2) { Logger.LogWarning("[NetworkUtils] Error processing method " + methodInfo.Name + " in type " + item.Name + ": " + ex2.Message); } } } } catch (Exception ex3) { Logger.LogError("[NetworkUtils] Failed to run NetcodePatcherAwake: " + ex3.Message); } } public static bool IsExecutingRPCMethod(NetworkBehaviour networkBehaviour) { if ((Object)(object)networkBehaviour == (Object)null) { return false; } NetworkManager networkManager = networkBehaviour.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (_rpcExecStageField == null) { Logger.LogError("[NetworkUtils] IsExecutingRPCMethod: Failed to find \"__rpc_exec_stage\" field."); return false; } object value = _rpcExecStageField.GetValue(networkBehaviour); int num = (int)value; if (num != 0) { return num == 1; } return true; } } internal static class PlayerHelper { private static bool _wasLocalPlayerDead; public static void DamagePlayerWithCaller(PlayerControllerB playerScript, int damageNumber, bool hasDamageSFX = true, bool callRPC = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0, bool fallDamage = false, Vector3 force = default(Vector3), object caller = null) { //IL_0021: 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 ((Object)(object)playerScript == (Object)null || !PlayerUtils.IsLocalPlayer(playerScript)) { return; } _wasLocalPlayerDead = playerScript.isPlayerDead; playerScript.DamagePlayer(damageNumber, hasDamageSFX, callRPC, causeOfDeath, deathAnimation, fallDamage, force); if (caller != null) { object classInstanceFromCaller = ReflectionHelper.GetClassInstanceFromCaller(caller); LogPlayerDamage("DamagePlayer", playerScript, classInstanceFromCaller); if (!_wasLocalPlayerDead && playerScript.isPlayerDead) { OnLocalPlayerDied(playerScript, classInstanceFromCaller); } } } public static void KillPlayerWithCaller(PlayerControllerB playerScript, Vector3 bodyVelocity, bool spawnBody = true, CauseOfDeath causeOfDeath = 0, int deathAnimation = 0, Vector3 positionOffset = default(Vector3), bool setOverrideDropItems = false, object caller = null) { //IL_001e: 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_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)playerScript == (Object)null || !PlayerUtils.IsLocalPlayer(playerScript)) { return; } _wasLocalPlayerDead = playerScript.isPlayerDead; playerScript.KillPlayer(bodyVelocity, spawnBody, causeOfDeath, deathAnimation, positionOffset, setOverrideDropItems); if (caller != null) { object classInstanceFromCaller = ReflectionHelper.GetClassInstanceFromCaller(caller); LogPlayerDamage("KillPlayer", playerScript, classInstanceFromCaller); if (!_wasLocalPlayerDead && playerScript.isPlayerDead) { OnLocalPlayerDied(playerScript, classInstanceFromCaller); } } } private static void OnLocalPlayerDied(PlayerControllerB playerScript, object caller) { //IL_0078: 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_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) if ((Object)(object)playerScript == (Object)null || caller == null || _wasLocalPlayerDead || !playerScript.isPlayerDead) { return; } EnemyAI enemyScriptFromCaller = GetEnemyScriptFromCaller(caller); if ((Object)(object)enemyScriptFromCaller == (Object)null || !EnemyNametagManager.Instance.EnemyNametagPairs.TryGetValue(enemyScriptFromCaller, out var value) || (Object)(object)value.SpawnedFromPlayerScript == (Object)null) { return; } NametagData nametagData = value.NametagData; DeathMessage.Instance?.Show(value); SpawnEventHandler.Instance?.ShowCrewmateDeathMessage_ServerRpc(nametagData); if (nametagData.SpawnEnemyData.IsFromViewer) { SpawnPointManager.RewardFromDeath(nametagData); if (!PlayerUtils.IsLocalPlayer(value.SpawnedFromPlayerScript)) { SpawnEventHandler.Instance?.RewardSpawnPointsFromCrewmateDeath_ServerRpc(nametagData); } } } private static EnemyAI GetEnemyScriptFromCaller(object caller) { if (caller == null) { return null; } EnemyAI component = (EnemyAI)((caller is EnemyAI) ? caller : null); if (component != null) { return component; } ShotgunItem val = (ShotgunItem)((caller is ShotgunItem) ? caller : null); if (val != null && (Object)(object)val.heldByEnemy != (Object)null) { return val.heldByEnemy; } Component val2 = (Component)((caller is Component) ? caller : null); if (val2 != null && val2.transform.IsChildOfComponent(out component)) { return component; } return null; } private static void LogPlayerDamage(string methodName, PlayerControllerB playerScript, object caller) { Logger.LogInfo("\n\n" + methodName + " called!\n", extended: true); if ((Object)(object)playerScript == (Object)null || caller == null) { return; } Logger.LogInfo("\n\nCaller: " + caller.GetType().FullName + "\n", extended: true); EnemyAI enemyScriptFromCaller = GetEnemyScriptFromCaller(caller); if (!((Object)(object)enemyScriptFromCaller == (Object)null)) { if (playerScript.isPlayerDead) { Logger.LogInfo("\n\nYou died to a \"" + enemyScriptFromCaller.enemyType.enemyName + "\"\n", extended: true); return; } Logger.LogInfo("\n\n" + methodName + " method called by \"" + enemyScriptFromCaller.enemyType.enemyName + "\"\n", extended: true); } } } internal static class PlayerIdentityUtils { public static PlayerIdentity TakerstIdentity { get; private set; } = new PlayerIdentity("Takerst", 76561197980238122uL); public static bool IsPlayer(PlayerControllerB playerScript, PlayerIdentity identity) { if ((Object)(object)playerScript == (Object)null) { return false; } if (playerScript.playerUsername.Equals(identity.Username, StringComparison.OrdinalIgnoreCase)) { return true; } if (playerScript.playerSteamId == identity.SteamId) { return true; } return false; } public static bool IsLocalPlayer(PlayerIdentity identity) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (SteamClient.IsValid) { if (SteamClient.Name.Equals(identity.Username, StringComparison.OrdinalIgnoreCase)) { return true; } if (SteamId.op_Implicit(SteamClient.SteamId) == identity.SteamId) { return true; } } return IsPlayer(PlayerUtils.LocalPlayerScript, identity); } public static bool TryGetPlayer(PlayerIdentity identity, out PlayerControllerB playerScript) { if (PlayerUtils.ConnectedPlayerScripts.Length == 0) { Logger.LogWarning("[PlayerIdentityUtils] TryGetPlayer: PlayerScripts list is empty!"); playerScript = null; return false; } playerScript = ((IEnumerable)PlayerUtils.ConnectedPlayerScripts).FirstOrDefault((Func)((PlayerControllerB x) => IsPlayer(x, identity))); return (Object)(object)playerScript != (Object)null; } public static bool HasPlayer(PlayerIdentity identity) { PlayerControllerB playerScript; return TryGetPlayer(identity, out playerScript); } public static bool IsPlayerAny(PlayerControllerB playerScript, IEnumerable identities) { return identities.Any((PlayerIdentity x) => IsPlayer(playerScript, x)); } public static bool IsLocalPlayerAny(IEnumerable identities) { return identities.Any(IsLocalPlayer); } public static bool TryGetPlayerAny(IEnumerable identities, out PlayerControllerB playerScript) { foreach (PlayerIdentity identity in identities) { if (TryGetPlayer(identity, out playerScript)) { return true; } } playerScript = null; return false; } public static bool HasPlayerAny(IEnumerable identities) { return identities.Any(HasPlayer); } } public struct PlayerIdentity { public string Username { get; set; } public ulong SteamId { get; set; } public PlayerIdentity(string username, ulong steamId) { Username = username; SteamId = steamId; } } internal static class PlayerUtils { public static PlayerControllerB LocalPlayerScript => GameNetworkManager.Instance?.localPlayerController ?? null; public static PlayerControllerB[] AllPlayerScripts => StartOfRound.Instance?.allPlayerScripts ?? Array.Empty(); public static PlayerControllerB[] ConnectedPlayerScripts => AllPlayerScripts.Where(IsConnected).ToArray(); public static PlayerControllerB[] AlivePlayerScripts => ConnectedPlayerScripts.Where((PlayerControllerB x) => !x.isPlayerDead).ToArray(); public static PlayerControllerB[] DeadPlayerScripts => ConnectedPlayerScripts.Where((PlayerControllerB x) => x.isPlayerDead).ToArray(); public static bool TryGetLocalPlayerScript(out PlayerControllerB playerScript) { playerScript = LocalPlayerScript; return (Object)(object)playerScript != (Object)null; } public static bool IsLocalPlayer(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null) { return false; } return (Object)(object)playerScript == (Object)(object)LocalPlayerScript; } public static bool IsConnected(PlayerControllerB playerScript) { if ((Object)(object)playerScript == (Object)null) { return false; } if (!playerScript.isPlayerControlled) { return playerScript.isPlayerDead; } return true; } public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId) { return ((IEnumerable)ConnectedPlayerScripts).FirstOrDefault((Func)((PlayerControllerB playerScript) => playerScript.actualClientId == clientId)); } public static bool TryGetPlayerScriptByClientId(ulong clientId, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByClientId(clientId); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetPlayerScriptByPlayerId(int playerId) { if (playerId < 0 || playerId > ConnectedPlayerScripts.Length - 1) { return null; } return ConnectedPlayerScripts[playerId]; } public static bool TryGetPlayerScriptByPlayerId(int playerId, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByPlayerId(playerId); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetPlayerScriptByUsername(string username) { PlayerControllerB[] source = ConnectedPlayerScripts.OrderBy((PlayerControllerB x) => x.playerUsername.Length).ToArray(); PlayerControllerB val = ((IEnumerable)source).FirstOrDefault((Func)((PlayerControllerB x) => x.playerUsername.Equals(username, StringComparison.OrdinalIgnoreCase))); if (val == null) { val = ((IEnumerable)source).FirstOrDefault((Func)((PlayerControllerB x) => x.playerUsername.StartsWith(username, StringComparison.OrdinalIgnoreCase))); } if (val == null) { val = ((IEnumerable)source).FirstOrDefault((Func)((PlayerControllerB x) => x.playerUsername.Contains(username, StringComparison.OrdinalIgnoreCase))); } return val; } public static bool TryGetPlayerScriptByUsername(string username, out PlayerControllerB playerScript) { playerScript = GetPlayerScriptByUsername(username); return (Object)(object)playerScript != (Object)null; } public static PlayerControllerB GetRandomPlayerScript(PlayerControllerB[] playerScripts, bool excludeLocal = false) { if (playerScripts == null || playerScripts.Length == 0) { return null; } PlayerControllerB[] array = playerScripts.Where((PlayerControllerB playerScript) => !excludeLocal || !IsLocalPlayer(playerScript)).ToArray(); if (array.Length == 0) { return null; } return array[Random.Range(0, array.Length)]; } public static bool TryGetRandomPlayerScript(PlayerControllerB[] playerScripts, out PlayerControllerB playerScript, bool excludeLocal = false) { playerScript = GetRandomPlayerScript(playerScripts, excludeLocal); return (Object)(object)playerScript != (Object)null; } public static Camera GetLocalPlayerCamera() { if ((Object)(object)LocalPlayerScript == (Object)null || LocalPlayerScript.isPlayerDead) { return StartOfRound.Instance.spectateCamera; } return LocalPlayerScript.gameplayCamera; } public static bool TryGetLocalPlayerCamera(out Camera camera) { camera = GetLocalPlayerCamera(); return (Object)(object)camera != (Object)null; } public static bool IsLocalPlayerCameraInsideInterior() { if (!TryGetLocalPlayerScript(out var playerScript)) { return false; } if (!playerScript.isPlayerDead) { return playerScript.isInsideFactory; } if ((Object)(object)playerScript.spectatedPlayerScript != (Object)null) { return playerScript.spectatedPlayerScript.isInsideFactory; } return false; } } internal static class ReflectionHelper { public static object GetClassInstanceFromCaller(object caller) { if (caller == null) { return null; } Type type = caller.GetType(); Type declaringType = type.DeclaringType; if (declaringType == null) { return caller; } Logger.LogInfo("Analyzing caller type: " + type.FullName + ", parent type: " + declaringType.FullName, extended: true); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object value = fieldInfo.GetValue(caller); if (value != null && declaringType.IsAssignableFrom(value.GetType())) { Logger.LogInfo("Found parent instance of type " + value.GetType().FullName + " in field " + fieldInfo.Name, extended: true); return value; } if (value != null && IsCompilerGeneratedClass(value.GetType())) { object classInstanceFromCaller = GetClassInstanceFromCaller(value); if (classInstanceFromCaller != null) { return classInstanceFromCaller; } } } Logger.LogInfo("No parent instance found for " + type.FullName + ", returning original caller.", extended: true); return caller; } private static bool IsCompilerGeneratedClass(Type type) { if (type.Name.Contains("<") && type.Name.Contains(">")) { return Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute)); } return false; } public static bool IsCoroutineMethod(MethodInfo method) { return method?.ReturnType == typeof(IEnumerator); } public static MethodInfo GetCoroutineMoveNextMethod(MethodInfo method) { return method?.DeclaringType.GetNestedTypes(BindingFlags.Instance | BindingFlags.NonPublic).FirstOrDefault((Type t) => t.Name.Contains("<" + method.Name + ">"))?.GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.NonPublic); } } internal static class Utils { public static string GetPluginDirectoryPath() { return Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location); } public static string GetConfigDirectoryPath() { return Paths.ConfigPath; } public static string GetPluginPersistentDataPath() { return Path.Combine(Application.persistentDataPath, "MonsterHotkeys"); } public static ConfigFile CreateConfigFile(BaseUnityPlugin plugin, string path, string name = null, bool saveOnInit = false) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)plugin); if (name == null) { name = metadata.GUID; } name += ".cfg"; return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata); } public static ConfigFile CreateLocalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { return CreateConfigFile(plugin, GetConfigDirectoryPath(), name, saveOnInit); } public static ConfigFile CreateGlobalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false) { string pluginPersistentDataPath = GetPluginPersistentDataPath(); if (name == null) { name = "global"; } return CreateConfigFile(plugin, pluginPersistentDataPath, name, saveOnInit); } public static bool RollPercentChance(float percent) { if (percent <= 0f) { return false; } if (percent >= 100f) { return true; } return Random.value * 100f <= percent; } public static void LogStackTrace() { StackTrace stackTrace = new StackTrace(); for (int i = 1; i < stackTrace.FrameCount; i++) { StackFrame frame = stackTrace.GetFrame(i); MethodBase method = frame.GetMethod(); Type declaringType = method.DeclaringType; string name = method.Name; Logger.LogInfo($"Call stack depth {i}: {declaringType}.{name}", extended: true); } } public static string GetFormattedKeyValuePairMessage(Dictionary keyValuePair, int columns, string format) { if (keyValuePair == null || keyValuePair.Count == 0) { return string.Empty; } int num = Mathf.CeilToInt((float)keyValuePair.Count / (float)columns); List>> list = new List>>(); for (int i = 0; i < columns; i++) { list.Add(keyValuePair.Skip(i * num).Take(num).ToList()); } List list2 = list.Select((List> column) => column.Any() ? column.Max((KeyValuePair item) => item.Key.Length) : 0).ToList(); List list3 = list.Select((List> column) => column.Any() ? column.Max((KeyValuePair item) => item.Value.ToString().Length) : 0).ToList(); StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < num; j++) { for (int k = 0; k < columns; k++) { if (k < list.Count && j < list[k].Count) { KeyValuePair keyValuePair2 = list[k][j]; string newValue = keyValuePair2.Key.PadRight(list2[k]); string newValue2 = keyValuePair2.Value.ToString().PadRight(list3[k]); string value = format.Replace("{key}", newValue).Replace("{value}", newValue2); stringBuilder.Append(value); if (k < columns - 1) { stringBuilder.Append(" | "); } } } stringBuilder.AppendLine(); } return stringBuilder.ToString().TrimEnd(); } public static List FormatAsGrid(List> rows, int columnPadding = 1) { if (rows == null || rows.Count == 0) { return new List(); } int num = rows.Max((List row) => row?.Count ?? 0); int[] array = new int[num]; foreach (List row in rows) { if (row == null) { continue; } for (int i = 0; i < row.Count; i++) { int num2 = row[i]?.Length ?? 0; if (num2 > array[i]) { array[i] = num2; } } } List list = new List(); foreach (List row2 in rows) { if (row2 == null) { list.Add(string.Empty); continue; } StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < num; j++) { string text = ((j < row2.Count) ? row2[j] : null) ?? string.Empty; if (j < num - 1) { stringBuilder.Append(text.PadRight(array[j] + columnPadding)); } else { stringBuilder.Append(text); } } list.Add(stringBuilder.ToString()); } return list; } } } namespace com.github.zehsteam.MonsterHotkeys.Extensions { internal static class AssemblyExtensions { public static bool IsLocatedInPluginsFolder(this Assembly assembly) { if (assembly == null) { return false; } if (assembly.IsDynamic) { return false; } return assembly.Location.StartsWith(Paths.PluginPath, StringComparison.OrdinalIgnoreCase); } public static IEnumerable GetLoadableTypes(this Assembly assembly) { if (assembly == null) { return Array.Empty(); } try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type type) => type != null); } } } internal static class CollectionExtensions { public static IEnumerable StringToCollection(this string s, string separator = ",") { if (string.IsNullOrEmpty(s)) { return Array.Empty(); } T result; return from x in s.Split(separator, StringSplitOptions.RemoveEmptyEntries) where !string.IsNullOrWhiteSpace(x) select x.Trim() into x select (!x.TryConvertTo(out result)) ? default(T) : result into x where x != null select x; } public static string CollectionToString(this IEnumerable value, string separator = ", ") { if (value == null || !value.Any()) { return string.Empty; } return string.Join(separator, from x in value where x != null && !string.IsNullOrWhiteSpace(x.ToString()) select x.ToString().Trim()); } } internal static class ConfigEntryExtensions { public static bool SetValue(this ConfigEntry configEntry, string value) { if (configEntry == null) { return false; } try { configEntry.Value = value.ConvertTo(); return true; } catch (Exception ex) { Logger.LogError("SetValue failed for key '" + ((ConfigEntryBase)configEntry).Definition.Key + "': " + ex.Message); return false; } } public static bool SetValue(this SyncedConfigEntry configEntry, string value) { if (configEntry == null) { return false; } try { configEntry.Value = value.ConvertTo(); return true; } catch (Exception ex) { Logger.LogError($"SetValue failed for key '{configEntry.Definition}': {ex.Message}"); return false; } } } internal static class ConfigFileExtensions { private static readonly PropertyInfo EntriesProperty = AccessTools.Property(typeof(ConfigFile), "Entries"); private static readonly PropertyInfo OrphanedEntriesProperty = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); public static ConfigEntry Bind(this ConfigFile configFile, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown if (acceptableValues == null) { return configFile.Bind(section, key, defaultValue, description); } return configFile.Bind(section, key, defaultValue, new ConfigDescription(description, acceptableValues, Array.Empty())); } public static Dictionary GetConfigEntries_Ext(this ConfigFile configFile) { if (configFile == null) { return new Dictionary(); } if (EntriesProperty == null) { Logger.LogError("ConfigFileExtensions: GetConfigEntries_Ext(); EntriesProperty is null."); return new Dictionary(); } return EntriesProperty?.GetValue(configFile) as Dictionary; } public static Dictionary GetOrphanedConfigEntries(this ConfigFile configFile) { if (configFile == null) { return new Dictionary(); } if (OrphanedEntriesProperty == null) { Logger.LogError("ConfigFileExtensions: GetOrphanedConfigEntries(); OrphanedEntriesProperty is null."); return new Dictionary(); } return (OrphanedEntriesProperty?.GetValue(configFile, null) as Dictionary) ?? new Dictionary(); } public static bool RemoveOrphaned(this ConfigFile configFile, ConfigDefinition configDefinition) { if (configFile == null || configDefinition == (ConfigDefinition)null) { return false; } if (typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(configFile) is IDictionary dictionary) { return dictionary.Remove(configDefinition); } return false; } public static bool MigrateConfigEntry(this ConfigFile configFile, ConfigDefinition oldConfigDefinition, string value, ConfigEntry newConfigEntry) { if (configFile == null || oldConfigDefinition == (ConfigDefinition)null || newConfigEntry == null) { return false; } configFile.RemoveOrphaned(oldConfigDefinition); return newConfigEntry.SetValue(value); } public static bool MigrateConfigEntry(this ConfigFile configFile, ConfigDefinition oldConfigDefinition, string value, SyncedConfigEntry newConfigEntry) { if (configFile == null || oldConfigDefinition == (ConfigDefinition)null || newConfigEntry == null) { return false; } configFile.RemoveOrphaned(oldConfigDefinition); return newConfigEntry.SetValue(value); } public static bool MigrateConfigEntry(this ConfigFile configFile, ConfigDefinition oldConfigDefinition, string value, ConfigEntryBase configEntryBase) { if (configFile == null || oldConfigDefinition == (ConfigDefinition)null || configEntryBase == null) { return false; } Type type = ((object)configEntryBase).GetType(); if (!type.IsGenericType || type.GetGenericTypeDefinition() != typeof(ConfigEntry<>)) { return false; } Type type2 = type.GenericTypeArguments[0]; MethodInfo methodInfo = typeof(ConfigFileExtensions).GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "MigrateConfigEntry" && m.IsGenericMethodDefinition && m.GetParameters().Length == 4 && m.GetGenericArguments().Length == 1); if (methodInfo == null) { throw new InvalidOperationException("Cannot find MigrateConfigEntry method."); } MethodInfo methodInfo2 = methodInfo.MakeGenericMethod(type2); object obj = methodInfo2.Invoke(null, new object[4] { configFile, oldConfigDefinition, value, configEntryBase }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } public static void MigrateConfigEntries(this ConfigFile configFile, ConfigSectionMigration[] migrations) { Dictionary configEntries_Ext = configFile.GetConfigEntries_Ext(); Dictionary dictionary = new Dictionary(configFile.GetOrphanedConfigEntries()); Logger.LogInfo($"ConfigFileExtensions: MigrateConfigEntries(); entries: {configEntries_Ext.Count}, orphanedEntries: {dictionary.Count}", extended: true); foreach (ConfigSectionMigration migration in migrations) { configFile.MigrateConfigEntries(migration, configEntries_Ext, dictionary); } } public static void MigrateConfigEntries(this ConfigFile configFile, ConfigSectionMigration migration, Dictionary entries = null, Dictionary orphanedEntries = null) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown if (entries == null) { entries = configFile.GetConfigEntries_Ext(); } if (orphanedEntries == null) { orphanedEntries = new Dictionary(configFile.GetOrphanedConfigEntries()); } foreach (KeyValuePair orphanedEntry in orphanedEntries) { ConfigDefinition orphanedDefinition = orphanedEntry.Key; if (migration.OldSections.Any((string oldSection) => oldSection.Equals(orphanedDefinition.Section, StringComparison.OrdinalIgnoreCase))) { string value = orphanedEntry.Value; ConfigDefinition val = new ConfigDefinition(migration.NewSection, orphanedDefinition.Key); if (entries.TryGetValue(val, out var value2) && configFile.MigrateConfigEntry(orphanedDefinition, value, value2)) { Logger.LogInfo("Migrated orphaned config entry (section: \"" + orphanedDefinition.Section + "\", key: \"" + orphanedDefinition.Key + "\", value: \"" + value + "\") to (section: \"" + val.Section + "\", key: \"" + val.Key + "\")"); } } } } } public readonly struct ConfigSectionMigration { public string[] OldSections { get; } public string NewSection { get; } public ConfigSectionMigration(string[] oldSections, string newSection) { OldSections = oldSections; NewSection = newSection; } public ConfigSectionMigration(string oldSection, string newSection) : this(new string[1] { oldSection }, newSection) { } } internal static class EnemyTypeExtensions { public static bool IsValid(this EnemyType enemyType) { if ((Object)(object)enemyType == (Object)null) { return false; } if (string.IsNullOrWhiteSpace(enemyType.enemyName)) { return false; } if ((Object)(object)enemyType.enemyPrefab == (Object)null) { return false; } if (enemyType.spawningDisabled) { return false; } return true; } public static EnemyData GetData(this EnemyType enemyType) { if ((Object)(object)enemyType == (Object)null) { return null; } if ((Object)(object)Assets.EnemyDatabase == (Object)null) { return null; } return Assets.EnemyDatabase.GetData(enemyType); } public static bool TryGetData(this EnemyType enemyType, out EnemyData enemyData) { enemyData = enemyType.GetData(); return enemyData != null; } public static string GetDisplayName(this EnemyType enemyType) { if ((Object)(object)enemyType == (Object)null) { return "Unknown Enemy"; } if (enemyType.TryGetData(out var enemyData)) { return enemyData.DisplayName; } return enemyType.enemyName.FormatCapitalization(); } public static bool CanSpawnOnPlayer(this EnemyType enemyType, PlayerControllerB playerScript, SpawnSource spawnSource) { if (!enemyType.TryGetData(out var enemyData)) { return false; } return enemyData.CanSpawnOnPlayer(playerScript, spawnSource); } } internal static class ImageExtensions { public static void SetAlpha(this Image image, int value) { //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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)image == (Object)null)) { Color32 val = Color32.op_Implicit(((Graphic)image).color); val.a = (byte)Mathf.Clamp(value, 0, 255); ((Graphic)image).color = Color32.op_Implicit(val); } } } public static class StringExtensions { public static T ConvertTo(this string s) { Type typeFromHandle = typeof(T); if ((object)typeFromHandle != null) { Type type = typeFromHandle; object obj; if (type == typeof(int) && int.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out var result)) { obj = result; } else { Type type2 = typeFromHandle; if (type2 == typeof(float) && float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { obj = result2; } else { Type type3 = typeFromHandle; if (type3 == typeof(double) && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { obj = result3; } else { Type type4 = typeFromHandle; if (type4 == typeof(bool) && bool.TryParse(s, out var result4)) { obj = result4; } else { Type type5 = typeFromHandle; if (type5 == typeof(string)) { obj = s; } else { Type type6 = typeFromHandle; if (!type6.IsEnum || !Enum.TryParse(type6, s, ignoreCase: true, out object result5)) { goto IL_0121; } obj = result5; } } } } } object obj2 = obj; return (T)obj2; } goto IL_0121; IL_0121: throw new NotSupportedException($"Unsupported value type: {typeof(T)}"); } public static bool TryConvertTo(this string s, out T result) { try { result = s.ConvertTo(); return true; } catch { result = default(T); return false; } } public static bool EqualsAny(this string input, string[] values, StringComparison comparisonType = StringComparison.CurrentCulture) { if (input == null) { throw new ArgumentNullException("input"); } if (values == null) { throw new ArgumentNullException("values"); } foreach (string value in values) { if (input.Equals(value, comparisonType)) { return true; } } return false; } public static bool ContainsAny(this string input, string[] values, StringComparison comparisonType = StringComparison.CurrentCulture) { if (input == null) { throw new ArgumentNullException("input"); } if (values == null) { throw new ArgumentNullException("values"); } foreach (string value in values) { if (input.Contains(value, comparisonType)) { return true; } } return false; } public static bool StartsWithAny(this string input, string[] values, StringComparison comparisonType = StringComparison.CurrentCulture) { if (input == null) { throw new ArgumentNullException("input"); } if (values == null) { throw new ArgumentNullException("values"); } foreach (string value in values) { if (input.StartsWith(value, comparisonType)) { return true; } } return false; } public static string FormatCapitalization(this string s) { if (string.IsNullOrWhiteSpace(s)) { return string.Empty; } return string.Join(" ", from word in s.Split(' ', StringSplitOptions.RemoveEmptyEntries) select $"{char.ToUpper(word[0])}{word.Substring(1).ToLower()}"); } public static string RemoveSpaces(this string s) { return s.Replace(" ", ""); } public static bool Equals_OrdinalIgnoreCase(this string a, string b) { return a.Equals(b, StringComparison.OrdinalIgnoreCase); } public static string RichColor(this string s, string colorHex) { if (string.IsNullOrWhiteSpace(colorHex)) { colorHex = "#FFFFFF"; } return "" + s + ""; } public static string RichReadableColor(this string s, string colorHex, string backgroundColorHex = "#000000") { if (string.IsNullOrWhiteSpace(colorHex)) { colorHex = "#FFFFFF"; } string readableColorHex = ColorHelper.GetReadableColorHex(colorHex, backgroundColorHex); return s.RichColor(readableColorHex); } } internal static class TransformExtensions { public static bool IsChildOfComponent(this Transform transform, out T component) where T : Component { component = default(T); if ((Object)(object)transform == (Object)null || (Object)(object)transform.parent == (Object)null) { return false; } if (((Component)transform.parent).TryGetComponent(ref component)) { return true; } return transform.parent.IsChildOfComponent(out component); } } internal static class TwitchChatAPIExtensions { public static string GetDisplayNameWithReadableColor(this TwitchUser twitchUser) { return ((TwitchUser)(ref twitchUser)).DisplayName.RichReadableColor(((TwitchUser)(ref twitchUser)).Color); } public static bool IsModeratorOrHigher(this TwitchUser twitchUser) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!((TwitchUser)(ref twitchUser)).IsModerator && !((TwitchUser)(ref twitchUser)).IsBroadcaster && !twitchUser.IsDeveloper()) { return twitchUser.IsExtraModerator(); } return true; } public static bool IsExtraModerator(this TwitchUser twitchUser) { return ConfigManager.TwitchChatCommands_ExtraModerators_Array.Contains(((TwitchUser)(ref twitchUser)).Username, StringComparer.OrdinalIgnoreCase); } public static bool IsDeveloper(this TwitchUser twitchUser) { return ((TwitchUser)(ref twitchUser)).Username.Equals("CritHaxXoG", StringComparison.OrdinalIgnoreCase); } } } namespace com.github.zehsteam.MonsterHotkeys.Enums { [Serializable] public class PlushiePoolData { public string PoolId; public GameObject Prefab; } internal enum SaveLocation { CurrentSave, GeneralSave, Modpack, Global } public enum ScreenAnchor { BottomRight, BottomLeft, TopRight, TopLeft } public enum SpawnSource { Default, Twitch, CrowdControl } } namespace com.github.zehsteam.MonsterHotkeys.Dependencies { internal static class LethalConfigProxy { public const string PLUGIN_GUID = "ainavt.lc.lethalconfig"; public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SkipAutoGen() { LethalConfigManager.SkipAutoGen(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry configEntry, bool requiresRestart = false, bool isHexColor = false) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown BaseConfigItem val = (BaseConfigItem)((!isHexColor) ? ((object)new TextInputFieldConfigItem(configEntry, requiresRestart)) : ((object)new HexColorInputFieldConfigItem(configEntry, requiresRestart))); LethalConfigManager.AddConfigItem(val); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry configEntry, bool requiresRestart = false) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown AcceptableValueBase acceptableValues = ((ConfigEntryBase)configEntry).Description.AcceptableValues; if (acceptableValues != null) { if (acceptableValues is AcceptableValueRange || acceptableValues is AcceptableValueRange) { AddConfigSlider(configEntry, requiresRestart); return; } if (acceptableValues is AcceptableValueList) { AddConfigDropdown(configEntry, requiresRestart); return; } } if (typeof(T).IsEnum) { Type type = typeof(EnumDropDownConfigItem<>).MakeGenericType(typeof(T)); object obj = Activator.CreateInstance(type, configEntry, requiresRestart); MethodInfo methodInfo = AccessTools.Method(typeof(LethalConfigManager), "AddConfigItem", new Type[1] { type }, (Type[])null); methodInfo.Invoke(null, new object[1] { obj }); } else if (!(configEntry is ConfigEntry val)) { if (!(configEntry is ConfigEntry val2)) { if (!(configEntry is ConfigEntry val3)) { if (!(configEntry is ConfigEntry val4)) { throw new NotSupportedException($"Unsupported type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(val4, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(val3, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(val2, requiresRestart)); } } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigSlider(ConfigEntry configEntry, bool requiresRestart = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (!(configEntry is ConfigEntry val)) { if (!(configEntry is ConfigEntry val2)) { throw new NotSupportedException($"Slider not supported for type: {typeof(T)}"); } LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(val2, requiresRestart)); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(val, requiresRestart)); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigDropdown(ConfigEntry configEntry, bool requiresRestart = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (configEntry is ConfigEntry val) { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(val, requiresRestart)); return; } throw new NotSupportedException($"Dropdown not supported for type: {typeof(T)}"); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string buttonText, string description, Action callback) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); })); } } } namespace com.github.zehsteam.MonsterHotkeys.Dependencies.ImmersiveEntranceMod { internal static class ImmersiveEntranceProxy { public const string PLUGIN_GUID = "com.github.zehsteam.ImmersiveEntrance"; public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("com.github.zehsteam.ImmersiveEntrance"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static bool TryGetRenderingCamera(out Camera camera) { try { DoorPortal val = default(DoorPortal); if (DoorPortal.TryGetRenderingInstance(ref val)) { camera = val.PortalCamera; return true; } } catch { } camera = null; return false; } } } namespace com.github.zehsteam.MonsterHotkeys.Dependencies.CrowdControlMod { internal static class CrowdControlProxy { public const string PLUGIN_GUID = "WarpWorld.CrowdControl"; public static bool IsInstalled => Chainloader.PluginInfos.ContainsKey("WarpWorld.CrowdControl"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void PatchAll(Harmony harmony) { try { harmony.PatchAll(typeof(CrowdDelegates_Patches)); Logger.LogInfo("Applied CrowdControl patches."); } catch (Exception arg) { Logger.LogError($"Failed to apply CrowdControl patches. {arg}"); } } } } namespace com.github.zehsteam.MonsterHotkeys.Dependencies.CrowdControlMod.Patches { [HarmonyPatch(typeof(CrowdDelegates))] internal static class CrowdDelegates_Patches { private static Dictionary _failedEntitySpawns = new Dictionary(); private static readonly float _enemyStunDuration = 6f; [HarmonyPatch("Spawn")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool Spawn_Patch(CrowdRequest req, ref CrowdResponse __result) { try { return SpawnLogic(req, ref __result); } catch (Exception arg) { Logger.LogWarning(string.Format("Failed to run CrowdControl {0}.{1} replacement method. Running original method instead. {2}", "CrowdDelegates", "Spawn", arg)); return true; } } private static bool SpawnLogic(CrowdRequest req, ref CrowdResponse __result) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown if (!ConfigManager.CrowdControl_Enabled.Value) { return true; } Logger.LogInfo("[CrowdDelegates_Patches] SpawnLogic: req.code: \"" + req.code + "\"", extended: true); PlayerControllerB localPlayerScript = PlayerUtils.LocalPlayerScript; if ((Object)(object)localPlayerScript == (Object)null || localPlayerScript.isPlayerDead) { __result = new CrowdResponse(req.GetReqID(), (Status)3, "Player is dead"); return false; } string[] array = req.code.Split('_'); if (array.Length != 2) { __result = new CrowdResponse(req.GetReqID(), (Status)1, "What"); return false; } string text = array[1]; string[] source = new string[4] { "landmine", "turret", "turretcont", "spiketrap" }; if (source.Contains(text)) { return true; } if (!TryGetEnemyName(text, out var _)) { ShowSpawnErrorMessage(req, "SpawnLogic", text); throw new NotSupportedException("Entity \"" + text + "\" is not recognized."); } ulong spawnedFromClientId = NetworkUtils.LocalClientId; if (array.Length > 3 && ulong.TryParse(array[3], out var result)) { spawnedFromClientId = result; } __result = SpawnEnemy(localPlayerScript, text, req, spawnedFromClientId); return false; } [HarmonyPatch("CrewSpawn")] [HarmonyPrefix] [HarmonyPriority(800)] private static bool CrewSpawn_Patch(CrowdRequest req, ref CrowdResponse __result) { try { return CrewSpawnLogic(req, ref __result); } catch (Exception arg) { Logger.LogWarning(string.Format("Failed to run CrowdControl {0}.{1} replacement method. Running original method instead. {2}", "CrowdDelegates", "CrewSpawn", arg)); return true; } } private static bool CrewSpawnLogic(CrowdRequest req, ref CrowdResponse __result) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown if (!ConfigManager.CrowdControl_Enabled.Value) { return true; } Logger.LogInfo("[CrowdDelegates_Patches] CrewSpawnLogic: req.code: \"" + req.code + "\"", extended: true); string[] array = req.code.Split('_'); if (array.Length != 2) { __result = new CrowdResponse(req.GetReqID(), (Status)1, "What"); return false; } PlayerControllerB val = null; if (TargetPlayerManager.TryGetTarget(req.viewer, out var playerScript)) { val = playerScript; } if (val == null) { val = PlayerUtils.GetRandomPlayerScript(PlayerUtils.AlivePlayerScripts, excludeLocal: true); } if ((Object)(object)val == (Object)null) { __result = new CrowdResponse(req.GetReqID(), (Status)3, ""); return false; } string text = array[1]; string[] source = new string[4] { "landmine", "turret", "turretcont", "spiketrap" }; if (source.Contains(text)) { return true; } if (!TryGetEnemyName(text, out var _)) { ShowSpawnErrorMessage(req, "CrewSpawnLogic", text); throw new NotSupportedException("Entity \"" + text + "\" is not recognized."); } ulong spawnedFromClientId = NetworkUtils.LocalClientId; if (array.Length > 3 && ulong.TryParse(array[3], out var result)) { spawnedFromClientId = result; } __result = SpawnEnemy(val, text, req, spawnedFromClientId); return false; } private static void ShowSpawnErrorMessage(CrowdRequest crowdRequest, string spawnMethod, string entity) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (_failedEntitySpawns.TryGetValue(entity, out var value)) { _failedEntitySpawns[entity] = Time.realtimeSinceStartup; float num = Time.realtimeSinceStartup - value; if (num < 5f) { return; } } _failedEntitySpawns[entity] = Time.realtimeSinceStartup; string text = "CrowdControl integration error! " + spawnMethod + "()"; text = ((!TryGetEnemyName(entity, out var enemyName)) ? (text + " Entity \"" + entity + "\" was not recognized and will spawn without a nametag.") : (text + " Enemy \"" + enemyName + "\" will spawn without a nametag.")); MessageManger instance = MessageManger.Instance; if (instance != null) { string message = text; Color? color = Color.red; instance.ShowMessage_LocalClient(message, new MessageSettings(null, color)); } } private static CrowdResponse SpawnEnemy(PlayerControllerB targetPlayerScript, string entity, CrowdRequest crowdRequest, ulong spawnedFromClientId) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown if (!((Object)(object)targetPlayerScript == (Object)null) && crowdRequest != null) { if (!targetPlayerScript.isPlayerDead) { if (EnemyHelper.CanSpawnEnemiesOnPlayer(targetPlayerScript)) { if (!NetworkUtils.IsServer) { LethalCompanyControl.ActionQueue.Enqueue(delegate { ulong playerClientId = targetPlayerScript.playerClientId; HUDManager.Instance.AddTextToChatOnServer($"/cc_cspawn_{entity}_{targetPlayerScript.playerClientId}_{spawnedFromClientId}", -1); }); return new CrowdResponse(crowdRequest.GetReqID(), (Status)0, ""); } if (!TryGetEnemyName(entity, out var enemyName)) { ShowSpawnErrorMessage(crowdRequest, "SpawnEnemy", entity); throw new NotSupportedException("Entity \"" + entity + "\" is not recognized."); } if (!Assets.EnemyDatabase.TryGetDataByName(enemyName, out var enemyData)) { ShowSpawnErrorMessage(crowdRequest, "SpawnEnemy", entity); throw new NotSupportedException("Entity \"" + entity + "\" is not recognized."); } if (enemyData.CanSpawnOnPlayer(targetPlayerScript, SpawnSource.CrowdControl)) { LethalCompanyControl.ActionQueue.Enqueue(delegate { //IL_000b: 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_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_0041: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)targetPlayerScript).transform.position + ((Component)targetPlayerScript).transform.forward * 5f; EnemyAI val = EnemyHelper.SpawnEnemyAtPosition_Server(enemyData.EnemyType, targetPlayerScript, position, spawnStunned: true, _enemyStunDuration); if (!((Object)(object)val == (Object)null)) { NetworkObject component = ((Component)val).GetComponent(); string viewer = crowdRequest.viewer; ViewerData viewerData = null; TwitchUser user = default(TwitchUser); viewerData = ((!API.TryGetUserByUsername(viewer, ref user)) ? new ViewerData("CC_" + viewer, viewer, viewer, "#FFFFFF") : new ViewerData(user)); SpawnEnemyData spawnEnemyData = new SpawnEnemyData(viewerData, SpawnSource.CrowdControl, 1, string.Empty, "", spawnedFromClientId, targetPlayerScript.actualClientId); EnemyNametagManager.Instance?.SpawnNametags_ServerRpc(spawnEnemyData, (NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(component) }); } }); return new CrowdResponse(crowdRequest.GetReqID(), (Status)0, ""); } return new CrowdResponse(crowdRequest.GetReqID(), (Status)3, ""); } return new CrowdResponse(crowdRequest.GetReqID(), (Status)3, ""); } return new CrowdResponse(crowdRequest.GetReqID(), (Status)3, "Player is dead"); } return new CrowdResponse(crowdRequest.GetReqID(), (Status)1, ""); } private static bool TryGetEnemyName(string entity, out string enemyName) { enemyName = entity.ToLower() switch { "hawk" => "Baboon hawk", "clay" => "Clay Surgeon", "blob" => "Blob", "flower" => "Flowerman", "spider" => "Bunker Spider", "butler" => "Butler", "spring" => "Spring", "levi" => "Earth Leviathan", "dog" => "MouthDog", "giant" => "ForestGiant", "girl" => "Girl", "hoard" => "Hoarding bug", "jester" => "Jester", "bush" => "Bush Wolf", "eater" => "Maneater", "mimic" => "Masked", "cracker" => "Nutcracker", "radmech" => "RadMech", "kiwi" => "Giantkiwi", "pede" => "Centipede", "puff" => "Puffer", "crawl" => "Crawler", "snake" => "Tulip Snake", "pum" => "Feiopar", "ray" => "Stingray", "bloom" => "Cadaver Bloom", "growths" => "Cadaver Growths", _ => string.Empty, }; return !string.IsNullOrEmpty(enemyName); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace com.github.zehsteam.MonsterHotkeys.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }