using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; using Zorro.Core; using Zorro.Core.Serizalization; using pworld.Scripts.Extensions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("MMHOOK_Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PeakRandomizedChaos")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.1.5.0")] [assembly: AssemblyInformationalVersion("1.1.5")] [assembly: AssemblyProduct("PeakRandomizedChaos")] [assembly: AssemblyTitle("PeakRandomizedChaos")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.5.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace PeakRandomizedChaos { [BepInPlugin("PeakRandomizedChaos", "Chaos", "1.1.5")] public sealed class Plugin : BaseUnityPlugin { public const string ModGuid = "PeakRandomizedChaos"; public const string ModName = "Chaos"; public const string ModVersion = "1.1.5"; internal static ManualLogSource Log; internal static Plugin Instance; private Harmony _harmony = null; private bool _showSettingsGUI; private Rect _settingsWindowRect = new Rect(0f, 0f, 540f, 620f); private Vector2 _scrollPosition; private string _tempWaitTimeMin = ""; private string _tempWaitTimeMax = ""; private GUIStyle _buttonStyle = null; private GUIStyle _windowStyle = null; private GUIStyle _labelStyle = null; private GUIStyle _titleStyle = null; private GUIStyle _sectionStyle = null; private GUIStyle _textFieldStyle = null; private GUIStyle _textFieldHoverStyle = null; private GUIStyle _switchOnStyle = null; private GUIStyle _switchOffStyle = null; private GUIStyle _closeStyle = null; private GUIStyle _hintStyle = null; private Texture2D _btnTex = null; private Texture2D _btnHoverTex = null; private Texture2D _windowTex = null; private Texture2D _fieldTex = null; private Texture2D _accentTex = null; private Texture2D _rowTex = null; private Texture2D _switchOnTex = null; private Texture2D _switchOnHoverTex = null; private Texture2D _switchOffTex = null; private Texture2D _switchOffHoverTex = null; private Texture2D _dimTex = null; private bool _lastChaosMasterState; private bool _lastRandomEventsState; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; ModConfig.Startup(((BaseUnityPlugin)this).Config); _harmony = new Harmony("PeakRandomizedChaos"); _harmony.PatchAll(typeof(LootTablePatch)); _harmony.PatchAll(typeof(GameHandlerPatch)); _harmony.PatchAll(typeof(MountainProgressHandlerPatch)); _harmony.PatchAll(typeof(LoadingScreenHandlerPatch)); _harmony.PatchAll(typeof(PauseMenuMainPagePatch)); _harmony.PatchAll(typeof(AchievementManagerPatch)); _harmony.PatchAll(typeof(SpecialHeldItemPatch)); _harmony.PatchAll(typeof(RescueHookDestroyPatch)); _harmony.PatchAll(typeof(DayNightManagerBootstrapPatch)); _harmony.PatchAll(typeof(WindChillZonePatch)); _harmony.PatchAll(typeof(HotSunPatch)); _harmony.PatchAll(typeof(TornadoCompatibilityPatch)); _harmony.PatchAll(typeof(ItemOptimizationCompatibilityPatch)); SyncTempValuesFromConfig(); _lastChaosMasterState = ModConfig.EnableChaosMaster.Value; _lastRandomEventsState = ModConfig.EnableRandomEvents.Value; Log.LogInfo((object)"Chaos loaded."); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(ModConfig.ToggleGuiKey.Value)) { _showSettingsGUI = !_showSettingsGUI; if (_showSettingsGUI) { SyncTempValuesFromConfig(); } } bool value = ModConfig.EnableChaosMaster.Value; bool value2 = ModConfig.EnableRandomEvents.Value; if (_lastChaosMasterState == value && _lastRandomEventsState == value2) { return; } _lastChaosMasterState = value; _lastRandomEventsState = value2; if (PhotonNetwork.IsMasterClient) { if (!value || !value2) { RandomEventTask.StopTask(); RandomizerEvents.ClearPendingQueues(); } else { RandomEventTask.StartTask(); } } } private void OnGUI() { EnsureGuiStyles(); DrawSettingsButton(); if (_showSettingsGUI) { DrawSettingsWindow(); } } private void OnDestroy() { try { ChaosEnvironmentController.ResetLocalState(); if (PhotonNetwork.IsMasterClient) { RandomEventTask.StopTask(); RandomizerEvents.ClearPendingQueues(); } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } SafeDestroy(ref _btnTex); SafeDestroy(ref _btnHoverTex); SafeDestroy(ref _windowTex); SafeDestroy(ref _fieldTex); SafeDestroy(ref _accentTex); SafeDestroy(ref _rowTex); SafeDestroy(ref _switchOnTex); SafeDestroy(ref _switchOnHoverTex); SafeDestroy(ref _switchOffTex); SafeDestroy(ref _switchOffHoverTex); SafeDestroy(ref _dimTex); } private static bool IsNonGameplayScene(string sceneName) { if (string.IsNullOrWhiteSpace(sceneName)) { return true; } switch (sceneName.ToLowerInvariant()) { case "airport": case "mainmenu": case "title": case "pretitle": case "wilisland": return true; default: return false; } } public static bool IsGameplayScene() { //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) Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; return !IsNonGameplayScene(name); } private void DrawSettingsButton() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.ShowSettingsButton.Value) { return; } float num = 40f; float num2 = (float)Screen.width - num - 14f; float num3 = Mathf.Max(10f, ModConfig.SettingsButtonTopOffset.Value); if (GUI.Button(new Rect(num2, num3, num, num), "⚙", _buttonStyle)) { _showSettingsGUI = !_showSettingsGUI; if (_showSettingsGUI) { SyncTempValuesFromConfig(); ((Rect)(ref _settingsWindowRect)).x = Mathf.Max(10f, num2 - 486f); ((Rect)(ref _settingsWindowRect)).y = Mathf.Min((float)Screen.height - ((Rect)(ref _settingsWindowRect)).height - 10f, num3 + 48f); } } } private void DrawSettingsWindow() { //IL_0017: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_dimTex); _settingsWindowRect = GUI.Window(987654, _settingsWindowRect, new WindowFunction(DrawSettingsWindowContents), "", _windowStyle); } private void DrawSettingsWindowContents(int id) { //IL_0025: 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_006b: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) float width = ((Rect)(ref _settingsWindowRect)).width; float height = ((Rect)(ref _settingsWindowRect)).height; GUI.DrawTexture(new Rect(0f, 0f, width, height), (Texture)(object)_windowTex); GUI.DrawTexture(new Rect(0f, 0f, width, 52f), (Texture)(object)_accentTex); GUI.Label(new Rect(16f, 11f, 360f, 30f), "Chaos Settings", _titleStyle); if (GUI.Button(new Rect(width - 46f, 11f, 30f, 30f), "X", _closeStyle)) { _showSettingsGUI = false; } Rect val = default(Rect); ((Rect)(ref val))..ctor(14f, 64f, width - 28f, height - 122f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, ((Rect)(ref val)).width - 18f, 660f); _scrollPosition = GUI.BeginScrollView(val, _scrollPosition, val2); float y = 0f; DrawSectionLabel("界面", ref y, ((Rect)(ref val2)).width); DrawToggleRow("显示右上角设置按钮", ref y, ((Rect)(ref val2)).width, ModConfig.ShowSettingsButton); DrawSectionLabel("主开关", ref y, ((Rect)(ref val2)).width); DrawToggleRow("Chaos Mod 总开关", ref y, ((Rect)(ref val2)).width, ModConfig.EnableChaosMaster); DrawSectionLabel("随机内容", ref y, ((Rect)(ref val2)).width); DrawToggleRow("随机箱子 / 随机掉落", ref y, ((Rect)(ref val2)).width, ModConfig.EnableItemRandomization); DrawToggleRow("随机事件", ref y, ((Rect)(ref val2)).width, ModConfig.EnableRandomEvents); DrawSectionLabel("随机事件时间范围", ref y, ((Rect)(ref val2)).width); DrawTextFieldRow("最小时间(秒)", ref y, ((Rect)(ref val2)).width, ref _tempWaitTimeMin, delegate(string value) { if (int.TryParse(value, out var result2)) { ModConfig.WaitTimeMin.Value = Mathf.Max(1, result2); ClampTimeRange(); ((BaseUnityPlugin)this).Config.Save(); SyncTempValuesFromConfig(); } }, delegate(int delta) { ModConfig.WaitTimeMin.Value = Mathf.Max(1, ModConfig.WaitTimeMin.Value + delta); ClampTimeRange(); ((BaseUnityPlugin)this).Config.Save(); SyncTempValuesFromConfig(); }); DrawTextFieldRow("最大时间(秒)", ref y, ((Rect)(ref val2)).width, ref _tempWaitTimeMax, delegate(string value) { if (int.TryParse(value, out var result)) { ModConfig.WaitTimeMax.Value = Mathf.Max(1, result); ClampTimeRange(); ((BaseUnityPlugin)this).Config.Save(); SyncTempValuesFromConfig(); } }, delegate(int delta) { ModConfig.WaitTimeMax.Value = Mathf.Max(1, ModConfig.WaitTimeMax.Value + delta); ClampTimeRange(); ((BaseUnityPlugin)this).Config.Save(); SyncTempValuesFromConfig(); }); GUI.DrawTexture(new Rect(12f, y, ((Rect)(ref val2)).width - 24f, 44f), (Texture)(object)_rowTex); GUI.Label(new Rect(24f, y + 11f, ((Rect)(ref val2)).width - 48f, 24f), $"当前范围:{ModConfig.WaitTimeMin.Value}s ~ {ModConfig.WaitTimeMax.Value}s", _labelStyle); y += 56f; DrawToggleRow("最后一关熔炉允许龙卷风", ref y, ((Rect)(ref val2)).width, ModConfig.EnableTornadoAtKiln); GUI.Label(new Rect(12f, y, ((Rect)(ref val2)).width - 24f, 78f), $"GUI 热键:{ModConfig.ToggleGuiKey.Value}\n" + "关闭总开关后,随机箱子和随机事件都会停止。\n关闭“随机箱子”只影响掉落;关闭“随机事件”只影响事件。\n晒伤 / 烈日持续时间已从界面隐藏,只保留在配置文件中。", _hintStyle); GUI.EndScrollView(); if (GUI.Button(new Rect(16f, height - 44f, 120f, 30f), "恢复默认", _buttonStyle)) { ResetSimpleDefaults(); SyncTempValuesFromConfig(); } if (GUI.Button(new Rect(width - 116f, height - 44f, 100f, 30f), "关闭", _buttonStyle)) { _showSettingsGUI = false; } GUI.DragWindow(new Rect(0f, 0f, width, 52f)); } private void DrawSectionLabel(string text, ref float y, float width) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(12f, y, width - 24f, 26f), text, _sectionStyle); y += 32f; } private void DrawToggleRow(string label, ref float y, float width, ConfigEntry entry) { //IL_0014: 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_009e: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(12f, y, width - 24f, 42f), (Texture)(object)_rowTex); GUI.Label(new Rect(24f, y + 9f, width - 160f, 24f), label, _labelStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(width - 118f, y + 5f, 82f, 32f); GUIStyle val2 = (entry.Value ? _switchOnStyle : _switchOffStyle); string text = (entry.Value ? "ON" : "OFF"); if (GUI.Button(val, text, val2)) { entry.Value = !entry.Value; ((BaseUnityPlugin)this).Config.Save(); } y += 50f; } private void DrawTextFieldRow(string label, ref float y, float width, ref string tempValue, Action onChanged, Action onStep, int step = 5) { //IL_0014: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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) GUI.DrawTexture(new Rect(12f, y, width - 24f, 42f), (Texture)(object)_rowTex); GUI.Label(new Rect(24f, y + 9f, width - 230f, 24f), label, _labelStyle); Rect val = default(Rect); ((Rect)(ref val))..ctor(width - 196f, y + 6f, 32f, 28f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(width - 158f, y + 6f, 94f, 28f); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(width - 58f, y + 6f, 32f, 28f); if (GUI.Button(val, "-", _buttonStyle)) { onStep(-Mathf.Abs(step)); GUI.FocusControl((string)null); } GUIStyle val4 = (((Rect)(ref val2)).Contains(Event.current.mousePosition) ? _textFieldHoverStyle : _textFieldStyle); string text = GUI.TextField(val2, tempValue, val4); if (text != tempValue) { tempValue = text; onChanged(text); } if (GUI.Button(val3, "+", _buttonStyle)) { onStep(Mathf.Abs(step)); GUI.FocusControl((string)null); } y += 50f; } private void SyncTempValuesFromConfig() { _tempWaitTimeMin = ModConfig.WaitTimeMin.Value.ToString(); _tempWaitTimeMax = ModConfig.WaitTimeMax.Value.ToString(); } private void ResetSimpleDefaults() { ModConfig.ShowSettingsButton.Value = true; ModConfig.EnableChaosMaster.Value = true; ModConfig.EnableItemRandomization.Value = true; ModConfig.EnableRandomEvents.Value = true; ModConfig.EnableTornadoAtKiln.Value = false; ModConfig.WaitTimeMin.Value = 30; ModConfig.WaitTimeMax.Value = 60; ModConfig.MesaSunDurationMin.Value = 10; ModConfig.MesaSunDurationMax.Value = 30; ModConfig.TropicsRain.Value = 0; ModConfig.RootsWindRandom.Value = 0; ModConfig.AlpineSnowRandom.Value = 0; ModConfig.MesaSunRandom.Value = 0; ModConfig.PitonPatch.Value = 35; ModConfig.ChainCache.Value = 22; ModConfig.ToxicBounceShroom.Value = 28; ModConfig.LowGravityShroom.Value = 18; ModConfig.SleepySpores.Value = 12; ModConfig.FungusCloud.Value = 14; ClampTimeRange(); ClampSunDurationRange(); ((BaseUnityPlugin)this).Config.Save(); } private void ClampTimeRange() { if (ModConfig.WaitTimeMin.Value < 1) { ModConfig.WaitTimeMin.Value = 1; } if (ModConfig.WaitTimeMax.Value < ModConfig.WaitTimeMin.Value) { ModConfig.WaitTimeMax.Value = ModConfig.WaitTimeMin.Value; } } private void ClampSunDurationRange() { if (ModConfig.MesaSunDurationMin.Value < 1) { ModConfig.MesaSunDurationMin.Value = 1; } if (ModConfig.MesaSunDurationMax.Value < ModConfig.MesaSunDurationMin.Value) { ModConfig.MesaSunDurationMax.Value = ModConfig.MesaSunDurationMin.Value; } } private void EnsureGuiStyles() { //IL_002b: 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_0077: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Expected O, but got Unknown //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Expected O, but got Unknown //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Expected O, but got Unknown //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0677: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06b1: Expected O, but got Unknown //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Expected O, but got Unknown //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Expected O, but got Unknown //IL_07b6: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_07da: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0822: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_0846: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Expected O, but got Unknown //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08cc: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Expected O, but got Unknown //IL_091f: Unknown result type (might be due to invalid IL or missing references) //IL_0929: Expected O, but got Unknown //IL_0979: Unknown result type (might be due to invalid IL or missing references) //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_09a5: Unknown result type (might be due to invalid IL or missing references) //IL_09e2: Unknown result type (might be due to invalid IL or missing references) //IL_09ec: Expected O, but got Unknown //IL_09f8: Unknown result type (might be due to invalid IL or missing references) //IL_0a02: Expected O, but got Unknown //IL_0a52: Unknown result type (might be due to invalid IL or missing references) //IL_0a68: Unknown result type (might be due to invalid IL or missing references) //IL_0a7e: Unknown result type (might be due to invalid IL or missing references) //IL_0abb: Unknown result type (might be due to invalid IL or missing references) //IL_0ac5: Expected O, but got Unknown if (_buttonStyle == null) { _btnTex = MakeTexture(2, 2, new Color(0.16f, 0.45f, 0.86f, 1f)); _btnHoverTex = MakeTexture(2, 2, new Color(0.1f, 0.35f, 0.75f, 1f)); _windowTex = MakeTexture(2, 2, new Color(0.97f, 0.98f, 1f, 1f)); _fieldTex = MakeTexture(2, 2, new Color(1f, 1f, 1f, 1f)); _accentTex = MakeTexture(2, 2, new Color(0.1f, 0.3f, 0.62f, 1f)); _rowTex = MakeTexture(2, 2, new Color(0.9f, 0.94f, 0.99f, 1f)); _switchOnTex = MakeTexture(2, 2, new Color(0.12f, 0.62f, 0.29f, 1f)); _switchOnHoverTex = MakeTexture(2, 2, new Color(0.08f, 0.54f, 0.24f, 1f)); _switchOffTex = MakeTexture(2, 2, new Color(0.42f, 0.48f, 0.56f, 1f)); _switchOffHoverTex = MakeTexture(2, 2, new Color(0.34f, 0.4f, 0.48f, 1f)); _dimTex = MakeTexture(2, 2, new Color(0f, 0f, 0f, 0.42f)); _buttonStyle = new GUIStyle(GUI.skin.button); _buttonStyle.normal.background = _btnTex; _buttonStyle.hover.background = _btnHoverTex; _buttonStyle.active.background = _btnHoverTex; _buttonStyle.normal.textColor = Color.white; _buttonStyle.hover.textColor = Color.white; _buttonStyle.active.textColor = Color.white; _buttonStyle.fontSize = 15; _buttonStyle.fontStyle = (FontStyle)1; _buttonStyle.alignment = (TextAnchor)4; _buttonStyle.border = new RectOffset(0, 0, 0, 0); _buttonStyle.padding = new RectOffset(8, 8, 4, 4); _windowStyle = new GUIStyle(GUI.skin.window); _windowStyle.normal.background = _windowTex; _windowStyle.onNormal.background = _windowTex; _windowStyle.border = new RectOffset(0, 0, 0, 0); _windowStyle.padding = new RectOffset(0, 0, 0, 0); _titleStyle = new GUIStyle(GUI.skin.label); _titleStyle.fontSize = 19; _titleStyle.fontStyle = (FontStyle)1; _titleStyle.normal.textColor = Color.white; _titleStyle.alignment = (TextAnchor)3; _sectionStyle = new GUIStyle(GUI.skin.label); _sectionStyle.fontSize = 16; _sectionStyle.fontStyle = (FontStyle)1; _sectionStyle.normal.textColor = new Color(0.08f, 0.24f, 0.48f, 1f); _labelStyle = new GUIStyle(GUI.skin.label); _labelStyle.fontSize = 15; _labelStyle.normal.textColor = new Color(0.12f, 0.18f, 0.26f, 1f); _labelStyle.alignment = (TextAnchor)3; _hintStyle = new GUIStyle(GUI.skin.label); _hintStyle.fontSize = 13; _hintStyle.normal.textColor = new Color(0.22f, 0.28f, 0.36f, 1f); _textFieldStyle = new GUIStyle(GUI.skin.textField); _textFieldStyle.normal.background = _fieldTex; _textFieldStyle.hover.background = _fieldTex; _textFieldStyle.focused.background = _fieldTex; _textFieldStyle.active.background = _fieldTex; _textFieldStyle.onNormal.background = _fieldTex; _textFieldStyle.onHover.background = _fieldTex; _textFieldStyle.onFocused.background = _fieldTex; _textFieldStyle.onActive.background = _fieldTex; _textFieldStyle.normal.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.hover.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.focused.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.active.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.onNormal.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.onHover.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.onFocused.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.onActive.textColor = new Color(0.1f, 0.14f, 0.2f, 1f); _textFieldStyle.fontSize = 15; _textFieldStyle.alignment = (TextAnchor)4; _textFieldStyle.border = new RectOffset(0, 0, 0, 0); _textFieldStyle.padding = new RectOffset(6, 6, 4, 4); _textFieldHoverStyle = new GUIStyle(_textFieldStyle); Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.07f, 0.26f, 0.64f, 1f); _textFieldHoverStyle.normal.background = _fieldTex; _textFieldHoverStyle.hover.background = _fieldTex; _textFieldHoverStyle.focused.background = _fieldTex; _textFieldHoverStyle.active.background = _fieldTex; _textFieldHoverStyle.onNormal.background = _fieldTex; _textFieldHoverStyle.onHover.background = _fieldTex; _textFieldHoverStyle.onFocused.background = _fieldTex; _textFieldHoverStyle.onActive.background = _fieldTex; _textFieldHoverStyle.normal.textColor = textColor; _textFieldHoverStyle.hover.textColor = textColor; _textFieldHoverStyle.focused.textColor = textColor; _textFieldHoverStyle.active.textColor = textColor; _textFieldHoverStyle.onNormal.textColor = textColor; _textFieldHoverStyle.onHover.textColor = textColor; _textFieldHoverStyle.onFocused.textColor = textColor; _textFieldHoverStyle.onActive.textColor = textColor; _switchOnStyle = new GUIStyle(GUI.skin.button); _switchOnStyle.normal.background = _switchOnTex; _switchOnStyle.hover.background = _switchOnHoverTex; _switchOnStyle.active.background = _switchOnHoverTex; _switchOnStyle.normal.textColor = Color.white; _switchOnStyle.hover.textColor = Color.white; _switchOnStyle.active.textColor = Color.white; _switchOnStyle.fontSize = 15; _switchOnStyle.fontStyle = (FontStyle)1; _switchOnStyle.alignment = (TextAnchor)4; _switchOnStyle.border = new RectOffset(0, 0, 0, 0); _switchOffStyle = new GUIStyle(GUI.skin.button); _switchOffStyle.normal.background = _switchOffTex; _switchOffStyle.hover.background = _switchOffHoverTex; _switchOffStyle.active.background = _switchOffHoverTex; _switchOffStyle.normal.textColor = Color.white; _switchOffStyle.hover.textColor = Color.white; _switchOffStyle.active.textColor = Color.white; _switchOffStyle.fontSize = 15; _switchOffStyle.fontStyle = (FontStyle)1; _switchOffStyle.alignment = (TextAnchor)4; _switchOffStyle.border = new RectOffset(0, 0, 0, 0); _closeStyle = new GUIStyle(GUI.skin.button); _closeStyle.normal.background = _btnTex; _closeStyle.hover.background = _btnHoverTex; _closeStyle.active.background = _btnHoverTex; _closeStyle.normal.textColor = Color.white; _closeStyle.hover.textColor = Color.white; _closeStyle.active.textColor = Color.white; _closeStyle.fontSize = 14; _closeStyle.fontStyle = (FontStyle)1; _closeStyle.alignment = (TextAnchor)4; _closeStyle.border = new RectOffset(0, 0, 0, 0); } } private static Texture2D MakeTexture(int width, int height, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)5, false); ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = color; } val.SetPixels(array); val.Apply(); return val; } private static void SafeDestroy(ref Texture2D tex) { if ((Object)(object)tex != (Object)null) { Object.DestroyImmediate((Object)(object)tex); tex = null; } } } public static class ModConfig { public static ConfigEntry EnableChaosMaster { get; private set; } public static ConfigEntry WaitTimeMin { get; private set; } public static ConfigEntry WaitTimeMax { get; private set; } public static ConfigEntry EnableItemRandomization { get; private set; } public static ConfigEntry EnableRandomEvents { get; private set; } public static ConfigEntry TropicsRain { get; private set; } public static ConfigEntry RootsWindRandom { get; private set; } public static ConfigEntry AlpineSnowRandom { get; private set; } public static ConfigEntry MesaSunRandom { get; private set; } public static ConfigEntry MesaSunDurationMin { get; private set; } public static ConfigEntry MesaSunDurationMax { get; private set; } public static ConfigEntry ShowSettingsButton { get; private set; } public static ConfigEntry SettingsButtonTopOffset { get; private set; } public static ConfigEntry ToggleGuiKey { get; private set; } public static ConfigEntry Tornado { get; private set; } public static ConfigEntry Tick { get; private set; } public static ConfigEntry Bees { get; private set; } public static ConfigEntry Tumbleweed { get; private set; } public static ConfigEntry Dynamite { get; private set; } public static ConfigEntry Zombie { get; private set; } public static ConfigEntry Mandrake { get; private set; } public static ConfigEntry Cactus { get; private set; } public static ConfigEntry RandomItem { get; private set; } public static ConfigEntry RandomGoodItem { get; private set; } public static ConfigEntry RandomGoodItemRain { get; private set; } public static ConfigEntry BingBongRain { get; private set; } public static ConfigEntry CureAll { get; private set; } public static ConfigEntry Pandora { get; private set; } public static ConfigEntry SwapPlayers { get; private set; } public static ConfigEntry WarpToLastPlayer { get; private set; } public static ConfigEntry SwapPlayerItems { get; private set; } public static ConfigEntry SwapPlayerStatuses { get; private set; } public static ConfigEntry ReviveOne { get; private set; } public static ConfigEntry ReviveAll { get; private set; } public static ConfigEntry HealShroom { get; private set; } public static ConfigEntry BounceShroom { get; private set; } public static ConfigEntry MoraleBoost { get; private set; } public static ConfigEntry Scorpion { get; private set; } public static ConfigEntry RandomBackpackGood { get; private set; } public static ConfigEntry RandomBackpack { get; private set; } public static ConfigEntry Beanstalk { get; private set; } public static ConfigEntry BeanstalkSpam { get; private set; } public static ConfigEntry EnergyDrink { get; private set; } public static ConfigEntry Lollipop { get; private set; } public static ConfigEntry Milk { get; private set; } public static ConfigEntry UnlimitedPower { get; private set; } public static ConfigEntry TwoAtOnce { get; private set; } public static ConfigEntry Skeleton { get; private set; } public static ConfigEntry TieBalloon { get; private set; } public static ConfigEntry TieThreeBalloons { get; private set; } public static ConfigEntry Web { get; private set; } public static ConfigEntry Antirope { get; private set; } public static ConfigEntry PitonPatch { get; private set; } public static ConfigEntry ChainCache { get; private set; } public static ConfigEntry ToxicBounceShroom { get; private set; } public static ConfigEntry LowGravityShroom { get; private set; } public static ConfigEntry SleepySpores { get; private set; } public static ConfigEntry FungusCloud { get; private set; } public static ConfigEntry DayNight { get; private set; } public static ConfigEntry Eruption { get; private set; } public static ConfigEntry EnableTornadoAtKiln { get; private set; } public static ConfigEntry ExtendedDynamiteChance { get; private set; } public static ConfigEntry BoobyTrappedBackpacksChance { get; private set; } public static void Startup(ConfigFile config) { EnableChaosMaster = config.Bind("General", "EnableChaosMaster", true, "Master switch. OFF = disable random loot and random events."); EnableItemRandomization = config.Bind("General", "EnableItemRandomization", true, "Enable randomized item spawns."); EnableRandomEvents = config.Bind("General", "EnableRandomEvents", true, "Enable random events."); WaitTimeMin = config.Bind("Events.Timer", "WaitTimeMin", 30, "Minimum seconds between random events."); WaitTimeMax = config.Bind("Events.Timer", "WaitTimeMax", 60, "Maximum seconds between random events."); ShowSettingsButton = config.Bind("GUI", "ShowSettingsButton", true, "Show the in-game settings button."); SettingsButtonTopOffset = config.Bind("GUI", "SettingsButtonTopOffset", 66f, "Top offset of the settings button."); ToggleGuiKey = config.Bind("GUI", "ToggleGuiKey", (KeyCode)289, "Keyboard key to open/close the chaos settings window."); EnableTornadoAtKiln = config.Bind("Events.Settings", "EnableTornadoAtKiln", false, "Enable Tornado at Kiln."); ExtendedDynamiteChance = config.Bind("Events.Settings", "ExtendedDynamiteChance", 0.1f, "Chance for extended dynamite."); BoobyTrappedBackpacksChance = config.Bind("Events.Settings", "BoobyTrappedBackpacksChance", 0.1f, "Chance for troll backpack."); MesaSunDurationMin = config.Bind("Events.Settings", "MesaSunDurationMin", 10, "Minimum duration in seconds for random global hot sun / sunburn event."); MesaSunDurationMax = config.Bind("Events.Settings", "MesaSunDurationMax", 30, "Maximum duration in seconds for random global hot sun / sunburn event."); TropicsRain = config.Bind("Events.Weights", "TropicsRain", 0, "Default 0 = disabled unless explicitly enabled."); RootsWindRandom = config.Bind("Events.Weights", "RootsWindRandom", 0, "Default 0 = disabled unless explicitly enabled."); AlpineSnowRandom = config.Bind("Events.Weights", "AlpineSnowRandom", 0, "Default 0 = disabled unless explicitly enabled."); MesaSunRandom = config.Bind("Events.Weights", "MesaSunRandom", 0, "Default 0 = disabled unless explicitly enabled."); Tornado = config.Bind("Events.Weights", "Tornado", 50, ""); Tick = config.Bind("Events.Weights", "Tick", 70, ""); Bees = config.Bind("Events.Weights", "Bees", 10, ""); Tumbleweed = config.Bind("Events.Weights", "Tumbleweed", 100, ""); Dynamite = config.Bind("Events.Weights", "Dynamite", 20, ""); Zombie = config.Bind("Events.Weights", "Zombie", 60, ""); Mandrake = config.Bind("Events.Weights", "Mandrake", 90, ""); Cactus = config.Bind("Events.Weights", "Cactus", 100, ""); RandomItem = config.Bind("Events.Weights", "RandomItem", 100, ""); RandomGoodItem = config.Bind("Events.Weights", "RandomGoodItem", 20, ""); RandomGoodItemRain = config.Bind("Events.Weights", "RandomGoodItemRain", 10, ""); BingBongRain = config.Bind("Events.Weights", "BingBongRain", 15, ""); CureAll = config.Bind("Events.Weights", "CureAll", 20, ""); Pandora = config.Bind("Events.Weights", "Pandora", 50, ""); SwapPlayers = config.Bind("Events.Weights", "SwapPlayers", 60, ""); WarpToLastPlayer = config.Bind("Events.Weights", "WarpToLowestPlayer", 10, ""); SwapPlayerItems = config.Bind("Events.Weights", "SwapPlayerItems", 50, ""); SwapPlayerStatuses = config.Bind("Events.Weights", "SwapPlayerStatuses", 45, "Swap part or all of player statuses except backpack weight."); ReviveOne = config.Bind("Events.Weights", "ReviveOne", 20, ""); ReviveAll = config.Bind("Events.Weights", "ReviveAll", 10, ""); HealShroom = config.Bind("Events.Weights", "HealShroom", 40, ""); BounceShroom = config.Bind("Events.Weights", "BounceShroom", 80, ""); MoraleBoost = config.Bind("Events.Weights", "MoraleBoost", 50, ""); Scorpion = config.Bind("Events.Weights", "Scorpion", 60, ""); RandomBackpack = config.Bind("Events.Weights", "RandomBackpack", 60, ""); RandomBackpackGood = config.Bind("Events.Weights", "RandomBackpackGood", 10, ""); Beanstalk = config.Bind("Events.Weights", "Beanstalk", 40, ""); BeanstalkSpam = config.Bind("Events.Weights", "BeanstalkSpam", 10, ""); EnergyDrink = config.Bind("Events.Weights", "EnergyDrink", 30, ""); Lollipop = config.Bind("Events.Weights", "Lollipop", 30, ""); Milk = config.Bind("Events.Weights", "Milk", 30, ""); UnlimitedPower = config.Bind("Events.Weights", "UnlimitedPower", 10, ""); TwoAtOnce = config.Bind("Events.Weights", "TwoAtOnce", 20, ""); Skeleton = config.Bind("Events.Weights", "Skeleton", 10, ""); TieBalloon = config.Bind("Events.Weights", "TieBalloon", 30, ""); TieThreeBalloons = config.Bind("Events.Weights", "TieThreeBalloons", 10, ""); Web = config.Bind("Events.Weights", "Web", 58, ""); Antirope = config.Bind("Events.Weights", "Antirope", 20, ""); PitonPatch = config.Bind("Events.Weights", "PitonPatch", 35, "Place 1-3 vanilla pitons on nearby walls, roughly 2-4m above random players. Host only chooses placement; spawned pitons are vanilla network objects."); ChainCache = config.Bind("Events.Weights", "ChainCache", 22, "Place vanilla ChainShooter chains from near player feet toward a valid TerrainMap point 5-30m away; falls back to giving the item if no safe placement is found."); ToxicBounceShroom = config.Bind("Events.Weights", "ToxicBounceShroom", 28, "Spawn small vanilla bounce-shroom traps and apply light poison/spores to selected players."); LowGravityShroom = config.Bind("Events.Weights", "LowGravityShroom", 18, "Feed a vanilla mushroom whose current run effect is low gravity, when one can be found."); SleepySpores = config.Bind("Events.Weights", "SleepySpores", 12, "Light drowsy/spore effect for a few random players. Lower weight and lower intensity because it is negative."); FungusCloud = config.Bind("Events.Weights", "FungusCloud", 14, "Small vanilla spore-cloud burst around one player, affecting only nearby players."); DayNight = config.Bind("Events.Weights", "DayNightSwap", 30, ""); Eruption = config.Bind("Events.Weights", "Eruption", 70, ""); if (TropicsRain.Value == 35 && RootsWindRandom.Value == 35 && AlpineSnowRandom.Value == 25 && MesaSunRandom.Value == 30) { TropicsRain.Value = 0; RootsWindRandom.Value = 0; AlpineSnowRandom.Value = 0; MesaSunRandom.Value = 0; config.Save(); } } } public static class CustomLoot { public static readonly HashSet ExcludedItemNames = new HashSet { "Cheat Compass", "ScoutCookies_Vanilla", "ClimbingChalk", "Skull", "Warp Compass", "AncientIdol", "Passport" }; public static readonly HashSet ExcludedItemPrefixes = new HashSet { "C_", "Guidebook" }; public static readonly HashSet ExcludedItemSuffixes = new HashSet { "_Prop", "_Prop Variant", "_TEMP", "Spawn", "Placed" }; public static readonly HashSet UnsafeForRandomLootNames = new HashSet { "BingBong", "BugfixOnYou", "BeeSwarm", "TumbleWeed", "MushroomZombie", "RopeAnchorForRopeShooterAnti", "BounceShroomSpawn", "HealingPuffShroomSpawn", "ShelfShroomSpawn", "Anti-Rope Spool", "RopeShooterAnti", "RopeShooter", "VineShooter", "VineShooter Variant", "BananaPeel", "Banana Peel" }; public static readonly HashSet UnsafeForRandomEventItemNames = new HashSet { "Backpack", "BingBong", "BugfixOnYou", "BeeSwarm", "TumbleWeed", "MushroomZombie", "RopeAnchorForRopeShooterAnti", "BounceShroomSpawn", "HealingPuffShroomSpawn", "ShelfShroomSpawn", "Anti-Rope Spool", "RopeShooterAnti", "RopeShooter", "VineShooter", "VineShooter Variant", "BananaPeel", "Banana Peel" }; public static readonly HashSet UnsafeForBushLootNames = new HashSet { "Dynamite", "CactusBall", "Mandrake", "Scorpion", "MagicBean", "PandorasBox", "BingBong", "BugfixOnYou", "BeeSwarm", "TumbleWeed", "MushroomZombie", "RopeAnchorForRopeShooterAnti", "BounceShroomSpawn", "HealingPuffShroomSpawn", "ShelfShroomSpawn", "Backpack", "Anti-Rope Spool", "RopeShooterAnti", "BalloonBunch", "ChainShooter", "Flag_Plantable_Checkpoint" }; public static readonly HashSet TrollItems = new HashSet { "CactusBall", "Mandrake", "Dynamite", "Scorpion" }; public static readonly Dictionary MaxSpawnCountByItemName = new Dictionary { { "RescueHook_Infinite", 1 } }; private static readonly HashSet GoodItemsBasic = new HashSet { "Lantern_Faerie", "ChainShooter", "Cure-All", "FirstAidKit", "Glizzy", "Winterberry Yellow", "PandorasBox", "EggTurkey", "Napberry", "Flag_Plantable_Checkpoint" }; private static readonly HashSet GoodItemsMultiplayer = new HashSet { "Bugle_Magic", "ScoutEffigy", "HealingDart Variant" }; private static readonly HashSet GoodItemsFloaty = new HashSet { "BalloonBunch" }; private static readonly Dictionary SpawnedCountByItemName = new Dictionary(); private static readonly object CacheLock = new object(); private static Dictionary? _baseFilteredAllCache; private static Dictionary? _baseFilteredLootCache; private static Dictionary? _baseFilteredBushCache; private static Dictionary? _baseFilteredEventCache; private static Dictionary? _availableAllItemsCache; private static Dictionary? _availableLootItemsCache; private static Dictionary? _availableBushItemsCache; private static Dictionary? _availableEventItemsCache; private static bool _availableCachesDirty = true; public static readonly HashSet UnsafeForHangingLootNames = new HashSet { "Dynamite", "CactusBall", "Mandrake", "Scorpion", "MagicBean", "PandorasBox", "BingBong", "BugfixOnYou", "BeeSwarm", "TumbleWeed", "MushroomZombie", "RopeAnchorForRopeShooterAnti", "BounceShroomSpawn", "HealingPuffShroomSpawn", "ShelfShroomSpawn", "BalloonBunch", "Anti-Rope Spool", "RopeShooterAnti", "ChainShooter", "Flag_Plantable_Checkpoint", "Backpack" }; public static HashSet GoodItems { get { IEnumerable enumerable = new HashSet().Concat(GoodItemsBasic); if (Character.AllCharacters.Count((Character c) => (Object)(object)c != (Object)null && !c.isBot) > 1) { enumerable = enumerable.Concat(GoodItemsMultiplayer); } return enumerable.ToHashSet(); } } public static HashSet GoodItemsBackpack { get { IEnumerable first = new HashSet().Concat(GoodItemsBasic); if (Character.AllCharacters.Count((Character c) => (Object)(object)c != (Object)null && !c.isBot) > 1) { first = first.Concat(GoodItemsMultiplayer); } first = first.Concat(GoodItemsFloaty); return first.ToHashSet(); } } public static void ResetRuntimeState() { lock (CacheLock) { SpawnedCountByItemName.Clear(); _baseFilteredAllCache = null; _baseFilteredLootCache = null; _baseFilteredBushCache = null; _baseFilteredEventCache = null; _availableAllItemsCache = null; _availableLootItemsCache = null; _availableBushItemsCache = null; _availableEventItemsCache = null; _availableCachesDirty = true; } } public static void NotifyFiltersChanged() { lock (CacheLock) { _availableAllItemsCache = null; _availableLootItemsCache = null; _availableBushItemsCache = null; _availableEventItemsCache = null; _availableCachesDirty = true; } } private static bool IsHardExcluded(string itemName) { string itemName2 = itemName; if (ExcludedItemNames.Contains(itemName2)) { return true; } if (ExcludedItemPrefixes.Any((string prefix) => itemName2.StartsWith(prefix))) { return true; } if (ExcludedItemSuffixes.Any((string suffix) => itemName2.EndsWith(suffix))) { return true; } if (MaxSpawnCountByItemName.TryGetValue(itemName2, out var value) && value <= 0) { return true; } return false; } private static bool IsBlockedBySpawnLimit(string itemName) { if (!MaxSpawnCountByItemName.TryGetValue(itemName, out var value)) { return false; } int value2; int num = (SpawnedCountByItemName.TryGetValue(itemName, out value2) ? value2 : 0); return num >= value; } public static void MarkSpawned(string itemName) { if (MaxSpawnCountByItemName.ContainsKey(itemName)) { if (!SpawnedCountByItemName.ContainsKey(itemName)) { SpawnedCountByItemName[itemName] = 0; } SpawnedCountByItemName[itemName]++; _availableCachesDirty = true; } } public static Dictionary GetHangingItemsDatabaseFiltered() { ItemDatabase instance = SingletonAsset.Instance; return instance.itemLookup.Where((KeyValuePair pair) => (Object)(object)pair.Value != (Object)null && !IsHardExcluded(((Object)pair.Value).name) && !UnsafeForRandomLootNames.Contains(((Object)pair.Value).name) && !UnsafeForHangingLootNames.Contains(((Object)pair.Value).name) && pair.Value.IsValidToSpawn() && pair.Value.UIData != null && pair.Value.UIData.canPocket && pair.Value.UIData.canDrop).ToDictionary((KeyValuePair pair) => pair.Key, (KeyValuePair pair) => pair.Value); } public static bool TryGetRandomHangingLootItem(out Item item) { item = null; Dictionary hangingItemsDatabaseFiltered = GetHangingItemsDatabaseFiltered(); if (hangingItemsDatabaseFiltered.Count == 0) { return false; } item = hangingItemsDatabaseFiltered.ElementAt(Random.Range(0, hangingItemsDatabaseFiltered.Count)).Value; return (Object)(object)item != (Object)null; } private static bool IsSafeInventoryItem(Item item) { if ((Object)(object)item == (Object)null) { return false; } if (!item.IsValidToSpawn()) { return false; } if (item.UIData == null) { return false; } if (!item.UIData.canPocket) { return false; } if (!item.UIData.canDrop) { return false; } return true; } private static bool IsSafeRandomEventItem(Item item) { if ((Object)(object)item == (Object)null) { return false; } if (!item.IsValidToSpawn()) { return false; } if (item.UIData == null) { return false; } if (!item.UIData.canDrop) { return false; } if (UnsafeForRandomLootNames.Contains(((Object)item).name) || UnsafeForRandomEventItemNames.Contains(((Object)item).name)) { return false; } return true; } private static bool IsSafeBushItem(Item item) { if (!IsSafeInventoryItem(item)) { return false; } return !UnsafeForBushLootNames.Contains(((Object)item).name); } private static Dictionary BuildBaseFiltered(bool lootOnly, bool bushOnly, bool eventOnly = false) { ItemDatabase instance = SingletonAsset.Instance; return instance.itemLookup.Where((KeyValuePair pair) => (Object)(object)pair.Value != (Object)null && (eventOnly ? IsSafeRandomEventItem(pair.Value) : IsSafeInventoryItem(pair.Value)) && !IsHardExcluded(((Object)pair.Value).name) && (!lootOnly || !UnsafeForRandomLootNames.Contains(((Object)pair.Value).name)) && (!bushOnly || IsSafeBushItem(pair.Value))).ToDictionary((KeyValuePair pair) => pair.Key, (KeyValuePair pair) => pair.Value); } private static Dictionary BuildAvailableFromBase(Dictionary baseCache) { return baseCache.Where>((KeyValuePair pair) => !IsBlockedBySpawnLimit(((Object)pair.Value).name)).ToDictionary((KeyValuePair pair) => pair.Key, (KeyValuePair pair) => pair.Value); } private static void EnsureAvailableCaches() { lock (CacheLock) { if (_baseFilteredAllCache == null) { _baseFilteredAllCache = BuildBaseFiltered(lootOnly: false, bushOnly: false); } if (_baseFilteredLootCache == null) { _baseFilteredLootCache = BuildBaseFiltered(lootOnly: true, bushOnly: false); } if (_baseFilteredBushCache == null) { _baseFilteredBushCache = BuildBaseFiltered(lootOnly: true, bushOnly: true); } if (_baseFilteredEventCache == null) { _baseFilteredEventCache = BuildBaseFiltered(lootOnly: false, bushOnly: false, eventOnly: true); } if (_availableCachesDirty || _availableAllItemsCache == null || _availableLootItemsCache == null || _availableBushItemsCache == null || _availableEventItemsCache == null) { _availableAllItemsCache = BuildAvailableFromBase(_baseFilteredAllCache); _availableLootItemsCache = BuildAvailableFromBase(_baseFilteredLootCache); _availableBushItemsCache = BuildAvailableFromBase(_baseFilteredBushCache); _availableEventItemsCache = BuildAvailableFromBase(_baseFilteredEventCache); _availableCachesDirty = false; } } } public static ushort GetRandomId() { EnsureAvailableCaches(); Dictionary availableEventItemsCache = _availableEventItemsCache; if (availableEventItemsCache.Count == 0) { return 0; } Dictionary.KeyCollection keys = availableEventItemsCache.Keys; return keys.ElementAt(Random.Range(0, keys.Count)); } public static Dictionary GetItemsDatabaseFiltered() { EnsureAvailableCaches(); return _availableAllItemsCache; } public static Dictionary GetEventItemsDatabaseFiltered() { EnsureAvailableCaches(); return _availableEventItemsCache; } public static Dictionary GetLootItemsDatabaseFiltered() { EnsureAvailableCaches(); return _availableLootItemsCache; } public static Dictionary GetBushItemsDatabaseFiltered() { EnsureAvailableCaches(); return _availableBushItemsCache; } public static bool TryGetRandomItem(out Item item) { item = null; Dictionary itemsDatabaseFiltered = GetItemsDatabaseFiltered(); if (itemsDatabaseFiltered.Count == 0) { return false; } item = itemsDatabaseFiltered.ElementAt(Random.Range(0, itemsDatabaseFiltered.Count)).Value; return (Object)(object)item != (Object)null; } public static bool TryGetRandomEventItem(out Item item) { item = null; Dictionary eventItemsDatabaseFiltered = GetEventItemsDatabaseFiltered(); if (eventItemsDatabaseFiltered.Count == 0) { return false; } item = eventItemsDatabaseFiltered.ElementAt(Random.Range(0, eventItemsDatabaseFiltered.Count)).Value; return (Object)(object)item != (Object)null; } public static bool TryGetRandomLootItem(out Item item) { item = null; Dictionary lootItemsDatabaseFiltered = GetLootItemsDatabaseFiltered(); if (lootItemsDatabaseFiltered.Count == 0) { return false; } item = lootItemsDatabaseFiltered.ElementAt(Random.Range(0, lootItemsDatabaseFiltered.Count)).Value; return (Object)(object)item != (Object)null; } public static bool TryGetRandomBushLootItem(out Item item) { item = null; Dictionary bushItemsDatabaseFiltered = GetBushItemsDatabaseFiltered(); if (bushItemsDatabaseFiltered.Count == 0) { return false; } item = bushItemsDatabaseFiltered.ElementAt(Random.Range(0, bushItemsDatabaseFiltered.Count)).Value; return (Object)(object)item != (Object)null; } } public static class LootTablePatch { [ThreadStatic] private static int _suppressGenericLootRandomizationDepth; private static readonly int TerrainMask = LayerMask.GetMask(new string[2] { "Terrain", "Map" }); private static bool IsGenericLootRandomizationSuppressed() { return _suppressGenericLootRandomizationDepth > 0; } private static void PushGenericLootRandomizationSuppression() { _suppressGenericLootRandomizationDepth++; } private static void PopGenericLootRandomizationSuppression() { if (_suppressGenericLootRandomizationDepth > 0) { _suppressGenericLootRandomizationDepth--; } } [HarmonyPatch(typeof(LootData), "GetRandomItem")] [HarmonyPrefix] private static bool PrefixGetRandomItem(SpawnPool spawnPool, ref GameObject __result) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected I4, but got Unknown if (!Plugin.IsGameplayScene()) { return true; } if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableItemRandomization.Value) { return true; } if (IsGenericLootRandomizationSuppressed()) { return true; } int num = (int)spawnPool; if (num == 131072 || num == 32768 || num == 65536) { return true; } if (LootData.AllSpawnWeightData == null) { LootData.PopulateLootData(); } if (CustomLoot.TryGetRandomLootItem(out Item item)) { CustomLoot.MarkSpawned(((Object)item).name); __result = ((Component)item).gameObject; return false; } return true; } [HarmonyPatch(typeof(LootData), "GetRandomItems")] [HarmonyPrefix] private static bool PrefixGetRandomItems(SpawnPool spawnPool, int count, bool canRepeat, ref List __result) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected I4, but got Unknown if (!Plugin.IsGameplayScene()) { return true; } if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableItemRandomization.Value) { return true; } if (IsGenericLootRandomizationSuppressed()) { return true; } int num = (int)spawnPool; if (num == 131072 || num == 32768 || num == 65536) { return true; } if (LootData.AllSpawnWeightData == null) { LootData.PopulateLootData(); } __result = new List(count); for (int i = 0; i < count; i++) { if (CustomLoot.TryGetRandomLootItem(out Item item)) { CustomLoot.MarkSpawned(((Object)item).name); __result.Add(((Component)item).gameObject); } } return __result.Count <= 0; } [HarmonyPatch(typeof(SpawnList), "GetSpawns")] [HarmonyPrefix] private static bool PrefixSpawnListGetSpawns(int count, bool canRepeat, ref List __result) { if (!Plugin.IsGameplayScene()) { return true; } if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableItemRandomization.Value) { return true; } if (IsGenericLootRandomizationSuppressed()) { return true; } __result = new List(count); for (int i = 0; i < count; i++) { if (CustomLoot.TryGetRandomLootItem(out Item item)) { CustomLoot.MarkSpawned(((Object)item).name); __result.Add(((Component)item).gameObject); } } return __result.Count <= 0; } [HarmonyPatch(typeof(SpawnList), "GetSingleSpawn")] [HarmonyPrefix] private static bool PrefixSpawnListGetSingleSpawn(ref GameObject __result) { if (!Plugin.IsGameplayScene()) { return true; } if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableItemRandomization.Value) { return true; } if (IsGenericLootRandomizationSuppressed()) { return true; } if (CustomLoot.TryGetRandomLootItem(out Item item)) { CustomLoot.MarkSpawned(((Object)item).name); __result = ((Component)item).gameObject; return false; } return true; } [HarmonyPatch(typeof(BerryBush), "SpawnItems")] [HarmonyPrefix] private static bool PrefixBerryBushSpawnItems(BerryBush __instance, List spawnSpots, ref List __result) { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Invalid comparison between Unknown and I4 //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) List list = (__result = new List()); if (!Plugin.IsGameplayScene()) { return true; } if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableItemRandomization.Value) { return true; } if (!PhotonNetwork.IsMasterClient) { return false; } if ((Object)(object)__instance == (Object)null || spawnSpots == null || spawnSpots.Count == 0) { return false; } List list2 = spawnSpots.Where((Transform s) => (Object)(object)s != (Object)null).ToList(); if (list2.Count == 0) { return false; } float num = Mathf.Pow(Random.value, __instance.randomPow); int num2 = Mathf.RoundToInt(Mathf.Lerp(__instance.possibleBerries.x, __instance.possibleBerries.y, num)); num2 = Mathf.Clamp(num2, 0, list2.Count); for (int i = 0; i < num2 && list2.Count != 0; i++) { int index = Random.Range(0, list2.Count); Transform val = list2[index]; list2.RemoveAt(index); if ((Object)(object)val == (Object)null) { continue; } GameObject val2 = null; Item item; if ((int)((Spawner)__instance).spawnMode == 0) { val2 = ((Spawner)__instance).spawnedObjectPrefab; } else if (CustomLoot.TryGetRandomBushLootItem(out item) && (Object)(object)item != (Object)null) { CustomLoot.MarkSpawned(((Object)item).name); val2 = ((Component)item).gameObject; } if ((Object)(object)val2 == (Object)null || string.IsNullOrEmpty(((Object)val2).name)) { continue; } GameObject val3; try { val3 = PhotonNetwork.InstantiateItemRoom(((Object)val2).name, val.position, Quaternion.identity); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"BerryBush spawn failed: {((Object)val2).name}, {arg}"); continue; } if ((Object)(object)val3 == (Object)null) { continue; } Item component = val3.GetComponent(); PhotonView component2 = val3.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Plugin.Log.LogWarning((object)("BerryBush spawned invalid object: " + ((Object)val2).name)); try { PhotonNetwork.Destroy(val3); } catch { } continue; } list.Add(component2); if (Object.op_Implicit((Object)(object)((Spawner)__instance).spawnUpTowardsTarget) && (Object)(object)((Spawner)__instance).spawnUpTowardsTarget != (Object)null) { Vector3 val4 = ((Spawner)__instance).spawnUpTowardsTarget.position - ((Component)component).transform.position; if (((Vector3)(ref val4)).sqrMagnitude > 0.0001f) { ((Component)component).transform.up = ((Vector3)(ref val4)).normalized; ((Component)component).transform.Rotate(Vector3.up, Random.Range(0f, 360f), (Space)1); } } if (((Spawner)__instance).spawnTransformIsSpawnerTransform) { ((Component)component).transform.rotation = val.rotation; ((Component)component).transform.Rotate(Vector3.up, Random.Range(0f, 360f), (Space)1); } try { component2.RPC("SetKinematicRPC", (RpcTarget)3, new object[3] { true, ((Component)component).transform.position, ((Component)component).transform.rotation }); } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"BerryBush SetKinematicRPC failed: {arg2}"); } } __result = list; return false; } [HarmonyPatch(typeof(Spawner), "SpawnItems")] [HarmonyPrefix] private static void PrefixSpawnerSpawnItems(List spawnSpots) { if (Plugin.IsGameplayScene() && ModConfig.EnableChaosMaster.Value && ModConfig.EnableItemRandomization.Value && spawnSpots != null && spawnSpots.Count != 0 && HasAnyHangingSpot(spawnSpots)) { PushGenericLootRandomizationSuppression(); } } [HarmonyPatch(typeof(Spawner), "SpawnItems")] [HarmonyFinalizer] private static Exception? FinalizerSpawnerSpawnItems(List spawnSpots, Exception? __exception) { if (Plugin.IsGameplayScene() && ModConfig.EnableChaosMaster.Value && ModConfig.EnableItemRandomization.Value && spawnSpots != null && spawnSpots.Count > 0 && HasAnyHangingSpot(spawnSpots)) { PopGenericLootRandomizationSuppression(); } return __exception; } private static string GetTransformPath(Transform t) { if ((Object)(object)t == (Object)null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(128); Transform val = t; while ((Object)(object)val != (Object)null) { if (stringBuilder.Length > 0) { stringBuilder.Insert(0, "/"); } stringBuilder.Insert(0, ((Object)val).name); val = val.parent; } return stringBuilder.ToString(); } private static bool IsHangingSpawnSpot(Transform spot) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)spot == (Object)null) { return false; } string text = GetTransformPath(spot).ToLowerInvariant(); if (text.Contains("vine") || text.Contains("junglevine") || text.Contains("tree") || text.Contains("branch") || text.Contains("root") || text.Contains("mushroom") || text.Contains("shroom") || text.Contains("hang")) { return true; } Vector3 val = spot.position + Vector3.up * 0.15f; RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val, Vector3.down, ref val2, 1.35f, TerrainMask, (QueryTriggerInteraction)1)) { return true; } if (Vector3.Angle(((RaycastHit)(ref val2)).normal, Vector3.up) > 42f) { return true; } return false; } private static bool HasAnyHangingSpot(List spawnSpots) { if (spawnSpots == null || spawnSpots.Count == 0) { return false; } for (int i = 0; i < spawnSpots.Count; i++) { if (IsHangingSpawnSpot(spawnSpots[i])) { return true; } } return false; } } public static class AchievementManagerPatch { [HarmonyPatch(typeof(AchievementManager), "ThrowAchievement")] [HarmonyPrefix] private static bool Prefix(AchievementManager __instance) { return false; } } public static class LoadingScreenHandlerPatch { [HarmonyPatch(typeof(LoadingScreenHandler), "LoadSceneProcess")] [HarmonyPrefix] public static bool Prefix(LoadingScreenHandler __instance, string sceneName, bool networked, bool yieldForCharacterSpawn, float extraYieldTimeOnEnd, ref IEnumerator __result) { switch ((sceneName ?? string.Empty).ToLowerInvariant()) { case "airport": case "mainmenu": case "title": case "pretitle": case "wilisland": ChaosEnvironmentController.ResetLocalState(); if (PhotonNetwork.IsMasterClient) { RandomEventTask.StopTask(); CustomLoot.ResetRuntimeState(); } break; } return true; } } public static class PauseMenuMainPagePatch { [HarmonyPatch(typeof(PauseMenuMainPage), "OnQuitClicked")] [HarmonyPrefix] public static bool Prefix(PauseMenuMainPage __instance) { ChaosEnvironmentController.ResetLocalState(); if (PhotonNetwork.IsMasterClient) { RandomEventTask.StopTask(); CustomLoot.ResetRuntimeState(); } return true; } } public static class MountainProgressHandlerPatch { [HarmonyPatch(typeof(MountainProgressHandler), "TriggerReached")] [HarmonyPrefix] public static bool Prefix(MountainProgressHandler __instance, ProgressPoint progressPoint) { ChaosEnvironmentController.ResetLocalState(); if (PhotonNetwork.IsMasterClient) { if (Singleton.Instance.currentSegment == 0) { CustomLoot.ResetRuntimeState(); RandomizerEvents.ClearPendingQueues(); RandomEventTask.StartTask(); } else { RandomizerEvents.ClearPendingQueues(); QueueGarbageForCleanup(); } } return true; } private static void CollectGarbageOf(List results) where T : MonoBehaviour { //IL_00df: 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 (results == null) { return; } MapHandler instance = Singleton.Instance; if ((Object)(object)instance == (Object)null || instance.currentSegment <= 0 || instance.segments == null) { return; } int num = instance.currentSegment - 1; if (num < 0 || num >= instance.segments.Length) { return; } GameObject segmentCampfire = instance.segments[num].segmentCampfire; if ((Object)(object)segmentCampfire == (Object)null) { return; } T[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); T[] array2 = array; foreach (T val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)(object)val).gameObject == (Object)null) && segmentCampfire.transform.position.z - ((Component)(object)val).transform.position.z > 20f) { results.Add(((Component)(object)val).gameObject); } } } public static void QueueGarbageForCleanup() { List list = new List(); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); CollectGarbageOf(list); if (list.Count == 0) { return; } foreach (GameObject item in list.Distinct()) { RandomizerEvents.RemoveObjectAfterTime(item, 0f); } } } public static class GameHandlerPatch { private const int MaxEventsPerFrame = 1; private const int MaxDestroyPerFrame = 24; [HarmonyPatch(typeof(GameHandler), "Update")] [HarmonyPrefix] private static bool Prefix(GameHandler __instance) { if (!PhotonNetwork.IsMasterClient) { return true; } if (!Plugin.IsGameplayScene()) { return true; } if (ModConfig.EnableChaosMaster.Value && ModConfig.EnableRandomEvents.Value) { RandomEventTask.EnsureStarted(); } RandomizerEvents.FlushScheduledWork(); List list = RandomizerEvents.DequeueEvents(1); foreach (string name in list) { try { (string, ConfigEntry, Action) tuple = RandomizerEvents.Events.FirstOrDefault<(string, ConfigEntry, Action)>(((string name, ConfigEntry weightConfigEntry, Action action) e) => e.name == name); if (tuple.Item3 == null) { Plugin.Log.LogWarning((object)("Unknown or empty random event: " + name)); continue; } tuple.Item3(); RandomizerEvents.CleanupOrphanTemporarySlotsForAll("after " + name); } catch (Exception arg) { Plugin.Log.LogError((object)$"Error when trying to execute {name}: {arg}"); } } List list2 = RandomizerEvents.DequeueDestroy(24); foreach (GameObject item in list2) { try { if (!((Object)(object)item == (Object)null)) { PhotonView component = item.GetComponent(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)item); } else { PhotonNetwork.Destroy(item); } } } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"Destroy queue error: {arg2}"); } } return true; } } public static class TornadoCompatibilityPatch { [HarmonyPatch] private static class TornadoFixedUpdatePatch { private static bool Prepare() { Type type = AccessTools.TypeByName("Tornado"); return type != null && AccessTools.Method(type, "FixedUpdate", (Type[])null, (Type[])null) != null; } private static MethodBase TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("Tornado"), "FixedUpdate", (Type[])null, (Type[])null); } private static bool Prefix(object __instance) { if (!NeedsFallbackFixedUpdate()) { return true; } RunFallbackTornadoFixedUpdate(__instance); return false; } private static Exception? Finalizer(object __instance, Exception? __exception) { if (IsRemovedFallRpcException(__exception)) { RunFallbackTornadoFixedUpdate(__instance); return null; } return __exception; } } [HarmonyPatch] private static class TornadoCapturedCharacterPatch { private static bool Prepare() { Type type = AccessTools.TypeByName("Tornado"); return type != null && AccessTools.Method(type, "CapturedCharacter", (Type[])null, (Type[])null) != null; } private static MethodBase TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("Tornado"), "CapturedCharacter", (Type[])null, (Type[])null); } private static Exception? Finalizer(object __instance, Exception? __exception) { if (IsRemovedFallRpcException(__exception)) { RunFallbackTornadoFixedUpdate(__instance); return null; } return __exception; } } private const float FallbackMoveSpeed = 18f; private const float FallbackAffectRadius = 24f; private const float FallbackFallRadius = 9f; private const float FallbackPullImpulse = 26f; private const float FallbackLiftImpulse = 34f; private const float FallbackSpinImpulse = 22f; private const float FallbackFallSeconds = 0.85f; private const float FallbackFallCooldown = 0.9f; private static readonly Dictionary NextFallTimeByViewId = new Dictionary(); private static int _warnedFallbackMode; private static int _warnedMissingTarget; private static MethodInfo? _characterFallMethod; private static MethodInfo? _characterAddForceAtPositionMethod; private static MethodInfo? CharacterFallMethod { get { if ((object)_characterFallMethod == null) { _characterFallMethod = AccessTools.Method(typeof(Character), "Fall", new Type[2] { typeof(float), typeof(float) }, (Type[])null); } return _characterFallMethod; } } private static MethodInfo? CharacterAddForceAtPositionMethod { get { if ((object)_characterAddForceAtPositionMethod == null) { _characterAddForceAtPositionMethod = AccessTools.Method(typeof(Character), "AddForceAtPosition", new Type[3] { typeof(Vector3), typeof(Vector3), typeof(float) }, (Type[])null); } return _characterAddForceAtPositionMethod; } } public static bool CanUseTornadoEvent() { return true; } private static bool HasLegacyFallRpcOverload() { return AccessTools.Method(typeof(Character), "RPCA_Fall", new Type[2] { typeof(float), typeof(PhotonMessageInfo) }, (Type[])null) != null; } private static bool NeedsFallbackFixedUpdate() { return !HasLegacyFallRpcOverload(); } private static bool IsRemovedFallRpcException(Exception? exception) { if (exception == null) { return false; } if (exception is MissingMethodException && exception.Message.IndexOf("Character.RPCA_Fall", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } return exception.InnerException != null && IsRemovedFallRpcException(exception.InnerException); } private static void LogFallbackOnce(string reason) { if (Interlocked.Exchange(ref _warnedFallbackMode, 1) == 0) { Plugin.Log.LogWarning((object)("Tornado compatibility mode active: " + reason + ". The Tornado event is still enabled; only the removed RPCA_Fall overload is replaced with the current Character.Fall/RPCA_Fall(float) path.")); } } private static Transform? TryGetTargetTransform(object tornado) { Type type = tornado.GetType(); try { FieldInfo fieldInfo = AccessTools.Field(type, "target"); if (fieldInfo != null) { object? value = fieldInfo.GetValue(tornado); Transform val = (Transform)((value is Transform) ? value : null); if (val != null) { return val; } } PropertyInfo propertyInfo = AccessTools.Property(type, "target"); if (propertyInfo != null) { object? value2 = propertyInfo.GetValue(tornado, null); Transform val2 = (Transform)((value2 is Transform) ? value2 : null); if (val2 != null) { return val2; } } } catch (Exception arg) { if (Interlocked.Exchange(ref _warnedMissingTarget, 1) == 0) { Plugin.Log.LogWarning((object)$"Tornado compatibility could not read target transform: {arg}"); } } return null; } private static bool IsFallbackCharacterUsable(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)((MonoBehaviourPun)character).photonView == (Object)null || (Object)(object)character.view == (Object)null || (Object)(object)character.data == (Object)null || character.refs == null || (Object)(object)character.refs.items == (Object)null) { return false; } if (!character.IsPlayerControlled || character.isBot || character.isZombie || character.isScoutmaster) { return false; } if (!character.IsRegisteredToPlayer) { return false; } Player player = character.player; if ((Object)(object)player == (Object)null || (Object)(object)((MonoBehaviourPun)player).photonView == (Object)null || (Object)(object)player.view == (Object)null || (Object)(object)player.character != (Object)(object)character) { return false; } if (character.data.dead || character.data.fullyPassedOut || character.data.isInFog) { return false; } return true; } private static bool TryGetCharacterCenter(Character character, out Vector3 center) { //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_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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) center = Vector3.zero; try { center = character.Center; return true; } catch { if ((Object)(object)character != (Object)null && (Object)(object)((Component)character).transform != (Object)null) { center = ((Component)character).transform.position; return true; } } return false; } private static void ApplyTornadoForce(Character character, Vector3 tornadoPosition, Vector3 characterCenter, float strength) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00d0: Unknown result type (might be due to invalid IL or missing references) Vector3 val = tornadoPosition - characterCenter; val.y = 0f; Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.zero); Vector3 val4; if (!(val2 == Vector3.zero)) { Vector3 val3 = Vector3.Cross(Vector3.up, val2); val4 = ((Vector3)(ref val3)).normalized; } else { val4 = Vector3.zero; } Vector3 val5 = val4; Vector3 val6 = val2 * (26f * strength) + Vector3.up * (34f * strength) + val5 * (22f * strength); MethodInfo characterAddForceAtPositionMethod = CharacterAddForceAtPositionMethod; if (characterAddForceAtPositionMethod != null) { try { characterAddForceAtPositionMethod.Invoke(character, new object[3] { val6 * Mathf.Max(Time.fixedDeltaTime, 0.015f), characterCenter, 24f }); return; } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Tornado compatibility AddForceAtPosition failed for {((Object)character).name}: {arg}"); } } try { character.RPCA_AddForceAtPosition(val6 * Mathf.Max(Time.fixedDeltaTime, 0.015f), characterCenter, 24f); } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"Tornado compatibility local RPCA_AddForceAtPosition fallback failed for {((Object)character).name}: {arg2}"); } } private static void FallCharacterCompat(Character character, float seconds) { int key = (((Object)(object)((MonoBehaviourPun)character).photonView != (Object)null) ? ((MonoBehaviourPun)character).photonView.ViewID : ((Object)character).GetInstanceID()); float time = Time.time; if (NextFallTimeByViewId.TryGetValue(key, out var value) && time < value) { return; } NextFallTimeByViewId[key] = time + 0.9f; MethodInfo characterFallMethod = CharacterFallMethod; if (characterFallMethod != null) { try { characterFallMethod.Invoke(character, new object[2] { seconds, 0f }); return; } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Tornado compatibility Character.Fall failed for {((Object)character).name}: {arg}"); } } try { character.refs.view.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { seconds }); } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"Tornado compatibility RPCA_Fall(float) fallback failed for {((Object)character).name}: {arg2}"); } } private static void RunFallbackTornadoFixedUpdate(object tornadoInstance) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_006b: 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_006f: 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_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_00df: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) Component val = (Component)((tornadoInstance is Component) ? tornadoInstance : null); if (val == null || (Object)(object)val == (Object)null) { return; } LogFallbackOnce("Character.RPCA_Fall(float, PhotonMessageInfo) is not present in this game build"); Transform transform = val.transform; Transform val2 = TryGetTargetTransform(tornadoInstance); float num = Mathf.Max(Time.fixedDeltaTime, 0.015f); if ((Object)(object)val2 != (Object)null) { Vector3 val3 = transform.position; Vector3 position = val2.position; Vector3 val4 = position - val3; val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude > 0.01f) { val3 += ((Vector3)(ref val4)).normalized * 18f * num; } val3.y = Mathf.Lerp(val3.y, position.y, Mathf.Clamp01(num * 2f)); transform.position = val3; } transform.Rotate(Vector3.up, 420f * num, (Space)0); Character[] array = Character.AllCharacters.ToArray(); foreach (Character character in array) { if (!IsFallbackCharacterUsable(character) || !TryGetCharacterCenter(character, out var center)) { continue; } float num2 = Vector3.Distance(transform.position, center); if (!(num2 > 24f)) { float strength = Mathf.Clamp01(1f - num2 / 24f); ApplyTornadoForce(character, transform.position, center, strength); if (num2 <= 9f) { FallCharacterCompat(character, 0.85f); } } } } } public static class ItemOptimizationCompatibilityPatch { [HarmonyPatch] private static class DeregisterItemPatch { private static bool Prepare() { Type type = AccessTools.TypeByName("Peak.ItemOptimizationManager"); return type != null && AccessTools.Method(type, "DeregisterItem", (Type[])null, (Type[])null) != null; } private static MethodBase TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("Peak.ItemOptimizationManager"), "DeregisterItem", (Type[])null, (Type[])null); } private static Exception? Finalizer(Exception? __exception) { return SwallowNullKeyDeregister(__exception, "DeregisterItem"); } } [HarmonyPatch] private static class ItemOptimizerOnDisablePatch { private static bool Prepare() { Type type = AccessTools.TypeByName("Peak.ItemOptimizer"); return type != null && AccessTools.Method(type, "OnDisable", (Type[])null, (Type[])null) != null; } private static MethodBase TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("Peak.ItemOptimizer"), "OnDisable", (Type[])null, (Type[])null); } private static Exception? Finalizer(Exception? __exception) { return SwallowNullKeyDeregister(__exception, "ItemOptimizer.OnDisable"); } } private static int _warned; private static bool IsNullKeyDeregisterException(Exception? exception) { if (exception == null) { return false; } if (exception is ArgumentNullException ex && string.Equals(ex.ParamName, "key", StringComparison.OrdinalIgnoreCase)) { return true; } return exception.InnerException != null && IsNullKeyDeregisterException(exception.InnerException); } private static Exception? SwallowNullKeyDeregister(Exception? exception, string source) { if (!IsNullKeyDeregisterException(exception)) { return exception; } if (Interlocked.Exchange(ref _warned, 1) == 0) { Plugin.Log.LogWarning((object)("Suppressed ItemOptimizationManager null-key deregister exception from " + source + ". Rich loot remains enabled; this only prevents isolated null-key optimizer errors from spamming the log.")); } return null; } } public static class RandomEventTask { [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private int 5__1; private int 5__2; private int 5__3; private float 5__4; private Random <>s__5; private bool <>s__6; private Exception 5__7; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__5 = null; 5__7 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; Plugin.Log.LogInfo((object)"Starting random event coroutine."); goto IL_01bd; case 1: <>1__state = -1; goto IL_015f; case 2: { <>1__state = -1; goto IL_01bd; } IL_01bd: if (Interlocked.CompareExchange(ref ShouldStopTask, 0, 0) != 0 || !PhotonNetwork.IsMasterClient || !Plugin.IsGameplayScene() || !ModConfig.EnableChaosMaster.Value || !ModConfig.EnableRandomEvents.Value) { break; } 5__1 = Mathf.Max(1, ModConfig.WaitTimeMin.Value); 5__2 = Mathf.Max(5__1, ModConfig.WaitTimeMax.Value); <>s__5 = Rng; <>s__6 = false; try { Monitor.Enter(<>s__5, ref <>s__6); 5__3 = Rng.Next(5__1, 5__2 + 1); } finally { if (<>s__6) { Monitor.Exit(<>s__5); } } <>s__5 = null; 5__4 = 5__3; goto IL_015f; IL_015f: if (5__4 > 0f) { if (Interlocked.CompareExchange(ref ShouldStopTask, 0, 0) != 0 || !PhotonNetwork.IsMasterClient || !Plugin.IsGameplayScene() || !ModConfig.EnableChaosMaster.Value || !ModConfig.EnableRandomEvents.Value) { _routine = null; RandomizerEvents.ClearPendingQueues(); return false; } 5__4 -= Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } try { RandomizerEvents.QueueRandomEvent(); } catch (Exception ex) { 5__7 = ex; Plugin.Log.LogError((object)$"Queue random event error: {5__7}"); } <>2__current = null; <>1__state = 2; return true; } _routine = null; RandomizerEvents.ClearPendingQueues(); Plugin.Log.LogInfo((object)"Stopped random event coroutine."); 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 Coroutine? _routine; private static readonly Random Rng = new Random(); public static int ShouldStopTask = 1; public static bool IsRunning => _routine != null; public static void EnsureStarted() { if (PhotonNetwork.IsMasterClient) { if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableRandomEvents.Value) { StopTask(); } else if (_routine == null) { StartTask(); } } } public static void StartTask() { if (PhotonNetwork.IsMasterClient && ModConfig.EnableChaosMaster.Value && ModConfig.EnableRandomEvents.Value && !((Object)(object)Plugin.Instance == (Object)null) && _routine == null) { Interlocked.Exchange(ref ShouldStopTask, 0); RandomizerEvents.SkeletonEventActive = false; _routine = ((MonoBehaviour)Plugin.Instance).StartCoroutine(RandomEventLoop()); } } public static void StopTask() { Interlocked.Exchange(ref ShouldStopTask, 1); if (_routine != null && (Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StopCoroutine(_routine); } _routine = null; RandomizerEvents.ClearPendingQueues(); Plugin.Log.LogInfo((object)"Stopped random event coroutine."); } [IteratorStateMachine(typeof(d__8))] private static IEnumerator RandomEventLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0); } } public static class SpecialHeldItemPatch { private static readonly MethodInfo RescueHookLetGoMethod = AccessTools.Method(typeof(RescueHook), "RPCA_LetGo", (Type[])null, (Type[])null); private static bool IsRescueHook(Item item) { return (Object)(object)item != (Object)null && (Object)(object)((Component)item).GetComponent() != (Object)null; } private static bool IsInfiniteRescueHook(Item item) { return (Object)(object)item != (Object)null && !string.IsNullOrEmpty(((Object)item).name) && ((Object)item).name.Contains("RescueHook_Infinite", StringComparison.OrdinalIgnoreCase); } private static void SafeReleaseRescueHook(Item item) { if (!IsRescueHook(item)) { return; } RescueHook component = ((Component)item).GetComponent(); if ((Object)(object)component == (Object)null) { return; } try { if (Traverse.Create((object)component).Field("isPulling").GetValue()) { RescueHookLetGoMethod?.Invoke(component, null); } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SafeReleaseRescueHook failed: {arg}"); } } [HarmonyPatch(typeof(CharacterItems), "DropItemRpc")] [HarmonyPrefix] private static void PrefixDropItemRpc(CharacterItems __instance) { object obj; if (__instance == null) { obj = null; } else { Character character = __instance.character; if (character == null) { obj = null; } else { CharacterData data = character.data; obj = ((data != null) ? data.currentItem : null); } } Item val = (Item)obj; if ((Object)(object)val != (Object)null) { SafeReleaseRescueHook(val); } } [HarmonyPatch(typeof(CharacterItems), "DestroyHeldItemRpc")] [HarmonyPrefix] private static void PrefixDestroyHeldItemRpc(CharacterItems __instance) { object obj; if (__instance == null) { obj = null; } else { Character character = __instance.character; if (character == null) { obj = null; } else { CharacterData data = character.data; obj = ((data != null) ? data.currentItem : null); } } Item val = (Item)obj; if ((Object)(object)val != (Object)null) { SafeReleaseRescueHook(val); } } [HarmonyPatch(typeof(CharacterItems), "EquipSlot")] [HarmonyPrefix] private static bool PrefixEquipSlot(CharacterItems __instance, Optionable slotID) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null) { return true; } Item currentItem = __instance.character.data.currentItem; if ((Object)(object)currentItem == (Object)null || !IsInfiniteRescueHook(currentItem)) { return true; } if (!__instance.currentSelectedSlot.IsSome || __instance.currentSelectedSlot.Value != 250) { return true; } if (slotID.IsSome && slotID.Value == 250) { return true; } Plugin.Log.LogInfo((object)"Blocked switching away from temp-slot RescueHook_Infinite to prevent auto-drop crash."); return false; } } public static class RescueHookDestroyPatch { private static readonly MethodInfo RescueHookLetGoMethod = AccessTools.Method(typeof(RescueHook), "RPCA_LetGo", (Type[])null, (Type[])null); [HarmonyPatch(typeof(RescueHook), "OnDestroy")] [HarmonyPrefix] private static void Prefix(RescueHook __instance) { if ((Object)(object)__instance == (Object)null) { return; } try { if (Traverse.Create((object)__instance).Field("isPulling").GetValue()) { RescueHookLetGoMethod?.Invoke(__instance, null); } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"RescueHook OnDestroy safe release failed: {arg}"); } } } public class ChaosEnvironmentSync : MonoBehaviourPun { private static readonly object MagicBeanVineCleanupLock = new object(); private static readonly List<(Vector3 center, float radius, float cleanupAt)> LocalMagicBeanVineCleanupJobs = new List<(Vector3, float, float)>(); public static ChaosEnvironmentSync Instance { get; private set; } public static bool MesaSunActive { get; private set; } public static float MesaSunRemaining { get; private set; } private void Awake() { Instance = this; } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } MesaSunActive = false; MesaSunRemaining = 0f; ChaosEnvironmentController.RestoreLocalWeatherOverrides(); ClearLocalMagicBeanVineCleanupJobs(); } private void Update() { ChaosEnvironmentController.UpdateLocalControlledWeatherBounds(); ProcessLocalMagicBeanVineCleanupJobs(); if (MesaSunActive) { ChaosEnvironmentController.TickControlledMesaSunGlobal(null); MesaSunRemaining -= Time.deltaTime; if (MesaSunRemaining <= 0f) { MesaSunActive = false; MesaSunRemaining = 0f; ChaosEnvironmentController.ResetControlledMesaSun(); } } } public static void EnsureExists(GameObject host) { if (!((Object)(object)host == (Object)null) && (Object)(object)host.GetComponent() == (Object)null) { host.AddComponent(); } } public void BroadcastMesaSun(float durationSeconds) { if (PhotonNetwork.IsMasterClient && !((Object)(object)((MonoBehaviourPun)this).photonView == (Object)null)) { ((MonoBehaviourPun)this).photonView.RPC("RPCA_SetMesaSunState", (RpcTarget)0, new object[2] { true, Mathf.Max(0f, durationSeconds) }); } } public void BroadcastMesaSunOff() { if (PhotonNetwork.IsMasterClient && !((Object)(object)((MonoBehaviourPun)this).photonView == (Object)null)) { ((MonoBehaviourPun)this).photonView.RPC("RPCA_SetMesaSunState", (RpcTarget)0, new object[2] { false, 0f }); } } public static void BroadcastMagicBeanVineCleanupForAllClients(Vector3 center, float radius, float delaySeconds) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsMasterClient) { ChaosEnvironmentSync chaosEnvironmentSync = Instance; if ((Object)(object)chaosEnvironmentSync == (Object)null && (Object)(object)DayNightManager.instance != (Object)null) { EnsureExists(((Component)DayNightManager.instance).gameObject); chaosEnvironmentSync = ((Component)DayNightManager.instance).GetComponent(); } if ((Object)(object)chaosEnvironmentSync != (Object)null && (Object)(object)((MonoBehaviourPun)chaosEnvironmentSync).photonView != (Object)null) { ((MonoBehaviourPun)chaosEnvironmentSync).photonView.RPC("RPCA_ScheduleMagicBeanVineCleanup", (RpcTarget)0, new object[3] { center, Mathf.Max(1f, radius), Mathf.Max(0f, delaySeconds) }); } else { ScheduleLocalMagicBeanVineCleanup(center, radius, delaySeconds); } } } public void BroadcastTemporaryWeather(int weatherKind, Vector3 windDirection, float durationSeconds) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsMasterClient && !((Object)(object)((MonoBehaviourPun)this).photonView == (Object)null)) { ((MonoBehaviourPun)this).photonView.RPC("RPCA_StartTemporaryWeather", (RpcTarget)0, new object[3] { weatherKind, windDirection, Mathf.Max(1f, durationSeconds) }); } } [PunRPC] public void RPCA_StartTemporaryWeather(int weatherKind, Vector3 windDirection, float durationSeconds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ChaosEnvironmentController.StartLocalTemporaryWeather(weatherKind, windDirection, durationSeconds); } [PunRPC] public void RPCA_SetMesaSunState(bool active, float durationSeconds) { MesaSunActive = active; MesaSunRemaining = (active ? Mathf.Max(0f, durationSeconds) : 0f); if (!active) { ChaosEnvironmentController.ResetControlledMesaSun(); } } [PunRPC] public void RPCA_ScheduleMagicBeanVineCleanup(Vector3 center, float radius, float delaySeconds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ScheduleLocalMagicBeanVineCleanup(center, radius, delaySeconds); } private static void ScheduleLocalMagicBeanVineCleanup(Vector3 center, float radius, float delaySeconds) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) lock (MagicBeanVineCleanupLock) { LocalMagicBeanVineCleanupJobs.Add((center, Mathf.Max(1f, radius), Time.time + Mathf.Max(0f, delaySeconds))); } } private static void ProcessLocalMagicBeanVineCleanupJobs() { //IL_005a: 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) List<(Vector3, float)> list = null; lock (MagicBeanVineCleanupLock) { for (int num = LocalMagicBeanVineCleanupJobs.Count - 1; num >= 0; num--) { if (!(LocalMagicBeanVineCleanupJobs[num].cleanupAt > Time.time)) { if (list == null) { list = new List<(Vector3, float)>(); } list.Add((LocalMagicBeanVineCleanupJobs[num].center, LocalMagicBeanVineCleanupJobs[num].radius)); LocalMagicBeanVineCleanupJobs.RemoveAt(num); } } } if (list == null) { return; } foreach (var item in list) { RandomizerEvents.CleanupNearbyMagicBeanVines(item.Item1, item.Item2); } } private static void ClearLocalMagicBeanVineCleanupJobs() { lock (MagicBeanVineCleanupLock) { LocalMagicBeanVineCleanupJobs.Clear(); } } public static void ResetLocalStateOnly() { MesaSunActive = false; MesaSunRemaining = 0f; ClearLocalMagicBeanVineCleanupJobs(); } } [HarmonyPatch(typeof(DayNightManager), "Start")] public static class DayNightManagerBootstrapPatch { [HarmonyPostfix] private static void Postfix(DayNightManager __instance) { if (!((Object)(object)__instance == (Object)null)) { ChaosEnvironmentSync.EnsureExists(((Component)__instance).gameObject); } } } public static class ChaosEnvironmentController { private enum TemporaryWeatherKind { None, Rain, Wind, Snow } private sealed class LocalWeatherOverride { public WindChillZone? Zone; public Bounds OriginalBounds; public float RestoreAtTime; public bool OriginalActiveSelf; public TemporaryWeatherKind Kind; public Transform? OriginalParent; public Vector3 OriginalLocalPosition; public Quaternion OriginalLocalRotation; public Vector3 OriginalLocalScale; public bool DetachedFromInactiveParent; public Vector3 WindDirection; public float OriginalRainstormWindFactor; public float OriginalSnowstormWindFactor; public float OriginalGlobalWind; public float OriginalExtraFog; public float OriginalGlobalHaze; public float OriginalBandFog; public float OriginalHeightFogAmount; public float OriginalHeightFogHeight; public float OriginalWeatherBlend; public Texture? OriginalWindTexture; public Color OriginalWindTint; public float OriginalWindSkyBrightnessValue; public float OriginalWindTextureInfluence; public float OriginalWindFogDensity; public float OriginalWindFogTextureDensity; public float OriginalWindMixInfluence; public Vector4 OriginalWindSpeed; public Vector4 OriginalWindRotationAxis; public float OriginalWindRotationAngle; public float OriginalWindSphereScale; public FogConfig? OriginalCurrentFog; public readonly List ActivatedVisualObjects = new List(); } private sealed class WeatherZoneCache { public float BuiltAt = -9999f; public readonly List All = new List(); public readonly List Rain = new List(); public readonly List Wind = new List(); public readonly List Snow = new List(); } private const float DisabledIdleSeconds = 99999f; private const float RandomWeatherBoundsSize = 3000f; private static FieldRef? UntilSwitchRef; private static FieldRef? TimeUntilNextWindRef; private static MethodInfo? ToggleWindRpcMethod; private static FieldInfo? CurrentWindDirectionField; private static MethodInfo? CharacterAddForceAtPositionMethod; private static bool _weatherReflectionReady; private static bool _weatherReflectionFailed; private static readonly int GlobalWindShader = Shader.PropertyToID("GlobalWind"); private static readonly int ExtraFogShader = Shader.PropertyToID("EXTRAFOG"); private static readonly int GlobalHazeShader = Shader.PropertyToID("_GlobalHazeAmount"); private static readonly int BandFogShader = Shader.PropertyToID("BandFogAmount"); private static readonly int HeightFogAmountShader = Shader.PropertyToID("HeightFogAmount"); private static readonly int HeightFogHeightShader = Shader.PropertyToID("HeightFogHeight"); private static readonly int WeatherBlendShader = Shader.PropertyToID("_WeatherBlend"); private static readonly int WindTextureShader = Shader.PropertyToID("_WindTexture"); private static readonly int WindTintShader = Shader.PropertyToID("WindTint"); private static readonly int WindSkyBrightnessValueShader = Shader.PropertyToID("WindSkyBrightnessValue"); private static readonly int WindTextureInfluenceShader = Shader.PropertyToID("WindTextureInfluence"); private static readonly int WindFogDensityShader = Shader.PropertyToID("WindFogDensity"); private static readonly int WindFogTextureDensityShader = Shader.PropertyToID("WindFogTextureDensity"); private static readonly int WindMixInfluenceShader = Shader.PropertyToID("WindMixInfluence"); private static readonly int WindSpeedShader = Shader.PropertyToID("WindSpeed"); private static readonly int WindRotationAxisShader = Shader.PropertyToID("WindRotationAxis"); private static readonly int WindRotationAngleShader = Shader.PropertyToID("WindRotationAngle"); private static readonly int WindSphereScaleShader = Shader.PropertyToID("WindSphereScale"); private static readonly Dictionary LocalWeatherOverrides = new Dictionary(); private static readonly WeatherZoneCache CachedWeatherZones = new WeatherZoneCache(); private const float WeatherZoneCacheSeconds = 10f; private const float MesaSunDefaultRate = 0.5f; private const float MesaSunDefaultAmount = 0.05f; private static float _controlledMesaSunCounter; private static int _controlledMesaSunLastFrame = -1; private static bool EnsureWeatherReflection() { if (_weatherReflectionReady) { return true; } if (_weatherReflectionFailed) { return false; } try { UntilSwitchRef = AccessTools.FieldRefAccess("untilSwitch"); TimeUntilNextWindRef = AccessTools.FieldRefAccess("timeUntilNextWind"); ToggleWindRpcMethod = AccessTools.Method(typeof(WindChillZone), "RPCA_ToggleWind", (Type[])null, (Type[])null); CurrentWindDirectionField = AccessTools.Field(typeof(WindChillZone), "currentWindDirection"); CharacterAddForceAtPositionMethod = AccessTools.Method(typeof(Character), "AddForceAtPosition", (Type[])null, (Type[])null); _weatherReflectionReady = true; return true; } catch (Exception arg) { _weatherReflectionFailed = true; Plugin.Log.LogWarning((object)$"Weather reflection failed. Native WindChillZone weather disabled safely: {arg}"); return false; } } public static void ResetLocalState() { ChaosEnvironmentSync.ResetLocalStateOnly(); ResetControlledMesaSun(); RestoreLocalWeatherOverrides(); } public static void ResetControlledMesaSun() { _controlledMesaSunCounter = 0f; _controlledMesaSunLastFrame = -1; } public static bool ShouldTakeOverWindZone(WindChillZone zone) { if ((Object)(object)zone == (Object)null || LocalWeatherOverrides.Count == 0) { return false; } return LocalWeatherOverrides.ContainsKey(((Object)zone).GetInstanceID()); } public static void TickControlledZone(WindChillZone zone) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)zone == (Object)null) && EnsureWeatherReflection() && UntilSwitchRef != null && TimeUntilNextWindRef != null) { float num = UntilSwitchRef.Invoke(zone) - Time.deltaTime; UntilSwitchRef.Invoke(zone) = num; if (!(num >= 0f)) { InvokeToggleWind(zone, set: false, Vector3.zero, 99999f); TimeUntilNextWindRef.Invoke(zone) = 99999f; } } } public static bool TryTriggerTropicsRain() { return false; } public static bool TryTriggerRootsWind() { return TryTriggerWeatherType("Wind", TemporaryWeatherKind.Wind); } public static bool TryTriggerAlpineSnow() { return TryTriggerWeatherType("Snow", TemporaryWeatherKind.Snow); } public static bool TryTriggerMesaSun() { if (!PhotonNetwork.IsMasterClient) { return false; } if (HasAnyActiveWeatherEffect()) { return false; } DayNightManager instance = DayNightManager.instance; if ((Object)(object)instance == (Object)null) { return false; } ChaosEnvironmentSync.EnsureExists(((Component)instance).gameObject); ChaosEnvironmentSync component = ((Component)instance).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } int num = Mathf.Max(1, ModConfig.MesaSunDurationMin.Value); int num2 = Mathf.Max(num, ModConfig.MesaSunDurationMax.Value); float durationSeconds = Random.Range(num, num2 + 1); component.BroadcastMesaSun(durationSeconds); return true; } public static bool ShouldTakeOverHotSun() { return false; } public static void RunControlledHotSun(object hotSun) { TickControlledMesaSunGlobal(hotSun); } public static void TickControlledMesaSunGlobal(object hotSun) { if (!Application.isPlaying || !ChaosEnvironmentSync.MesaSunActive || _controlledMesaSunLastFrame == Time.frameCount) { return; } _controlledMesaSunLastFrame = Time.frameCount; if (!((Object)(object)Character.localCharacter == (Object)null) && Character.localCharacter.refs != null && !((Object)(object)Character.localCharacter.refs.afflictions == (Object)null) && HasDirectSunOrNoSunObject()) { float num = Mathf.Max(0.05f, GetFloatMember(hotSun, "rate", 0.5f)); float floatMember = GetFloatMember(hotSun, "amount", 0.05f); _controlledMesaSunCounter += Time.deltaTime; if (_controlledMesaSunCounter > num) { _controlledMesaSunCounter = 0f; Character.localCharacter.refs.afflictions.AddSunHeat(floatMember); } } } private static bool HasDirectSunOrNoSunObject() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0093: Unknown result type (might be due to invalid IL or missing references) object obj = (((Object)(object)DayNightManager.instance != (Object)null) ? GetMemberValue(DayNightManager.instance, "sun") : null); Light val = (Light)((obj is Light) ? obj : null); if ((Object)(object)val == (Object)null) { return true; } if (val.intensity < 5f) { return false; } Transform transform = ((Component)val).transform; RaycastHit val2 = HelperFunctions.LineCheck(Character.localCharacter.Center + transform.forward * -1000f, Character.localCharacter.Center, (LayerType)0, 0f, (QueryTriggerInteraction)1); return (Object)(object)((RaycastHit)(ref val2)).transform == (Object)null || (Object)(object)((RaycastHit)(ref val2)).transform.root == (Object)(object)((Component)Character.localCharacter).transform.root; } public static void StartLocalTemporaryWeather(int weatherKind, Vector3 windDirection, float durationSeconds) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (weatherKind == 0 || weatherKind == 1 || !EnsureWeatherReflection()) { return; } RefreshWeatherZoneCache(force: true); List localWeatherCandidates = GetLocalWeatherCandidates((TemporaryWeatherKind)weatherKind); if (localWeatherCandidates.Count == 0) { Plugin.Log.LogWarning((object)("Temporary " + WeatherKindName((TemporaryWeatherKind)weatherKind) + " weather received, but no native WindChillZone/StormVisual was found. Custom rain/weather visual is disabled, so this weather event was skipped.")); return; } int num = Random.Range(0, localWeatherCandidates.Count); for (int i = 0; i < localWeatherCandidates.Count; i++) { WindChillZone zone = localWeatherCandidates[(num + i) % localWeatherCandidates.Count]; if (BeginLocalTemporaryWeather(zone, (TemporaryWeatherKind)weatherKind, windDirection, durationSeconds)) { return; } } Plugin.Log.LogWarning((object)("Temporary " + WeatherKindName((TemporaryWeatherKind)weatherKind) + " weather received, but every native candidate failed to activate. Custom rain/weather visual is disabled, so this weather event was skipped.")); } private static bool BeginLocalTemporaryWeather(WindChillZone zone, TemporaryWeatherKind kind, Vector3 windDirection, float durationSeconds) { //IL_009d: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zone == (Object)null || !EnsureWeatherReflection() || UntilSwitchRef == null || TimeUntilNextWindRef == null) { return false; } if (zone.windActive) { return false; } int instanceID = ((Object)zone).GetInstanceID(); if (!LocalWeatherOverrides.TryGetValue(instanceID, out LocalWeatherOverride value)) { value = CreateWeatherState(zone, kind, windDirection, durationSeconds); LocalWeatherOverrides[instanceID] = value; } else { value.RestoreAtTime = Time.time + Mathf.Max(1f, durationSeconds); value.Kind = kind; value.WindDirection = windDirection; } if (!((Component)zone).gameObject.activeInHierarchy && (Object)(object)((Component)zone).transform.parent != (Object)null && !((Component)((Component)zone).transform.parent).gameObject.activeInHierarchy) { ((Component)zone).transform.SetParent((Transform)null, true); value.DetachedFromInactiveParent = true; } if (!((Component)zone).gameObject.activeSelf) { ((Component)zone).gameObject.SetActive(true); } if (!((Component)zone).gameObject.activeInHierarchy) { Plugin.Log.LogWarning((object)("Temporary " + WeatherKindName(kind) + " weather skipped: " + ((Object)zone).name + " could not be activated locally.")); RestoreLocalWeatherOverride(instanceID, value); LocalWeatherOverrides.Remove(instanceID); return false; } int num = EnsureNativeWeatherVisualsActive(zone, kind, value); zone.windZoneBounds = BuildPlayerCenteredWeatherBounds(value.OriginalBounds); InvokeToggleWind(zone, set: true, windDirection, Mathf.Max(1f, durationSeconds)); Plugin.Log.LogInfo((object)$"Temporary {WeatherKindName(kind)} weather started locally: zone={((Object)zone).name}, duration={durationSeconds:0.0}s, nativeVisuals={num}, visualActivation=disabled."); return true; } private static LocalWeatherOverride CreateWeatherState(WindChillZone? zone, TemporaryWeatherKind kind, Vector3 windDirection, float durationSeconds) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_00a2: 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_00a7: 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_00b6: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) return new LocalWeatherOverride { Zone = zone, OriginalBounds = (Bounds)(((Object)(object)zone != (Object)null) ? zone.windZoneBounds : new Bounds(Vector3.zero, Vector3.one)), RestoreAtTime = Time.time + Mathf.Max(1f, durationSeconds), OriginalActiveSelf = ((Object)(object)zone != (Object)null && ((Component)zone).gameObject.activeSelf), Kind = kind, OriginalParent = (((Object)(object)zone != (Object)null) ? ((Component)zone).transform.parent : null), OriginalLocalPosition = (((Object)(object)zone != (Object)null) ? ((Component)zone).transform.localPosition : Vector3.zero), OriginalLocalRotation = (((Object)(object)zone != (Object)null) ? ((Component)zone).transform.localRotation : Quaternion.identity), OriginalLocalScale = (((Object)(object)zone != (Object)null) ? ((Component)zone).transform.localScale : Vector3.one), WindDirection = ((windDirection == Vector3.zero) ? RandomWindDirection() : ((Vector3)(ref windDirection)).normalized), OriginalRainstormWindFactor = GetFloatMember(DayNightManager.instance, "rainstormWindFactor", 0f), OriginalSnowstormWindFactor = GetFloatMember(DayNightManager.instance, "snowstormWindFactor", 0f), OriginalGlobalWind = Shader.GetGlobalFloat(GlobalWindShader), OriginalExtraFog = Shader.GetGlobalFloat(ExtraFogShader), OriginalGlobalHaze = Shader.GetGlobalFloat(GlobalHazeShader), OriginalBandFog = Shader.GetGlobalFloat(BandFogShader), OriginalHeightFogAmount = Shader.GetGlobalFloat(HeightFogAmountShader), OriginalHeightFogHeight = Shader.GetGlobalFloat(HeightFogHeightShader), OriginalWeatherBlend = Shader.GetGlobalFloat(WeatherBlendShader), OriginalWindTexture = Shader.GetGlobalTexture(WindTextureShader), OriginalWindTint = Shader.GetGlobalColor(WindTintShader), OriginalWindSkyBrightnessValue = Shader.GetGlobalFloat(WindSkyBrightnessValueShader), OriginalWindTextureInfluence = Shader.GetGlobalFloat(WindTextureInfluenceShader), OriginalWindFogDensity = Shader.GetGlobalFloat(WindFogDensityShader), OriginalWindFogTextureDensity = Shader.GetGlobalFloat(WindFogTextureDensityShader), OriginalWindMixInfluence = Shader.GetGlobalFloat(WindMixInfluenceShader), OriginalWindSpeed = Shader.GetGlobalVector(WindSpeedShader), OriginalWindRotationAxis = Shader.GetGlobalVector(WindRotationAxisShader), OriginalWindRotationAngle = Shader.GetGlobalFloat(WindRotationAngleShader), OriginalWindSphereScale = Shader.GetGlobalFloat(WindSphereScaleShader), OriginalCurrentFog = FogConfig.currentFog }; } public static void UpdateLocalControlledWeatherBounds() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (LocalWeatherOverrides.Count == 0) { return; } bool flag = EnsureWeatherReflection(); List list = null; foreach (KeyValuePair localWeatherOverride in LocalWeatherOverrides) { LocalWeatherOverride value = localWeatherOverride.Value; WindChillZone zone = value.Zone; if (Time.time >= value.RestoreAtTime) { RestoreLocalWeatherOverride(localWeatherOverride.Key, value); if (list == null) { list = new List(); } list.Add(localWeatherOverride.Key); } else if ((Object)(object)zone != (Object)null && !flag) { RestoreLocalWeatherOverride(localWeatherOverride.Key, value); if (list == null) { list = new List(); } list.Add(localWeatherOverride.Key); } else { if ((Object)(object)zone != (Object)null) { zone.windZoneBounds = BuildPlayerCenteredWeatherBounds(value.OriginalBounds); } ApplyLocalFallbackWeatherEffect(value); } } if (list != null) { for (int i = 0; i < list.Count; i++) { LocalWeatherOverrides.Remove(list[i]); } } } public static void RestoreLocalWeatherOverrides() { foreach (KeyValuePair item in LocalWeatherOverrides.ToList()) { RestoreLocalWeatherOverride(item.Key, item.Value); } LocalWeatherOverrides.Clear(); } private static void RestoreLocalWeatherOverride(int key, LocalWeatherOverride state) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if (state == null) { return; } WindChillZone zone = state.Zone; if ((Object)(object)zone != (Object)null) { InvokeToggleWind(zone, set: false, Vector3.zero, 99999f); zone.windActive = false; zone.windZoneBounds = state.OriginalBounds; zone.StormProgress = 0f; zone.timeUntilStorm = 0f; zone.hasBeenActiveFor = 0f; zone.windPlayerFactor = 0f; zone.windIntensity = 0f; if (UntilSwitchRef != null) { UntilSwitchRef.Invoke(zone) = 99999f; } if (TimeUntilNextWindRef != null) { TimeUntilNextWindRef.Invoke(zone) = 99999f; } ResetNativeWeatherVisuals(zone, state.Kind); for (int num = state.ActivatedVisualObjects.Count - 1; num >= 0; num--) { GameObject val = state.ActivatedVisualObjects[num]; if ((Object)(object)val != (Object)null) { val.SetActive(false); } } state.ActivatedVisualObjects.Clear(); if (!state.OriginalActiveSelf && ((Component)zone).gameObject.activeSelf) { ((Component)zone).gameObject.SetActive(false); } if (state.DetachedFromInactiveParent) { ((Component)zone).transform.SetParent(state.OriginalParent, false); ((Component)zone).transform.localPosition = state.OriginalLocalPosition; ((Component)zone).transform.localRotation = state.OriginalLocalRotation; ((Component)zone).transform.localScale = state.OriginalLocalScale; } } ResetStormAudioByReflection(state.Kind); RestoreWeatherGlobals(state); Plugin.Log.LogInfo((object)("Temporary " + WeatherKindName(state.Kind) + " weather restored locally.")); } private static void RestoreWeatherGlobals(LocalWeatherOverride state) { //IL_00cb: 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_0142: Unknown result type (might be due to invalid IL or missing references) SetFloatMember(DayNightManager.instance, "rainstormWindFactor", state.OriginalRainstormWindFactor); SetFloatMember(DayNightManager.instance, "snowstormWindFactor", state.OriginalSnowstormWindFactor); InvokeMember(DayNightManager.instance, "UpdateCycle"); Shader.SetGlobalFloat(GlobalWindShader, state.OriginalGlobalWind); Shader.SetGlobalFloat(ExtraFogShader, state.OriginalExtraFog); Shader.SetGlobalFloat(GlobalHazeShader, state.OriginalGlobalHaze); Shader.SetGlobalFloat(BandFogShader, state.OriginalBandFog); Shader.SetGlobalFloat(HeightFogAmountShader, state.OriginalHeightFogAmount); Shader.SetGlobalFloat(HeightFogHeightShader, state.OriginalHeightFogHeight); Shader.SetGlobalFloat(WeatherBlendShader, state.OriginalWeatherBlend); Shader.SetGlobalTexture(WindTextureShader, state.OriginalWindTexture); Shader.SetGlobalColor(WindTintShader, state.OriginalWindTint); Shader.SetGlobalFloat(WindSkyBrightnessValueShader, state.OriginalWindSkyBrightnessValue); Shader.SetGlobalFloat(WindTextureInfluenceShader, state.OriginalWindTextureInfluence); Shader.SetGlobalFloat(WindFogDensityShader, state.OriginalWindFogDensity); Shader.SetGlobalFloat(WindFogTextureDensityShader, state.OriginalWindFogTextureDensity); Shader.SetGlobalFloat(WindMixInfluenceShader, state.OriginalWindMixInfluence); Shader.SetGlobalVector(WindSpeedShader, state.OriginalWindSpeed); Shader.SetGlobalVector(WindRotationAxisShader, state.OriginalWindRotationAxis); Shader.SetGlobalFloat(WindRotationAngleShader, state.OriginalWindRotationAngle); Shader.SetGlobalFloat(WindSphereScaleShader, state.OriginalWindSphereScale); FogConfig.currentFog = state.OriginalCurrentFog; } private static void ApplyLocalFallbackWeatherEffect(LocalWeatherOverride state) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (state == null) { return; } ApplyLocalFallbackWeatherFog(state); Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null) && localCharacter.refs != null && !((Object)(object)localCharacter.refs.afflictions == (Object)null) && state.Kind != TemporaryWeatherKind.Rain) { if (state.Kind == TemporaryWeatherKind.Snow) { localCharacter.refs.afflictions.AddStatus((STATUSTYPE)2, 0.012f * Time.deltaTime, false, true, true); SetFloatMember(DayNightManager.instance, "snowstormWindFactor", Mathf.Max(GetFloatMember(DayNightManager.instance, "snowstormWindFactor", 0f), 0.65f)); } else if (state.Kind == TemporaryWeatherKind.Wind) { ApplyManualWindForce(localCharacter, state.WindDirection); SetFloatMember(DayNightManager.instance, "rainstormWindFactor", Mathf.Max(GetFloatMember(DayNightManager.instance, "rainstormWindFactor", 0f), 0.45f)); } InvokeMember(DayNightManager.instance, "UpdateCycle"); } } private static void ApplyManualWindForce(Character c, Vector3 windDirection) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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) if ((Object)(object)c == (Object)null || (Object)(object)((MonoBehaviourPun)c).photonView == (Object)null || !((MonoBehaviourPun)c).photonView.IsMine || (Object)(object)c.data.currentClimbHandle != (Object)null) { return; } if (CharacterAddForceAtPositionMethod == null) { CharacterAddForceAtPositionMethod = AccessTools.Method(typeof(Character), "AddForceAtPosition", (Type[])null, (Type[])null); } if (CharacterAddForceAtPositionMethod == null) { return; } try { float num = ((c.data.fallSeconds >= 0.01f) ? 1.8f : 0.65f); Vector3 val = ((Vector3)(ref windDirection)).normalized * (20f * Time.deltaTime * num); CharacterAddForceAtPositionMethod.Invoke(c, new object[3] { val, c.Center, 2f }); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Manual wind force failed: {arg}"); } } private static void ApplyLocalFallbackWeatherFog(LocalWeatherOverride state) { //IL_0126: 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) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) WindChillZone zone = state.Zone; float num = Mathf.Clamp01((state.RestoreAtTime - Time.time > 1.5f) ? 1f : (Mathf.Max(0f, state.RestoreAtTime - Time.time) / 1.5f)); if ((Object)(object)zone != (Object)null) { num = Mathf.Clamp01(Mathf.Max(new float[4] { num, zone.StormProgress, zone.windIntensity, zone.hasBeenActiveFor * 0.2f })); } float num2 = Mathf.Max(Shader.GetGlobalFloat(WeatherBlendShader), Mathf.Lerp(0.35f, 1f, num)); Shader.SetGlobalFloat(WeatherBlendShader, num2); Shader.SetGlobalFloat(ExtraFogShader, Mathf.Max(Shader.GetGlobalFloat(ExtraFogShader), 0.015f * num)); Shader.SetGlobalFloat(GlobalHazeShader, Mathf.Max(Shader.GetGlobalFloat(GlobalHazeShader), 0.08f * num)); Shader.SetGlobalVector(WindSpeedShader, new Vector4(state.WindDirection.x * 0.28f, state.WindDirection.z * 0.28f, 0f, 0f)); if (state.Kind != TemporaryWeatherKind.Rain) { if (state.Kind == TemporaryWeatherKind.Snow) { Shader.SetGlobalColor(WindTintShader, Color.Lerp(Color.white, new Color(0.82f, 0.92f, 1f, 1f), num)); Shader.SetGlobalFloat(WindFogDensityShader, Mathf.Max(Shader.GetGlobalFloat(WindFogDensityShader), 20f * num)); Shader.SetGlobalFloat(WindFogTextureDensityShader, Mathf.Max(Shader.GetGlobalFloat(WindFogTextureDensityShader), 10f * num)); } else if (state.Kind == TemporaryWeatherKind.Wind) { Shader.SetGlobalFloat(GlobalWindShader, Mathf.Max(Shader.GetGlobalFloat(GlobalWindShader), num)); Shader.SetGlobalColor(WindTintShader, Color.Lerp(Color.white, new Color(0.7f, 0.68f, 0.6f, 1f), num)); } } } private static Bounds BuildPlayerCenteredWeatherBounds(Bounds original) { //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_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_0011: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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 weatherVisualCenter = GetWeatherVisualCenter(); Vector3 size = ((Bounds)(ref original)).size; size.x = Mathf.Max(size.x, 3000f); size.y = Mathf.Max(size.y, 3000f); size.z = Mathf.Max(size.z, 3000f); return new Bounds(weatherVisualCenter, size); } private static Vector3 GetWeatherVisualCenter() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_0043: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Character.observedCharacter != (Object)null) { return Character.observedCharacter.Center; } if ((Object)(object)Character.localCharacter != (Object)null) { return Character.localCharacter.Center; } return Vector3.zero; } private static void InvokeToggleWind(WindChillZone zone, bool set, Vector3 windDirection, float untilSwitch) { //IL_003b: 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_00b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zone == (Object)null) { return; } try { if (ToggleWindRpcMethod != null) { ToggleWindRpcMethod.Invoke(zone, new object[3] { set, windDirection, untilSwitch }); } else { zone.windActive = set; CurrentWindDirectionField?.SetValue(zone, windDirection); } if (UntilSwitchRef != null) { UntilSwitchRef.Invoke(zone) = untilSwitch; } if (TimeUntilNextWindRef != null) { TimeUntilNextWindRef.Invoke(zone) = untilSwitch; } CurrentWindDirectionField?.SetValue(zone, windDirection); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Temporary weather toggle failed on {((Object)zone).name}: {arg}"); zone.windActive = set; } } private static bool HasAnyActiveWeatherEffect(bool refreshCache = true) { if (ChaosEnvironmentSync.MesaSunActive || LocalWeatherOverrides.Count > 0) { return true; } if (refreshCache) { RefreshWeatherZoneCache(force: false); } for (int i = 0; i < CachedWeatherZones.All.Count; i++) { WindChillZone val = CachedWeatherZones.All[i]; if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy && val.windActive) { return true; } } return false; } private static bool TryTriggerWeatherType(string weatherTypeName, TemporaryWeatherKind weatherKind) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient) { return false; } RefreshWeatherZoneCache(force: true); if (HasAnyActiveWeatherEffect(refreshCache: false)) { return false; } ChaosEnvironmentSync chaosEnvironmentSync = ChaosEnvironmentSync.Instance; if ((Object)(object)chaosEnvironmentSync == (Object)null) { DayNightManager instance = DayNightManager.instance; if ((Object)(object)instance != (Object)null) { ChaosEnvironmentSync.EnsureExists(((Component)instance).gameObject); chaosEnvironmentSync = ((Component)instance).GetComponent(); } } if ((Object)(object)chaosEnvironmentSync == (Object)null) { Plugin.Log.LogWarning((object)"Temporary weather failed: ChaosEnvironmentSync not found."); return false; } List localWeatherCandidates = GetLocalWeatherCandidates(weatherKind); float num = ChooseWeatherDuration(localWeatherCandidates); Vector3 windDirection = RandomWindDirection(); chaosEnvironmentSync.BroadcastTemporaryWeather((int)weatherKind, windDirection, num); Plugin.Log.LogInfo((object)$"Temporary {weatherTypeName} weather broadcast. nativeCandidateCount={localWeatherCandidates.Count}, duration={num:0.0}s."); return true; } private static float ChooseWeatherDuration(List candidates) { for (int i = 0; i < candidates.Count; i++) { WindChillZone val = candidates[i]; if (!((Object)(object)val == (Object)null)) { float num = Mathf.Max(1f, val.windTimeRangeOn.x); float num2 = Mathf.Max(num, val.windTimeRangeOn.y); if (num2 > 1f) { return Random.Range(num, num2); } } } return 25f; } private static List GetLocalWeatherCandidates(TemporaryWeatherKind weatherKind) { if (1 == 0) { } List result = weatherKind switch { TemporaryWeatherKind.Rain => CachedWeatherZones.Rain, TemporaryWeatherKind.Wind => (CachedWeatherZones.Wind.Count > 0) ? CachedWeatherZones.Wind : CachedWeatherZones.All, TemporaryWeatherKind.Snow => CachedWeatherZones.Snow, _ => CachedWeatherZones.All, }; if (1 == 0) { } return result; } private static string WeatherKindName(TemporaryWeatherKind weatherKind) { if (1 == 0) { } string result = weatherKind switch { TemporaryWeatherKind.Rain => "Rain", TemporaryWeatherKind.Wind => "Wind", TemporaryWeatherKind.Snow => "Snow", _ => "Unknown", }; if (1 == 0) { } return result; } private static int EnsureNativeWeatherVisualsActive(WindChillZone zone, TemporaryWeatherKind kind, LocalWeatherOverride state) { return 0; } private static void ResetNativeWeatherVisuals(WindChillZone zone, TemporaryWeatherKind kind) { } private static void ResetStormAudioByReflection(TemporaryWeatherKind kind) { } private static void SetAudioSourceVolume(object obj, string memberName, float volume) { object? memberValue = GetMemberValue(obj, memberName); AudioSource val = (AudioSource)((memberValue is AudioSource) ? memberValue : null); if ((Object)(object)val != (Object)null) { val.volume = volume; } } private static bool IsStormVisualComponent(Component component) { return (Object)(object)component != (Object)null && TypeNameEquals(((object)component).GetType(), "StormVisual"); } private static bool IsMatchingWeatherVisual(Component component, TemporaryWeatherKind kind) { if ((Object)(object)component == (Object)null) { return false; } string text = (GetMemberValue(component, "stormType")?.ToString() ?? string.Empty).ToLowerInvariant(); if (1 == 0) { } bool result = kind switch { TemporaryWeatherKind.Rain => text.Contains("rain"), TemporaryWeatherKind.Wind => text.Contains("wind"), TemporaryWeatherKind.Snow => text.Contains("snow"), _ => false, }; if (1 == 0) { } return result; } private static void TryRememberActivatedVisualObject(LocalWeatherOverride state, GameObject obj) { if (state == null || (Object)(object)obj == (Object)null) { return; } for (int i = 0; i < state.ActivatedVisualObjects.Count; i++) { if ((Object)(object)state.ActivatedVisualObjects[i] == (Object)(object)obj) { return; } } state.ActivatedVisualObjects.Add(obj); } private static void RefreshWeatherZoneCache(bool force) { if (!force && CachedWeatherZones.All.Count > 0 && Time.time - CachedWeatherZones.BuiltAt < 10f) { return; } CachedWeatherZones.All.Clear(); CachedWeatherZones.Rain.Clear(); CachedWeatherZones.Wind.Clear(); CachedWeatherZones.Snow.Clear(); CachedWeatherZones.BuiltAt = Time.time; WindChillZone[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); foreach (WindChillZone zone in array) { if (CanUseWeatherZone(zone)) { AddUnique(CachedWeatherZones.All, zone); bool alreadyClassified = ClassifyZoneByNativeVisuals(zone); ClassifyZoneByName(zone, alreadyClassified); } } Plugin.Log.LogInfo((object)$"Weather cache refreshed. all={CachedWeatherZones.All.Count}, rain={CachedWeatherZones.Rain.Count}, wind={CachedWeatherZones.Wind.Count}, snow={CachedWeatherZones.Snow.Count}."); } private static bool ClassifyZoneByNativeVisuals(WindChillZone zone) { return false; } private static void ClassifyZoneByName(WindChillZone zone, bool alreadyClassified) { string text = GetTransformPath(((Component)zone).transform).ToLowerInvariant(); if (text.Contains("rain") || text.Contains("tropic") || text.Contains("storm")) { AddUnique(CachedWeatherZones.Rain, zone); } if (text.Contains("wind") || text.Contains("root") || IsRootsWindZone(zone)) { AddUnique(CachedWeatherZones.Wind, zone); } if (text.Contains("snow") || text.Contains("alpine") || text.Contains("blizzard")) { AddUnique(CachedWeatherZones.Snow, zone); } if (!alreadyClassified && CachedWeatherZones.Wind.Count == 0) { AddUnique(CachedWeatherZones.Wind, zone); } } private static bool IsRootsWindZone(WindChillZone zone) { Type type = AccessTools.TypeByName("RootsWind"); if (type == null) { return false; } object obj = AccessTools.Field(type, "instance")?.GetValue(null) ?? AccessTools.Property(type, "instance")?.GetValue(null, null); if (obj == null) { return false; } object memberValue = GetMemberValue(obj, "windZone"); return memberValue == zone; } private static bool CanUseWeatherZone(WindChillZone zone) { return (Object)(object)zone != (Object)null && (Object)(object)((Component)zone).gameObject != (Object)null; } private static void AddUnique(List list, WindChillZone zone) { if ((Object)(object)zone == (Object)null) { return; } for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] == (Object)(object)zone) { return; } } list.Add(zone); } private static Vector3 RandomWindDirection() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Lerp(Vector3.right * ((Random.value > 0.5f) ? 1f : (-1f)), Vector3.forward, 0.2f); return ((Vector3)(ref val)).normalized; } private static string GetTransformPath(Transform t) { if ((Object)(object)t == (Object)null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(128); Transform val = t; while ((Object)(object)val != (Object)null) { if (stringBuilder.Length > 0) { stringBuilder.Insert(0, "/"); } stringBuilder.Insert(0, ((Object)val).name); val = val.parent; } return stringBuilder.ToString(); } private static bool TypeNameEquals(Type type, string expectedName) { return type != null && (type.Name == expectedName || type.FullName == expectedName || (type.FullName != null && type.FullName.EndsWith("." + expectedName, StringComparison.Ordinal))); } private static object? GetMemberValue(object? obj, string name) { if (obj == null || string.IsNullOrWhiteSpace(name)) { return null; } Type type = obj.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, name); if (fieldInfo != null) { return fieldInfo.GetValue(obj); } PropertyInfo propertyInfo = AccessTools.Property(type, name); if (propertyInfo != null) { return propertyInfo.GetValue(obj, null); } return null; } private static void SetMemberValue(object? obj, string name, object? value) { if (obj == null || string.IsNullOrWhiteSpace(name)) { return; } Type type = obj.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, name); if (fieldInfo != null) { fieldInfo.SetValue(obj, value); return; } PropertyInfo propertyInfo = AccessTools.Property(type, name); if (propertyInfo != null && propertyInfo.CanWrite) { propertyInfo.SetValue(obj, value, null); } } private static float GetFloatMember(object? obj, string name, float fallback) { object memberValue = GetMemberValue(obj, name); if (memberValue is float result) { return result; } if (memberValue is double num) { return (float)num; } if (memberValue is int num2) { return num2; } return fallback; } private static void SetFloatMember(object? obj, string name, float value) { if (obj != null) { SetMemberValue(obj, name, value); } } private static void InvokeMember(object? obj, string methodName) { if (obj == null || string.IsNullOrWhiteSpace(methodName)) { return; } try { AccessTools.Method(obj.GetType(), methodName, (Type[])null, (Type[])null)?.Invoke(obj, null); } catch { } } } [HarmonyPatch(typeof(WindChillZone), "HandleTime")] public static class WindChillZonePatch { [HarmonyPrefix] private static bool Prefix(WindChillZone __instance) { if (!ChaosEnvironmentController.ShouldTakeOverWindZone(__instance)) { return true; } ChaosEnvironmentController.TickControlledZone(__instance); return false; } } public static class HotSunPatch { } public static class RandomizerEvents { internal static class BP { public const BodypartType Torso = 2; public const BodypartType Head = 4; public const BodypartType LeftFoot = 13; public const BodypartType LeftHand = 14; public const BodypartType RightFoot = 16; } public static List EventQueue = new List(); public static Mutex EventQueueMutex = new Mutex(); public static List DestroyQueue = new List(); public static Mutex DestroyQueueMutex = new Mutex(); public static bool SkeletonEventActive = false; public static Vector3 OutOfSight = new Vector3(0f, -9999f, 0f); private static readonly object ScheduleLock = new object(); private const float MagicBeanVineCleanupDelaySeconds = 62f; private const float MagicBeanVineCleanupRadius = 45f; private static readonly List<(string eventName, DateTime dueUtc)> ScheduledEvents = new List<(string, DateTime)>(); private static readonly List<(GameObject obj, DateTime dueUtc)> ScheduledDestroy = new List<(GameObject, DateTime)>(); private static readonly List<(Vector3 center, float radius)> _scheduledVineCleanupCenters = new List<(Vector3, float)>(); private static int _currentImmediateEventDepth = 0; private const int MaxImmediateEventDepth = 4; private static ClimbingSpikeComponent? _cachedClimbingSpikeComponent; private static RopeShooter? _cachedRopeShooterTemplate; private static string _cachedChainShooterItemName = string.Empty; private static int _roundRobinCursor = 0; public static readonly List<(string name, ConfigEntry? weightConfigEntry, Action action)> Events = new List<(string, ConfigEntry, Action)> { ("__CleanupJungleVines", null, delegate { //IL_004d: 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) List<(Vector3, float)> list19; lock (ScheduleLock) { list19 = _scheduledVineCleanupCenters.ToList(); _scheduledVineCleanupCenters.Clear(); } foreach (var item2 in list19) { CleanupNearbyJungleVines(item2.Item1, item2.Item2); CleanupNearbyMagicBeanVines(item2.Item1, item2.Item2); } }), ("Tornado", ModConfig.Tornado, delegate { //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_0036: 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_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_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) for (int num27 = 0; num27 < 10; num27++) { if (!TryGetRandomCharacter(out Character character2)) { return; } Vector3 center = character2.Center; int num28 = ((Random.Range(0, 2) == 0) ? 1 : (-1)); center += new Vector3((float)(num28 * Random.Range(100, 600)), 0f, (float)(num28 * Random.Range(100, 600))); if (Physics.CheckSphere(center, 50f)) { GameObject val36 = SafeInstantiateNetwork("Tornado", center, Quaternion.identity); if ((Object)(object)val36 != (Object)null) { Tornado component3 = val36.GetComponent(); if ((Object)(object)component3 == (Object)null) { Plugin.Log.LogWarning((object)"Tornado skipped: Tornado component missing."); RemoveObjectAfterTime(val36, 0f); } else { GameObject val37 = new GameObject(); Object.Destroy((Object)(object)val37, 300f); val37.transform.position = character2.Center; component3.target = val37.transform; RemoveObjectAfterTime(val36, 60f); } return; } } } ForceEvent("Pandora"); }), ("Tick", ModConfig.Tick, delegate { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) List list18 = PickRandomHumans(1, 4); if (list18.Count == 0) { return; } foreach (Character item3 in list18) { GameObject val34 = SafeInstantiateNetwork("BugfixOnYou", Vector3.zero, Quaternion.identity); PhotonView val35 = (((Object)(object)val34 != (Object)null) ? val34.GetComponent() : null); if ((Object)(object)val35 != (Object)null && (Object)(object)((MonoBehaviourPun)item3).photonView != (Object)null) { val35.RPC("AttachBug", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)item3).photonView.ViewID }); } else if ((Object)(object)val34 != (Object)null) { RemoveObjectAfterTime(val34, 0f); } } }), ("Bees", ModConfig.Bees, delegate { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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) foreach (Character rotatingHuman in GetRotatingHumans()) { int num25 = RandomCountInclusive(3); for (int num26 = 0; num26 < num25; num26++) { Vector3 position11 = GetCharacterTransform(rotatingHuman, (BodypartType)4).position + new Vector3(Random.Range(-0.8f, 0.8f), Random.Range(0.2f, 1.2f), Random.Range(-0.8f, 0.8f)); GameObject val32 = SafeInstantiateNetwork("BeeSwarm", position11, Quaternion.identity); BeeSwarm val33 = (((Object)(object)val32 != (Object)null) ? val32.GetComponent() : null); if ((Object)(object)val33 != (Object)null && (Object)(object)((MonoBehaviourPun)val33).photonView != (Object)null) { ((MonoBehaviourPun)val33).photonView.RPC("SetBeesAngryRPC", (RpcTarget)3, new object[1] { true }); RemoveObjectAfterTime(val32, 3f); } else if ((Object)(object)val32 != (Object)null) { RemoveObjectAfterTime(val32, 0f); } } } }), ("Tumbleweed", ModConfig.Tumbleweed, delegate { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009b: Unknown result type (might be due to invalid IL or missing references) foreach (Character rotatingHuman2 in GetRotatingHumans()) { Vector3 val31 = GetCharacterTransform(rotatingHuman2, (BodypartType)14).position; int num21 = RandomCountFromOriginalRange(2, 5); for (int num22 = 0; num22 < num21; num22++) { int num23 = ((Random.Range(0, 2) == 0) ? 1 : (-1)); int num24 = ((Random.Range(0, 2) == 0) ? 1 : (-1)); val31 += new Vector3((float)(num23 * Random.Range(1, 10)), 0f, (float)(num24 * Random.Range(1, 10))); if (Physics.CheckSphere(val31, 10f)) { GameObject obj9 = SafeInstantiateNetwork("TumbleWeed", val31, Quaternion.identity); RemoveObjectAfterTime(obj9, 15f); } } } }), ("Dynamite", ModConfig.Dynamite, delegate { List list17 = (from x in PickRandomHumans(1, 4) where CanReceiveSpawnedItems(x) select x).ToList(); if (list17.Count == 0) { return; } bool extendedFuse = Random.Range(0f, 1f) < Mathf.Clamp(ModConfig.ExtendedDynamiteChance.Value, 0f, 1f); foreach (Character item4 in list17) { GiveDynamiteToCharacter(item4, extendedFuse); } }), ("Zombie", ModConfig.Zombie, delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0079: Unknown result type (might be due to invalid IL or missing references) if (TryGetRandomCharacter(out Character character)) { Vector3 pos2 = GetCharacterTransform(character, (BodypartType)2).position; MushroomZombie[] source2 = Object.FindObjectsByType((FindObjectsSortMode)0); if (!source2.Any((MushroomZombie z) => (Object)(object)z != (Object)null && Vector3.Distance(((Component)z).transform.position, pos2) <= 30f) && Physics.CheckSphere(pos2, 5f)) { GameObject obj8 = SafeInstantiateNetwork("MushroomZombie", pos2, Quaternion.identity); RemoveObjectAfterTime(obj8, 25f); } } }), ("Mandrake", ModConfig.Mandrake, delegate { //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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_013b: Unknown result type (might be due to invalid IL or missing references) List list15 = PickRandomHumans(1, 4); if (list15.Count == 0) { return; } Mandrake[] source = Object.FindObjectsByType((FindObjectsSortMode)0); List list16 = new List(); foreach (Character item5 in list15) { if (TryGetCharacterTransform(item5, (BodypartType)4, out Transform transform3)) { Vector3 pos = transform3.position; if (!source.Any((Mandrake m) => (Object)(object)m != (Object)null && Vector3.Distance(((Component)m).transform.position, pos) <= 25f) && !list16.Any((Vector3 p) => Vector3.Distance(p, pos) <= 25f)) { Vector3 val28 = pos + new Vector3(0f, 2f, 0f); if (!Physics.CheckSphere(val28, 2f)) { val28 = pos; } GameObject val29 = SafeInstantiateItemRoom("Mandrake", val28, Quaternion.identity); Mandrake val30 = (((Object)(object)val29 != (Object)null) ? val29.GetComponent() : null); if ((Object)(object)val30 != (Object)null && (Object)(object)((ItemComponent)val30).photonView != (Object)null) { list16.Add(pos); ((ItemComponent)val30).photonView.RPC("RPC_Scream", (RpcTarget)0, Array.Empty()); RemoveObjectAfterTime(val29, 10f); } else if ((Object)(object)val29 != (Object)null) { RemoveObjectAfterTime(val29, 0f); } } } } }), ("Cactus", ModConfig.Cactus, delegate { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) foreach (Character rotatingHuman3 in GetRotatingHumans()) { Vector3 position10 = GetCharacterTransform(rotatingHuman3, (BodypartType)13).position; GameObject obj7 = SafeInstantiateItemRoom("CactusBall", position10, Quaternion.identity); RemoveObjectAfterTime(obj7, 10f); } }), ("RandomItem", ModConfig.RandomItem, delegate { foreach (Character item6 in from x in GetRotatingHumans() where CanReceiveSpawnedItems(x) select x) { try { if (CustomLoot.TryGetRandomEventItem(out Item item) && (Object)(object)item != (Object)null) { CustomLoot.MarkSpawned(((Object)item).name); SummonToCharacter(item6, ((Object)item).name); } } catch (Exception arg6) { Plugin.Log.LogWarning((object)string.Format("RandomItem failed for {0}: {1}", ((item6 != null) ? ((Object)item6).name : null) ?? "", arg6)); } } }), ("RandomGoodItem", ModConfig.RandomGoodItem, delegate { foreach (Character item7 in from x in GetRotatingHumans() where CanReceiveSpawnedItems(x) select x) { try { SummonToCharacter(item7, CustomLoot.GoodItems.ElementAt(Random.Range(0, CustomLoot.GoodItems.Count))); } catch (Exception arg5) { Plugin.Log.LogWarning((object)string.Format("RandomGoodItem failed for {0}: {1}", ((item7 != null) ? ((Object)item7).name : null) ?? "", arg5)); } } }), ("RandomGoodItemRain", ModConfig.RandomGoodItemRain, delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00d0: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) foreach (Character rotatingHuman4 in GetRotatingHumans()) { Vector3 position9 = GetCharacterTransform(rotatingHuman4, (BodypartType)4).position; int num20; for (num20 = 5; num20 > 0; num20--) { Vector3 val23 = position9 + new Vector3(0f, (float)num20, 0f); if (Physics.CheckSphere(val23, 5f)) { break; } } Vector3 val24 = position9 + new Vector3(0f, (float)num20, 0f); List list14 = new List { new Vector3(-2f, 0f, -2f), new Vector3(-2f, 0f, 0f), new Vector3(0f, 0f, -2f), new Vector3(0f, 0f, 0f) }; int count2 = RandomCountInclusive(list14.Count); list14 = TakeRandom(list14, count2); foreach (Vector3 item8 in list14) { Vector3 val25 = val24 + new Vector3(item8.x + Random.Range(-1f, 1f), Random.Range(-2f, 2f), item8.z + Random.Range(-1f, 1f)); if (Physics.CheckSphere(val25, 5f)) { string text2 = CustomLoot.GoodItems.ElementAt(Random.Range(0, CustomLoot.GoodItems.Count)); if (text2 == "Cure-All") { text2 = "FortifiedMilk"; } GameObject val26 = SafeInstantiateItemRoom(text2, val25, Quaternion.identity); Item val27 = (((Object)(object)val26 != (Object)null) ? val26.GetComponent() : null); if ((Object)(object)val27 != (Object)null) { val27.SetKinematicNetworked(false); } RemoveObjectAfterTime(val26); } } } }), ("BingBongRain", ModConfig.BingBongRain, delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00d0: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) foreach (Character rotatingHuman5 in GetRotatingHumans()) { Vector3 position8 = GetCharacterTransform(rotatingHuman5, (BodypartType)4).position; int num19; for (num19 = 5; num19 > 0; num19--) { Vector3 val20 = position8 + new Vector3(0f, (float)num19, 0f); if (Physics.CheckSphere(val20, 5f)) { break; } } Vector3 val21 = position8 + new Vector3(0f, (float)num19, 0f); List list13 = new List { new Vector3(-2f, 0f, -2f), new Vector3(-2f, 0f, 0f), new Vector3(0f, 0f, -2f), new Vector3(0f, 0f, 0f) }; int count = RandomCountInclusive(list13.Count); list13 = TakeRandom(list13, count); foreach (Vector3 item9 in list13) { Vector3 val22 = val21 + new Vector3(item9.x + Random.Range(-1f, 1f), Random.Range(-2f, 2f), item9.z + Random.Range(-1f, 1f)); if (Physics.CheckSphere(val22, 5f)) { GameObject obj6 = SafeInstantiateItemRoom("BingBong", val22, Quaternion.identity); RemoveObjectAfterTime(obj6, 5f); } } } }), ("CureAll", ModConfig.CureAll, delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) foreach (Character rotatingHuman6 in GetRotatingHumans(excludeDead: true, excludePassedOut: false)) { Vector3 position7 = GetCharacterTransform(rotatingHuman6, (BodypartType)4).position; GameObject val18 = SafeInstantiateItemRoom("Cure-All", position7, Quaternion.identity); Item val19 = (((Object)(object)val18 != (Object)null) ? val18.GetComponent() : null); if ((Object)(object)((val19 == null) ? null : ((ItemComponent)(val19.cooking?)).photonView) != (Object)null) { ((ItemComponent)val19.cooking).photonView.RPC("RPC_CookingExplode", (RpcTarget)0, Array.Empty()); } RemoveObjectAfterTime(val18, 5f); } }), ("Pandora", ModConfig.Pandora, delegate { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) foreach (Character rotatingHuman7 in GetRotatingHumans(excludeDead: true, excludePassedOut: false)) { Vector3 position6 = GetCharacterTransform(rotatingHuman7, (BodypartType)4).position; GameObject val16 = SafeInstantiateItemRoom("PandorasBox", position6, Quaternion.identity); Item val17 = (((Object)(object)val16 != (Object)null) ? val16.GetComponent() : null); if ((Object)(object)((val17 == null) ? null : ((ItemComponent)(val17.cooking?)).photonView) != (Object)null) { ((ItemComponent)val17.cooking).photonView.RPC("RPC_CookingExplode", (RpcTarget)0, Array.Empty()); } RemoveObjectAfterTime(val16, 5f); } }), ("SwapPlayers", ModConfig.SwapPlayers, delegate { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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) List list10 = (from c in GetRotatingHumans(excludeDead: true, excludePassedOut: false) where !c.data.isInFog select c).ToList(); if (list10.Count >= 2) { List list11 = new List(); foreach (Character item10 in list10) { list11.Add(GetCharacterTransform(item10, (BodypartType)2).position); PrepCharacterAsTeleportDestination(item10); PrepCharacterAsTeleportee(item10); } List list12 = list11.ToList(); list12 = ExtCollections.Shuffle((IList)list12).ToList(); if (list12.SequenceEqual(list11) && list12.Count > 1) { Vector3 value2 = list12[0]; for (int num17 = 0; num17 < list12.Count - 1; num17++) { list12[num17] = list12[num17 + 1]; } list12[list12.Count - 1] = value2; } for (int num18 = 0; num18 < list10.Count; num18++) { SafeWarpPlayer(list10[num18], list12[num18], poof: true, "SwapPlayers"); } } }), ("WarpToLastPlayer", ModConfig.WarpToLastPlayer, delegate { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_011a: Unknown result type (might be due to invalid IL or missing references) Vector3 val14 = Singleton.Instance.peakSequence.transform.position + new Vector3(0f, 20f, 0f); List list9 = (from c in GetRotatingHumans(excludeDead: true, excludePassedOut: false) where !c.data.isInFog select c).ToList(); if (list9.Count == 0) { return; } Character val15 = list9[0]; float num15 = Vector3.Distance(val14, GetCharacterTransform(val15, (BodypartType)2).position); foreach (Character item11 in list9.Skip(1)) { float num16 = Vector3.Distance(val14, GetCharacterTransform(item11, (BodypartType)2).position); if (num16 > num15) { num15 = num16; val15 = item11; } } PrepCharacterAsTeleportDestination(val15); foreach (Character item12 in list9) { if ((Object)(object)item12 != (Object)(object)val15) { SafeWarpPlayer(item12, GetPosForTeleportingTo(val15), poof: true, "WarpToLastPlayer"); } } }), ("SwapPlayerItems", ModConfig.SwapPlayerItems, delegate { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) List rotatingHumans4 = GetRotatingHumans(); if (rotatingHumans4.Count >= 2) { if (rotatingHumans4.Any((Character c) => (Object)(object)c != (Object)null && (Object)(object)c.data != (Object)null && (Object)(object)c.data.currentItem != (Object)null && (Object)(object)((Component)c.data.currentItem).GetComponent() != (Object)null)) { Plugin.Log.LogInfo((object)"SwapPlayerItems skipped because a player is holding a RescueHook-type item."); } else if (rotatingHumans4.Any(HasTemporaryHeldItem)) { Plugin.Log.LogInfo((object)"SwapPlayerItems skipped because a player is using tempFullSlot."); } else { List list6 = new List(); List list7 = new List(); InventorySyncData val9 = default(InventorySyncData); foreach (Character item13 in rotatingHumans4) { Player player = item13.player; ((InventorySyncData)(ref val9))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot); list6.Add(IBinarySerializable.ToManagedArray(val9)); list7.Add(val9.tempSlot); ItemSlot[] itemSlots = player.itemSlots; foreach (ItemSlot val10 in itemSlots) { val10.EmptyOut(); } ((ItemSlot)player.backpackSlot).EmptyOut(); player.tempFullSlot.EmptyOut(); byte[] array5 = IBinarySerializable.ToManagedArray(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot)); item13.player.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array5, true }); item13.refs.items.photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty()); } List list8 = list6.ToList(); list8 = ExtCollections.Shuffle((IList)list8).ToList(); if (list8.SequenceEqual(list6) && list8.Count > 1) { byte[] value = list8[0]; for (int num13 = 0; num13 < list8.Count - 1; num13++) { list8[num13] = list8[num13 + 1]; } list8[list8.Count - 1] = value; } for (int num14 = 0; num14 < rotatingHumans4.Count; num14++) { Character val11 = rotatingHumans4[num14]; Player player2 = val11.player; InventorySyncData fromManagedArray = IBinarySerializable.GetFromManagedArray(list8[num14]); fromManagedArray.tempSlot = list7[num14]; byte[] array6 = IBinarySerializable.ToManagedArray(fromManagedArray); player2.view.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array6, true }); if (val11.refs.items.currentSelectedSlot.IsSome) { ItemSlot itemSlot = val11.player.GetItemSlot(val11.refs.items.currentSelectedSlot.Value); if (!itemSlot.IsEmpty()) { Transform transform2 = ((Component)val11.GetBodypart((BodypartType)2)).transform; GameObject val12 = SafeInstantiateNetwork("0_Items/" + itemSlot.GetPrefabName(), transform2.position + transform2.forward * 0.6f, Quaternion.identity); PhotonView val13 = (((Object)(object)val12 != (Object)null) ? val12.GetComponent() : null); if (!((Object)(object)val13 == (Object)null)) { val13.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { itemSlot.data }); val11.refs.items.photonView.RPC("EquipSlotRpc", (RpcTarget)0, new object[2] { (int)val11.refs.items.currentSelectedSlot.Value, val13.ViewID }); } } } } } } }), ("SwapPlayerStatuses", ModConfig.SwapPlayerStatuses, delegate { SwapPlayerStatusesSafe(); }), ("ReviveOne", ModConfig.ReviveOne, delegate { //IL_00af: Unknown result type (might be due to invalid IL or missing references) List list5 = DeadHumanCharacters(); if (list5.Count != 0) { List rotatingHumans3 = GetRotatingHumans(); if (rotatingHumans3.Count != 0) { Character scout2 = rotatingHumans3[Random.Range(0, rotatingHumans3.Count)]; Character val8 = list5[Random.Range(0, list5.Count)]; if (!((Object)(object)val8 == (Object)null) && !((Object)(object)((MonoBehaviourPun)val8).photonView == (Object)null)) { PrepCharacterAsTeleportDestination(scout2); if (TryGetPosForTeleportingTo(scout2, out var targetPos2)) { ((MonoBehaviourPun)val8).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { targetPos2, false, -1 }); } } } } }), ("ReviveAll", ModConfig.ReviveAll, delegate { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) List list4 = DeadHumanCharacters(); if (list4.Count != 0) { List rotatingHumans2 = GetRotatingHumans(); if (rotatingHumans2.Count != 0) { foreach (Character item14 in list4) { if (!((Object)(object)item14 == (Object)null) && !((Object)(object)((MonoBehaviourPun)item14).photonView == (Object)null)) { Character scout = rotatingHumans2[Random.Range(0, rotatingHumans2.Count)]; PrepCharacterAsTeleportDestination(scout); if (TryGetPosForTeleportingTo(scout, out var targetPos)) { ((MonoBehaviourPun)item14).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[2] { targetPos, false }); } } } } } }), ("HealShroom", ModConfig.HealShroom, delegate { //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) foreach (Character rotatingHuman8 in GetRotatingHumans(excludeDead: true, excludePassedOut: false)) { GameObject obj5 = SafeInstantiateItemRoom("HealingPuffShroomSpawn", GetCharacterTransform(rotatingHuman8, (BodypartType)2).position, Quaternion.identity); RemoveObjectAfterTime(obj5); } }), ("BounceShroom", ModConfig.BounceShroom, delegate { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) foreach (Character rotatingHuman9 in GetRotatingHumans()) { Vector3 position4 = GetCharacterTransform(rotatingHuman9, (BodypartType)13).position; Vector3 position5 = GetCharacterTransform(rotatingHuman9, (BodypartType)16).position; GameObject obj4 = SafeInstantiateItemRoom("BounceShroomSpawn", Vector3.Lerp(position4, position5, 0.5f) - new Vector3(0f, 0.5f, 0f), Quaternion.identity); RemoveObjectAfterTime(obj4); } }), ("MoraleBoost", ModConfig.MoraleBoost, delegate { List rotatingHumans = GetRotatingHumans(excludeDead: true, excludePassedOut: false); foreach (Character item15 in rotatingHumans) { ((MonoBehaviourPun)item15).photonView.RPC("MoraleBoost", (RpcTarget)0, new object[2] { 1f, rotatingHumans.Count }); } }), ("Scorpion", ModConfig.Scorpion, delegate { foreach (Character rotatingHuman10 in GetRotatingHumans()) { SummonToCharacter(rotatingHuman10, "Scorpion"); } }), ("RandomBackpackGood", ModConfig.RandomBackpackGood, delegate { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (Random.Range(0f, 1f) < Mathf.Clamp(ModConfig.BoobyTrappedBackpacksChance.Value, 0f, 1f)) { ForceEvent("RandomBackpackTroll"); return; } foreach (Character item16 in from x in GetRotatingHumans() where CanReceiveSpawnedItems(x) select x) { if (TryGetSafeSpawnPosAboveCharacter(item16, (BodypartType)4, 4f, 4f, out var spawnPos3)) { try { int num10 = RandomCountInclusive(4); string[] array4 = new string[num10]; for (int num11 = 0; num11 < num10; num11++) { array4[num11] = CustomLoot.GoodItemsBackpack.ElementAt(Random.Range(0, CustomLoot.GoodItemsBackpack.Count)); } GameObject obj3 = SpawnBackpackWithItems(spawnPos3, array4); RemoveObjectAfterTime(obj3); } catch (Exception arg4) { Plugin.Log.LogWarning((object)string.Format("RandomBackpackGood failed for {0}: {1}", ((item16 != null) ? ((Object)item16).name : null) ?? "", arg4)); } } } }), ("RandomBackpack", ModConfig.RandomBackpack, delegate { //IL_0140: Unknown result type (might be due to invalid IL or missing references) foreach (Character item17 in from x in GetRotatingHumans() where CanReceiveSpawnedItems(x) select x) { if (TryGetSafeSpawnPosAboveCharacter(item17, (BodypartType)4, 4f, 4f, out var spawnPos2)) { try { int num8 = RandomCountInclusive(4); string[] array3 = new string[num8]; Dictionary itemsDatabaseFiltered = CustomLoot.GetItemsDatabaseFiltered(); if (itemsDatabaseFiltered.Count != 0) { for (int num9 = 0; num9 < num8; num9++) { string text = ((Object)itemsDatabaseFiltered.ElementAt(Random.Range(0, itemsDatabaseFiltered.Count)).Value).name; switch (text) { case "Backpack": text = "Airplane Food"; break; case "Dynamite": text = "TrailMix"; break; case "Mandrake": text = "RescueHook"; break; case "Scorpion": text = "ScoutCookies"; break; } array3[num9] = text; } GameObject obj2 = SpawnBackpackWithItems(spawnPos2, array3); RemoveObjectAfterTime(obj2); } } catch (Exception arg3) { Plugin.Log.LogWarning((object)string.Format("RandomBackpack failed for {0}: {1}", ((item17 != null) ? ((Object)item17).name : null) ?? "", arg3)); } } } }), ("Beanstalk", ModConfig.Beanstalk, delegate { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //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_0039: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_00f9: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) Vector3 val7 = default(Vector3); foreach (Character rotatingHuman11 in GetRotatingHumans()) { Vector3 position2 = GetCharacterTransform(rotatingHuman11, (BodypartType)13).position; Vector3 position3 = GetCharacterTransform(rotatingHuman11, (BodypartType)16).position; Vector3 val4 = Vector3.Lerp(position2, position3, 0.5f); GameObject val5 = SafeInstantiateItemRoom("MagicBean", val4, Quaternion.identity); MagicBean val6 = (((Object)(object)val5 != (Object)null) ? val5.GetComponent() : null); if ((Object)(object)val6 == (Object)null || (Object)(object)((ItemComponent)val6).photonView == (Object)null) { RemoveObjectAfterTime(val5, 0f); } else { ((Vector3)(ref val7))..ctor(Random.Range(-1f, 1f), Random.Range(0.15f, 1f), Random.Range(-1f, 1f)); val7 = ((((Vector3)(ref val7)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val7)).normalized : Vector3.up); float magicBeanVineDistance = GetMagicBeanVineDistance(val6, val4, val7); ((ItemComponent)val6).photonView.RPC("GrowVineRPC", (RpcTarget)0, new object[3] { val4, val7, magicBeanVineDistance }); RemoveObjectAfterTime(val5, 60f); ScheduleJungleVineCleanup(val4, 45f, 62f); ChaosEnvironmentSync.BroadcastMagicBeanVineCleanupForAllClients(val4, 45f, 62f); } } }), ("BeanstalkSpam", ModConfig.BeanstalkSpam, delegate { int num7 = RandomCountInclusive(3); for (int n = 0; n < num7; n++) { ForceEvent("Beanstalk"); } }), ("EnergyDrink", ModConfig.EnergyDrink, delegate { SpawnAndFeedToAll("Energy Drink", 1); }), ("Lollipop", ModConfig.Lollipop, delegate { SpawnAndFeedToAll("Lollipop", 1); }), ("Milk", ModConfig.Milk, delegate { SpawnAndFeedToAll("FortifiedMilk"); }), ("UnlimitedPower", ModConfig.UnlimitedPower, delegate { SpawnAndFeedToAll("Energy Drink", 1); SpawnAndFeedToAll("Lollipop", 1); SpawnAndFeedToAll("FortifiedMilk"); }), ("TwoAtOnce", ModConfig.TwoAtOnce, delegate { int num6 = RandomCountInclusive(2); for (int l = 0; l < num6; l++) { ForceRandomEvent("TwoAtOnce"); } }), ("Skeleton", ModConfig.Skeleton, delegate { SkeletonEventActive = true; foreach (Character rotatingHuman12 in GetRotatingHumans()) { rotatingHuman12.data.SetSkeleton(!rotatingHuman12.data.isSkeleton); } ScheduleEvent("SkeletonCure", Random.Range(30f, 60f)); }), ("SkeletonCure", null, delegate { SkeletonEventActive = false; foreach (Character rotatingHuman13 in GetRotatingHumans()) { rotatingHuman13.data.SetSkeleton(!rotatingHuman13.data.isSkeleton); } }), ("TieBalloon", ModConfig.TieBalloon, delegate { foreach (Character rotatingHuman14 in GetRotatingHumans()) { rotatingHuman14.refs.balloons.TieNewBalloon(0); } }), ("TieThreeBalloons", ModConfig.TieThreeBalloons, delegate { foreach (Character rotatingHuman15 in GetRotatingHumans()) { int num5 = RandomCountInclusive(3); for (int k = 0; k < num5; k++) { rotatingHuman15.refs.balloons.TieNewBalloon(0); } } }), ("Web", ModConfig.Web, delegate { //IL_0024: 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) foreach (Character rotatingHuman16 in GetRotatingHumans()) { rotatingHuman16.TryStickBodypart(rotatingHuman16.GetBodypart((BodypartType)4), default(Vector3), (STATUSTYPE)11, 0.25f); } }), ("Antirope", ModConfig.Antirope, delegate { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) foreach (Character rotatingHuman17 in GetRotatingHumans()) { if (IsCharacterUsable(rotatingHuman17) && !rotatingHuman17.data.dead && !rotatingHuman17.data.fullyPassedOut && !rotatingHuman17.data.passedOut && !rotatingHuman17.data.isClimbingAnything && TryGetCharacterTransform(rotatingHuman17, (BodypartType)4, out Transform transform)) { Vector3 position = transform.position; try { GameObject val3 = SafeInstantiateNetwork("RopeAnchorForRopeShooterAnti", position, Quaternion.identity); if ((Object)(object)val3 == (Object)null) { Plugin.Log.LogWarning((object)"Antirope skipped: anchor instantiate returned null."); } else { RopeAnchorProjectile component = val3.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)component.photonView == (Object)null) { Plugin.Log.LogWarning((object)"Antirope skipped: RopeAnchorProjectile missing."); RemoveObjectAfterTime(val3, 0f); } else { float num3 = Random.Range(25f, 60f); int num4 = Random.Range(0, 100); if (num4 < 10) { num3 = Random.Range(100f, 150f); } else if (num4 < 20) { num3 = Random.Range(1f, 10f); } else if (num4 == 99) { num3 = 300f; } component.photonView.RPC("GetShot", (RpcTarget)3, new object[4] { position, 0f, num3, Vector3.up }); RemoveObjectAfterTime(val3, 120f); RopeAnchorWithRope component2 = val3.GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.ropeInstance != (Object)null) { RemoveObjectAfterTime(component2.ropeInstance, 120f); } } } } catch (Exception arg2) { Plugin.Log.LogWarning((object)string.Format("Antirope failed for {0}: {1}", ((rotatingHuman17 != null) ? ((Object)rotatingHuman17).name : null) ?? "", arg2)); } } } }), ("PitonPatch", ModConfig.PitonPatch, delegate { PlaceVanillaPitonPatch(); }), ("ChainCache", ModConfig.ChainCache, delegate { GiveVanillaChainCache(); }), ("ToxicBounceShroom", ModConfig.ToxicBounceShroom, delegate { SpawnToxicBounceShrooms(); }), ("LowGravityShroom", ModConfig.LowGravityShroom, delegate { FeedLowGravityMushroom(); }), ("SleepySpores", ModConfig.SleepySpores, delegate { ApplySleepySpores(); }), ("FungusCloud", ModConfig.FungusCloud, delegate { SpawnSmallFungusCloud(); }), ("DayNight", ModConfig.DayNight, delegate { if ((Object)(object)DayNightManager.instance != (Object)null && (Object)(object)DayNightManager.instance.photonView != (Object)null) { DayNightManager.instance.photonView.RPC("RPCA_SyncTime", (RpcTarget)0, new object[1] { (DayNightManager.instance.timeOfDay + 12f) % 24f }); } }), ("TropicsRain", ModConfig.TropicsRain, delegate { if (!ChaosEnvironmentController.TryTriggerTropicsRain()) { ForceRandomEvent("TropicsRain", "RootsWindRandom", "AlpineSnowRandom", "MesaSunRandom"); } }), ("RootsWindRandom", ModConfig.RootsWindRandom, delegate { if (!ChaosEnvironmentController.TryTriggerRootsWind()) { ForceRandomEvent("TropicsRain", "RootsWindRandom", "AlpineSnowRandom", "MesaSunRandom"); } }), ("AlpineSnowRandom", ModConfig.AlpineSnowRandom, delegate { if (!ChaosEnvironmentController.TryTriggerAlpineSnow()) { ForceRandomEvent("TropicsRain", "RootsWindRandom", "AlpineSnowRandom", "MesaSunRandom"); } }), ("MesaSunRandom", ModConfig.MesaSunRandom, delegate { if (!ChaosEnvironmentController.TryTriggerMesaSun()) { ForceRandomEvent("TropicsRain", "RootsWindRandom", "AlpineSnowRandom", "MesaSunRandom"); } }), ("Eruption", ModConfig.Eruption, delegate { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) EruptionSpawner val = Object.FindAnyObjectByType(); PhotonView val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { List list2 = new List(); List list3 = PickPartialHumans(1, 0.35f, 3); foreach (Character item18 in list3) { if (TryGetSafeEruptionPointNearCharacter(item18, list2, out var point)) { val2.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { point }); list2.Add(point); } } if (list2.Count > 0) { ScheduleEvent("EruptionAloe", 25f); } } }), ("EruptionAloe", null, delegate { int num2 = RandomCountInclusive(2); for (int j = 0; j < num2; j++) { SpawnAndFeedToAll("AloeVera"); } }), ("RandomBackpackTroll", null, delegate { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) foreach (Character item19 in from x in GetRotatingHumans() where CanReceiveSpawnedItems(x) select x) { if (TryGetSafeSpawnPosAboveCharacter(item19, (BodypartType)4, 4f, 4f, out var spawnPos)) { try { int num = RandomCountInclusive(4); string[] array = new string[num]; string[] array2 = new string[num]; for (int i = 0; i < num; i++) { array[i] = CustomLoot.TrollItems.ElementAt(Random.Range(0, CustomLoot.TrollItems.Count)); array2[i] = CustomLoot.GoodItemsBackpack.ElementAt(Random.Range(0, CustomLoot.GoodItemsBackpack.Count)); } GameObject obj = SpawnBackpackWithItemsTroll(spawnPos, array, array2); RemoveObjectAfterTime(obj); } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("RandomBackpackTroll failed for {0}: {1}", ((item19 != null) ? ((Object)item19).name : null) ?? "", arg)); } } } }), ("DynamiteExtended", null, delegate { List list = (from x in PickRandomHumans(1, 4) where CanReceiveSpawnedItems(x) select x).ToList(); foreach (Character item20 in list) { GiveDynamiteToCharacter(item20, extendedFuse: true); } }), ("ListItems", null, delegate { Plugin.Log.LogInfo((object)string.Join("\n", SingletonAsset.Instance.itemLookup.Values.Select((Item x) => ((Object)x).name))); }) }; private static bool CanSpawnNetworkObjects() { return PhotonNetwork.IsMasterClient && (PhotonNetwork.OfflineMode || PhotonNetwork.InRoom); } private static GameObject SafeInstantiateItemRoom(string itemName, Vector3 position, Quaternion rotation) { //IL_0020: 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) if (string.IsNullOrWhiteSpace(itemName) || !CanSpawnNetworkObjects()) { return null; } try { return PhotonNetwork.InstantiateItemRoom(itemName, position, rotation); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SafeInstantiateItemRoom failed for {itemName}: {arg}"); return null; } } private static GameObject SafeInstantiateNetwork(string prefabName, Vector3 position, Quaternion rotation) { //IL_0020: 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) if (string.IsNullOrWhiteSpace(prefabName) || !CanSpawnNetworkObjects()) { return null; } try { return PhotonNetwork.Instantiate(prefabName, position, rotation, (byte)0, (object[])null); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SafeInstantiateNetwork failed for {prefabName}: {arg}"); return null; } } private static int RandomCountInclusive(int maxInclusive) { return Random.Range(1, Mathf.Max(1, maxInclusive) + 1); } private static bool CanReceiveSpawnedItems(Character c, bool allowPassedOut = false) { if (!IsCharacterUsable(c)) { return false; } if (c.data.dead || c.data.fullyPassedOut) { return false; } if (!allowPassedOut && c.data.passedOut) { return false; } if (c.data.isInFog) { return false; } return true; } private static int RandomCountFromOriginalRange(int originalMinInclusive, int originalMaxExclusive) { int num = Mathf.Max(originalMinInclusive, originalMaxExclusive - 1); return Random.Range(1, num + 1); } private static float GetMagicBeanVineDistance(MagicBean magicBean, Vector3 startPos, Vector3 direction) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0058: 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_007b: Unknown result type (might be due to invalid IL or missing references) float num = 20f; try { if ((Object)(object)magicBean != (Object)null && (Object)(object)magicBean.plantPrefab != (Object)null) { num = Mathf.Max(0.5f, magicBean.plantPrefab.maxLength); } RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[128]; int num2 = HelperFunctions.LineCheckAll(startPos, startPos + ((Vector3)(ref direction)).normalized * num, (LayerType)1, array, 0f, (QueryTriggerInteraction)1); float num3 = num; for (int i = 0; i < num2; i++) { RaycastHit val = array[i]; if ((Object)(object)((RaycastHit)(ref val)).collider != (Object)null && ((RaycastHit)(ref val)).distance > 0.7f && ((RaycastHit)(ref val)).distance < num3) { num3 = ((RaycastHit)(ref val)).distance; } } return Mathf.Max(0.5f, num3); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"GetMagicBeanVineDistance fallback used: {arg}"); return num; } } private static void CleanupNearbyJungleVines(Vector3 center, float radius) { //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) JungleVine[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); JungleVine[] array2 = array; foreach (JungleVine val in array2) { if (!((Object)(object)val == (Object)null) && Vector3.Distance(((Component)val).transform.position, center) <= radius) { RemoveObjectAfterTime(((Component)val).gameObject, 0f); } } } public static void CleanupNearbyMagicBeanVines(Vector3 center, float radius) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) MagicBeanVine[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); int num = 0; MagicBeanVine[] array2 = array; foreach (MagicBeanVine val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && !(Vector3.Distance(((Component)val).transform.position, center) > radius)) { Object.Destroy((Object)(object)((Component)val).gameObject); num++; } } if (num > 0) { Plugin.Log.LogInfo((object)$"Cleaned up {num} MagicBeanVine object(s) near event bean."); } } private static void ScheduleJungleVineCleanup(Vector3 center, float radius, float delaySeconds) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) ScheduleEvent("__CleanupJungleVines", delaySeconds); lock (ScheduleLock) { _scheduledVineCleanupCenters.Add((center, radius)); } } private static void WithMutex(Mutex mutex, Action action) { mutex.WaitOne(); try { action(); } finally { mutex.ReleaseMutex(); } } public static void ClearPendingQueues() { WithMutex(EventQueueMutex, delegate { EventQueue.Clear(); }); WithMutex(DestroyQueueMutex, delegate { DestroyQueue.Clear(); }); lock (ScheduleLock) { ScheduledEvents.Clear(); ScheduledDestroy.Clear(); _scheduledVineCleanupCenters.Clear(); } } public static void ScheduleEvent(string eventName, float delaySeconds) { lock (ScheduleLock) { ScheduledEvents.Add((eventName, DateTime.UtcNow.AddSeconds(Mathf.Max(0f, delaySeconds)))); } } public static void ScheduleDestroy(GameObject obj, float delaySeconds) { if ((Object)(object)obj == (Object)null) { return; } lock (ScheduleLock) { ScheduledDestroy.Add((obj, DateTime.UtcNow.AddSeconds(Mathf.Max(0f, delaySeconds)))); } } public static void FlushScheduledWork() { List readyEvents = new List(); List readyDestroy = new List(); DateTime utcNow = DateTime.UtcNow; lock (ScheduleLock) { for (int num = ScheduledEvents.Count - 1; num >= 0; num--) { if (ScheduledEvents[num].dueUtc <= utcNow) { readyEvents.Add(ScheduledEvents[num].eventName); ScheduledEvents.RemoveAt(num); } } for (int num2 = ScheduledDestroy.Count - 1; num2 >= 0; num2--) { if (ScheduledDestroy[num2].dueUtc <= utcNow) { readyDestroy.Add(ScheduledDestroy[num2].obj); ScheduledDestroy.RemoveAt(num2); } } } if (readyEvents.Count > 0) { WithMutex(EventQueueMutex, delegate { EventQueue.AddRange(readyEvents); }); } if (readyDestroy.Count > 0) { WithMutex(DestroyQueueMutex, delegate { DestroyQueue.AddRange(readyDestroy); }); } } public static List DequeueEvents(int maxCount) { List result = new List(); if (maxCount <= 0) { return result; } WithMutex(EventQueueMutex, delegate { int num = Mathf.Min(maxCount, EventQueue.Count); if (num > 0) { result.AddRange(EventQueue.Take(num)); EventQueue.RemoveRange(0, num); } }); return result; } public static List DequeueDestroy(int maxCount) { List result = new List(); if (maxCount <= 0) { return result; } WithMutex(DestroyQueueMutex, delegate { int num = Mathf.Min(maxCount, DestroyQueue.Count); if (num > 0) { result.AddRange(DestroyQueue.Take(num)); DestroyQueue.RemoveRange(0, num); } }); return result; } private static List GetRotatingHumans(bool excludeDead = true, bool excludePassedOut = true) { List list = HumanCharacters(excludeDead, excludePassedOut); if (list.Count <= 1) { return list; } int num = _roundRobinCursor % list.Count; _roundRobinCursor = (_roundRobinCursor + 1) % list.Count; List list2 = new List(list.Count); for (int i = 0; i < list.Count; i++) { list2.Add(list[(num + i) % list.Count]); } return list2; } private static List PickRandomHumans(int minCountInclusive, int maxCountInclusive, bool excludeDead = true, bool excludePassedOut = true) { List list = HumanCharacters(excludeDead, excludePassedOut); if (list.Count == 0) { return list; } int num = Mathf.Clamp(maxCountInclusive, 1, list.Count); int num2 = Mathf.Clamp(minCountInclusive, 1, num); int num3 = Random.Range(num2, num + 1); for (int i = 0; i < num3; i++) { int index = Random.Range(i, list.Count); Character value = list[i]; list[i] = list[index]; list[index] = value; } if (num3 < list.Count) { list.RemoveRange(num3, list.Count - num3); } return list; } private static List TakeRandom(List items, int count) { if (items == null || items.Count == 0) { return new List(); } int num = Mathf.Clamp(count, 0, items.Count); for (int i = 0; i < num; i++) { int index = Random.Range(i, items.Count); T value = items[i]; items[i] = items[index]; items[index] = value; } if (num < items.Count) { items.RemoveRange(num, items.Count - num); } return items; } private static void GiveDynamiteToCharacter(Character c, bool extendedFuse) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!CanReceiveSpawnedItems(c)) { return; } try { if (!TryGetSafeSpawnPosAboveCharacter(c, (BodypartType)4, 2f, 2f, out var spawnPos)) { return; } GameObject val = SafeInstantiateItemRoom("Dynamite", spawnPos, Quaternion.identity); if ((Object)(object)val == (Object)null) { return; } Item component = val.GetComponent(); Dynamite component2 = val.GetComponent(); if ((Object)(object)component == (Object)null) { RemoveObjectAfterTime(val, 0f); return; } if (extendedFuse && (Object)(object)component2 != (Object)null) { ((ItemComponent)component2).GetData((DataEntryKey)10, (Func)component2.SetupDefaultFuel).Value = Random.Range(10f, 30f); if ((Object)(object)((MonoBehaviourPun)component).photonView != (Object)null) { ((MonoBehaviourPun)component).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { component.data }); } } RemoveObjectAfterTime(val, extendedFuse ? 45f : 30f); } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("GiveDynamiteToCharacter failed for {0}: {1}", ((c != null) ? ((Object)c).name : null) ?? "", arg)); } } private static bool IsSwappableStatusIndex(int index) { //IL_001d: 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_0020: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 if (index < 0 || index >= CharacterAfflictions.NumStatusTypes) { return false; } STATUSTYPE val = (STATUSTYPE)index; return (int)val != 7 && (int)val != 9; } private static float[] SnapshotSwappableStatuses(Character c) { int numStatusTypes = CharacterAfflictions.NumStatusTypes; float[] array = new float[numStatusTypes]; if ((Object)(object)c == (Object)null || c.refs == null || (Object)(object)c.refs.afflictions == (Object)null || c.refs.afflictions.currentStatuses == null) { return array; } float[] currentStatuses = c.refs.afflictions.currentStatuses; int num = Mathf.Min(numStatusTypes, currentStatuses.Length); for (int i = 0; i < num; i++) { if (IsSwappableStatusIndex(i)) { array[i] = Mathf.Clamp01(currentStatuses[i]); } } return array; } private static void ApplyStatusDelta(Character c, float[] delta) { if ((Object)(object)c == (Object)null || (Object)(object)((MonoBehaviourPun)c).photonView == (Object)null || delta == null) { return; } try { ((MonoBehaviourPun)c).photonView.RPC("RPC_ApplyStatusesFromFloatArray", (RpcTarget)0, new object[1] { delta }); } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("ApplyStatusDelta failed for {0}: {1}", ((c != null) ? ((Object)c).name : null) ?? "", arg)); } } private static void SwapPlayerStatusesSafe() { List list = (from c in GetRotatingHumans(excludeDead: true, excludePassedOut: false) where !c.data.isInFog && (Object)(object)c.refs?.afflictions != (Object)null select c).ToList(); if (list.Count < 2) { return; } int numStatusTypes = CharacterAfflictions.NumStatusTypes; List list2 = new List(); for (int i = 0; i < numStatusTypes; i++) { if (IsSwappableStatusIndex(i)) { list2.Add(i); } } if (list2.Count == 0) { return; } bool flag = Random.value < 0.5f; if (!flag) { int count = Random.Range(1, list2.Count + 1); list2 = TakeRandom(list2, count); } List list3 = new List(list.Count); for (int j = 0; j < list.Count; j++) { list3.Add(SnapshotSwappableStatuses(list[j])); } List list4 = Enumerable.Range(0, list.Count).ToList(); list4 = ExtCollections.Shuffle((IList)list4).ToList(); bool flag2 = true; for (int k = 0; k < list4.Count; k++) { if (list4[k] != k) { flag2 = false; break; } } if (flag2 && list4.Count > 1) { int value = list4[0]; for (int l = 0; l < list4.Count - 1; l++) { list4[l] = list4[l + 1]; } list4[list4.Count - 1] = value; } for (int m = 0; m < list.Count; m++) { Character c2 = list[m]; float[] array = list3[m]; float[] array2 = list3[list4[m]]; float[] array3 = new float[numStatusTypes]; for (int n = 0; n < list2.Count; n++) { int num = list2[n]; array3[num] = Mathf.Clamp(array2[num] - array[num], -1f, 1f); } ApplyStatusDelta(c2, array3); } Plugin.Log.LogInfo((object)string.Format("SwapPlayerStatuses applied: {0}, players={1}.", flag ? "all safe statuses" : "partial statuses", list.Count)); } private static int GetPartialTargetCap(float fractionOfHumans, int hardCap) { int count = HumanCharacters().Count; if (count <= 0) { return 0; } int num = Mathf.CeilToInt((float)count * Mathf.Clamp01(fractionOfHumans)); return Mathf.Clamp(Mathf.Max(1, num), 1, Mathf.Min(hardCap, count)); } private static List PickPartialHumans(int minCountInclusive, float fractionOfHumans, int hardCap, bool excludeDead = true, bool excludePassedOut = true) { int partialTargetCap = GetPartialTargetCap(fractionOfHumans, hardCap); if (partialTargetCap <= 0) { return new List(); } return PickRandomHumans(minCountInclusive, partialTargetCap, excludeDead, excludePassedOut); } private static bool TryGetGroundedPointNearCharacter(Character c, float horizontalRadius, out Vector3 point) { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; if (!IsCharacterUsable(c)) { return false; } Vector3 position = GetCharacterTransform(c, (BodypartType)2).position; int num = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1)); RaycastHit val3 = default(RaycastHit); for (int i = 0; i < 8; i++) { Vector2 val = Random.insideUnitCircle * Mathf.Max(0.1f, horizontalRadius); Vector3 val2 = position + new Vector3(val.x, 4f, val.y); if (Physics.Raycast(val2, Vector3.down, ref val3, 10f, num, (QueryTriggerInteraction)1)) { point = ((RaycastHit)(ref val3)).point + ((RaycastHit)(ref val3)).normal * 0.06f; return true; } } if (TryGetCharacterTransform(c, (BodypartType)13, out Transform transform)) { point = transform.position + Vector3.up * 0.08f; return true; } return false; } private static bool TryGetSafeEruptionPointNearCharacter(Character c, List usedPositions, out Vector3 point) { //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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) point = Vector3.zero; if (!IsCharacterUsable(c) || !TryGetCharacterTransform(c, (BodypartType)2, out Transform transform)) { return false; } int num = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1)); Vector3 position = transform.position; List source = HumanCharacters(excludeDead: false, excludePassedOut: false); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < 14; i++) { float num2 = Random.Range(0f, MathF.PI * 2f); float num3 = Random.Range(9f, 18f); Vector3 val = position + new Vector3(Mathf.Cos(num2) * num3, 8f, Mathf.Sin(num2) * num3); if (Physics.Raycast(val, Vector3.down, ref val2, 24f, num, (QueryTriggerInteraction)1)) { Vector3 candidate = ((RaycastHit)(ref val2)).point; if (!source.Any((Character h) => (Object)(object)h != (Object)null && (Object)(object)((Component)h).transform != (Object)null && Vector3.Distance(GetCharacterTransform(h, (BodypartType)2).position, candidate) < 6.5f) && (usedPositions == null || !usedPositions.Any((Vector3 u) => Vector3.Distance(u, candidate) < 35f))) { point = candidate; return true; } } } return false; } private static bool TryResolveItemName(IEnumerable candidates, out string itemName) { itemName = string.Empty; if (candidates == null) { return false; } foreach (string candidate in candidates) { if (string.IsNullOrWhiteSpace(candidate) || !TryGetItemByName(candidate, out Item item) || !((Object)(object)item != (Object)null) || !item.IsValidToSpawn()) { continue; } itemName = ((Object)item).name; return true; } return false; } private static bool TryFindItemNameWithComponent(out string itemName) where T : Component { itemName = string.Empty; try { ItemDatabase instance = SingletonAsset.Instance; if ((Object)(object)instance == (Object)null || instance.itemLookup == null) { return false; } foreach (Item value in instance.itemLookup.Values) { if ((Object)(object)value == (Object)null || !value.IsValidToSpawn() || (!((Object)(object)((Component)value).GetComponent() != (Object)null) && ((Component)value).GetComponentsInChildren(true).Length == 0)) { continue; } itemName = ((Object)value).name; return true; } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"TryFindItemNameWithComponent<{typeof(T).Name}> failed: {arg}"); } return false; } private static bool TryGetClimbingSpikeComponent(out ClimbingSpikeComponent spike) { spike = null; if ((Object)(object)_cachedClimbingSpikeComponent != (Object)null && (Object)(object)_cachedClimbingSpikeComponent.hammeredVersionPrefab != (Object)null) { spike = _cachedClimbingSpikeComponent; return true; } try { ItemDatabase instance = SingletonAsset.Instance; if ((Object)(object)instance == (Object)null || instance.itemLookup == null) { return false; } foreach (Item value in instance.itemLookup.Values) { if (!((Object)(object)value == (Object)null) && value.IsValidToSpawn()) { ClimbingSpikeComponent val = ((Component)value).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)value).GetComponentInChildren(true); } if ((Object)(object)val != (Object)null && (Object)(object)val.hammeredVersionPrefab != (Object)null) { _cachedClimbingSpikeComponent = val; spike = val; return true; } } } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"TryGetClimbingSpikeComponent failed: {arg}"); _cachedClimbingSpikeComponent = null; } return false; } private static bool TryGetCharacterFootBasePoint(Character c, out Vector3 basePoint) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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) basePoint = Vector3.zero; if (!IsCharacterUsable(c)) { return false; } Vector3 val = Vector3.zero; int num = 0; if (TryGetCharacterTransform(c, (BodypartType)13, out Transform transform)) { val += transform.position; num++; } if (TryGetCharacterTransform(c, (BodypartType)16, out Transform transform2)) { val += transform2.position; num++; } Transform transform3; if (num > 0) { basePoint = val / (float)num; } else if (TryGetCharacterTransform(c, (BodypartType)2, out transform3)) { basePoint = transform3.position; } else { basePoint = ((Component)c).transform.position; } try { int num2 = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1)); Vector3 val2 = basePoint + Vector3.up * 1.75f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, Vector3.down, ref val3, 5f, num2, (QueryTriggerInteraction)1)) { basePoint = ((RaycastHit)(ref val3)).point; } } catch { } return true; } private static bool TryFindPitonPlacement(Character c, out Vector3 point, out Quaternion rotation) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_010b: 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_0114: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) point = Vector3.zero; rotation = Quaternion.identity; if (!IsCharacterUsable(c) || !TryGetCharacterFootBasePoint(c, out var basePoint)) { return false; } int num = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1)); Vector3 forward = ((Component)c).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); Vector3 right = ((Component)c).transform.right; right.y = 0f; if (((Vector3)(ref right)).sqrMagnitude < 0.001f) { right = Vector3.right; } ((Vector3)(ref right)).Normalize(); Vector3[] obj = new Vector3[8] { forward, -forward, right, -right, default(Vector3), default(Vector3), default(Vector3), default(Vector3) }; Vector3 val = forward + right; obj[4] = ((Vector3)(ref val)).normalized; val = forward - right; obj[5] = ((Vector3)(ref val)).normalized; val = -forward + right; obj[6] = ((Vector3)(ref val)).normalized; val = -forward - right; obj[7] = ((Vector3)(ref val)).normalized; Vector3[] array = (Vector3[])(object)obj; int num2 = Random.Range(0, array.Length); Vector3 val2 = default(Vector3); RaycastHit val4 = default(RaycastHit); for (int i = 0; i < 18; i++) { if (i < array.Length) { val2 = array[(num2 + i) % array.Length]; } else { float num3 = Random.Range(0f, MathF.PI * 2f); ((Vector3)(ref val2))..ctor(Mathf.Cos(num3), 0f, Mathf.Sin(num3)); } if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { continue; } float num4 = Random.Range(2f, 4f); Vector3 val3 = basePoint + Vector3.up * num4 + Vector3.up * Random.Range(-0.15f, 0.25f); float num5 = Random.Range(7f, 11f); if (Physics.Raycast(val3, ((Vector3)(ref val2)).normalized, ref val4, num5, num, (QueryTriggerInteraction)1)) { float num6 = Vector3.Angle(((RaycastHit)(ref val4)).normal, Vector3.up); if (!(num6 < 35f) && !(num6 > 145f)) { point = ((RaycastHit)(ref val4)).point; rotation = Quaternion.LookRotation(-((RaycastHit)(ref val4)).normal, Vector3.up); return true; } } } return false; } private static void PlaceVanillaPitonPatch() { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) List list = PickPartialHumans(1, 0.45f, 3); if (list.Count == 0) { return; } if (!TryGetClimbingSpikeComponent(out ClimbingSpikeComponent spike) || (Object)(object)spike.hammeredVersionPrefab == (Object)null) { if (TryFindItemNameWithComponent(out string itemName)) { foreach (Character item in list.Where((Character x) => CanReceiveSpawnedItems(x))) { SummonToCharacter(item, itemName); } return; } Plugin.Log.LogWarning((object)"PitonPatch skipped: no vanilla ClimbingSpikeComponent item was found."); return; } string prefabName = "0_Items/" + ((Object)spike.hammeredVersionPrefab.gameObject).name; int num = 0; foreach (Character item2 in list) { if (TryFindPitonPlacement(item2, out var point, out var rotation)) { GameObject val = SafeInstantiateNetwork(prefabName, point, rotation); if (!((Object)(object)val == (Object)null)) { num++; } } } if (num == 0 && TryFindItemNameWithComponent(out string itemName2)) { foreach (Character item3 in list.Where((Character x) => CanReceiveSpawnedItems(x))) { SummonToCharacter(item3, itemName2); } } Plugin.Log.LogInfo((object)$"PitonPatch placed {num} vanilla piton(s) for {list.Count} target(s)."); } private static bool TryGetRopeShooterTemplate(out RopeShooter shooter, out string itemName) { shooter = null; itemName = _cachedChainShooterItemName; if ((Object)(object)_cachedRopeShooterTemplate != (Object)null && (Object)(object)_cachedRopeShooterTemplate.ropeAnchorWithRopePref != (Object)null) { shooter = _cachedRopeShooterTemplate; return true; } try { ItemDatabase instance = SingletonAsset.Instance; if ((Object)(object)instance == (Object)null || instance.itemLookup == null) { return false; } foreach (Item value in instance.itemLookup.Values) { if (!((Object)(object)value == (Object)null) && value.IsValidToSpawn()) { RopeShooter val = ((Component)value).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)value).GetComponentInChildren(true); } if (!((Object)(object)val == (Object)null) && !((Object)(object)val.ropeAnchorWithRopePref == (Object)null)) { _cachedRopeShooterTemplate = val; _cachedChainShooterItemName = ((Object)value).name; shooter = val; itemName = ((Object)value).name; return true; } } } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"TryGetRopeShooterTemplate failed: {arg}"); _cachedRopeShooterTemplate = null; _cachedChainShooterItemName = string.Empty; } return false; } private static bool IsValidChainAnchorHit(Vector3 startPoint, RaycastHit hit, float minDistance, float maxDistance) { //IL_0017: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { return false; } float num = Vector3.Distance(startPoint, ((RaycastHit)(ref hit)).point); if (num < minDistance || num > maxDistance) { return false; } if (Vector3.Angle(((RaycastHit)(ref hit)).normal, Vector3.down) < 12f) { return false; } return true; } private static bool TryFindChainPlacement(Character c, RopeShooter shooter, out Vector3 startPoint, out Vector3 targetPoint, out Quaternion spawnRotation, out Vector3 flyingRotation, out float ropeLength) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00de: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) startPoint = Vector3.zero; targetPoint = Vector3.zero; spawnRotation = Quaternion.identity; flyingRotation = Vector3.forward; ropeLength = 20f; if (!IsCharacterUsable(c) || (Object)(object)shooter == (Object)null || (Object)(object)shooter.ropeAnchorWithRopePref == (Object)null || !TryGetCharacterFootBasePoint(c, out var basePoint)) { return false; } int num = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)1)); float num2 = 5f; float num3 = Mathf.Clamp((shooter.maxLength > 0f) ? shooter.maxLength : 30f, num2, 30f); ropeLength = Mathf.Max(1f, (shooter.length > 0f) ? shooter.length : num3); Vector3 val = basePoint + Vector3.up * 0.55f; Vector3 forward = ((Component)c).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = Vector3.forward; } ((Vector3)(ref forward)).Normalize(); RaycastHit hit = default(RaycastHit); for (int i = 0; i < 36; i++) { float num4 = ((i == 0) ? 0f : ((i >= 8) ? Random.Range(-180f, 180f) : ((float)(i - 4) * 22.5f))); Vector3 val2 = Quaternion.AngleAxis(num4, Vector3.up) * forward; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { continue; } ((Vector3)(ref val2)).Normalize(); float num5 = Random.Range(num2, num3); float num6 = ((i % 3 == 0) ? Random.Range(2.5f, 8f) : ((i % 3 != 1) ? Random.Range(1f, 4.5f) : Random.Range(-0.5f, 1.5f))); Vector3 val3 = basePoint + val2 * num5 + Vector3.up * num6; Vector3 val4 = val3 - val; if (!(((Vector3)(ref val4)).sqrMagnitude < num2 * num2) && Physics.Raycast(val, ((Vector3)(ref val4)).normalized, ref hit, num3 + 2f, num, (QueryTriggerInteraction)1) && IsValidChainAnchorHit(val, hit, num2, num3)) { Vector3 val5 = ((RaycastHit)(ref hit)).point - val; Vector3 normalized = ((Vector3)(ref val5)).normalized; if (!(((Vector3)(ref normalized)).sqrMagnitude < 0.001f)) { startPoint = val; targetPoint = ((RaycastHit)(ref hit)).point; spawnRotation = ExtQuaternion.FromUpAndRightPrioUp(normalized, ((RaycastHit)(ref hit)).normal); flyingRotation = -normalized; return true; } } } return false; } private static bool SpawnPlacedChainFromTemplate(RopeShooter shooter, Vector3 startPoint, Vector3 targetPoint, Quaternion spawnRotation, Vector3 flyingRotation, float ropeLength) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)shooter == (Object)null || (Object)(object)shooter.ropeAnchorWithRopePref == (Object)null) { return false; } GameObject val = SafeInstantiateNetwork(((Object)shooter.ropeAnchorWithRopePref).name, startPoint, spawnRotation); if ((Object)(object)val == (Object)null) { return false; } try { RopeAnchorProjectile component = val.GetComponent(); PhotonView val2 = (((Object)(object)component != (Object)null && (Object)(object)component.photonView != (Object)null) ? component.photonView : val.GetComponent()); if ((Object)(object)component == (Object)null || (Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)("ChainCache spawned invalid anchor prefab: " + ((Object)shooter.ropeAnchorWithRopePref).name)); RemoveObjectAfterTime(val, 0f); return false; } float num = Mathf.Clamp(Vector3.Distance(startPoint, targetPoint) * 0.01f, 0.03f, 0.35f); val2.RPC("GetShot", (RpcTarget)3, new object[4] { targetPoint, num, Mathf.Max(1f, ropeLength), (((Vector3)(ref flyingRotation)).sqrMagnitude > 0.001f) ? ((Vector3)(ref flyingRotation)).normalized : Vector3.back }); return true; } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SpawnPlacedChainFromTemplate failed: {arg}"); RemoveObjectAfterTime(val, 0f); return false; } } private static void GiveVanillaChainCache() { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) if (!TryGetRopeShooterTemplate(out RopeShooter shooter, out string itemName)) { if (!TryResolveItemName(new string[2] { "ChainShooter", "Chain Shooter" }, out itemName) && !TryFindItemNameWithComponent(out itemName)) { Plugin.Log.LogWarning((object)"ChainCache skipped: no vanilla chain/rope shooter item was found."); return; } List list = (from x in PickPartialHumans(1, 0.4f, 3) where CanReceiveSpawnedItems(x) select x).ToList(); { foreach (Character item in list) { SummonToCharacter(item, itemName); } return; } } List list2 = (from x in PickPartialHumans(1, 0.4f, 3) where CanReceiveSpawnedItems(x) select x).ToList(); int num = 0; foreach (Character item2 in list2) { if (TryFindChainPlacement(item2, shooter, out var startPoint, out var targetPoint, out var spawnRotation, out var flyingRotation, out var ropeLength) && SpawnPlacedChainFromTemplate(shooter, startPoint, targetPoint, spawnRotation, flyingRotation, ropeLength)) { num++; } } if (num == 0 && !string.IsNullOrWhiteSpace(itemName)) { foreach (Character item3 in list2) { SummonToCharacter(item3, itemName); } } Plugin.Log.LogInfo((object)$"ChainCache placed {num} vanilla chain(s) for {list2.Count} target(s)."); } private static void ApplyStatusesNetworked(Character c, params (STATUSTYPE type, float amount)[] statuses) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected I4, but got Unknown if (!IsCharacterUsable(c) || (Object)(object)((MonoBehaviourPun)c).photonView == (Object)null || statuses == null || statuses.Length == 0) { return; } float[] array = new float[CharacterAfflictions.NumStatusTypes]; for (int i = 0; i < statuses.Length; i++) { int num = (int)statuses[i].type; if (num >= 0 && num < array.Length) { array[num] += statuses[i].amount; } } ApplyStatusDelta(c, array); } private static List HumanCharactersWithin(Vector3 center, float radius, int hardCap) { //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) List list = (from c in HumanCharacters() where !c.data.isInFog && Vector3.Distance(GetCharacterTransform(c, (BodypartType)2).position, center) <= radius select c).ToList(); if (list.Count == 0) { return list; } return TakeRandom(list, Mathf.Clamp(hardCap, 1, list.Count)); } private static void SpawnSporeVfx(Vector3 center) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)GameUtils.instance != (Object)null) { GameUtils.instance.SpawnResourceAtPositionNetworked("VFX_SporeExploExploEdibleSpawn_NoKnockback", center, (RpcTarget)0); } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SpawnSporeVfx failed: {arg}"); } } private static void SpawnToxicBounceShrooms() { //IL_0047: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) List list = PickPartialHumans(1, 0.35f, 4); foreach (Character item in list) { if (TryGetGroundedPointNearCharacter(item, 2.8f, out var point)) { GameObject obj = SafeInstantiateItemRoom("BounceShroomSpawn", point, Quaternion.identity); RemoveObjectAfterTime(obj, 55f); SpawnSporeVfx(point + Vector3.up * 0.35f); ApplyStatusesNetworked(item, ((STATUSTYPE)3, Random.Range(0.035f, 0.07f)), ((STATUSTYPE)10, Random.Range(0.025f, 0.055f))); } } } private static bool TryFindMushroomItemForEffect(int effect, out string itemName) { itemName = string.Empty; try { ItemDatabase instance = SingletonAsset.Instance; MushroomManager instance2 = MushroomManager.instance; if ((Object)(object)instance == (Object)null || instance.itemLookup == null) { return false; } foreach (Item value in instance.itemLookup.Values) { if ((Object)(object)value == (Object)null || !value.IsValidToSpawn()) { continue; } Action_RandomMushroomEffect[] componentsInChildren = ((Component)value).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { continue; } foreach (Action_RandomMushroomEffect val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } if (val.useDebugEffect && val.debugEffect == effect) { itemName = ((Object)value).name; return true; } if ((Object)(object)instance2 != (Object)null && instance2.mushroomEffects != null && instance2.mushroomEffects.Length != 0) { int num = Mathf.Abs(val.mushroomTypeIndex) % instance2.mushroomEffects.Length; if (instance2.mushroomEffects[num] == effect) { itemName = ((Object)value).name; return true; } } } } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"TryFindMushroomItemForEffect({effect}) failed: {arg}"); } return false; } private static void SpawnAndFeedToTargets(string itemName, List targets, int cookedAmount = 0) { //IL_0062: 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) if (string.IsNullOrWhiteSpace(itemName) || targets == null || targets.Count == 0) { return; } targets = targets.Where((Character c) => CanReceiveSpawnedItems(c)).ToList(); if (targets.Count == 0) { return; } GameObject val = SafeInstantiateItemRoom(itemName, OutOfSight, Quaternion.identity); if ((Object)(object)val == (Object)null) { return; } Item component = val.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)((MonoBehaviourPun)component).photonView == (Object)null) { RemoveObjectAfterTime(val, 0f); return; } try { ((MonoBehaviourPun)component).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { cookedAmount }); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SpawnAndFeedToTargets SetCookedAmountRPC failed for {itemName}: {arg}"); } foreach (Character target in targets) { try { target.FeedItem(component); } catch (Exception arg2) { Plugin.Log.LogWarning((object)string.Format("SpawnAndFeedToTargets FeedItem failed for {0} with {1}: {2}", ((target != null) ? ((Object)target).name : null) ?? "", itemName, arg2)); } } RemoveObjectAfterTime(val, 1f); } private static void FeedLowGravityMushroom() { if (!TryFindMushroomItemForEffect(2, out string itemName)) { Plugin.Log.LogWarning((object)"LowGravityShroom skipped: no vanilla mushroom item currently mapped to effect 2 was found."); return; } List targets = (from x in PickPartialHumans(1, 0.35f, 3) where CanReceiveSpawnedItems(x) select x).ToList(); SpawnAndFeedToTargets(itemName, targets); } private static void ApplySleepySpores() { List list = PickPartialHumans(1, 0.3f, 3); foreach (Character item in list) { ApplyStatusesNetworked(item, ((STATUSTYPE)6, Random.Range(0.035f, 0.075f)), ((STATUSTYPE)10, Random.Range(0.015f, 0.04f))); } } private static void SpawnSmallFungusCloud() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: 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_003f: Unknown result type (might be due to invalid IL or missing references) if (!TryGetRandomCharacter(out Character character)) { return; } Vector3 center = GetCharacterTransform(character, (BodypartType)2).position + Vector3.up * 0.65f; SpawnSporeVfx(center); List list = HumanCharactersWithin(center, 7.5f, GetPartialTargetCap(0.35f, 4)); foreach (Character item in list) { ApplyStatusesNetworked(item, ((STATUSTYPE)3, Random.Range(0.025f, 0.055f)), ((STATUSTYPE)10, Random.Range(0.035f, 0.075f))); if (Random.value < 0.35f) { ApplyStatusesNetworked(item, ((STATUSTYPE)6, Random.Range(0.015f, 0.035f))); } } } public static void RemoveObjectAfterTime(GameObject obj, float time = 30f) { ScheduleDestroy(obj, time); } private static List HumanCharacters(bool excludeDead = true, bool excludePassedOut = true) { return Character.AllCharacters.Where((Character c) => IsCharacterUsable(c) && !c.isBot && (!excludeDead || !c.data.dead) && (!excludePassedOut || !c.data.fullyPassedOut)).ToList(); } private static List DeadHumanCharacters() { return Character.AllCharacters.Where((Character c) => IsCharacterUsable(c) && !c.isBot && (c.data.dead || c.data.fullyPassedOut)).ToList(); } private static bool TryGetRandomCharacter(out Character character, bool excludeDead = true, bool excludePassedOut = true) { List list = HumanCharacters(excludeDead, excludePassedOut); if (list.Count == 0) { character = null; return false; } character = list[Random.Range(0, list.Count)]; return true; } private static Transform GetCharacterTransform(Character character, BodypartType part = 2) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (TryGetCharacterTransform(character, part, out Transform transform)) { return transform; } return ((Object)(object)character != (Object)null) ? ((Component)character).transform : null; } private static bool TryGetEmptyPocketSlot(Player player, out ItemSlot slot) { slot = null; if ((Object)(object)player == (Object)null || player.itemSlots == null) { return false; } ItemSlot[] itemSlots = player.itemSlots; for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i] != null && itemSlots[i].IsEmpty()) { slot = itemSlots[i]; return true; } } return false; } private static int CountEmptyPocketSlots(Player player) { if ((Object)(object)player == (Object)null || player.itemSlots == null) { return 0; } int num = 0; ItemSlot[] itemSlots = player.itemSlots; for (int i = 0; i < itemSlots.Length; i++) { if (itemSlots[i] != null && itemSlots[i].IsEmpty()) { num++; } } return num; } private static bool CanForceGiveItem(string itemName) { if (!TryGetItemByName(itemName, out Item item) || (Object)(object)item == (Object)null) { return false; } return item.IsValidToSpawn() && item.UIData != null && item.UIData.canPocket && item.UIData.canDrop; } private static bool IsUsingTemporaryHeldSlot(Character scout) { return (Object)(object)scout != (Object)null && scout.refs != null && (Object)(object)scout.refs.items != (Object)null && scout.refs.items.currentSelectedSlot.IsSome && scout.refs.items.currentSelectedSlot.Value == 250; } private static bool HasTemporaryHeldItem(Character scout) { if ((Object)(object)scout == (Object)null || (Object)(object)scout.player == (Object)null) { return false; } if (!scout.player.tempFullSlot.IsEmpty()) { return true; } return IsUsingTemporaryHeldSlot(scout) && (Object)(object)scout.data != (Object)null && (Object)(object)scout.data.currentItem != (Object)null; } private static bool CleanupOrphanTemporarySlot(Character scout, string reason) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient || !IsCharacterUsable(scout) || scout.player.tempFullSlot == null) { return false; } if (scout.player.tempFullSlot.IsEmpty()) { return false; } if (!IsUsingTemporaryHeldSlot(scout)) { CharacterData data = scout.data; if (!((Object)(object)((data != null) ? data.currentItem : null) != (Object)null)) { try { scout.player.tempFullSlot.EmptyOut(); byte[] array = IBinarySerializable.ToManagedArray(new InventorySyncData(scout.player.itemSlots, scout.player.backpackSlot, scout.player.tempFullSlot)); ((MonoBehaviourPun)scout.player).photonView.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array, true }); Plugin.Log.LogInfo((object)("Cleared orphan tempFullSlot for " + ((Object)scout).name + " (" + reason + ").")); return true; } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("CleanupOrphanTemporarySlot failed for {0}: {1}", ((scout != null) ? ((Object)scout).name : null) ?? "", arg)); return false; } } } return false; } public static void CleanupOrphanTemporarySlotsForAll(string reason) { if (PhotonNetwork.IsMasterClient) { List list = HumanCharacters(excludeDead: false, excludePassedOut: false); for (int i = 0; i < list.Count; i++) { CleanupOrphanTemporarySlot(list[i], reason); } } } private static void SpawnItemNearCharacter(Character scout, string itemName, bool kinematic = false) { //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) if (!PhotonNetwork.IsMasterClient || !TryGetCharacterTransform(scout, (BodypartType)4, out Transform transform)) { return; } Vector3 position = transform.position; Vector3 val = position + new Vector3(0f, 2f, 0f); if (Physics.CheckSphere(val, 2f)) { val = position; } GameObject val2 = SafeInstantiateItemRoom(itemName, val, Quaternion.identity); if (!((Object)(object)val2 == (Object)null)) { Item component = val2.GetComponent(); if ((Object)(object)component != (Object)null) { component.SetKinematicNetworked(kinematic); } } } private static bool TryGrantItemToEmptyPocketSlot(Character scout, string itemName) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (!CanSpawnNetworkObjects() || !CanReceiveSpawnedItems(scout)) { return false; } if ((Object)(object)scout == (Object)null || (Object)(object)scout.player == (Object)null || (Object)(object)scout.data == (Object)null) { return false; } if ((Object)(object)scout.data.currentItem != (Object)null || scout.data.isClimbingAnything || HasTemporaryHeldItem(scout)) { return false; } if (CountEmptyPocketSlots(scout.player) < 2) { return false; } if (!CanForceGiveItem(itemName) || !TryGetItemByName(itemName, out Item item) || (Object)(object)item == (Object)null) { return false; } if (!TryGetEmptyPocketSlot(scout.player, out ItemSlot slot) || slot == null) { return false; } try { ItemInstanceData val = new ItemInstanceData(Guid.NewGuid()); ItemInstanceDataHandler.AddInstanceData(val); slot.SetItem(item, val); byte[] array = IBinarySerializable.ToManagedArray(new InventorySyncData(scout.player.itemSlots, scout.player.backpackSlot, scout.player.tempFullSlot)); ((MonoBehaviourPun)scout.player).photonView.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array, true }); return true; } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("TryGrantItemToEmptyPocketSlot failed for {0} item {1}: {2}", ((scout != null) ? ((Object)scout).name : null) ?? "", itemName, arg)); return false; } } private static void SummonToCharacter(Character scout, string itemName, bool kinematic = false) { if (!CanReceiveSpawnedItems(scout)) { return; } try { if (!TryGrantItemToEmptyPocketSlot(scout, itemName)) { SpawnItemNearCharacter(scout, itemName, kinematic); } } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("SummonToCharacter failed for {0} item {1}: {2}", ((scout != null) ? ((Object)scout).name : null) ?? "", itemName, arg)); } } public static void AddItemsToBackpack(Backpack backpack, params string[] items) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown if ((Object)(object)backpack == (Object)null) { return; } Item component = ((Component)backpack).GetComponent(); if ((Object)(object)component == (Object)null) { return; } BackpackData data = component.GetData((DataEntryKey)7); if (data == null) { return; } for (byte b = 0; b < items.Length; b++) { if (!TryGetItemByName(items[b], out Item item)) { Plugin.Log.LogWarning((object)("AddItemsToBackpack skipped unknown item: " + items[b])); } else if (item.UIData == null || !item.IsValidToSpawn() || !item.UIData.canPocket || !item.UIData.canDrop || !item.UIData.canBackpack) { Plugin.Log.LogWarning((object)("AddItemsToBackpack skipped unsafe backpack item: " + items[b])); } else { try { data.AddItem(item, new ItemInstanceData(default(Guid)), b); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"AddItemsToBackpack failed for item {items[b]} at slot {b}: {arg}"); } } } try { ((MonoBehaviourPun)component).photonView.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { component.data }); } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"AddItemsToBackpack SetItemInstanceDataRPC failed: {arg2}"); } try { BackpackVisuals component2 = ((Component)backpack).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.RefreshVisuals(); } } catch (Exception arg3) { Plugin.Log.LogWarning((object)$"AddItemsToBackpack RefreshVisuals failed: {arg3}"); } } public static void AddTrollItemsToBackpack(Backpack backpack, string[] actualItems) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)backpack == (Object)null) { return; } Item component = ((Component)backpack).GetComponent(); if ((Object)(object)component == (Object)null) { return; } BackpackReference fromBackpackItem; try { fromBackpackItem = BackpackReference.GetFromBackpackItem(component); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"AddTrollItemsToBackpack GetFromBackpackItem failed: {arg}"); return; } BackpackVisuals visuals; try { visuals = ((BackpackReference)(ref fromBackpackItem)).GetVisuals(); } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"AddTrollItemsToBackpack GetVisuals failed: {arg2}"); return; } if ((Object)(object)visuals == (Object)null) { return; } for (byte b = 0; b < actualItems.Length; b++) { if (visuals.spawnedVisualItems.TryGetValue(b, out var value) && !((Object)(object)value == (Object)null)) { if (!TryGetItemByName(actualItems[b], out Item item)) { Plugin.Log.LogWarning((object)("AddTrollItemsToBackpack skipped unknown item: " + actualItems[b])); } else { try { value.isSecretlyOtherItemPrefab = item; } catch (Exception arg3) { Plugin.Log.LogWarning((object)$"AddTrollItemsToBackpack visual override failed for {actualItems[b]}: {arg3}"); } } } } if (TryGetItemByName("CactusBall", out Item item2)) { component.isSecretlyOtherItemPrefab = item2; } } public static GameObject SpawnBackpackWithItems(Vector3 position, params string[] items) { //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) try { GameObject val = SafeInstantiateItemRoom("Backpack", position, Quaternion.identity); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"SpawnBackpackWithItems failed: instantiate returned null."); return null; } AddItemsToBackpack(val.GetComponent(), items); return val; } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SpawnBackpackWithItems failed: {arg}"); return null; } } public static GameObject SpawnBackpackWithItemsTroll(Vector3 position, string[] actualItems, string[] fakeoutItems) { //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) try { GameObject val = SafeInstantiateItemRoom("Backpack", position, Quaternion.identity); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"SpawnBackpackWithItemsTroll failed: instantiate returned null."); return null; } Backpack component = val.GetComponent(); AddItemsToBackpack(component, fakeoutItems); AddTrollItemsToBackpack(component, actualItems); return val; } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SpawnBackpackWithItemsTroll failed: {arg}"); return null; } } private static void SafeWarpPlayer(Character scout, Vector3 targetPosition, bool poof, string reason) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scout == (Object)null || (Object)(object)((MonoBehaviourPun)scout).photonView == (Object)null) { return; } try { ((MonoBehaviourPun)scout).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { targetPosition, poof }); } catch (Exception arg) { Plugin.Log.LogWarning((object)string.Format("SafeWarpPlayer failed for {0} ({1}): {2}", ((scout != null) ? ((Object)scout).name : null) ?? "", reason, arg)); } } public static void PrepCharacterAsTeleportDestination(Character scout) { //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_0037: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: Unknown result type (might be due to invalid IL or missing references) if (!scout.data.isGrounded || scout.data.isClimbingAnything) { Vector3 position = GetCharacterTransform(scout, (BodypartType)13).position; Vector3 position2 = GetCharacterTransform(scout, (BodypartType)16).position; GameObject obj = SafeInstantiateItemRoom("ShelfShroomSpawn", Vector3.Lerp(position, position2, 0.5f) - new Vector3(0f, 0.5f, 0f), Quaternion.identity); RemoveObjectAfterTime(obj); } } public static void PrepCharacterAsTeleportee(Character scout) { scout.refs.climbing.StopAnyClimbing(); } public static Vector3 GetPosForTeleportingTo(Character scout) { //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_000e: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007f: Unknown result type (might be due to invalid IL or missing references) Vector3 position = GetCharacterTransform(scout, (BodypartType)2).position; Vector3 val = Random.insideUnitSphere * 2f + position; val.y = ((val.y < position.y) ? position.y : val.y); int num = 0; while (Physics.OverlapSphere(val, 1f).Length != 0) { if (num > 5) { val = position; break; } val = Random.insideUnitSphere * 2f + position; val.y = ((val.y < position.y) ? position.y : val.y); num++; } return val; } public static void SpawnAndFeedToAll(string itemName, int cookedAmount = 0, bool excludePassedOut = false) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) List list = (from c in GetRotatingHumans(excludeDead: true, excludePassedOut) where CanReceiveSpawnedItems(c, !excludePassedOut) select c).ToList(); if (list.Count == 0) { return; } GameObject val; Item component; try { val = SafeInstantiateItemRoom(itemName, OutOfSight, Quaternion.identity); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("SpawnAndFeedToAll failed: instantiate returned null for " + itemName)); return; } component = val.GetComponent(); if ((Object)(object)component == (Object)null || (Object)(object)((MonoBehaviourPun)component).photonView == (Object)null) { Plugin.Log.LogWarning((object)("SpawnAndFeedToAll failed: Item or photonView missing for " + itemName)); RemoveObjectAfterTime(val, 0f); return; } } catch (Exception arg) { Plugin.Log.LogWarning((object)$"SpawnAndFeedToAll instantiate failed for {itemName}: {arg}"); return; } try { ((MonoBehaviourPun)component).photonView.RPC("SetCookedAmountRPC", (RpcTarget)0, new object[1] { cookedAmount }); } catch (Exception arg2) { Plugin.Log.LogWarning((object)$"SpawnAndFeedToAll SetCookedAmountRPC failed for {itemName}: {arg2}"); } foreach (Character item in list) { try { item.FeedItem(component); } catch (Exception arg3) { Plugin.Log.LogWarning((object)string.Format("SpawnAndFeedToAll FeedItem failed for {0} with {1}: {2}", ((item != null) ? ((Object)item).name : null) ?? "", itemName, arg3)); } } RemoveObjectAfterTime(val, 1f); } public static void RandomEvent() { if (ModConfig.EnableChaosMaster.Value && ModConfig.EnableRandomEvents.Value && Interlocked.CompareExchange(ref RandomEventTask.ShouldStopTask, 0, 0) == 0 && (!PhotonNetwork.OfflineMode || Time.timeScale != 0f)) { QueueRandomEvent(); } } public static void QueueRandomEvent() { if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableRandomEvents.Value) { return; } string name = GetRandomEventName(); if (!string.IsNullOrWhiteSpace(name)) { WithMutex(EventQueueMutex, delegate { EventQueue.Add(name); }); } } public static void QueueEvent(string type) { string type2 = type; if (ModConfig.EnableChaosMaster.Value && ModConfig.EnableRandomEvents.Value && Events.Any<(string, ConfigEntry, Action)>(((string name, ConfigEntry weightConfigEntry, Action action) e) => e.name == type2)) { WithMutex(EventQueueMutex, delegate { EventQueue.Add(type2); }); } } public static void ForceEvent(string type) { string type2 = type; if (!ModConfig.EnableChaosMaster.Value || !ModConfig.EnableRandomEvents.Value) { return; } (string, ConfigEntry, Action) tuple = Events.FirstOrDefault<(string, ConfigEntry, Action)>(((string name, ConfigEntry weightConfigEntry, Action action) e) => e.name == type2); if (tuple.Item3 == null) { return; } if (_currentImmediateEventDepth >= 4) { QueueEvent(type2); return; } _currentImmediateEventDepth++; try { tuple.Item3(); } catch (Exception arg) { Plugin.Log.LogError((object)$"Error when trying to execute forced event {type2}: {arg}"); } finally { _currentImmediateEventDepth--; } } public static void ForceRandomEvent(params string[] exclude) { HashSet source = new HashSet(exclude ?? Array.Empty()) { "TwoAtOnce" }; string randomEventName = GetRandomEventName(source.ToArray()); if (!string.IsNullOrWhiteSpace(randomEventName)) { ForceEvent(randomEventName); } } public static string GetRandomEventName(params string[] exclude) { List<(string, ConfigEntry, Action)> list = GetFilteredEvents(exclude).ToList(); int num = list.Sum<(string, ConfigEntry, Action)>(((string name, ConfigEntry weightConfigEntry, Action action) e) => e.weightConfigEntry?.Value ?? 0); if (num <= 0) { return ""; } int num2 = Random.Range(0, num); foreach (var item in list) { int num3 = item.Item2?.Value ?? 0; if (num2 < num3) { return item.Item1; } num2 -= num3; } return ""; } private static bool TryGetCharacterTransform(Character character, BodypartType part, out Transform transform) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) transform = null; if ((Object)(object)character == (Object)null) { return false; } Bodypart bodypart = character.GetBodypart(part); if ((Object)(object)bodypart == (Object)null || (Object)(object)((Component)bodypart).transform == (Object)null) { return false; } transform = ((Component)bodypart).transform; return true; } public static bool TryGetPosForTeleportingTo(Character scout, out Vector3 targetPos) { //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_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: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) targetPos = Vector3.zero; if (!TryGetCharacterTransform(scout, (BodypartType)2, out Transform transform)) { return false; } Vector3 position = transform.position; Vector3[] array = (Vector3[])(object)new Vector3[6] { Vector3.zero, transform.right * 0.65f, -transform.right * 0.65f, transform.forward * 0.65f, -transform.forward * 0.65f, Vector3.up * 0.2f }; for (int i = 0; i < array.Length; i++) { Vector3 val = position + array[i]; if (!Physics.CheckSphere(val, 0.45f, -1, (QueryTriggerInteraction)1)) { targetPos = val; return true; } } targetPos = position + Vector3.up * 0.2f; return true; } public static IEnumerable<(string name, ConfigEntry? weightConfigEntry, Action action)> GetFilteredEvents(params string[] exclude) { HashSet excluded = new HashSet(exclude ?? Array.Empty()); int count = HumanCharacters().Count; if (count < 2) { excluded.Add("SwapPlayers"); excluded.Add("WarpToLastPlayer"); excluded.Add("SwapPlayerItems"); excluded.Add("SwapPlayerStatuses"); } if (DeadHumanCharacters().Count == 0) { excluded.Add("ReviveOne"); excluded.Add("ReviveAll"); } if ((Object)(object)Singleton.Instance != (Object)null && Singleton.Instance.currentSegment > 3 && !ModConfig.EnableTornadoAtKiln.Value) { excluded.Add("Tornado"); } if (SkeletonEventActive) { excluded.Add("Skeleton"); } if ((Object)(object)Object.FindAnyObjectByType() == (Object)null) { excluded.Add("Eruption"); } return Events.Where<(string, ConfigEntry, Action)>(((string name, ConfigEntry weightConfigEntry, Action action) e) => e.weightConfigEntry != null && !excluded.Contains(e.name)); } private static bool TryGetSafeSpawnPosAboveCharacter(Character c, BodypartType part, float upOffset, float checkRadius, out Vector3 spawnPos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) spawnPos = Vector3.zero; if (!TryGetCharacterTransform(c, part, out Transform transform)) { return false; } Vector3 position = transform.position; Vector3 val = position + new Vector3(0f, upOffset, 0f); if (Physics.CheckSphere(val, checkRadius)) { val = position; } spawnPos = val; return true; } private static bool TryGetItemByName(string itemName, out Item item) { string itemName2 = itemName; item = null; try { ItemDatabase instance = SingletonAsset.Instance; if ((Object)(object)instance == (Object)null) { return false; } item = ((IEnumerable)instance.itemLookup.Values).FirstOrDefault((Func)((Item x) => (Object)(object)x != (Object)null && ((Object)x).name == itemName2)); return (Object)(object)item != (Object)null; } catch (Exception arg) { Plugin.Log.LogWarning((object)$"TryGetItemByName failed for '{itemName2}': {arg}"); return false; } } private static bool IsCharacterUsable(Character character) { if ((Object)(object)character == (Object)null || (Object)(object)((MonoBehaviourPun)character).photonView == (Object)null || (Object)(object)character.view == (Object)null || (Object)(object)character.data == (Object)null || character.refs == null || (Object)(object)character.refs.items == (Object)null) { return false; } if (!character.IsPlayerControlled || character.isZombie || character.isScoutmaster || character.isBot) { return false; } if (!character.IsRegisteredToPlayer) { return false; } Player player = character.player; if ((Object)(object)player == (Object)null || (Object)(object)((MonoBehaviourPun)player).photonView == (Object)null || (Object)(object)player.view == (Object)null) { return false; } if ((Object)(object)player.character != (Object)(object)character) { return false; } Player val = default(Player); if (!PhotonNetwork.OfflineMode && (!PhotonNetwork.TryGetPlayer(((MonoBehaviourPun)character).photonView.OwnerActorNr, ref val) || val == null || val.IsInactive)) { return false; } string text = (((Object)(object)((Component)character).gameObject != (Object)null) ? ((Object)((Component)character).gameObject).name : string.Empty); if (!string.IsNullOrEmpty(text) && (text.IndexOf("Zombie", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Scoutmaster", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("MushroomZombie", StringComparison.OrdinalIgnoreCase) >= 0)) { return false; } return true; } public static List EventNames() { return Events.Select<(string, ConfigEntry, Action), string>(((string name, ConfigEntry weightConfigEntry, Action action) e) => e.name).ToList(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }