Decompiled source of RespawnEquipment v1.0.0

RespawnEquipment.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RespawnEquipment.Components;
using RespawnEquipment.Networking;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
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("RespawnEquipment")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RespawnEquipment")]
[assembly: AssemblyTitle("RespawnEquipment")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 RespawnEquipment
{
	public class Assets
	{
		public static AssetBundle assetBundle;

		public static GameObject characterSelectUI;

		public static BuffDef immunityBd = Addressables.LoadAssetAsync<BuffDef>((object)RoR2_Base_Common.bdImmune_asset).WaitForCompletion();

		public static GameObject polymorphEffect = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC4_ShrineCompulsion.SurvivorPolymorphCharge_prefab).WaitForCompletion();

		public static GameObject pickupTransceiverPrefab;

		public static void Init()
		{
			GetAssetBundle();
			CreateCharacterSelectUI();
			CreatePickupModel();
		}

		private static void GetAssetBundle()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RespawnEquipment.mwmwrespawnequipmentbundle");
			if (stream != null)
			{
				assetBundle = AssetBundle.LoadFromStream(stream);
			}
		}

		private static void CreateCharacterSelectUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			characterSelectUI = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Command.CommandPickerPanel_prefab).WaitForCompletion(), "CharacterPickerPanel", false);
			((Behaviour)characterSelectUI.GetComponent<MPButton>()).enabled = false;
			string text = (((Component)characterSelectUI.transform.Find("MainPanel/Juice/Label")).GetComponent<LanguageTextMeshController>().token = Language.interactionHeader);
			string text2 = text;
			CharacterPickerPanel characterPickerPanel = characterSelectUI.AddComponent<CharacterPickerPanel>();
			PickupPickerPanel component = characterSelectUI.GetComponent<PickupPickerPanel>();
			characterPickerPanel.gridlayoutGroup = component.gridlayoutGroup;
			characterPickerPanel.buttonContainer = component.buttonContainer;
			characterPickerPanel.buttonPrefab = component.buttonPrefab;
			characterPickerPanel.coloredImages = component.coloredImages;
			characterPickerPanel.darkColoredImages = component.darkColoredImages;
			characterPickerPanel.useLockSpriteForUnavailableOptions = component.useLockSpriteForUnavailableOptions;
			HGButton component2 = characterPickerPanel.buttonPrefab.GetComponent<HGButton>();
			ColorBlock colors = ((Selectable)component2).colors;
			((ColorBlock)(ref colors)).normalColor = Color.white;
			((Selectable)component2).colors = colors;
			ChildLocator component3 = ((Component)component2).GetComponent<ChildLocator>();
			Transform val = component3.FindChild("Icon");
			Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<AsyncImage>());
			Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<Image>());
			RawImage targetGraphic = ((Component)val).gameObject.AddComponent<RawImage>();
			((Selectable)component2).targetGraphic = (Graphic)(object)targetGraphic;
			Object.Destroy((Object)(object)((Component)component2).GetComponent<Image>());
			Object.Destroy((Object)(object)component);
			CharacterPickerPanelSizeAdjuster characterPickerPanelSizeAdjuster = characterSelectUI.AddComponent<CharacterPickerPanelSizeAdjuster>();
			PickerPanelSizeAdjuster component4 = characterSelectUI.GetComponent<PickerPanelSizeAdjuster>();
			characterPickerPanelSizeAdjuster.pickerPanel = characterPickerPanel;
			characterPickerPanelSizeAdjuster.rectToAdjust = component4.rectToAdjust;
			characterPickerPanelSizeAdjuster.minRows = component4.minRows;
			characterPickerPanelSizeAdjuster.maxRows = component4.maxRows;
			characterPickerPanelSizeAdjuster.adjustmentPerRow = component4.adjustmentPerRow;
			Object.Destroy((Object)(object)component4);
		}

		private static void CreatePickupModel()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0082: 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)
			pickupTransceiverPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_DroneBackup.PickupRadio_prefab).WaitForCompletion(), "PickupNkuhanaTransceiver", false);
			MeshRenderer componentInChildren = pickupTransceiverPrefab.GetComponentInChildren<MeshRenderer>();
			Material val = new Material(((Renderer)componentInChildren).material);
			val.SetTexture("_MainTex", assetBundle.LoadAsset<Texture>("texRadioDiffuse"));
			val.SetTexture("_EmTex", assetBundle.LoadAsset<Texture>("texRadioEmission"));
			((Renderer)componentInChildren).sharedMaterials = (Material[])(object)new Material[2]
			{
				val,
				Addressables.LoadAssetAsync<Material>((object)RoR2_DLC4_survival_common.matMalachiteOverlay_mat).WaitForCompletion()
			};
		}
	}
	public abstract class BaseEquipment<T> where T : BaseEquipment<T>
	{
		protected static string prefix = "DEFAULT_DEFAULT";

		protected static string name = "DEFAULT NAME";

		protected static string desc = "DEFAULT DESC";

		protected static string pickup = "DEFAULT PICKUP";

		protected static string lore = "<style=cMono>///EMPTY TRANSMISSION///</style>";

		protected static Func<Sprite> pickupIconSprite;

		protected static Func<GameObject> pickupModelPrefab;

		protected static Func<ItemDisplayRuleDict> itemDisplayRuleDict;

		public static EquipmentDef equipmentDef;

		protected static ColorIndex colorIndex = (ColorIndex)5;

		protected static float cooldown = 60f;

		protected static bool canDrop = true;

		protected static bool enigmaCompatible = true;

		protected static bool isLunar = false;

		protected static bool isBoss = false;

		protected static bool foodRelated = false;

		protected static bool appearsInSinglePlayer = true;

		protected static bool appearsInMultiPlayer = true;

		protected static bool canBeRandomlyTriggered = true;

		protected void CreateItem()
		{
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			equipmentDef = ScriptableObject.CreateInstance<EquipmentDef>();
			((Object)equipmentDef).name = prefix + "_NAME";
			equipmentDef.nameToken = prefix + "_NAME";
			equipmentDef.pickupToken = prefix + "_PICKUP";
			equipmentDef.descriptionToken = prefix + "_DESC";
			equipmentDef.loreToken = prefix + "_LORE";
			equipmentDef.cooldown = cooldown;
			equipmentDef.canDrop = canDrop;
			equipmentDef.enigmaCompatible = enigmaCompatible;
			equipmentDef.isLunar = isLunar;
			equipmentDef.isBoss = isBoss;
			equipmentDef.foodRelated = foodRelated;
			equipmentDef.appearsInSinglePlayer = appearsInSinglePlayer;
			equipmentDef.appearsInMultiPlayer = appearsInMultiPlayer;
			equipmentDef.pickupIconSprite = pickupIconSprite?.Invoke() ?? Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common_MiscIcons.texMysteryIcon_png).WaitForCompletion();
			equipmentDef.pickupModelPrefab = pickupModelPrefab?.Invoke() ?? Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Mystery.PickupMystery_prefab).WaitForCompletion();
			LanguageAPI.Add(prefix + "_NAME", name);
			LanguageAPI.Add(prefix + "_DESC", desc);
			LanguageAPI.Add(prefix + "_PICKUP", pickup);
			LanguageAPI.Add(prefix + "_LORE", lore);
			ItemDisplayRuleDict val = (ItemDisplayRuleDict)(((object)itemDisplayRuleDict?.Invoke()) ?? ((object)new ItemDisplayRuleDict((ItemDisplayRule[])null)));
			ItemAPI.Add(new CustomEquipment(equipmentDef, val));
			EquipmentSlot.PerformEquipmentAction += new hook_PerformEquipmentAction(CheckForEquipment);
		}

		protected abstract bool ActivateEquipment(EquipmentSlot slot);

		protected virtual bool CheckForEquipment(orig_PerformEquipmentAction orig, EquipmentSlot self, EquipmentDef activatedEquipmentDef)
		{
			if ((Object)(object)activatedEquipmentDef == (Object)(object)equipmentDef)
			{
				return ActivateEquipment(self);
			}
			return orig.Invoke(self, equipmentDef);
		}

		public virtual void Init()
		{
			CreateItem();
		}
	}
	public class UmbrousTransceiver : BaseEquipment<UmbrousTransceiver>
	{
		public override void Init()
		{
			BaseEquipment<UmbrousTransceiver>.prefix = "RESPAWNEQUIPMENT_UMBROUSTRANSCEIVER";
			BaseEquipment<UmbrousTransceiver>.name = "Umbrous Transceiver";
			BaseEquipment<UmbrousTransceiver>.desc = "<style=cIsUtility>Transform</style> into another survivor of your choice. Gain brief <style=cIsUtility>immunity</style> while selecting.";
			BaseEquipment<UmbrousTransceiver>.pickup = "Transform into another survivor of your choice.";
			BaseEquipment<UmbrousTransceiver>.lore = "> Patient claimed to be one of the troops who went missing. Tried prescribing quetiapine.\n\n> Drug seemed to have no effect. Patient continuing to state that a \"weird device\" transformed them. Considering stronger medication.\n\n> Patient revealed a concerning amount of accurate information about the missing troop. Suspect they were involved in foul play.\n\n> Patient managed to contact the family of the missing troop. Don't know why the caretakers allowed that. But, for some reason, the family is corroborating the patient's claims.\n\n> Patient has been released to the family of the missing troop, despite clearly being something alien. What a mess.";
			BaseEquipment<UmbrousTransceiver>.cooldown = Options.cooldown.Value;
			BaseEquipment<UmbrousTransceiver>.canBeRandomlyTriggered = false;
			BaseEquipment<UmbrousTransceiver>.pickupIconSprite = () => Assets.assetBundle.LoadAsset<Sprite>("texRadioIcon");
			BaseEquipment<UmbrousTransceiver>.pickupModelPrefab = () => Assets.pickupTransceiverPrefab;
			base.Init();
		}

		protected override bool ActivateEquipment(EquipmentSlot slot)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			CharacterPickerFlag characterPickerFlag = default(CharacterPickerFlag);
			if (((Component)slot).TryGetComponent<CharacterPickerFlag>(ref characterPickerFlag))
			{
				Object.Destroy((Object)(object)characterPickerFlag);
				return true;
			}
			if (Object.op_Implicit((Object)(object)slot.characterBody) && Object.op_Implicit((Object)(object)slot.characterBody.master) && Object.op_Implicit((Object)(object)slot.characterBody.master.playerCharacterMasterController))
			{
				NetMessageExtensions.Send((INetMessage)(object)new SyncOpenUI(slot.characterBody.master.bodyInstanceId), (NetworkDestination)1);
				TransceiverImmunityController transceiverImmunityController = default(TransceiverImmunityController);
				if (!((Component)slot).TryGetComponent<TransceiverImmunityController>(ref transceiverImmunityController))
				{
					((Component)slot).gameObject.AddComponent<TransceiverImmunityController>();
				}
			}
			return false;
		}
	}
	public static class Language
	{
		public static string interactionHeader;

		private const string prefix = "MIYOWI_RESPAWNEQUIPMENT_";

		public static void Init()
		{
			interactionHeader = Add("INTERACTION_HEADER", "Select your Replacement.");
		}

		public static string Add(string token, string text)
		{
			string text2 = "MIYOWI_RESPAWNEQUIPMENT_" + token;
			LanguageAPI.Add(text2, text);
			return text2;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public class Options
	{
		private static bool? _rooEnabled;

		public static bool rooEnabled
		{
			get
			{
				if (!_rooEnabled.HasValue)
				{
					_rooEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _rooEnabled.Value;
			}
		}

		public static ConfigEntry<int> uiColumns { get; set; }

		public static ConfigEntry<float> immunityPeriod { get; set; }

		public static ConfigEntry<float> immunityDuration { get; set; }

		public static ConfigEntry<float> cooldown { get; set; }

		public static void Init()
		{
			uiColumns = RespawnEquipment.config.Bind<int>("Umbral Transceiver", "UI Columns", 8, "The number of columns in the character selection UI. Increase this if icons start to overflow. (Client-side)");
			immunityPeriod = RespawnEquipment.config.Bind<float>("Umbral Transceiver", "Immunity Period", 60f, "The minimum period, in seconds, between the application of temporary immunity buffs. (Server-side)");
			immunityDuration = RespawnEquipment.config.Bind<float>("Umbral Transceiver", "Immunity Duration", 5f, "The maximum amount of seconds the temporary immunity buff can last while in the menu. (Server-side)");
			cooldown = RespawnEquipment.config.Bind<float>("Umbral Transceiver", "Cooldown", 300f, "The cooldown of the equipment, in seconds. (Server-side)");
			cooldown.SettingChanged += delegate
			{
				BaseEquipment<UmbrousTransceiver>.equipmentDef.cooldown = cooldown.Value;
			};
			if (rooEnabled)
			{
				RoOInit();
			}
		}

		private static void RoOInit()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_001f: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00c1: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(uiColumns, new IntSliderConfig
			{
				min = 1,
				max = 30
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(immunityPeriod, new StepSliderConfig
			{
				min = 0f,
				max = 3000f,
				increment = 0.1f
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(immunityDuration, new StepSliderConfig
			{
				min = 0f,
				max = 600f,
				increment = 0.1f
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(cooldown, new StepSliderConfig
			{
				min = 0f,
				max = 3000f,
				increment = 0.1f
			}));
			ModSettingsManager.SetModDescription("Config options for the Umbrous Transceiver mod.");
			ModSettingsManager.SetModIcon(Assets.assetBundle.LoadAsset<Sprite>("texRadioIcon"));
		}
	}
	[BepInPlugin("mwmw.RespawnEquipment", "RespawnEquipment", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class RespawnEquipment : BaseUnityPlugin
	{
		public const string PluginGUID = "mwmw.RespawnEquipment";

		public const string PluginAuthor = "mwmw";

		public const string PluginName = "RespawnEquipment";

		public const string PluginVersion = "1.0.0";

		public static ConfigFile config;

		public void Awake()
		{
			config = ((BaseUnityPlugin)this).Config;
			Log.Init(((BaseUnityPlugin)this).Logger);
			Language.Init();
			Assets.Init();
			NetworkMessages.Init();
			Options.Init();
			new UmbrousTransceiver().Init();
		}
	}
}
namespace RespawnEquipment.Networking
{
	public static class NetworkMessages
	{
		public static void Init()
		{
			NetworkingAPI.RegisterMessageType<SyncOpenUI>();
			NetworkingAPI.RegisterMessageType<SyncCloseUI>();
			NetworkingAPI.RegisterMessageType<SyncRespawnRequest>();
		}
	}
	public class SyncOpenUI : INetMessage, ISerializableObject
	{
		private NetworkInstanceId netInstanceId;

		public SyncOpenUI()
		{
		}

		public SyncOpenUI(NetworkInstanceId netInstanceId)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			this.netInstanceId = netInstanceId;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(netInstanceId);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			netInstanceId = reader.ReadNetworkId();
		}

		public void OnReceived()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(netInstanceId);
			CharacterBody val2 = default(CharacterBody);
			if (!Object.op_Implicit((Object)(object)val) || !Util.HasEffectiveAuthority(val) || !val.TryGetComponent<CharacterBody>(ref val2) || !Object.op_Implicit((Object)(object)val2.master) || !Object.op_Implicit((Object)(object)val2.master.playerCharacterMasterController))
			{
				return;
			}
			CameraRigController val3 = null;
			foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
			{
				if ((Object)(object)readOnlyInstances.target == (Object)(object)val)
				{
					val3 = readOnlyInstances;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)val3))
			{
				GameObject val4 = Object.Instantiate<GameObject>(Assets.characterSelectUI, val3.hud.mainContainer.transform);
				CharacterPickerPanel component = val4.GetComponent<CharacterPickerPanel>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.SetupOptions(val2.master.playerCharacterMasterController);
				}
			}
		}
	}
	public class SyncCloseUI : INetMessage, ISerializableObject
	{
		private NetworkInstanceId netInstanceId;

		public SyncCloseUI()
		{
		}

		public SyncCloseUI(NetworkInstanceId netInstanceId)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			this.netInstanceId = netInstanceId;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(netInstanceId);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			netInstanceId = reader.ReadNetworkId();
		}

		public void OnReceived()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(netInstanceId);
			TransceiverImmunityController transceiverImmunityController = default(TransceiverImmunityController);
			if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<TransceiverImmunityController>(ref transceiverImmunityController))
			{
				transceiverImmunityController.RemoveBuff();
			}
		}
	}
	public class SyncRespawnRequest : INetMessage, ISerializableObject
	{
		private NetworkInstanceId netInstanceId;

		private string bodyName;

		public SyncRespawnRequest()
		{
		}

		public SyncRespawnRequest(NetworkInstanceId netInstanceId, string bodyName)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			this.netInstanceId = netInstanceId;
			this.bodyName = bodyName;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(netInstanceId);
			writer.Write(bodyName);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			netInstanceId = reader.ReadNetworkId();
			bodyName = reader.ReadString();
		}

		public void OnReceived()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			//IL_004a: Expected O, but got Unknown
			//IL_0081: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(netInstanceId);
			CharacterBody val2 = default(CharacterBody);
			if (Object.op_Implicit((Object)(object)val) && val.TryGetComponent<CharacterBody>(ref val2) && Object.op_Implicit((Object)(object)val2.master))
			{
				EffectData val3 = new EffectData
				{
					origin = val.transform.position
				};
				EffectManager.SpawnEffect(Assets.polymorphEffect, val3, true);
				if (Object.op_Implicit((Object)(object)val2.equipmentSlot))
				{
					((Component)val2).gameObject.AddComponent<CharacterPickerFlag>();
					EquipmentSlot equipmentSlot = val2.equipmentSlot;
					EquipmentLocation activeEquipmentLocation = val2.equipmentSlot.activeEquipmentLocation;
					equipmentSlot.OnEquipmentExecuted(ref activeEquipmentLocation, BaseEquipment<UmbrousTransceiver>.equipmentDef.equipmentIndex);
				}
				val2.master.TransformBody(bodyName);
			}
		}
	}
}
namespace RespawnEquipment.Components
{
	public class CharacterPickerFlag : MonoBehaviour
	{
	}
	[RequireComponent(typeof(RectTransform))]
	public class CharacterPickerPanel : MonoBehaviour
	{
		public struct Option
		{
			public SurvivorIndex survivorIndex;

			public bool available;

			public Texture2D texture;

			public Color? overrideUnavailableBGColor;

			public Color? overrideSelectedBGColor;
		}

		private PlayerCharacterMasterController player;

		private Option[] characterOptions;

		public GridLayoutGroup gridlayoutGroup;

		public RectTransform buttonContainer;

		public GameObject buttonPrefab;

		public Image[] coloredImages;

		public Image[] darkColoredImages;

		public int maxColumnCount;

		public bool useLockSpriteForUnavailableOptions = true;

		private UIElementAllocator<MPButton> buttonAllocator;

		public bool shouldChangeButtonFrameColor;

		public bool shouldLeaveDisabledButtonsInteractable;

		[SerializeField]
		[Tooltip("If the root of the panel is a button, keep this false!")]
		private bool automaticButtonNavigation;

		private bool _inspectFeatureIsEnabled;

		private Sprite lockedSprite;

		public Action OnPanelSetupComplete;

		private bool cancelled = true;

		private void Awake()
		{
			maxColumnCount = Mathf.Max(1, Options.uiColumns.Value);
			buttonAllocator = new UIElementAllocator<MPButton>(buttonContainer, buttonPrefab, true, false)
			{
				onCreateElement = OnCreateButton
			};
			gridlayoutGroup.constraint = (Constraint)1;
			gridlayoutGroup.constraintCount = maxColumnCount;
			if (Object.op_Implicit((Object)(object)EventSystem.current))
			{
				EventSystem current = EventSystem.current;
				MPEventSystem val = (MPEventSystem)(object)((current is MPEventSystem) ? current : null);
				if (val != null)
				{
					LocalUser localUser = val.localUser;
					_inspectFeatureIsEnabled = localUser != null && localUser.userProfile?.useInspectFeature == true;
				}
			}
		}

		public void SetupOptions(PlayerCharacterMasterController player)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			this.player = player;
			List<Option> list = new List<Option>();
			SurvivorDef[] survivorDefs = SurvivorCatalog.survivorDefs;
			ExpansionRequirementComponent val2 = default(ExpansionRequirementComponent);
			foreach (SurvivorDef val in survivorDefs)
			{
				if (!val.hidden && Object.op_Implicit((Object)(object)val.bodyPrefab) && (!val.bodyPrefab.TryGetComponent<ExpansionRequirementComponent>(ref val2) || val2.PlayerCanUseBody(player)))
				{
					list.Add(new Option
					{
						survivorIndex = val.survivorIndex,
						available = (!Object.op_Implicit((Object)(object)val.unlockableDef) || ((BaseUserEntitlementTracker<LocalUser>)(object)EntitlementManager.localUserEntitlementTracker).UserHasEntitlementForUnlockable(LocalUserManager.GetFirstLocalUser(), val.unlockableDef)),
						texture = (Texture2D)/*isinst with value type is only supported in some contexts*/
					});
				}
			}
			SetButtons(list.ToArray());
		}

		private void OnCreateButton(int index, MPButton button)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			((UnityEvent)((Button)button).onClick).AddListener((UnityAction)delegate
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)player.master))
				{
					NetMessageExtensions.Send((INetMessage)(object)new SyncRespawnRequest(player.master.bodyInstanceId, ((Object)SurvivorCatalog.GetSurvivorDef(characterOptions[index].survivorIndex).bodyPrefab).name), (NetworkDestination)2);
				}
				cancelled = false;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			});
		}

		private void EnsureLockedSprite()
		{
			//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)
			if ((Object)(object)lockedSprite == (Object)null)
			{
				lockedSprite = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common_MiscIcons.texUnlockIconSmall_png).WaitForCompletion();
			}
		}

		private void OnDestroy()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (cancelled && Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)player.master))
			{
				NetMessageExtensions.Send((INetMessage)(object)new SyncCloseUI(player.master.bodyInstanceId), (NetworkDestination)2);
			}
		}

		public void RemovePickupButtonAvailability(int characterOption)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			EnsureLockedSprite();
			characterOptions[characterOption].available = false;
			MPButton val = buttonAllocator.elements[characterOption];
			RawImage component = ((Component)((Component)val).GetComponent<ChildLocator>().FindChild("Icon")).GetComponent<RawImage>();
			((Graphic)component).color = Color.gray;
			component.texture = (Texture)(object)lockedSprite.texture;
			if (!shouldLeaveDisabledButtonsInteractable)
			{
				((Selectable)val).interactable = false;
			}
			TooltipProvider val2 = default(TooltipProvider);
			if (((Component)val).TryGetComponent<TooltipProvider>(ref val2))
			{
				((Behaviour)val2).enabled = false;
			}
		}

		private void SetButtons(Option[] options)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			characterOptions = options;
			buttonAllocator.AllocateElements(options.Length);
			ReadOnlyCollection<MPButton> elements = buttonAllocator.elements;
			EnsureLockedSprite();
			new StringBuilder().Append($"PANELDEBUG: Picker Panel for {((Object)((Component)this).gameObject).name}: {options.Length} options\r\n");
			for (int i = 0; i < options.Length; i++)
			{
				MPButton val = elements[i];
				int num = i - i % maxColumnCount;
				int num2 = i % maxColumnCount;
				int num3 = num2 - maxColumnCount;
				int num4 = num2 - 1;
				int num5 = num2 + 1;
				int num6 = num2 + maxColumnCount;
				Navigation navigation = ((Selectable)val).navigation;
				if (automaticButtonNavigation)
				{
					((Navigation)(ref navigation)).mode = (Mode)3;
				}
				else
				{
					((Navigation)(ref navigation)).mode = (Mode)4;
					if (num4 >= 0)
					{
						MPButton selectOnLeft = elements[num + num4];
						((Navigation)(ref navigation)).selectOnLeft = (Selectable)(object)selectOnLeft;
					}
					if (num5 < maxColumnCount && num + num5 < options.Length)
					{
						MPButton selectOnRight = elements[num + num5];
						((Navigation)(ref navigation)).selectOnRight = (Selectable)(object)selectOnRight;
					}
					if (num + num3 >= 0)
					{
						MPButton selectOnUp = elements[num + num3];
						((Navigation)(ref navigation)).selectOnUp = (Selectable)(object)selectOnUp;
					}
					if (num + num6 < options.Length)
					{
						MPButton selectOnDown = elements[num + num6];
						((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)selectOnDown;
					}
				}
				((Selectable)val).navigation = navigation;
				UpdateButtonUI(i);
			}
			OnPanelSetupComplete?.Invoke();
		}

		private void UpdateButtonUI(int index)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			MPButton val = buttonAllocator.elements[index];
			Option option = characterOptions[index];
			SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(option.survivorIndex);
			ChildLocator component = ((Component)val).GetComponent<ChildLocator>();
			RawImage component2 = ((Component)component.FindChild("Icon")).GetComponent<RawImage>();
			if (option.available)
			{
				((Graphic)component2).color = Color.white;
				component2.texture = (Texture)(object)option.texture;
				((Selectable)val).interactable = true;
			}
			else
			{
				((Graphic)component2).color = Color.gray;
				if (useLockSpriteForUnavailableOptions)
				{
					component2.texture = (Texture)(object)lockedSprite.texture;
				}
				else
				{
					component2.texture = (Texture)(object)option.texture;
				}
				if (!shouldLeaveDisabledButtonsInteractable)
				{
					((Selectable)val).interactable = false;
				}
			}
			if (shouldChangeButtonFrameColor)
			{
				((Graphic)((Selectable)val).image).color = (Color)(option.available ? Color.white : new Color(0.1f, 0.1f, 0.1f, 1f));
			}
			ColorBlock colors = ((Selectable)val).colors;
			bool flag = false;
			if (option.overrideUnavailableBGColor.HasValue && !option.available)
			{
				flag = true;
				((ColorBlock)(ref colors)).selectedColor = option.overrideUnavailableBGColor.Value;
			}
			else if (option.overrideSelectedBGColor.HasValue)
			{
				flag = true;
				((ColorBlock)(ref colors)).selectedColor = option.overrideSelectedBGColor.Value;
			}
			if (flag)
			{
				((Selectable)val).colors = colors;
			}
			TooltipProvider val2 = default(TooltipProvider);
			if (((Component)val).TryGetComponent<TooltipProvider>(ref val2))
			{
				((Behaviour)val2).enabled = _inspectFeatureIsEnabled && option.available;
				Color primaryColor = survivorDef.primaryColor;
				primaryColor.a = 1f;
				val2.SetContent(new TooltipContent
				{
					bodyColor = primaryColor,
					titleToken = survivorDef.displayNameToken,
					titleColor = primaryColor
				});
			}
		}
	}
	public class CharacterPickerPanelSizeAdjuster : MonoBehaviour
	{
		public CharacterPickerPanel pickerPanel;

		public RectTransform rectToAdjust;

		[Tooltip("How many rows can we have before we begin to adjust")]
		public int minRows = 5;

		[Tooltip("After this many rows, we will not adjust the size any higher")]
		public int maxRows = 7;

		[Tooltip("How much should we adjust the window for each new row")]
		public float adjustmentPerRow;

		[Tooltip("This will be set automatically")]
		public float objectHeight;

		private bool capturedDefaults;

		private void Awake()
		{
			CharacterPickerPanel characterPickerPanel = pickerPanel;
			characterPickerPanel.OnPanelSetupComplete = (Action)Delegate.Combine(characterPickerPanel.OnPanelSetupComplete, new Action(AdjustPickerPanelSize));
		}

		private void CaptureDefaults()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (capturedDefaults)
			{
				return;
			}
			RectTransform buttonContainer = pickerPanel.buttonContainer;
			if ((Object)(object)buttonContainer != (Object)null && ((Transform)buttonContainer).childCount > 0)
			{
				RectTransform component = ((Component)((Transform)buttonContainer).GetChild(0)).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					Rect rect = component.rect;
					objectHeight = ((Rect)(ref rect)).height;
				}
			}
			capturedDefaults = true;
		}

		private void AdjustPickerPanelSize()
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			//IL_007f: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Max(1, pickerPanel.maxColumnCount);
			int num2 = ((Transform)pickerPanel.buttonContainer).childCount / num;
			num2 = Mathf.Clamp(num2, minRows, maxRows) - minRows;
			rectToAdjust.ForceUpdateRectTransforms();
			CaptureDefaults();
			if (num2 > 0)
			{
				float num3 = adjustmentPerRow / 2f * (float)num2;
				Vector2 offsetMin = rectToAdjust.offsetMin;
				rectToAdjust.offsetMin = new Vector2(offsetMin.x, offsetMin.y - num3);
				offsetMin = rectToAdjust.offsetMax;
				rectToAdjust.offsetMax = new Vector2(offsetMin.x, offsetMin.y + num3);
			}
			rectToAdjust.sizeDelta = new Vector2(250f + (float)(120 * (num - 1)), rectToAdjust.sizeDelta.y);
		}
	}
	public class TransceiverImmunityController : MonoBehaviour
	{
		private float stopwatch;

		private CharacterBody body;

		private bool removedBuff;

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)body))
			{
				body.AddBuff(Assets.immunityBd);
			}
		}

		private void FixedUpdate()
		{
			stopwatch += Time.deltaTime;
			if (stopwatch >= Options.immunityDuration.Value)
			{
				RemoveBuff();
			}
			if (stopwatch >= Options.immunityPeriod.Value)
			{
				Object.Destroy((Object)(object)this);
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void RemoveBuff()
		{
			if (!removedBuff && Object.op_Implicit((Object)(object)body))
			{
				body.RemoveBuff(Assets.immunityBd);
				removedBuff = true;
			}
		}
	}
}