using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RumbleModdingAPI;
using UnityEngine;
using tournamentScore;
[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), "RUMBLE Tournament Scoring", "1.0.0", "davisg", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("tournamentScoring")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("tournamentScoring")]
[assembly: AssemblyTitle("tournamentScoring")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace tournamentScore
{
public class main : MelonMod
{
private int localMatchWins = 0;
private int remoteMatchWins = 0;
private int localRoundsInLosses = 0;
private int remoteRoundsInLosses = 0;
private int localRoundWinsThisMatch = 0;
private int remoteRoundWinsThisMatch = 0;
private GameObject scoreboardGO;
private TextMeshPro scoreboardText;
private string currentScene = "";
private bool scoreboardSpawned = false;
private Vector3 pendingPosition;
private float spawnTimer = 0f;
private bool spawnCountdownActive = false;
private string logPath = "UserData/tournament_score_log.txt";
public override void OnLateInitializeMelon()
{
Calls.onMatchStarted += OnMatchStarted;
Calls.onRoundEnded += OnRoundEnded;
Calls.onMatchEnded += OnMatchEnded;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
currentScene = sceneName;
scoreboardSpawned = false;
spawnCountdownActive = false;
spawnTimer = 0f;
MelonLogger.Msg("[DEBUG] Scene loaded: " + sceneName);
if (sceneName == "Gym")
{
MelonLogger.Msg("[DEBUG] Gym loaded. Resetting scores and hiding scoreboard.");
ResetScore();
if ((Object)(object)scoreboardGO != (Object)null)
{
scoreboardGO.SetActive(false);
}
}
else if (sceneName == "Map0" || sceneName == "Map1")
{
pendingPosition = ((sceneName == "Map0") ? new Vector3(-10f, 5f, 0f) : new Vector3(12f, 5f, 0f));
MelonLogger.Msg("[DEBUG] Preparing to spawn scoreboard after delay...");
spawnCountdownActive = true;
}
}
private void ResetScore()
{
localMatchWins = 0;
remoteMatchWins = 0;
localRoundsInLosses = 0;
remoteRoundsInLosses = 0;
LogScore();
UpdateScoreboardText();
MelonLogger.Msg("[DEBUG] Scoreboard and tournament scores reset to 0(0)-0(0).");
}
public override void OnUpdate()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
if (spawnCountdownActive)
{
spawnTimer += Time.deltaTime;
if (spawnTimer >= 5f && !scoreboardSpawned)
{
SpawnScoreboard();
}
}
if (scoreboardSpawned && (Object)(object)scoreboardGO != (Object)null && (Object)(object)scoreboardText != (Object)null)
{
Camera val = Camera.main;
if ((Object)(object)val != (Object)null)
{
scoreboardGO.transform.rotation = Quaternion.LookRotation(scoreboardGO.transform.position - ((Component)val).transform.position);
}
}
if (Input.GetKeyDown((KeyCode)114))
{
MelonLogger.Msg("[DEBUG] Reset key pressed. Resetting score manually!");
ResetScore();
}
}
private void SpawnScoreboard()
{
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)scoreboardGO == (Object)null)
{
scoreboardGO = Create.NewText("scoreboardText", 3f, Color.white, Vector3.zero, Quaternion.identity);
if ((Object)(object)scoreboardGO != (Object)null)
{
scoreboardText = scoreboardGO.GetComponent<TextMeshPro>();
((TMP_Text)scoreboardText).alignment = (TextAlignmentOptions)514;
((TMP_Text)scoreboardText).enableWordWrapping = false;
((TMP_Text)scoreboardText).fontSize = 3f;
((TMP_Text)scoreboardText).text = "0(0)-0(0)";
scoreboardGO.transform.position = pendingPosition;
scoreboardGO.transform.localScale = Vector3.one * 5f;
MelonLogger.Msg($"[DEBUG] Scoreboard spawned at {scoreboardGO.transform.position}");
}
else
{
MelonLogger.Error("[ERROR] Failed to create scoreboard.");
}
}
else
{
scoreboardGO.transform.position = pendingPosition;
scoreboardGO.transform.localScale = Vector3.one * 5f;
scoreboardGO.SetActive(true);
MelonLogger.Msg($"[DEBUG] Reusing existing scoreboard. New position: {scoreboardGO.transform.position}");
}
scoreboardSpawned = true;
UpdateScoreboardText();
}
private void OnMatchStarted()
{
MelonLogger.Msg("[DEBUG] Match started. Resetting round wins.");
localRoundWinsThisMatch = 0;
remoteRoundWinsThisMatch = 0;
}
private void OnRoundEnded()
{
try
{
PlayerManager instance = Singleton<PlayerManager>.instance;
Player val = ((instance != null) ? instance.localPlayer : null);
PlayerData val2 = ((val != null) ? val.Data : null);
if (val == null || val2 == null)
{
MelonLogger.Warning("[WARNING] Missing local player data. Skipping round tracking.");
return;
}
if (val2.HealthPoints > 0)
{
localRoundWinsThisMatch++;
}
else
{
remoteRoundWinsThisMatch++;
}
MelonLogger.Msg($"[DEBUG] Round ended. LocalRounds: {localRoundWinsThisMatch}, RemoteRounds: {remoteRoundWinsThisMatch}");
}
catch (Exception ex)
{
MelonLogger.Error("[ERROR] Exception in OnRoundEnded: " + ex);
}
}
private void OnMatchEnded()
{
try
{
bool flag = Players.IsHost();
if (localRoundWinsThisMatch > remoteRoundWinsThisMatch)
{
localMatchWins++;
if (flag && remoteRoundWinsThisMatch > 0)
{
remoteRoundsInLosses++;
MelonLogger.Msg("[DEBUG] Opponent was client and won rounds. Incrementing opponent parentheses.");
}
}
else
{
remoteMatchWins++;
if (!flag && localRoundWinsThisMatch > 0)
{
localRoundsInLosses++;
MelonLogger.Msg("[DEBUG] Local was client and won rounds. Incrementing local parentheses.");
}
}
MelonLogger.Msg($"[DEBUG] Match ended. Score: {localMatchWins}({localRoundsInLosses})-{remoteMatchWins}({remoteRoundsInLosses})");
LogScore();
UpdateScoreboardText();
}
catch (Exception ex)
{
MelonLogger.Error("[ERROR] Exception in OnMatchEnded: " + ex);
}
}
private void LogScore()
{
try
{
string text = $"===SCORING===\n{localMatchWins}({localRoundsInLosses})-{remoteMatchWins}({remoteRoundsInLosses})";
MelonLogger.Msg("[RUMBLE Tournament Scoring] " + text);
string directoryName = Path.GetDirectoryName(logPath);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
File.WriteAllText(logPath, text);
}
catch (Exception ex)
{
MelonLogger.Error("[ERROR] Error writing to score file: " + ex);
}
}
private void UpdateScoreboardText()
{
if (!((Object)(object)scoreboardText == (Object)null))
{
((TMP_Text)scoreboardText).text = $"{localMatchWins}({localRoundsInLosses})-{remoteMatchWins}({remoteRoundsInLosses})";
}
}
}
}