Decompiled source of LeekPresence v1.0.1

BepInEx/plugins/LeekPresence/cyclozarin.contentwarning.LeekPresence.dll

Decompiled 3 months ago
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Discord;
using LeekPresence.Hooks;
using Microsoft.CodeAnalysis;
using On;
using Photon.Pun;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Ashley.MeshSplitter")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")]
[assembly: IgnoresAccessChecksTo("Discord")]
[assembly: IgnoresAccessChecksTo("HBAO.Demo.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Runtime")]
[assembly: IgnoresAccessChecksTo("HBAO.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("MeshSplit")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("pworld")]
[assembly: IgnoresAccessChecksTo("sc.posteffects.runtime")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Tayx.Graphy")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.PlayableGraphVisualizer")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipeline.Universal.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Universal.Shaders")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.PhotonUtility")]
[assembly: IgnoresAccessChecksTo("Zorro.Recorder")]
[assembly: IgnoresAccessChecksTo("Zorro.Settings.Runtime")]
[assembly: IgnoresAccessChecksTo("Zorro.UI.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("cyclozarin.contentwarning.LeekPresence")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+ef89ffb9e2f91cb26f940ca8720b9c6976793943")]
[assembly: AssemblyProduct("LeekPresence")]
[assembly: AssemblyTitle("cyclozarin.contentwarning.LeekPresence")]
[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.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
	[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 LeekPresence
{
	[ContentWarningPlugin("cyclozarin.contentwarning.LeekPresence", "1.0.1", true)]
	[BepInPlugin("cyclozarin.contentwarning.LeekPresence", "LeekPresence", "1.0.1")]
	public class LeekPresence : BaseUnityPlugin
	{
		public static LeekPresence Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static ConfigEntry<long> DiscordAppID { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			HookAll();
			DiscordAppID = ((BaseUnityPlugin)this).Config.Bind<long>("General", "Discord App ID", 1278755625123184681L, "Determines Discord App ID for mod to use");
			Logger.LogInfo((object)("LeekPresence v1.0.1 by " + "cyclozarin.contentwarning.LeekPresence".Split("")[0] + " has loaded!"));
		}

		internal static void HookAll()
		{
			Logger.LogDebug((object)"Hooking...");
			RichPresenceHandlerHooks.Init();
			CameraHook.Init();
			PlayerHook.Init();
			UploadCompleteUIHook.Init();
			Logger.LogDebug((object)"Finished hooking!");
		}

		internal static string GetCurrentMap()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			return ((Scene)(ref activeScene)).name.Replace("Scene", "");
		}

		internal static bool ViralityLoaded()
		{
			return Chainloader.PluginInfos.ContainsKey("MaxWasUnavailable.Virality");
		}

		internal static bool ViralityLateJoinEnabled()
		{
			if (!ViralityLoaded())
			{
				return false;
			}
			ConfigEntry<bool> val = default(ConfigEntry<bool>);
			Chainloader.PluginInfos.First((KeyValuePair<string, PluginInfo> x) => x.Key == "MaxWasUnavailable.Virality").Value.Instance.Config.TryGetEntry<bool>("General", "AllowLateJoin", ref val);
			return val.Value;
		}

		internal static bool InTheOldWorld()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)RichPresenceHandler._currentState != 4)
			{
				return (int)RichPresenceHandler._currentState == 5;
			}
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "cyclozarin.contentwarning.LeekPresence";

		public const string PLUGIN_NAME = "LeekPresence";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace LeekPresence.Hooks
{
	internal class CameraHook
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Update <0>__MMHook_Prefix_CameraUpdate;
		}

		internal static bool Recording = false;

		internal static int FilmLeftInSeconds = 0;

		internal static int FilmLeftInPercentage = 0;

		internal static float CameraStatusUpdateInterval = 1f;

		internal static float CameraStatusUpdateTimer = 1f;

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_Prefix_CameraUpdate;
			if (obj == null)
			{
				hook_Update val = MMHook_Prefix_CameraUpdate;
				<>O.<0>__MMHook_Prefix_CameraUpdate = val;
				obj = (object)val;
			}
			VideoCamera.Update += (hook_Update)obj;
		}

		private static void MMHook_Prefix_CameraUpdate(orig_Update orig, VideoCamera self)
		{
			Recording = self.m_recorderInfoEntry.isRecording;
			if (self.HasFilmLeft && self.m_recorderInfoEntry.isRecording)
			{
				if (CameraStatusUpdateTimer > 0f)
				{
					CameraStatusUpdateTimer -= Time.deltaTime;
				}
				else
				{
					FilmLeftInSeconds = Mathf.RoundToInt(self.m_recorderInfoEntry.timeLeft);
					FilmLeftInPercentage = Mathf.RoundToInt(self.m_recorderInfoEntry.GetPercentage() * 100f);
					RichPresenceHandler.DirtyDiscord();
					CameraStatusUpdateTimer = CameraStatusUpdateInterval;
				}
			}
			orig.Invoke(self);
		}
	}
	internal class PlayerHook
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_RPCA_PlayerDie <0>__MMHook_Postfix_Die;

			public static hook_CallHeal <1>__MMHook_Postfix_Heal;

			public static hook_RPCA_PlayerRevive <2>__MMHook_Postfix_Revive;

			public static hook_TakeDamage <3>__MMHook_Postfix_Damage;

			public static hook_UpdateValues <4>__MMHook_Postfix_UpdateStatus;
		}

		internal static float StatusUpdateInterval = 10f;

		internal static float StatusUpdateTimer = 10f;

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_Postfix_Die;
			if (obj == null)
			{
				hook_RPCA_PlayerDie val = MMHook_Postfix_Die;
				<>O.<0>__MMHook_Postfix_Die = val;
				obj = (object)val;
			}
			Player.RPCA_PlayerDie += (hook_RPCA_PlayerDie)obj;
			object obj2 = <>O.<1>__MMHook_Postfix_Heal;
			if (obj2 == null)
			{
				hook_CallHeal val2 = MMHook_Postfix_Heal;
				<>O.<1>__MMHook_Postfix_Heal = val2;
				obj2 = (object)val2;
			}
			Player.CallHeal += (hook_CallHeal)obj2;
			object obj3 = <>O.<2>__MMHook_Postfix_Revive;
			if (obj3 == null)
			{
				hook_RPCA_PlayerRevive val3 = MMHook_Postfix_Revive;
				<>O.<2>__MMHook_Postfix_Revive = val3;
				obj3 = (object)val3;
			}
			Player.RPCA_PlayerRevive += (hook_RPCA_PlayerRevive)obj3;
			object obj4 = <>O.<3>__MMHook_Postfix_Damage;
			if (obj4 == null)
			{
				hook_TakeDamage val4 = MMHook_Postfix_Damage;
				<>O.<3>__MMHook_Postfix_Damage = val4;
				obj4 = (object)val4;
			}
			Player.TakeDamage += (hook_TakeDamage)obj4;
			object obj5 = <>O.<4>__MMHook_Postfix_UpdateStatus;
			if (obj5 == null)
			{
				hook_UpdateValues val5 = MMHook_Postfix_UpdateStatus;
				<>O.<4>__MMHook_Postfix_UpdateStatus = val5;
				obj5 = (object)val5;
			}
			PlayerData.UpdateValues += (hook_UpdateValues)obj5;
		}

		private static void MMHook_Postfix_UpdateStatus(orig_UpdateValues orig, PlayerData self)
		{
			orig.Invoke(self);
			if (self.player.IsLocal)
			{
				if (StatusUpdateTimer > 0f)
				{
					StatusUpdateTimer -= Time.deltaTime;
					return;
				}
				RichPresenceHandler.DirtyDiscord();
				StatusUpdateTimer = StatusUpdateInterval;
			}
		}

		private static void MMHook_Postfix_Damage(orig_TakeDamage orig, Player self, float damage)
		{
			orig.Invoke(self, damage);
			if (self.IsLocal)
			{
				RichPresenceHandler.DirtyDiscord();
			}
		}

		private static void MMHook_Postfix_Revive(orig_RPCA_PlayerRevive orig, Player self)
		{
			orig.Invoke(self);
			if (self.IsLocal)
			{
				RichPresenceHandler.DirtyDiscord();
			}
		}

		private static bool MMHook_Postfix_Heal(orig_CallHeal orig, Player self, float healAmount)
		{
			bool result = orig.Invoke(self, healAmount);
			if (self.IsLocal)
			{
				RichPresenceHandler.DirtyDiscord();
			}
			return result;
		}

		private static void MMHook_Postfix_Die(orig_RPCA_PlayerDie orig, Player self)
		{
			orig.Invoke(self);
			if (self.IsLocal)
			{
				RichPresenceHandler.DirtyDiscord();
			}
		}
	}
	public class RichPresenceHandlerHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Initialize <0>__MMHook_InitRichPresence;

			public static hook_UpdateDiscord <1>__MMHook_UpdateDiscord;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_RPC_QuotaFailed <>9__2_0;

			public static ActivityJoinHandler <>9__3_0;

			public static UpdateActivityHandler <>9__4_0;

			public static Func<DivingBell, bool> <>9__10_0;

			internal void <Init>b__2_0(orig_RPC_QuotaFailed orig, SurfaceNetworkHandler self)
			{
				_failedQuota = true;
				_failedQuotaString = $"Failed quota {SurfaceNetworkHandler.RoomStats.CurrentRun + 1} ({RichPresenceHandler._currentQuota}) on day {RichPresenceHandler._currentDay}";
				RichPresenceHandler.DirtyDiscord();
				orig.Invoke(self);
			}

			internal void <MMHook_InitRichPresence>b__3_0(string secret)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				if (ulong.TryParse(secret, out var result))
				{
					MainMenuHandler.SteamLobbyHandler.TryToJoinLobby((CSteamID)result);
				}
				else
				{
					LeekPresence.Logger.LogInfo((object)"Cannot accept Discord game invite via Presence++; lobby id to join in may be wrong");
				}
				LeekPresence.Logger.LogInfo((object)"Accepted Discord game invite via Presence++");
			}

			internal void <MMHook_UpdateDiscord>b__4_0(Result result)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				if ((int)result != 0)
				{
					LeekPresence.Logger.LogError((object)$"Something went wrong while updating Discord Rich Presence; error code is {result}");
				}
			}

			internal bool <GetSmallIconText>b__10_0(DivingBell bell)
			{
				return ((Behaviour)bell).enabled;
			}
		}

		private static bool _failedQuota;

		private static string _failedQuotaString;

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_InitRichPresence;
			if (obj == null)
			{
				hook_Initialize val = MMHook_InitRichPresence;
				<>O.<0>__MMHook_InitRichPresence = val;
				obj = (object)val;
			}
			RichPresenceHandler.Initialize += (hook_Initialize)obj;
			object obj2 = <>O.<1>__MMHook_UpdateDiscord;
			if (obj2 == null)
			{
				hook_UpdateDiscord val2 = MMHook_UpdateDiscord;
				<>O.<1>__MMHook_UpdateDiscord = val2;
				obj2 = (object)val2;
			}
			RichPresenceHandler.UpdateDiscord += (hook_UpdateDiscord)obj2;
			object obj3 = <>c.<>9__2_0;
			if (obj3 == null)
			{
				hook_RPC_QuotaFailed val3 = delegate(orig_RPC_QuotaFailed orig, SurfaceNetworkHandler self)
				{
					_failedQuota = true;
					_failedQuotaString = $"Failed quota {SurfaceNetworkHandler.RoomStats.CurrentRun + 1} ({RichPresenceHandler._currentQuota}) on day {RichPresenceHandler._currentDay}";
					RichPresenceHandler.DirtyDiscord();
					orig.Invoke(self);
				};
				<>c.<>9__2_0 = val3;
				obj3 = (object)val3;
			}
			SurfaceNetworkHandler.RPC_QuotaFailed += (hook_RPC_QuotaFailed)obj3;
		}

		private static void MMHook_InitRichPresence(orig_Initialize orig)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			try
			{
				RichPresenceHandler._discord = new Discord(LeekPresence.DiscordAppID.Value, 1uL);
			}
			catch (Exception arg)
			{
				LeekPresence.Logger.LogError((object)$"Presence++ failed to initialize Discord Rich Presence: {arg}");
			}
			ActivityManager activityManager = RichPresenceHandler._discord.GetActivityManager();
			activityManager.RegisterSteam(2881650u);
			object obj = <>c.<>9__3_0;
			if (obj == null)
			{
				ActivityJoinHandler val = delegate(string secret)
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					if (ulong.TryParse(secret, out var result))
					{
						MainMenuHandler.SteamLobbyHandler.TryToJoinLobby((CSteamID)result);
					}
					else
					{
						LeekPresence.Logger.LogInfo((object)"Cannot accept Discord game invite via Presence++; lobby id to join in may be wrong");
					}
					LeekPresence.Logger.LogInfo((object)"Accepted Discord game invite via Presence++");
				};
				<>c.<>9__3_0 = val;
				obj = (object)val;
			}
			activityManager.OnActivityJoin += (ActivityJoinHandler)obj;
		}

		private static void MMHook_UpdateDiscord(orig_UpdateDiscord orig)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_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_0113: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (RichPresenceHandler._discord == null)
			{
				return;
			}
			ActivityManager activityManager = RichPresenceHandler._discord.GetActivityManager();
			Activity val = default(Activity);
			val.State = GetStateString();
			val.Details = GetDetailsString();
			val.Assets = new ActivityAssets
			{
				LargeImage = GetLargeIconString(),
				LargeText = GetLargeIconText(),
				SmallImage = GetSmallIconString(),
				SmallText = GetSmallIconText()
			};
			Activity val2 = val;
			if (RichPresenceHandler._currentPlayersInGroup > 0)
			{
				val2.Party = new ActivityParty
				{
					Id = RichPresenceHandler._currentGroup,
					Size = new PartySize
					{
						CurrentSize = RichPresenceHandler._currentPlayersInGroup,
						MaxSize = PhotonNetwork.CurrentRoom.MaxPlayers
					},
					Privacy = (ActivityPartyPrivacy)1
				};
				if (!SurfaceNetworkHandler.HasStarted || (SurfaceNetworkHandler.HasStarted && LeekPresence.ViralityLateJoinEnabled() && (int)TimeOfDayHandler.TimeOfDay == 0))
				{
					val2.Secrets.Join = ((object)(CSteamID)(ref MainMenuHandler.SteamLobbyHandler.m_CurrentLobby)).ToString();
				}
			}
			Activity val3 = val2;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				UpdateActivityHandler val4 = delegate(Result result)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					if ((int)result != 0)
					{
						LeekPresence.Logger.LogError((object)$"Something went wrong while updating Discord Rich Presence; error code is {result}");
					}
				};
				<>c.<>9__4_0 = val4;
				obj = (object)val4;
			}
			activityManager.UpdateActivity(val3, (UpdateActivityHandler)obj);
		}

		private static string GetStateString()
		{
			//IL_000d: 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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected I4, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Invalid comparison between Unknown and I4
			if (_failedQuota)
			{
				return string.Empty;
			}
			RichPresenceState currentState = RichPresenceHandler._currentState;
			switch (currentState - 1)
			{
			case 1:
				return "In friends lobby";
			case 0:
				return "In random lobby";
			case 3:
			case 4:
				return "In the Old World";
			default:
				if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 0)
				{
					return "At the surface";
				}
				if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 10 && PhotonGameLobbyHandler.CurrentObjective is CelebrateObjective)
				{
					return "Watching the video (" + UploadCompleteUIHook.ViewsString + ")";
				}
				if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 10)
				{
					return "Back from the Old World";
				}
				return string.Empty;
			}
		}

		private static string GetDetailsString()
		{
			//IL_000d: 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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			if (_failedQuota)
			{
				return _failedQuotaString;
			}
			RichPresenceState currentState = RichPresenceHandler._currentState;
			if ((int)currentState != 0)
			{
				if (currentState - 3 <= 2)
				{
					return string.Format("Day {0} ({1}), {2}/{3}, {4}$", RichPresenceHandler._currentDay, (SurfaceNetworkHandler.RoomStats.GetDaysLeft() == 0) ? "last day" : $"{SurfaceNetworkHandler.RoomStats.GetDaysLeft() + 1} days left", RichPresenceHandler._currentViews, RichPresenceHandler._currentQuota, SurfaceNetworkHandler.RoomStats.Money);
				}
				return string.Empty;
			}
			return "In main menu";
		}

		private static string GetLargeIconString()
		{
			//IL_000d: 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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Invalid comparison between Unknown and I4
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			if (_failedQuota)
			{
				return "failedquota";
			}
			RichPresenceState currentState = RichPresenceHandler._currentState;
			switch ((int)currentState)
			{
			case 0:
				return "mainmenu";
			case 1:
			case 2:
				return "lobby";
			case 4:
			case 5:
				return LeekPresence.GetCurrentMap().ToLower();
			default:
				if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 10 && PhotonGameLobbyHandler.CurrentObjective is CelebrateObjective)
				{
					return "watchingvideo";
				}
				if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 0)
				{
					return "surface";
				}
				if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 10)
				{
					return "mainmenu";
				}
				return string.Empty;
			}
		}

		private static string GetLargeIconText()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			if (_failedQuota)
			{
				_failedQuota = false;
				return "Womp womp";
			}
			if (LeekPresence.InTheOldWorld())
			{
				return "Current map: " + LeekPresence.GetCurrentMap();
			}
			if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 10 && PhotonGameLobbyHandler.CurrentObjective is CelebrateObjective)
			{
				return "Watching the video";
			}
			if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 0)
			{
				return "At the surface";
			}
			if ((int)RichPresenceHandler._currentState == 3 && (int)TimeOfDayHandler.TimeOfDay == 10)
			{
				return "Back from the Old World";
			}
			RichPresenceState currentState = RichPresenceHandler._currentState;
			if ((int)currentState != 1)
			{
				if ((int)currentState == 2)
				{
					return "In friends lobby";
				}
				return string.Empty;
			}
			return "In random lobby";
		}

		private static string GetSmallIconString()
		{
			if (CameraHook.Recording)
			{
				return "https://contentwarning.wiki.gg/images/thumb/8/80/Camera.png/350px-Camera.png";
			}
			if (LeekPresence.InTheOldWorld())
			{
				if (!Player.localPlayer.data.dead)
				{
					return "alive";
				}
				if (PlayerHandler.instance.playersAlive.Count == 0 && PlayerHandler.instance.players.Count > 1)
				{
					return "everyoneisdead";
				}
				return "dead";
			}
			if (LeekPresence.ViralityLoaded())
			{
				return "virality";
			}
			return "cw";
		}

		private static string GetSmallIconText()
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			if (CameraHook.Recording)
			{
				return $"Recording on camera\nFilm left: {CameraHook.FilmLeftInPercentage}% ({CameraHook.FilmLeftInSeconds}s)";
			}
			if (LeekPresence.InTheOldWorld())
			{
				if (!Player.localPlayer.data.dead)
				{
					return $"Alive - HP: {Mathf.Round(Player.localPlayer.data.health)}, O2: {Mathf.Round(Player.localPlayer.data.OxygenPercentage() * 100f)}%, current face {((TMP_Text)Player.localPlayer.refs.visor.visorFaceText).text}";
				}
				if (PlayerHandler.instance.playersAlive.Count == 0 && PlayerHandler.instance.players.Count > 1)
				{
					return "Everyone is dead.";
				}
				return $"Dead - {Mathf.Round(HelperFunctions.FlatDistance(((Component)((Component)((Component)DiveBellParent.instance).transform).GetComponentsInChildren<DivingBell>().First((DivingBell bell) => ((Behaviour)bell).enabled)).transform.position, ((Component)Player.localPlayer.refs.ragdoll.GetBodypart((BodypartType)0)).transform.position))}m away from diving bell";
			}
			int count = Chainloader.PluginInfos.Count;
			if (LeekPresence.ViralityLoaded())
			{
				return $"{count} mods loaded, Virality enabled";
			}
			return $"{count} mods loaded";
		}
	}
	internal class UploadCompleteUIHook
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_PlayVideo <0>__MMHook_Postfix_PlayVideo;

			public static hook_DisplayComment <1>__MMHook_Postfix_DisplayComment;
		}

		internal static string ViewsString = string.Empty;

		internal static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__MMHook_Postfix_PlayVideo;
			if (obj == null)
			{
				hook_PlayVideo val = MMHook_Postfix_PlayVideo;
				<>O.<0>__MMHook_Postfix_PlayVideo = val;
				obj = (object)val;
			}
			UploadCompleteUI.PlayVideo += (hook_PlayVideo)obj;
			object obj2 = <>O.<1>__MMHook_Postfix_DisplayComment;
			if (obj2 == null)
			{
				hook_DisplayComment val2 = MMHook_Postfix_DisplayComment;
				<>O.<1>__MMHook_Postfix_DisplayComment = val2;
				obj2 = (object)val2;
			}
			UploadCompleteUI.DisplayComment += (hook_DisplayComment)obj2;
		}

		private static void MMHook_Postfix_DisplayComment(orig_DisplayComment orig, UploadCompleteUI self, Comment comment)
		{
			orig.Invoke(self, comment);
			ViewsString = ((TMP_Text)self.m_views).text;
			RichPresenceHandler.DirtyDiscord();
		}

		private static void MMHook_Postfix_PlayVideo(orig_PlayVideo orig, UploadCompleteUI self, IPlayableVideo playableVideo, int views, Comment[] comments, Action onPlayed)
		{
			orig.Invoke(self, playableVideo, views, comments, onPlayed);
			ViewsString = ((TMP_Text)self.m_views).text;
			RichPresenceHandler.DirtyDiscord();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}