Decompiled source of NPCMurder v0.0.1

Murder.dll

Decompiled 2 years ago
using System;
using System.Diagnostics;
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 Unity.Netcode;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Murder")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("Murder")]
[assembly: AssemblyTitle("Murder")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 Murder
{
	[BepInPlugin("xuthics.murder", "Murder", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerInteraction), "InteractionRay")]
		private class InteractionRayPatch
		{
			private static void Postfix(PlayerInteraction __instance)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//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_004f: 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_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Unknown result type (might be due to invalid IL or missing references)
				FieldInfo field = typeof(PlayerInteraction).GetField("mainCamera", BindingFlags.Instance | BindingFlags.NonPublic);
				Camera val = (Camera)field.GetValue(__instance);
				NetworkManager singleton = NetworkManager.Singleton;
				PlayerInventory component = ((Component)singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
				Vector3 position = ((Component)val).transform.position;
				Vector3 forward = ((Component)val).transform.forward;
				CustomerController[] array = Object.FindObjectsOfType<CustomerController>();
				CustomerController[] array2 = array;
				Vector3 val4 = default(Vector3);
				foreach (CustomerController val2 in array2)
				{
					Vector3 position2 = ((Component)val2).transform.position;
					float num = Vector3.Distance(position, position2);
					if (!(num <= __instance.interactionDistance))
					{
						continue;
					}
					Vector3 val3 = position2 - position;
					float num2 = Vector3.Angle(forward, val3);
					if (!(num2 < 45f))
					{
						continue;
					}
					PlayerActions player = InputManager.Instance.inputMaster.Player;
					if (((PlayerActions)(ref player)).Put.WasPerformedThisFrame())
					{
						ItemSO currentItemSO = component.GetCurrentItemSO();
						if (currentItemSO.id == 1726692805238L)
						{
							component.ReduceCurrentItemAmount();
							float num3 = 1f;
							float num4 = Random.Range(0f, (float)Math.PI * 2f);
							float num5 = Random.Range(1f, 1.5f);
							((Vector3)(ref val4))..ctor(Mathf.Cos(num4) * num3, num5, Mathf.Sin(num4) * num3);
							float value = Random.value;
							int num6 = ((!(value < 0.3f)) ? 1 : 0);
							long num7 = meatIds[num6];
							int num8 = meatAmounts[num6];
							GameManager.Instance.SpawnItemAtPositionServerRpc(num7, ((Component)val2).transform.position + val4, true, num8, 30, 0);
							GameManager.Instance.IncrementReputationServer(-10);
							Object.Destroy((Object)(object)((Component)val2).gameObject);
						}
					}
				}
			}
		}

		internal static ManualLogSource Logger;

		private Harmony m_harmony = new Harmony("xuthics.murder");

		private static long[] meatIds = new long[2] { 1725831514152L, 1725566767230L };

		private static int[] meatAmounts = new int[2] { 1, 4 };

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin Murder v0.0.1 is loaded!");
			m_harmony.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Murder";

		public const string PLUGIN_NAME = "Murder";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}