using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[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("ItemSpawner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Spoopylocal")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyInformationalVersion("1.0.6")]
[assembly: AssemblyProduct("ItemSpawner")]
[assembly: AssemblyTitle("ItemSpawner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ItemSpawner
{
[BepInPlugin("ItemSpawner", "ItemSpawner", "1.0.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("ItemSpawner");
internal static Plugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
Instance = this;
Logger = Logger.CreateLogSource("ItemSpawner");
Logger.LogInfo((object)"ItemSpawner has awoken!");
Harmony val = new Harmony("ItemSpawner");
val.PatchAll();
Logger.LogInfo((object)"ShopManagerPatchPlugin loaded and custom prefab pool applied.");
((MonoBehaviour)this).StartCoroutine(WaitForStatsManager());
}
private IEnumerator WaitForStatsManager()
{
while ((Object)(object)StatsManager.instance == (Object)null)
{
Debug.LogWarning((object)"[ShopManagerPatchPlugin] Waiting for StatsManager to initialize...");
yield return (object)new WaitForSeconds(0.5f);
}
Logger.LogInfo((object)"[ShopManagerPatchPlugin] StatsManager is now available!");
}
private GameObject FindExistingItemPrefab(string itemKey)
{
if (StatsManager.instance.itemDictionary.TryGetValue(itemKey, out var value))
{
if ((Object)(object)value.prefab != (Object)null)
{
Logger.LogInfo((object)("[FindExistingItemPrefab] Found prefab for key: " + itemKey));
return value.prefab;
}
Logger.LogInfo((object)("[FindExistingItemPrefab] Found item for key '" + itemKey + "' but item.prefab is null!"));
}
else
{
Logger.LogInfo((object)("[FindExistingItemPrefab] No item found in itemDictionary for key: " + itemKey));
}
return null;
}
}
public class ShopManagerSpawnGUI : MonoBehaviour
{
private string spawnItemName = "";
public bool showSpawnGUI = false;
private bool isTextFieldFocused = false;
private void Update()
{
if (!isTextFieldFocused)
{
if (((ButtonControl)Keyboard.current.f1Key).wasPressedThisFrame)
{
showSpawnGUI = !showSpawnGUI;
Debug.Log((object)("Spawn GUI toggled: " + (showSpawnGUI ? "Shown" : "Hidden")));
}
if (((ButtonControl)Keyboard.current.enterKey).wasPressedThisFrame)
{
SpawnItem(spawnItemName);
spawnItemName = "";
GUI.FocusControl((string)null);
}
}
}
private void OnGUI()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (showSpawnGUI)
{
GUILayout.BeginArea(new Rect(10f, 10f, 300f, 120f), "Spawn Item UI", GUI.skin.window);
GUILayout.Label("Enter Item Name:", Array.Empty<GUILayoutOption>());
GUI.SetNextControlName("SpawnItemTextField");
spawnItemName = GUILayout.TextField(spawnItemName, 100, Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Spawn Item", Array.Empty<GUILayoutOption>()))
{
SpawnItem(spawnItemName);
}
GUILayout.EndArea();
isTextFieldFocused = GUI.GetNameOfFocusedControl() == "SpawnItemTextField";
}
}
private void SpawnItem(string searchName)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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_00b6: 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_0153: 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_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_016e: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(searchName))
{
Debug.LogWarning((object)"Item name is empty!");
return;
}
searchName = searchName.Trim();
Transform transform = ((Component)Camera.main).transform;
Vector3 val = transform.position + transform.forward * 2f;
Quaternion identity = Quaternion.identity;
IReadOnlyList<GameObject> registeredValuables = Valuables.RegisteredValuables;
GameObject val2 = ((IEnumerable<GameObject>)registeredValuables).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => string.Equals(((Object)go).name, searchName, StringComparison.OrdinalIgnoreCase)));
Vector3 val3;
if ((Object)(object)val2 != (Object)null)
{
if (SemiFunc.IsMultiplayer())
{
PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val2).name, val, identity, (byte)0, (object[])null);
}
else
{
Object.Instantiate<GameObject>(val2, val, identity);
}
string name = ((Object)val2).name;
val3 = val;
Debug.Log((object)("Spawned registered valuable: " + name + " at " + ((object)(Vector3)(ref val3)).ToString()));
return;
}
Debug.Log((object)("Registered valuable not found; searching entire Resources folder for: " + searchName));
string foundPath;
GameObject val4 = TryLoadValuablePrefab(searchName, out foundPath);
if ((Object)(object)val4 != (Object)null)
{
if (SemiFunc.IsMultiplayer())
{
PhotonNetwork.InstantiateRoomObject(foundPath, val, identity, (byte)0, (object[])null);
}
else
{
Object.Instantiate<GameObject>(val4, val, identity);
}
string name2 = ((Object)val4).name;
val3 = val;
Debug.Log((object)("Spawned prefab from Resources: " + name2 + " at " + ((object)(Vector3)(ref val3)).ToString()));
}
else
{
Debug.LogWarning((object)("No item or valuable found with name: " + searchName));
}
}
private GameObject SearchEntireResourcesForPrefab(string searchName)
{
GameObject[] array = Resources.LoadAll<GameObject>("");
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (string.Equals(((Object)val).name, searchName, StringComparison.OrdinalIgnoreCase))
{
return val;
}
}
return null;
}
private GameObject TryLoadValuablePrefab(string searchName, out string foundPath)
{
foundPath = "";
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)
{
string text2 = "Valuables/" + text + "/" + searchName;
GameObject val = Resources.Load<GameObject>(text2);
if ((Object)(object)val != (Object)null)
{
foundPath = text2;
return val;
}
}
string text3 = "Items/Removed Items/" + searchName;
GameObject val2 = Resources.Load<GameObject>(text3);
if ((Object)(object)val2 != (Object)null)
{
foundPath = text3;
return val2;
}
string text4 = "Items/" + searchName;
GameObject val3 = Resources.Load<GameObject>(text4);
if ((Object)(object)val3 != (Object)null)
{
foundPath = text4;
return val3;
}
return null;
}
}
[HarmonyPatch(typeof(ShopManager), "Awake")]
public static class ShopManager_Awake_Patch
{
private static void Postfix(ShopManager __instance)
{
if ((Object)(object)((Component)__instance).gameObject.GetComponent<ShopManagerSpawnGUI>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<ShopManagerSpawnGUI>();
Debug.Log((object)"ShopManagerSpawnGUI added via Harmony patch.");
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ItemSpawner";
public const string PLUGIN_NAME = "ItemSpawner";
public const string PLUGIN_VERSION = "1.0.6";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}