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.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UltrakillDifficultyLeaderboard.Data;
using UltrakillDifficultyLeaderboard.HarmonyPatches;
using UltrakillModLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UltrakillDifficultyLeaderboard")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltrakillDifficultyLeaderboard")]
[assembly: AssemblyTitle("UltrakillDifficultyLeaderboard")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace UltrakillDifficultyLeaderboard
{
[BepInPlugin("net.zephyr.ultrakill.DifficultyLeaderboards", "Leaderboard Manager", "1.3.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class LeaderboardPlugin : BaseUnityPlugin
{
internal static DebugLog Log = null;
private PluginConfigurator config;
public static Dictionary<GameDifficulty, DifficultyOption> DifficultyVisibility = new Dictionary<GameDifficulty, DifficultyOption>();
private const string ModName = "Zephyr's Leaderboard Manager";
public const string VisGlobalCategoryName = "--Entry Visibility--";
public const string TimeManagementGlobalCategoryName = "--Record Management--";
public const string CosmeticGlobalCategoryName = "--Other--";
private const string TypeSortingDirectionName = "Time Sorting Direction";
private const string TypeSortingBehaviorName = "Time Sorting Behavior";
private const string PerDifficultySortingName = "Difficulty Sorting Direction";
private const string PerDifficultyBehaviorName = "Difficulty Sorting Behavior";
private const string ActiveDiffName = "Show Times of Active Difficulty";
private const string ActiveDiffOnlyName = "Hide Other Difficulty Times";
private const string HideTimesAboveYourOwnName = "Hide Times Above Your Own";
private const string HideOthersName = "Hide Other Players";
private const string BlockAllRecordName = "Prevent New Steam Level Records";
private const string BlockAllCybergrindRecordName = "Prevent New Cybergrind Records";
private const string BlockAllLocalTimesName = "Save Records per Difficulty";
private const string UserPanelName = "Config Friends Visibility";
private const string DiffPanelName = "Config Difficulties";
private const string AnyRecordColorName = "ANY% Best time Color";
private const string PRankRecordColorName = "P-RANK Best time Color";
private const string EnableBestWaveAnimationName = "Best Time WAVE Animation";
private const string ColorizeDifficultiesName = "Colorize Difficulties";
private const string FeedbackButtonName = "Send FEEDBACK / REPORT BUG (discord)";
private const string DiffCatecoryName1 = "--ACCESSIBLE--";
private const string DiffCatecoryName2 = "--HARD--";
private const string DiffCatecoryName3 = "--VERY HARD--";
private static readonly Color HarmlessColor = new Color(0.43f, 1f, 0.905f);
private static readonly Color LenientColor = new Color(0.49f, 0.753f, 1f);
private static readonly Color StandardColor = new Color(0.664f, 0.47f, 1f);
private static readonly Color ViolentColor = new Color(1f, 0.35f, 0.968f);
private static readonly Color BrutalColor = new Color(1f, 0.27f, 0.647f);
private static readonly Color UKMDColor = new Color(1f, 0.248f, 0.285f);
public BoolField ActiveDiffVis { get; private set; }
public BoolField DiffVis { get; private set; }
public BoolField BlockAllRecords { get; private set; }
public BoolField BlockAllCybergrindRecords { get; private set; }
public BoolField AllowAllLocalTimes { get; private set; }
public BoolField HideTimesAboveYourOwn { get; private set; }
public BoolField HideOthers { get; private set; }
public ColorField AnyRecordColor { get; private set; }
public ColorField PRankRecordColor { get; private set; }
public BoolField EnableBestWaveAnimation { get; private set; }
public BoolField ColorizeDifficulties { get; private set; }
public ConfigPanel UserPanel { get; private set; }
public EnumField<SortingDirection> TypeSortingDirection { get; private set; }
public EnumField<TimeSortingBehavior> TypeSortingBehavior { get; private set; }
public EnumField<SortingDirection> PerDifficultySortingDirection { get; private set; }
public EnumField<DifficultySortingBehavior> PerDifficultySortingBehavior { get; private set; }
public static Dictionary<SteamId, BoolField> UserVisibilityToggles { get; private set; } = new Dictionary<SteamId, BoolField>();
public static Dictionary<SteamId, ConfigPanel> UserPanels { get; private set; } = new Dictionary<SteamId, ConfigPanel>();
public static LeaderboardPlugin Instance { get; private set; } = null;
public LeaderboardPlugin()
{
Instance = this;
CreateConfig();
}
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
Harmony val = new Harmony("net.zephyr.ultrakill.DifficultyLeaderboards");
val.PatchAll();
Log = new DebugLog("Zephyr's Leaderboard Manager", ConsoleColor.DarkYellow, false);
Log.Log("The goop is in the bag.");
}
private void Update()
{
SteamControllerPatch.UpdateRealBests();
}
private void CreateConfig()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_00b1: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Expected O, but got Unknown
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Expected O, but got Unknown
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Expected O, but got Unknown
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Expected O, but got Unknown
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Expected O, but got Unknown
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Expected O, but got Unknown
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Expected O, but got Unknown
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Expected O, but got Unknown
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Expected O, but got Unknown
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Expected O, but got Unknown
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Expected O, but got Unknown
config = PluginConfigurator.Create("Zephyr's Leaderboard Manager", "net.zephyr.ultrakill.DifficultyLeaderboards");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string path = Path.Combine(directoryName, "icon.png");
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(val, array);
Sprite image = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
config.image = image;
ConfigHeader val2 = new ConfigHeader(config.rootPanel, "--Record Management--", 24);
AllowAllLocalTimes = new BoolField(config.rootPanel, "Save Records per Difficulty", "local_times_lock", true);
BlockAllRecords = new BoolField(config.rootPanel, "Prevent New Steam Level Records", "records_lock", false);
BlockAllCybergrindRecords = new BoolField(config.rootPanel, "Prevent New Cybergrind Records", "records_cybergrind_lock", false);
TypeSortingBehavior = new EnumField<TimeSortingBehavior>(config.rootPanel, "Time Sorting Behavior", "time_behavior", TimeSortingBehavior.Time);
TypeSortingDirection = new EnumField<SortingDirection>(config.rootPanel, "Time Sorting Direction", "time_sorting", SortingDirection.Ascending);
PerDifficultySortingBehavior = new EnumField<DifficultySortingBehavior>(config.rootPanel, "Difficulty Sorting Behavior", "difficulty_behavior", DifficultySortingBehavior.NoSorting);
PerDifficultySortingDirection = new EnumField<SortingDirection>(config.rootPanel, "Difficulty Sorting Direction", "difficulty_sorting", SortingDirection.Descending);
ConfigPanel diffPanel = new ConfigPanel(config.rootPanel, "Config Difficulties", "diff_panel", (PanelFieldType)3);
ConfigHeader val3 = new ConfigHeader(config.rootPanel, "--Entry Visibility--", 24);
ActiveDiffVis = new BoolField(config.rootPanel, "Show Times of Active Difficulty", "active_diff_vis", true);
DiffVis = new BoolField(config.rootPanel, "Hide Other Difficulty Times", "diff_vis", false);
HideTimesAboveYourOwn = new BoolField(config.rootPanel, "Hide Times Above Your Own", "better_times_vis", false);
HideOthers = new BoolField(config.rootPanel, "Hide Other Players", "others_vis", false);
CreatePerUserConfig();
CreateConfigDifficulties(diffPanel);
ConfigHeader val4 = new ConfigHeader(config.rootPanel, "--Other--", 24);
AnyRecordColor = new ColorField(config.rootPanel, "ANY% Best time Color", "any_record_color", new Color(0.416f, 0.809f, 0.82f));
PRankRecordColor = new ColorField(config.rootPanel, "P-RANK Best time Color", "prank_record_color", new Color(0.93f, 0.64f, 0f));
EnableBestWaveAnimation = new BoolField(config.rootPanel, "Best Time WAVE Animation", "enable_record_wave", true);
ColorizeDifficulties = new BoolField(config.rootPanel, "Colorize Difficulties", "colorize_difficulties", true);
ConfigPanel feedbackButton = new ConfigPanel(config.rootPanel, "Send FEEDBACK / REPORT BUG (discord)", "feedback_button", (PanelFieldType)3);
feedbackButton.onPannelOpenEvent += (OpenPanelEventDelegate)delegate
{
Process.Start("https://discord.gg/KcsjvKa6jw");
feedbackButton.ClosePanel();
};
}
private void CreatePerUserConfig()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
UserPanel = new ConfigPanel(config.rootPanel, "Config Friends Visibility", "user_panel", (PanelFieldType)3);
((ConfigField)UserPanel).interactable = !HideOthers.value;
HideOthers.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
{
((ConfigField)UserPanel).interactable = !e.value;
};
UserPanel.onPannelOpenEvent += (OpenPanelEventDelegate)delegate
{
RefreshFriends();
};
}
public async void RefreshFriends()
{
LeaderboardController leaderboardController = MonoSingleton<LeaderboardController>.Instance;
LeaderboardEntry[] entries = await leaderboardController.GetLevelScores("Level 0-1", false);
List<Friend> friends = new List<Friend>();
LeaderboardEntry[] array = entries;
for (int i = 0; i < array.Length; i++)
{
LeaderboardEntry entry = array[i];
friends.Add(entry.User);
}
friends = new List<Friend>(friends.OrderBy((Friend x) => ((Friend)(ref x)).Name));
if (friends == null)
{
return;
}
foreach (Friend item in friends)
{
Friend friend = item;
if (!((Friend)(ref friend)).IsMe)
{
if (!UserVisibilityToggles.ContainsKey(friend.Id))
{
CreateUserEntry(UserPanel, friend);
}
else
{
SetUserIcon(friend);
}
}
}
}
private static void CreateUserEntry(ConfigPanel panel, Friend friend)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
ConfigPanel val = new ConfigPanel(panel, ((Friend)(ref friend)).Name, "friend_" + friend.Id.Value, (PanelFieldType)1);
val.buttonText = "CONFIG";
BoolField value = new BoolField(val, "Show Times of " + ((Friend)(ref friend)).Name, "friend_" + friend.Id.Value + "_vis", true);
UserVisibilityToggles.Add(friend.Id, value);
UserPanels.Add(friend.Id, val);
SetUserIcon(friend);
}
private static void SetUserIcon(Friend friend)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (UserPanels.ContainsKey(friend.Id))
{
ConfigPanel val = UserPanels[friend.Id];
GameObject val2 = new GameObject();
RawImage val3 = val2.AddComponent<RawImage>();
SteamController.FetchAvatar(val3, friend);
Texture2D val4 = FlipTexture((Texture2D)val3.texture);
val.icon = Sprite.Create(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), Vector2.one * 0.5f);
Object.Destroy((Object)(object)val2);
}
}
private static Texture2D FlipTexture(Texture2D original)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(((Texture)original).width, ((Texture)original).height);
for (int i = 0; i < ((Texture)original).width; i++)
{
for (int j = 0; j < ((Texture)original).height; j++)
{
val.SetPixel(i, ((Texture)original).height - j - 1, original.GetPixel(i, j));
}
}
val.Apply();
return val;
}
private void CreateConfigDifficulties(ConfigPanel diffPanel)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_00ce: 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)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Expected O, but got Unknown
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Expected O, but got Unknown
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
((ConfigField)diffPanel).interactable = !DiffVis.value || !BlockAllRecords.value || AllowAllLocalTimes.value;
ActiveDiffVis.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
{
DiffVis.value = DiffVis.value && e.value;
((ConfigField)DiffVis).interactable = e.value;
DiffVis.TriggerValueChangeEvent();
};
ConfigHeader val = new ConfigHeader(diffPanel, "--ACCESSIBLE--", 24);
val.textColor = HarmlessColor;
DifficultyOption difficultyOption = DifficultyOption.Create((GameDifficulty)0, diffPanel, HarmlessColor);
DifficultyOption difficultyOption2 = DifficultyOption.Create((GameDifficulty)1, diffPanel, LenientColor);
ConfigHeader val2 = new ConfigHeader(diffPanel, "", 24);
ConfigHeader val3 = new ConfigHeader(diffPanel, "--HARD--", 24);
val3.textColor = StandardColor;
DifficultyOption difficultyOption3 = DifficultyOption.Create((GameDifficulty)2, diffPanel, StandardColor);
DifficultyOption difficultyOption4 = DifficultyOption.Create((GameDifficulty)3, diffPanel, ViolentColor);
ConfigHeader val4 = new ConfigHeader(diffPanel, "", 24);
ConfigHeader val5 = new ConfigHeader(diffPanel, "--VERY HARD--", 24);
val5.textColor = BrutalColor;
DifficultyOption difficultyOption5 = DifficultyOption.Create((GameDifficulty)4, diffPanel, BrutalColor);
DifficultyOption difficultyOption6 = DifficultyOption.Create((GameDifficulty)5, diffPanel, UKMDColor);
DiffVis.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
{
foreach (DifficultyOption value in DifficultyVisibility.Values)
{
((ConfigField)value.VisibilityField).interactable = !e.value;
}
((ConfigField)diffPanel).interactable = !e.value || !BlockAllRecords.value || AllowAllLocalTimes.value;
};
BlockAllRecords.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
{
foreach (DifficultyOption value2 in DifficultyVisibility.Values)
{
((ConfigField)value2.RecordSetField).interactable = !e.value;
}
((ConfigField)diffPanel).interactable = !DiffVis.value || !e.value || AllowAllLocalTimes.value;
};
AllowAllLocalTimes.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
{
foreach (DifficultyOption value3 in DifficultyVisibility.Values)
{
((ConfigField)value3.LocalTimeSetField).interactable = e.value;
}
((ConfigField)diffPanel).interactable = !DiffVis.value || !BlockAllRecords.value || e.value;
};
}
}
}
namespace UltrakillDifficultyLeaderboard.HarmonyPatches
{
[HarmonyPatch(typeof(DifficultySelectButton))]
public class DifficultySelectButtonPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__0_0;
internal void <StartPostfix>b__0_0()
{
LeaderboardPlugin.Instance.RefreshFriends();
}
}
[HarmonyPostfix]
[HarmonyPatch("Start")]
private static void StartPostfix(DifficultySelectButton __instance)
{
//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_0030: Expected O, but got Unknown
ButtonClickedEvent onClick = ((Component)__instance).gameObject.GetComponent<Button>().onClick;
object obj = <>c.<>9__0_0;
if (obj == null)
{
UnityAction val = delegate
{
LeaderboardPlugin.Instance.RefreshFriends();
};
<>c.<>9__0_0 = val;
obj = (object)val;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
}
}
[HarmonyPatch(typeof(GameProgressSaver))]
public class GameProgressSaverPatch
{
[HarmonyPrefix]
[HarmonyPatch("SetBestCyber")]
private static bool SetBestCyberPrefix(ref FinalCyberRank fcr)
{
int num = MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
if ((LeaderboardPlugin.DifficultyVisibility.ContainsKey((GameDifficulty)num) || LeaderboardPlugin.Instance.BlockAllCybergrindRecords.value) && (!LeaderboardPlugin.DifficultyVisibility[(GameDifficulty)num].LocalTimeSetField.value || LeaderboardPlugin.Instance.BlockAllCybergrindRecords.value))
{
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch("PrepareFs")]
private static void PrepareFsPostfix()
{
}
}
[HarmonyPatch(typeof(LeaderboardController))]
public class LeaderboardControllerPatch
{
public static Dictionary<string, LoadedLeaderboardEntry> LeaderboardEntriesMap = new Dictionary<string, LoadedLeaderboardEntry>();
[HarmonyPostfix]
[HarmonyPatch("FetchLeaderboardEntries")]
private static void FetchLeaderboardEntriesPostfix(string key, LeaderboardType type, int count, bool createIfNotFound, LeaderboardSort defaultSortMode, ref Task<LeaderboardEntry[]> __result)
{
if (!key.Contains("Cyber Grind"))
{
bool pRankFromKey = GetPRankFromKey(key);
string levelFromKey = GetLevelFromKey(key);
Task<LeaderboardEntry[]> task = ModifyLeaderboardEntries(levelFromKey, pRankFromKey, __result);
__result = task;
}
}
public static string GetLevelFromKey(string key)
{
if (key.StartsWith("Level "))
{
bool pRankFromKey = GetPRankFromKey(key);
if (!string.IsNullOrWhiteSpace(key))
{
int num = key.IndexOf(pRankFromKey ? " PRank" : " Any%", StringComparison.Ordinal);
if (num > 0)
{
return key.Substring(0, num);
}
}
}
return "";
}
public static bool GetPRankFromKey(string key)
{
return key.Contains("PRank");
}
[HarmonyPrefix]
[HarmonyPatch("SubmitCyberGrindScore")]
private static bool SubmitCyberGrindScorePrefix(ref int difficulty, ref float wave, ref int kills, ref int style, ref float seconds)
{
if ((LeaderboardPlugin.DifficultyVisibility.ContainsKey((GameDifficulty)difficulty) || LeaderboardPlugin.Instance.BlockAllCybergrindRecords.value) && (!LeaderboardPlugin.DifficultyVisibility[(GameDifficulty)difficulty].RecordSetField.value || LeaderboardPlugin.Instance.BlockAllCybergrindRecords.value))
{
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("SubmitLevelScore")]
private static bool SubmitScoreAsyncPrefix(ref string levelName, ref int difficulty, ref float seconds, ref int kills, ref int style, ref int restartCount, ref bool pRank)
{
if (LeaderboardPlugin.Instance.BlockAllRecords.value)
{
return false;
}
if (LeaderboardPlugin.DifficultyVisibility.ContainsKey((GameDifficulty)difficulty) && !LeaderboardPlugin.DifficultyVisibility[(GameDifficulty)difficulty].RecordSetField.value)
{
return false;
}
if (LeaderboardPlugin.DifficultyVisibility.ContainsKey((GameDifficulty)difficulty) && LeaderboardPlugin.DifficultyVisibility[(GameDifficulty)difficulty].LocalTimeSetField.value && LeaderboardPlugin.Instance.AllowAllLocalTimes.value)
{
LeaderboardLocalTimeManager.SetBestLocalTime(levelName, difficulty, seconds, pRank);
}
return true;
}
private static async Task<LeaderboardEntry[]> ModifyLeaderboardEntries(string levelName, bool pRank, Task<LeaderboardEntry[]> original)
{
LeaderboardEntry[] entries = await original;
if (entries == null)
{
return (LeaderboardEntry[])(object)new LeaderboardEntry[0];
}
List<LeaderboardEntry> modifiedEntries = new List<LeaderboardEntry>();
int difficulty = MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
if (!string.IsNullOrEmpty(levelName))
{
for (int i = 0; i < 6; i++)
{
float localTime = LeaderboardLocalTimeManager.GetBestLocalTime(levelName, i, pRank);
if (localTime > 0f)
{
LeaderboardEntry localEntry = new LeaderboardEntry
{
User = new Friend(SteamClient.SteamId),
Score = (int)(localTime * 1000f),
Details = new int[1] { i }
};
Array.Resize(ref entries, entries.Length + 1);
entries[^1] = localEntry;
}
}
}
bool showOnlyActive = LeaderboardPlugin.Instance.DiffVis.value;
bool showActive = LeaderboardPlugin.Instance.ActiveDiffVis.value || showOnlyActive;
int personalBestTime = int.MaxValue;
for (int j = 0; j < entries.Length; j++)
{
LeaderboardEntry entry = entries[j];
bool isOtherAndHidden = (LeaderboardPlugin.Instance.HideOthers.value || (LeaderboardPlugin.UserVisibilityToggles.ContainsKey(entry.User.Id) && !LeaderboardPlugin.UserVisibilityToggles[entry.User.Id].value)) && !((Friend)(ref entry.User)).IsMe;
if (showActive && entry.Details[0] == difficulty && !isOtherAndHidden)
{
modifiedEntries.Add(entry);
}
else if (!showOnlyActive && LeaderboardPlugin.DifficultyVisibility.ContainsKey((GameDifficulty)entry.Details[0]) && LeaderboardPlugin.DifficultyVisibility[(GameDifficulty)entry.Details[0]].VisibilityField.value && !isOtherAndHidden)
{
modifiedEntries.Add(entry);
}
else
{
entry = default(LeaderboardEntry);
}
}
personalBestTime = Mathf.Min(personalBestTime, (from e in modifiedEntries
where ((Friend)(ref e.User)).IsMe
orderby e.Score
select e).FirstOrDefault().Score);
int personalBestTimeOnDifficulty = Mathf.Min(personalBestTime, (from e in modifiedEntries
where ((Friend)(ref e.User)).IsMe && e.Details[0] == difficulty
orderby e.Score
select e).FirstOrDefault().Score);
for (int i2 = 0; i2 < 6; i2++)
{
LeaderboardEntry lowestEntry = (from e in modifiedEntries
where ((Friend)(ref e.User)).IsMe && e.Details[0] == i2
orderby e.Score
select e).FirstOrDefault();
modifiedEntries.RemoveAll((LeaderboardEntry e) => modifiedEntries.IndexOf(e) != modifiedEntries.IndexOf(lowestEntry) && ((Friend)(ref e.User)).IsMe && e.Details[0] == i2 && e.Score >= lowestEntry.Score);
}
if (LeaderboardPlugin.Instance.HideTimesAboveYourOwn.value)
{
modifiedEntries.RemoveAll((LeaderboardEntry e) => !((Friend)(ref e.User)).IsMe && e.Score < personalBestTime);
}
if (LeaderboardPlugin.Instance.PerDifficultySortingBehavior.value == DifficultySortingBehavior.PerDifficulty)
{
modifiedEntries = SortPerDifficulty(modifiedEntries);
}
else
{
modifiedEntries = SortEntries(modifiedEntries);
}
int best = ((LeaderboardPlugin.Instance.PerDifficultySortingBehavior.value == DifficultySortingBehavior.PerDifficulty) ? personalBestTimeOnDifficulty : personalBestTime);
LoadedLeaderboardEntry leaderboard = new LoadedLeaderboardEntry(personalBestIndex: modifiedEntries.FindIndex((LeaderboardEntry e) => e.Score == best), personalBestToHighlightIndex: modifiedEntries.FindIndex((LeaderboardEntry e) => e.Score == personalBestTime), entries: modifiedEntries, isPRank: pRank);
LeaderboardEntriesMap[levelName] = leaderboard;
return modifiedEntries.ToArray();
}
private static List<LeaderboardEntry> SortPerDifficulty(List<LeaderboardEntry> entries)
{
List<LeaderboardEntry> list = new List<LeaderboardEntry>();
for (int i = 0; i < 6; i++)
{
int index = i;
if (LeaderboardPlugin.Instance.PerDifficultySortingDirection.value == SortingDirection.Descending)
{
index = 5 - i;
}
List<LeaderboardEntry> entries2 = entries.Where((LeaderboardEntry e) => e.Details[0] == index).ToList();
entries2 = SortEntries(entries2);
list.AddRange(entries2);
}
return list;
}
private static List<LeaderboardEntry> SortEntries(List<LeaderboardEntry> entries)
{
TimeSortingBehavior value = LeaderboardPlugin.Instance.TypeSortingBehavior.value;
SortingDirection value2 = LeaderboardPlugin.Instance.TypeSortingDirection.value;
switch (value)
{
case TimeSortingBehavior.Time:
entries = new List<LeaderboardEntry>(entries.OrderByDescending((LeaderboardEntry e) => e.Score));
if (value2 == SortingDirection.Ascending)
{
entries.Reverse();
}
break;
case TimeSortingBehavior.Alphabetical:
entries = new List<LeaderboardEntry>(entries.OrderBy((LeaderboardEntry x) => ((Friend)(ref x.User)).Name));
if (value2 == SortingDirection.Descending)
{
entries.Reverse();
}
break;
}
return entries;
}
}
[HarmonyPatch(typeof(SteamController))]
public class SteamControllerPatch
{
private static readonly FieldInfo ContainerField = AccessTools.Field(typeof(LevelSelectLeaderboard), "container");
private static readonly FieldInfo IsPRankSelectedField = AccessTools.Field(typeof(LevelSelectLeaderboard), "pRankSelected");
private static readonly FieldInfo OwnEntryIndexField = AccessTools.Field(typeof(LevelSelectLeaderboard), "ownEntryIndex");
private static readonly Color HighlightOutlineColor = new Color(1f, 1f, 1f, 1f);
private static readonly Color HighlightBackgroundColor = new Color(0.745f, 0.745f, 0.745f, 0.349f);
private static readonly Color BackgroundColor = new Color(0.5f, 0.5f, 0.5f, 0.239f);
private static Dictionary<TMP_Text, string> pRankBests = new Dictionary<TMP_Text, string>();
private static Dictionary<TMP_Text, string> anyBests = new Dictionary<TMP_Text, string>();
[HarmonyPostfix]
[HarmonyPatch("FetchAvatar")]
private static void FetchAvatarPostfix(RawImage target, Friend user)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)target == (Object)null))
{
LevelSelectLeaderboard componentInParent = ((Component)target).GetComponentInParent<LevelSelectLeaderboard>();
if (!((Object)(object)componentInParent == (Object)null))
{
ChangeLevelSelectLeaderboards(((Component)target).gameObject, componentInParent, user);
}
}
}
private static void ChangeLevelSelectLeaderboards(GameObject avatarObject, LevelSelectLeaderboard leaderboard, Friend user)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: 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_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: 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_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0484: Unknown result type (might be due to invalid IL or missing references)
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
Transform val = (Transform)ContainerField.GetValue(leaderboard);
string key = "Level " + leaderboard.layerLevelNumber;
bool flag = (bool)IsPRankSelectedField.GetValue(leaderboard);
int num = (int)OwnEntryIndexField.GetValue(leaderboard);
LoadedLeaderboardEntry loadedLeaderboardEntry = LeaderboardControllerPatch.LeaderboardEntriesMap[key];
Transform val2 = avatarObject.transform;
while ((Object)(object)val2 != (Object)null && (Object)(object)val2.parent != (Object)(object)val)
{
val2 = val2.parent;
}
if ((Object)(object)val2 == (Object)null)
{
return;
}
int num2 = val2.GetSiblingIndex() - 1;
LeaderboardEntry val3 = loadedLeaderboardEntry.entries[num2];
int num3 = val3.Details[0];
bool flag2 = num2 == loadedLeaderboardEntry.personalBestIndex;
bool flag3 = num2 == loadedLeaderboardEntry.personalBestToHighlightIndex;
Color val4 = LeaderboardPlugin.DifficultyVisibility[(GameDifficulty)num3].DifficultyColor.value;
if (!LeaderboardPlugin.Instance.ColorizeDifficulties.value)
{
val4 = Color.white;
}
OwnEntryIndexField.SetValue(leaderboard, loadedLeaderboardEntry.personalBestIndex);
Image[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Image>(true);
foreach (Image val5 in componentsInChildren)
{
if (((Object)((Component)val5).gameObject).name.Contains("Highlight"))
{
if (((Object)((Component)val5).gameObject).name.Contains("Background"))
{
((Graphic)val5).color = HighlightBackgroundColor;
if (LeaderboardPlugin.Instance.ColorizeDifficulties.value)
{
((Graphic)val5).color = ((Graphic)val5).color * val4;
((Graphic)val5).color = ((Graphic)val5).color * ((Graphic)val5).color.a;
((Graphic)val5).color = new Color(((Graphic)val5).color.r, ((Graphic)val5).color.g, ((Graphic)val5).color.b, 0.75f);
}
if (!flag2)
{
((Graphic)val5).color = new Color(((Graphic)val5).color.r, ((Graphic)val5).color.g, ((Graphic)val5).color.b, ((Graphic)val5).color.a / 2f);
}
}
else
{
((Graphic)val5).color = HighlightOutlineColor;
((Graphic)val5).color = ((Graphic)val5).color * val4;
if (!flag2)
{
((Graphic)val5).color = new Color(((Graphic)val5).color.r, ((Graphic)val5).color.g, ((Graphic)val5).color.b, 0.25f);
}
}
}
else if (LeaderboardPlugin.Instance.ColorizeDifficulties.value)
{
((Graphic)val5).color = BackgroundColor;
((Graphic)val5).color = ((Graphic)val5).color * val4;
((Graphic)val5).color = ((Graphic)val5).color * ((Graphic)val5).color.a;
((Graphic)val5).color = new Color(((Graphic)val5).color.r, ((Graphic)val5).color.g, ((Graphic)val5).color.b, 0.6f);
}
}
TMP_Text[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<TMP_Text>(true);
foreach (TMP_Text val6 in componentsInChildren2)
{
if (((Object)val6).name.Contains("Username"))
{
((Graphic)val6).color = Color.white;
if (((Friend)(ref val3.User)).IsMe)
{
((Graphic)val6).color = Color.white;
if (flag2)
{
val6.text = "<b>" + val6.text + "</b>";
}
}
}
else if (((Object)val6).name.Contains("Difficulty"))
{
((Graphic)val6).color = val4;
if (((Friend)(ref val3.User)).IsMe && flag2)
{
((Graphic)val6).color = Color.white;
val6.text = "<b>" + val6.text + "</b>";
}
}
else
{
if (!((Object)val6).name.Contains("Time"))
{
continue;
}
((Graphic)val6).color = Color.white;
if (flag3 && !pRankBests.ContainsKey(val6))
{
if (flag)
{
pRankBests.Add(val6, val6.text);
}
else
{
anyBests.Add(val6, val6.text);
}
}
}
}
}
public static void UpdateRealBests()
{
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: 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_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
List<TMP_Text> list = new List<TMP_Text>();
foreach (KeyValuePair<TMP_Text, string> item in pRankBests.Where<KeyValuePair<TMP_Text, string>>((KeyValuePair<TMP_Text, string> e) => ((UIBehaviour)e.Key).IsDestroyed()))
{
list.Add(item.Key);
}
foreach (TMP_Text item2 in list)
{
pRankBests.Remove(item2);
}
list.Clear();
foreach (KeyValuePair<TMP_Text, string> item3 in anyBests.Where<KeyValuePair<TMP_Text, string>>((KeyValuePair<TMP_Text, string> e) => ((UIBehaviour)e.Key).IsDestroyed()))
{
list.Add(item3.Key);
}
foreach (TMP_Text item4 in list)
{
anyBests.Remove(item4);
}
for (int num = 0; num < pRankBests.Count; num++)
{
TMP_Text val = pRankBests.Keys.ToList()[num];
string text = pRankBests[val];
if (((UIBehaviour)val).IsDestroyed())
{
continue;
}
string text2 = "";
for (int num2 = 0; num2 < text.Length; num2++)
{
char c = text[num2];
string text3 = (LeaderboardPlugin.Instance.EnableBestWaveAnimation.value ? (Mathf.Sin(Time.time * 3f + (float)num2) / 25f) : 0f).ToString("0.00");
float num3 = Mathf.Clamp01(Mathf.Sin(Time.time * 3f + (float)num2 / 3f) + 1f) * 5f;
Color val2 = Color.Lerp(Color.white, LeaderboardPlugin.Instance.PRankRecordColor.value, num3);
if (!LeaderboardPlugin.Instance.ColorizeDifficulties.value)
{
val2 = Color.white;
}
string text4 = "#" + ColorUtility.ToHtmlStringRGBA(val2);
text2 = text2 + "<voffset=" + text3 + "em>";
text2 += "<b>";
text2 = text2 + "<color=" + text4.ToUpper() + ">";
text2 += c;
text2 += "</color>";
text2 += "</b>";
text2 += "</voffset>";
}
val.text = text2;
}
for (int num4 = 0; num4 < anyBests.Count; num4++)
{
TMP_Text val3 = anyBests.Keys.ToList()[num4];
string text5 = anyBests[val3];
if (((UIBehaviour)val3).IsDestroyed())
{
continue;
}
string text6 = "";
for (int num5 = 0; num5 < text5.Length; num5++)
{
char c2 = text5[num5];
string text7 = (LeaderboardPlugin.Instance.EnableBestWaveAnimation.value ? (Mathf.Sin(Time.time * 3f + (float)num5) / 25f) : 0f).ToString("0.00");
float num6 = Mathf.Clamp01(Mathf.Sin(Time.time * 3f + (float)num5 / 3f) + 1f) * 5f;
Color val4 = Color.Lerp(Color.white, LeaderboardPlugin.Instance.AnyRecordColor.value, num6);
if (!LeaderboardPlugin.Instance.ColorizeDifficulties.value)
{
val4 = Color.white;
}
string text8 = "#" + ColorUtility.ToHtmlStringRGBA(val4);
text6 = text6 + "<voffset=" + text7 + "em>";
text6 += "<b>";
text6 = text6 + "<color=" + text8.ToUpper() + ">";
text6 += c2;
text6 += "</color>";
text6 += "</b>";
text6 += "</voffset>";
}
val3.text = text6;
}
}
}
}
namespace UltrakillDifficultyLeaderboard.Data
{
public class DifficultyOption
{
public GameDifficulty Difficulty { get; }
public BoolField VisibilityField { get; set; }
public BoolField RecordSetField { get; set; }
public BoolField LocalTimeSetField { get; set; }
public ColorField DifficultyColor { get; set; }
public unsafe DifficultyOption(GameDifficulty difficulty, ConfigPanel panel, Color defaultColor)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected O, but got Unknown
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected O, but got Unknown
Difficulty = difficulty;
string text = ((object)(*(GameDifficulty*)(&difficulty))/*cast due to .constrained prefix*/).ToString().ToUpper();
string text2 = ((object)(*(GameDifficulty*)(&difficulty))/*cast due to .constrained prefix*/).ToString().ToLower();
ConfigPanel val = new ConfigPanel(panel, text, text2 + "_panel");
val.buttonText = "CONFIG";
ConfigHeader val2 = new ConfigHeader(val, "--Entry Visibility--", 24);
DifficultyColor = new ColorField(val, "Color", text2 + "_color", defaultColor);
VisibilityField = new BoolField(val, "Show " + text + " Times\non Leaderboards", text2 + "_vis_toggle", true);
ConfigHeader val3 = new ConfigHeader(val, "--Record Management--", 24);
RecordSetField = new BoolField(val, "Allow new " + text + "\nRecords", text2 + "_time_toggle", true);
LocalTimeSetField = new BoolField(val, "Save " + text + " Times\nLocally", text2 + "_time_local_toggle", true);
ConfigHeader val4 = new ConfigHeader(val, "--DANGER ZONE--", 24);
val4.textColor = Color.red;
ConfigPanel erasePanel = new ConfigPanel(val, "ERASE LOCAL TIME", text2 + "_panel");
ConfigPanel erasePRankPanel = new ConfigPanel(val, "ERASE LOCAL P-RANK TIME", text2 + "_prank_panel");
erasePanel.onPannelOpenEvent += (OpenPanelEventDelegate)delegate
{
RefreshLocalTimes(erasePanel);
};
erasePRankPanel.onPannelOpenEvent += (OpenPanelEventDelegate)delegate
{
RefreshLocalTimes(erasePRankPanel);
};
((ConfigField)VisibilityField).interactable = !LeaderboardPlugin.Instance.DiffVis.value;
((ConfigField)RecordSetField).interactable = !LeaderboardPlugin.Instance.BlockAllRecords.value;
((ConfigField)LocalTimeSetField).interactable = LeaderboardPlugin.Instance.AllowAllLocalTimes.value;
}
public void RefreshLocalTimes(ConfigPanel panel)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected I4, but got Unknown
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Expected O, but got Unknown
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Expected O, but got Unknown
bool prank = ((ConfigField)panel).guid.Contains("prank");
ConfigHeader val = new ConfigHeader(panel, "NO LOCAL TIMES FOUND", 24);
((ConfigField)val).hidden = true;
ConfigHeader val2 = new ConfigHeader(panel, "FOR THIS DIFFICULTY", 24);
((ConfigField)val2).hidden = true;
bool flag = true;
string[] files = Directory.GetFiles(LeaderboardLocalTimeManager.localTimesSavesDir, "*.bepis", SearchOption.TopDirectoryOnly);
foreach (string text in files)
{
flag = false;
string levelName = text.Replace(LeaderboardLocalTimeManager.localTimesSavesDir, "").Replace("_localtimes.bepis", "").Replace("\\", "")
.Replace("/", "");
float bestLocalTime = LeaderboardLocalTimeManager.GetBestLocalTime(levelName, (int)Difficulty, prank);
if (bestLocalTime > 0f)
{
string text2 = (prank ? "P-RANK" : "ANY%");
string text3 = levelName.Replace("Level ", "");
ConfigPanel eraseButton = new ConfigPanel(panel, "[" + text3 + "] RESET Local Time [" + text2 + "]", levelName + "any_erase_button", (PanelFieldType)3);
eraseButton.onPannelOpenEvent += (OpenPanelEventDelegate)delegate
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected I4, but got Unknown
LeaderboardLocalTimeManager.ResetLocalTime(levelName, (int)Difficulty, prank);
eraseButton.ClosePanel();
((ConfigField)eraseButton).hidden = true;
};
panel.onPannelCloseEvent += (ClosePanelEventDelegate)delegate
{
((ConfigField)eraseButton).hidden = true;
};
}
}
if (flag)
{
((ConfigField)val).hidden = false;
((ConfigField)val2).hidden = false;
}
}
public static DifficultyOption Create(GameDifficulty difficulty, ConfigPanel panel, Color defaultColor)
{
//IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references)
DifficultyOption difficultyOption = new DifficultyOption(difficulty, panel, defaultColor);
LeaderboardPlugin.DifficultyVisibility.Add(difficulty, difficultyOption);
return difficultyOption;
}
}
[Serializable]
public class LeaderboardLocalTime
{
public float[] Time;
public float[] PRankTime;
public LeaderboardLocalTime()
{
Time = new float[6];
PRankTime = new float[6];
}
}
public class LeaderboardLocalTimeManager
{
private static string customSavesDir => Path.Combine(GameProgressSaver.SavePath, "Custom");
public static string localTimesSavesDir => Path.Combine(GameProgressSaver.SavePath, "LeaderboardManager");
private static string localBestTimesPath(string levelName)
{
return Path.Combine(localTimesSavesDir, levelName + "_localtimes.bepis");
}
private static LeaderboardLocalTime GetLocalTimesData(string levelName)
{
LeaderboardLocalTime leaderboardLocalTime = ReadFile(localBestTimesPath(levelName)) as LeaderboardLocalTime;
if (leaderboardLocalTime == null)
{
leaderboardLocalTime = new LeaderboardLocalTime();
}
if (leaderboardLocalTime.Time.Length == 0)
{
leaderboardLocalTime.Time = new float[6];
}
if (leaderboardLocalTime.PRankTime.Length == 0)
{
leaderboardLocalTime.PRankTime = new float[6];
}
return leaderboardLocalTime;
}
public static float GetBestLocalTime(string levelName, int difficulty, bool pRank)
{
if (SceneHelper.IsPlayingCustom)
{
return 0f;
}
LeaderboardLocalTime localTimesData = GetLocalTimesData(levelName);
float[] array = (pRank ? localTimesData.PRankTime : localTimesData.Time);
return array[difficulty];
}
public static void SetBestLocalTime(string levelName, int difficulty, float time, bool pRank)
{
if (SceneHelper.IsPlayingCustom)
{
return;
}
float bestLocalTime = GetBestLocalTime(levelName, difficulty, pRank);
if (bestLocalTime > time || bestLocalTime == 0f)
{
LeaderboardLocalTime localTimesData = GetLocalTimesData(levelName);
if (pRank)
{
localTimesData.PRankTime[difficulty] = time;
}
else
{
localTimesData.Time[difficulty] = time;
}
WriteFile(localBestTimesPath(levelName), localTimesData);
}
}
public static void ResetLocalTime(string levelName, int difficulty, bool pRank)
{
if (!SceneHelper.IsPlayingCustom)
{
LeaderboardLocalTime localTimesData = GetLocalTimesData(levelName);
if (pRank)
{
localTimesData.PRankTime[difficulty] = 0f;
}
else
{
localTimesData.Time[difficulty] = 0f;
}
WriteFile(localBestTimesPath(levelName), localTimesData);
}
}
private static void WriteFile(string path, object data)
{
Debug.Log((object)("[FS] Writing To " + path));
Directory.CreateDirectory(Path.GetDirectoryName(path));
using FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate);
BinaryFormatter binaryFormatter = new BinaryFormatter();
try
{
binaryFormatter.Serialize(fileStream, data);
fileStream.Close();
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
private static object ReadFile(string path)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
if (!File.Exists(path))
{
return null;
}
using FileStream fileStream = new FileStream(path, FileMode.Open);
if (fileStream.Length == 0L)
{
throw new Exception("Stream Length 0");
}
BinaryFormatter binaryFormatter = new BinaryFormatter();
RestrictedSerializationBinder val = new RestrictedSerializationBinder();
val.AllowedTypes.Add(typeof(RankData));
val.AllowedTypes.Add(typeof(CyberRankData));
val.AllowedTypes.Add(typeof(RankScoreData));
val.AllowedTypes.Add(typeof(GameProgressData));
val.AllowedTypes.Add(typeof(GameProgressMoneyAndGear));
val.AllowedTypes.Add(typeof(LeaderboardLocalTime));
binaryFormatter.Binder = (SerializationBinder?)(object)val;
return binaryFormatter.Deserialize(fileStream);
}
}
public class LoadedLeaderboardEntry
{
public List<LeaderboardEntry> entries;
public int personalBestIndex;
public int personalBestToHighlightIndex;
public bool isPRank;
public LoadedLeaderboardEntry(List<LeaderboardEntry> entries, int personalBestIndex, bool isPRank, int personalBestToHighlightIndex)
{
this.entries = entries;
this.personalBestIndex = personalBestIndex;
this.isPRank = isPRank;
this.personalBestToHighlightIndex = personalBestToHighlightIndex;
}
}
public enum DifficultySortingBehavior
{
NoSorting,
PerDifficulty
}
public enum SortingDirection
{
Ascending,
Descending
}
public enum TimeSortingBehavior
{
Time,
Alphabetical
}
}