using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RevivePotion")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RevivePotion")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("be47d6c1-2612-46ea-bb4b-a7765861ef07")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RevivePotion;
[BepInPlugin("scriptova.revivepotion", "Revive Potion", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("REPO.exe")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "scriptova.revivepotion";
private const string modName = "Revive Potion";
private const string modVersion = "1.0.2";
internal static ManualLogSource mls;
private static Plugin Instance;
private AssetBundle assetBundle;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("scriptova.revivepotion");
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("scriptova.revivepotion");
assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "revivepotion"));
LoadRevivePotion();
val.PatchAll();
mls.LogInfo((object)"RevivePotion Mods are Onine.");
}
private void LoadRevivePotion()
{
GameObject val = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/RevivePotion/RevivePotion.prefab");
val.AddComponent<RevivePotion>();
RevivePotion component = val.GetComponent<RevivePotion>();
GameObject val2 = assetBundle.LoadAsset<GameObject>("Assets/REPO/Mods/RevivePotion/ReviveField.prefab");
val2.AddComponent<ReviveField>();
component.reviveField = val2;
Utilities.FixAudioMixerGroups(val2);
Item val3 = assetBundle.LoadAsset<Item>("Assets/REPO/Mods/RevivePotion/RevivePotion.asset");
val3.prefab = val;
Items.RegisterItem(val3);
mls.LogInfo((object)"Revive Potion Loaded!");
}
}
internal class RevivePotion : MonoBehaviour
{
public GameObject reviveField;
private void Start()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
if (SemiFunc.RunIsLevel() || SemiFunc.RunIsArena())
{
component.onDestroy.AddListener(new UnityAction(CreateReviveField));
}
else
{
component.destroyDisable = true;
}
}
private void CreateReviveField()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
NavMeshHit val = default(NavMeshHit);
if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 3f, -1))
{
Object.Instantiate<GameObject>(reviveField, ((NavMeshHit)(ref val)).position + new Vector3(0f, 0.05f, 0f), Quaternion.identity, ((Component)LevelGenerator.Instance).transform);
return;
}
RaycastHit[] array = Physics.RaycastAll(((Component)this).transform.position, Vector3.down, 20f);
RaycastHit[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
RaycastHit val2 = array2[i];
if (((Component)((RaycastHit)(ref val2)).collider).CompareTag("Wall"))
{
Object.Instantiate<GameObject>(reviveField, ((RaycastHit)(ref val2)).point + new Vector3(0f, 0.05f, 0f), Quaternion.identity, ((Component)LevelGenerator.Instance).transform);
return;
}
}
Object.Instantiate<GameObject>(reviveField, ((Component)this).transform.position, Quaternion.identity, ((Component)LevelGenerator.Instance).transform);
}
}
internal class ReviveField : MonoBehaviour
{
private float timer;
private PlayerHealth playerHealth;
private PlayerDeathHead playerDeathHead;
private FieldInfo maxHealth = AccessTools.Field(typeof(PlayerHealth), "maxHealth");
private FieldInfo inExtractionPoint = AccessTools.Field(typeof(PlayerDeathHead), "inExtractionPoint");
private FieldInfo deathHeadTriggered = AccessTools.Field(typeof(PlayerDeathHead), "triggered");
private void Start()
{
timer = 35f;
foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
{
if ((Object)(object)player != (Object)null && player.photonView.IsMine)
{
playerHealth = player.playerHealth;
playerDeathHead = player.playerDeathHead;
}
}
}
private void Update()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
timer -= Time.deltaTime;
if (timer <= 0f)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Vector3 val = ((Component)playerDeathHead).transform.position - ((Component)this).transform.position;
if (timer < 31f && ((Vector3)(ref val)).magnitude < 1.65f && (bool)deathHeadTriggered.GetValue(playerDeathHead) && !(bool)inExtractionPoint.GetValue(playerDeathHead))
{
inExtractionPoint.SetValue(playerDeathHead, true);
playerDeathHead.Revive();
playerHealth.HealOther((int)maxHealth.GetValue(playerHealth), true);
inExtractionPoint.SetValue(playerDeathHead, false);
}
}
}