Decompiled source of LobbyPlayersEclipseLevels v1.1.0

plugins/LobbyPlayersEclipseLevels/LobbyPlayersEclipseLevels.dll

Decompiled 2 weeks ago
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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LobbyPlayersEclipseLevels")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+feb8830216cf8cb996f52fe730956c9e438d3eb8")]
[assembly: AssemblyProduct("LobbyPlayersEclipseLevels")]
[assembly: AssemblyTitle("LobbyPlayersEclipseLevels")]
[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;
		}
	}
}
public static class BuildInfo
{
	public const string TargetPath = "I:\\_important\\_hobby\\c#\\ror2mods\\LobbyEclipseInfo\\LobbyPlayersEclipseLevels\\bin\\Release\\netstandard2.1\\LobbyPlayersEclipseLevels.dll";
}
namespace LobbyPlayersEclipseLevels
{
	[BepInPlugin("diselgonk.LobbyPlayersEclipseLevels", "LobbyPlayersEclipseLevels", "1.1.0")]
	public class LobbyPlayersEclipseLevels : BaseUnityPlugin
	{
		public const string PluginGUID = "diselgonk.LobbyPlayersEclipseLevels";

		public const string PluginAuthor = "diselgonk";

		public const string PluginName = "LobbyPlayersEclipseLevels";

		public const string PluginVersion = "1.1.0";

		private readonly Dictionary<NetworkUserId, string> eclipseTooltipCache = new Dictionary<NetworkUserId, string>();

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			VoteInfoPanelController.UpdateElements += new hook_UpdateElements(VoteInfoPanelController_UpdateElements);
			NetworkUser.onNetworkUserUnlockablesUpdated += new NetworkUserGenericDelegate(NetworkUser_OnNetworkUserUnlockablesUpdated);
		}

		private void NetworkUser_OnNetworkUserUnlockablesUpdated(NetworkUser networkUser)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			eclipseTooltipCache[networkUser.id] = GetUserEclipseLevelsFormatted(networkUser);
		}

		private void VoteInfoPanelController_UpdateElements(orig_UpdateElements orig, VoteInfoPanelController self)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!NetworkServer.active)
			{
				return;
			}
			int voteCount = self.voteController.GetVoteCount();
			for (int i = 0; i < voteCount; i++)
			{
				UserVote vote = self.voteController.GetVote(i);
				if (!Object.op_Implicit((Object)(object)vote.networkUserObject))
				{
					Log.Warning("No vote.networkUserObject", "I:\\_important\\_hobby\\c#\\ror2mods\\LobbyEclipseInfo\\LobbyPlayersEclipseLevels\\LobbyPlayersEclipseLevels.cs", 58);
					continue;
				}
				NetworkUser component = vote.networkUserObject.GetComponent<NetworkUser>();
				eclipseTooltipCache.TryGetValue(component.id, out var value);
				if (value != null)
				{
					self.indicators[i].tooltipProvider.overrideBodyText = value;
				}
			}
		}

		private static string GetUserEclipseLevelsFormatted(NetworkUser user)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			_ = user.userName;
			Dictionary<SurvivorDef, int> dictionary = new Dictionary<SurvivorDef, int>();
			foreach (SurvivorDef orderedSurvivorDef in SurvivorCatalog.orderedSurvivorDefs)
			{
				int networkUserSurvivorCompletedEclipseLevel = EclipseRun.GetNetworkUserSurvivorCompletedEclipseLevel(user, orderedSurvivorDef);
				dictionary.Add(orderedSurvivorDef, networkUserSurvivorCompletedEclipseLevel);
			}
			string text = "Finished eclipses: <br>";
			foreach (var (val2, num2) in dictionary)
			{
				if (num2 == 0)
				{
					continue;
				}
				string text2 = Language.GetString(val2.displayNameToken).Trim();
				if (string.IsNullOrEmpty(text2))
				{
					Log.Warning("No survivor display name for " + val2.cachedName, "I:\\_important\\_hobby\\c#\\ror2mods\\LobbyEclipseInfo\\LobbyPlayersEclipseLevels\\LobbyPlayersEclipseLevels.cs", 99);
					continue;
				}
				GameObject bodyPrefab = val2.bodyPrefab;
				CharacterBody obj = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
				Color bodyColor = obj.bodyColor;
				bodyColor.a = 1f;
				string text3 = ColorUtility.ToHtmlStringRGB(obj.bodyColor);
				if (!string.IsNullOrEmpty(text3))
				{
					text = text + "<color=#" + text3 + ">";
				}
				text = text + text2 + " - ";
				text = ((num2 != 8) ? (text + $"{num2}") : (text + $"<i>{num2}</i>"));
				if (!string.IsNullOrEmpty(text3))
				{
					text += "</color><br>";
				}
			}
			if (dictionary.All((KeyValuePair<SurvivorDef, int> kvp) => kvp.Value == 0))
			{
				return text + "None";
			}
			return text;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
}