Decompiled source of FightMeBro v1.0.0

FightMeBro.dll

Decompiled 2 months ago
using System;
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 BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FightMeBro")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FightMeBro")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f4e054cb-55b5-457e-b63b-5d81aad45f96")]
[assembly: AssemblyFileVersion("1.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]
[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 FightMeBro
{
	public class PluginConfig
	{
		public static ConfigEntry<bool> IsModEnabled { get; private set; }

		public static void BindConfig(ConfigFile config)
		{
			IsModEnabled = config.Bind<bool>("Global", "isModEnabled", true, "Globally enable or disable this mod.");
		}
	}
	[BepInPlugin("EardwulfC.valheim.FightMeBro", "FightMeBro", "1.0.0")]
	public sealed class FightMeBro : BaseUnityPlugin
	{
		public const string PluginGuid = "EardwulfC.valheim.FightMeBro";

		public const string PluginName = "FightMeBro";

		public const string PluginVersion = "1.0.0";

		private Harmony _harmony;

		private void Awake()
		{
			PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "EardwulfC.valheim.FightMeBro");
		}
	}
	internal class InventoryGUIPatches
	{
		[HarmonyPatch(typeof(InventoryGui))]
		private static class GuiPVPPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("UpdateCharacterStats")]
			private static void GuiPVPUpdater(InventoryGui __instance)
			{
				if (Object.op_Implicit((Object)(object)InventoryGui.m_instance) && PluginConfig.IsModEnabled.Value)
				{
					__instance.m_pvp.isOn = true;
				}
			}
		}
	}
	internal class PlayerPatches
	{
		[HarmonyPatch(typeof(Player))]
		private static class PlayerPvPPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("OnSpawned")]
			private static void PVPUpdaterPostfix(Player __instance)
			{
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && PluginConfig.IsModEnabled.Value)
				{
					__instance.SetPVP(true);
					((Terminal)Chat.m_instance).AddString("<color=red>You are now flagged for PVP!</color>");
				}
			}
		}
	}
}