Decompiled source of AlwaysSpawnDeadBody v1.0.0

AlwaysSpawnDeadBody/AlwaysSpawnDeadBody.dll

Decompiled 6 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
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("AlwaysSpawnDeadBody")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AlwaysSpawnDeadBody")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6b3efe0d-22c3-4733-95a8-dcda7dcd2cca")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AlwaysSpawnDeadBody;

[BepInPlugin("yazirushi.AlwaysSpawnDeadBody", "AlwaysSpawnDeadBody", "1.0.0")]
public class AlwaysSpawnDeadBody : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("yazirushi.AlwaysSpawnDeadBody");

	internal static ManualLogSource mls;

	public static ConfigEntry<bool> DebugLog;

	private void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log", false, new ConfigDescription("Whether to output debug logs", (AcceptableValueBase)null, Array.Empty<object>()));
		mls = ((BaseUnityPlugin)this).Logger;
		mls.LogInfo((object)"Starting AlwaysSpawnDeadBody...");
		harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
public class AlwaysSpawnDeadBody_patch_A
{
	private static void Prefix(ref bool spawnBody, ref int deathAnimation)
	{
		bool flag = false;
		if (AlwaysSpawnDeadBody.DebugLog.Value)
		{
			AlwaysSpawnDeadBody.mls.LogInfo((object)$"  DeadBodyInfo \nSpawnBody : {spawnBody} \nDeathAnimationType : {deathAnimation} ");
		}
		if (!spawnBody)
		{
			spawnBody = true;
			flag = true;
		}
		if (deathAnimation == 9)
		{
			deathAnimation = 0;
			flag = true;
		}
		if (flag && AlwaysSpawnDeadBody.DebugLog.Value)
		{
			AlwaysSpawnDeadBody.mls.LogInfo((object)"Patched DeadBody");
		}
	}
}
[HarmonyPatch(typeof(DeadBodyInfo), "DeactivateBody")]
public class AlwaysSpawnDeadBody_patch_B
{
	private static async void Postfix(DeadBodyInfo __instance)
	{
		await Task.Delay(4000);
		((Component)__instance).gameObject.SetActive(true);
		__instance.deactivated = false;
		__instance.SetBodyPartsKinematic(false);
		if (AlwaysSpawnDeadBody.DebugLog.Value)
		{
			AlwaysSpawnDeadBody.mls.LogInfo((object)"Stop the deactivation process");
		}
	}
}
[HarmonyPatch(typeof(DepositItemsDesk), "AnimationGrabPlayer")]
internal class AlwaysSpawnDeadBody_patch_C
{
	private static void Postfix(int playerID)
	{
		PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerID];
		if ((Object)(object)val?.deadBody != (Object)null)
		{
			((Component)val.deadBody).gameObject.SetActive(true);
			if (AlwaysSpawnDeadBody.DebugLog.Value)
			{
				AlwaysSpawnDeadBody.mls.LogInfo((object)"Reactivation DeadBody");
			}
		}
		else if (AlwaysSpawnDeadBody.DebugLog.Value)
		{
			AlwaysSpawnDeadBody.mls.LogWarning((object)"Not found DeadBody");
		}
	}
}