Decompiled source of ChilloutForcedPVP v1.1.0

plugins/ChilloutForcedPVP/ChilloutForcedPVP.dll

Decompiled 6 hours ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.UI;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ChilloutForcedPVP;

[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("chillout.forcedpvp", "Forced PVP", "1.1.0")]
public sealed class Plugin : BaseUnityPlugin
{
	public const string PluginGuid = "chillout.forcedpvp";

	public const string PluginName = "Forced PVP";

	public const string PluginVersion = "1.1.0";

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("chillout.forcedpvp").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"PVP is enforced with conflict-resistant patch ordering and no per-frame update loop.");
	}
}
[HarmonyPatch(typeof(Player), "SetPVP", new Type[] { typeof(bool) })]
internal static class ForceSetPvpPatch
{
	[HarmonyPriority(0)]
	private static void Prefix(ref bool enabled)
	{
		enabled = true;
	}
}
[HarmonyPatch(typeof(Player), "IsPVPEnabled")]
internal static class ForceIsPvpEnabledPatch
{
	[HarmonyPriority(0)]
	private static void Postfix(ref bool __result)
	{
		__result = true;
	}
}
[HarmonyPatch(typeof(Player), "CanSwitchPVP")]
internal static class PreventPvpSwitchPatch
{
	[HarmonyPriority(0)]
	private static void Postfix(ref bool __result)
	{
		__result = false;
	}
}
[HarmonyPatch(typeof(InventoryGui), "OnEnable")]
internal static class ForcePvpToggleVisualPatch
{
	[HarmonyPriority(0)]
	private static void Postfix(InventoryGui __instance)
	{
		if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.m_pvp != (Object)null)
		{
			__instance.m_pvp.SetIsOnWithoutNotify(true);
			((Selectable)__instance.m_pvp).interactable = false;
		}
	}
}
[HarmonyPatch(typeof(Player), "OnSpawned", new Type[] { typeof(bool) })]
internal static class ForcePvpOnSpawnPatch
{
	[HarmonyPriority(0)]
	private static void Postfix(Player __instance)
	{
		if ((Object)(object)__instance != (Object)null)
		{
			__instance.SetPVP(true);
		}
	}
}