using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("P-Rank_Module")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("P-Rank_Module")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("59727b2f-361f-4e85-9939-3e9a43fb6b45")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace P_Rank_Module;
[BepInPlugin("ultrakill.exmagikguy.prankAssist", "P-Rank Module", "1.0.0")]
public class Module_Main : BaseUnityPlugin
{
[Configgable("Settings", "Disable Checkpoints", 0, "Enable or disable checkpoints.")]
public static bool disableCheckpoints = true;
[Configgable("Settings", "Additional P-Rank UI", 1, "Enable or disable New P-Rank UI, that shows time, kills and style left until P-Rank.")]
public static bool PRank_UI = true;
[Configgable("Settings", "Stop Timer Upon Collecting Every Kill", 2, "Enable or disable stopping the timer, when all kills are collected.")]
public static bool timerStop_OnSInKills = true;
public static ConfigBuilder ConfigMenu;
public static bool[] checkList = new bool[3];
public static int waitVar = 60;
public static string oldProgLog = "";
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
ConfigMenu = new ConfigBuilder("ultrakill.exmagikguy.prankAssist", "P-Rank Module");
ConfigMenu.BuildType(typeof(Module_Main));
}
private void Start()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Modded V1 Modules: P-Rank Functions Initiated.");
SceneManager.sceneLoaded += OnSceneLoad;
}
private void OnSceneLoad(Scene scene, LoadSceneMode mode)
{
waitVar = 60;
checkList[0] = false;
checkList[1] = false;
checkList[2] = false;
}
private void Update()
{
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Expected O, but got Unknown
if (waitVar > -1)
{
waitVar--;
if (waitVar < 2 && (Object)(object)MonoSingleton<GunControl>.Instance == (Object)null)
{
waitVar = 60;
}
return;
}
if (disableCheckpoints && !checkList[0])
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"P-Rank Module: Task \"Disable Checkpoints\" not completed. Completing...");
CheckPoint[] array = Object.FindObjectsOfType<CheckPoint>();
CheckPoint[] array2 = array;
foreach (CheckPoint val in array2)
{
((Component)val).gameObject.SetActive(false);
}
CheckPoint[] array3 = Object.FindObjectsOfType<CheckPoint>();
int num = array3.Length;
int num2 = 0;
CheckPoint[] array4 = array3;
foreach (CheckPoint val2 in array4)
{
if (!((Component)val2).gameObject.activeSelf)
{
num2++;
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"P-Rank Module: Actions done. Checking...");
if (num2 >= num)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"P-Rank Module: Task \"Disable Checkpoints\" completed.");
checkList[0] = true;
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"P-Rank Module: Task \"Disable Checkpoints\" is still uncomplete.");
}
}
if (!PRank_UI && !timerStop_OnSInKills)
{
return;
}
StatsManager instance = MonoSingleton<StatsManager>.Instance;
float num3 = instance.timeRanks[instance.timeRanks.Length - 1];
int num4 = instance.styleRanks[instance.styleRanks.Length - 1];
int num5 = instance.killRanks[instance.killRanks.Length - 1];
int count = MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies().Count;
double num6 = Math.Round(num3 - instance.seconds);
int num7 = (int)num6;
int num8 = num5 - instance.kills;
int num9 = num4 - instance.stylePoints;
if (num7 < 0)
{
num7 = 0;
}
if (num8 < 0)
{
num8 = 0;
}
if (num9 < 0)
{
num9 = 0;
}
if (PRank_UI)
{
string text = $"Time Left: {num7}; \nKills Left: {num8} (Room: {count}); \nStyle Left {num9}";
if (num7 == 0 || (num8 == 0 && num9 > 0 && num5 > 0) || (num5 < 1 && num9 < num4 && count < 1 && num9 > 0))
{
text = "<color=#FF0000>P-RANK FAILED!</color>";
}
else if (count < 1 && (num8 == 0 || num5 < 1) && num9 == 0 && (!instance.timer || !timerStop_OnSInKills))
{
text = "<color=green>P-RANK COMPLETED!</color>";
}
HudMessageReceiver instance2 = MonoSingleton<HudMessageReceiver>.Instance;
if (!checkList[1] && (Object)(object)instance2 != (Object)null && (oldProgLog != num7.ToString() || text == "<color=#FF0000>P-RANK FAILED!</color>" || text == "<color=green>P-RANK COMPLETED!</color>"))
{
FieldInfo field = typeof(HudMessageReceiver).GetField("aud", BindingFlags.Instance | BindingFlags.NonPublic);
AudioSource val3 = (AudioSource)field.GetValue(instance2);
val3.mute = true;
instance2.SendHudMessage(text, "", "", 0, true, false, true);
oldProgLog = num7.ToString();
if (text == "<color=#FF0000>P-RANK FAILED!</color>" || text == "<color=green>P-RANK COMPLETED!</color>")
{
checkList[1] = true;
}
}
}
if (num8 == 0 && count < 1 && timerStop_OnSInKills && instance.timer && num5 > 0 && !checkList[2])
{
instance.StopTimer();
checkList[2] = true;
}
}
}