using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("REPO_lucky_block")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+17f886403ddca51826ca4456ebf9048ef499731f")] [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 = false; private int _selectedIndex = 0; private Page _page = Page.Main; 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 static readonly string[] EVENT_LABELS = new string[11] { "Valuable (random, near you)", "Item (random, near you)", "Monster (random, near you)", "Potion (drops + breaks on floor)", "Lucky Cluster ×3 (3 new lucky blocks)", "Cluster ×3 (3 bombs around player)", "Cluster ×5 (5 bombs around block)", "Explosive at Feet (1 bomb drops at feet)", "HP Loss (−10% max HP)", "Tumble (knock you over)", "Full Roll (random spin, all effects)" }; private const int EVENT_COUNT = 11; private const int MAIN_ITEMS = 5; public static DebugMenu 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() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) 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 => 12, 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_001f: 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) if (p == Page.BlocksOnMap) { RefreshBlockCache(); } _page = p; _selectedIndex = 0; _scroll = Vector2.zero; ResetTimers(); } private void SyncScroll() { if (_page == Page.Main) { return; } float num = 68f; float num2 = 420f - num - 8f - 24f; float num3 = (float)_selectedIndex * 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 + 1) * 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)PlayerAvatar.instance == (Object)null)) { Vector3 spawnPositionInFront = SpawnUtils.GetSpawnPositionInFront(PlayerAvatar.instance, 2.5f); LuckyBlockSpawner.SpawnOne(spawnPositionInFront); } } 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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) PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { return; } Vector3 spawnPositionInFront = SpawnUtils.GetSpawnPositionInFront(instance, 2.5f); bool flag = SemiFunc.IsMasterClientOrSingleplayer(); switch (eventIdx) { case 0: if (flag) { SpawnUtils.SpawnRandomValuable(spawnPositionInFront); _lastEventMsg = "Valuable: " + SpawnUtils.LastSpawnedName; } break; case 1: if (flag) { SpawnUtils.SpawnRandomItem(spawnPositionInFront); _lastEventMsg = "Item: " + SpawnUtils.LastSpawnedName; } break; case 2: if (flag) { SpawnUtils.SpawnRandomMonster(spawnPositionInFront, (MonoBehaviour)(object)this); _lastEventMsg = "Monster: " + SpawnUtils.LastSpawnedName; } break; case 3: if (flag) { SpawnUtils.SpawnPotion(spawnPositionInFront); _lastEventMsg = "Potion: " + SpawnUtils.LastSpawnedName; } break; case 4: if (flag) { LuckyBlockManager.Instance?.SpawnBlocks(SpawnUtils.GetFloorRing(spawnPositionInFront, 3, 2f)); _lastEventMsg = "Lucky Cluster ×3 spawned"; } break; case 5: if (flag) { SpawnUtils.SpawnExplosiveCluster(instance); _lastEventMsg = "Small Cluster ×3 around player"; } break; case 6: if (flag) { SpawnUtils.SpawnLargeExplosiveCluster(spawnPositionInFront); _lastEventMsg = "Large Cluster ×5 around block"; } break; case 7: if (flag) { SpawnUtils.SpawnRandomExplosive(SpawnUtils.GetSpawnPositionOnPlayer(instance)); _lastEventMsg = "Explosive at feet: " + SpawnUtils.LastSpawnedName; } break; case 8: if ((Object)(object)instance.playerHealth != (Object)null) { RandomEventRoller.ForceHPLoss(instance.playerHealth, "[Debug]"); _lastEventMsg = "HP Loss –10% fired"; } break; case 9: RandomEventRoller.ForceTumble(instance, "[Debug]", ignoreAlreadyTumbling: true); _lastEventMsg = "Tumble fired"; break; case 10: LuckyBlockEvents.Roll(instance, ((Component)instance).transform.position); _lastEventMsg = "Full Roll fired"; break; } } private void ForceOpenBlock(LuckyBlock b) { typeof(LuckyBlock).GetMethod("Open", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(b, null); } private LuckyBlock FindNearestBlock() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) 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_003a: 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_00d3: 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) if (_open) { float num = 10f; float num2 = (float)Screen.height - 420f - 10f; GUI.Box(new Rect(num, num2, 360f, 420f), ""); float num3 = num + 8f; float cy = num2 + 8f; float num4 = 344f; switch (_page) { case Page.Main: DrawMain(num3, cy, num4); break; case Page.ForceEvent: DrawForceEvent(num3, cy, num4); break; case Page.BlocksOnMap: DrawBlocksOnMap(num3, cy, num4); break; } float num5 = num2 + 420f - 8f - 18f; GUI.color = COL_DIM; GUI.Label(new Rect(num3, num5, num4, 18f), "↑↓ navigate (wrap+hold) ENTER select (hold) F6 close"); GUI.color = Color.white; } } private void DrawMain(float cx, float cy, float cw) { //IL_0001: 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_0024: 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_006b: 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_00e9: 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); } private void DrawForceEvent(float cx, float cy, float cw) { //IL_0001: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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; for (int i = 0; i < 11; i++) { int num = i + 1; bool flag = _selectedIndex == num; Color val = (Color)((i <= 1) ? COL_GREEN : ((i == 2) ? COL_RED : ((i == 3) ? COL_GREEN : ((i == 4) ? COL_GOLD : ((i <= 7) ? new Color(1f, 0.55f, 0f) : ((i <= 9) ? COL_RED : COL_GOLD)))))); GUI.color = (flag ? COL_SELECTED : val); GUI.Label(new Rect(cx, cy, cw, 22f), (flag ? "► " : " ") + EVENT_LABELS[i]); GUI.color = Color.white; cy += 26f; } } private void DrawBlocksOnMap(float cx, float cy, float cw) { //IL_0001: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0249: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) 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; } } 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_007b: 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_0089: 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 { public const float SPAWN_VALUABLE = 26f; public const float SPAWN_ITEM = 26f; public const float SPAWN_MONSTER = 9f; public const float SPAWN_POTION = 8f; public const float SPAWN_LUCKY_CLUSTER = 10f; public const float SPAWN_CLUSTER_SMALL = 8f; public const float SPAWN_CLUSTER_LARGE = 5f; public const float SPAWN_SINGLE_EXPLOSIVE = 8f; public static void TriggerSpecific(int eventIdx, PlayerAvatar player, Vector3 blockPos) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00dd: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } if ((Object)(object)player == (Object)null) { player = PlayerAvatar.instance; } if (!((Object)(object)player == (Object)null)) { if (blockPos == Vector3.zero) { blockPos = ((Component)player).transform.position; } Vector3 spawnPositionInFront = SpawnUtils.GetSpawnPositionInFront(player, 2.5f); switch (eventIdx) { case 0: SpawnUtils.SpawnRandomValuable(spawnPositionInFront); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Valuable: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); break; case 1: SpawnUtils.SpawnRandomItem(spawnPositionInFront); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Item: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); break; case 2: SpawnUtils.SpawnRandomMonster(spawnPositionInFront, null); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Monster: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); break; case 3: SpawnUtils.SpawnPotion(spawnPositionInFront); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Potion: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); break; case 4: LuckyBlockManager.Instance?.SpawnBlocks(SpawnUtils.GetFloorRing(blockPos, 3, 2f)); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Lucky Cluster ×3", "[LuckyBlock]"); break; case 5: SpawnUtils.SpawnExplosiveCluster(player); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Small Cluster ×3", "[LuckyBlock]"); break; case 6: SpawnUtils.SpawnLargeExplosiveCluster(blockPos); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Large Cluster ×5", "[LuckyBlock]"); break; case 7: SpawnUtils.SpawnRandomExplosive(SpawnUtils.GetSpawnPositionOnPlayer(player)); RandomEventRoller.LogEvent("LuckyBlock [Voice] → Explosive: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); break; default: Roll(player, blockPos); break; } } } public static void Roll(PlayerAvatar opener, Vector3 blockPos) { //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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)opener == (Object)null) { opener = PlayerAvatar.instance; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } PlayerAvatar val = opener ?? PlayerAvatar.instance; if (!((Object)(object)val == (Object)null)) { if (blockPos == Vector3.zero) { blockPos = ((Component)val).transform.position; } Vector3 spawnPositionInFront = SpawnUtils.GetSpawnPositionInFront(val, 2.5f); float num = Random.value * 100f; float num2 = 0f; if (num < (num2 += 26f)) { SpawnUtils.SpawnRandomValuable(spawnPositionInFront); RandomEventRoller.LogEvent("LuckyBlock → Valuable: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); } else if (num < (num2 += 26f)) { SpawnUtils.SpawnRandomItem(spawnPositionInFront); RandomEventRoller.LogEvent("LuckyBlock → Item: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); } else if (num < (num2 += 9f)) { SpawnUtils.SpawnRandomMonster(spawnPositionInFront, null); RandomEventRoller.LogEvent("LuckyBlock → Monster: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); } else if (num < (num2 += 8f)) { SpawnUtils.SpawnPotion(spawnPositionInFront); RandomEventRoller.LogEvent("LuckyBlock → Potion (breaks on floor): " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); } else if (num < (num2 += 10f)) { List floorRing = SpawnUtils.GetFloorRing(blockPos, 3, 2f); LuckyBlockManager.Instance?.SpawnBlocks(floorRing); RandomEventRoller.LogEvent("LuckyBlock → Lucky Cluster ×3 (3 new lucky blocks)", "[LuckyBlock]"); } else if (num < (num2 += 8f)) { SpawnUtils.SpawnExplosiveCluster(val); RandomEventRoller.LogEvent("LuckyBlock → Small Cluster ×3 (around player)", "[LuckyBlock]"); } else if (num < (num2 += 5f)) { SpawnUtils.SpawnLargeExplosiveCluster(blockPos); RandomEventRoller.LogEvent("LuckyBlock → Large Cluster ×5 (around block)", "[LuckyBlock]"); } else { Vector3 spawnPositionOnPlayer = SpawnUtils.GetSpawnPositionOnPlayer(val); SpawnUtils.SpawnRandomExplosive(spawnPositionOnPlayer); RandomEventRoller.LogEvent("LuckyBlock → Explosive at feet: " + SpawnUtils.LastSpawnedName, "[LuckyBlock]"); } } } } 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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; } return ModeManager.IsPrivate ? SpawnPrivate(positions, list) : SpawnPublic(positions, list); } private List SpawnPrivate(List positions, List spawned) { //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_0036: 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) 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) 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 => (EditionConfig != null) ? EditionConfig.Value : LuckyBlockMode.PublicServer; 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.0.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; } private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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); 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)."); 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 pv = PhotonView.Find(viewID); if ((Object)(object)pv != (Object)null) { LuckyBlockSkin.Apply(((Component)pv).gameObject); break; } yield return null; } } 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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)(object)val); } if ((Object)(object)Object.FindObjectOfType() == (Object)null) { GameObject val2 = new GameObject("LuckyBlock_DebugMenu"); val2.AddComponent(); Object.DontDestroyOnLoad((Object)(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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_008d: 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_00da: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) 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)); MeshFilter val3 = val2.AddComponent(); val3.sharedMesh = cubeMesh; MeshRenderer val4 = val2.AddComponent(); ((Renderer)val4).sharedMaterial = material; } } private static Bounds ComputeBounds(GameObject go) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) 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 val = GameObject.CreatePrimitive((PrimitiveType)3); _cubeMesh = val.GetComponent().sharedMesh; Object.Destroy((Object)(object)val); return _cubeMesh; } private static Material GetMaterial() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00b2: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if ((Object)(object)_tex != (Object)null) { return _tex; } _tex = new Texture2D(2, 2, (TextureFormat)4, false); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)LuckyBlockPlugin.Instance).Info.Location); string text = Path.Combine(directoryName, "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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: 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_002b: 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 }); return (list.Count > 0) ? list[0] : null; } 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e2: 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_0107: 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 val3 = 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 val2 = ((Component)instance).transform.position + val + Vector3.up * 5f; Vector3 item = (Physics.Raycast(val2, Vector3.down, ref val3, 12f) ? (((RaycastHit)(ref val3)).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 = 0f; 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_0050: 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_00dc: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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 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") }); if (EventLog.Count > 3) { EventLog.RemoveAt(3); } } 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_009c: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_009e: 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 clip = FindBoomboxClip(); AudioSource musicSrc = null; if ((Object)(object)clip != (Object)null) { GameObject musicObj = new GameObject("BoomboxDanceMusic"); musicObj.transform.SetParent(((Component)avatar).transform); musicObj.transform.localPosition = Vector3.up * 1.5f; musicSrc = musicObj.AddComponent(); musicSrc.clip = clip; 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 sine = Mathf.Sin(Time.time * 15f); float headTilt = sine * 25f; avatar.playerExpression.OverrideExpressionSet(4, 100f); if ((Object)(object)avatar.playerAvatarVisuals != (Object)null) { avatar.playerAvatarVisuals.HeadTiltOverride(headTilt * 0.5f); } if ((Object)(object)avatar == (Object)(object)PlayerAvatar.instance) { if ((Object)(object)CameraAim.Instance != (Object)null) { CameraAim.Instance.AdditiveAimY(sine * 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(headTilt * 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_006f: 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_007e: 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_0091: 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_0064: 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_0033: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null) { return Vector3.zero; } Vector3 val = ((Component)avatar).transform.position + Vector3.up * 2f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, 5f)) { return ((RaycastHit)(ref val2)).point + Vector3.up * 0.15f; } return ((Component)avatar).transform.position + Vector3.up * 0.5f; } internal static Vector3 GetSpawnPositionInFront(PlayerAvatar avatar, float dist = 3f) { //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0046: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) 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(); Vector3 val2 = ((Component)avatar).transform.position + forward * dist + Vector3.up * 2f; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, Vector3.down, ref val3, 5f)) { return ((RaycastHit)(ref val3)).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_00ab: 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) 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_00c7: 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) 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) 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_00c7: 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_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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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 impact = potion.GetComponentInChildren(); if ((Object)(object)impact != (Object)null) { impact.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)) { continue; } _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_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_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 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_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_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) //IL_0044: 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_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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) List list = new List(count); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < count; i++) { float num = (float)i * (360f / (float)count) * ((float)Math.PI / 180f); Vector3 val = centre + new Vector3(Mathf.Cos(num) * radius, 2f, Mathf.Sin(num) * radius); Vector3 item = ((!Physics.Raycast(val, Vector3.down, ref val2, 6f)) ? (centre + new Vector3(Mathf.Cos(num) * radius, 0.5f, Mathf.Sin(num) * radius)) : (((RaycastHit)(ref val2)).point + Vector3.up * 0.5f)); list.Add(item); } return list; } internal static void SpawnExplosiveCluster(PlayerAvatar avatar) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)avatar == (Object)null)) { Vector3 val = default(Vector3); RaycastHit val3 = 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 val2 = ((Component)avatar).transform.position + val; Vector3 pos = ((!Physics.Raycast(val2, Vector3.down, ref val3, 5f)) ? (((Component)avatar).transform.position + new Vector3(Mathf.Cos(num) * 2f, 0.5f, Mathf.Sin(num) * 2f)) : (((RaycastHit)(ref val3)).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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); RaycastHit val3 = 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 val2 = centre + val; Vector3 pos = ((!Physics.Raycast(val2, Vector3.down, ref val3, 6f)) ? (centre + new Vector3(Mathf.Cos(num) * 2.4f, 0.5f, Mathf.Sin(num) * 2.4f)) : (((RaycastHit)(ref val3)).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_0063: 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) 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_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EnemyDirector.instance == (Object)null) { LastStatus = "SpawnSpecificEnemy: EnemyDirector null"; return; } if (_spawning) { LastStatus = "SpawnSpecificEnemy: already spawning"; return; } MonoBehaviour val = (MonoBehaviour)(((Object)(object)EnemyDirector.instance != (Object)null) ? ((object)EnemyDirector.instance) : ((object)context)); val.StartCoroutine(SpawnEnemyCoroutine(setup, pos)); } internal static void SpawnSpecificItem(Item item, Vector3 pos) { //IL_005d: 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_0074: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00e2: 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_00e9: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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) 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 obj = Object.Instantiate(((PrefabRef)(object)setup.spawnObjects[0]).Prefab, pos, Quaternion.identity); EnemyParent parent = obj.GetComponent(); if ((Object)(object)parent != (Object)null) { typeof(EnemyParent).GetField("SetupDone", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(parent, true); Enemy enemy = obj.GetComponentInChildren(); if (enemy != null) { enemy.EnemyTeleported(pos); } EnemyDirector.instance.FirstSpawnPointAdd(parent); EnemyDirector.instance.enemiesSpawned.Add(parent); foreach (PlayerAvatar player in SemiFunc.PlayerGetAll()) { if (enemy != null) { enemy.PlayerAdded(player.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; } }