using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using WhatchaGotThere.Helpers;
using WhatchaGotThere.Patches;
[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("WarperSan")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Shows what equipment an ally is currently holding.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+c5fb4b07434f8638ae9739b48b11335383a9b096")]
[assembly: AssemblyProduct("WhatchaGotThere")]
[assembly: AssemblyTitle("WhatchaGotThere")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/WarperSan/WhatchaGotThere/")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 WhatchaGotThere
{
[BepInPlugin("dev.warpersan.whatchagotthere", "WhatchaGotThere", "1.0.1")]
internal class Plugin : BaseUnityPlugin
{
private void Awake()
{
Patch.ApplyAll();
Log.Info("dev.warpersan.whatchagotthere v1.0.1 has loaded!");
}
private void OnDestroy()
{
Patch.RevertAll();
Log.Info("dev.warpersan.whatchagotthere v1.0.1 has unloaded!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "dev.warpersan.whatchagotthere";
public const string PLUGIN_NAME = "WhatchaGotThere";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace WhatchaGotThere.Patches
{
[HarmonyPatch(typeof(AllyCardController))]
internal static class AllyCardController_Patches
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake_Postfix(AllyCardController __instance)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00ce: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Expected O, but got Unknown
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Expected O, but got Unknown
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Expected O, but got Unknown
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("WhatchaGotThere EquipmentSlot", new Type[4]
{
typeof(RectTransform),
typeof(LayoutElement),
typeof(Image),
typeof(TooltipProvider)
});
val.transform.SetParent((Transform)(object)__instance.rectTransform, false);
val.AddComponent<MPEventSystemLocator>();
val.AddComponent<HGButton>();
Transform obj = ((Transform)__instance.rectTransform).Find("Portrait");
int num = ((obj != null) ? obj.GetSiblingIndex() : (-1));
if (num != -1)
{
val.transform.SetSiblingIndex(num + 1);
}
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(48f, 48f);
LayoutElement component2 = val.GetComponent<LayoutElement>();
Rect rect = component.rect;
component2.preferredWidth = ((Rect)(ref rect)).width;
rect = component.rect;
component2.preferredHeight = ((Rect)(ref rect)).height;
Image component3 = val.GetComponent<Image>();
((Graphic)component3).color = Color.clear;
((Graphic)component3).raycastTarget = false;
HGButton component4 = val.GetComponent<HGButton>();
((Selectable)component4).image = component3;
EquipmentIcon val2 = val.AddComponent<EquipmentIcon>();
val2.tooltipProvider = val.GetComponent<TooltipProvider>();
GameObject val3 = new GameObject("DisplayRoot", new Type[1] { typeof(RectTransform) });
val3.transform.SetParent(val.transform, false);
val2.displayRoot = val3;
RectTransform component5 = val3.GetComponent<RectTransform>();
component5.anchorMin = Vector2.zero;
component5.anchorMax = Vector2.one;
component5.offsetMin = Vector2.zero;
component5.offsetMax = Vector2.zero;
GameObject val4 = new GameObject("IconPanel", new Type[2]
{
typeof(RectTransform),
typeof(RawImage)
});
val4.transform.SetParent(val3.transform, false);
val2.iconImage = val4.GetComponent<RawImage>();
RectTransform component6 = val4.GetComponent<RectTransform>();
component6.anchorMin = Vector2.zero;
component6.anchorMax = Vector2.one;
component6.offsetMin = Vector2.zero;
component6.offsetMax = Vector2.zero;
GameObject val5 = new GameObject("Cooldown Text", new Type[2]
{
typeof(RectTransform),
typeof(HGTextMeshProUGUI)
});
val5.transform.SetParent(val3.transform, false);
RectTransform component7 = val5.GetComponent<RectTransform>();
component7.anchorMin = Vector2.zero;
component7.anchorMax = Vector2.one;
component7.offsetMin = Vector2.zero;
component7.offsetMax = Vector2.zero;
HGTextMeshProUGUI component8 = val5.GetComponent<HGTextMeshProUGUI>();
((TMP_Text)component8).alignment = (TextAlignmentOptions)514;
val2.cooldownText = (TextMeshProUGUI)(object)component8;
}
[HarmonyPatch("UpdateInfo")]
[HarmonyPostfix]
private static void UpdateInfo_Postfix(AllyCardController __instance)
{
EquipmentIcon componentInChildren = ((Component)__instance).GetComponentInChildren<EquipmentIcon>();
if (!((Object)(object)componentInChildren == (Object)null))
{
bool active = ShouldShowIcon(__instance);
componentInChildren.targetInventory = __instance.sourceMaster.inventory;
((Component)componentInChildren).gameObject.SetActive(active);
}
}
private static bool ShouldShowIcon(AllyCardController controller)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Invalid comparison between Unknown and I4
if ((Object)(object)controller.sourceMaster.inventory == (Object)null)
{
return false;
}
EquipmentIndex equipmentIndex = controller.sourceMaster.inventory.GetEquipmentIndex();
if ((int)equipmentIndex == -1)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(AllyCardManager))]
internal static class AllyCardManager_Patches
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Awake_Postfix(AllyCardManager __instance)
{
Canvas componentInParent = ((Component)((Component)__instance).transform).GetComponentInParent<Canvas>();
if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)((Component)componentInParent).gameObject.GetComponent<GraphicRaycaster>() != (Object)null))
{
((Component)componentInParent).gameObject.AddComponent<GraphicRaycaster>();
}
}
}
}
namespace WhatchaGotThere.Helpers
{
internal static class Log
{
private static ManualLogSource? _logger;
private static void LogSelf(string message, LogLevel level)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (_logger == null)
{
_logger = Logger.CreateLogSource("WhatchaGotThere");
}
ManualLogSource? logger = _logger;
if (logger != null)
{
logger.Log(level, (object)message);
}
}
public static void Debug(string message)
{
LogSelf(message, (LogLevel)32);
}
public static void Info(string message)
{
LogSelf(message, (LogLevel)8);
}
public static void Warning(string message)
{
LogSelf(message, (LogLevel)4);
}
public static void Error(string message)
{
LogSelf(message, (LogLevel)2);
}
}
internal static class Patch
{
private static Harmony? _harmony;
public static void ApplyAll()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if (_harmony != null)
{
Log.Debug("Unpatching the existing harmony instance.");
RevertAll();
}
_harmony = new Harmony("dev.warpersan.whatchagotthere");
_harmony.PatchAll(typeof(AllyCardController_Patches));
_harmony.PatchAll(typeof(AllyCardManager_Patches));
Log.Debug("All patches applied.");
}
public static void RevertAll()
{
if (_harmony != null)
{
_harmony.UnpatchSelf();
_harmony = null;
Log.Debug("All patches reverted.");
}
}
}
}