Decompiled source of Friendly Fire Guns v1.1.0

PopyModFriendlyFireGuns.dll

Decompiled 4 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using On;
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: AssemblyTitle("PopyModFriendlyFireGuns")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PopyModFriendlyFireGuns")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2de51f47-166c-4498-b889-24f0f703e4f1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace PopyModFriendlyFireGuns
{
	[BepInPlugin("PopyMod.FriendlyFireGuns", "FriendlyFireGuns", "1.1.0")]
	public class PopyModFriendlyFireGuns : BaseUnityPlugin
	{
		private const string modGUID = "PopyMod.FriendlyFireGuns";

		private const string modName = "FriendlyFireGuns";

		private const string modVersion = "1.1.0";

		internal static ManualLogSource Log;

		internal bool FriendlyFireGuns = false;

		internal string PlayerNameClient = null;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			Log = Logger.CreateLogSource("PopyMod.FriendlyFireGuns");
			Log.LogWarning((object)"\r\n    ______.        PopyMod\r\n  ~(_]----'   Friendly Fire Guns\r\n  /_(           1.1.0  loaded");
			PardnerEquipment_BullwormRifle.OnUse += new hook_OnUse(PlayerKiller);
			PardnerEquipment_BullwormRifle.OnEquipmentDepleted += new hook_OnEquipmentDepleted(InfiniteGun);
			PardnerEquipment_BullwormRifle.Update += new hook_Update(UpdateCode);
			PardnerEquipment_BullwormRifle.OnNetworkSpawn += new hook_OnNetworkSpawn(OnNetworkSpawnCode);
		}

		private void PlayerKiller(orig_OnUse orig, PardnerEquipment_BullwormRifle self)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			((PardnerEquipment)self).hasCooldown = true;
			if (((PardnerEquipment)self).cooldownReady)
			{
				((PardnerEquipment)self).cooldown_Curr = ((PardnerEquipment)self).cooldown;
				orig.Invoke(self);
				((PardnerEquipment)self).equipmentType = (EquipmentType)2;
				if (!FriendlyFireGuns)
				{
					return;
				}
				Vector3 val = ((PardnerEquipment)self).aimSpotOnUse - ((PardnerEquipment)self).cameraPositionOnUse;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(new Ray(((PardnerEquipment)self).cameraPositionOnUse, normalized), ref val2, 1000f, -1, (QueryTriggerInteraction)1) && ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer == 8)
				{
					Player component = ((Component)((PardnerEquipment)self).grabberScriptOfWhoHasUsEquipped).GetComponent<Player>();
					Player componentInParent = ((Component)((RaycastHit)(ref val2)).collider).gameObject.GetComponentInParent<Player>();
					Log.LogDebug((object)("Raycast hit: " + (object)componentInParent));
					if (((NetworkBehaviour)component).IsLocalPlayer)
					{
						PlayerNameClient = component.playerDisplayName;
					}
					if (!((NetworkBehaviour)componentInParent).IsLocalPlayer)
					{
						componentInParent.KillPlayer(true, (LastCauseOfDeath)1, 1000000uL);
						string playerDisplayName = componentInParent.playerDisplayName;
						string text = "</color></color></color></color></color>";
						string s = "Pardner " + PlayerNameClient + text + " <#CA1433>shot</color> Pardner " + playerDisplayName;
						EventFeedManager.Singleton.AddANewEventFeedPopUp_ServerRPC(Encoding.UTF8.GetBytes(s), (byte)0);
					}
					else
					{
						Log.LogDebug((object)"You hit yourself");
					}
				}
			}
			else
			{
				Log.LogDebug((object)("Gun is on cooldown for: " + ((PardnerEquipment)self).cooldown_Curr));
			}
		}

		private void InfiniteGun(orig_OnEquipmentDepleted orig, PardnerEquipment_BullwormRifle self)
		{
			if (FriendlyFireGuns)
			{
				Log.LogDebug((object)"Stoped gun from Depleting");
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void UpdateCode(orig_Update orig, PardnerEquipment_BullwormRifle self)
		{
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			CheatsManager component = GameObject.Find("_GameManager (+ HeartJar Manager) (+ ChatBox Manager)").GetComponent<CheatsManager>();
			if (component.cheatsEnabled.Value)
			{
				if (!FriendlyFireGuns)
				{
					FriendlyFireGuns = !FriendlyFireGuns;
					Log.LogDebug((object)("FriendlyFireGuns: " + FriendlyFireGuns));
					GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
					foreach (GameObject val in array)
					{
						if (((Object)val.transform).name == "Player_Pardner(Clone)")
						{
							Log.LogDebug((object)val);
							((Component)val.transform.GetChild(26)).gameObject.SetActive(false);
						}
					}
				}
				((PardnerEquipment)self).hasCooldown = true;
				((PardnerEquipment)self).cooldown = 3f;
				self.pardnerPushBackForce = 0f;
			}
			else if (!component.cheatsEnabled.Value && FriendlyFireGuns)
			{
				if (FriendlyFireGuns)
				{
					FriendlyFireGuns = !FriendlyFireGuns;
					Log.LogDebug((object)("FriendlyFireGuns: " + FriendlyFireGuns));
					GameObject[] array2 = GameObject.FindGameObjectsWithTag("Player");
					foreach (GameObject val2 in array2)
					{
						if (((Object)val2.transform).name == "Player_Pardner(Clone)")
						{
							Log.LogDebug((object)val2);
							((Component)val2.transform.GetChild(26)).gameObject.SetActive(true);
						}
					}
				}
				self.pardnerPushBackForce = 25f;
			}
			if (((PardnerEquipment)self).hasCooldown)
			{
				if (((PardnerEquipment)self).cooldown_Curr > 0f)
				{
					((PardnerEquipment)self).cooldown_Curr = ((PardnerEquipment)self).cooldown_Curr - Time.deltaTime;
					((PardnerEquipment)self).cooldownReady = false;
					Log.LogDebug((object)("cooldown_Curr: " + ((PardnerEquipment)self).cooldown_Curr));
				}
				else
				{
					((PardnerEquipment)self).cooldownReady = true;
					((PardnerEquipment)self).equipmentType = (EquipmentType)1;
				}
			}
		}

		private void OnNetworkSpawnCode(orig_OnNetworkSpawn orig, PardnerEquipment_BullwormRifle self)
		{
			orig.Invoke(self);
			((PardnerEquipment)self).hasCooldown = true;
		}
	}
}