Decompiled source of DropInMultiplayer GUI v1.0.1

RoR2DropInMultiplayerHelper.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using Survariants;
using UnityEngine;
using UnityEngine.AddressableAssets;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("RoR2DropInMultiplayerHelper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod for Risk of Rain 2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9a1271e42d7ace9d78399501bd486979fabb1182")]
[assembly: AssemblyProduct("RoR2DropInMultiplayerHelper")]
[assembly: AssemblyTitle("RoR2DropInMultiplayerHelper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DisallowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MaybeNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public MaybeNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullIfNotNullAttribute : Attribute
	{
		public string ParameterName { get; }

		public NotNullIfNotNullAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	[DebuggerNonUserCode]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
}
namespace RoR2DropInMultiplayerHelper
{
	internal class ModCompat
	{
		public static bool loaded_Survariants;

		public static void Init()
		{
			if (Chainloader.PluginInfos.ContainsKey("pseudopulse.Survariants"))
			{
				loaded_Survariants = true;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static bool Survariants_IsVariant(SurvivorDef survivorDef)
		{
			return SurvivorVariantCatalog.SurvivorVariantReverseMap.ContainsKey(survivorDef);
		}
	}
	[BepInPlugin("com.DestroyedClone.DropInMultiplayerHelper", "Drop In Multiplayer Helper", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public class KeepInactive : MonoBehaviour
		{
			public void Update()
			{
				((Component)this).gameObject.SetActive(false);
			}
		}

		public class DestroyOnEsc : MonoBehaviour
		{
			public void Update()
			{
				if (Input.GetKey((KeyCode)27))
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		public static GameObject displayInstance;

		public void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			Chat.AddMessage_ChatMessageBase += new hook_AddMessage_ChatMessageBase(Chat_AddMessage_ChatMessageBase);
			SurvivorIconController.Awake += new hook_Awake(SurvivorIconController_Awake);
			Run.onClientGameOverGlobal += Run_onClientGameOverGlobal;
			CharacterSelectBarController.ShouldDisplaySurvivor += new hook_ShouldDisplaySurvivor(CharacterSelectBarController_ShouldDisplaySurvivor);
			Console.SubmitCmd_CmdSender_string_bool += new hook_SubmitCmd_CmdSender_string_bool(Console_SubmitCmd_CmdSender_string_bool);
			ModCompat.Init();
		}

		private void Console_SubmitCmd_CmdSender_string_bool(orig_SubmitCmd_CmdSender_string_bool orig, Console self, CmdSender sender, string cmd, bool recordSubmit)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (cmd == "pause" && !recordSubmit && Object.op_Implicit((Object)(object)displayInstance))
			{
				DestroyDisplayInstance();
			}
			else
			{
				orig.Invoke(self, sender, cmd, recordSubmit);
			}
		}

		private bool CharacterSelectBarController_ShouldDisplaySurvivor(orig_ShouldDisplaySurvivor orig, CharacterSelectBarController self, SurvivorDef survivorDef)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && ModCompat.loaded_Survariants && ModCompat.Survariants_IsVariant(survivorDef))
			{
				return true;
			}
			return orig.Invoke(self, survivorDef);
		}

		private void Run_onClientGameOverGlobal(Run run, RunReport runReport)
		{
			DestroyDisplayInstance();
		}

		private void SurvivorIconController_Awake(orig_Awake orig, SurvivorIconController self)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				((UnityEventBase)((Button)self.hgButton).onClick).RemoveAllListeners();
				LocalUser localUser = self.GetLocalUser();
				((UnityEvent)((Button)self.hgButton).onClick).AddListener((UnityAction)delegate
				{
					OnClick(self.survivorDef, localUser);
				});
			}
		}

		public void OnClick(SurvivorDef survivorDef, LocalUser localUser)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)localUser.cachedMaster) && localUser.currentNetworkUser.bodyIndexPreference == SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorDef.survivorIndex))
			{
				DestroyDisplayInstance();
				return;
			}
			Console.instance.SubmitCmd(localUser.currentNetworkUser, "say \"/join_as " + survivorDef.cachedName + "\"", true);
			DestroyDisplayInstance();
		}

		private void Chat_AddMessage_ChatMessageBase(orig_AddMessage_ChatMessageBase orig, ChatMessageBase message)
		{
			orig.Invoke(message);
			UserChatMessage val = (UserChatMessage)(object)((message is UserChatMessage) ? message : null);
			if (val != null && (Object)(object)val.sender == (Object)(object)((Component)LocalUserManager.GetFirstLocalUser().currentNetworkUser).gameObject && val.text.ToUpperInvariant() == "/LIST_SURVIVORS")
			{
				DisplayCharacters();
			}
		}

		public static void DestroyDisplayInstance()
		{
			if (Object.op_Implicit((Object)(object)displayInstance))
			{
				Object.Destroy((Object)(object)displayInstance);
			}
		}

		public static void DisplayCharacters()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)displayInstance))
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/CharacterSelectUI.prefab").WaitForCompletion();
				GameObject val2 = Object.Instantiate<GameObject>(val);
				((Behaviour)val2.GetComponent<CharacterSelectController>()).enabled = false;
				val2.transform.parent = ((Component)AchievementNotificationPanel.GetUserCanvas(LocalUserManager.GetFirstLocalUser())).transform;
				val2.AddComponent<DestroyOnEsc>();
				((Behaviour)val2.GetComponent<CursorOpener>()).enabled = false;
				((Component)val2.transform.Find("BottomSideFade")).gameObject.SetActive(false);
				((Component)val2.transform.Find("TopSideFade")).gameObject.SetActive(false);
				Transform val3 = val2.transform.Find("SafeArea");
				((Component)val3.Find("ReadyPanel")).gameObject.SetActive(false);
				((Component)val3.Find("RightHandPanel")).gameObject.SetActive(false);
				((Component)val3.Find("ChatboxPanel")).gameObject.SetActive(false);
				((Component)val3.Find("FooterPanel")).gameObject.SetActive(false);
				Transform obj = val3.Find("ConfigPanel(Clone)");
				if (obj != null)
				{
					((Component)obj).gameObject.SetActive(false);
				}
				Transform val4 = val3.Find("LeftHandPanel (Layer: Main)");
				((Component)val4.Find("BlurPanel")).gameObject.SetActive(false);
				((Component)val4.Find("BorderImage")).gameObject.SetActive(false);
				((Component)val4.Find("SurvivorInfoPanel, Active (Layer: Secondary)")).gameObject.AddComponent<KeepInactive>();
				val2.transform.localPosition = Vector3.zero;
				val2.transform.localScale = Vector3.one;
				displayInstance = val2;
			}
		}
	}
}