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 PocketCartPlusValueScreenFix v0.1.0
PocketCartPlusValueScreenFix.dll
Decompiled 8 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("PocketCartPlusValueScreenFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("PocketCartPlusValueScreenFix")] [assembly: AssemblyTitle("PocketCartPlusValueScreenFix")] [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 PocketCartPlusValueScreenFix { [HarmonyPatch(typeof(PhysGrabCart), "Start")] [HarmonyAfter(new string[] { "com.github.darmuh.PocketCartPlus" })] [HarmonyPriority(0)] internal static class PhysGrabCartStartPatch { private const string PocketCartPlusNamePrefix = "Item PCartPlus"; private static void Postfix(PhysGrabCart __instance) { try { RepairValueScreen(__instance); } catch (Exception arg) { Plugin.Log.LogError((object)$"Failed to repair a Pocket C.A.R.T. Plus 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 PCartPlus", StringComparison.Ordinal)) { return; } ValueScreen componentInChildren = ((Component)cart).GetComponentInChildren<ValueScreen>(true); if ((Object)(object)componentInChildren != (Object)null) { cart.valueScreen = componentInChildren; ConfigureValueScreen(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 = FindDisplayText(val); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogWarning((object)("Could not repair '" + ((Object)gameObject).name + "': the existing 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 ConfigureValueScreen(ValueScreen valueScreen, GameObject cartRoot) { if ((Object)(object)valueScreen.displayText == (Object)null) { valueScreen.displayText = FindDisplayText(((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 TextMeshPro display reference.")); } } private static TextMeshPro FindDisplayText(Transform screenTransform) { Transform obj = screenTransform.Find("Text"); TextMeshPro val = ((obj != null) ? ((Component)obj).GetComponent<TextMeshPro>() : null); if (!((Object)(object)val != (Object)null)) { return ((Component)screenTransform).GetComponentInChildren<TextMeshPro>(true); } return val; } 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.pocketcartplusvaluescreenfix", "PocketCartPlus Value Screen Fix", "0.1.0")] [BepInDependency("com.github.darmuh.PocketCartPlus", "0.5.6")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "mathe.pocketcartplusvaluescreenfix"; public const string PluginName = "PocketCartPlus Value Screen Fix"; public const string PluginVersion = "0.1.0"; public const string PocketCartPlusGuid = "com.github.darmuh.PocketCartPlus"; public const string PocketCartPlusMinimumVersion = "0.5.6"; 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.pocketcartplusvaluescreenfix"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PocketCartPlus Value Screen Fix 0.1.0 loaded. Waiting for Pocket C.A.R.T. Plus instances."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } }