using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using Faust.QoLChests.Api; using Faust.QoLChests.Components; using Faust.QoLChests.Handlers; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [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; } } } [BepInPlugin("ClientSideRepairs.QoLChestSupport", "QoL Chests DLC Compatibility", "1.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class QoLChestSupport : BaseUnityPlugin { public class AvailableHighlightFallback : MonoBehaviour { public PurchaseInteraction Purchase; public Highlight Highlight; public InteractableCategory Category; private float next; private void LateUpdate() { if (Time.unscaledTime >= next) { next = Time.unscaledTime + 0.25f; Refresh(); } } public void Refresh() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Highlight)) { if (!Object.op_Implicit((Object)(object)Purchase) || !((Behaviour)Purchase).isActiveAndEnabled || !Purchase.available || Object.op_Implicit((Object)(object)((Component)this).GetComponent()) || categoryEnabled == null || !categoryEnabled(Category)) { Highlight.isOn = false; return; } HighlightHandler.Enable(((Component)this).gameObject, false); EnsureRegistered(Highlight); } } } private float nextScan; private static Func categoryEnabled; private readonly HashSet reported = new HashSet(); private readonly HashSet inspected = new HashSet(); private readonly HashSet candidates = new HashSet(); private int scannedRun; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown Harmony val = new Harmony("ClientSideRepairs.QoLChestSupport"); val.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("Faust.QoLChests.Utils"), "DisableColliders", (Type[])null, (Type[])null), new HarmonyMethod(typeof(QoLChestSupport), "KeepColliders", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(AccessTools.TypeByName("Faust.QoLChests.Hooks.ShopHooks"), "PurchaseInteractionOnInteractionBegin", (Type[])null, (Type[])null), new HarmonyMethod(typeof(QoLChestSupport), "ProtectTimedInteraction", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(HighlightHandler), "Enable", new Type[2] { typeof(GameObject), typeof(bool) }, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(QoLChestSupport), "ProtectOutlineColour", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); string[] array = new string[6] { "DroneCombiner", "DroneCombinerStation", "DroneUpgradeStation", "HollowChest", "ShrineHalcyonite", "ShrineRebirth" }; foreach (string text in array) { QoLChestsApi.BlackListInteractable(text); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"QoLChests 1.3.6 API support installed. Official barrel and multi-renderer handling retained; visual-only hiding and timed-interaction safeguards preserved."); Type type = AccessTools.TypeByName("Faust.QoLChests.Configs.ModConfig"); object value = AccessTools.Property(type, "Instance").GetValue(null, null); categoryEnabled = (Func)Delegate.CreateDelegate(typeof(Func), value, AccessTools.Method(type, "IsCategoryHighlightEnabled", (Type[])null, (Type[])null)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Available-interactable highlight fallback enabled; includes late-spawned repair drones and missing renderer targets. Existing category colours retained."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"QoL outline colour guard installed: low-red cyan/blue/green colours receive a small visibility-channel floor."); } private unsafe void Update() { //IL_0270: 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_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Run.instance) || categoryEnabled == null || Time.unscaledTime < nextScan) { return; } nextScan = Time.unscaledTime + 3f; PurchaseInteraction[] array = Object.FindObjectsOfType(); if (array.Length != 0 && scannedRun != ((Object)Run.instance).GetInstanceID()) { scannedRun = ((Object)Run.instance).GetInstanceID(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Highlight scene scan active; purchase interactions=" + array.Length)); } PurchaseInteraction[] array2 = array; InteractableCategory val2 = default(InteractableCategory); foreach (PurchaseInteraction val in array2) { if (Object.op_Implicit((Object)(object)val) && (val.isDrone || ((Object)((Component)val).gameObject).name.IndexOf("Drone", StringComparison.OrdinalIgnoreCase) >= 0) && candidates.Count < 40 && candidates.Add(((Object)((Component)val).gameObject).name.Replace("(Clone)", ""))) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Drone highlight candidate: " + ((Object)((Component)val).gameObject).name + "; active=" + ((Behaviour)val).isActiveAndEnabled + "; available=" + val.available + "; token=" + val.contextToken + "; body=" + ((Object)(object)((Component)val).GetComponentInParent() != (Object)null) + "; used=" + ((Object)(object)((Component)val).GetComponent() != (Object)null))); } if (!Object.op_Implicit((Object)(object)val) || !((Behaviour)val).isActiveAndEnabled || !val.available) { continue; } GameObject gameObject = ((Component)val).gameObject; bool flag = GroundHighlightPolicy.IsRepairDrone(((Object)gameObject).name, val.contextToken, (Object)(object)gameObject.GetComponent() != (Object)null || (Object)(object)gameObject.GetComponent() != (Object)null); if (Object.op_Implicit((Object)(object)gameObject.GetComponentInParent()) && !flag) { continue; } InteractableHighlightCategoryMarker component = gameObject.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { val2 = component.Category; } else if (!InteractableRegistry.IsRegistered(((Object)gameObject).name, ref val2)) { int num = GroundHighlightPolicy.Category(((Object)gameObject).name, val.contextToken, flag); if (num < 0) { continue; } val2 = (InteractableCategory)num; } if (!categoryEnabled(val2) || Object.op_Implicit((Object)(object)gameObject.GetComponent())) { continue; } Highlight val3 = gameObject.GetComponent(); string text = ((Object)gameObject).name.Replace("(Clone)", ""); bool flag2 = HasActiveTarget(val3); bool flag3 = Object.op_Implicit((Object)(object)val3) && Highlight.readonlyHighlightList.Contains(val3); if (flag && inspected.Count < 40 && inspected.Add(text)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Repair drone outline audit: " + text + "; category=" + ((object)(*(InteractableCategory*)(&val2))/*cast due to .constrained prefix*/).ToString() + "; on=" + (Object.op_Implicit((Object)(object)val3) && val3.isOn) + "; enabled=" + (Object.op_Implicit((Object)(object)val3) && ((Behaviour)val3).enabled) + "; activeTarget=" + flag2 + "; registered=" + flag3)); } if (!flag && Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)val3) && val3.isOn && ((Behaviour)val3).enabled && flag2 && flag3) { continue; } if (!Object.op_Implicit((Object)(object)component)) { component = gameObject.AddComponent().SetCategory(val2); } if (!Object.op_Implicit((Object)(object)val3)) { val3 = gameObject.AddComponent(); } AvailableHighlightFallback availableHighlightFallback = gameObject.GetComponent(); if (!flag2 || (flag && !Object.op_Implicit((Object)(object)availableHighlightFallback))) { List list = new List(); ModelLocator component2 = gameObject.GetComponent(); Transform val4 = ((Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.modelTransform)) ? component2.modelTransform : gameObject.transform); Renderer[] componentsInChildren = ((Component)val4).GetComponentsInChildren(); foreach (Renderer val5 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val5) && val5.enabled && (val5 is MeshRenderer || val5 is SkinnedMeshRenderer)) { list.Add(val5); } } if (list.Count == 0) { continue; } val3.SetTargetRendererList(list); } if (!Object.op_Implicit((Object)(object)availableHighlightFallback)) { availableHighlightFallback = gameObject.AddComponent(); } availableHighlightFallback.Purchase = val; availableHighlightFallback.Highlight = val3; availableHighlightFallback.Category = val2; availableHighlightFallback.Refresh(); if (reported.Count < 80 && reported.Add(text)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Repaired available-interactable highlight: " + text + "; category=" + ((object)(*(InteractableCategory*)(&val2))/*cast due to .constrained prefix*/).ToString())); } } } private static bool ActiveRenderer(Renderer renderer) { return Object.op_Implicit((Object)(object)renderer) && renderer.enabled && ((Component)renderer).gameObject.activeInHierarchy && (renderer is MeshRenderer || renderer is SkinnedMeshRenderer); } private static bool HasActiveTarget(Highlight highlight) { if (!Object.op_Implicit((Object)(object)highlight)) { return false; } if (Object.op_Implicit((Object)(object)highlight.targetRenderer)) { return ActiveRenderer(highlight.targetRenderer); } List targetRendererList = highlight.GetTargetRendererList(); if (targetRendererList != null) { foreach (Renderer item in targetRendererList) { if (ActiveRenderer(item)) { return true; } } } return false; } private static void EnsureRegistered(Highlight highlight) { if (Object.op_Implicit((Object)(object)highlight) && !Highlight.readonlyHighlightList.Contains(highlight)) { ((Behaviour)highlight).enabled = false; ((Behaviour)highlight).enabled = true; } } private static bool KeepColliders(ref Collider[] __result) { __result = Array.Empty(); return false; } private static void ProtectOutlineColour(GameObject __0) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__0)) { Highlight component = __0.GetComponent(); if (Object.op_Implicit((Object)(object)component) && component.isOn && (int)component.highlightColor == 3) { Color customColor = component.CustomColor; customColor.r = OutlineColourPolicy.SafeRed(customColor.r, customColor.g, customColor.b); component.CustomColor = customColor; } } } private static void ProtectTimedInteraction(PurchaseInteraction __1) { if (Object.op_Implicit((Object)(object)__1) && Object.op_Implicit((Object)(object)((Component)__1).gameObject)) { string name = ((Object)((Component)__1).gameObject).name; string text = name.ToUpperInvariant(); if (text.Contains("HOLLOW") || text.Contains("DRONECOMBIN") || text.Contains("DRONEUPGRADE") || text.Contains("HALCYON") || text.Contains("SHRINEREBIRTH")) { QoLChestsApi.BlackListInteractable(name); } } } } public static class OutlineColourPolicy { public static float SafeRed(float red, float green, float blue) { return (green > 0f || blue > 0f) ? Math.Max(red, 0.1f) : red; } } public static class GroundHighlightPolicy { public static bool IsRepairDrone(string name, string token, bool hasRepairComponent) { string text = (name ?? "").ToUpperInvariant(); string text2 = (token ?? "").ToUpperInvariant(); return hasRepairComponent && text.Contains("BROKEN") && (text.Contains("DRONE") || text.Contains("TURRET")) && (text2.Contains("DRONE") || text2.Contains("TURRET")); } public static int Category(string name, string token, bool repair) { string text = (name ?? "").Replace("(Clone)", "").ToUpperInvariant(); if (repair) { return text.Contains("TURRET") ? 5 : 4; } if (text.Contains("TRIPLEDRONESHOP") || text.Contains("SHOPTERMINAL")) { return 1; } if (text.Contains("DRONESCRAPPER") || text == "SCRAPPER") { return 2; } if (text.Contains("DRONECOMBIN") || text.Contains("DRONEUPGRADE") || text.Contains("DRONEASSEMBLY") || text.Contains("DUPLICATOR")) { return 3; } if (text.Contains("LOCKBOX")) { return 8; } if (text.Contains("EQUIPMENTBARREL")) { return 12; } if (text == "BARREL1" || text == "BARREL2") { return 9; } if (text.Contains("VOIDCHEST") || text.Contains("VOIDCRADLE")) { return 14; } if (text.Contains("LUNARCHEST") || text.Contains("LUNARPOD")) { return 13; } if (text.Contains("CHEST") && text.Contains("STEALTH")) { return 6; } if (text.Contains("CHEST")) { return 0; } if (text.StartsWith("NEWTSTATUE")) { return 10; } if (text.Contains("PRESSUREPLATE")) { return 11; } if (text.StartsWith("SHRINE") || text.Contains("HALLOWINGSHRINE")) { return 7; } return -1; } }