using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using InGameClock;
using MelonLoader;
using RumbleModdingAPI;
using RumbleStats;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "InGame Clock", "1.1.3", "ERROR", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: AssemblyTitle("In Game Clock")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InGame Clock")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b10c94a1-8a40-4701-bc5b-98eabb44dfea")]
[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 InGameClock;
public class main : MelonMod
{
public enum RoundResult
{
T,
W,
L,
u
}
private bool init = false;
private string currentScene = "Loader";
private int sceneCount = 0;
private GameObject timers;
private GameObject timeDisplay;
private TextMeshPro timeDisplayText;
private GameObject totalMatchDisplay;
private TextMeshPro totalMatchDisplayText;
private float matchStartTime = 0f;
private bool isMatchRunning = false;
private GameObject[] roundTimers = (GameObject[])(object)new GameObject[3];
public TextMeshPro[] roundTimerTexts = (TextMeshPro[])(object)new TextMeshPro[3];
private float roundStartTime = 0f;
private bool isRoundRunning = false;
private int round = 0;
private StatsMod mod = new StatsMod();
public RoundResult[] rounds = new RoundResult[3]
{
RoundResult.u,
RoundResult.u,
RoundResult.u
};
private float textYValue = 2.0332f;
public static main Instance { get; private set; }
public main()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
Instance = this;
}
public override void OnLateInitializeMelon()
{
Calls.onMapInitialized += OnMapInitialized;
Calls.onMatchStarted += delegate
{
MelonCoroutines.Start(OnMatchStart());
};
Calls.onRoundStarted += delegate
{
MelonCoroutines.Start(roundStarted());
};
Calls.onRoundEnded += roundEnded;
mod.ModName = "InGameClock";
mod.storeEntryTime = true;
Dictionary<string, Type> dictionary = new Dictionary<string, Type>();
dictionary.Add("Opponent", typeof(string));
dictionary.Add("Opponent BP", typeof(int));
dictionary.Add("Your BP", typeof(int));
dictionary.Add("R1 Time", typeof(string));
dictionary.Add("R2 Time", typeof(string));
dictionary.Add("R3 Time", typeof(string));
dictionary.Add("R1 Result", typeof(string));
dictionary.Add("R2 Result", typeof(string));
dictionary.Add("R3 Result", typeof(string));
Dictionary<string, Type> dictionary2 = dictionary;
mod.InitializeStatFile("MatchTimes", dictionary2);
Main.instance.RegisterCSVFile("MatchTimes", "Records the following data at the end of every match: \nOpponent Name\nOpponent BP\nYour BP\nR1 Time\nR2 Time\nR3 Time\nR1 Result\nR2 Result\nR3 Result");
MelonLogger.Msg("InGameClock Initiated");
}
public void OnMapInitialized()
{
if (currentScene != "Loader")
{
MelonCoroutines.Start(InitializeWithPause(sceneCount));
}
}
private IEnumerator InitializeWithPause(int sceneNumber)
{
DateTime targetTime = DateTime.Now.AddSeconds(1.0);
while (DateTime.Now < targetTime)
{
yield return (object)new WaitForFixedUpdate();
}
if (sceneNumber == sceneCount)
{
Initialize();
}
}
public void Initialize()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
if (!init)
{
timers = new GameObject("Timers");
timeDisplay = Create.NewText("Hour:Minute", 5f, Color.white, Vector3.zero, Quaternion.identity);
timeDisplay.transform.SetParent(timers.transform, true);
timeDisplayText = timeDisplay.GetComponent<TextMeshPro>();
((TMP_Text)timeDisplayText).alignment = (TextAlignmentOptions)514;
((TMP_Text)timeDisplayText).enableWordWrapping = false;
((Object)timeDisplay).name = "Time Clock";
Vector3 position = default(Vector3);
Vector3 localScale = default(Vector3);
Vector3 val = default(Vector3);
if (currentScene == "Gym")
{
textYValue = 2.0332f;
((Vector3)(ref position))..ctor(2.4095f, textYValue, 0.9112f);
((Vector3)(ref localScale))..ctor(1f, 1f, 1.318f);
val = Vector3.zero;
}
else if (currentScene == "Map1")
{
textYValue = 5.5709f;
((Vector3)(ref position))..ctor(-14.4782f, textYValue, 2.1164f);
localScale = Vector3.one * 4f;
((Vector3)(ref val))..ctor(0f, 288.0543f, 0f);
}
else if (currentScene == "Map0")
{
textYValue = 1.5564f;
((Vector3)(ref position))..ctor(17.951f, textYValue, 3.2618f);
localScale = Vector3.one * 3f;
((Vector3)(ref val))..ctor(0f, 76.8618f, 0f);
}
else if (currentScene == "Park")
{
textYValue = -1.38f;
((Vector3)(ref position))..ctor(10.24f, textYValue, 0.9517f);
localScale = Vector3.one * 2.5f;
((Vector3)(ref val))..ctor(0f, 73.0908f, 0f);
}
timeDisplay.transform.position = position;
timeDisplay.transform.localScale = localScale;
timeDisplay.transform.rotation = Quaternion.Euler(val);
if (currentScene == "Map0" || currentScene == "Map1")
{
InitializeMatchTimers();
}
init = true;
}
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
currentScene = sceneName;
init = false;
}
private Quaternion GetAngleToFaceMe(Vector3 objectPosition, Vector3 lookAtPosition)
{
//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_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = objectPosition - lookAtPosition;
return Quaternion.LookRotation(val);
}
public override void OnUpdate()
{
//IL_0072: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
if (!init)
{
return;
}
if ((Object)(object)timeDisplayText != (Object)null)
{
string text = DateTime.Now.ToString("h:mm tt");
((TMP_Text)timeDisplayText).text = text;
float num = textYValue + Mathf.Sin(Time.time) * 0.05f;
timeDisplay.transform.position = new Vector3(timeDisplay.transform.position.x, num, timeDisplay.transform.position.z);
if (currentScene == "Gym")
{
timeDisplay.transform.rotation = GetAngleToFaceMe(timeDisplay.transform.position, ((Component)Camera.main).transform.position);
}
}
if (currentScene == "Map1" || currentScene == "Map0")
{
if ((Object)(object)totalMatchDisplayText != (Object)null && isMatchRunning)
{
float elapsedTime = Time.time - matchStartTime;
((TMP_Text)totalMatchDisplayText).text = FormatTime(elapsedTime);
}
if (isRoundRunning && (Object)(object)roundTimerTexts[round] != (Object)null)
{
float elapsedTime2 = Time.time - roundStartTime;
((TMP_Text)roundTimerTexts[round]).text = FormatTime(elapsedTime2);
}
}
}
private void InitializeMatchTimers()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
totalMatchDisplay = Create.NewText("0:00", 5f, Color.white, Vector3.zero, Quaternion.identity);
totalMatchDisplay.transform.SetParent(timeDisplay.transform, true);
totalMatchDisplayText = totalMatchDisplay.GetComponent<TextMeshPro>();
((Object)totalMatchDisplay).name = "Total Match Timer";
((TMP_Text)totalMatchDisplayText).alignment = (TextAlignmentOptions)514;
((TMP_Text)totalMatchDisplayText).enableWordWrapping = false;
totalMatchDisplay.transform.rotation = timeDisplay.transform.rotation;
totalMatchDisplay.transform.localPosition = new Vector3(0f, 0.3273f, 0f);
totalMatchDisplay.transform.localScale = Vector3.one * 0.8f;
roundTimers[0] = Create.NewText("0:00", 5f, Color.white, Vector3.zero, Quaternion.identity);
roundTimers[0].transform.SetParent(timeDisplay.transform, true);
((Object)roundTimers[0]).name = "Round 1 Timer";
roundTimerTexts[0] = roundTimers[0].GetComponent<TextMeshPro>();
((TMP_Text)roundTimerTexts[0]).alignment = (TextAlignmentOptions)514;
((TMP_Text)roundTimerTexts[0]).enableWordWrapping = false;
roundTimers[0].transform.rotation = timeDisplay.transform.rotation;
roundTimers[0].transform.localPosition = new Vector3(-0.4108f, -0.2582f, 0.0105f);
roundTimerTexts[0].transform.localScale = Vector3.one * 0.4f;
roundTimers[1] = Create.NewText("0:00", 5f, Color.white, Vector3.zero, Quaternion.identity);
roundTimers[1].transform.SetParent(timeDisplay.transform, true);
((Object)roundTimers[1]).name = "Round 2 Timer";
roundTimerTexts[1] = roundTimers[1].GetComponent<TextMeshPro>();
((TMP_Text)roundTimerTexts[1]).alignment = (TextAlignmentOptions)514;
((TMP_Text)roundTimerTexts[1]).enableWordWrapping = false;
roundTimers[1].transform.rotation = timeDisplay.transform.rotation;
roundTimers[1].transform.localPosition = new Vector3(0f, -0.2545f, 0f);
roundTimerTexts[1].transform.localScale = Vector3.one * 0.4f;
roundTimers[2] = Create.NewText("0:00", 5f, Color.white, Vector3.zero, Quaternion.identity);
roundTimers[2].transform.SetParent(timeDisplay.transform, true);
((Object)roundTimers[2]).name = "Round 3 Timer";
roundTimerTexts[2] = roundTimers[2].GetComponent<TextMeshPro>();
((TMP_Text)roundTimerTexts[2]).alignment = (TextAlignmentOptions)514;
((TMP_Text)roundTimerTexts[2]).enableWordWrapping = false;
roundTimers[2].transform.rotation = timeDisplay.transform.rotation;
roundTimers[2].transform.localPosition = new Vector3(0.3849f, -0.2461f, -0.004f);
roundTimerTexts[2].transform.localScale = Vector3.one * 0.4f;
TextMeshPro[] array = roundTimerTexts;
foreach (TextMeshPro val in array)
{
((TMP_Text)val).text = "0:00";
}
}
private IEnumerator OnMatchStart()
{
round = -1;
rounds = new RoundResult[3];
yield return (object)new WaitForSeconds(12f);
isMatchRunning = true;
matchStartTime = Time.time;
}
private IEnumerator roundStarted()
{
round++;
if (round == 0)
{
yield return (object)new WaitForSeconds(12f);
}
isRoundRunning = true;
roundStartTime = Time.time;
}
private void roundEnded()
{
//IL_0064: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
int healthPoints = Singleton<PlayerManager>.instance.AllPlayers[0].Data.HealthPoints;
int healthPoints2 = Singleton<PlayerManager>.instance.AllPlayers[1].Data.HealthPoints;
isRoundRunning = false;
if (healthPoints == healthPoints2)
{
rounds[round] = RoundResult.T;
((TMP_Text)roundTimerTexts[round]).color = Color.yellow;
}
else if (healthPoints > healthPoints2)
{
rounds[round] = RoundResult.W;
((TMP_Text)roundTimerTexts[round]).color = Color.green;
}
else
{
rounds[round] = RoundResult.L;
((TMP_Text)roundTimerTexts[round]).color = Color.red;
}
int num = 0;
int num2 = 0;
RoundResult[] array = rounds;
for (int i = 0; i < array.Length; i++)
{
switch (array[i])
{
case RoundResult.W:
num++;
break;
case RoundResult.L:
num2++;
break;
}
}
string[] array2 = rounds.Select((RoundResult result) => (result == RoundResult.u) ? "-" : result.ToString()).ToArray();
if (num >= 2 || num2 >= 2)
{
isMatchRunning = false;
if (num >= 2)
{
((TMP_Text)totalMatchDisplayText).color = Color.green;
}
else
{
((TMP_Text)totalMatchDisplayText).color = Color.red;
}
mod.AddStatRow(new object[9]
{
Players.GetAllPlayers()[1].Data.GeneralData.PublicUsername,
Players.GetAllPlayers()[1].Data.GeneralData.BattlePoints,
Players.GetLocalPlayer().Data.GeneralData.BattlePoints,
((TMP_Text)roundTimerTexts[0]).text,
((TMP_Text)roundTimerTexts[1]).text,
((TMP_Text)roundTimerTexts[2]).text,
array2[0],
array2[1],
array2[2]
}, "MatchTimes");
}
}
private string FormatTime(float elapsedTime)
{
int num = Mathf.FloorToInt(elapsedTime / 60f);
int num2 = Mathf.FloorToInt(elapsedTime % 60f);
return $"{num}:{num2:D2}";
}
}