using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("REPO_lucky_block")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+72b724b4ced6c76df5941a41dd6a460d24aaced1")] [assembly: AssemblyProduct("REPO_lucky_block")] [assembly: AssemblyTitle("REPO_lucky_block")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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; } } } public class DebugMenu : MonoBehaviour { private enum Page { Main, ForceEvent, BlocksOnMap } private bool _open; private int _selectedIndex; private Page _page; private Vector2 _scroll = Vector2.zero; private List _blockCache = new List(); private string _lastEventMsg = ""; private const float WIN_W = 360f; private const float WIN_H = 420f; private const float ROW_H = 26f; private const float BTN_H = 22f; private const float PAD = 8f; private const float HOLD_DELAY = 0.28f; private const float REPEAT_RATE = 0.07f; private float _upTimer = -1f; private float _downTimer = -1f; private float _enterTimer = -1f; private static readonly Color COL_SELECTED = new Color(1f, 0.85f, 0f); private static readonly Color COL_NORMAL = Color.white; private static readonly Color COL_GOLD = new Color(1f, 0.8f, 0.1f); private static readonly Color COL_DIM = new Color(1f, 1f, 1f, 0.35f); private static readonly Color COL_GREEN = new Color(0.4f, 1f, 0.4f); private static readonly Color COL_RED = new Color(1f, 0.35f, 0.35f); private const int MAIN_ITEMS = 5; public static DebugMenu Instance { get; private set; } private static int EventCount => LuckyEventRegistry.All.Count + 1; private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Update() { //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 (Input.GetKeyDown((KeyCode)287)) { _open = !_open; if (_open) { RefreshBlockCache(); } _selectedIndex = 0; _scroll = Vector2.zero; _page = Page.Main; _lastEventMsg = ""; ResetTimers(); } if (_open) { float deltaTime = Time.deltaTime; HandleHeld((KeyCode)273, ref _upTimer, deltaTime, NavigateUp); HandleHeld((KeyCode)274, ref _downTimer, deltaTime, NavigateDown); HandleHeld((KeyCode)13, ref _enterTimer, deltaTime, ActivateSelected); if (Input.GetKeyDown((KeyCode)271) || Input.GetKey((KeyCode)271)) { HandleHeld((KeyCode)271, ref _enterTimer, deltaTime, ActivateSelected); } } } private void HandleHeld(KeyCode key, ref float timer, float dt, Action action) { //IL_0000: 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) if (Input.GetKeyDown(key)) { action(); timer = -0.28f; } else if (Input.GetKey(key)) { timer += dt; while (timer >= 0f) { action(); timer -= 0.07f; } } else { timer = -0.28f; } } private void ResetTimers() { _upTimer = (_downTimer = (_enterTimer = -0.28f)); } private int PageItemCount() { return _page switch { Page.Main => 5, Page.ForceEvent => 1 + EventCount, Page.BlocksOnMap => 1 + _blockCache.Count, _ => 0, }; } private void NavigateUp() { int num = PageItemCount(); if (num != 0) { _selectedIndex = (_selectedIndex - 1 + num) % num; SyncScroll(); } } private void NavigateDown() { int num = PageItemCount(); if (num != 0) { _selectedIndex = (_selectedIndex + 1) % num; SyncScroll(); } } private void GoTo(Page p) { //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) if (p == Page.BlocksOnMap) { RefreshBlockCache(); } _page = p; _selectedIndex = 0; _scroll = Vector2.zero; ResetTimers(); } private void SyncScroll() { if (_page == Page.Main) { return; } float num = 96f; float num2 = 420f - num - 8f - 24f; float num3 = (float)(_selectedIndex - 1) * 26f; float num4 = num3 + 26f; int num5 = PageItemCount() - 1; if (_selectedIndex == 0) { _scroll.y = 0f; return; } if (_selectedIndex == num5) { _scroll.y = Mathf.Max(0f, (float)num5 * 26f - num2); return; } if (num3 < _scroll.y) { _scroll.y = num3; } if (num4 > _scroll.y + num2) { _scroll.y = num4 - num2; } } private void ActivateSelected() { switch (_page) { case Page.Main: ActivateMain(); break; case Page.ForceEvent: ActivateForceEvent(); break; case Page.BlocksOnMap: ActivateBlocksOnMap(); break; } } private void ActivateMain() { switch (_selectedIndex) { case 0: DoSpawnInFront(); break; case 1: DoForceRandomNearest(); break; case 2: GoTo(Page.ForceEvent); break; case 3: GoTo(Page.BlocksOnMap); break; case 4: DoForceSpawnLevel(); break; } } private void ActivateForceEvent() { if (_selectedIndex == 0) { GoTo(Page.Main); return; } int eventIdx = _selectedIndex - 1; DoForceEvent(eventIdx); } private void ActivateBlocksOnMap() { if (_selectedIndex == 0) { GoTo(Page.Main); return; } int num = _selectedIndex - 1; if (num < _blockCache.Count && (Object)(object)_blockCache[num] != (Object)null) { ForceOpenBlock(_blockCache[num]); } } private void DoSpawnInFront() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)PlayerAvatar.instance == (Object)null)) { LuckyBlockSpawner.SpawnOne(SpawnUtils.GetSpawnPositionInFront(PlayerAvatar.instance, 2.5f)); } } private void DoForceRandomNearest() { LuckyBlock luckyBlock = FindNearestBlock(); if ((Object)(object)luckyBlock != (Object)null) { ForceOpenBlock(luckyBlock); } else { Debug.Log((object)"[LuckyBlock] Debug: no blocks in scene."); } } private void DoForceSpawnLevel() { if (!SemiFunc.RunIsLevel()) { Debug.Log((object)"[LuckyBlock] Debug: not in a level scene."); return; } LuckyBlockSpawner.ResetSpawnFlag(); LuckyBlockSpawner.SpawnForCurrentLevel("ForceSpawnLevel (debug)"); } private void DoForceEvent(int eventIdx) { //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_005e: 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) PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { return; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { _lastEventMsg = "Host only — events are master-authoritative"; return; } Vector3 spawnPositionInFront = SpawnUtils.GetSpawnPositionInFront(instance, 2.5f); IReadOnlyList all = LuckyEventRegistry.All; if (eventIdx >= 0 && eventIdx < all.Count) { LuckyBlockEvents.TriggerSpecific(eventIdx, instance, spawnPositionInFront); _lastEventMsg = all[eventIdx].Label; } else { LuckyBlockEvents.Roll(instance, spawnPositionInFront); _lastEventMsg = "Full Roll fired"; } } private void ForceOpenBlock(LuckyBlock b) { typeof(LuckyBlock).GetMethod("Open", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(b, null); } private LuckyBlock FindNearestBlock() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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) LuckyBlock[] array = Object.FindObjectsOfType(); if (array.Length == 0) { return null; } if ((Object)(object)PlayerAvatar.instance == (Object)null) { return array[0]; } LuckyBlock result = null; float num = float.MaxValue; Vector3 position = ((Component)PlayerAvatar.instance).transform.position; LuckyBlock[] array2 = array; foreach (LuckyBlock luckyBlock in array2) { float num2 = Vector3.Distance(((Component)luckyBlock).transform.position, position); if (num2 < num) { num = num2; result = luckyBlock; } } return result; } private void RefreshBlockCache() { _blockCache.Clear(); _blockCache.AddRange(Object.FindObjectsOfType()); } private void OnGUI() { //IL_002d: 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_00b5: 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) if (_open) { float num = (float)Screen.height - 420f - 10f; GUI.Box(new Rect(10f, num, 360f, 420f), ""); float num2 = 10f + 8f; float cy = num + 8f; float num3 = 344f; switch (_page) { case Page.Main: DrawMain(num2, cy, num3); break; case Page.ForceEvent: DrawForceEvent(num2, cy, num3); break; case Page.BlocksOnMap: DrawBlocksOnMap(num2, cy, num3); break; } float num4 = num + 420f - 8f - 18f; GUI.color = COL_DIM; GUI.Label(new Rect(num2, num4, num3, 18f), "↑↓ navigate (wrap+hold) ENTER select (hold) F6 close"); GUI.color = Color.white; } } private void DrawMain(float cx, float cy, float cw) { //IL_0000: 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_0021: 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_0066: 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_00e2: Unknown result type (might be due to invalid IL or missing references) GUI.color = COL_GOLD; GUI.Label(new Rect(cx, cy, cw, 22f), "[ LUCKY BLOCK DEBUG ]"); GUI.color = Color.white; cy += 30f; int num = Object.FindObjectsOfType().Length; int num2 = (((Object)(object)RunManager.instance != (Object)null) ? (SemiFunc.RunGetLevelsCompleted() + 1) : 0); GUI.color = COL_DIM; GUI.Label(new Rect(cx, cy, cw, 22f), $" Lvl {num2} Blocks: {num} " + "Master: " + (SemiFunc.IsMasterClientOrSingleplayer() ? "✓" : "✗")); cy += 24f; string text = (ModeManager.IsPrivate ? "Private (custom item, press E)" : "Public (valuable, grab it)"); GUI.Label(new Rect(cx, cy, cw, 22f), " Edition: " + text + " (config + restart)"); GUI.color = Color.white; cy += 28f; DrawItem(cx, cy, cw, "Spawn Lucky Block in Front", 0); cy += 26f; DrawItem(cx, cy, cw, "Force Random Event on Nearest", 1); cy += 26f; DrawItem(cx, cy, cw, "→ Force Specific Event", 2); cy += 26f; DrawItem(cx, cy, cw, $"→ Blocks on Map ({num})", 3); cy += 26f; DrawItem(cx, cy, cw, "Force-Spawn Level Blocks", 4); cy += 26f; DrawEventLog(cx, cy, cw); } private void DrawEventLog(float cx, float cy, float cw) { //IL_0011: 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_0041: 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_0074: 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_00d5: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (!LuckyEventLog.Enabled) { return; } cy += 6f; GUI.color = COL_GOLD; GUI.Label(new Rect(cx, cy, cw, 22f), $"[ LAST EVENTS ({LuckyEventLog.Duration:F0}s window) ]"); GUI.color = Color.white; cy += 22f; List visible = LuckyEventLog.GetVisible(); if (visible.Count == 0) { GUI.color = COL_DIM; GUI.Label(new Rect(cx, cy, cw, 22f), " No events yet."); GUI.color = Color.white; return; } float realtimeSinceStartup = Time.realtimeSinceStartup; foreach (RandomEventRoller.EventLogEntry item in visible) { float num = realtimeSinceStartup - item.TimeLogged; bool num2 = num > LuckyEventLog.Duration; GUI.color = (num2 ? COL_DIM : ((num < 10f) ? COL_GREEN : COL_NORMAL)); string text = (num2 ? "old" : $"{num:F0}s"); GUI.Label(new Rect(cx, cy, cw, 22f), " " + item.Timestamp + " " + item.Label + " (" + text + ")"); GUI.color = Color.white; cy += 20f; } } private void DrawForceEvent(float cx, float cy, float cw) { //IL_0000: 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_0021: 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_008c: 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_0042: 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_006e: 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_0111: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0265: 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) GUI.color = COL_GOLD; GUI.Label(new Rect(cx, cy, cw, 22f), "[ Force Specific Event ]"); GUI.color = Color.white; cy += 28f; if (_lastEventMsg.Length > 0) { GUI.color = COL_GREEN; GUI.Label(new Rect(cx, cy, cw, 22f), " ✓ " + _lastEventMsg); GUI.color = Color.white; } else { GUI.color = COL_DIM; GUI.Label(new Rect(cx, cy, cw, 22f), " Spawns block in front + fires chosen event"); GUI.color = Color.white; } cy += 30f; DrawItem(cx, cy, cw, "← Back", 0); cy += 28f; IReadOnlyList all = LuckyEventRegistry.All; float num = 420f - (cy - ((float)Screen.height - 420f - 10f)) - 8f - 24f; float num2 = Mathf.Max((float)EventCount * 26f, num); _scroll = GUI.BeginScrollView(new Rect(cx, cy, cw, num), _scroll, new Rect(0f, 0f, cw - 16f, num2)); Color val = default(Color); for (int i = 0; i < EventCount; i++) { bool flag = _selectedIndex == i + 1; string text; if (i >= all.Count) { text = "Full Roll (random spin, all events)"; val = COL_GOLD; } else { LuckyEvent luckyEvent = all[i]; switch (luckyEvent.Category) { case LuckyEventCategory.Lucky: val = COL_GREEN; break; case LuckyEventCategory.Unlucky: val = COL_RED; break; case LuckyEventCategory.Chaotic: ((Color)(ref val))..ctor(1f, 0.55f, 0f); break; default: ((Color)(ref val))..ctor(0.7f, 0.6f, 1f); break; } bool flag2 = luckyEvent.RequiresAllClients && SemiFunc.IsMultiplayer() && !ModeManager.IsPrivate; text = luckyEvent.Label + (flag2 ? " [private only]" : ""); if (flag2) { val = COL_DIM; } } GUI.color = (flag ? COL_SELECTED : val); GUI.Label(new Rect(0f, (float)i * 26f, cw - 16f, 22f), (flag ? "► " : " ") + text); GUI.color = Color.white; } GUI.EndScrollView(); } private void DrawBlocksOnMap(float cx, float cy, float cw) { //IL_0000: 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_0021: 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_009d: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e6: 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) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) GUI.color = COL_GOLD; GUI.Label(new Rect(cx, cy, cw, 22f), "[ Blocks on Map ]"); GUI.color = Color.white; cy += 28f; DrawItem(cx, cy, cw, "← Back", 0); cy += 30f; RefreshBlockCache(); float num = 420f - (cy - ((float)Screen.height - 420f - 10f)) - 8f - 24f; float num2 = Mathf.Max((float)_blockCache.Count * 26f, num); _scroll = GUI.BeginScrollView(new Rect(cx, cy, cw, num), _scroll, new Rect(0f, 0f, cw - 16f, num2)); Vector3 val = (((Object)(object)PlayerAvatar.instance != (Object)null) ? ((Component)PlayerAvatar.instance).transform.position : Vector3.zero); for (int i = 0; i < _blockCache.Count; i++) { LuckyBlock luckyBlock = _blockCache[i]; if (!((Object)(object)luckyBlock == (Object)null)) { bool flag = _selectedIndex == i + 1; Vector3 position = ((Component)luckyBlock).transform.position; float num3 = Vector3.Distance(position, val); GUI.color = (flag ? COL_SELECTED : COL_GOLD); GUI.Label(new Rect(0f, (float)i * 26f, cw - 16f, 22f), (flag ? "► " : " ") + $"Block {i + 1}: ({position.x:F1}, {position.y:F1}, {position.z:F1}) | {num3:F1}m [ENTER=open]"); GUI.color = Color.white; } } if (_blockCache.Count == 0) { GUI.color = COL_DIM; GUI.Label(new Rect(0f, 0f, cw - 16f, 22f), " No lucky blocks in scene."); GUI.color = Color.white; } GUI.EndScrollView(); } private void DrawItem(float cx, float cy, float cw, string label, int idx) { //IL_0015: 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_0027: 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) bool flag = _selectedIndex == idx; GUI.color = (flag ? COL_SELECTED : COL_NORMAL); GUI.Label(new Rect(cx, cy, cw, 22f), (flag ? "► " : " ") + label); GUI.color = Color.white; } } internal static class EventHelpers { private static FieldInfo _fValCurrent; private static FieldInfo _fValOriginal; private static FieldInfo _fValSet; private static FieldInfo _fExtCurrent; private static FieldInfo _fGrabbedObj; private static bool _reflected; private static Item _grenadeItem; private static void EnsureReflection() { if (!_reflected) { _reflected = true; Type? typeFromHandle = typeof(ValuableObject); _fValCurrent = typeFromHandle.GetField("dollarValueCurrent", BindingFlags.Instance | BindingFlags.NonPublic); _fValOriginal = typeFromHandle.GetField("dollarValueOriginal", BindingFlags.Instance | BindingFlags.NonPublic); _fValSet = typeFromHandle.GetField("dollarValueSet", BindingFlags.Instance | BindingFlags.NonPublic); _fExtCurrent = typeof(RoundDirector).GetField("extractionPointCurrent", BindingFlags.Instance | BindingFlags.NonPublic); _fGrabbedObj = typeof(PhysGrabber).GetField("grabbedPhysGrabObject", BindingFlags.Instance | BindingFlags.NonPublic); } } internal static void Announce(string label) { LuckyFx.Broadcast("announce", label); } internal static List GetAllPlayers() { List list = new List(); foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { if ((Object)(object)item != (Object)null) { list.Add(item); } } return list; } internal static void TeleportPlayer(PlayerAvatar avatar, Vector3 pos) { //IL_000b: 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_0029: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null) { return; } avatar.Spawn(pos, ((Component)avatar).transform.rotation); if ((Object)(object)avatar == (Object)(object)PlayerAvatar.instance) { TeleportLocalController(pos); } else if (SemiFunc.IsMultiplayer() && ModeManager.IsPrivate) { PhotonView component = ((Component)avatar).GetComponent(); if ((Object)(object)component != (Object)null) { LuckyFx.Broadcast("teleport", string.Format(CultureInfo.InvariantCulture, "{0},{1:F2},{2:F2},{3:F2}", component.ViewID, pos.x, pos.y, pos.z)); } } } internal static void TeleportLocalController(Vector3 pos) { //IL_0040: 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_0034: Unknown result type (might be due to invalid IL or missing references) PlayerController instance = PlayerController.instance; if (!((Object)(object)instance == (Object)null)) { if ((Object)(object)instance.rb != (Object)null) { instance.rb.velocity = Vector3.zero; instance.rb.position = pos; } ((Component)instance).transform.position = pos; } } internal static void UpgradePlayer(PlayerAvatar avatar, string upgradeName, int amount = 1) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || (Object)(object)PunManager.instance == (Object)null) { return; } string text = SemiFunc.PlayerGetSteamID(avatar); if (string.IsNullOrEmpty(text)) { return; } if (SemiFunc.IsMultiplayer()) { PhotonView component = ((Component)PunManager.instance).GetComponent(); if ((Object)(object)component != (Object)null) { component.RPC("TesterUpgradeCommandRPC", (RpcTarget)0, new object[3] { text, upgradeName, amount }); } } else { PunManager.instance.TesterUpgradeCommandRPC(text, upgradeName, amount, default(PhotonMessageInfo)); } } internal static void HealPlayer(PlayerAvatar avatar, int amount) { if ((Object)(object)avatar != (Object)null && (Object)(object)avatar.playerHealth != (Object)null) { avatar.playerHealth.HealOther(amount, true); } } internal static List GetSpawnedEnemies() { List list = new List(); if ((Object)(object)EnemyDirector.instance == (Object)null) { return list; } foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned) { if (!((Object)(object)item == (Object)null)) { Enemy componentInChildren = ((Component)item).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null && ((Component)componentInChildren).gameObject.activeInHierarchy) { list.Add(componentInChildren); } } } return list; } internal static void TeleportEnemy(Enemy enemy, Vector3 pos) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemy != (Object)null) { enemy.EnemyTeleported(pos); } } internal static List GetLooseValuables() { List list = new List(); List list2 = (((Object)(object)RoundDirector.instance != (Object)null) ? RoundDirector.instance.dollarHaulList : null); ValuableObject[] array = Object.FindObjectsOfType(); foreach (ValuableObject val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent() != (Object)null)) { LuckyBlockItem component = ((Component)val).GetComponent(); if ((!((Object)(object)component != (Object)null) || !component.IsLucky) && (list2 == null || !list2.Contains(((Component)val).gameObject))) { list.Add(val); } } } return list; } internal static float GetValuableValue(ValuableObject v) { EnsureReflection(); if ((Object)(object)v == (Object)null || _fValCurrent == null) { return 0f; } return (float)_fValCurrent.GetValue(v); } internal static void SetValuableValue(ValuableObject v, float value) { EnsureReflection(); if ((Object)(object)v == (Object)null || _fValCurrent == null) { return; } value = Mathf.Max(0f, Mathf.Round(value)); _fValCurrent.SetValue(v, value); _fValOriginal?.SetValue(v, value); _fValSet?.SetValue(v, true); if (SemiFunc.IsMultiplayer()) { PhotonView component = ((Component)v).GetComponent(); if ((Object)(object)component != (Object)null && component.ViewID != 0) { component.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { value }); } } } internal static void TeleportPhysObject(PhysGrabObject o, Vector3 pos) { //IL_000a: 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) if ((Object)(object)o != (Object)null) { o.Teleport(pos, ((Component)o).transform.rotation); } } internal static void DestroyValuable(ValuableObject v) { if (!((Object)(object)v == (Object)null)) { PhysGrabObjectImpactDetector component = ((Component)v).GetComponent(); if ((Object)(object)component != (Object)null) { component.DestroyObject(true); } else { Object.Destroy((Object)(object)((Component)v).gameObject); } } } internal static ExtractionPoint GetActiveExtraction() { EnsureReflection(); if ((Object)(object)RoundDirector.instance == (Object)null || _fExtCurrent == null) { return null; } object? value = _fExtCurrent.GetValue(RoundDirector.instance); return (ExtractionPoint)((value is ExtractionPoint) ? value : null); } internal static void SetHaulGoal(ExtractionPoint ep, int value) { //IL_0052: 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) if ((Object)(object)ep == (Object)null) { return; } value = Mathf.Max(1, value); if (SemiFunc.IsMultiplayer()) { PhotonView component = ((Component)ep).GetComponent(); if ((Object)(object)component != (Object)null && component.ViewID != 0) { component.RPC("HaulGoalSetRPC", (RpcTarget)0, new object[1] { value }); } } else { ep.HaulGoalSetRPC(value, default(PhotonMessageInfo)); } } internal static List GetRandomLevelPoints(int count) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if ((Object)(object)LevelGenerator.Instance != (Object)null) { foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints) { if ((Object)(object)levelPathPoint != (Object)null && !levelPathPoint.Truck && (Object)(object)((Component)levelPathPoint).GetComponentInParent() == (Object)null) { list.Add(levelPathPoint); } } } List list2 = new List(count); if (list.Count == 0) { PlayerAvatar instance = PlayerAvatar.instance; return SpawnUtils.GetFloorRing(((Object)(object)instance != (Object)null) ? ((Component)instance).transform.position : Vector3.zero, count, 5f); } for (int i = 0; i < count; i++) { LevelPoint val = list[Random.Range(0, list.Count)]; list2.Add(((Component)val).transform.position + Vector3.up * 0.5f); } return list2; } private static Item FindGrenadeItem() { if ((Object)(object)_grenadeItem != (Object)null) { return _grenadeItem; } foreach (Item allItem in Items.AllItems) { string text = ((Object)allItem).name.ToLowerInvariant(); if (text.Contains("grenade") && !text.Contains("mine") && !text.Contains("human")) { _grenadeItem = allItem; break; } } return _grenadeItem; } internal static void SpawnGrenadeAt(Vector3 pos, float fuse) { //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_0022: 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) Item val = FindGrenadeItem(); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = (SemiFunc.IsMultiplayer() ? Items.SpawnItem(val, pos, Quaternion.identity) : Object.Instantiate(((PrefabRef)(object)val.prefab).Prefab, pos, Quaternion.identity)); if (!((Object)(object)val2 == (Object)null)) { ItemGrenade componentInChildren = val2.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.isSpawnedGrenade = true; componentInChildren.tickTime = fuse; } ItemToggle componentInChildren2 = val2.GetComponentInChildren(); if ((Object)(object)componentInChildren2 != (Object)null) { componentInChildren2.toggleState = true; } } } internal static void ReleaseLocalGrab() { EnsureReflection(); PhysGrabber instance = PhysGrabber.instance; if (!((Object)(object)instance == (Object)null) && instance.grabbed && !(_fGrabbedObj == null)) { object? value = _fGrabbedObj.GetValue(instance); PhysGrabObject val = (PhysGrabObject)((value is PhysGrabObject) ? value : null); if (!((Object)(object)val == (Object)null)) { PhotonView component = ((Component)val).GetComponent(); int num = (((Object)(object)component != (Object)null) ? component.ViewID : 0); instance.OverrideGrabRelease(num, 1f); } } } } public class EvTreasureMigration : LuckyEvent { public override string Id => "TreasureMigration"; public override string Label => "Treasure Migration — all loot scatters"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 2; } public override void Execute(LuckyEventContext ctx) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) List looseValuables = EventHelpers.GetLooseValuables(); List randomLevelPoints = EventHelpers.GetRandomLevelPoints(looseValuables.Count); for (int i = 0; i < looseValuables.Count && i < randomLevelPoints.Count; i++) { EventHelpers.TeleportPhysObject(((Component)looseValuables[i]).GetComponent(), randomLevelPoints[i]); } } } public class EvPositionSwap : LuckyEvent { public override string Id => "PositionSwap"; public override string Label => "Musical Chairs — everyone swaps positions"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 3f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetAllPlayers().Count >= 2; } public override void Execute(LuckyEventContext ctx) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) List allPlayers = EventHelpers.GetAllPlayers(); List list = new List(allPlayers.Count); foreach (PlayerAvatar item in allPlayers) { list.Add(((Component)item).transform.position); } for (int i = 0; i < allPlayers.Count; i++) { EventHelpers.TeleportPlayer(allPlayers[i], list[(i + 1) % list.Count]); } } } public class EvMeteorShower : LuckyEvent { public override string Id => "MeteorShower"; public override string Label => "Meteor Shower — grenades rain on everyone"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 2.5f; public override void Execute(LuckyEventContext ctx) { //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_0058: 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_0060: 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) Vector3 val = default(Vector3); foreach (PlayerAvatar allPlayer in EventHelpers.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)null)) { Vector3 position = ((Component)allPlayer).transform.position; for (int i = 0; i < 3; i++) { ((Vector3)(ref val))..ctor(Random.Range(-2.5f, 2.5f), 0f, Random.Range(-2.5f, 2.5f)); EventHelpers.SpawnGrenadeAt(position + val + Vector3.up * 6f, 1.6f); } } } } } public class EvEarthquake : LuckyEvent { public override string Id => "Earthquake"; public override string Label => "Earthquake — everything gets launched"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 3f; public override void Execute(LuckyEventContext ctx) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) PhysGrabObject[] array = Object.FindObjectsOfType(); Vector3 val2 = default(Vector3); foreach (PhysGrabObject val in array) { if (!((Object)(object)val == (Object)null)) { Rigidbody component = ((Component)val).GetComponent(); if (!((Object)(object)component == (Object)null) && !component.isKinematic) { ((Vector3)(ref val2))..ctor(Random.Range(-1.5f, 1.5f), Random.Range(2f, 4f), Random.Range(-1.5f, 1.5f)); component.AddForce(val2, (ForceMode)2); } } } LuckyFx.Broadcast("shake", "5,1.5"); } } public class EvVacuumPulse : LuckyEvent { public override string Id => "VacuumPulse"; public override string Label => "Vacuum Pulse — loot flies to the block"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 1; } public override void Execute(LuckyEventContext ctx) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) List looseValuables = EventHelpers.GetLooseValuables(); List floorRing = SpawnUtils.GetFloorRing(ctx.BlockPos, Mathf.Max(3, looseValuables.Count), 2.2f); int num = 0; foreach (ValuableObject item in looseValuables) { EventHelpers.TeleportPhysObject(((Component)item).GetComponent(), floorRing[num++ % floorRing.Count] + Vector3.up * 0.4f); } } } public class EvEnemyScatter : LuckyEvent { public override string Id => "EnemyScatter"; public override string Label => "The Rapture — every enemy teleports away"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetSpawnedEnemies().Count > 0; } public override void Execute(LuckyEventContext ctx) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) List spawnedEnemies = EventHelpers.GetSpawnedEnemies(); List randomLevelPoints = EventHelpers.GetRandomLevelPoints(spawnedEnemies.Count); for (int i = 0; i < spawnedEnemies.Count && i < randomLevelPoints.Count; i++) { EventHelpers.TeleportEnemy(spawnedEnemies[i], randomLevelPoints[i]); } } } public class EvZeroGLoot : LuckyEvent { public override string Id => "ZeroGLoot"; public override string Label => "Zero-G Loot — valuables float for 15s"; public override LuckyEventCategory Category => LuckyEventCategory.Chaotic; public override float DefaultWeight => 3f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 0; } public override void Execute(LuckyEventContext ctx) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) foreach (ValuableObject looseValuable in EventHelpers.GetLooseValuables()) { PhysGrabObject component = ((Component)looseValuable).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.OverrideZeroGravity(15f); Rigidbody component2 = ((Component)component).GetComponent(); if ((Object)(object)component2 != (Object)null && !component2.isKinematic) { component2.AddForce(Vector3.up * 1.2f, (ForceMode)2); } } } } } public class EvValuable : LuckyEvent { public override string Id => "Valuable"; public override string Label => "Random Valuable"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 14f; public override void Execute(LuckyEventContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) SpawnUtils.SpawnRandomValuable(SpawnUtils.GetSpawnPositionInFront(ctx.Opener, 2.5f)); } } public class EvJackpot : LuckyEvent { public override string Id => "Jackpot"; public override string Label => "Jackpot — 3 Valuables"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 4f; public override void Execute(LuckyEventContext ctx) { //IL_0001: 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) foreach (Vector3 item in SpawnUtils.GetFloorRing(ctx.BlockPos, 3, 1.8f)) { SpawnUtils.SpawnRandomValuable(item); } } } public class EvItem : LuckyEvent { public override string Id => "Item"; public override string Label => "Random Item"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 10f; public override void Execute(LuckyEventContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) SpawnUtils.SpawnRandomItem(SpawnUtils.GetSpawnPositionInFront(ctx.Opener, 2.5f)); } } public class EvToolChest : LuckyEvent { public override string Id => "ToolChest"; public override string Label => "Tool Chest — 2 Items"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 3f; public override void Execute(LuckyEventContext ctx) { //IL_0001: 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) foreach (Vector3 item in SpawnUtils.GetFloorRing(ctx.BlockPos, 2, 1.5f)) { SpawnUtils.SpawnRandomItem(item); } } } public class EvPotion : LuckyEvent { public override string Id => "Potion"; public override string Label => "Potion (breaks on floor)"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 6f; public override void Execute(LuckyEventContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) SpawnUtils.SpawnPotion(SpawnUtils.GetSpawnPositionInFront(ctx.Opener, 2.5f)); } } public class EvLuckyCluster : LuckyEvent { public override string Id => "LuckyCluster"; public override string Label => "Lucky Cluster — 3 New Blocks"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 6f; public override void Execute(LuckyEventContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) LuckyBlockManager.Instance?.SpawnBlocks(SpawnUtils.GetFloorRing(ctx.BlockPos, 3, 2f)); } } public class EvHealingWave : LuckyEvent { public override string Id => "HealingWave"; public override string Label => "Healing Wave — +50 HP everyone"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 5f; public override void Execute(LuckyEventContext ctx) { foreach (PlayerAvatar allPlayer in EventHelpers.GetAllPlayers()) { EventHelpers.HealPlayer(allPlayer, 50); } } } public abstract class EvUpgradeBase : LuckyEvent { public override LuckyEventCategory Category => LuckyEventCategory.Lucky; protected abstract string UpgradeName { get; } public override void Execute(LuckyEventContext ctx) { EventHelpers.UpgradePlayer(ctx.Opener, UpgradeName); } } public class EvUpgradeSpeed : EvUpgradeBase { public override string Id => "UpgradeSpeed"; public override string Label => "Adrenaline — Sprint Speed +1"; public override float DefaultWeight => 2.5f; protected override string UpgradeName => "Speed"; } public class EvUpgradeJump : EvUpgradeBase { public override string Id => "UpgradeJump"; public override string Label => "Moon Boots — Extra Jump +1"; public override float DefaultWeight => 2.5f; protected override string UpgradeName => "ExtraJump"; } public class EvUpgradeStamina : EvUpgradeBase { public override string Id => "UpgradeStamina"; public override string Label => "Iron Lungs — Stamina +1"; public override float DefaultWeight => 2.5f; protected override string UpgradeName => "Stamina"; } public class EvUpgradeHealth : EvUpgradeBase { public override string Id => "UpgradeHealth"; public override string Label => "Vitality — Max Health +1"; public override float DefaultWeight => 2.5f; protected override string UpgradeName => "Health"; } public class EvUpgradeStrength : EvUpgradeBase { public override string Id => "UpgradeStrength"; public override string Label => "Strong Arms — Grab Strength +1"; public override float DefaultWeight => 2f; protected override string UpgradeName => "Strength"; } public class EvUpgradeRange : EvUpgradeBase { public override string Id => "UpgradeRange"; public override string Label => "Long Reach — Grab Range +1"; public override float DefaultWeight => 2f; protected override string UpgradeName => "Range"; } public class EvEnemyFreeze : LuckyEvent { public override string Id => "EnemyFreeze"; public override string Label => "Deep Freeze — enemies frozen 10s"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 4f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetSpawnedEnemies().Count > 0; } public override void Execute(LuckyEventContext ctx) { foreach (Enemy spawnedEnemy in EventHelpers.GetSpawnedEnemies()) { spawnedEnemy.Freeze(10f); } } } public class EvGoldenTouch : LuckyEvent { public override string Id => "GoldenTouch"; public override string Label => "Golden Touch — all loot +25% value"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 3f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 0; } public override void Execute(LuckyEventContext ctx) { foreach (ValuableObject looseValuable in EventHelpers.GetLooseValuables()) { float valuableValue = EventHelpers.GetValuableValue(looseValuable); if (valuableValue > 0f) { EventHelpers.SetValuableValue(looseValuable, valuableValue * 1.25f); } } } } public class EvScavengerHunt : LuckyEvent { public override string Id => "ScavengerHunt"; public override string Label => "Scavenger Hunt — one hidden valuable ×10"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 3f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 0; } public override void Execute(LuckyEventContext ctx) { List looseValuables = EventHelpers.GetLooseValuables(); ValuableObject v = looseValuables[Random.Range(0, looseValuables.Count)]; float valuableValue = EventHelpers.GetValuableValue(v); if (valuableValue > 0f) { EventHelpers.SetValuableValue(v, valuableValue * 10f); } } } public class EvLuckyDiscount : LuckyEvent { public override string Id => "LuckyDiscount"; public override string Label => "Lucky Discount — quota −15%"; public override LuckyEventCategory Category => LuckyEventCategory.Lucky; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { ExtractionPoint activeExtraction = EventHelpers.GetActiveExtraction(); if ((Object)(object)activeExtraction != (Object)null) { return activeExtraction.haulGoal > 0; } return false; } public override void Execute(LuckyEventContext ctx) { ExtractionPoint activeExtraction = EventHelpers.GetActiveExtraction(); if (!((Object)(object)activeExtraction == (Object)null)) { EventHelpers.SetHaulGoal(activeExtraction, Mathf.RoundToInt((float)activeExtraction.haulGoal * 0.85f)); } } } public class EvMonster : LuckyEvent { public override string Id => "Monster"; public override string Label => "Random Monster"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 8f; public override void Execute(LuckyEventContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) SpawnUtils.SpawnRandomMonster(SpawnUtils.GetSpawnPositionInFront(ctx.Opener, 2.5f), (MonoBehaviour)(object)LuckyBlockPlugin.Instance); } } public class EvMonsterPack : LuckyEvent { public override string Id => "MonsterPack"; public override string Label => "Monster Pack — 2 Monsters"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 2.5f; public override void Execute(LuckyEventContext ctx) { //IL_0001: 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) foreach (Vector3 item in SpawnUtils.GetFloorRing(ctx.BlockPos, 2, 3f)) { SpawnUtils.SpawnRandomMonster(item, (MonoBehaviour)(object)LuckyBlockPlugin.Instance); } } } public class EvExplosiveFeet : LuckyEvent { public override string Id => "ExplosiveFeet"; public override string Label => "Explosive at Feet"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 7f; public override void Execute(LuckyEventContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) SpawnUtils.SpawnRandomExplosive(SpawnUtils.GetSpawnPositionOnPlayer(ctx.Opener)); } } public class EvClusterSmall : LuckyEvent { public override string Id => "ClusterSmall"; public override string Label => "Small Cluster — 3 bombs around player"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 5f; public override void Execute(LuckyEventContext ctx) { SpawnUtils.SpawnExplosiveCluster(ctx.Opener); } } public class EvClusterLarge : LuckyEvent { public override string Id => "ClusterLarge"; public override string Label => "Large Cluster — 5 bombs around block"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 3f; public override void Execute(LuckyEventContext ctx) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SpawnUtils.SpawnLargeExplosiveCluster(ctx.BlockPos); } } public class EvTumble : LuckyEvent { public override string Id => "Tumble"; public override string Label => "Knockdown — tumble lock 3s"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 4f; public override void Execute(LuckyEventContext ctx) { RandomEventRoller.ForceTumbleLock(ctx.Opener); } } public class EvTeleportRoulette : LuckyEvent { public override string Id => "TeleportRoulette"; public override string Label => "Teleport Roulette — opener sent somewhere"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 3f; public override void Execute(LuckyEventContext ctx) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) List randomLevelPoints = EventHelpers.GetRandomLevelPoints(1); if (randomLevelPoints.Count > 0) { EventHelpers.TeleportPlayer(ctx.Opener, randomLevelPoints[0]); } } } public class EvPiedPiper : LuckyEvent { public override string Id => "PiedPiper"; public override string Label => "Pied Piper — every enemy comes to YOU"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetSpawnedEnemies().Count > 0; } public override void Execute(LuckyEventContext ctx) { //IL_001a: 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) if ((Object)(object)ctx.Opener == (Object)null) { return; } List floorRing = SpawnUtils.GetFloorRing(((Component)ctx.Opener).transform.position, Mathf.Max(1, EventHelpers.GetSpawnedEnemies().Count), 4f); int num = 0; foreach (Enemy spawnedEnemy in EventHelpers.GetSpawnedEnemies()) { EventHelpers.TeleportEnemy(spawnedEnemy, floorRing[num++ % floorRing.Count]); } } } public class EvTaxman : LuckyEvent { public override string Id => "Taxman"; public override string Label => "The Taxman — cheapest valuable repossessed"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 3f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 1; } public override void Execute(LuckyEventContext ctx) { ValuableObject val = null; float num = float.MaxValue; foreach (ValuableObject looseValuable in EventHelpers.GetLooseValuables()) { float valuableValue = EventHelpers.GetValuableValue(looseValuable); if (valuableValue > 0f && valuableValue < num) { num = valuableValue; val = looseValuable; } } if ((Object)(object)val != (Object)null) { EventHelpers.DestroyValuable(val); } } } public class EvReversePayday : LuckyEvent { public override string Id => "ReversePayday"; public override string Label => "Reverse Payday — quota +15%"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { ExtractionPoint activeExtraction = EventHelpers.GetActiveExtraction(); if ((Object)(object)activeExtraction != (Object)null) { return activeExtraction.haulGoal > 0; } return false; } public override void Execute(LuckyEventContext ctx) { ExtractionPoint activeExtraction = EventHelpers.GetActiveExtraction(); if (!((Object)(object)activeExtraction == (Object)null)) { EventHelpers.SetHaulGoal(activeExtraction, Mathf.RoundToInt((float)activeExtraction.haulGoal * 1.15f)); } } } public class EvHoardersCurse : LuckyEvent { public override string Id => "HoardersCurse"; public override string Label => "Hoarder's Curse — all loot piles up in one room"; public override LuckyEventCategory Category => LuckyEventCategory.Unlucky; public override float DefaultWeight => 2f; public override bool CanRun(LuckyEventContext ctx) { return EventHelpers.GetLooseValuables().Count > 2; } public override void Execute(LuckyEventContext ctx) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) List randomLevelPoints = EventHelpers.GetRandomLevelPoints(1); if (randomLevelPoints.Count == 0) { return; } Vector3 val = randomLevelPoints[0]; int num = 0; Vector3 val2 = default(Vector3); foreach (ValuableObject looseValuable in EventHelpers.GetLooseValuables()) { PhysGrabObject component = ((Component)looseValuable).GetComponent(); ((Vector3)(ref val2))..ctor(Random.Range(-0.8f, 0.8f), 0.3f + (float)(num++ % 5) * 0.3f, Random.Range(-0.8f, 0.8f)); EventHelpers.TeleportPhysObject(component, val + val2); } } } public class EvBlackout : LuckyEvent { public override string Id => "Blackout"; public override string Label => "Blackout — lights out for 30s"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 3f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("blackout", "30"); } } public class EvLowGravity : LuckyEvent { public override string Id => "LowGravity"; public override string Label => "Low Gravity — 20s of moon physics"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 3f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("lowgrav", "20"); } } public class EvRaveLights : LuckyEvent { public override string Id => "RaveLights"; public override string Label => "Rave — rainbow lighting for 20s"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 2.5f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("rave", "20"); } } public class EvFalseAlarm : LuckyEvent { public override string Id => "FalseAlarm"; public override string Label => "False Alarm — something is coming..."; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 3f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("falsealarm", ""); } } public class EvButterFingers : LuckyEvent { public override string Id => "ButterFingers"; public override string Label => "Butter Fingers — everyone drops their grab"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 3f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("butterfingers", ""); } } public class EvTinyPlayers : LuckyEvent { public override string Id => "TinyPlayers"; public override string Label => "Honey I Shrunk the Crew — tiny for 30s"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 2f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("avatarscale", "0.5,30"); } } public class EvGiantPlayers : LuckyEvent { public override string Id => "GiantPlayers"; public override string Label => "Growth Spurt — giant avatars for 30s"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 2f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("avatarscale", "1.6,30"); } } public class EvDanceParty : LuckyEvent { public override string Id => "DanceParty"; public override string Label => "Dance Party — everybody boogie 15s"; public override LuckyEventCategory Category => LuckyEventCategory.Wacky; public override float DefaultWeight => 2.5f; public override bool RequiresAllClients => true; public override void Execute(LuckyEventContext ctx) { LuckyFx.Broadcast("danceparty", "15"); } } public enum LuckyEventCategory { Lucky, Unlucky, Chaotic, Wacky } public class LuckyEventContext { public PlayerAvatar Opener; public Vector3 BlockPos; } public abstract class LuckyEvent { internal ConfigEntry ConfigEnabled; internal ConfigEntry ConfigWeight; public abstract string Id { get; } public abstract string Label { get; } public abstract LuckyEventCategory Category { get; } public abstract float DefaultWeight { get; } public virtual bool RequiresAllClients => false; public bool Enabled { get { if (ConfigEnabled != null) { return ConfigEnabled.Value; } return true; } } public float Weight { get { if (ConfigWeight == null) { return DefaultWeight; } return Mathf.Max(0f, ConfigWeight.Value); } } public virtual bool CanRun(LuckyEventContext ctx) { return true; } public abstract void Execute(LuckyEventContext ctx); } public static class LuckyEventLog { internal static ConfigEntry ConfigEnabled; internal static ConfigEntry ConfigMaxEntries; internal static ConfigEntry ConfigDuration; public static bool Enabled { get { if (ConfigEnabled != null) { return ConfigEnabled.Value; } return true; } } public static int MaxEntries { get { if (ConfigMaxEntries == null) { return 3; } return Mathf.Max(1, ConfigMaxEntries.Value); } } public static float Duration { get { if (ConfigDuration == null) { return 60f; } return Mathf.Max(1f, ConfigDuration.Value); } } public static void BindConfig(ConfigFile config) { ConfigEnabled = config.Bind("EventLog", "Enabled", true, "Show the recent-events log in the F6 debug window."); ConfigMaxEntries = config.Bind("EventLog", "MaxEntries", 3, "How many recent events to show at most."); ConfigDuration = config.Bind("EventLog", "DurationSeconds", 60f, "Events older than this disappear from the log — except the newest one, which stays visible permanently."); } public static List GetVisible() { List list = new List(); List eventLog = RandomEventRoller.EventLog; if (eventLog.Count == 0) { return list; } float realtimeSinceStartup = Time.realtimeSinceStartup; foreach (RandomEventRoller.EventLogEntry item in eventLog) { if (list.Count >= MaxEntries) { break; } if (realtimeSinceStartup - item.TimeLogged <= Duration) { list.Add(item); } } if (list.Count == 0) { list.Add(eventLog[0]); } return list; } } public static class LuckyEventRegistry { private static readonly List _events = new List(); private static bool _built; public static IReadOnlyList All => _events; public static void Build() { if (_built) { return; } _built = true; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (!type.IsAbstract && typeof(LuckyEvent).IsAssignableFrom(type)) { try { _events.Add((LuckyEvent)Activator.CreateInstance(type)); } catch (Exception ex) { Debug.LogError((object)("[LuckyBlock] Failed to create event '" + type.Name + "': " + ex.Message)); } } } _events.Sort(delegate(LuckyEvent a, LuckyEvent b) { int num = a.Category.CompareTo(b.Category); return (num == 0) ? string.CompareOrdinal(a.Id, b.Id) : num; }); Debug.Log((object)$"[LuckyBlock] Event registry built: {_events.Count} events."); } public static void BindConfig(ConfigFile config) { foreach (LuckyEvent @event in _events) { string text = $"Events.{@event.Category}"; @event.ConfigEnabled = config.Bind(text, @event.Id + ".Enabled", true, "Enable '" + @event.Label + "'."); @event.ConfigWeight = config.Bind(text, @event.Id + ".Weight", @event.DefaultWeight, "Roll weight for '" + @event.Label + "' (0 disables it). Higher = more frequent."); } } public static void Roll(LuckyEventContext ctx) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } List list = new List(); float num = 0f; foreach (LuckyEvent @event in _events) { if (IsEligible(@event, ctx)) { list.Add(@event); num += @event.Weight; } } if (list.Count == 0 || num <= 0f) { Debug.LogWarning((object)"[LuckyBlock] Roll: no eligible events — falling back to a valuable."); SpawnUtils.SpawnRandomValuable(SpawnUtils.GetSpawnPositionInFront(ctx.Opener, 2.5f)); return; } float num2 = Random.value * num; float num3 = 0f; LuckyEvent ev = list[list.Count - 1]; foreach (LuckyEvent item in list) { num3 += item.Weight; if (num2 < num3) { ev = item; break; } } Fire(ev, ctx); } public static void Fire(LuckyEvent ev, LuckyEventContext ctx) { try { ev.Execute(ctx); EventHelpers.Announce($"[{ev.Category}] {ev.Label}"); } catch (Exception arg) { Debug.LogError((object)$"[LuckyBlock] Event '{ev.Id}' failed: {arg}"); } } private static bool IsEligible(LuckyEvent ev, LuckyEventContext ctx) { if (!ev.Enabled || ev.Weight <= 0f) { return false; } if (ev.RequiresAllClients && SemiFunc.IsMultiplayer() && !ModeManager.IsPrivate) { return false; } try { return ev.CanRun(ctx); } catch { return false; } } } public static class LuckyFx { public const string ANNOUNCE = "announce"; public const string BLACKOUT = "blackout"; public const string LOW_GRAVITY = "lowgrav"; public const string SHAKE = "shake"; public const string RAVE = "rave"; public const string FALSE_ALARM = "falsealarm"; public const string BUTTERFINGERS = "butterfingers"; public const string AVATAR_SCALE = "avatarscale"; public const string DANCE_PARTY = "danceparty"; public const string TELEPORT = "teleport"; private static bool _blackoutActive; private static bool _lowGravActive; private static bool _raveActive; private static bool _scaleActive; public static void Broadcast(string id, string args) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) string text = ((args != null && args.Length > 0) ? (id + "|" + args) : id); Run(text); if (SemiFunc.IsMultiplayer() && ModeManager.IsPrivate && LuckyBlockPlugin.FxEvent != null) { LuckyBlockPlugin.FxEvent.RaiseEvent((object)text, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } public static void Run(string payload) { if (string.IsNullOrEmpty(payload)) { return; } int num = payload.IndexOf('|'); string text = ((num >= 0) ? payload.Substring(0, num) : payload); string text2 = ((num >= 0) ? payload.Substring(num + 1) : ""); try { switch (text) { case "announce": RandomEventRoller.LogEvent(text2, "[LuckyBlock]"); break; case "blackout": Start(Blackout(ParseF(text2, 0, 30f))); break; case "lowgrav": Start(LowGravity(ParseF(text2, 0, 20f))); break; case "shake": Start(Shake(ParseF(text2, 0, 6f), ParseF(text2, 1, 1.5f))); break; case "rave": Start(Rave(ParseF(text2, 0, 20f))); break; case "falsealarm": FalseAlarm(); break; case "butterfingers": EventHelpers.ReleaseLocalGrab(); break; case "avatarscale": Start(AvatarScale(ParseF(text2, 0, 0.5f), ParseF(text2, 1, 30f))); break; case "danceparty": DanceParty(ParseF(text2, 0, 15f)); break; case "teleport": TeleportSelf(text2); break; default: Debug.LogWarning((object)("[LuckyBlock] Unknown FX id '" + text + "'.")); break; } } catch (Exception ex) { Debug.LogError((object)("[LuckyBlock] FX '" + text + "' failed: " + ex.Message)); } } private static void Start(IEnumerator routine) { LuckyBlockPlugin.StartManagedCoroutine(routine); } private static float ParseF(string args, int index, float fallback) { if (string.IsNullOrEmpty(args)) { return fallback; } string[] array = args.Split(','); if (index >= array.Length) { return fallback; } if (!float.TryParse(array[index], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return fallback; } return result; } private static IEnumerator Blackout(float duration) { if (_blackoutActive) { yield break; } _blackoutActive = true; List> dimmed = new List>(); Light[] array = Object.FindObjectsOfType(); foreach (Light val in array) { if (!((Object)(object)val == (Object)null) && !(val.intensity <= 0.01f)) { dimmed.Add(new KeyValuePair(val, val.intensity)); val.intensity = 0.02f; } } Color ambient = RenderSettings.ambientLight; RenderSettings.ambientLight = Color.black; yield return (object)new WaitForSeconds(duration); foreach (KeyValuePair item in dimmed) { if ((Object)(object)item.Key != (Object)null) { item.Key.intensity = item.Value; } } RenderSettings.ambientLight = ambient; _blackoutActive = false; } private static IEnumerator LowGravity(float duration) { if (!_lowGravActive) { _lowGravActive = true; Vector3 original = Physics.gravity; Physics.gravity = original * 0.25f; yield return (object)new WaitForSeconds(duration); Physics.gravity = original; _lowGravActive = false; } } private static IEnumerator Shake(float duration, float strength) { CameraShake shaker = Object.FindObjectOfType(); float elapsed = 0f; while (elapsed < duration) { if ((Object)(object)shaker != (Object)null) { shaker.Shake(strength, 0.3f); } elapsed += 0.25f; yield return (object)new WaitForSeconds(0.25f); } } private static IEnumerator Rave(float duration) { if (!_raveActive) { _raveActive = true; Color original = RenderSettings.ambientLight; float elapsed = 0f; while (elapsed < duration) { RenderSettings.ambientLight = Color.HSVToRGB(Mathf.Repeat(elapsed * 0.5f, 1f), 0.9f, 0.8f); elapsed += Time.deltaTime; yield return null; } RenderSettings.ambientLight = original; _raveActive = false; } } private static void FalseAlarm() { //IL_0033: 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) ChatManager instance = ChatManager.instance; if (!((Object)(object)instance == (Object)null)) { instance.PossessChatScheduleStart(9); instance.PossessChat((PossessChatID)0, "something is coming . . .", 0.06f, new Color(0.9f, 0.1f, 0.1f), 0f, false, 0, (UnityEvent)null); instance.PossessChat((PossessChatID)0, "nevermind. probably nothing", 0.05f, new Color(0.6f, 0.6f, 0.6f), 3f, false, 0, (UnityEvent)null); instance.PossessChatScheduleEnd(); } } private static IEnumerator AvatarScale(float scale, float duration) { if (_scaleActive) { yield break; } _scaleActive = true; List> scaled = new List>(); foreach (PlayerAvatar allPlayer in EventHelpers.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)null) && !((Object)(object)allPlayer.playerAvatarVisuals == (Object)null)) { Transform transform = ((Component)allPlayer.playerAvatarVisuals).transform; scaled.Add(new KeyValuePair(transform, transform.localScale)); transform.localScale *= scale; } } yield return (object)new WaitForSeconds(duration); foreach (KeyValuePair item in scaled) { if ((Object)(object)item.Key != (Object)null) { item.Key.localScale = item.Value; } } _scaleActive = false; } private static void TeleportSelf(string args) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; if (!((Object)(object)instance == (Object)null)) { PhotonView component = ((Component)instance).GetComponent(); if (!((Object)(object)component == (Object)null) && (int)ParseF(args, 0, -1f) == component.ViewID) { EventHelpers.TeleportLocalController(new Vector3(ParseF(args, 1, 0f), ParseF(args, 2, 0f), ParseF(args, 3, 0f))); } } } private static void DanceParty(float duration) { MonoBehaviour instance = (MonoBehaviour)(object)LuckyBlockPlugin.Instance; if ((Object)(object)instance == (Object)null) { return; } foreach (PlayerAvatar allPlayer in EventHelpers.GetAllPlayers()) { RandomEventRoller.ForceBoomboxDance(allPlayer, duration, instance, "[LuckyBlock]"); } } } public class LuckyBlock : MonoBehaviour { private PhysGrabObject _grab; private PhysGrabObjectImpactDetector _impact; private bool _triggered; private void Awake() { RandomEventRoller.Init(); _grab = ((Component)this).GetComponent(); _impact = ((Component)this).GetComponent(); } private void Update() { if (!_triggered && SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)_grab != (Object)null && _grab.grabbed) { Trigger(ResolveGrabber()); } } private void Open() { Trigger(ResolveGrabber()); } private void Trigger(PlayerAvatar grabber) { //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_002d: Unknown result type (might be due to invalid IL or missing references) if (!_triggered) { _triggered = true; if ((Object)(object)grabber == (Object)null) { grabber = PlayerAvatar.instance; } Vector3 position = ((Component)this).transform.position; LuckyBlockEvents.Roll(grabber, position); if ((Object)(object)_impact != (Object)null) { _impact.DestroyObject(true); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private PlayerAvatar ResolveGrabber() { //IL_0069: 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) if ((Object)(object)_grab != (Object)null && _grab.playerGrabbing != null && _grab.playerGrabbing.Count > 0) { PhysGrabber val = _grab.playerGrabbing[0]; if ((Object)(object)val != (Object)null && (Object)(object)val.playerAvatar != (Object)null) { return val.playerAvatar; } } List list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(8f, ((Component)this).transform.position, false, default(LayerMask)); if (list != null && list.Count > 0 && (Object)(object)list[0] != (Object)null) { return list[0]; } return PlayerAvatar.instance; } } public static class LuckyBlockEvents { private static LuckyEventContext MakeContext(PlayerAvatar player, Vector3 blockPos) { //IL_0010: 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_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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { player = PlayerAvatar.instance; } if (blockPos == Vector3.zero && (Object)(object)player != (Object)null) { blockPos = ((Component)player).transform.position; } return new LuckyEventContext { Opener = player, BlockPos = blockPos }; } public static void Roll(PlayerAvatar opener, Vector3 blockPos) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { LuckyEventContext luckyEventContext = MakeContext(opener, blockPos); if (!((Object)(object)luckyEventContext.Opener == (Object)null)) { LuckyEventRegistry.Roll(luckyEventContext); } } } public static void TriggerSpecific(int eventIdx, PlayerAvatar player, Vector3 blockPos) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } LuckyEventContext luckyEventContext = MakeContext(player, blockPos); if (!((Object)(object)luckyEventContext.Opener == (Object)null)) { IReadOnlyList all = LuckyEventRegistry.All; if (eventIdx >= 0 && eventIdx < all.Count) { LuckyEventRegistry.Fire(all[eventIdx], luckyEventContext); } else { LuckyEventRegistry.Roll(luckyEventContext); } } } } public class LuckyBlockItem : MonoBehaviour { private bool _isLucky; internal bool _consumed; private bool _activatedLocal; private PhysGrabObject _grab; private PhotonView _view; internal bool IsLucky => _isLucky; private void Awake() { RandomEventRoller.Init(); _grab = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); _view = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInParent(); } private void Update() { if (_isLucky && !_activatedLocal && !((Object)(object)_grab == (Object)null) && ModeManager.IsPrivate && _grab.grabbedLocal && SemiFunc.InputDown((InputKey)2)) { Activate(); } } internal void SetLucky() { MakeLucky(); if (SemiFunc.IsMultiplayer() && (Object)(object)_view != (Object)null && _view.ViewID != 0) { _view.RPC("SetLuckyRPC", (RpcTarget)4, Array.Empty()); } } [PunRPC] private void SetLuckyRPC() { MakeLucky(); } private void MakeLucky() { _isLucky = true; LuckyBlockSkin.Apply(((Component)this).gameObject, 1f / 6f); } private void Open() { Activate(); } private void Activate() { if (!_activatedLocal) { _activatedLocal = true; int num = SemiFunc.PhotonViewIDPlayerAvatarLocal(); if (SemiFunc.IsMasterClientOrSingleplayer()) { ActivateOnHost(((Component)this).gameObject, num); } else if ((Object)(object)_view != (Object)null && _view.ViewID != 0) { _view.RPC("ActivateRPC", (RpcTarget)2, new object[1] { num }); } } } [PunRPC] private void ActivateRPC(int playerViewID) { ActivateOnHost(((Component)this).gameObject, playerViewID); } internal static void ActivateOnHost(GameObject item, int playerViewID) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } LuckyBlockItem component = item.GetComponent(); if ((Object)(object)component != (Object)null) { if (component._consumed) { return; } component._consumed = true; } PlayerAvatar opener = ResolvePlayer(playerViewID); Vector3 position = item.transform.position; LuckyBlockEvents.Roll(opener, position); if (SemiFunc.IsMultiplayer()) { PhotonNetwork.Destroy(item); } else { Object.Destroy((Object)(object)item); } } private static PlayerAvatar ResolvePlayer(int viewID) { if (viewID > 0) { PhotonView val = PhotonView.Find(viewID); PlayerAvatar val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { return val2; } } return PlayerAvatar.instance; } } [HarmonyPatch(typeof(ItemAttributes), "Awake")] internal static class LuckyBlockItem_AttachPatch { private static void Postfix(ItemAttributes __instance) { if (!((Object)(object)__instance == (Object)null)) { string text = (((Object)(object)__instance.item != (Object)null) ? __instance.item.itemName : null); string value = "Drone Battery"; if (((text != null && text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) || ((Object)((Component)__instance).gameObject).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) && (Object)(object)((Component)__instance).GetComponent() == (Object)null) { ((Component)__instance).gameObject.AddComponent(); } } } } [HarmonyPatch(typeof(ItemAttributes), "GetItemNameLocalized")] internal static class LuckyBlockItem_NamePatch { private static void Postfix(ItemAttributes __instance, ref string __result) { LuckyBlockItem luckyBlockItem = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponent() : null); if ((Object)(object)luckyBlockItem != (Object)null && luckyBlockItem.IsLucky) { __result = "Lucky Block"; } } } public class LuckyBlockManager : MonoBehaviour { public static LuckyBlockManager Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } } internal List SpawnBlocks(List positions) { List list = new List(); if (positions == null || positions.Count == 0) { return list; } if (SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClientOrSingleplayer()) { Debug.LogWarning((object)"[LuckyBlock] Only the host can spawn lucky blocks."); return list; } if (!ModeManager.IsPrivate) { return SpawnPublic(positions, list); } return SpawnPrivate(positions, list); } private List SpawnPrivate(List positions, List spawned) { //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_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SpawnUtils.GetLuckyItem() == (Object)null) { Debug.LogError((object)"[LuckyBlock] PRIVATE mode: base item 'Drone Battery' not found. Switch back to Public mode (F6 menu)."); return spawned; } foreach (Vector3 position in positions) { GameObject val = SpawnUtils.SpawnLuckyItem(position); if (!((Object)(object)val == (Object)null)) { LuckyBlockItem componentInChildren = val.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.SetLucky(); } else { Debug.LogError((object)"[LuckyBlock] spawned item has no LuckyBlockItem component."); } spawned.Add(val); Debug.Log((object)$"[LuckyBlock] Lucky ITEM spawned at {position:F1} (private edition)."); } } return spawned; } private List SpawnPublic(List positions, List spawned) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_00af: 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) foreach (Vector3 position in positions) { GameObject val = SpawnUtils.SpawnLuckyValuable(position); if ((Object)(object)val == (Object)null) { Debug.LogError((object)$"[LuckyBlock] Failed to spawn lucky valuable at {position:F1}."); continue; } if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } LuckyBlockSkin.Apply(val); if (SemiFunc.IsMultiplayer()) { PhotonView component = val.GetComponent(); if ((Object)(object)component != (Object)null && component.ViewID != 0 && LuckyBlockPlugin.SkinEvent != null) { LuckyBlockPlugin.SkinEvent.RaiseEvent((object)component.ViewID, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } spawned.Add(val); Debug.Log((object)$"[LuckyBlock] Lucky six-pack spawned at {position:F1}."); } return spawned; } internal void ClearBlocks() { } } public enum LuckyBlockMode { PublicServer, PrivateServer } public static class ModeManager { internal static ConfigEntry EditionConfig; public static LuckyBlockMode CurrentEdition { get { if (EditionConfig == null) { return LuckyBlockMode.PublicServer; } return EditionConfig.Value; } } public static bool IsPrivate => CurrentEdition == LuckyBlockMode.PrivateServer; public static void SetEdition(LuckyBlockMode mode) { if (EditionConfig != null) { EditionConfig.Value = mode; } } } [BepInPlugin("com.tonnom.luckyblock", "REPO_lucky_block", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class LuckyBlockPlugin : BaseUnityPlugin { private static MonoBehaviour _coroutineHost; private Harmony _harmony; public static LuckyBlockPlugin Instance { get; private set; } internal static NetworkedEvent SkinEvent { get; private set; } internal static NetworkedEvent FxEvent { get; private set; } private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown Instance = this; _coroutineHost = (MonoBehaviour)(object)this; ((Component)this).gameObject.AddComponent(); _harmony = new Harmony("com.tonnom.luckyblock"); _harmony.PatchAll(); SkinEvent = new NetworkedEvent("LuckyBlock Skin", (Action)OnSkinEvent); FxEvent = new NetworkedEvent("LuckyBlock FX", (Action)OnFxEvent); ModeManager.EditionConfig = ((BaseUnityPlugin)this).Config.Bind("General", "Edition", LuckyBlockMode.PublicServer, "PublicServer = host-only, no client install needed (lucky block is a valuable, grab it). PrivateServer = everyone must install the mod (lucky block is a custom item, press E)."); LuckyEventRegistry.Build(); LuckyEventRegistry.BindConfig(((BaseUnityPlugin)this).Config); LuckyEventLog.BindConfig(((BaseUnityPlugin)this).Config); SceneManager.sceneLoaded += OnSceneLoaded; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[LuckyBlock] Plugin loaded — Manager alive: {(Object)(object)LuckyBlockManager.Instance != (Object)null}. F6 for debug menu."); } private static void OnSkinEvent(EventData e) { if (((e != null) ? e.CustomData : null) is int viewID) { StartManagedCoroutine(SkinWhenReady(viewID)); } } private static IEnumerator SkinWhenReady(int viewID) { for (int i = 0; i < 120; i++) { PhotonView val = PhotonView.Find(viewID); if ((Object)(object)val != (Object)null) { LuckyBlockSkin.Apply(((Component)val).gameObject); break; } yield return null; } } private static void OnFxEvent(EventData e) { if (((e != null) ? e.CustomData : null) is string payload) { LuckyFx.Run(payload); } } internal static void StartManagedCoroutine(IEnumerator routine) { if ((Object)(object)_coroutineHost != (Object)null) { _coroutineHost.StartCoroutine(routine); } else { Debug.LogWarning((object)"[LuckyBlock] CoroutineHost missing — coroutine dropped."); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown LuckyBlockManager.Instance?.ClearBlocks(); if ((Object)(object)Object.FindObjectOfType() == (Object)null) { GameObject val = new GameObject("LuckyBlock_StatusPanel"); val.AddComponent(); Object.DontDestroyOnLoad((Object)val); } if ((Object)(object)Object.FindObjectOfType() == (Object)null) { GameObject val2 = new GameObject("LuckyBlock_DebugMenu"); val2.AddComponent(); Object.DontDestroyOnLoad((Object)val2); } LuckyBlockSpawner.ResetSpawnFlag(); StartManagedCoroutine(BackupSpawnCoroutine()); } private static IEnumerator BackupSpawnCoroutine() { yield return (object)new WaitForSeconds(1f); if ((Object)(object)RunManager.instance == (Object)null || !SemiFunc.RunIsLevel() || !SemiFunc.IsMasterClientOrSingleplayer()) { yield break; } for (float waited = 0f; waited < 15f; waited += 0.5f) { if ((Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated) { break; } yield return (object)new WaitForSeconds(0.5f); } if (!((Object)(object)LevelGenerator.Instance == (Object)null) && LevelGenerator.Instance.Generated && SemiFunc.RunIsLevel()) { LuckyBlockSpawner.SpawnForCurrentLevel("BackupCoroutine"); } } } public class CoroutineHost : MonoBehaviour { } internal static class LuckyBlockSkin { private const string SKIN_NAME = "LuckyBlockSkin"; private static Texture2D _tex; private static Material _mat; private static Mesh _cubeMesh; internal static void Apply(GameObject valuable, float scale = 1f) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0071: 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_00b3: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f4: 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_0113: 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_0133: 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) if ((Object)(object)valuable == (Object)null || (Object)(object)valuable.transform.Find("LuckyBlockSkin") != (Object)null) { return; } Material material = GetMaterial(); Mesh cubeMesh = GetCubeMesh(); if (!((Object)(object)material == (Object)null) && !((Object)(object)cubeMesh == (Object)null)) { Bounds val = ComputeBounds(valuable); float num = Mathf.Max(new float[3] { ((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.y, ((Bounds)(ref val)).size.z }) * 1.05f; if (num <= 0.001f) { num = 0.5f; } num = Mathf.Clamp(num, 0.2f, 1f) * scale; GameObject val2 = new GameObject("LuckyBlockSkin"); val2.transform.SetParent(valuable.transform, false); val2.transform.localRotation = Quaternion.identity; val2.transform.position = ((Bounds)(ref val)).center; Vector3 lossyScale = valuable.transform.lossyScale; val2.transform.localScale = new Vector3(num / Mathf.Max(0.0001f, lossyScale.x), num / Mathf.Max(0.0001f, lossyScale.y), num / Mathf.Max(0.0001f, lossyScale.z)); val2.AddComponent().sharedMesh = cubeMesh; ((Renderer)val2.AddComponent()).sharedMaterial = material; } } private static Bounds ComputeBounds(GameObject go) { //IL_0002: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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) Bounds result = default(Bounds); bool flag = false; Renderer[] componentsInChildren = go.GetComponentsInChildren(); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !(((Object)((Component)val).gameObject).name == "LuckyBlockSkin") && (val is MeshRenderer || val is SkinnedMeshRenderer)) { if (!flag) { result = val.bounds; flag = true; } else { ((Bounds)(ref result)).Encapsulate(val.bounds); } } } if (!flag) { ((Bounds)(ref result))..ctor(go.transform.position, Vector3.one * 0.5f); } return result; } private static Mesh GetCubeMesh() { if ((Object)(object)_cubeMesh != (Object)null) { return _cubeMesh; } GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); _cubeMesh = obj.GetComponent().sharedMesh; Object.Destroy((Object)(object)obj); return _cubeMesh; } private static Material GetMaterial() { //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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_mat != (Object)null) { return _mat; } Texture2D texture = GetTexture(); Shader val = Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { return null; } _mat = new Material(val) { name = "LuckyBlockMat", mainTexture = (Texture)(object)texture }; _mat.SetFloat("_Glossiness", 0.1f); _mat.SetFloat("_Metallic", 0f); _mat.EnableKeyword("_EMISSION"); _mat.SetColor("_EmissionColor", new Color(0.3f, 0.24f, 0f)); if ((Object)(object)texture != (Object)null) { _mat.SetTexture("_EmissionMap", (Texture)(object)texture); } return _mat; } private static Texture2D GetTexture() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if ((Object)(object)_tex != (Object)null) { return _tex; } _tex = new Texture2D(2, 2, (TextureFormat)4, false); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)LuckyBlockPlugin.Instance).Info.Location), "lucky_block.png"); if (File.Exists(text)) { ImageConversion.LoadImage(_tex, File.ReadAllBytes(text)); ((Texture)_tex).filterMode = (FilterMode)0; ((Texture)_tex).wrapMode = (TextureWrapMode)1; _tex.Apply(); } else { Debug.LogError((object)("[LuckyBlock] Skin texture not found at '" + text + "'. Block will be untextured.")); } return _tex; } } [HarmonyPatch(typeof(SemiFunc), "OnLevelGenDone")] internal static class OnLevelGenDone_Patch { private static void Postfix() { try { if (!((Object)(object)RunManager.instance == (Object)null) && SemiFunc.RunIsLevel() && SemiFunc.IsMasterClientOrSingleplayer()) { LuckyBlockSpawner.SpawnForCurrentLevel("OnLevelGenDone"); } } catch (Exception arg) { Debug.LogError((object)$"[LuckyBlock] Spawn postfix failed (ignored): {arg}"); } } } internal static class LuckyBlockSpawner { private const float MIN_BLOCK_SPACING = 4f; private static bool _spawnedThisLoad; internal static void ResetSpawnFlag() { _spawnedThisLoad = false; } internal static void SpawnForCurrentLevel(string caller = "?") { //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) if (_spawnedThisLoad) { Debug.Log((object)("[LuckyBlock] SpawnForCurrentLevel(" + caller + "): already spawned — skip.")); return; } if ((Object)(object)LuckyBlockManager.Instance == (Object)null) { Debug.LogError((object)"[LuckyBlock] LuckyBlockManager.Instance is null — cannot spawn."); return; } _spawnedThisLoad = true; int currentLevel = GetCurrentLevel(); int blockCount = GetBlockCount(currentLevel); Debug.Log((object)$"[LuckyBlock] Spawning {blockCount} block(s) for level {currentLevel} (caller: {caller})."); List list = new List(); if ((Object)(object)LevelGenerator.Instance != (Object)null) { foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints) { if ((Object)(object)levelPathPoint != (Object)null && !levelPathPoint.Truck && (Object)(object)((Component)levelPathPoint).GetComponentInParent() == (Object)null) { list.Add(levelPathPoint); } } } Debug.Log((object)$"[LuckyBlock] Found {list.Count} interior LevelPathPoint(s)."); if (list.Count == 0) { FallbackSpawn(blockCount); return; } for (int num = list.Count - 1; num > 0; num--) { int index = Random.Range(0, num + 1); LevelPoint value = list[num]; list[num] = list[index]; list[index] = value; } List list2 = new List(); List list3 = new List(); foreach (LevelPoint item in list) { if (list2.Count >= blockCount) { break; } Vector3 val = ((Component)item).transform.position + Vector3.up * 0.5f; bool flag = false; foreach (Vector3 item2 in list3) { if (Vector3.Distance(val, item2) < 4f) { flag = true; break; } } if (!flag) { list2.Add(val); list3.Add(val); } } if (list2.Count < blockCount) { foreach (LevelPoint item3 in list) { if (list2.Count >= blockCount) { break; } Vector3 val2 = ((Component)item3).transform.position + Vector3.up * 0.5f; bool flag2 = false; foreach (Vector3 item4 in list3) { if (Vector3.Distance(val2, item4) < 0.5f) { flag2 = true; break; } } if (!flag2) { list2.Add(val2); list3.Add(val2); } } } LuckyBlockManager.Instance.SpawnBlocks(list2); Debug.Log((object)$"[LuckyBlock] Sent {list2.Count}/{blockCount} block position(s) to manager."); } internal static GameObject SpawnOne(Vector3 pos) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)LuckyBlockManager.Instance == (Object)null) { Debug.LogError((object)"[LuckyBlock] SpawnOne: LuckyBlockManager.Instance is null."); return null; } List list = LuckyBlockManager.Instance.SpawnBlocks(new List { pos }); if (list.Count <= 0) { return null; } return list[0]; } internal static int GetCurrentLevel() { return Mathf.Clamp(SemiFunc.RunGetLevelsCompleted() + 1, 1, 20); } private static int GetBlockCount(int level) { int[] array = new int[4] { 2, 5, 7, 9 }; int num = ((level <= array.Length) ? array[level - 1] : (array[^1] + (level - array.Length) * 2)); return Mathf.Max(1, num + Random.Range(-1, 2)); } private static void FallbackSpawn(int count) { //IL_007b: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) Debug.LogWarning((object)"[LuckyBlock] No interior LevelPathPoints — using fallback ring."); PlayerAvatar instance = PlayerAvatar.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)LuckyBlockManager.Instance == (Object)null)) { List list = new List(count); Vector3 val = default(Vector3); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < count; i++) { float num = (float)i * (360f / (float)count) * ((float)Math.PI / 180f); float num2 = 6f + (float)i * 1.5f; ((Vector3)(ref val))..ctor(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2); Vector3 item = (Physics.Raycast(((Component)instance).transform.position + val + Vector3.up * 5f, Vector3.down, ref val2, 12f) ? (((RaycastHit)(ref val2)).point + Vector3.up * 0.4f) : (((Component)instance).transform.position + val + Vector3.up * 0.4f)); list.Add(item); } LuckyBlockManager.Instance.SpawnBlocks(list); } } } public class LuckyBlockStatusPanel : MonoBehaviour { private const float PANEL_W = 340f; private const float LINE_H = 18f; private const float PAD = 6f; private const float UPDATE_INTERVAL = 0.25f; private readonly List _blocks = new List(); private float _nextUpdate; public static LuckyBlockStatusPanel Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; } } private void Update() { if (Time.time < _nextUpdate) { return; } _nextUpdate = Time.time + 0.25f; _blocks.Clear(); LuckyBlock[] array = Object.FindObjectsOfType(); foreach (LuckyBlock luckyBlock in array) { if ((Object)(object)luckyBlock != (Object)null) { _blocks.Add(((Component)luckyBlock).transform); } } LuckyBlockItem[] array2 = Object.FindObjectsOfType(); foreach (LuckyBlockItem luckyBlockItem in array2) { if ((Object)(object)luckyBlockItem != (Object)null && luckyBlockItem.IsLucky) { _blocks.Add(((Component)luckyBlockItem).transform); } } } private void OnGUI() { //IL_004e: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) float num = 1 + ((_blocks.Count <= 0) ? 1 : _blocks.Count); float num2 = 12f + num * 18f; float num3 = (float)Screen.width - 340f - 10f; float num4 = 10f; GUI.Box(new Rect(num3, num4, 340f, num2), ""); float num5 = num3 + 6f; float num6 = num4 + 6f; float num7 = 328f; GUI.Label(new Rect(num5, num6, num7, 18f), $"[ LUCKY BLOCKS ON MAP: {_blocks.Count} ]"); num6 += 18f; if (_blocks.Count == 0) { GUI.color = new Color(1f, 1f, 1f, 0.4f); GUI.Label(new Rect(num5, num6, num7, 18f), " No blocks in scene."); GUI.color = Color.white; return; } Vector3 val = (((Object)(object)PlayerAvatar.instance != (Object)null) ? ((Component)PlayerAvatar.instance).transform.position : Vector3.zero); for (int i = 0; i < _blocks.Count; i++) { Transform val2 = _blocks[i]; if (!((Object)(object)val2 == (Object)null)) { Vector3 position = val2.position; float num8 = Vector3.Distance(position, val); string arg = ((num8 < 10f) ? "lime" : ((num8 < 25f) ? "yellow" : "red")); GUI.Label(new Rect(num5, num6, num7, 18f), $" #{i + 1} " + $"({position.x:F1}, {position.y:F1}, {position.z:F1}) " + $"{num8:F1} m"); num6 += 18f; } } } } public static class RandomEventRoller { public struct EventLogEntry { public string Label; public string PlayerName; public string Timestamp; public float TimeLogged; } public const float HP_CHANCE = 31f; public const float BOOMBOX_CHANCE = 10f; public const float BOOMBOX_DURATION = 20f; public const float SPAWN_GATE = 85f; public const float MONSTER_CHANCE = 12f; public const float ITEM_CHANCE = 24f; public const float EXPLOSIVE_CHANCE = 19f; public const float EXPLOSIVE_CLUSTER_CHANCE = 6f; public const float VALUABLE_CHANCE = 29f; public const float SPAWN_COOLDOWN = 3f; public const float GLOBAL_SPIKE_COOLDOWN = 2f; public const float SUSTAINED_THRESHOLD = 4f; public const float SUSTAINED_COOLDOWN = 2f; private static bool _initialized; private static FieldInfo _fieldMaxHealth; private static FieldInfo _fieldGodMode; private static MethodInfo _methodHurtOther; private static FieldInfo _fieldTumble; private static FieldInfo _fieldIsTumbling; public static bool AntiSpamEnabled = false; public static readonly List EventLog = new List(); private static AudioClip _boomboxClip; public static void LogEvent(string label, string playerName) { EventLog.Insert(0, new EventLogEntry { Label = label, PlayerName = playerName, Timestamp = DateTime.Now.ToString("HH:mm:ss"), TimeLogged = Time.realtimeSinceStartup }); int num = Mathf.Max(1, LuckyEventLog.MaxEntries); while (EventLog.Count > num) { EventLog.RemoveAt(EventLog.Count - 1); } } public static void Init() { if (!_initialized) { Type? typeFromHandle = typeof(PlayerHealth); _fieldMaxHealth = typeFromHandle.GetField("maxHealth", BindingFlags.Instance | BindingFlags.NonPublic); _fieldGodMode = typeFromHandle.GetField("godMode", BindingFlags.Instance | BindingFlags.NonPublic); _methodHurtOther = typeFromHandle.GetMethod("HurtOther", BindingFlags.Instance | BindingFlags.Public); Type? typeFromHandle2 = typeof(PlayerAvatar); _fieldTumble = typeFromHandle2.GetField("tumble", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _fieldIsTumbling = typeFromHandle2.GetField("isTumbling", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _initialized = true; } } public static void RollOnSpikeStart(PlayerAvatar avatar, PlayerHealth pHealth, float currentDb, float threshold, ref float spawnCooldown, MonoBehaviour context, bool isMasterClient, string playerName = "[?]") { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || (Object)(object)pHealth == (Object)null) { return; } if ((!(_fieldGodMode != null) || !(bool)_fieldGodMode.GetValue(pHealth)) && Random.value * 100f <= 31f) { ApplyDamage(pHealth, currentDb, threshold, playerName); } if (isMasterClient && spawnCooldown <= 0f && Random.value * 100f <= 85f) { Vector3 spawnPositionInFront = SpawnUtils.GetSpawnPositionInFront(avatar); Vector3 spawnPositionOnPlayer = SpawnUtils.GetSpawnPositionOnPlayer(avatar); float num = Random.value * 100f; if (num < 12f) { SpawnUtils.SpawnRandomMonster(spawnPositionInFront, context); LogEvent("Monster: " + SpawnUtils.LastSpawnedName, playerName); } else if (num < 36f) { SpawnUtils.SpawnRandomItem(spawnPositionInFront); LogEvent("Item: " + SpawnUtils.LastSpawnedName, playerName); } else if (num < 55f) { SpawnUtils.SpawnRandomExplosive(spawnPositionOnPlayer); LogEvent("Explosive: " + SpawnUtils.LastSpawnedName, playerName); } else if (num < 61f) { SpawnUtils.SpawnExplosiveCluster(avatar); LogEvent("Cluster ×3", playerName); } else if (num < 90f) { SpawnUtils.SpawnRandomValuable(spawnPositionInFront); LogEvent("Valuable: " + SpawnUtils.LastSpawnedName, playerName); } spawnCooldown = 3f; } } public static void ApplySustainedPenalty(PlayerHealth pHealth, string playerName) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pHealth == (Object)null) && !(_methodHurtOther == null) && (!(_fieldGodMode != null) || !(bool)_fieldGodMode.GetValue(pHealth))) { int num = 100; if (_fieldMaxHealth != null) { num = (int)_fieldMaxHealth.GetValue(pHealth); } int num2 = Mathf.Max(1, Mathf.RoundToInt((float)num * 0.5f)); _methodHurtOther.Invoke(pHealth, new object[5] { num2, Vector3.zero, false, -1, false }); LogEvent($"SUSTAINED -{num2} HP (50%)", playerName); Debug.Log((object)$"[DontScream] Sustained penalty: {num2} HP (50% of {num})"); } } public static void ForceTumble(PlayerAvatar avatar, string playerName = "[DEV]", bool ignoreAlreadyTumbling = false) { if (!((Object)(object)avatar == (Object)null) && !(_fieldTumble == null)) { object? value = _fieldTumble.GetValue(avatar); PlayerTumble val = (PlayerTumble)((value is PlayerTumble) ? value : null); if (!((Object)(object)val == (Object)null) && (ignoreAlreadyTumbling || !(_fieldIsTumbling != null) || !(bool)_fieldIsTumbling.GetValue(avatar))) { val.TumbleSet(true, false); LogEvent("Tumble", playerName); } } } private static AudioClip FindBoomboxClip() { if ((Object)(object)_boomboxClip != (Object)null) { return _boomboxClip; } ValuableBoombox val = Object.FindObjectOfType(); if (val != null && val.soundBoomboxMusic?.Sounds?.Length > 0) { return _boomboxClip = val.soundBoomboxMusic.Sounds[0]; } foreach (PrefabRef allValuable in Valuables.AllValuables) { if (((PrefabRef)(object)allValuable).PrefabName.IndexOf("Boombox", StringComparison.OrdinalIgnoreCase) >= 0) { GameObject prefab = ((PrefabRef)(object)allValuable).Prefab; ValuableBoombox val2 = ((prefab != null) ? prefab.GetComponent() : null); if (val2 != null && val2.soundBoomboxMusic?.Sounds?.Length > 0) { return _boomboxClip = val2.soundBoomboxMusic.Sounds[0]; } } } return null; } public static void ForceBoomboxDance(PlayerAvatar avatar, float duration, MonoBehaviour context, string playerName) { if (!((Object)(object)avatar == (Object)null) && !((Object)(object)avatar.playerExpression == (Object)null)) { context.StartCoroutine(BoomboxDanceCoroutine(avatar, duration)); LogEvent("Boombox Dance", playerName); } } private static IEnumerator BoomboxDanceCoroutine(PlayerAvatar avatar, float duration) { if ((Object)(object)avatar == (Object)null) { yield break; } AudioClip val = FindBoomboxClip(); AudioSource musicSrc = null; if ((Object)(object)val != (Object)null) { GameObject val2 = new GameObject("BoomboxDanceMusic"); val2.transform.SetParent(((Component)avatar).transform); val2.transform.localPosition = Vector3.up * 1.5f; musicSrc = val2.AddComponent(); musicSrc.clip = val; musicSrc.loop = true; musicSrc.spatialBlend = 1f; musicSrc.minDistance = 2f; musicSrc.maxDistance = 20f; musicSrc.volume = 1.2f; musicSrc.Play(); } float elapsed = 0f; while (elapsed < duration && !((Object)(object)avatar == (Object)null) && !((Object)(object)avatar.playerExpression == (Object)null)) { float num = Mathf.Sin(Time.time * 15f); float num2 = num * 25f; avatar.playerExpression.OverrideExpressionSet(4, 100f); if ((Object)(object)avatar.playerAvatarVisuals != (Object)null) { avatar.playerAvatarVisuals.HeadTiltOverride(num2 * 0.5f); } if ((Object)(object)avatar == (Object)(object)PlayerAvatar.instance) { if ((Object)(object)CameraAim.Instance != (Object)null) { CameraAim.Instance.AdditiveAimY(num * 0.5f); } if ((Object)(object)PlayerExpressionsUI.instance?.playerExpression != (Object)null) { PlayerExpressionsUI.instance.playerExpression.OverrideExpressionSet(4, 100f); } if ((Object)(object)PlayerExpressionsUI.instance?.playerAvatarVisuals != (Object)null) { PlayerExpressionsUI.instance.playerAvatarVisuals.HeadTiltOverride(num2 * 0.5f); } } elapsed += Time.deltaTime; yield return null; } if ((Object)(object)musicSrc != (Object)null) { Object.Destroy((Object)(object)((Component)musicSrc).gameObject); } } public static void ForceHPLoss(PlayerHealth pHealth, string playerName = "[DEV]") { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pHealth == (Object)null) && !(_methodHurtOther == null)) { int num = 100; if (_fieldMaxHealth != null) { num = (int)_fieldMaxHealth.GetValue(pHealth); } int num2 = Mathf.Max(1, Mathf.RoundToInt((float)num * 0.1f)); _methodHurtOther.Invoke(pHealth, new object[5] { num2, Vector3.zero, false, -1, false }); LogEvent($"[DEV] HP -{num2}", playerName); } } public static void ForceTumbleLock(PlayerAvatar avatar, float duration = 3f, string playerName = "[LuckyBlock]") { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || _fieldTumble == null) { return; } object? value = _fieldTumble.GetValue(avatar); PlayerTumble val = (PlayerTumble)((value is PlayerTumble) ? value : null); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)avatar.playerHealth != (Object)null && _methodHurtOther != null) { _methodHurtOther.Invoke(avatar.playerHealth, new object[5] { 1, Vector3.zero, false, -1, false }); } val.TumbleRequest(true, false); val.TumbleOverrideTime(duration); LogEvent($"Tumble lock {duration:F0}s", playerName); } } private static void ApplyDamage(PlayerHealth pHealth, float currentDb, float threshold, string playerName) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pHealth == (Object)null) && !(_methodHurtOther == null)) { float num = Mathf.Clamp((Mathf.Ceil(currentDb) - threshold) * 11f, 0f, 100f) / 100f; int num2 = 100; if (_fieldMaxHealth != null) { num2 = (int)_fieldMaxHealth.GetValue(pHealth); } int num3 = Mathf.Max(1, Mathf.RoundToInt((float)num2 * num)); _methodHurtOther.Invoke(pHealth, new object[5] { num3, Vector3.zero, false, -1, false }); LogEvent($"HP -{num3} ({num * 100f:F0}%) | {currentDb:F1} dB", playerName); Debug.Log((object)$"[DontScream] Spike HP: {num3} HP ({num * 100f:F0}%) | db={currentDb:F1} threshold={threshold:F1}"); } } public static void KillPlayer(PlayerHealth pHealth, string playerName) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)pHealth == (Object)null) && !(_methodHurtOther == null) && (!(_fieldGodMode != null) || !(bool)_fieldGodMode.GetValue(pHealth))) { _methodHurtOther.Invoke(pHealth, new object[5] { 99999, Vector3.zero, false, -1, false }); LogEvent("ANTI-SPAM: KILLED", playerName); Debug.Log((object)"[DontScream] Anti-spam kill applied."); } } } internal static class SpawnUtils { internal static bool _spawning = false; internal static string LastStatus = "idle"; internal static string LastSpawnedName = ""; private static readonly string[] LuckyValuableTerms = new string[4] { "Arctic Sample Six Pack", "Sample Six Pack", "Six Pack", "SixPack" }; private static PrefabRef _luckyValuable; private static readonly string[] ValuableSearchTerms = new string[3] { "Boombox", "Museum Boombox", "Museum" }; private static readonly string[] ItemSearchTerms = new string[3] { "Gun Laser", "Laser Gun", "Photon Blaster" }; private static readonly string[] EnemySearchTerms = new string[1] { "Robe" }; private static List _potions; internal const string PrivateBaseItem = "Drone Battery"; private static Item _luckyItem; internal static PrefabRef GetLuckyValuable() { if (_luckyValuable != null) { return _luckyValuable; } string[] luckyValuableTerms = LuckyValuableTerms; foreach (string term in luckyValuableTerms) { PrefabRef val = SearchPrefabList(Valuables.AllValuables, term); if (val != null) { _luckyValuable = val; Debug.Log((object)("[LuckyBlock] Using valuable '" + ((PrefabRef)(object)val).PrefabName + "' for lucky blocks.")); return val; } } Debug.LogWarning((object)"[LuckyBlock] Lucky valuable not found. Candidates with 'Sample'/'Six':"); foreach (PrefabRef allValuable in Valuables.AllValuables) { string prefabName = ((PrefabRef)(object)allValuable).PrefabName; if (prefabName.IndexOf("Sample", StringComparison.OrdinalIgnoreCase) >= 0 || prefabName.IndexOf("Six", StringComparison.OrdinalIgnoreCase) >= 0) { Debug.LogWarning((object)("[LuckyBlock] candidate: " + prefabName)); } } return null; } internal static GameObject SpawnLuckyValuable(Vector3 pos) { //IL_0027: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) PrefabRef luckyValuable = GetLuckyValuable(); if (luckyValuable == null) { return null; } GameObject result = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate(((PrefabRef)(object)luckyValuable).Prefab, pos, Quaternion.identity) : Valuables.SpawnValuable(luckyValuable, pos, Quaternion.identity)); LastSpawnedName = ((PrefabRef)(object)luckyValuable).PrefabName; return result; } internal static Vector3 GetSpawnPositionOnPlayer(PlayerAvatar avatar) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0009: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null) { return Vector3.zero; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)avatar).transform.position + Vector3.up * 2f, Vector3.down, ref val, 5f)) { return ((RaycastHit)(ref val)).point + Vector3.up * 0.15f; } return ((Component)avatar).transform.position + Vector3.up * 0.5f; } internal static Vector3 GetSpawnPositionInFront(PlayerAvatar avatar, float dist = 3f) { //IL_0009: 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_0022: 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_003b: 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_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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d2: 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_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_00ed: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null) { return Vector3.zero; } Vector3 val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.forward : ((Component)avatar).transform.forward); Vector3 forward = default(Vector3); ((Vector3)(ref forward))..ctor(val.x, 0f, val.z); if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = ((Component)avatar).transform.forward; } ((Vector3)(ref forward)).Normalize(); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(((Component)avatar).transform.position + forward * dist + Vector3.up * 2f, Vector3.down, ref val2, 5f)) { return ((RaycastHit)(ref val2)).point + Vector3.up * 0.15f; } return ((Component)avatar).transform.position + forward * dist + Vector3.up * 0.5f; } internal static void SpawnRandomMonster(Vector3 pos, MonoBehaviour context) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (EnemySetup allEnemy in Enemies.AllEnemies) { if (!((Object)allEnemy).name.StartsWith("Enemy Group")) { list.Add(allEnemy); } } if (list.Count == 0) { LastStatus = "SpawnRandomMonster: no enemies available"; return; } EnemySetup val = list[Random.Range(0, list.Count)]; LastSpawnedName = ((Object)val).name.Replace("Enemy - ", "").Trim(); LastStatus = $"Random monster: {((Object)val).name} at {pos:F0}"; Debug.Log((object)("[SpawnUtils] " + LastStatus)); SpawnSpecificEnemy(val, pos, context); } internal static void SpawnRandomItem(Vector3 pos) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (Item allItem in Items.AllItems) { string text = ((Object)allItem).name.ToLowerInvariant(); if (!text.Contains("grenade") && !text.Contains("mine")) { list.Add(allItem); } } if (list.Count == 0) { LastStatus = "SpawnRandomItem: no items available"; return; } Item val = list[Random.Range(0, list.Count)]; LastSpawnedName = ((Object)val).name.Replace("Item ", "").Trim(); LastStatus = $"Random item: {((Object)val).name} at {pos:F0}"; Debug.Log((object)("[SpawnUtils] " + LastStatus)); SpawnSpecificItem(val, pos); } internal static void SpawnRandomExplosive(Vector3 pos) { //IL_00d8: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (Item allItem in Items.AllItems) { string text = ((Object)allItem).name.ToLowerInvariant(); if ((text.Contains("grenade") || text.Contains("bomb")) && !text.Contains("mine")) { list.Add(allItem); } } if (list.Count == 0) { LastStatus = "SpawnRandomExplosive: no grenade/bomb in item list"; Debug.LogWarning((object)("[SpawnUtils] " + LastStatus)); return; } Item val = list[Random.Range(0, list.Count)]; LastSpawnedName = ((Object)val).name.Replace("Item ", "").Trim(); LastStatus = $"Explosive: {((Object)val).name} at {pos:F0}"; Debug.Log((object)("[SpawnUtils] " + LastStatus)); GameObject val2 = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate(((PrefabRef)(object)val.prefab).Prefab, pos, Quaternion.identity) : Items.SpawnItem(val, pos, Quaternion.identity)); if (!((Object)(object)val2 == (Object)null)) { ActivateIfExplosive(val2); ItemGrenade componentInChildren = val2.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.tickTime = 0.5f; } } } internal static void SpawnPotion(Vector3 groundPos) { //IL_00a1: 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_00ac: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (_potions == null) { _potions = new List(); foreach (PrefabRef allValuable in Valuables.AllValuables) { if (((PrefabRef)(object)allValuable).PrefabName.IndexOf("potion", StringComparison.OrdinalIgnoreCase) >= 0) { _potions.Add(allValuable); } } } if (_potions.Count == 0) { LastStatus = "SpawnPotion: no valuable containing 'potion' found"; Debug.LogWarning((object)("[SpawnUtils] " + LastStatus)); return; } PrefabRef val = _potions[Random.Range(0, _potions.Count)]; Vector3 val2 = groundPos + Vector3.up * 1.2f; GameObject val3 = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate(((PrefabRef)(object)val).Prefab, val2, Quaternion.identity) : Valuables.SpawnValuable(val, val2, Quaternion.identity)); LastSpawnedName = ((PrefabRef)(object)val).PrefabName.Replace("Valuable ", "").Trim(); LastStatus = "Potion dropped: " + ((PrefabRef)(object)val).PrefabName; if ((Object)(object)val3 != (Object)null) { LuckyBlockPlugin.StartManagedCoroutine(BreakPotionAfter(val3, 0.6f)); } } private static IEnumerator BreakPotionAfter(GameObject potion, float delay) { yield return (object)new WaitForSeconds(delay); if (!((Object)(object)potion == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer()) { PhysGrabObjectImpactDetector componentInChildren = potion.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.BreakHeavy(potion.transform.position, true, 0f); } else { Object.Destroy((Object)(object)potion); } } } internal static Item GetLuckyItem() { if ((Object)(object)_luckyItem != (Object)null) { return _luckyItem; } foreach (Item allItem in Items.AllItems) { if (!((Object)(object)allItem == (Object)null) && ((allItem.itemName ?? "").IndexOf("Drone Battery", StringComparison.OrdinalIgnoreCase) >= 0 || (((Object)allItem).name ?? "").IndexOf("Drone Battery", StringComparison.OrdinalIgnoreCase) >= 0)) { _luckyItem = allItem; Debug.Log((object)("[LuckyBlock] Private edition base item: '" + allItem.itemName + "' (asset '" + ((Object)allItem).name + "').")); return allItem; } } return null; } internal static GameObject SpawnLuckyItem(Vector3 pos) { //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_0019: 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) Item luckyItem = GetLuckyItem(); if ((Object)(object)luckyItem == (Object)null) { return null; } GameObject result = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate(((PrefabRef)(object)luckyItem.prefab).Prefab, pos, Quaternion.identity) : Items.SpawnItem(luckyItem, pos, Quaternion.identity)); LastSpawnedName = luckyItem.itemName; return result; } internal static List GetFloorRing(Vector3 centre, int count, float radius) { //IL_0020: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_005a: 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_006e: 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) List list = new List(count); RaycastHit val = default(RaycastHit); for (int i = 0; i < count; i++) { float num = (float)i * (360f / (float)count) * ((float)Math.PI / 180f); Vector3 item = ((!Physics.Raycast(centre + new Vector3(Mathf.Cos(num) * radius, 2f, Mathf.Sin(num) * radius), Vector3.down, ref val, 6f)) ? (centre + new Vector3(Mathf.Cos(num) * radius, 0.5f, Mathf.Sin(num) * radius)) : (((RaycastHit)(ref val)).point + Vector3.up * 0.5f)); list.Add(item); } return list; } internal static void SpawnExplosiveCluster(PlayerAvatar avatar) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)avatar == (Object)null)) { Vector3 val = default(Vector3); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < 3; i++) { float num = (float)i * 120f * ((float)Math.PI / 180f); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * 2f, 2f, Mathf.Sin(num) * 2f); Vector3 pos = ((!Physics.Raycast(((Component)avatar).transform.position + val, Vector3.down, ref val2, 5f)) ? (((Component)avatar).transform.position + new Vector3(Mathf.Cos(num) * 2f, 0.5f, Mathf.Sin(num) * 2f)) : (((RaycastHit)(ref val2)).point + Vector3.up * 0.15f)); SpawnRandomExplosive(pos); } LastStatus = "Explosive cluster x3 around " + ((Object)((Component)avatar).gameObject).name; Debug.Log((object)("[SpawnUtils] " + LastStatus)); } } internal static void SpawnLargeExplosiveCluster(Vector3 centre) { //IL_003a: 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_0041: 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_0072: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_009b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < 5; i++) { float num = (float)i * 72f * ((float)Math.PI / 180f); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * 2.4f, 2f, Mathf.Sin(num) * 2.4f); Vector3 pos = ((!Physics.Raycast(centre + val, Vector3.down, ref val2, 6f)) ? (centre + new Vector3(Mathf.Cos(num) * 2.4f, 0.5f, Mathf.Sin(num) * 2.4f)) : (((RaycastHit)(ref val2)).point + Vector3.up * 0.15f)); SpawnRandomExplosive(pos); } LastStatus = $"Large explosive cluster x5 at {centre:F0}"; Debug.Log((object)("[SpawnUtils] " + LastStatus)); } internal static void SpawnRandomValuable(Vector3 pos) { //IL_005b: 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) List list = new List(Valuables.AllValuables); if (list.Count == 0) { LastStatus = "SpawnRandomValuable: no valuables available"; return; } PrefabRef val = list[Random.Range(0, list.Count)]; LastSpawnedName = ((PrefabRef)(object)val).PrefabName.Replace("Valuable ", "").Trim(); LastStatus = $"Random valuable: {((PrefabRef)(object)val).PrefabName} at {pos:F0}"; Debug.Log((object)("[SpawnUtils] " + LastStatus)); SpawnSpecificValuable(val, pos); } internal static void SpawnSpecificEnemy(EnemySetup setup, Vector3 pos, MonoBehaviour context) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EnemyDirector.instance == (Object)null) { LastStatus = "SpawnSpecificEnemy: EnemyDirector null"; } else if (_spawning) { LastStatus = "SpawnSpecificEnemy: already spawning"; } else { ((MonoBehaviour)(((Object)(object)EnemyDirector.instance != (Object)null) ? ((object)EnemyDirector.instance) : ((object)context))).StartCoroutine(SpawnEnemyCoroutine(setup, pos)); } } internal static void SpawnSpecificItem(Item item, Vector3 pos) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { LastStatus = "SpawnSpecificItem: item null"; return; } GameObject val; if (SemiFunc.IsMultiplayer()) { val = Items.SpawnItem(item, pos, Quaternion.identity); LastStatus = $"Item '{((Object)item).name}' spawned at {pos:F0} (MP)"; } else { val = Object.Instantiate(((PrefabRef)(object)item.prefab).Prefab, pos, Quaternion.identity); LastStatus = $"Item '{((Object)item).name}' spawned at {pos:F0} (SP)"; } Debug.Log((object)("[SpawnUtils] " + LastStatus)); if ((Object)(object)val != (Object)null) { ItemBattery componentInParent = val.GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && componentInParent.batteryBars < 6) { componentInParent.SetBatteryLife(100); } ActivateIfExplosive(val); } } internal static void SpawnSpecificValuable(PrefabRef prefab, Vector3 pos) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) if (prefab == null) { LastStatus = "SpawnSpecificValuable: prefab null"; return; } if (SemiFunc.IsMultiplayer()) { Valuables.SpawnValuable(prefab, pos, Quaternion.identity); LastStatus = $"Valuable '{((PrefabRef)(object)prefab).PrefabName}' spawned at {pos:F0} (MP)"; } else { Object.Instantiate(((PrefabRef)(object)prefab).Prefab, pos, Quaternion.identity); LastStatus = $"Valuable '{((PrefabRef)(object)prefab).PrefabName}' spawned at {pos:F0} (SP)"; } Debug.Log((object)("[SpawnUtils] " + LastStatus)); } internal static void SpawnValuableByName(string _unused) { //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_0088: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList allValuables = Valuables.AllValuables; PrefabRef val = null; string text = null; string[] valuableSearchTerms = ValuableSearchTerms; foreach (string text2 in valuableSearchTerms) { val = SearchPrefabList(allValuables, text2); if (val != null) { text = text2; break; } } if (val == null) { LastStatus = "Valuable not found. Tried: [" + string.Join(", ", ValuableSearchTerms) + "]"; Debug.LogWarning((object)("[SpawnUtils] " + LastStatus)); return; } Vector3 spawnPositionInFront = GetSpawnPositionInFront(PlayerAvatar.instance); SpawnSpecificValuable(val, spawnPositionInFront); LastStatus = "[F9] Valuable '" + ((PrefabRef)(object)val).PrefabName + "' via '" + text + "'"; } internal static void SpawnItemByName(string _unused) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) IReadOnlyList allItems = Items.AllItems; Item val = null; string text = null; string[] itemSearchTerms = ItemSearchTerms; foreach (string text2 in itemSearchTerms) { foreach (Item item in allItems) { if (((Object)item).name.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0) { val = item; text = text2; break; } } if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { LastStatus = "Item not found. Tried: [" + string.Join(", ", ItemSearchTerms) + "]"; Debug.LogWarning((object)("[SpawnUtils] " + LastStatus)); return; } Vector3 spawnPositionInFront = GetSpawnPositionInFront(PlayerAvatar.instance); SpawnSpecificItem(val, spawnPositionInFront); LastStatus = "[F10] Item '" + ((Object)val).name + "' via '" + text + "'"; } internal static void SpawnEnemyByName(string _unused) { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EnemyDirector.instance == (Object)null) { LastStatus = "Enemy: EnemyDirector.instance null"; return; } if (_spawning) { LastStatus = "Enemy: already spawning, wait"; return; } IReadOnlyList allEnemies = Enemies.AllEnemies; EnemySetup val = null; string text = null; string[] enemySearchTerms = EnemySearchTerms; foreach (string text2 in enemySearchTerms) { foreach (EnemySetup item in allEnemies) { if (((Object)item).name.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0 && !((Object)item).name.StartsWith("Enemy Group")) { val = item; text = text2; break; } } if ((Object)(object)val != (Object)null) { break; } } if ((Object)(object)val == (Object)null) { LastStatus = "Enemy not found. Tried: [" + string.Join(", ", EnemySearchTerms) + "]"; Debug.LogWarning((object)("[SpawnUtils] " + LastStatus)); return; } LastStatus = "[F12] Enemy '" + ((Object)val).name + "' via '" + text + "', spawning in 3s..."; Debug.Log((object)("[SpawnUtils] " + LastStatus)); Vector3 spawnPositionInFront = GetSpawnPositionInFront(PlayerAvatar.instance); SpawnSpecificEnemy(val, spawnPositionInFront, (MonoBehaviour)(object)EnemyDirector.instance); } private static IEnumerator SpawnEnemyCoroutine(EnemySetup setup, Vector3 pos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForSeconds(3f); if (SemiFunc.IsMultiplayer()) { Enemies.SpawnEnemy(setup, pos, Quaternion.identity, false); LastStatus = $"Enemy '{((Object)setup).name}' spawned at {pos:F0} (MP)"; Debug.Log((object)("[SpawnUtils] " + LastStatus)); yield break; } _spawning = true; typeof(LevelGenerator).GetField("EnemiesSpawned", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(LevelGenerator.Instance, -1); GameObject val = Object.Instantiate(((PrefabRef)(object)setup.spawnObjects[0]).Prefab, pos, Quaternion.identity); EnemyParent component = val.GetComponent(); if ((Object)(object)component != (Object)null) { typeof(EnemyParent).GetField("SetupDone", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(component, true); Enemy componentInChildren = val.GetComponentInChildren(); if (componentInChildren != null) { componentInChildren.EnemyTeleported(pos); } EnemyDirector.instance.FirstSpawnPointAdd(component); EnemyDirector.instance.enemiesSpawned.Add(component); foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { if (componentInChildren != null) { componentInChildren.PlayerAdded(item.photonView.ViewID); } } LastStatus = $"Enemy '{((Object)setup).name}' spawned at {pos:F0} (SP)"; } else { LastStatus = "Enemy '" + ((Object)setup).name + "': EnemyParent component missing"; } Debug.Log((object)("[SpawnUtils] " + LastStatus)); _spawning = false; } private static void ActivateIfExplosive(GameObject spawned) { if ((Object)(object)spawned == (Object)null) { return; } ItemGrenade componentInChildren = spawned.GetComponentInChildren(); ItemMine componentInChildren2 = spawned.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null && (Object)(object)componentInChildren2 == (Object)null) { return; } ItemToggle componentInChildren3 = spawned.GetComponentInChildren(); if (!((Object)(object)componentInChildren3 == (Object)null)) { if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.isSpawnedGrenade = true; } componentInChildren3.toggleState = true; } } private static PrefabRef SearchPrefabList(IEnumerable list, string term) { foreach (PrefabRef item in list) { if (((PrefabRef)(object)item).PrefabName.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0) { return item; } } return null; } } [HarmonyPatch(typeof(EnemyParent), "Despawn")] internal class EnemyParentDespawnPatch { private static bool Prefix() { return !SpawnUtils._spawning; } }