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 CustomCarts v1.1.0
CustomCarts.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib.Modules; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Snicki")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d0dd4b1aece772defc768b2c891832d297e44293")] [assembly: AssemblyProduct("CustomCarts")] [assembly: AssemblyTitle("CustomCarts")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 CustomCarts { public class CartItem { public PhysGrabObject physGrab; private PhysGrabCart physGrabCart; } public class CartManager { } [BepInPlugin("Snicki.CustomCarts", "CustomCarts", "1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CustomCarts : BaseUnityPlugin { public static Durability WeakDurability = ScriptableObject.CreateInstance<Durability>(); public bool IsLoaded = false; public Dictionary<PhysGrabCart, List<PhysGrabObject>> cartItems = new Dictionary<PhysGrabCart, List<PhysGrabObject>>(); internal static CustomCarts Instance { get; private set; } = null; internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } public static Durability InvincibleDurability { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "CustomCarts"); AssetBundle assetBundle = AssetBundle.LoadFromFile(text); LoadAssets(assetBundle); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); WeakDurability.durability = 0f; WeakDurability.fragility = 100f; IsLoaded = true; } private void LoadAssets(AssetBundle assetBundle) { Item val = assetBundle.LoadAsset<Item>("Item Cart Small Orbs"); val.prefab = assetBundle.LoadAsset<GameObject>("Item Cart Small Orbs"); Items.RegisterItem(val); Item val2 = assetBundle.LoadAsset<Item>("Item Cart Medium Orbs"); val2.prefab = assetBundle.LoadAsset<GameObject>("Item Cart Medium Orbs"); Items.RegisterItem(val2); InvincibleDurability = assetBundle.LoadAsset<Durability>("Durability Invincible"); Logger.LogDebug((object)("Item Name => " + ((Object)val).name)); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } [HarmonyPatch(typeof(PhysGrabCart))] public class PhysGrabCartPatch { [HarmonyPostfix] [HarmonyPatch("ObjectsInCart")] private static void ObjectsInCart(PhysGrabCart __instance, List<PhysGrabObject> ___itemsInCart) { if (CustomCarts.Instance.IsLoaded && ((Object)__instance).name.Contains("Orb")) { if (CustomCarts.Instance.cartItems.TryGetValue(__instance, out List<PhysGrabObject> _)) { CustomCarts.Instance.cartItems.Remove(__instance); } CustomCarts.Instance.cartItems.Add(__instance, ___itemsInCart); } } } [HarmonyPatch(typeof(PhysGrabObject))] internal class PhysGrabObjectPatch { [CompilerGenerated] private sealed class <ExpandItem>d__6 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private float <duration>5__1; private float <time>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ExpandItem>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <duration>5__1 = 0.5f; <time>5__2 = 0f; goto IL_00dc; case 1: <>1__state = -1; goto IL_00dc; case 2: { <>1__state = -1; return false; } IL_00dc: if (<time>5__2 < <duration>5__1) { <time>5__2 += Time.deltaTime; CustomCarts.Logger.LogDebug((object)<time>5__2); ((Component)instance).gameObject.transform.localScale = Vector3.Lerp(((Component)instance).gameObject.transform.localScale, new Vector3(1f, 1f, 1f), <time>5__2 / <duration>5__1); <>2__current = null; <>1__state = 1; return true; } <>2__current = null; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <ShrinkItem>d__5 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private float <duration>5__1; private float <time>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShrinkItem>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <duration>5__1 = 0.5f; <time>5__2 = 0f; goto IL_00dc; case 1: <>1__state = -1; goto IL_00dc; case 2: { <>1__state = -1; return false; } IL_00dc: if (<time>5__2 < <duration>5__1) { <time>5__2 += Time.deltaTime; CustomCarts.Logger.LogDebug((object)<time>5__2); ((Component)instance).gameObject.transform.localScale = Vector3.Lerp(((Component)instance).gameObject.transform.localScale, new Vector3(0.5f, 0.5f, 0.5f), <time>5__2 / <duration>5__1); <>2__current = null; <>1__state = 1; return true; } <>2__current = null; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static float transformSize = 1f; private static PhysGrabObject instance; private static Dictionary<PhysGrabObject, Coroutine> shrinkRoutines = new Dictionary<PhysGrabObject, Coroutine>(); private static Dictionary<PhysGrabObject, Coroutine> expandRoutines = new Dictionary<PhysGrabObject, Coroutine>(); [HarmonyPatch("Update")] [HarmonyPostfix] private static void Update(PhysGrabObject __instance, bool ___isValuable) { if (!CustomCarts.Instance.IsLoaded || !SemiFunc.RunIsLevel()) { return; } foreach (KeyValuePair<PhysGrabCart, List<PhysGrabObject>> cartItem in CustomCarts.Instance.cartItems) { if ((Object)(object)cartItem.Key == (Object)null || !((Object)cartItem.Key).name.Contains("Orb") || !((Object)__instance).name.Contains("Enemy Valuable")) { continue; } instance = __instance; if (cartItem.Value.Any((PhysGrabObject x) => (Object)(object)x == (Object)(object)__instance)) { if (!shrinkRoutines.Keys.Contains(__instance)) { if (expandRoutines.Keys.Contains(__instance)) { expandRoutines.Remove(__instance); } transformSize = 1f; shrinkRoutines.Add(__instance, ((MonoBehaviour)__instance).StartCoroutine(ShrinkItem())); ValuableObject component = ((Component)__instance).GetComponent<ValuableObject>(); component.durabilityPreset = CustomCarts.InvincibleDurability; } } else if (!expandRoutines.Keys.Contains(__instance)) { if (shrinkRoutines.Keys.Contains(__instance)) { ((MonoBehaviour)__instance).StopCoroutine(GeneralExtensions.GetValueSafe<PhysGrabObject, Coroutine>(shrinkRoutines, __instance)); shrinkRoutines.Remove(__instance); } expandRoutines.Add(__instance, ((MonoBehaviour)__instance).StartCoroutine(ExpandItem())); ValuableObject val = null; if (((Component)__instance).TryGetComponent<ValuableObject>(ref val)) { val.durabilityPreset = CustomCarts.WeakDurability; } } } } [IteratorStateMachine(typeof(<ShrinkItem>d__5))] private static IEnumerator ShrinkItem() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShrinkItem>d__5(0); } [IteratorStateMachine(typeof(<ExpandItem>d__6))] private static IEnumerator ExpandItem() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ExpandItem>d__6(0); } } }