Decompiled source of RiskUIRevived v1.0.4

RiskUIRevived.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using MaterialHud;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2.Scripts.GameBehaviors.UI;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;

[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("RiskUIRevived")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RiskUIRevived")]
[assembly: AssemblyTitle("RiskUIRevived")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RiskUIRevived
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(string data)
		{
		}

		internal static void Info(string data)
		{
		}

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

		internal static void Warning(string data)
		{
			_logSource.LogWarning((object)data);
		}

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

		internal static void Fatal(string data)
		{
			_logSource.LogFatal((object)data);
		}
	}
	[HarmonyPatch]
	public static class NewHarmonyPatches
	{
		[HarmonyILManipulator]
		[HarmonyPatch(typeof(CameraRigController), "UpdateHUD")]
		public static void ReplaceHUD(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			int num = default(int);
			MethodReference val2 = default(MethodReference);
			val.GotoNext((MoveType)1, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val2),
				(Instruction x) => ILPatternMatchingExt.MatchStsfld(x, typeof(CameraRigController), "HudPrefab")
			});
			val.EmitDelegate<Func<GameObject>>((Func<GameObject>)RiskUIPlugin.CreateHud);
			val.RemoveRange(2);
			val.GotoNext((MoveType)1, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(CameraRigController), "HudPrefab")
			});
			val.EmitDelegate<Func<GameObject>>((Func<GameObject>)RiskUIPlugin.CreateHud);
			val.Remove();
		}

		[HarmonyILManipulator]
		[HarmonyPatch(typeof(HealthBar), "UpdateBarInfos")]
		public static void FixInfusionColor(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(HealthBar), "voidPanelColor")
			});
			val.Remove();
			val.EmitDelegate<Func<Color>>((Func<Color>)delegate
			{
				//IL_0005: 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)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
				Color value3 = RiskUIPlugin.VoidColor.Value;
				return (value3 == Color.clear) ? Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f) : value3;
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(HealthBar), "infusionPanelColor")
			});
			val.Remove();
			val.EmitDelegate<Func<Color>>((Func<Color>)delegate
			{
				//IL_0005: 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)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
				Color value2 = RiskUIPlugin.InfusionColor.Value;
				return (value2 == Color.clear) ? Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f) : value2;
			});
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(HealthBar), "voidShieldsColor")
			});
			val.Remove();
			val.EmitDelegate<Func<Color>>((Func<Color>)delegate
			{
				//IL_0005: 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)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
				Color value = RiskUIPlugin.VoidShieldColor.Value;
				return (value == Color.clear) ? Color.HSVToRGB(Mathf.Sin(Time.time) * 0.5f + 0.5f, 1f, 1f) : value;
			});
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Run), "InstantiateUi")]
		public static bool OverwriteTracker(Run __instance, Transform uiRoot, ref GameObject __result)
		{
			if (!Object.op_Implicit((Object)(object)uiRoot))
			{
				return true;
			}
			string nameToken = __instance.nameToken;
			if (nameToken == "ECLIPSE_GAMEMODE_NAME" || nameToken == "GAMEMODE_CLASSIC_RUN_NAME")
			{
				__result = Object.Instantiate<GameObject>(RiskUIPlugin.CreateClassicRunHud(), uiRoot);
				__instance.uiInstances.Add(__result);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(DifficultyDef), "GetIconSprite")]
		public static bool SwapIcon(DifficultyDef __instance, ref Sprite __result)
		{
			if (__instance.nameToken == null || !RiskUIPlugin.DifficultyIconMap.ContainsKey(__instance.nameToken))
			{
				return true;
			}
			__result = RiskUIPlugin.DifficultyIconMap[__instance.nameToken];
			return false;
		}

		[HarmonyILManipulator]
		[HarmonyPatch(typeof(AllyCardManager), "Awake")]
		public static void ReplaceAllyCards(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Prefabs/UI/AllyCard")
			});
			val.RemoveRange(2);
			val.EmitDelegate<Func<GameObject>>((Func<GameObject>)RiskUIPlugin.CreateAllyCard);
		}

		public static void MoveVoidSurvivorController(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<VoidSurvivorController>(x, "overlayChildLocatorEntry")
			});
			val.RemoveRange(2);
			val.Emit(OpCodes.Ldstr, "BottomLeftCluster");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyInfoPanel), "Init")]
		public static void ChangeMonsterInventory()
		{
			EnemyInfoPanel.panelPrefab = RiskUIPlugin.EnemyInfoPanel;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ScoreboardStrip), "ResetNavIndicators")]
		public static bool ResetNav()
		{
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HUD), "DeactivateScoreboard")]
		public static void Unselect(HUD __instance)
		{
			ScoreboardController val = default(ScoreboardController);
			if (Object.op_Implicit((Object)(object)__instance.scoreboardPanel) && __instance.scoreboardPanel.TryGetComponent<ScoreboardController>(ref val) && Object.op_Implicit((Object)(object)val.eventSystem))
			{
				((EventSystem)val.eventSystem).SetSelectedGameObject((GameObject)null);
				val.eventSystem.currentSelectedButton = null;
			}
		}

		[HarmonyILManipulator]
		[HarmonyPatch(typeof(ItemIcon), "SetItemIndex")]
		public static void ItemCount(ILContext il)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			ILCursor[] array = null;
			if (new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(ItemIcon), "spriteAsNumberManager"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<SpriteAsNumberManager>(x, "SetItemCount"),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(ItemIcon), "spriteAsNumberManager"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<SpriteAsNumberManager>(x, "SetVisible")
			}))
			{
				array[0].Remove();
				array[0].Emit<ItemIcon>(OpCodes.Ldfld, "stackText");
				array[1].Remove();
				array[1].EmitDelegate<Action<TextMeshProUGUI, int>>((Action<TextMeshProUGUI, int>)delegate(TextMeshProUGUI image, int num)
				{
					((TMP_Text)image).text = "x" + num;
					((Behaviour)image).enabled = true;
				});
				array[2].Remove();
				array[2].Emit<ItemIcon>(OpCodes.Ldfld, "stackText");
				array[3].Remove();
				array[3].EmitDelegate<Action<TextMeshProUGUI, bool>>((Action<TextMeshProUGUI, bool>)delegate(TextMeshProUGUI image, bool num)
				{
					((TMP_Text)image).text = "";
					((Behaviour)image).enabled = false;
				});
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ScoreboardStrip), "UpdateItemCountText")]
		public static bool NoCount()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InspectPanelLocator), "Awake")]
		public static bool NoPanel()
		{
			return false;
		}

		[HarmonyILManipulator]
		[HarmonyPatch(typeof(ContextManager), "Update")]
		public static void NoInspect(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.Index = val.Instrs.Count - 1;
			if (val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(GameObject), "SetActive")
			}))
			{
				val.Remove();
				val.EmitDelegate<Action<GameObject, bool>>((Action<GameObject, bool>)Slurp2);
			}
			if (val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(TMP_Text), "text"))
			}))
			{
				val.Remove();
				val.EmitDelegate<Action<TMP_Text, string>>((Action<TMP_Text, string>)Slurp);
			}
			if (val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(TMP_Text), "text"))
			}))
			{
				val.Remove();
				val.EmitDelegate<Action<TMP_Text, string>>((Action<TMP_Text, string>)Slurp);
			}
			if (val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(GameObject), "SetActive")
			}))
			{
				val.Remove();
				val.EmitDelegate<Action<GameObject, bool>>((Action<GameObject, bool>)Slurp2);
			}
			if (val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(TMP_Text), "text"))
			}))
			{
				val.Remove();
				val.EmitDelegate<Action<TMP_Text, string>>((Action<TMP_Text, string>)Slurp);
			}
			if (val.TryGotoPrev(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(TMP_Text), "text"))
			}))
			{
				val.Remove();
				val.EmitDelegate<Action<TMP_Text, string>>((Action<TMP_Text, string>)Slurp);
			}
			static void Slurp(TMP_Text _, string __)
			{
				if (Object.op_Implicit((Object)(object)_))
				{
					_.text = __;
				}
			}
			static void Slurp2(GameObject _, bool __)
			{
				if (Object.op_Implicit((Object)(object)_))
				{
					_.SetActive(__);
				}
			}
		}
	}
	[BepInPlugin("_score.RiskUIRevived", "RiskUIRevived", "1.0.4")]
	public class RiskUIRevivedPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "_score.RiskUIRevived";

		public const string PluginAuthor = "score";

		public const string PluginName = "RiskUIRevived";

		public const string PluginVersion = "1.0.4";

		public static RiskUIRevivedPlugin Instance { get; private set; }

		public void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).CreateClassProcessor(typeof(PatchPlugin)).Patch();
		}
	}
	[HarmonyPatch]
	public class PatchPlugin
	{
		[HarmonyPatch(typeof(RiskUIPlugin), "Awake")]
		[HarmonyILManipulator]
		public static void ReplaceTarget(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			IMetadataTokenProvider val4 = default(IMetadataTokenProvider);
			MethodReference val3 = default(MethodReference);
			MethodReference val2 = default(MethodReference);
			val.GotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<RiskUIPlugin>(x, "harm"),
				(Instruction x) => ILPatternMatchingExt.MatchLdtoken(x, ref val4),
				(Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchNewobj(x, ref val2),
				(Instruction x) => ILPatternMatchingExt.MatchStfld<RiskUIPlugin>(x, "patcher")
			});
			val.RemoveRange(6);
			val.EmitDelegate<Action<RiskUIPlugin>>((Action<RiskUIPlugin>)delegate(RiskUIPlugin instance)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				instance.patcher = new PatchClassProcessor(instance.harm, typeof(NewHarmonyPatches));
			});
		}

		[HarmonyPatch(typeof(RiskUIPlugin), "Awake")]
		[HarmonyPostfix]
		public static void EditShit(RiskUIPlugin __instance)
		{
			//IL_0096: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			AssetBundle assetBundle = __instance.assetBundle;
			HUD component = RiskUIPlugin._newHud.GetComponent<HUD>();
			GameObject go = assetBundle.LoadAsset<GameObject>("SkillIconRoot");
			GameObject go2 = assetBundle.LoadAsset<GameObject>("HealthBarSub");
			GameObject go3 = assetBundle.LoadAsset<GameObject>("MaterialChatbox");
			GameObject go4 = assetBundle.LoadAsset<GameObject>("MaterialArtifactStatusIcon");
			GameObject val = assetBundle.LoadAsset<GameObject>("MaterialObjectiveStrip");
			SkillIcon[] skillIcons = component.skillIcons;
			GameObject buffIconPrefab = component.buffDisplay.buffIconPrefab;
			GameObject gameObject = ((Component)component.itemInventoryDisplay).gameObject;
			EquipmentIcon[] equipmentIcons = component.equipmentIcons;
			val.TryAddComponent<UIInputPassthrough>();
			val.TryAddComponent<MPEventSystemLocator>();
			val.TryAddComponent<ObjectiveStripAnimationParams>().Params = new List<ObjectiveStripAnimationParam>(4)
			{
				new ObjectiveStripAnimationParam
				{
					Param = "enterAlphaStartPercent",
					Value = 0.25f
				},
				new ObjectiveStripAnimationParam
				{
					Param = "enterAlphaEndPercent",
					Value = 0.5f
				},
				new ObjectiveStripAnimationParam
				{
					Param = "enterHeightStartPercent",
					Value = 0f
				},
				new ObjectiveStripAnimationParam
				{
					Param = "enterHeightEndPercent",
					Value = 0.25f
				}
			};
			if (Object.op_Implicit((Object)(object)val.transform.Find("Checkbox")))
			{
				val.transform.Find("Checkbox").SetParent(val.transform.Find("Label"));
			}
			buffIconPrefab.TryAddComponent<UIInputPassthrough>();
			buffIconPrefab.TryAddComponent<MPEventSystemLocator>();
			MPButton obj = buffIconPrefab.TryAddComponent<MPButton>();
			obj.disableGamepadClick = true;
			obj.disablePointerClick = true;
			((Component)equipmentIcons[0]).gameObject.TryAddComponent<MPEventSystemLocator>();
			((Component)equipmentIcons[0]).gameObject.TryAddComponent<UIInputPassthrough>();
			MPButton obj2 = ((Component)equipmentIcons[0]).gameObject.TryAddComponent<MPButton>();
			obj2.disableGamepadClick = true;
			obj2.disablePointerClick = true;
			((Component)equipmentIcons[1]).gameObject.TryAddComponent<MPEventSystemLocator>();
			((Component)equipmentIcons[1]).gameObject.TryAddComponent<UIInputPassthrough>();
			MPButton obj3 = ((Component)equipmentIcons[1]).gameObject.TryAddComponent<MPButton>();
			obj3.disableGamepadClick = true;
			obj3.disablePointerClick = true;
			((Component)skillIcons[0]).gameObject.TryAddComponent<MPEventSystemLocator>();
			((Component)skillIcons[0]).gameObject.TryAddComponent<UIInputPassthrough>();
			MPButton obj4 = ((Component)skillIcons[0]).gameObject.TryAddComponent<MPButton>();
			obj4.disableGamepadClick = true;
			obj4.disablePointerClick = true;
			((Component)skillIcons[1]).gameObject.TryAddComponent<MPEventSystemLocator>();
			((Component)skillIcons[1]).gameObject.TryAddComponent<UIInputPassthrough>();
			MPButton obj5 = ((Component)skillIcons[1]).gameObject.TryAddComponent<MPButton>();
			obj5.disableGamepadClick = true;
			obj5.disablePointerClick = true;
			((Component)skillIcons[2]).gameObject.TryAddComponent<MPEventSystemLocator>();
			((Component)skillIcons[2]).gameObject.TryAddComponent<UIInputPassthrough>();
			MPButton obj6 = ((Component)skillIcons[2]).gameObject.TryAddComponent<MPButton>();
			obj6.disableGamepadClick = true;
			obj6.disablePointerClick = true;
			((Component)skillIcons[3]).gameObject.TryAddComponent<MPEventSystemLocator>();
			((Component)skillIcons[3]).gameObject.TryAddComponent<UIInputPassthrough>();
			MPButton obj7 = ((Component)skillIcons[3]).gameObject.TryAddComponent<MPButton>();
			obj7.disableGamepadClick = true;
			obj7.disablePointerClick = true;
			gameObject.TryAddComponent<UIInputPassthrough>();
			gameObject.TryAddComponent<MPEventSystemLocator>();
			MPButton obj8 = gameObject.TryAddComponent<MPButton>();
			obj8.disableGamepadClick = true;
			obj8.disablePointerClick = true;
			component.scoreboardPanel.TryAddComponent<UIInputPassthrough>();
			component.scoreboardPanel.TryAddComponent<MPEventSystemLocator>();
			ScoreboardController component2 = component.scoreboardPanel.GetComponent<ScoreboardController>();
			component2.stripPrefab.TryAddComponent<UIInputPassthrough>();
			ScoreboardStrip component3 = component2.stripPrefab.GetComponent<ScoreboardStrip>();
			component3.eventSystemLocator = component2.stripPrefab.TryAddComponent<MPEventSystemLocator>();
			((Component)component3.equipmentIcon).gameObject.TryAddComponent<UIInputPassthrough>();
			((Component)component3.equipmentIcon).gameObject.TryAddComponent<MPEventSystemLocator>();
			MPButton obj9 = ((Component)component3).gameObject.TryAddComponent<MPButton>();
			obj9.disableGamepadClick = true;
			obj9.disablePointerClick = true;
			go3.TryAddComponent<UIInputPassthrough>();
			go3.TryAddComponent<MPEventSystemLocator>();
			go4.TryAddComponent<UIInputPassthrough>();
			go4.TryAddComponent<MPEventSystemLocator>();
			go2.TryAddComponent<UIInputPassthrough>();
			go2.TryAddComponent<MPEventSystemLocator>();
			go.TryAddComponent<UIInputPassthrough>();
			go.TryAddComponent<MPEventSystemLocator>();
			RiskUIPlugin.EnemyInfoPanel.TryAddComponent<UIInputPassthrough>();
			RiskUIPlugin.EnemyInfoPanel.TryAddComponent<MPEventSystemLocator>();
			RiskUIPlugin._allyCard.TryAddComponent<UIInputPassthrough>();
			RiskUIPlugin._allyCard.TryAddComponent<MPEventSystemLocator>();
			RiskUIPlugin._newClassicRunHud.TryAddComponent<UIInputPassthrough>();
			RiskUIPlugin._newClassicRunHud.TryAddComponent<MPEventSystemLocator>();
			RiskUIPlugin._newSimulacrumHud.TryAddComponent<UIInputPassthrough>();
			RiskUIPlugin._newSimulacrumHud.TryAddComponent<MPEventSystemLocator>();
			RiskUIPlugin.BaseWaveUI.TryAddComponent<UIInputPassthrough>();
			RiskUIPlugin.BaseWaveUI.TryAddComponent<MPEventSystemLocator>();
		}
	}
	internal static class Utils
	{
		public static T TryAddComponent<T>(this GameObject go) where T : Component
		{
			T result = default(T);
			if (go.TryGetComponent<T>(ref result))
			{
				return result;
			}
			return go.AddComponent<T>();
		}

		public static void RemoveComponent<T>(this GameObject go) where T : Component
		{
			T val = default(T);
			if (go.TryGetComponent<T>(ref val))
			{
				Object.Destroy((Object)(object)val);
			}
		}

		public static void RemoveComponents<T>(this GameObject go) where T : Component
		{
			T[] components = go.GetComponents<T>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
		}

		public static T GetCopyOf<T>(this Component comp, T other) where T : Component
		{
			Type type = ((object)comp).GetType();
			if (type != ((object)other).GetType())
			{
				return default(T);
			}
			BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			PropertyInfo[] properties = type.GetProperties(bindingAttr);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanWrite)
				{
					try
					{
						propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
					}
					catch
					{
					}
				}
			}
			FieldInfo[] fields = type.GetFields(bindingAttr);
			foreach (FieldInfo fieldInfo in fields)
			{
				fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
			}
			return (T)(object)((comp is T) ? comp : null);
		}

		public static T GetCopyOf<T>(this ScriptableObject comp, T other) where T : ScriptableObject
		{
			Type type = ((object)comp).GetType();
			if (type != ((object)other).GetType())
			{
				return default(T);
			}
			BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			PropertyInfo[] properties = type.GetProperties(bindingAttr);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanWrite)
				{
					try
					{
						propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
					}
					catch
					{
					}
				}
			}
			FieldInfo[] fields = type.GetFields(bindingAttr);
			foreach (FieldInfo fieldInfo in fields)
			{
				fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
			}
			return (T)(object)((comp is T) ? comp : null);
		}

		public static T AddComponentCopy<T>(this GameObject go, T toAdd) where T : Component
		{
			return ((Component)(object)go.AddComponent<T>()).GetCopyOf(toAdd);
		}
	}
}