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 ShrinkerUpgrade v0.0.3
ShrinkerUpgrade.dll
Decompiled 9 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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.Configuration; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Konoe")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShrinkerUpgrade")] [assembly: AssemblyTitle("ShrinkerUpgrade")] [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; } } } [BepInPlugin("konoe.shrinker_upgrade", "Shrinker Upgrade", "0.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ShrinkerHandler : BaseUnityPlugin { [HarmonyPatch(typeof(PhysGrabCart), "ObjectsInCart")] public class AwakePatch { public static void Postfix(PhysGrabCart __instance) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)__instance)) { return; } PhysGrabCart component = ((Component)__instance).GetComponent<PhysGrabCart>(); if (!Object.op_Implicit((Object)(object)component)) { return; } Vector3 val = default(Vector3); List<PhysGrabObject> value; foreach (PhysGrabObject item in component.itemsInCart) { if ((Object)(object)item.rb == (Object)null || (Object)(object)((Component)item.rb).transform == (Object)null || item.isNonValuable) { continue; } float num = configMinShrinkScale?.Value ?? 0f; if (((Component)item.rb).transform.localScale.y <= num) { continue; } float num2 = configSmallestSide?.Value ?? 2f; ((Vector3)(ref val))..ctor(item.itemWidthX * 10f, item.itemHeightY * 10f, item.itemLengthZ * 10f); val = Vector3.Scale(val, ((Component)item.rb).transform.localScale); if (val.x <= num2 || val.y <= num2 || val.z <= num2) { continue; } float num3 = configTargetVolume?.Value ?? 10f; if (val.x * val.y * val.z <= num3) { continue; } float num4 = new float[3] { 0.01f / item.itemWidthX, 0.01f / item.itemHeightY, 0.01f / item.itemLengthZ }.Min() * (configShrinkSpeed?.Value ?? 1f); Transform transform = ((Component)item.rb).transform; transform.localScale -= new Vector3(num4, num4, num4); if (shrunkItems.TryGetValue(__instance, out value)) { if (!value.Contains(item)) { value?.Add(item); } } else { shrunkItems[__instance] = new List<PhysGrabObject> { item }; } } ConfigEntry<bool>? configDoGrowBack = ShrinkerHandler.configDoGrowBack; if ((configDoGrowBack != null && !configDoGrowBack.Value) || !shrunkItems.TryGetValue(__instance, out value)) { return; } foreach (PhysGrabObject item2 in value.ToList()) { if ((Object)(object)item2.rb == (Object)null || (Object)(object)((Component)item2.rb).transform == (Object)null) { value.Remove(item2); } else if (!component.itemsInCart.Contains(item2)) { float num5 = new float[3] { 0.0075f / item2.itemWidthX, 0.0075f / item2.itemHeightY, 0.0075f / item2.itemLengthZ }.Min() * (configShrinkSpeed?.Value ?? 1f); Transform transform2 = ((Component)item2.rb).transform; transform2.localScale += new Vector3(num5, num5, num5); if (((Component)item2.rb).transform.localScale.x >= 1f || ((Component)item2.rb).transform.localScale.y >= 1f || ((Component)item2.rb).transform.localScale.z >= 1f) { ((Component)item2.rb).transform.localScale = new Vector3(1f, 1f, 1f); value.Remove(item2); } } } } } private static ConfigEntry<float>? configTargetVolume; private static ConfigEntry<float>? configSmallestSide; private static ConfigEntry<float>? configMinShrinkScale; private static ConfigEntry<bool>? configDoGrowBack; private static ConfigEntry<float>? configShrinkSpeed; private static readonly Dictionary<PhysGrabCart, List<PhysGrabObject>> shrunkItems = new Dictionary<PhysGrabCart, List<PhysGrabObject>>(); private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown configTargetVolume = ((BaseUnityPlugin)this).Config.Bind<float>("ShrinkerUpgrade", "TargetVolume", 10f, new ConfigDescription("The Target Volume of an object to have when the upgrade level is 10.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>())); configSmallestSide = ((BaseUnityPlugin)this).Config.Bind<float>("ShrinkerUpgrade", "SmallestSide", 1f, new ConfigDescription("The Smallest Length of an object allowed to have.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>())); configMinShrinkScale = ((BaseUnityPlugin)this).Config.Bind<float>("ShrinkerUpgrade", "MinShrinkScale", 0f, new ConfigDescription("The Minimum Scale of an object allowed to be shrunk.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); configDoGrowBack = ((BaseUnityPlugin)this).Config.Bind<bool>("ShrinkerUpgrade", "DoGrowBack", true, "Whether a shrunk object will trun back to the original size outside a cart."); configShrinkSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("ShrinkerUpgrade", "ShrinkSpeed", 1f, new ConfigDescription("The Speed that items Shrink (or Grow).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); Harmony val = new Harmony("konoe.shrinker_upgrade"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shrinker Upgrade is awoken."); } }