using System;
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 BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
[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("SBG-LiveLeaderboard")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0")]
[assembly: AssemblyProduct("Super Battle Golf Live Leaderboard")]
[assembly: AssemblyTitle("SBG-LiveLeaderboard")]
[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 Leaderboard
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SBG-LiveLeaderboard";
public const string PLUGIN_NAME = "Super Battle Golf Live Leaderboard";
public const string PLUGIN_VERSION = "1.0";
}
}
namespace SpectatorLeaderboard
{
[BepInPlugin("com.kingcox22.sbg.liveleaderboard", "SBG-Live Leaderboard", "1.0")]
public class SpectatorLeaderboardPlugin : BaseUnityPlugin
{
private static ConfigEntry<float> _configSpecInterval;
private static ConfigEntry<int> _configLeaderboardCount;
private float _specTimer = 0f;
private Transform _cachedHole;
private List<string> _leaderboardStrings = new List<string>();
private string _spectatingDist = "0m";
private bool _isCustomSpectatorActive = false;
private void Awake()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
_configSpecInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Spectator", "Update Interval", 5f, "Seconds between leaderboard updates.");
_configLeaderboardCount = ((BaseUnityPlugin)this).Config.Bind<int>("Spectator", "Leaderboard Size", 16, "Number of players to show on the leaderboard.");
PlayerSpectator.LocalPlayerIsSpectatingChanged += OnGameSpectateChanged;
PlayerSpectator.LocalPlayerStoppedSpectating += OnGameSpectateStopped;
Harmony val = new Harmony("com.kingcox22.sbg.liveleaderboard");
val.PatchAll();
}
private void Update()
{
_specTimer += Time.deltaTime;
if (_specTimer >= _configSpecInterval.Value)
{
_specTimer = 0f;
RefreshLeaderboardLogic();
}
}
private void OnGameSpectateChanged()
{
PlayerSpectator val = ((IEnumerable<PlayerSpectator>)Object.FindObjectsByType<PlayerSpectator>((FindObjectsSortMode)0)).FirstOrDefault((Func<PlayerSpectator, bool>)((PlayerSpectator s) => ((NetworkBehaviour)s).isLocalPlayer));
if ((Object)(object)val != (Object)null)
{
_isCustomSpectatorActive = val.IsSpectating;
}
}
private void OnGameSpectateStopped()
{
_isCustomSpectatorActive = false;
_cachedHole = null;
}
private void RefreshLeaderboardLogic()
{
if (!_isCustomSpectatorActive)
{
return;
}
if ((Object)(object)_cachedHole == (Object)null)
{
GameObject val = GameObject.Find("Hole") ?? GameObject.Find("Main hole") ?? GameObject.Find("Desert Main Hole");
if ((Object)(object)val != (Object)null)
{
_cachedHole = val.transform;
}
}
if ((Object)(object)_cachedHole == (Object)null)
{
return;
}
List<PlayerGolfer> list = (from g in Object.FindObjectsByType<PlayerGolfer>((FindObjectsSortMode)0)
where (Object)(object)g != (Object)null && !CourseManager.IsPlayerSpectator(g)
select g).ToList();
if (list.Count != 0)
{
var list2 = (from g in list
select new
{
Golfer = g,
Distance = Vector3.Distance(((Component)g).transform.position, _cachedHole.position)
} into x
orderby x.Distance
select x).ToList();
_leaderboardStrings.Clear();
int num = Mathf.Min(_configLeaderboardCount.Value, list2.Count);
for (int i = 0; i < num; i++)
{
_leaderboardStrings.Add($"{i + 1}. {((Object)list2[i].Golfer).name} ({Mathf.Round(list2[i].Distance)}m)");
}
_spectatingDist = $"{Mathf.Round(list2[0].Distance)}m";
}
}
private void OnGUI()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_0090: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
if (_isCustomSpectatorActive)
{
float num = 15f;
float num2 = 130f;
float num3 = 250f;
float num4 = 65f + (float)_leaderboardStrings.Count * 22f;
GUI.backgroundColor = new Color(0f, 0f, 0f, 0.9f);
Rect val = default(Rect);
((Rect)(ref val))..ctor(num, num2, num3, num4);
GUI.Box(val, "<b><size=14><color=white>[Live Leaderboard]</color></size></b>");
GUIStyle val2 = new GUIStyle(GUI.skin.label)
{
richText = true
};
GUI.Label(new Rect(num + 10f, num2 + 35f, 200f, 25f), "<b>Closest:</b> <color=yellow>" + _spectatingDist + "</color>", val2);
for (int i = 0; i < _leaderboardStrings.Count; i++)
{
GUI.Label(new Rect(num + 15f, num2 + 65f + (float)(i * 22), 220f, 25f), _leaderboardStrings[i], val2);
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}