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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
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: IgnoresAccessChecksTo("GameAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SBGL-LiveLeaderboard")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.93.0")]
[assembly: AssemblyInformationalVersion("0.0.93+9a171ae398e246e91e136508c15c434c7e536a35")]
[assembly: AssemblyProduct("Super Battle Golf League Live Leaderboard")]
[assembly: AssemblyTitle("SBGL-LiveLeaderboard")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.93.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 SBGLLiveLeaderboard
{
[BepInPlugin("com.kingcox22.sbgl.liveleaderboard", "SBGL Live Leaderboard", "0.0.93")]
public class LiveLeaderboardPlugin : BaseUnityPlugin
{
public class SBGLPlayer
{
public string Name;
public int BaseScore;
public int AdjustedPoints;
public string RawStrokes;
public string MMR = "...";
public string ProjectedDisplay = "...";
}
[CompilerGenerated]
private sealed class <GetMMRForPlayer>d__37 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string originalName;
public LiveLeaderboardPlugin <>4__this;
private string <query>5__1;
private string <url>5__2;
private bool <needsFallback>5__3;
private UnityWebRequest <r>5__4;
private JArray <res>5__5;
private string <val>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GetMMRForPlayer>d__37(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<query>5__1 = null;
<url>5__2 = null;
<r>5__4 = null;
<res>5__5 = null;
<val>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Invalid comparison between Unknown and I4
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (<>4__this._pendingRequests.Contains(originalName))
{
return false;
}
<>4__this._pendingRequests.Add(originalName);
<query>5__1 = "{\"display_name\":{\"$regex\":\"^" + originalName + "$\",\"$options\":\"i\"}}";
<url>5__2 = "https://sbgleague.com/api/apps/69b0f4aba3975f2440fbf070/entities/Player?q=" + UnityWebRequest.EscapeURL(<query>5__1);
<needsFallback>5__3 = false;
<r>5__4 = UnityWebRequest.Get(<url>5__2);
<>1__state = -3;
<r>5__4.SetRequestHeader("X-App-Id", "69b0f4aba3975f2440fbf070");
<r>5__4.SetRequestHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJraW5nY294MjJAZ21haWwuY29tIiwiZXhwIjoxNzgyNzg5NDU0LCJpYXQiOjE3NzUwMTM0NTR9.2pCmAKXH98n3fvUaheN-e6kx3BoJflStfUb-Kq-i-gU");
<>2__current = <r>5__4.SendWebRequest();
<>1__state = 1;
return true;
case 1:
<>1__state = -3;
if ((int)<r>5__4.result == 1)
{
try
{
<res>5__5 = JArray.Parse(<r>5__4.downloadHandler.text);
if (((JContainer)<res>5__5).Count > 0)
{
<val>5__6 = ((object)<res>5__5[0][(object)"current_mmr"])?.ToString() ?? "--";
<>4__this._mmrCache[originalName] = (<val>5__6, Time.time);
<val>5__6 = null;
}
else
{
<needsFallback>5__3 = true;
}
<res>5__5 = null;
}
catch
{
<needsFallback>5__3 = true;
}
}
else
{
<needsFallback>5__3 = true;
}
<>m__Finally1();
<r>5__4 = null;
if (<needsFallback>5__3)
{
<>2__current = <>4__this.GetMMRFuzzyFallback(originalName);
<>1__state = 2;
return true;
}
break;
case 2:
<>1__state = -1;
break;
}
<>4__this._pendingRequests.Remove(originalName);
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<r>5__4 != null)
{
((IDisposable)<r>5__4).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <GetMMRFuzzyFallback>d__38 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string originalName;
public LiveLeaderboardPlugin <>4__this;
private string <query>5__1;
private string <url>5__2;
private UnityWebRequest <r>5__3;
private string <val>5__4;
private JArray <res>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GetMMRFuzzyFallback>d__38(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<query>5__1 = null;
<url>5__2 = null;
<r>5__3 = null;
<val>5__4 = null;
<res>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Invalid comparison between Unknown and I4
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<query>5__1 = "{\"display_name\":{\"$regex\":\"" + originalName + "\",\"$options\":\"i\"}}";
<url>5__2 = "https://sbgleague.com/api/apps/69b0f4aba3975f2440fbf070/entities/Player?q=" + UnityWebRequest.EscapeURL(<query>5__1);
<r>5__3 = UnityWebRequest.Get(<url>5__2);
<>1__state = -3;
<r>5__3.SetRequestHeader("X-App-Id", "69b0f4aba3975f2440fbf070");
<r>5__3.SetRequestHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJraW5nY294MjJAZ21haWwuY29tIiwiZXhwIjoxNzgyNzg5NDU0LCJpYXQiOjE3NzUwMTM0NTR9.2pCmAKXH98n3fvUaheN-e6kx3BoJflStfUb-Kq-i-gU");
<>2__current = <r>5__3.SendWebRequest();
<>1__state = 1;
return true;
case 1:
<>1__state = -3;
<val>5__4 = "--";
if ((int)<r>5__3.result == 1)
{
<res>5__5 = JArray.Parse(<r>5__3.downloadHandler.text);
if (((JContainer)<res>5__5).Count > 0)
{
<val>5__4 = ((object)<res>5__5[0][(object)"current_mmr"])?.ToString() ?? "--";
}
<res>5__5 = null;
}
<>4__this._mmrCache[originalName] = (<val>5__4, Time.time);
<val>5__4 = null;
<>m__Finally1();
<r>5__3 = null;
return false;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<r>5__3 != null)
{
((IDisposable)<r>5__3).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private const string APP_ID = "69b0f4aba3975f2440fbf070";
private const string AUTH_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJraW5nY294MjJAZ21haWwuY29tIiwiZXhwIjoxNzgyNzg5NDU0LCJpYXQiOjE3NzUwMTM0NTR9.2pCmAKXH98n3fvUaheN-e6kx3BoJflStfUb-Kq-i-gU";
private const string BASE_API = "https://sbgleague.com/api/apps/69b0f4aba3975f2440fbf070/entities/Player";
public ConfigEntry<float> ConfigWidth;
public ConfigEntry<float> ConfigMaxHeight;
public ConfigEntry<float> ConfigPosX;
public ConfigEntry<float> ConfigPosY;
public ConfigEntry<float> ConfigOpacity;
public ConfigEntry<float> ColWidthRank;
public ConfigEntry<float> ColWidthMMR;
public ConfigEntry<float> ColWidthPoints;
public ConfigEntry<float> ColWidthStroke;
public ConfigEntry<float> ColWidthBase;
public ConfigEntry<int> ConfigMaxPlayers;
public ConfigEntry<Key> ToggleKey;
private bool _showWindow = true;
private float _updateInterval = 2f;
private float _nextUpdateTime = 0f;
private float _lastOpacity = -1f;
private List<SBGLPlayer> _persistentLeaderboard = new List<SBGLPlayer>();
private Dictionary<string, (string mmr, float lastFetchTime)> _mmrCache = new Dictionary<string, (string, float)>();
private HashSet<string> _pendingRequests = new HashSet<string>();
private FieldInfo _entriesField;
private Scoreboard _cachedScoreboard;
private GUIStyle _windowStyle;
private GUIStyle _centeredStyle;
private GUIStyle _headerStyle;
private GUIStyle _nameStyle;
private GUIStyle _posStyle;
private GUIStyle _negStyle;
private Texture2D _blackTexture;
private void Awake()
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Expected O, but got Unknown
ConfigWidth = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Width", 298.6262f, "Width");
ConfigMaxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Max Height", 999f, "Height");
ConfigPosX = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "X Position", 5f, "X");
ConfigPosY = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Y Position", 200f, "Y");
ConfigOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Opacity", 1f, new ConfigDescription("Alpha", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
ConfigMaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("UI", "Max Players", 16, "Max Players");
ToggleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Controls", "Toggle Key", (Key)101, "Hotkey");
ColWidthRank = ((BaseUnityPlugin)this).Config.Bind<float>("Columns", "Rank Width", 20f, "Rank");
ColWidthMMR = ((BaseUnityPlugin)this).Config.Bind<float>("Columns", "MMR Width", 110f, "MMR");
ColWidthPoints = ((BaseUnityPlugin)this).Config.Bind<float>("Columns", "Points Width", 50f, "Points");
ColWidthStroke = ((BaseUnityPlugin)this).Config.Bind<float>("Columns", "Stroke Width", 25f, "+/-");
ColWidthBase = ((BaseUnityPlugin)this).Config.Bind<float>("Columns", "Base Width", 50f, "Base");
_entriesField = typeof(Scoreboard).GetField("entries", BindingFlags.Instance | BindingFlags.NonPublic);
_blackTexture = new Texture2D(1, 1);
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
}
private void Update()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (Keyboard.current != null && ((ButtonControl)Keyboard.current[ToggleKey.Value]).wasPressedThisFrame)
{
_showWindow = !_showWindow;
}
if (Time.time >= _nextUpdateTime)
{
ScrapeData();
_nextUpdateTime = Time.time + _updateInterval;
}
}
private void OnGUI()
{
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_0102: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected O, but got Unknown
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_01b4: Expected O, but got Unknown
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Expected O, but got Unknown
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Expected O, but got Unknown
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Expected O, but got Unknown
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Expected O, but got Unknown
//IL_039b: 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_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_0436: Unknown result type (might be due to invalid IL or missing references)
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Expected O, but got Unknown
//IL_0497: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0516: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Expected O, but got Unknown
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Unknown result type (might be due to invalid IL or missing references)
//IL_052a: Unknown result type (might be due to invalid IL or missing references)
//IL_0534: Expected O, but got Unknown
//IL_052f: Unknown result type (might be due to invalid IL or missing references)
//IL_0534: Unknown result type (might be due to invalid IL or missing references)
//IL_053f: Unknown result type (might be due to invalid IL or missing references)
//IL_054f: Unknown result type (might be due to invalid IL or missing references)
//IL_057d: Unknown result type (might be due to invalid IL or missing references)
//IL_0586: Unknown result type (might be due to invalid IL or missing references)
//IL_0601: Unknown result type (might be due to invalid IL or missing references)
//IL_0635: Unknown result type (might be due to invalid IL or missing references)
//IL_065e: Unknown result type (might be due to invalid IL or missing references)
//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
if (!_showWindow || _persistentLeaderboard.Count == 0)
{
return;
}
float num = (float)Screen.height / 1080f;
float num2 = 2f * num;
float num3 = 8f * num;
float num4 = 26f * num;
float num5 = 22f * num;
if (_windowStyle == null || Mathf.Abs(_lastOpacity - ConfigOpacity.Value) > 0.01f)
{
_lastOpacity = ConfigOpacity.Value;
_blackTexture.SetPixel(0, 0, new Color(0f, 0f, 0f, _lastOpacity));
_blackTexture.Apply();
GUIStyle val = new GUIStyle(GUI.skin.window);
val.normal.background = _blackTexture;
val.border = new RectOffset(0, 0, 0, 0);
_windowStyle = val;
_centeredStyle = new GUIStyle(GUI.skin.label)
{
fontSize = 11,
alignment = (TextAnchor)4,
richText = true,
wordWrap = false
};
_headerStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)4,
richText = true,
fontStyle = (FontStyle)1,
fontSize = 11
};
_nameStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)3,
richText = true,
wordWrap = true,
fontSize = 12,
padding = new RectOffset(0, 0, 0, 0)
};
GUIStyle val2 = new GUIStyle(_centeredStyle);
val2.normal.textColor = Color.green;
val2.wordWrap = false;
_posStyle = val2;
GUIStyle val3 = new GUIStyle(_centeredStyle);
val3.normal.textColor = Color.red;
val3.wordWrap = false;
_negStyle = val3;
}
float num6 = ColWidthRank.Value * num;
float num7 = ColWidthMMR.Value * num;
float num8 = ColWidthPoints.Value * num;
float num9 = ColWidthStroke.Value * num;
float num10 = ColWidthBase.Value * num;
float num11 = ConfigWidth.Value * num;
float num12 = num6 + num7 + num8 + num9 + num10 + num3 * 4f + num2 * 2f;
float num13 = Mathf.Max(60f * num, num11 - num12);
float num14 = num13 + num12;
float num15 = num2 * 2f + num4;
foreach (SBGLPlayer item in _persistentLeaderboard)
{
num15 += Mathf.Max(num5, _nameStyle.CalcHeight(new GUIContent(item.Name), num13));
}
float num16 = Mathf.Min(num15, ConfigMaxHeight.Value * num);
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(ConfigPosX.Value * num, ConfigPosY.Value * num, num14, num16);
GUI.Box(val4, "", _windowStyle);
GUILayout.BeginArea(val4);
float num17 = num2;
GUIStyle val5 = new GUIStyle(_centeredStyle);
val5.normal.textColor = new Color(1f, 0.85f, 0f);
val5.fontStyle = (FontStyle)1;
GUIStyle val6 = val5;
float num18 = num2;
GUI.Label(new Rect(num18 + num6, num17, num13, num4), "PLAYER", _headerStyle);
num18 += num6 + num13 + num3;
GUI.Label(new Rect(num18, num17, num7, num4), "MMR", _headerStyle);
num18 += num7 + num3;
GUI.Label(new Rect(num18, num17, num8, num4), "POINTS", _headerStyle);
num18 += num8 + num3;
GUI.Label(new Rect(num18, num17, num9, num4), "+/-", _headerStyle);
num18 += num9 + num3;
GUI.Label(new Rect(num18, num17, num10, num4), "BASE", _headerStyle);
num17 += num4;
for (int i = 0; i < _persistentLeaderboard.Count; i++)
{
SBGLPlayer sBGLPlayer = _persistentLeaderboard[i];
float num19 = Mathf.Max(num5, _nameStyle.CalcHeight(new GUIContent(sBGLPlayer.Name), num13));
float num20 = num2;
GUI.Label(new Rect(num20, num17, num6, num19), $"{i + 1}.", _nameStyle);
num20 += num6;
GUI.Label(new Rect(num20, num17, num13, num19), sBGLPlayer.Name, _nameStyle);
num20 += num13 + num3;
string mMR = sBGLPlayer.MMR;
string text = sBGLPlayer.ProjectedDisplay.Replace(mMR, "").Trim();
Vector2 val7 = _centeredStyle.CalcSize(new GUIContent(mMR));
Vector2 val8 = _centeredStyle.CalcSize(new GUIContent(text));
float num21 = 3f * num;
float num22 = val7.x + (string.IsNullOrEmpty(text) ? 0f : (val8.x + num21));
float num23 = num20 + num7 / 2f - num22 / 2f;
GUI.Label(new Rect(num23, num17, val7.x, num19), mMR, _centeredStyle);
if (!string.IsNullOrEmpty(text))
{
GUIStyle val9 = (text.Contains("+") ? _posStyle : _negStyle);
GUI.Label(new Rect(num23 + val7.x + num21, num17, val8.x, num19), text, val9);
}
num20 += num7 + num3;
GUI.Label(new Rect(num20, num17, num8, num19), $"{sBGLPlayer.AdjustedPoints}", val6);
num20 += num8 + num3;
GUI.Label(new Rect(num20, num17, num9, num19), sBGLPlayer.RawStrokes, _centeredStyle);
num20 += num9 + num3;
GUI.Label(new Rect(num20, num17, num10, num19), $"{sBGLPlayer.BaseScore}", _centeredStyle);
num17 += num19;
if (num17 > num16 - num2)
{
break;
}
}
GUILayout.EndArea();
}
private void ScrapeData()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
string name = ((Scene)(ref activeScene)).name;
if (name.Contains("Driving") || name.Contains("Range"))
{
return;
}
if ((Object)(object)_cachedScoreboard == (Object)null)
{
_cachedScoreboard = Object.FindAnyObjectByType<Scoreboard>((FindObjectsInactive)1);
}
if ((Object)(object)_cachedScoreboard == (Object)null || _entriesField == null || !(_entriesField.GetValue(_cachedScoreboard) is List<ScoreboardEntry> list) || list.Count == 0)
{
return;
}
List<SBGLPlayer> list2 = new List<SBGLPlayer>();
foreach (ScoreboardEntry item in list)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
TextMeshProUGUI name2 = item.name;
string text = CleanTMP((name2 != null) ? ((TMP_Text)name2).text : null);
if (string.IsNullOrEmpty(text) || text == "Name" || text.ToLower().Contains("spectator"))
{
continue;
}
TextMeshProUGUI strokes = item.strokes;
string text2 = CleanTMP((strokes != null) ? ((TMP_Text)strokes).text : null);
if (string.IsNullOrEmpty(text2) || text2.ToUpper().Contains("SPEC"))
{
continue;
}
TextMeshProUGUI courseScore = item.courseScore;
int.TryParse(CleanTMP((courseScore != null) ? ((TMP_Text)courseScore).text : null), out var result);
int.TryParse(text2.Replace("±", "").Replace("+", "").Trim(), out var result2);
string text3 = "...";
bool flag = true;
if (_mmrCache.TryGetValue(text, out (string, float) value))
{
(text3, _) = value;
if (Time.time - value.Item2 < 300f)
{
flag = false;
}
}
if (flag && !_pendingRequests.Contains(text))
{
((MonoBehaviour)this).StartCoroutine(GetMMRForPlayer(text));
}
list2.Add(new SBGLPlayer
{
Name = text,
BaseScore = result,
RawStrokes = text2,
AdjustedPoints = result + result2 * -10,
MMR = text3,
ProjectedDisplay = text3
});
}
if (list2.Count > 1)
{
CalculateProjectedMMR(list2);
}
if (list2.Count > 0)
{
_persistentLeaderboard = list2.OrderByDescending((SBGLPlayer p) => p.AdjustedPoints).Take(ConfigMaxPlayers.Value).ToList();
}
}
private void CalculateProjectedMMR(List<SBGLPlayer> players)
{
Dictionary<string, float> dictionary = new Dictionary<string, float>();
foreach (SBGLPlayer player in players)
{
dictionary[player.Name] = 0f;
}
for (int i = 0; i < players.Count; i++)
{
for (int j = i + 1; j < players.Count; j++)
{
SBGLPlayer sBGLPlayer = players[i];
SBGLPlayer sBGLPlayer2 = players[j];
if (float.TryParse(sBGLPlayer.MMR, out var result) && float.TryParse(sBGLPlayer2.MMR, out var result2))
{
float num = 1f / (1f + Mathf.Pow(10f, (result2 - result) / 400f));
float num2 = ((sBGLPlayer.AdjustedPoints > sBGLPlayer2.AdjustedPoints) ? 1f : ((sBGLPlayer.AdjustedPoints < sBGLPlayer2.AdjustedPoints) ? 0f : 0.5f));
float num3 = 24f * (num2 - num);
dictionary[sBGLPlayer.Name] += num3;
dictionary[sBGLPlayer2.Name] -= num3;
}
}
}
foreach (SBGLPlayer player2 in players)
{
if (float.TryParse(player2.MMR, out var _))
{
int num4 = Mathf.RoundToInt(dictionary[player2.Name]);
string arg = ((num4 >= 0) ? "+" : "");
player2.ProjectedDisplay = $"{player2.MMR} ({arg}{num4})";
}
else
{
player2.ProjectedDisplay = player2.MMR;
}
}
}
[IteratorStateMachine(typeof(<GetMMRForPlayer>d__37))]
private IEnumerator GetMMRForPlayer(string originalName)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetMMRForPlayer>d__37(0)
{
<>4__this = this,
originalName = originalName
};
}
[IteratorStateMachine(typeof(<GetMMRFuzzyFallback>d__38))]
private IEnumerator GetMMRFuzzyFallback(string originalName)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetMMRFuzzyFallback>d__38(0)
{
<>4__this = this,
originalName = originalName
};
}
private string CleanTMP(string input)
{
return string.IsNullOrEmpty(input) ? "" : Regex.Replace(input, "<.*?>", string.Empty).Trim();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SBGL-LiveLeaderboard";
public const string PLUGIN_NAME = "Super Battle Golf League Live Leaderboard";
public const string PLUGIN_VERSION = "0.0.93";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}