using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod Dev")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod Dev")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d02ce5b2-2aba-4217-94fe-197a209d10d4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoReviveMod;
[BepInPlugin("autorevive", "Auto Revive", "1.0.1")]
public class AutoRevivePlugin : BaseUnityPlugin
{
public static ManualLogSource log;
public static ConfigEntry<float> ReviveTimeConfig;
public static ConfigEntry<bool> RevivePostDebuffConfig;
private static float ReviveTime;
private static float _deathTimer;
private static bool _reviveTriggered;
private TextMeshProUGUI reviveText;
private TextMeshProUGUI reviveCountdownText;
private Canvas canvas;
private int _lastRemainingSeconds = -1;
private void Awake()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
ReviveTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ReviveTime", 120f, "Time(second) needed to automatically revive player. Minimum 15 seconds, if set below 15, it will be 15 by default.");
RevivePostDebuffConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnablePostDebuff", true, "Whether to apply debuff(curse and hunger) after revival");
if (ReviveTimeConfig.Value < 15f)
{
ReviveTime = 15f;
}
else
{
ReviveTime = ReviveTimeConfig.Value;
}
Harmony val = new Harmony("autorevive");
val.PatchAll();
log = ((BaseUnityPlugin)this).Logger;
log.LogInfo((object)"Auto Revive on");
CreateReviveHintUI();
((MonoBehaviour)this).StartCoroutine(WaitGame2LoadFont());
}
private void Update()
{
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Character.localCharacter == (Object)null || (Object)(object)Character.localCharacter.data == (Object)null)
{
ResetTimerUI();
}
else if (Character.localCharacter.data.dead)
{
_deathTimer += Time.deltaTime;
if (!((Behaviour)reviveText).enabled)
{
((Behaviour)reviveText).enabled = true;
}
float num = ReviveTime - _deathTimer;
num = Mathf.Max(0f, num);
int num2 = Mathf.CeilToInt(num);
if (num2 != _lastRemainingSeconds)
{
_lastRemainingSeconds = num2;
int num3 = Mathf.FloorToInt(num / 60f);
int num4 = Mathf.FloorToInt(num % 60f);
if (num <= 10f)
{
((Graphic)reviveText).color = Color.red;
((TMP_Text)reviveText).text = "REVIVE IMMINENT";
}
else if (num <= 30f)
{
((Graphic)reviveText).color = Color.yellow;
((TMP_Text)reviveText).text = $"REVIVE IN {num3:00}:{num4:00}";
}
else
{
((Graphic)reviveText).color = Color.white;
((TMP_Text)reviveText).text = $"You Died. {num3:00}:{num4:00} Before Revive";
}
}
if (num <= 10f)
{
float num5 = 1f + Mathf.Sin(Time.time * 6f) * 0.05f;
((TMP_Text)reviveText).transform.localScale = Vector3.one * num5;
}
else
{
((TMP_Text)reviveText).transform.localScale = Vector3.one;
}
if (num <= 10f && num > 0f)
{
if (!((Behaviour)reviveCountdownText).enabled)
{
((Behaviour)reviveCountdownText).enabled = true;
}
((TMP_Text)reviveCountdownText).text = num2.ToString();
float num6 = num % 1f;
float num7 = Mathf.Lerp(1f, 3f, num6);
((TMP_Text)reviveCountdownText).transform.localScale = Vector3.one * num7;
float num8 = Mathf.Lerp(0f, 0.4f, num6);
((Graphic)reviveCountdownText).color = new Color(1f, 0f, 0f, num8);
}
else if (((Behaviour)reviveCountdownText).enabled)
{
((Behaviour)reviveCountdownText).enabled = false;
}
if (_deathTimer >= ReviveTime && !_reviveTriggered)
{
_reviveTriggered = true;
ReviveLocalPlayer();
}
}
else
{
ResetTimerUI();
}
}
private bool IsValidReviveTarget(Character character, Character local)
{
if ((Object)(object)character == (Object)null)
{
return false;
}
if ((Object)(object)character == (Object)(object)local)
{
return false;
}
if ((Object)(object)character.data == (Object)null)
{
return false;
}
if (character.data.dead)
{
return false;
}
if (character.data.fullyPassedOut)
{
return false;
}
return true;
}
private Character FindReviveTarget(Character local)
{
if ((Object)(object)local.Ghost != (Object)null && (Object)(object)local.Ghost.m_target != (Object)null)
{
Character target = local.Ghost.m_target;
if (IsValidReviveTarget(target, local))
{
return target;
}
}
foreach (Character allCharacter in Character.AllCharacters)
{
if (IsValidReviveTarget(allCharacter, local))
{
return allCharacter;
}
}
return null;
}
private void ReviveLocalPlayer()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
Character localCharacter = Character.localCharacter;
if (!((Object)(object)localCharacter == (Object)null) && ((MonoBehaviourPun)localCharacter).photonView.IsMine)
{
Character val = FindReviveTarget(localCharacter);
if (!((Object)(object)val == (Object)null))
{
Vector3 val2 = val.Center + Vector3.up * 1.5f + Vector3.back * 1.5f;
((MonoBehaviourPun)localCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val2, RevivePostDebuffConfig.Value, -1 });
}
}
}
private void ApplyGameFont()
{
TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
TMP_FontAsset[] array2 = array;
foreach (TMP_FontAsset val in array2)
{
if (((Object)val).name == "DarumaDropOne-Regular SDF")
{
((TMP_Text)reviveText).font = val;
return;
}
}
log.LogWarning((object)"No game font found, use unity built-in font only");
}
private IEnumerator WaitGame2LoadFont()
{
yield return (object)new WaitForSeconds(8f);
ApplyGameFont();
}
private void CreateReviveHintUI()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Expected O, but got Unknown
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("AutoReviveCanvas");
canvas = val.AddComponent<Canvas>();
canvas.renderMode = (RenderMode)0;
Object.DontDestroyOnLoad((Object)(object)val);
GameObject val2 = new GameObject("ReviveText");
val2.transform.SetParent(val.transform);
reviveText = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)reviveText).fontSize = 36f;
((TMP_Text)reviveText).alignment = (TextAlignmentOptions)514;
((TMP_Text)reviveText).text = "";
((Behaviour)reviveText).enabled = false;
RectTransform component = ((Component)reviveText).GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.8f);
component.anchorMax = new Vector2(0.5f, 0.8f);
component.anchoredPosition = Vector2.zero;
component.sizeDelta = new Vector2(600f, 100f);
GameObject val3 = new GameObject("CountdownText");
val3.transform.SetParent(val.transform);
reviveCountdownText = val3.AddComponent<TextMeshProUGUI>();
((TMP_Text)reviveCountdownText).fontSize = 250f;
((TMP_Text)reviveCountdownText).alignment = (TextAlignmentOptions)514;
((TMP_Text)reviveCountdownText).fontStyle = (FontStyles)1;
((TMP_Text)reviveCountdownText).text = "";
((Behaviour)reviveCountdownText).enabled = false;
RectTransform component2 = ((Component)reviveCountdownText).GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.5f, 0.5f);
component2.anchorMax = new Vector2(0.5f, 0.5f);
component2.anchoredPosition = Vector2.zero;
component2.sizeDelta = new Vector2(800f, 800f);
}
private void ResetTimerUI()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
_deathTimer = 0f;
_reviveTriggered = false;
_lastRemainingSeconds = -1;
if ((Object)(object)reviveText != (Object)null && ((Behaviour)reviveText).enabled)
{
((TMP_Text)reviveText).text = "";
((Behaviour)reviveText).enabled = false;
((TMP_Text)reviveText).transform.localScale = Vector3.one;
}
if ((Object)(object)reviveCountdownText != (Object)null && ((Behaviour)reviveCountdownText).enabled)
{
((TMP_Text)reviveCountdownText).text = "";
((Behaviour)reviveCountdownText).enabled = false;
}
}
[HarmonyPatch(typeof(GlobalEvents), "TriggerRunEnded")]
[HarmonyPostfix]
public static void OnRunEnded()
{
_deathTimer = 0f;
}
}