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 BlackBox Fixer v2.1.0
BepInEx\plugins\Omniscye-BlackBox_Fixer\EmpressBlackboxFixer.dll
Decompiled a month agousing System; 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 BepInEx; using BepInEx.Logging; using Blackbox; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib.Modules; using TMPro; using UnityEngine; [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("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.4.0.0")] [assembly: AssemblyInformationalVersion("1.4.0")] [assembly: AssemblyProduct("EmpressBlackboxFixer")] [assembly: AssemblyTitle("EmpressBlackboxFixer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.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.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] [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] [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 EmpressBlackboxFixer { public static class Patches { public static bool AddComponent_Prefix(GameObject __instance, Type componentType, ref Component __result) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown if (((Object)__instance).name == "Blackbox_Quarantine") { return true; } if (componentType == typeof(Blackbox)) { Plugin.Log.LogInfo((object)"Empress Blackbox Fixer: Blackbox plugin detected, redirecting initialization..."); try { GameObject val = new GameObject("Blackbox_Quarantine"); val.SetActive(false); Object.DontDestroyOnLoad((Object)val); Component val2 = val.AddComponent(componentType); InitializeBlackbox((BaseUnityPlugin?)(object)((val2 is BaseUnityPlugin) ? val2 : null)); __result = val2; return false; } catch (Exception ex) { Plugin.Log.LogError((object)("Empress Blackbox Fixer: Redirect failed: " + ex.Message)); return true; } } return true; } private static void InitializeBlackbox(BaseUnityPlugin? plugin) { if ((Object)(object)plugin == (Object)null) { return; } try { Traverse val = Traverse.Create((object)plugin); val.Property("Instance", (object[])null).SetValue((object)plugin); ((Component)plugin).gameObject.transform.parent = null; ((Object)((Component)plugin).gameObject).hideFlags = (HideFlags)61; string text = Path.Combine(Path.GetDirectoryName(typeof(Blackbox).Assembly.Location), "mydamagecanvasbundle"); if (File.Exists(text)) { AssetBundle val2 = null; foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (((Object)allLoadedAssetBundle).name == "mydamagecanvasbundle") { val2 = allLoadedAssetBundle; } } if ((Object)(object)val2 == (Object)null) { val2 = AssetBundle.LoadFromFile(text); } if ((Object)(object)val2 != (Object)null) { GameObject val3 = val2.LoadAsset<GameObject>("DamageCanvasMultiplayerShop"); GameObject val4 = val2.LoadAsset<GameObject>("DamageCanvasMultiplayer"); if ((Object)(object)val3 != (Object)null) { NetworkPrefabs.RegisterNetworkPrefab(val3); } if ((Object)(object)val4 != (Object)null) { NetworkPrefabs.RegisterNetworkPrefab(val4); } val.Field("itemDmgMonitorShop").SetValue((object)val3); val.Field("itemDmgMonitorLevel").SetValue((object)val4); } } else { Plugin.Log.LogError((object)("Empress Blackbox Fixer: AssetBundle not found at: " + text)); } val.Method("Patch", Array.Empty<object>()).GetValue(); Plugin.Log.LogInfo((object)"Empress Blackbox Fixer: Blackbox manually initialized."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Empress Blackbox Fixer: Manual initialization failed: {arg}"); } } public static bool SafeSetText(MonoBehaviour __instance, string text) { if ((Object)(object)__instance == (Object)null) { return false; } TextMeshProUGUI componentInChildren = ((Component)__instance).GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)componentInChildren).text = text; } return false; } public static bool Patch_Prefix(Blackbox __instance) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown Plugin.Log.LogInfo((object)"Empress Blackbox Fixer: Intercepting Blackbox.Patch() to apply corrected patches..."); try { Traverse.Create(typeof(Blackbox)).Type("BlackBoxConfig").Method("Initialize", new object[1] { ((BaseUnityPlugin)__instance).Config }) .GetValue(); Traverse val = Traverse.Create((object)__instance); object value = val.Property("Harmony", (object[])null).GetValue(); Harmony val2 = (Harmony)((value is Harmony) ? value : null); if (val2 == null) { val2 = new Harmony(((BaseUnityPlugin)__instance).Info.Metadata.GUID); val.Property("Harmony", (object[])null).SetValue((object)val2); } val2.PatchAll(AccessTools.TypeByName("Blackbox.PhysGrabObjectImpactDetectorPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.PhysGrabObjectPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.ValuableObjectPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.TruckScreenTextPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.ShopManagerPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.HaulUIPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.PlayerHealthPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.HurtColliderPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.EnemyBangPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.EnemyUpscreamAnimPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.FloaterAttackLogicPatch")); val2.PatchAll(AccessTools.TypeByName("Blackbox.LevelGeneratorPatch")); val2.PatchAll(typeof(ReplacedRunManagerPatch)); val2.PatchAll(typeof(ReplacedSemiFuncPatch)); Plugin.Log.LogInfo((object)"Empress Blackbox Fixer: Corrected patches applied successfully."); } catch (Exception arg) { Plugin.Log.LogError((object)$"Empress Blackbox Fixer: Patch interception failed: {arg}"); } return false; } public static void TriggerRunLevelComplete() { try { object value = Traverse.Create(typeof(Blackbox)).Property("Instance", (object[])null).GetValue(); if (value != null) { object value2 = Traverse.Create(value).Field("valueEventTracker").GetValue(); if (value2 != null) { Traverse.Create(value2).Method("runLevelComplete", Array.Empty<object>()).GetValue(); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Empress Blackbox Fixer: Failed to trigger runLevelComplete: {arg}"); } } public static void TriggerResetRunStats() { try { object value = Traverse.Create(typeof(Blackbox)).Property("Instance", (object[])null).GetValue(); if (value != null) { object value2 = Traverse.Create(value).Field("valueEventTracker").GetValue(); if (value2 != null) { Traverse.Create(value2).Method("resetRunStats", Array.Empty<object>()).GetValue(); } Traverse.Create(value).Field("updateShopMonitorFlag").SetValue((object)false); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Empress Blackbox Fixer: Failed to trigger resetRunStats: {arg}"); } } } [HarmonyPatch(typeof(RunManager), "UpdateLevel")] public static class ReplacedRunManagerPatch { public static void Postfix(RunManager __instance) { if (SemiFunc.IsLevelShop(__instance.levelCurrent)) { Patches.TriggerRunLevelComplete(); return; } foreach (Level level in __instance.levels) { if (((Object)level).name == ((Object)__instance.levelCurrent).name) { Patches.TriggerResetRunStats(); break; } } } } [HarmonyPatch(typeof(SemiFunc), "StatSetSaveLevel")] public static class ReplacedSemiFuncPatch { public static void Prefix(int value) { if ((Object)(object)RunManager.instance == (Object)null) { return; } if (SemiFunc.IsLevelShop(RunManager.instance.levelCurrent)) { Patches.TriggerRunLevelComplete(); return; } foreach (Level level in RunManager.instance.levels) { if (((Object)level).name == ((Object)RunManager.instance.levelCurrent).name) { Patches.TriggerResetRunStats(); break; } } } } [BepInPlugin("com.empress.blackboxfixer", "Empress Blackbox Fixer", "1.4.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; public static Harmony HarmonyInstance; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; HarmonyInstance = new Harmony("com.empress.blackboxfixer"); Log.LogInfo((object)"Empress Blackbox Fixer: Initializing..."); try { HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(GameObject), "AddComponent", new Type[1] { typeof(Type) }, (Type[])null), new HarmonyMethod(typeof(Patches), "AddComponent_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Type typeFromHandle = typeof(MonitorTest); HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeFromHandle, "setTextRPC", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "SafeSetText", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Empress Blackbox Fixer: MonitorTest.setTextRPC patched successfully."); Type typeFromHandle2 = typeof(Blackbox); HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeFromHandle2, "Patch", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "Patch_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Empress Blackbox Fixer: Blackbox.Patch patched successfully."); } catch (Exception ex) { Log.LogError((object)("Empress Blackbox Fixer: Failed to patch MonitorTest or Patch method: " + ex.Message)); } Log.LogInfo((object)"Empress Blackbox Fixer: Loaded successfully."); } } }