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 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("ComaProtect")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+dd9c94a86ca5eec789df6bf8d9a85fa3cd41418b")]
[assembly: AssemblyProduct("ComaProtect")]
[assembly: AssemblyTitle("ComaProtect")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ABUF.ComaProtect
{
[BepInPlugin("abuf.comaprotect", "Coma Protection", "1.0.1")]
public sealed class Plugin : BaseUnityPlugin
{
public const string Guid = "abuf.comaprotect";
public const string PluginName = "Coma Protection";
public const string PluginVersion = "1.0.1";
public static ManualLogSource Log;
public static ConfigEntry<bool> Enabled;
private static readonly Harmony Harmony = new Harmony("abuf.comaprotect");
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("昏迷保护", "启用", true, "倒地昏迷时死亡倒计时不再自然累积。长按 E 主动放弃仍然有效。");
Harmony.PatchAll();
Log.LogInfo((object)("Coma Protection 1.0.1 loaded. enabled=" + Enabled.Value));
}
private void OnDestroy()
{
Harmony.UnpatchSelf();
}
}
[HarmonyPatch(typeof(Character), "UpdateVariablesFixed")]
internal static class ComaProtectPatch
{
[HarmonyPrefix]
private static void Prefix(Character __instance, out float __state)
{
__state = 0f;
if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.data != (Object)null && __instance.IsLocal)
{
__state = __instance.data.deathTimer;
}
}
[HarmonyPostfix]
private static void Postfix(Character __instance, float __state)
{
if (Plugin.Enabled.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.data == (Object)null) && __instance.IsLocal && __instance.data.fullyPassedOut && !((Object)(object)__instance.data.carrier != (Object)null) && (!((Object)(object)__instance.input != (Object)null) || !__instance.input.interactIsPressed))
{
__instance.data.deathTimer = Mathf.Max(__state, __instance.data.deathTimer);
__instance.data.deathTimer = __state;
}
}
}
}