using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using PEAKroyale;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PEAKroyale")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PEAKroyale")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("83243601-f6b1-468b-a0e9-3820bb3b9331")]
[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")]
[BepInPlugin("com.Mechanator.RespawnAutoAlways", "PEAKRoyale", "1.0.0")]
public class StarterPlugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"MODLINE INITIATED!");
Debug.Log((object)"MODLINE DEBUG INITIATED");
Harmony val = new Harmony("com.Mechanator.RespawnAutoAlways");
val.PatchAll();
DeathcountUISummoner.Initialize();
}
private void update()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"MODLINE Continuing!");
}
}
namespace PEAKroyale;
internal class PRVars : MonoBehaviourPunCallbacks
{
public int timesDied = 0;
private void addDeaths(int num)
{
timesDied += num;
}
}
internal class DeathcountUI : MonoBehaviour
{
private Canvas canvas;
private TextMeshProUGUI names;
private TextMeshProUGUI deathcounts;
private int leaderboardPosX = 23;
private int leaderboardPosY = -60;
private void Awake()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)this).gameObject;
canvas = gameObject.AddComponent<Canvas>();
canvas.renderMode = (RenderMode)0;
CanvasScaler val = ((Component)canvas).gameObject.AddComponent<CanvasScaler>();
val.uiScaleMode = (ScaleMode)1;
val.referenceResolution = new Vector2(1920f, 1080f);
Object[] array = Resources.FindObjectsOfTypeAll(typeof(Material));
Object[] array2 = array;
Debug.Log((object)"[RaceToThePeak] UI DATA LOADING, OBJECT CREATED!");
InitializeUI();
}
private void InitializeUI()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0032: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
GameObject val = new GameObject("LeaderboardUI");
val.transform.SetParent(((Component)canvas).transform, false);
names = val.AddComponent<TextMeshProUGUI>();
Vector3 anchoredPos = new Vector3
{
x = leaderboardPosX,
y = leaderboardPosY
};
((TMP_Text)names).text = "";
SetupText(names, anchoredPos);
((TMP_Text)names).fontSize = 18f;
GameObject val2 = new GameObject("TroopUI");
val2.transform.SetParent(((Component)canvas).transform, false);
}
public static void SetupText(TextMeshProUGUI text, Vector3 anchoredPos)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
RectTransform rectTransform = ((TMP_Text)text).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 1f);
rectTransform.anchorMax = new Vector2(0f, 1f);
rectTransform.pivot = new Vector2(0f, 1f);
((Transform)rectTransform).position = ((Transform)rectTransform).position + anchoredPos;
rectTransform.sizeDelta = new Vector2(500f, 500f);
((TMP_Text)text).alignment = (TextAlignmentOptions)257;
}
private void LateUpdate()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if ((Object)Character.localCharacter == (Object)null)
{
Debug.Log((object)"[RaceToThePeak] the Local Character has not been loaded yet");
}
else
{
updateScoreboard();
}
}
private void updateScoreboard()
{
int num = 0;
foreach (Character allCharacter in Character.AllCharacters)
{
if (allCharacter.IsPlayerControlled)
{
num++;
}
}
string[] array = new string[num * 2];
int num2 = 0;
foreach (Character allCharacter2 in Character.AllCharacters)
{
if (allCharacter2.IsPlayerControlled)
{
array[num2] = allCharacter2.characterName;
num2++;
PRVars component = ((Component)allCharacter2).GetComponent<PRVars>();
array[num2] = component.timesDied.ToString();
num2++;
}
}
Debug.Log((object)("All Players & Deaths " + string.Join(" \n", array)));
((TMP_Text)names).text = string.Join(" \n", array);
}
}
internal class DeathcountUISummoner
{
private static GameObject deathcountUI;
public static void Initialize()
{
Debug.Log((object)"[RaceToThePeak] TimerHandler was started");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_00b6: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
Scene val = scene;
if (!(((Scene)(ref val)).name == "Airport"))
{
val = scene;
if (!((Scene)(ref val)).name.ToLower().StartsWith("level_"))
{
deathcountUI = new GameObject();
return;
}
}
Debug.Log((object)"[RaceToThePeak] Starting Counter");
deathcountUI = new GameObject("deathcountUI");
RectTransform val2 = deathcountUI.AddComponent<RectTransform>();
val2.anchorMin = new Vector2(0f, 1f);
val2.anchorMax = new Vector2(0f, 1f);
val2.pivot = new Vector2(0f, 1f);
deathcountUI.AddComponent<DeathcountUI>();
}
}
public static class CampfireTracker
{
public static Vector3? LastCampfirePosition
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected I4, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
int num = (int)Singleton<MapHandler>.Instance.GetCurrentSegment();
if (num == 5)
{
return Singleton<MapHandler>.Instance.respawnThePeak.position;
}
return Singleton<MapHandler>.Instance.segments[num].reconnectSpawnPos.position;
}
}
}
[HarmonyPatch]
public static class Patch
{
[HarmonyPatch(typeof(Character))]
public static class CharacterPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
if (!CampfireTracker.LastCampfirePosition.HasValue || !PhotonNetwork.IsMasterClient || Time.time - lastRespawnTime < 5f)
{
return;
}
lastRespawnTime = Time.time;
float num = Random.Range(-3f, 3f);
float num2 = Random.Range(-3f, 3f);
Vector3 value = CampfireTracker.LastCampfirePosition.Value;
((Vector3)(ref value))..ctor(value.x + num, value.y + 1f, value.z + num2);
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter != (Object)null && allCharacter.data.dead)
{
((MonoBehaviourPun)allCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)3, new object[3] { value, false, -1 });
((Component)allCharacter).GetComponent<PRVars>().timesDied++;
}
}
}
[HarmonyPatch(typeof(Character), "Awake")]
[HarmonyPostfix]
private static void PosPatch(Character __instance)
{
((Component)__instance).gameObject.AddComponent<PRVars>();
Debug.Log((object)("[RaceToThePeak] TeamInfo Object Created for " + ((Object)__instance).name));
}
}
private static float lastRespawnTime;
[HarmonyPatch(typeof(RespawnChest), "GetInteractionText")]
[HarmonyPostfix]
private static void disableRespawnStatue(ref string __result)
{
__result = LocalizedText.GetText("TOUCH", true);
}
[HarmonyPatch(typeof(RespawnChest), "Interact_CastFinished")]
[HarmonyPostfix]
public static void minusOneDeath(Character interactor)
{
((Component)interactor).GetComponent<PRVars>().timesDied--;
}
}