Decompiled source of BlowgunSpawner v1.0.1

BlowgunSpawner.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("blowgun")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("blowgun")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3818718f-40e2-402e-9af3-dae477d5a785")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.peak.blowgunonly", "Blowgun Spawner", "1.8.0")]
public class BlowgunSpawner : BaseUnityPlugin
{
	private string _status = "等待输入 (O键)...";

	private void Update()
	{
		if (PhotonNetwork.InRoom && !((Object)(object)Character.localCharacter == (Object)null) && Input.GetKeyDown((KeyCode)111))
		{
			ExecuteSpawnInHand();
		}
	}

	private void ExecuteSpawnInHand()
	{
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		string realName = "HealingDart Variant";
		Item val = ((IEnumerable<Item>)instance.itemLookup.Values).FirstOrDefault((Func<Item, bool>)((Item i) => (Object)(object)i != (Object)null && ((Object)i).name == realName));
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		try
		{
			CharacterItems items = Character.localCharacter.refs.items;
			MethodInfo method = ((object)items).GetType().GetMethod("SpawnItemInHand", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(items, new object[1] { ((Object)((Component)val).gameObject).name });
				_status = "成功:已通过系统原生方法生成至手中!";
			}
			else
			{
				_status = "错误:反射未找到 SpawnItemInHand 方法";
				ItemDatabase.Add(val, ((Component)Character.localCharacter).transform.position + Vector3.up);
			}
		}
		catch (Exception ex)
		{
			_status = "执行异常";
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
		}
	}

	private void OnGUI()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		if (PhotonNetwork.InRoom && (Object)(object)Character.localCharacter != (Object)null)
		{
			GUIStyle val = new GUIStyle();
			val.fontSize = 20;
			val.normal.textColor = Color.green;
			GUI.Label(new Rect(20f, 20f, 600f, 40f), "[吹箭筒原生生成] " + _status, val);
		}
	}
}