using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeStage.AntiCheat.ObscuredTypes;
using HarmonyLib;
using LLScreen;
using Microsoft.CodeAnalysis;
using Multiplayer;
using Steamworks;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("DivDisplay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DivDisplay")]
[assembly: AssemblyTitle("DivDisplay")]
[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 DivDisplay
{
[BepInPlugin("com.github.daioutzu.divdisplay", "DivDisplay", "1.0.0")]
[BepInProcess("LLBlaze.exe")]
public class DivDisplay : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private Harmony Harmony = new Harmony("com.github.daioutzu.divdisplay");
internal ConfigEntry<bool> ShowOnlyDuringRanked;
internal Dictionary<string, PlayerRank> cachedPlayerRanks = new Dictionary<string, PlayerRank>(4);
internal static DivDisplay Instance { get; private set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
ShowOnlyDuringRanked = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "During Ranked Only", false, "Only shows the Division icon during a ranked match");
Harmony.PatchAll(typeof(Event));
Harmony.PatchAll(typeof(Steam_Leaderboard));
Event.OnLinkToPlayer += OnLinkToPlayer;
Event.OnRemoveOther += OnRemoveOther;
Event.OnRemoveSelf += OnRemoveSelf;
Event.AfterGameHudOpen += AfterGameHudOpen;
Logger.LogInfo((object)"Plugin DivDisplay is loaded!");
}
private void OnLinkToPlayer(Peer peer, int playerNr)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
if ((int)JOMBNFKIHIC.OIACPNLFAKK() == 3 || !ShowOnlyDuringRanked.Value)
{
if (cachedPlayerRanks.ContainsKey(peer.peerId))
{
Logger.LogWarning((object)$"{peer.peerId} : Already in cachedPlayerRanks");
}
else
{
cachedPlayerRanks.Add(peer.peerId, new PlayerRank(playerNr));
}
}
}
private void OnRemoveSelf(P2P peer)
{
cachedPlayerRanks?.Clear();
}
private void OnRemoveOther(P2P peer, Peer otherPeer)
{
if (otherPeer?.peerId == null)
{
Logger.LogError((object)"OnRemoveOther: failed to remove. otherPeer was null");
}
cachedPlayerRanks.Remove(otherPeer.peerId);
}
private void AfterGameHudOpen(ScreenGameHud hud)
{
UpdatePlayerRanks();
}
private void UpdatePlayerRanks()
{
List<string> list = new List<string>();
foreach (KeyValuePair<string, PlayerRank> cachedPlayerRank in cachedPlayerRanks)
{
if (RankAlreadyDownloaded(cachedPlayerRank.Key, cachedPlayerRank.Value))
{
Logger.LogWarning((object)$"{cachedPlayerRank.Key} : Local");
SetUpRankUI(ALDOKEMAOMB.BJDPHEHJJJK(cachedPlayerRank.Value.playerNr));
}
else
{
Logger.LogWarning((object)$"{cachedPlayerRank.Key} : Remote");
list.Add(cachedPlayerRank.Key);
}
}
if (list.Count == 0)
{
return;
}
try
{
DownloadPlayerRanks(list.ToArray());
}
catch (Exception ex)
{
Logger.LogFatal((object)ex);
}
}
private bool RankAlreadyDownloaded(string peerId, PlayerRank playerRank)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (ObscuredString.op_Implicit(peerId) == CGLLJHHAJAK.ELEKIDCPONL().GBAGFKMGPPF)
{
playerRank.rankScore = ObscuredInt.op_Implicit(CGLLJHHAJAK.ELEKIDCPONL().DDJNFFMLECG());
return true;
}
if (ObscuredString.op_Implicit(peerId) == CGLLJHHAJAK.ELEKIDCPONL().OCOOAGNNDEA)
{
playerRank.rankScore = ObscuredInt.op_Implicit(CGLLJHHAJAK.ELEKIDCPONL().FKMCIHKALDG());
return true;
}
return playerRank.rankScore > 0;
}
internal void DownloadPlayerRanks(string[] uID)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
if (CGLLJHHAJAK.CNEINEKEHMF() == null || !ObscuredBool.op_Implicit(CGLLJHHAJAK.CNEINEKEHMF().EOPAPPANNDE()))
{
Logger.LogError((object)"Learboard was NULL or not Initialized");
}
else if (uID == null || uID.Length != 0)
{
ObscuredString[] array = (ObscuredString[])(object)new ObscuredString[uID.Length];
for (int i = 0; i < uID.Length; i++)
{
array[i] = ObscuredString.op_Implicit(uID[i]);
}
bool wasSuccess = false;
CGLLJHHAJAK.CNEINEKEHMF().JAKPPFAPNAP(array, (MBDKLMKKBLP)delegate(ObscuredBool success, MLLLKIJLMGC[] downloadedEntries)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
wasSuccess = ObscuredBool.op_Implicit(success);
OnRankDownload(success, downloadedEntries);
});
}
}
private void OnRankDownload(ObscuredBool success, MLLLKIJLMGC[] downloadedEntries)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
Logger.LogWarning((object)$"OnRankDownload: {success}");
for (int i = 0; i < downloadedEntries.Length; i++)
{
if (cachedPlayerRanks.TryGetValue(ObscuredString.op_Implicit(downloadedEntries[i].KMHLFHENDDI), out var value))
{
value.rankScore = ObscuredInt.op_Implicit(downloadedEntries[i].BKPKJLGNIMB);
SetUpRankUI(ALDOKEMAOMB.BJDPHEHJJJK(value.playerNr));
}
}
}
private void SetUpRankUI(ALDOKEMAOMB player)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if (player != null)
{
ScreenGameHud instance = ScreenGameHud.instance;
GameHudPlayerInfo val = ((instance != null) ? instance.playerInfos[player.CJFLMDNNMIE] : null);
PlayerRank value;
if (val == null)
{
Logger.LogError((object)$"playerInfo for {player.CJFLMDNNMIE} was null");
}
else if (cachedPlayerRanks.TryGetValue(player.KLEEADMGHNE.peerId, out value))
{
CreateDivIcon(val, ObscuredInt.op_Implicit(value.rankScore));
}
}
}
internal static void CreateDivIcon(GameHudPlayerInfo playerInfo, ObscuredInt rankScore)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("divIcon", new Type[1] { typeof(Image) });
val.transform.SetParent(((Component)playerInfo).transform);
Image component = val.GetComponent<Image>();
HLDHGADFCGH val2 = NJLEDGLLDDJ.LEJPKPFFIIF(ObscuredInt.op_Implicit(rankScore));
if ((int)val2.PACBDHOJMBE == 0)
{
val2 = NJLEDGLLDDJ.HCLNIEKIFDG((BGOPHAMGDGC)0);
}
component.sprite = JPLELOFJOOH.EGHEJAKEOFC(val2.PACBDHOJMBE);
((Graphic)component).SetNativeSize();
((Component)component).transform.localScale = new Vector3(0.4f, 0.4f, 0.4f);
((Component)component).transform.localPosition = new Vector3(120f, -44f, -132f);
}
}
internal class Event
{
internal static event Action<P2P> OnRemoveSelf;
internal static event Action<P2P, Peer> OnRemoveOther;
internal static event Action<Peer, int> OnLinkToPlayer;
internal static event Action<ScreenGameHud> AfterGameHudOpen;
[HarmonyPatch(typeof(Peer), "LinkToPlayer")]
[HarmonyPostfix]
private static void OnLinkToPlayer_Patch(Peer __instance, int _playerNr)
{
Event.OnLinkToPlayer?.Invoke(__instance, _playerNr);
}
[HarmonyPatch(typeof(P2P), "RemoveSelf")]
[HarmonyPostfix]
private static void AfterRemoveSelf(P2P __instance)
{
Event.OnRemoveSelf?.Invoke(__instance);
}
[HarmonyPatch(typeof(P2P), "RemoveOther", new Type[]
{
typeof(Peer),
typeof(DisconnectReason),
typeof(bool)
})]
[HarmonyPostfix]
private static void AfterRemoveOther(P2P __instance, Peer otherPeer)
{
Event.OnRemoveOther?.Invoke(__instance, otherPeer);
}
[HarmonyPatch(typeof(ScreenGameHud), "OnOpen")]
[HarmonyPostfix]
private static void OnOpen_GameHud(ScreenGameHud __instance)
{
Event.AfterGameHudOpen?.Invoke(__instance);
}
}
internal class PlayerRank
{
internal int playerNr = -1;
internal int rankScore;
public PlayerRank(int pNr, int rank = -1)
{
playerNr = pNr;
rankScore = rank;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.github.daioutzu.divdisplay";
public const string PLUGIN_NAME = "DivDisplay";
public const string PLUGIN_VERSION = "1.0.0";
}
internal class Steam_Leaderboard
{
[HarmonyPatch(typeof(IDKAHAEPDHL), "JAKPPFAPNAP")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> InvalidSteamAPI_Fix(IEnumerable<CodeInstruction> instructions, ILGenerator iLGenerator)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, iLGenerator);
val.SearchForward((Func<CodeInstruction, bool>)((CodeInstruction il) => il.opcode == OpCodes.Call && (il.operand as MethodBase).Name == "FMCLMJBADMF")).ThrowIfNotMatch("Didn't find 'Create'", (CodeMatch[])(object)new CodeMatch[0]).Advance(2);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldloc_S, (object)(sbyte)4),
Transpilers.EmitDelegate<Func<IJJKCHBCHOG, SteamAPICall_t, bool>>((Func<IJJKCHBCHOG, SteamAPICall_t, bool>)IsSteamApiCallInValid)
});
val.InsertBranchAndAdvance(OpCodes.Brfalse, val.Pos).Insert((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ret, (object)null)
});
return val.InstructionEnumeration();
}
private static bool IsSteamApiCallInValid(IJJKCHBCHOG leaderboards, SteamAPICall_t steamAPICall_T)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
if (SteamAPICall_t.ODMJDNBPOIH(steamAPICall_T, SteamAPICall_t.Invalid))
{
DivDisplay.Logger.LogFatal((object)"Leaderboard entries were NOT valid");
leaderboards.KGLNKBPKNGD = (AEMCNPCEBLM)2;
return true;
}
return false;
}
}
}