Decompiled source of StealWeapon v1.0.0

StealWeapon.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("StealWeapon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StealWeapon")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("49f0a5f2-aea0-43f8-a5cd-61db498d2f5a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace StealWeapon;

[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerB_Patch
{
	[HarmonyPatch("SwitchToItemSlot")]
	[HarmonyPostfix]
	private static void SwitchToItemSlotPrefix(PlayerControllerB __instance, int slot, GrabbableObject fillSlotWithItem = null)
	{
		if (((NetworkBehaviour)__instance).IsOwner && (Object)(object)fillSlotWithItem != (Object)null)
		{
			ShotgunItem val = (ShotgunItem)(object)((fillSlotWithItem is ShotgunItem) ? fillSlotWithItem : null);
			if (val != null && ((GrabbableObject)val).isHeldByEnemy)
			{
				((GrabbableObject)val).DiscardItemFromEnemy();
				((GrabbableObject)val).isHeldByEnemy = false;
				((GrabbableObject)val).grabbableToEnemies = true;
				Plugin.Log.LogInfo((object)"夺取了胡桃夹子的枪");
			}
		}
	}
}
[BepInPlugin("qh3.StealWeapon", "StealWeapon", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static Plugin Instance;

	private static readonly Harmony harmony = new Harmony("qh3.StealWeapon");

	internal static ManualLogSource Log = Logger.CreateLogSource("qh3.StealWeapon");

	private void Awake()
	{
		Log.LogInfo((object)"Loading BigMap Mod");
		Instance = this;
		harmony.PatchAll(typeof(PlayerControllerB_Patch));
		harmony.PatchAll(typeof(NutcrackerEnemyAI_Patch));
	}
}
[HarmonyPatch(typeof(NutcrackerEnemyAI))]
internal static class NutcrackerEnemyAI_Patch
{
	[HarmonyPatch("GrabGun")]
	[HarmonyPostfix]
	private static void GrabGun_Postfix(NutcrackerEnemyAI __instance, GameObject gunObject)
	{
		((GrabbableObject)gunObject.GetComponent<ShotgunItem>()).grabbable = true;
		Plugin.Log.LogInfo((object)"设置胡桃夹子的枪可夺取");
	}
}