Decompiled source of SpawnItemInLevel v1.1.0

SpawnItemInLevel.dll

Decompiled 2 weeks ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using SpawnItemInLevel;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal class ConfigManager
{
	public static Dictionary<string, ConfigEntry<bool>> ShopItemConfigs = new Dictionary<string, ConfigEntry<bool>>();

	public static Dictionary<string, ConfigEntry<bool>> ValueItemConfigs = new Dictionary<string, ConfigEntry<bool>>();

	public static ConfigEntry<Key>? BindKeyValueItem { get; private set; }

	public static ConfigEntry<Key>? BindKeyShopItem { get; private set; }

	public static ConfigEntry<int>? ValueTop { get; private set; }

	public static ConfigEntry<int>? ValueDown { get; private set; }

	public static ConfigEntry<bool>? isDebug { get; private set; }

	public static ConfigEntry<bool>? isOpen { get; private set; }

	public static void Initialize(ConfigFile configFile)
	{
		//IL_0d61: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d6b: Expected O, but got Unknown
		//IL_0d93: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d9d: Expected O, but got Unknown
		List<ConfigEntry<bool>> list = new List<ConfigEntry<bool>>();
		List<CEVT> list2 = new List<CEVT>(7)
		{
			new CEVT("Tiny", "微小的", v3: true, "Cevt"),
			new CEVT("Small", "小的", v3: true, "Cevt"),
			new CEVT("Medium", "中的", v3: true, "Cevt"),
			new CEVT("Big", "大的", v3: true, "Cevt"),
			new CEVT("Wide", "宽的", v3: true, "Cevt"),
			new CEVT("Tall", "高的", v3: true, "Cevt"),
			new CEVT("VeryTall", "很高的", v3: true, "Cevt")
		};
		List<CESI> list3 = new List<CESI>(111)
		{
			new CESI("Tumble Launch Upgrade", "翻滚速度升级", v3: true, "Upgrade"),
			new CESI("Tumble Wings Upgrade", "翻滚翅膀升级", v3: true, "Upgrade"),
			new CESI("Crouch Rest Upgrade", "下蹲恢复升级", v3: true, "Upgrade"),
			new CESI("Sprint Speed Upgrade", "冲刺速度升级", v3: true, "Upgrade"),
			new CESI("Extra Jump Upgrade", "额外跳跃升级", v3: true, "Upgrade"),
			new CESI("Health Upgrade", "生命升级", v3: true, "Upgrade"),
			new CESI("Stamina Upgrade", "体力升级", v3: true, "Upgrade"),
			new CESI("Strength Upgrade", "力量升级", v3: true, "Upgrade"),
			new CESI("Range Upgrade", "抓取范围升级", v3: true, "Upgrade"),
			new CESI("Death Head Battery Upgrade", "头部电池升级", v3: true, "Upgrade"),
			new CESI("Map Player Count Upgrade", "地图玩家数量升级", v3: true, "Upgrade"),
			new CESI("Tumble Climb Upgrade", "翻滚抓取升级", v3: true, "Upgrade"),
			new CESI("Extra Life Upgrade", "额外生命升级", v3: true, "Upgrade"),
			new CESI("Item Resist Upgrade", "物品抗性升级", v3: true, "MoreUpgrades"),
			new CESI("Item Value Upgrade", "物品价值升级", v3: true, "MoreUpgrades"),
			new CESI("Autoscan Upgrade", "自动扫描升级", v3: true, "MoreUpgrades"),
			new CESI("Valuable Count Upgrade", "贵重物品数量升级", v3: true, "MoreUpgrades"),
			new CESI("Map Zoom Upgrade", "地图缩放升级", v3: true, "MoreUpgrades"),
			new CESI("Sprint Usage Upgrade", "冲刺消耗升级", v3: true, "MoreUpgrades"),
			new CESI("Recharge Drone", "充电无人机", v3: true, "Drone"),
			new CESI("Indestructible Drone", "无敌无人机", v3: true, "Drone"),
			new CESI("Zero Gravity Drone", "零重力无人机", v3: true, "Drone"),
			new CESI("Roll Drone", "滚动无人机", v3: true, "Drone"),
			new CESI("Feather Drone", "羽毛无人机", v3: true, "Drone"),
			new CESI("Large Health Pack (100)", "健康包(100)", v3: true, "Health Pack"),
			new CESI("Medium Health Pack (50)", "健康包(50)", v3: true, "Health Pack"),
			new CESI("Small Health Pack (25)", "健康包(25)", v3: true, "Health Pack"),
			new CESI("Sword", "剑", v3: true, "Item"),
			new CESI("Sledge Hammer", "大锤", v3: true, "Item"),
			new CESI("Inflatable Hammer", "充气锤", v3: true, "Item"),
			new CESI("Frying Pan", "铁锅", v3: true, "Item"),
			new CESI("Prodzap", "电击棒", v3: true, "Item"),
			new CESI("Baseball Bat", "棒球棒", v3: true, "Item"),
			new CESI("Grenade", "手榴弹", v3: true, "Item"),
			new CESI("Shockwave Grenade", "冲击波手榴弹", v3: true, "Item"),
			new CESI("Human Grenade", "人类手榴弹", v3: true, "Item"),
			new CESI("Duct Taped Grenades", "胶带手榴弹", v3: true, "Item"),
			new CESI("Stun Grenade", "眩晕手雷", v3: true, "Item"),
			new CESI("Tranq Gun", "麻醉枪", v3: true, "Item"),
			new CESI("Gun", "枪", v3: true, "Item"),
			new CESI("Shotgun", "霰弹枪", v3: true, "Item"),
			new CESI("Photon Blaster", "光子轰击器", v3: true, "Item"),
			new CESI("Boltzap", "电击弩", v3: true, "Item"),
			new CESI("Explosive Mine", "爆炸地雷", v3: true, "Item"),
			new CESI("Shockwave Mine", "冲击波地雷", v3: true, "Item"),
			new CESI("Trapzap", "电击陷阱", v3: true, "Item"),
			new CESI("Phase Bridge", "相位桥", v3: true, "Item"),
			new CESI("C.A.R.T.", "C.A.R.T.手推车", v3: true, "Item"),
			new CESI("POCKET C.A.R.T.", "迷你C.A.R.T.手推车", v3: true, "Item"),
			new CESI("C.A.R.T. Laser", "C.A.R.T.激光炮", v3: true, "Item"),
			new CESI("Zero Gravity Orb", "零重力球体", v3: true, "Item"),
			new CESI("Duck Bucket", "鸭子桶", v3: true, "Item"),
			new CESI("Valuable Tracker", "物品追踪器", v3: true, "Item"),
			new CESI("Rubber Duck", "橡胶鸭", v3: true, "Item"),
			new CESI("Extraction Tracker", "提取点追踪器", v3: true, "Item"),
			new CESI("Energy Crystal", "能量晶体", v3: true, "Item"),
			new CESI("Crowbar", "撬棍", v3: true, "SillyValuables"),
			new CESI("Energy Pistol", "能量手枪", v3: true, "SillyValuables"),
			new CESI("Lodestone Crossbow", "磁石十字弩", v3: true, "SillyValuables"),
			new CESI("Slushie Bomb", "冰沙炸弹", v3: true, "SillyValuables"),
			new CESI("Tech Scepter", "科技权杖", v3: true, "SillyValuables"),
			new CESI("Pickaxe", "稿子", v3: true, "SillyValuables"),
			new CESI("Baguette", "法棍面包", v3: true, "SillyValuables"),
			new CESI("Blerdly", "Blerdly 的戟", v3: true, "SillyValuables"),
			new CESI("Bloxiade", "Bloxiade(10 秒速度提升)", v3: true, "SillyValuables"),
			new CESI("Health Bloxy Cola (15)", "Bloxy 可乐(回血 15)", v3: true, "SillyValuables"),
			new CESI("Candy Bucket (100)", "糖果桶 (100)", v3: true, "SillyValuables"),
			new CESI("Chips for Noobs (100)", "新手薯片 (100)", v3: true, "SillyValuables"),
			new CESI("Comic Large Pencil", "漫画大铅笔", v3: true, "SillyValuables"),
			new CESI("Crimson Periastron", "深红权杖", v3: true, "SillyValuables"),
			new CESI("Devilsknife", "魔鬼之刃", v3: true, "SillyValuables"),
			new CESI("Exploding Pumpkin", "爆炸南瓜", v3: true, "SillyValuables"),
			new CESI("Fortune Healing Potion (65)", "幸运愈合药水 (65)", v3: true, "SillyValuables"),
			new CESI("Freeze Gun (Stun enemies for 5s)", "冷冻枪(眩晕敌人 5 秒)", v3: true, "SillyValuables"),
			new CESI("Golden AK47", "黄金 AK47", v3: true, "SillyValuables"),
			new CESI("Golden Deagle", "黄金沙鹰", v3: true, "SillyValuables"),
			new CESI("Guts shotgun", "内脏霰弹枪", v3: true, "SillyValuables"),
			new CESI("Halloween Hammer", "万圣节锤子", v3: true, "SillyValuables"),
			new CESI("Haunted Cheezburger", "幽灵芝士汉堡 [E](10 秒无敌模式)", v3: true, "SillyValuables"),
			new CESI("Healing Gun (Shoot to heal teammates)", "治疗枪(射击以治疗队友)", v3: true, "SillyValuables"),
			new CESI("Illumina", "光辉剑", v3: true, "SillyValuables"),
			new CESI("Stop Sign", "停车标志牌", v3: true, "SillyValuables"),
			new CESI("Explosive Snowball", "爆炸雪球", v3: true, "SillyValuables"),
			new CESI("Keyblade", "键刃", v3: true, "SillyValuables"),
			new CESI("M&M Peanut Chocolate Bag (50)", "M&M 花生巧克力袋 (50)", v3: true, "SillyValuables"),
			new CESI("Medkit (150)", "医疗箱 (150)", v3: true, "SillyValuables"),
			new CESI("Meowmere", "喵喵剑", v3: true, "SillyValuables"),
			new CESI("Beast Minigun", "兽神加特林", v3: true, "SillyValuables"),
			new CESI("Monster Energy (15)", "魔爪能量饮料 (15)", v3: true, "SillyValuables"),
			new CESI("Moon Stick", "月亮法杖", v3: true, "SillyValuables"),
			new CESI("Muffet Cereal Box (20)", "Muffet 麦片盒 (20)", v3: true, "SillyValuables"),
			new CESI("Nuclear Bomb", "核弹", v3: true, "SillyValuables"),
			new CESI("Roblox Paintball Gun", "Roblox 彩弹枪", v3: true, "SillyValuables"),
			new CESI("Pet Rock", "宠物石(这只宠物能轻易杀死怪物,但寿命很短)", v3: true, "SillyValuables"),
			new CESI("Pizza (40)", "披萨 (40)", v3: true, "SillyValuables"),
			new CESI("Rainbow Lucky Block", "彩虹幸运块(不知道里面是什么……)", v3: true, "SillyValuables"),
			new CESI("Rainbow Pistol", "彩虹手枪", v3: true, "SillyValuables"),
			new CESI("Riff Ripper", "Riff 破坏者", v3: true, "SillyValuables"),
			new CESI("Roblox Bomb", "Roblox 炸弹", v3: true, "SillyValuables"),
			new CESI("Roblox Rocket Launcher", "Roblox 火箭筒", v3: true, "SillyValuables"),
			new CESI("Shedletsky Gubby", "Shedletsky 长枪", v3: true, "SillyValuables"),
			new CESI("Spray Can", "喷漆罐", v3: true, "SillyValuables"),
			new CESI("Subspace Tripmine", "亚空间阔剑地雷", v3: true, "SillyValuables"),
			new CESI("Summit Shaper", "峰云", v3: true, "SillyValuables"),
			new CESI("Teddy Bloxpin", "泰迪熊(50% 几率满血复活,50% 几率死亡)", v3: true, "SillyValuables"),
			new CESI("The Moonlight Greatsword", "月光大剑", v3: true, "SillyValuables"),
			new CESI("True Knife", "真刀", v3: true, "SillyValuables"),
			new CESI("Turkey Leg (40)", "火鸡腿 (40)", v3: true, "SillyValuables"),
			new CESI("Ultraviolet Blaster", "紫外爆破枪", v3: true, "SillyValuables"),
			new CESI("Venomous Sniper", "剧毒狙击步枪(按 Z 瞄准)", v3: true, "SillyValuables"),
			new CESI("Water Balloon", "水气球", v3: true, "SillyValuables")
		};
		List<CEVI> list4 = new List<CEVI>();
		isOpen = configFile.Bind<bool>("Controls", "isOpen", true, "开关");
		isDebug = configFile.Bind<bool>("Controls", "isDebug", true, "调试模式");
		ValueTop = configFile.Bind<int>("Values", "随机物品价值上限", 10000, new ConfigDescription("随机物品价值上限", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50000), Array.Empty<object>()));
		ValueDown = configFile.Bind<int>("Values", "随机物品价值下限", 100, new ConfigDescription("随机物品价值下限", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50000), Array.Empty<object>()));
		BindKeyValueItem = configFile.Bind<Key>("Controls", "高价值物品生成按键绑定", (Key)34, "高价值物品生成按键绑定");
		BindKeyShopItem = configFile.Bind<Key>("Controls", "商店物品生成按键绑定", (Key)21, "商店物品生成按键绑定");
		foreach (CEVT item in list2)
		{
			list.Add(RegisterValueItemConfig(configFile, item.key, item.value, item.desc, item.modName));
		}
		foreach (CESI item2 in list3)
		{
			list.Add(RegisterShopItemConfig(configFile, item2.key, item2.value, item2.desc, item2.modName));
		}
		foreach (CEVI item3 in list4)
		{
			list.Add(RegisterValueItemConfig(configFile, item3.key, item3.value, item3.desc, item3.modName));
		}
	}

	private static ConfigEntry<bool> RegisterShopItemConfig(ConfigFile file, string key, bool defaultValue, string description, string modName)
	{
		ConfigEntry<bool> val = file.Bind<bool>(modName, key, defaultValue, description);
		ShopItemConfigs[key] = val;
		return val;
	}

	public static List<string> GetShopItemAllowed()
	{
		List<string> list = new List<string>();
		foreach (KeyValuePair<string, ConfigEntry<bool>> shopItemConfig in ShopItemConfigs)
		{
			if (shopItemConfig.Value.Value)
			{
				list.Add(shopItemConfig.Key);
			}
		}
		return list;
	}

	private static ConfigEntry<bool> RegisterValueItemConfig(ConfigFile file, string key, bool defaultValue, string description, string modName)
	{
		ConfigEntry<bool> val = file.Bind<bool>(modName, key, defaultValue, description);
		ValueItemConfigs[key] = val;
		return val;
	}

	public static List<Type> GetValueItemAllowedType()
	{
		List<Type> list = new List<Type>();
		foreach (KeyValuePair<string, ConfigEntry<bool>> valueItemConfig in ValueItemConfigs)
		{
			if (valueItemConfig.Value.Value)
			{
				switch (valueItemConfig.Key)
				{
				case "Tiny":
					list.Add((Type)0);
					break;
				case "Small":
					list.Add((Type)1);
					break;
				case "Medium":
					list.Add((Type)2);
					break;
				case "Big":
					list.Add((Type)3);
					break;
				case "Wide":
					list.Add((Type)4);
					break;
				case "Tall":
					list.Add((Type)5);
					break;
				case "VeryTall":
					list.Add((Type)6);
					break;
				}
			}
		}
		return list;
	}
}
namespace SpawnItemInLevel
{
	internal class CESI
	{
		public string key;

		public string desc;

		public bool value;

		public string modName;

		public CESI(string v1, string v2, bool v3, string? modName = "Controls")
		{
			key = v1;
			desc = v2;
			value = v3;
			this.modName = modName;
		}
	}
	internal class CEVI
	{
		public string key;

		public string desc;

		public bool value;

		public string modName;

		public CEVI(string v1, string v2, bool v3, string? modName = "Controls")
		{
			key = v1;
			desc = v2;
			value = v3;
			this.modName = modName;
		}
	}
	internal class CEVT
	{
		public string key;

		public string desc;

		public bool value;

		public string modName;

		public CEVT(string v1, string v2, bool v3, string? modName = "Controls")
		{
			key = v1;
			desc = v2;
			value = v3;
			this.modName = modName;
		}
	}
	[BepInPlugin("Gs.SpawnItemInLevel", "Spawn Item In Level", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SpawnItemInLevel : BaseUnityPlugin
	{
		internal static SpawnItemInLevel Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)"Spawn Item In Level Has Loaded!");
		}

		internal void Patch()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
			if (Harmony == null)
			{
				Harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	internal static class SpawnManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void KeyboardListener(ShopManager __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).gameObject.GetComponent<SpawnShopItemManager>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<SpawnShopItemManager>();
			}
			if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).gameObject.GetComponent<SpawnValueItemManager>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<SpawnValueItemManager>();
			}
		}
	}
	internal class SpawnShopItemManager : MonoBehaviour
	{
		private static readonly ManualLogSource Logger = Logger.CreateLogSource("SpawnShopItem");

		private static readonly Random random = new Random();

		private void Update()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigManager.isOpen.Value)
			{
				Key value = ConfigManager.BindKeyShopItem.Value;
				if (((ButtonControl)Keyboard.current[value]).wasPressedThisFrame)
				{
					GenerateAndSpawnStoreItem();
				}
			}
		}

		public void GenerateAndSpawnStoreItem()
		{
			//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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetRandomItem(new List<itemType>(), out Item item))
			{
				Vector3 position = ((Component)PlayerAvatar.instance).transform.position + Vector3.up * 1f + ((Component)PlayerAvatar.instance).transform.forward * 1.5f;
				Quaternion identity = Quaternion.identity;
				SpawnItem(item, position, identity);
			}
			else
			{
				Logger.LogError((object)"无法获取有效的物品来生成。");
			}
		}

		private static bool TryGetRandomItem(List<itemType>? filterTypes, out Item item)
		{
			List<itemType> filterTypes2 = filterTypes;
			item = null;
			if (StatsManager.instance?.itemDictionary == null)
			{
				Logger.LogError((object)"StatsManager 或 itemDictionary 未初始化");
				return false;
			}
			List<Item> list = ((!filterTypes2.Any()) ? StatsManager.instance.itemDictionary.Values.Select((Item i) => i).ToList() : StatsManager.instance.itemDictionary.Values.Where((Item i) => filterTypes2.Contains(i.itemType)).ToList());
			if (ConfigManager.isDebug.Value)
			{
				Logger.LogInfo((object)("所有商店物品:\n" + string.Join("\n", list.Select((Item i) => i.itemName))));
			}
			List<string> allowedSI = ConfigManager.GetShopItemAllowed();
			if (ConfigManager.isDebug.Value)
			{
				Logger.LogInfo((object)("设置的商店物品:\n" + string.Join("\n", allowedSI)));
			}
			List<Item> list2 = (from i in list
				where (Object)(object)i != (Object)null && i.prefab != null
				where allowedSI.Contains(i.itemName) || allowedSI.Any((string s) => ((Object)i).name.Contains(s))
				select i).ToList();
			if (allowedSI.Count == 0)
			{
				Logger.LogWarning((object)"筛选后没有符合条件的物品。从默认的物品集中随机获取。");
				int index = random.Next(list.Count);
				item = list[index];
			}
			else
			{
				int index2 = random.Next(list2.Count);
				item = list2[index2];
			}
			Logger.LogInfo((object)("当前随机选中的商店物品: " + item.itemName));
			return true;
		}

		private static GameObject SpawnItem(Item item, Vector3 position, Quaternion rotation)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			try
			{
				string text = "Items/" + ((Object)item).name;
				return (!SemiFunc.IsMultiplayer()) ? Object.Instantiate<GameObject>(item.prefab.Prefab, position, rotation) : PhotonNetwork.Instantiate(text, position, rotation, (byte)0, (object[])null);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("生成物品 " + item.itemName + " 时发生错误: " + ex.Message));
				return null;
			}
		}
	}
	internal class SpawnValueItemManager : MonoBehaviour
	{
		private readonly Random random = new Random();

		private static readonly ManualLogSource Logger = Logger.CreateLogSource("SpawnValueItem");

		private void Update()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigManager.isOpen.Value || !SemiFunc.RunIsLevel())
			{
				return;
			}
			Key value = ConfigManager.BindKeyValueItem.Value;
			if (((ButtonControl)Keyboard.current[value]).wasPressedThisFrame)
			{
				PrefabRef prefab = GetRandomValuablePrefab() ?? ((IEnumerable<PrefabRef>)Valuables.AllValuables).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef x) => ((Object)x.Prefab).name.Contains("money", StringComparison.OrdinalIgnoreCase)));
				SpawnItem(prefab);
			}
		}

		private void SpawnItem(PrefabRef prefab)
		{
			//IL_002e: 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_0047: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			ValuableObject val = ((prefab != null) ? prefab.Prefab.GetComponent<ValuableObject>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 val2 = ((Component)PlayerAvatar.instance).transform.position + new Vector3(0f, 1f, 0f) + ((Component)PlayerAvatar.instance).transform.forward * 2f;
				if (ConfigManager.ValueTop.Value < ConfigManager.ValueDown.Value)
				{
					val.valuePreset.valueMax = ConfigManager.ValueDown.Value;
					val.valuePreset.valueMin = ConfigManager.ValueTop.Value;
				}
				else
				{
					val.valuePreset.valueMax = ConfigManager.ValueTop.Value;
					val.valuePreset.valueMin = ConfigManager.ValueDown.Value;
				}
				if (ConfigManager.isDebug.Value)
				{
					Logger.LogInfo((object)$"当前随机的高价值物品:{((Object)val).name}、价值:{val.valuePreset}、物品类型:{val.volumeType}");
				}
				Valuables.SpawnValuable(prefab, val2, Quaternion.identity);
			}
		}

		private PrefabRef? GetRandomValuablePrefab()
		{
			if (Valuables.AllValuables == null || !Valuables.AllValuables.Any())
			{
				return null;
			}
			List<PrefabRef> source = Valuables.AllValuables.ToList();
			List<Type> list = ConfigManager.GetValueItemAllowedType();
			if (!list.Any())
			{
				Logger.LogInfo((object)"未开启高价值物品分类设置!将随机选择任意高价值物品");
				PrefabRef val = source.ElementAt(random.Next(source.Count()));
				ValuableObject component = val.Prefab.GetComponent<ValuableObject>();
				Logger.LogInfo((object)("选中的高价值物品:\n" + ((Object)component).name));
				return val;
			}
			List<PrefabRef> source2 = (from v in source.Select(delegate(PrefabRef value)
				{
					//IL_001a: Unknown result type (might be due to invalid IL or missing references)
					ValuableObject val4 = ((value != null) ? value.Prefab.GetComponent<ValuableObject>() : null);
					return list.Contains(val4.volumeType) ? value : null;
				})
				where v != null
				select v).ToList();
			if (ConfigManager.isDebug.Value)
			{
				int i = 1;
				List<string> values = source2.Select(delegate(PrefabRef v)
				{
					//IL_002a: Unknown result type (might be due to invalid IL or missing references)
					ValuableObject val3 = ((v != null) ? v.Prefab.GetComponent<ValuableObject>() : null);
					return $"[{i}]{((Object)val3).name}({val3.volumeType})";
				}).ToList();
				Logger.LogInfo((object)("所有的高价值物品:\n" + string.Join("\n", values)));
			}
			PrefabRef val2 = source2.ElementAt(random.Next(source2.Count()));
			ValuableObject component2 = val2.Prefab.GetComponent<ValuableObject>();
			Logger.LogInfo((object)("选中的高价值物品:\n" + ((Object)component2).name));
			return val2;
		}
	}
}