Decompiled source of InstantRevive v1.1.0

InstantRevive.dll

Decompiled 20 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InstantRevive")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InstantRevive")]
[assembly: AssemblyTitle("InstantRevive")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace InstantRevive
{
	[BepInPlugin("instantrevive.mod", "Instant Revive", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> ReviveWithHealth;

		internal static ConfigEntry<bool> ReviveInTruck;

		private readonly Harmony _harmony = new Harmony("instantrevive.mod");

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			ReviveWithHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Revive With Health", true, "Spieler erhalten volle HP beim Wiederbeleben am Extraction Point");
			ReviveInTruck = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Revive In Truck", false, "Tote Spieler werden auch im Truck automatisch wiederbelebt");
			Log.LogInfo((object)"Instant Revive 1.1.0 geladen!");
			_harmony.PatchAll();
		}
	}
	[HarmonyPatch(typeof(PlayerDeathHead))]
	internal class PlayerDeathHeadPatch
	{
		private static FieldInfo _roomVolumeCheckField = typeof(PlayerDeathHead).GetField("roomVolumeCheck", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo _inExtractionPointField = typeof(RoomVolumeCheck).GetField("inExtractionPoint", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo _inTruckField = typeof(RoomVolumeCheck).GetField("inTruck", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo _finalHealMethod = typeof(PlayerAvatar).GetMethod("FinalHeal", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		internal static void UpdatePatch(PlayerDeathHead __instance)
		{
			if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
			{
				return;
			}
			object? obj = _roomVolumeCheckField?.GetValue(__instance);
			RoomVolumeCheck val = (RoomVolumeCheck)((obj is RoomVolumeCheck) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool flag = (bool)(_inExtractionPointField?.GetValue(val) ?? ((object)false));
			bool flag2 = (bool)(_inTruckField?.GetValue(val) ?? ((object)false));
			if (flag)
			{
				__instance.Revive();
				if (Plugin.ReviveWithHealth.Value)
				{
					_finalHealMethod?.Invoke(__instance.playerAvatar, null);
				}
			}
			if (Plugin.ReviveInTruck.Value && flag2)
			{
				__instance.Revive();
				if (Plugin.ReviveWithHealth.Value)
				{
					_finalHealMethod?.Invoke(__instance.playerAvatar, null);
				}
			}
		}
	}
}