Decompiled source of Shotgun Snipers v1.0.1

SniperShotguns.dll

Decompiled a month ago
using System;
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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SniperShotguns")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SniperShotguns")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("082b1ac7-e734-433f-a460-b29b9c0fb395")]
[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")]
namespace SniperShotguns;

[BepInPlugin("altermodding.lethalcompany.snipershotguns", "Sniper Shotguns", "1.0.0.1")]
public class SniperShotguns : BaseUnityPlugin
{
	public const string pluginGuid = "altermodding.lethalcompany.snipershotguns";

	public const string pluginVersion = "1.0.0.1";

	public const string pluginName = "Sniper Shotguns";

	internal static ManualLogSource logger;

	public void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		logger = Logger.CreateLogSource("altermodding.lethalcompany.snipershotguns");
		logger.LogInfo((object)"Sniper Shotguns hath started!");
		Harmony val = new Harmony("altermodding.lethalcompany.snipershotguns");
		MethodInfo methodInfo = AccessTools.Method(typeof(ShotgunItem), "ShootGun", (Type[])null, (Type[])null);
		MethodInfo methodInfo2 = AccessTools.Method(typeof(SniperShotguns), "ShotgunItem_ShootGun_Prefix", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo methodInfo3 = AccessTools.Method(typeof(ShotgunItem), "Update", (Type[])null, (Type[])null);
		MethodInfo methodInfo4 = AccessTools.Method(typeof(SniperShotguns), "ShotgunItem_Update_Prefix", (Type[])null, (Type[])null);
		val.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	public static bool ShotgunItem_Update_Prefix(ref int ___shellsLoaded)
	{
		___shellsLoaded = 2;
		return true;
	}

	public static bool ShotgunItem_ShootGun_Prefix(Vector3 shotgunPosition, Vector3 shotgunForward, ref bool ___isReloading, ref bool ___isHeld, ref PlayerControllerB ___playerHeldBy, ref AudioSource ___gunShootAudio, ref AudioClip[] ___gunShootSFX, ref ParticleSystem ___gunShootParticle)
	{
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: 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_0173: Unknown result type (might be due to invalid IL or missing references)
		___isReloading = false;
		if (___isHeld && (Object)(object)___playerHeldBy != (Object)null && (Object)(object)___playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
		{
			___playerHeldBy.playerBodyAnimator.SetTrigger("ShootShotgun");
		}
		RoundManager.PlayRandomClip(___gunShootAudio, ___gunShootSFX, true, 0.2f, 1840, 1000);
		WalkieTalkie.TransmitOneShotAudio(___gunShootAudio, ___gunShootSFX[0], 1f);
		___gunShootParticle.Play(true);
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if ((Object)(object)localPlayerController == (Object)null)
		{
			return false;
		}
		logger.LogInfo((object)"Shot");
		RaycastHit val = default(RaycastHit);
		IHittable val2 = default(IHittable);
		if (Physics.Raycast(shotgunPosition, shotgunForward, ref val, 2000f, 11012424, (QueryTriggerInteraction)2) && ((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
		{
			logger.LogInfo((object)(((object)val2).GetType().ToString() + ", " + typeof(IHittable).ToString()));
			try
			{
				if (((object)val2).GetType() == typeof(PlayerControllerB))
				{
					PlayerControllerB component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<PlayerControllerB>();
					if ((Object)(object)component != (Object)null)
					{
						if ((Object)(object)component == (Object)(object)localPlayerController)
						{
							logger.LogInfo((object)"Stop shooting yourself dumbass");
						}
						else
						{
							component.KillPlayer(shotgunForward * 1000f, true, (CauseOfDeath)7, 0);
							logger.LogInfo((object)"Bonk :)");
						}
					}
					else
					{
						logger.LogInfo((object)"You shot a player but it doesn't have a PlayerControllerB (how)");
					}
				}
				else
				{
					EnemyAICollisionDetect component2 = ((Component)((RaycastHit)(ref val)).transform).GetComponent<EnemyAICollisionDetect>();
					if ((Object)(object)component2 == (Object)null)
					{
						logger.LogInfo((object)"You hit something but it sure as hell isn't an enemy or a player");
					}
					else
					{
						component2.mainScript.KillEnemy(false);
						logger.LogInfo((object)"Nice shot");
					}
				}
			}
			catch (Exception)
			{
				logger.LogInfo((object)"Error while shooting (womp womp)");
			}
		}
		else
		{
			logger.LogWarning((object)"YOU MISSED");
		}
		return false;
	}
}