Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ExtraFoodZenUIBridge v1.0.0
ExtraFoodZenUIBridge.dll
Decompiled 4 days agousing System; using System.Collections; 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 UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [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; } } } namespace ExtraFoodZenUIBridge { [BepInPlugin("local.extrafood.zenuibridge", "ExtraFood ZenUI Bridge", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BridgePlugin : BaseUnityPlugin { public const string PluginGuid = "local.extrafood.zenuibridge"; public const string PluginName = "ExtraFood ZenUI Bridge"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private static FieldInfo panelListField; private static FieldInfo augaField; private static FieldInfo backgroundField; private static Type itemType; private static Type componentType; private static bool announced; private static bool failed; private Harmony harmony; private void Awake() { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Type type = AccessTools.TypeByName("ZenUI.Section.FoodPanel"); Type type2 = AccessTools.TypeByName("Nick008ExtraFood.Nick008ExtraFoodPlugin"); Type type3 = AccessTools.TypeByName("Hud"); panelListField = ((type == null) ? null : AccessTools.Field(type, "FoodPanelUIs")); augaField = ((type == null) ? null : AccessTools.Field(type, "_isAugaLite")); backgroundField = ((type2 == null) ? null : AccessTools.Field(type2, "fourthFoodBackgroundObject")); MethodInfo methodInfo = ((type3 == null) ? null : AccessTools.Method(type3, "UpdateFood", (Type[])null, (Type[])null)); if (panelListField == null || backgroundField == null || methodInfo == null) { Log.LogWarning((object)"No se encontraron los campos esperados de ZenUI / nick008extrafood (cambio de version?). El puente no se activa."); return; } Type[] genericArguments = panelListField.FieldType.GetGenericArguments(); if (genericArguments.Length != 1 || !genericArguments[0].IsGenericType || genericArguments[0].GetGenericArguments().Length != 2) { Log.LogWarning((object)"FoodPanelUIs de ZenUI tiene un formato inesperado. El puente no se activa."); return; } itemType = genericArguments[0]; componentType = itemType.GetGenericArguments()[0]; harmony = new Harmony("local.extrafood.zenuibridge"); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(BridgePlugin), "UpdateFoodPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Listo: ZenUI coloreara tambien el cuarto slot de comida."); } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } } private static void UpdateFoodPrefix() { if (failed) { return; } try { if ((augaField != null && (bool)augaField.GetValue(null)) || !(panelListField.GetValue(null) is IList { Count: >=3, Count: <=4 } list)) { return; } object? value = backgroundField.GetValue(null); GameObject val = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val == (Object)null) { return; } Component component = val.GetComponent(componentType); if ((Object)(object)component == (Object)null) { return; } if (list.Count == 3) { list.Add(MakeItem(component)); Announce(); return; } object item = GetItem1(list[3]); if (item != component && !((object)component).Equals(item)) { list[3] = MakeItem(component); Announce(); } } catch (Exception ex) { failed = true; Log.LogError((object)("Error en el puente, se desactiva: " + ex)); } } private static object MakeItem(Component background) { return Activator.CreateInstance(itemType, background, null); } private static object GetItem1(object tuple) { if (tuple == null) { return null; } Type type = tuple.GetType(); FieldInfo field = type.GetField("Item1"); if (field != null) { return field.GetValue(tuple); } PropertyInfo property = type.GetProperty("Item1"); return (property != null) ? property.GetValue(tuple, null) : null; } private static void Announce() { if (!announced) { announced = true; Log.LogInfo((object)"Fondo del cuarto slot enlazado a ZenUI."); } } } }