Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Enhanced Item Spawner v1.0.0
plugins/RepoItemSpawner.dll
Decompiled 10 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Photon.Pun; using REPOLib.Modules; using UnityEngine; [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.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RepoItemSpawner")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RepoItemSpawner")] [assembly: AssemblyTitle("RepoItemSpawner")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ItemSpawner { [BepInPlugin("com.spoopylocal.itemspawner", "ItemSpawner", "2.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <WaitForStatsManager>d__9 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForStatsManager>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if ((Object)(object)StatsManager.instance == (Object)null) { Debug.LogWarning((object)"[ItemSpawner] Waiting for StatsManager to initialize..."); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } Logger.LogInfo((object)"[ItemSpawner] StatsManager is now available!"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static Plugin Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"ItemSpawner Enhanced has awoken!"); Harmony val = new Harmony("com.spoopylocal.itemspawner"); val.PatchAll(); Logger.LogInfo((object)"ItemSpawner Enhanced loaded and patches applied."); ((MonoBehaviour)this).StartCoroutine(WaitForStatsManager()); } [IteratorStateMachine(typeof(<WaitForStatsManager>d__9))] private IEnumerator WaitForStatsManager() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForStatsManager>d__9(0) { <>4__this = this }; } } [Serializable] public class SpawnableItem { public string name; public string displayName; public string category; public string path; public bool isItem; public bool isFavorite; public SpawnableItem(string name, string displayName, string category, string path, bool isItem) { this.name = name; this.displayName = displayName; this.category = category; this.path = path; this.isItem = isItem; isFavorite = false; } } public class EnhancedSpawnGUI : MonoBehaviour { [CompilerGenerated] private sealed class <InitializeItemsWhenReady>d__23 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnhancedSpawnGUI <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeItemsWhenReady>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_004f; case 1: <>1__state = -1; goto IL_004f; case 2: { <>1__state = -1; <>4__this.InitializeItems(); <>4__this.LoadFavorites(); return false; } IL_004f: if ((Object)(object)StatsManager.instance == (Object)null) { <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private bool showSpawnGUI = false; private string searchText = ""; private Vector2 scrollPosition = Vector2.zero; private Vector2 favoritesScrollPosition = Vector2.zero; private List<SpawnableItem> allItems = new List<SpawnableItem>(); private List<SpawnableItem> filteredItems = new List<SpawnableItem>(); private List<SpawnableItem> favoriteItems = new List<SpawnableItem>(); private bool showFavorites = true; private bool showSearch = true; private string favoritesFilePath; private int selectedIndex = -1; private bool isInFavorites = false; private List<SpawnableItem> currentDisplayList = new List<SpawnableItem>(); private bool f1KeyPressed = false; private bool f1KeyWasPressed = false; private bool upKeyPressed = false; private bool upKeyWasPressed = false; private bool downKeyPressed = false; private bool downKeyWasPressed = false; private bool enterKeyPressed = false; private bool enterKeyWasPressed = false; private bool isSearchFieldFocused = false; private void Start() { favoritesFilePath = Path.Combine(Application.persistentDataPath, "ItemSpawner_Favorites.json"); ((MonoBehaviour)this).StartCoroutine(InitializeItemsWhenReady()); } [IteratorStateMachine(typeof(<InitializeItemsWhenReady>d__23))] private IEnumerator InitializeItemsWhenReady() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeItemsWhenReady>d__23(0) { <>4__this = this }; } private void InitializeItems() { allItems.Clear(); try { IReadOnlyList<Item> registeredItems = Items.RegisteredItems; if (registeredItems != null) { foreach (Item item in registeredItems) { if ((Object)(object)item != (Object)null && !string.IsNullOrEmpty(((Object)item).name)) { string displayName = ((Object)item).name.Replace("(Clone)", "").Trim(); allItems.Add(new SpawnableItem(((Object)item).name, displayName, "Items", "Items/" + ((Object)item).name, isItem: true)); } } } } catch (Exception ex) { Debug.LogError((object)("Error loading registered items: " + ex.Message)); } try { IReadOnlyList<GameObject> registeredValuables = Valuables.RegisteredValuables; if (registeredValuables != null) { foreach (GameObject item2 in registeredValuables) { if ((Object)(object)item2 != (Object)null && !string.IsNullOrEmpty(((Object)item2).name)) { string displayName2 = ((Object)item2).name.Replace("(Clone)", "").Trim(); string text = ""; try { text = ResourcesHelper.GetValuablePrefabPath(item2); } catch { text = "Valuables/" + ((Object)item2).name; } allItems.Add(new SpawnableItem(((Object)item2).name, displayName2, "Valuables", text, isItem: false)); } } } } catch (Exception ex2) { Debug.LogError((object)("Error loading registered valuables: " + ex2.Message)); } ScanResourcesFolder(); filteredItems = new List<SpawnableItem>(allItems); Debug.Log((object)$"ItemSpawner: Loaded {allItems.Count} items total"); } private void ScanResourcesFolder() { string[] array = new string[7] { "01 Tiny", "02 Small", "03 Medium", "04 Big", "05 Wide", "06 Tall", "07 Very Tall" }; string[] array2 = array; foreach (string text in array2) { try { GameObject[] array3 = Resources.LoadAll<GameObject>("Valuables/" + text); GameObject[] array4 = array3; foreach (GameObject valuable in array4) { if ((Object)(object)valuable != (Object)null && !allItems.Any((SpawnableItem item) => item.name == ((Object)valuable).name)) { string displayName = ((Object)valuable).name.Replace("(Clone)", "").Trim(); allItems.Add(new SpawnableItem(((Object)valuable).name, displayName, text, "Valuables/" + text + "/" + ((Object)valuable).name, isItem: false)); } } } catch (Exception ex) { Debug.LogWarning((object)("Could not load valuables from category " + text + ": " + ex.Message)); } } try { GameObject[] array5 = Resources.LoadAll<GameObject>("Items"); GameObject[] array6 = array5; foreach (GameObject item3 in array6) { if ((Object)(object)item3 != (Object)null && !allItems.Any((SpawnableItem existingItem) => existingItem.name == ((Object)item3).name)) { string displayName2 = ((Object)item3).name.Replace("(Clone)", "").Trim(); allItems.Add(new SpawnableItem(((Object)item3).name, displayName2, "Items", "Items/" + ((Object)item3).name, isItem: true)); } } } catch (Exception ex2) { Debug.LogWarning((object)("Could not load items: " + ex2.Message)); } try { GameObject[] array7 = Resources.LoadAll<GameObject>("Items/Removed Items"); GameObject[] array8 = array7; foreach (GameObject item2 in array8) { if ((Object)(object)item2 != (Object)null && !allItems.Any((SpawnableItem existingItem) => existingItem.name == ((Object)item2).name)) { string displayName3 = ((Object)item2).name.Replace("(Clone)", "").Trim(); allItems.Add(new SpawnableItem(((Object)item2).name, displayName3, "Removed Items", "Items/Removed Items/" + ((Object)item2).name, isItem: true)); } } } catch (Exception ex3) { Debug.LogWarning((object)("Could not load removed items: " + ex3.Message)); } } private void Update() { f1KeyWasPressed = f1KeyPressed; f1KeyPressed = Input.GetKey((KeyCode)282); if (f1KeyPressed && !f1KeyWasPressed) { showSpawnGUI = !showSpawnGUI; if (showSpawnGUI) { selectedIndex = -1; isInFavorites = false; GUI.FocusControl((string)null); } Debug.Log((object)("Enhanced Spawn GUI toggled: " + (showSpawnGUI ? "Shown" : "Hidden"))); } if (!showSpawnGUI) { return; } upKeyWasPressed = upKeyPressed; upKeyPressed = Input.GetKey((KeyCode)273); downKeyWasPressed = downKeyPressed; downKeyPressed = Input.GetKey((KeyCode)274); enterKeyWasPressed = enterKeyPressed; enterKeyPressed = Input.GetKey((KeyCode)13) || Input.GetKey((KeyCode)271); if (upKeyPressed && !upKeyWasPressed) { if (isSearchFieldFocused) { GUI.FocusControl((string)null); isSearchFieldFocused = false; } NavigateUp(); } else if (downKeyPressed && !downKeyWasPressed) { if (isSearchFieldFocused) { GUI.FocusControl((string)null); isSearchFieldFocused = false; } NavigateDown(); } else if (enterKeyPressed && !enterKeyWasPressed) { if (isSearchFieldFocused) { GUI.FocusControl((string)null); isSearchFieldFocused = false; } SpawnSelectedItem(); } } private void NavigateUp() { UpdateCurrentDisplayList(); if (currentDisplayList.Count == 0) { return; } if (selectedIndex <= 0) { if (isInFavorites && showSearch && filteredItems.Count > 0) { isInFavorites = false; selectedIndex = filteredItems.Count - 1; scrollPosition.y = float.MaxValue; } else if (!isInFavorites && showFavorites && favoriteItems.Count > 0) { isInFavorites = true; selectedIndex = favoriteItems.Count - 1; favoritesScrollPosition.y = float.MaxValue; } else { selectedIndex = currentDisplayList.Count - 1; } } else { selectedIndex--; } ScrollToSelectedItem(); } private void NavigateDown() { UpdateCurrentDisplayList(); if (currentDisplayList.Count == 0) { return; } if (selectedIndex >= currentDisplayList.Count - 1) { if (!isInFavorites && showFavorites && favoriteItems.Count > 0) { isInFavorites = true; selectedIndex = 0; favoritesScrollPosition.y = 0f; } else if (isInFavorites && showSearch && filteredItems.Count > 0) { isInFavorites = false; selectedIndex = 0; scrollPosition.y = 0f; } else { selectedIndex = 0; } } else { selectedIndex++; } ScrollToSelectedItem(); } private void UpdateCurrentDisplayList() { if (showSearch && filteredItems.Count > 0 && !isInFavorites) { currentDisplayList = filteredItems; } else if (showFavorites && favoriteItems.Count > 0 && isInFavorites) { currentDisplayList = favoriteItems; } else if (showSearch && filteredItems.Count > 0) { isInFavorites = false; currentDisplayList = filteredItems; } else if (showFavorites && favoriteItems.Count > 0) { isInFavorites = true; currentDisplayList = favoriteItems; } else { currentDisplayList = new List<SpawnableItem>(); selectedIndex = -1; } if (selectedIndex >= currentDisplayList.Count) { selectedIndex = ((currentDisplayList.Count > 0) ? (currentDisplayList.Count - 1) : (-1)); } if (selectedIndex == -1 && currentDisplayList.Count > 0) { selectedIndex = 0; } } private void ScrollToSelectedItem() { if (selectedIndex == -1 || currentDisplayList.Count == 0) { return; } float num = 25f; float num2 = 150f; if (!isInFavorites) { float num3 = (float)selectedIndex * num; if (num3 < scrollPosition.y) { scrollPosition.y = num3; } else if (num3 + num > scrollPosition.y + num2) { scrollPosition.y = num3 - num2 + num; } } else { float num4 = (float)selectedIndex * num; if (num4 < favoritesScrollPosition.y) { favoritesScrollPosition.y = num4; } else if (num4 + num > favoritesScrollPosition.y + num2) { favoritesScrollPosition.y = num4 - num2 + num; } } } private void SpawnSelectedItem() { UpdateCurrentDisplayList(); if (selectedIndex >= 0 && selectedIndex < currentDisplayList.Count) { SpawnItem(currentDisplayList[selectedIndex]); } } private void OnGUI() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) if (!showSpawnGUI) { return; } GUILayout.BeginArea(new Rect(10f, 10f, 600f, 500f), "Enhanced Item Spawner", GUI.skin.window); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(showSearch ? "Hide Search" : "Show Search", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { showSearch = !showSearch; selectedIndex = -1; isInFavorites = false; } if (GUILayout.Button(showFavorites ? "Hide Favorites" : "Show Favorites", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) })) { showFavorites = !showFavorites; selectedIndex = -1; isInFavorites = false; } GUILayout.EndHorizontal(); if (showSearch) { GUILayout.Space(10f); GUILayout.Label("Search Items:", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.SetNextControlName("SearchField"); string text = GUILayout.TextField(searchText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (text != searchText) { searchText = text; FilterItems(); selectedIndex = -1; isInFavorites = false; } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) })) { searchText = ""; FilterItems(); selectedIndex = -1; isInFavorites = false; GUI.FocusControl((string)null); } GUILayout.EndHorizontal(); isSearchFieldFocused = GUI.GetNameOfFocusedControl() == "SearchField"; GUILayout.Label($"Search Results ({filteredItems.Count} items):", Array.Empty<GUILayoutOption>()); scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(150f) }); for (int i = 0; i < filteredItems.Count; i++) { SpawnableItem spawnableItem = filteredItems[i]; bool flag = !isInFavorites && selectedIndex == i; if (flag) { GUI.backgroundColor = new Color(1f, 0.65f, 0f, 1f); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string text2 = (spawnableItem.isFavorite ? "★" : "☆"); if (GUILayout.Button(text2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(25f) })) { ToggleFavorite(spawnableItem); } if (GUILayout.Button(spawnableItem.displayName + " (" + spawnableItem.category + ")", Array.Empty<GUILayoutOption>())) { SpawnItem(spawnableItem); } GUILayout.EndHorizontal(); if (flag) { GUI.backgroundColor = Color.white; } } GUILayout.EndScrollView(); } if (showFavorites) { GUILayout.Space(10f); GUILayout.Label($"Favorite Items ({favoriteItems.Count} items):", Array.Empty<GUILayoutOption>()); favoritesScrollPosition = GUILayout.BeginScrollView(favoritesScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(150f) }); for (int j = 0; j < favoriteItems.Count; j++) { SpawnableItem spawnableItem2 = favoriteItems[j]; bool flag2 = isInFavorites && selectedIndex == j; if (flag2) { GUI.backgroundColor = new Color(1f, 0.65f, 0f, 1f); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("✖", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(25f) })) { ToggleFavorite(spawnableItem2); } if (GUILayout.Button(spawnableItem2.displayName + " (" + spawnableItem2.category + ")", Array.Empty<GUILayoutOption>())) { SpawnItem(spawnableItem2); } GUILayout.EndHorizontal(); if (flag2) { GUI.backgroundColor = Color.white; } } GUILayout.EndScrollView(); } GUILayout.Space(10f); GUILayout.Label("Controls: F1=Toggle | ↑↓=Navigate | Enter=Spawn | ★/☆=Favorite | ✖=Remove", Array.Empty<GUILayoutOption>()); GUILayout.EndArea(); } private void FilterItems() { if (string.IsNullOrEmpty(searchText)) { filteredItems = new List<SpawnableItem>(allItems); return; } filteredItems = allItems.Where((SpawnableItem item) => item.displayName.ToLower().Contains(searchText.ToLower()) || item.category.ToLower().Contains(searchText.ToLower())).ToList(); } private void ToggleFavorite(SpawnableItem item) { item.isFavorite = !item.isFavorite; if (item.isFavorite) { if (!favoriteItems.Contains(item)) { favoriteItems.Add(item); } } else { favoriteItems.Remove(item); } SaveFavorites(); } private void SaveFavorites() { try { List<string> list = favoriteItems.Select((SpawnableItem item) => item.name).ToList(); string contents = JsonConvert.SerializeObject((object)list, (Formatting)1); File.WriteAllText(favoritesFilePath, contents); } catch (Exception ex) { Debug.LogError((object)("Failed to save favorites: " + ex.Message)); } } private void LoadFavorites() { try { if (!File.Exists(favoritesFilePath)) { return; } string text = File.ReadAllText(favoritesFilePath); List<string> list = JsonConvert.DeserializeObject<List<string>>(text); if (list == null) { return; } foreach (string favoriteName in list) { SpawnableItem spawnableItem = allItems.FirstOrDefault((SpawnableItem i) => i.name == favoriteName); if (spawnableItem != null) { spawnableItem.isFavorite = true; favoriteItems.Add(spawnableItem); } } } catch (Exception ex) { Debug.LogError((object)("Failed to load favorites: " + ex.Message)); } } private void SpawnItem(SpawnableItem spawnableItem) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) SpawnableItem spawnableItem2 = spawnableItem; if ((Object)(object)Camera.main == (Object)null) { Debug.LogError((object)"No main camera found!"); return; } Transform transform = ((Component)Camera.main).transform; Vector3 val = transform.position + transform.forward * 2f; Quaternion identity = Quaternion.identity; try { if (spawnableItem2.isItem) { Item val2 = Items.RegisteredItems?.FirstOrDefault((Func<Item, bool>)((Item i) => ((Object)i).name == spawnableItem2.name)); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.prefab != (Object)null) { if (SemiFunc.IsMultiplayer()) { PhotonNetwork.InstantiateRoomObject(spawnableItem2.path, val, identity, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(val2.prefab, val, identity); } Debug.Log((object)("Spawned item: " + spawnableItem2.displayName)); return; } } else { GameObject val3 = Valuables.RegisteredValuables?.FirstOrDefault((Func<GameObject, bool>)((GameObject v) => ((Object)v).name == spawnableItem2.name)); if ((Object)(object)val3 != (Object)null) { if (SemiFunc.IsMultiplayer()) { PhotonNetwork.InstantiateRoomObject(spawnableItem2.path, val, identity, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(val3, val, identity); } Debug.Log((object)("Spawned valuable: " + spawnableItem2.displayName)); return; } } GameObject val4 = Resources.Load<GameObject>(spawnableItem2.path); if ((Object)(object)val4 != (Object)null) { if (SemiFunc.IsMultiplayer()) { PhotonNetwork.InstantiateRoomObject(spawnableItem2.path, val, identity, (byte)0, (object[])null); } else { Object.Instantiate<GameObject>(val4, val, identity); } Debug.Log((object)("Spawned from Resources: " + spawnableItem2.displayName)); } else { Debug.LogWarning((object)("Failed to spawn item: " + spawnableItem2.displayName + " - prefab not found at path: " + spawnableItem2.path)); } } catch (Exception ex) { Debug.LogError((object)("Error spawning " + spawnableItem2.displayName + ": " + ex.Message)); } } } [HarmonyPatch(typeof(ShopManager), "Awake")] public static class ShopManager_Awake_Patch { private static void Postfix(ShopManager __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent<EnhancedSpawnGUI>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<EnhancedSpawnGUI>(); Debug.Log((object)"EnhancedSpawnGUI added via Harmony patch."); } } } }