using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Round Logger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Round Logger")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("04d1f23b-e5e3-43f3-9eb8-2f388785b31c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("repotime.discordbot", "time measurement", "1.0.0")]
public class RoundRecords : BaseUnityPlugin
{
[HarmonyPatch(typeof(RunManager))]
internal class RunManagerPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void CustomPatch()
{
if (SemiFunc.RunIsArena())
{
if (!dataSaved)
{
int level = StatsManager.instance.runStats["level"];
playTime -= deadTime;
SaveFinalData(level, playTime);
dataSaved = true;
playTime = 0f;
}
}
else if (SemiFunc.RunIsLevel())
{
if (modTime > 0f)
{
playTime += modTime;
}
int num = StatsManager.instance.runStats["level"];
if (playTime < 10f && num > 0)
{
playTime += 10000f;
}
playTime += Time.deltaTime;
deadTime += Time.deltaTime;
}
else if (SemiFunc.RunIsShop())
{
deadTime = 0f;
}
else if (SemiFunc.RunIsLobbyMenu() && dataSaved)
{
playTime = 0f;
dataSaved = false;
}
}
}
[HarmonyPatch(typeof(GoalUI))]
internal class GoalPatch
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void CustomPatch(ref TextMeshProUGUI ___Text)
{
if (!SemiFunc.RunIsShop())
{
int num = (int)(playTime / 60f);
int num2 = (int)(playTime % 60f);
string text = $"{num:D2}:{num2:D2}";
((TMP_Text)___Text).text = "<line-height=75%>" + ((TMP_Text)___Text).text + "\n<color=#e38c1b><size=28>Time " + text + "</size></color>";
((TMP_Text)___Text).alignment = (TextAlignmentOptions)260;
}
}
}
private static int highestLevelReached;
private static float playTime;
private static float deadTime;
private static float modTime;
private static bool dataSaved;
private static bool recordTime;
public void Awake()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
string[] excludedPluginIds = new string[4] { "com.myname.copyfontassetbundle", "gravydevsupreme.xunity.autotranslator", "gravydevsupreme.xunity.resourceredirector", "repotime.discordbot" };
if (pluginInfos.Any((KeyValuePair<string, PluginInfo> plugin) => !excludedPluginIds.Contains(plugin.Key)))
{
ExecuteCommand();
}
Harmony val = new Harmony("yourname.yourmod");
val.PatchAll();
}
private void ExecuteCommand()
{
modTime = 10000f;
((BaseUnityPlugin)this).Logger.LogInfo((object)"한글패치를 제외한 다른 모드가 감지되었습니다! 정상적인 기록이 불가합니다. 모드를 제외하고 실행하세요");
}
private static void SaveFinalData(int level, float time)
{
string text = Path.Combine(Application.dataPath, "save");
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
string arg = DateTime.Now.ToString("yyyy-MM-dd (dddd)");
string path = Path.Combine(text, $"final_record_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.txt");
string plainText = $"Cleared Level: {level}, Play Time: {time} seconds, Date: {arg}";
string text2 = EncryptStringWithRandomIV(plainText, "RepoRedgmvictory");
File.WriteAllText(path, text2);
Debug.Log((object)("Final data saved (encrypted): " + text2));
}
private static string EncryptStringWithRandomIV(string plainText, string key)
{
using Aes aes = Aes.Create();
aes.GenerateIV();
byte[] iV = aes.IV;
byte[] array = new byte[16];
Array.Copy(Encoding.UTF8.GetBytes(key), array, Math.Min(key.Length, array.Length));
aes.Key = array;
using MemoryStream memoryStream = new MemoryStream();
memoryStream.Write(iV, 0, iV.Length);
using (CryptoStream stream = new CryptoStream(memoryStream, aes.CreateEncryptor(), CryptoStreamMode.Write))
{
using StreamWriter streamWriter = new StreamWriter(stream);
streamWriter.Write(plainText);
}
return Convert.ToBase64String(memoryStream.ToArray());
}
}
namespace Round_Logger;
public class Class1
{
}