Decompiled source of NoFriendlyFire v1.0.0

NoFriendlyFire.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("NoFriendlyFire")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Disables the ability for teammates to damage each-other.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3dd114ce725e4bf8b6c1674e7a23d5326e84fcd7")]
[assembly: AssemblyProduct("NoFriendlyFire")]
[assembly: AssemblyTitle("NoFriendlyFire")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 NoFriendlyFire
{
	[BepInPlugin("NoFriendlyFire", "NoFriendlyFire", "1.0.0")]
	public class NoFriendlyFire : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("NoFriendlyFire");

		public static ManualLogSource LoggerInstance { get; private set; }

		private void Awake()
		{
			LoggerInstance = ((BaseUnityPlugin)this).Logger;
			LoggerInstance.LogInfo((object)"Plugin NoFriendlyFire loaded successfully.");
			_harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NoFriendlyFire";

		public const string PLUGIN_NAME = "NoFriendlyFire";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace NoFriendlyFire.Patches
{
	[HarmonyPatch]
	internal class NoFriendlyFireDamagePatch
	{
		[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayerFromOtherClientServerRpc")]
		[HarmonyPrefix]
		public static void DamagePlayerFromOtherClientServerRpc(ref int damageAmount, Vector3 hitDirection, int playerWhoHit)
		{
			NoFriendlyFire.LoggerInstance.LogDebug((object)$"Player{playerWhoHit} attempted to friendly fire, setting damage amount to 0.");
			damageAmount = 0;
		}
	}
}