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 WeaponizedCARTValueScreenFix v0.1.0
WeaponizedCARTValueScreenFix.dll
Decompiled 10 hours agousing 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 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("WeaponizedCARTValueScreenFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("WeaponizedCARTValueScreenFix")] [assembly: AssemblyTitle("WeaponizedCARTValueScreenFix")] [assembly: AssemblyVersion("0.1.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 WeaponizedCARTValueScreenFix { [HarmonyPatch(typeof(PhysGrabCart), "Start")] [HarmonyPriority(0)] internal static class PhysGrabCartStartPatch { private const string WeaponizedCartNamePrefix = "Item Cart Weaponized"; private static void Postfix(PhysGrabCart __instance) { try { RepairValueScreen(__instance); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to repair a Weaponized C.A.R.T. value screen without changing the cart: {arg}"); } } private static void RepairValueScreen(PhysGrabCart cart) { if ((Object)(object)cart == (Object)null || (Object)(object)cart.valueScreen != (Object)null) { return; } GameObject gameObject = ((Component)cart).gameObject; if ((Object)(object)gameObject == (Object)null || !((Object)gameObject).name.StartsWith("Item Cart Weaponized", StringComparison.Ordinal)) { return; } ValueScreen componentInChildren = ((Component)cart).GetComponentInChildren<ValueScreen>(true); if ((Object)(object)componentInChildren != (Object)null) { cart.valueScreen = componentInChildren; ConfigureExistingValueScreen(componentInChildren, gameObject); Plugin.Log.LogInfo((object)("Assigned the existing ValueScreen on '" + ((Object)gameObject).name + "'. No component was added.")); return; } Transform val = gameObject.transform.Find("Screen"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Could not repair '" + ((Object)gameObject).name + "': the expected direct child 'Screen' was not found.")); return; } TextMeshPro val2 = FindDirectDisplayText(val); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)("Could not repair '" + ((Object)gameObject).name + "': the expected Screen/Text TextMeshPro was not found.")); return; } ValueScreen val3 = ((Component)val).gameObject.AddComponent<ValueScreen>(); val3.displayText = val2; EnsureSafeSoundSlots(val3); cart.valueScreen = val3; Plugin.Log.LogInfo((object)("Attached the missing ValueScreen to '" + ((Object)gameObject).name + "/Screen' and bound its existing TextMeshPro display.")); } private static void ConfigureExistingValueScreen(ValueScreen valueScreen, GameObject cartRoot) { if ((Object)(object)valueScreen.displayText == (Object)null) { valueScreen.displayText = FindDirectDisplayText(((Component)valueScreen).transform); } EnsureSafeSoundSlots(valueScreen); if ((Object)(object)valueScreen.displayText == (Object)null) { Plugin.Log.LogWarning((object)("The existing ValueScreen on '" + ((Object)cartRoot).name + "' has no direct TextMeshPro display reference.")); } } private static TextMeshPro FindDirectDisplayText(Transform screenTransform) { Transform obj = screenTransform.Find("Text"); if (obj == null) { return null; } return ((Component)obj).GetComponent<TextMeshPro>(); } private static void EnsureSafeSoundSlots(ValueScreen valueScreen) { if (valueScreen.soundValueIncrease == null) { valueScreen.soundValueIncrease = CreateSilentSound(); } if (valueScreen.soundValueDecrease == null) { valueScreen.soundValueDecrease = CreateSilentSound(); } } private static Sound CreateSilentSound() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return new Sound { Sounds = Array.Empty<AudioClip>() }; } } [BepInPlugin("mathe.weaponizedcartvaluescreenfix", "WeaponizedCART Value Screen Fix", "0.1.0")] [BepInProcess("REPO.exe")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "mathe.weaponizedcartvaluescreenfix"; public const string PluginName = "WeaponizedCART Value Screen Fix"; public const string PluginVersion = "0.1.0"; private Harmony _harmony; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("mathe.weaponizedcartvaluescreenfix"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"WeaponizedCART Value Screen Fix 0.1.0 loaded. Waiting for Weaponized C.A.R.T. instances."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } }