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 Shrinker Drone v1.0.4
Shrinker Drone Mod.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; 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: AssemblyCompany("Shrinker Drone Mod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Shrinker Drone Mod")] [assembly: AssemblyTitle("Shrinker Drone Mod")] [assembly: AssemblyVersion("1.0.0.0")] 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; } } } public class ItemDroneShrink : MonoBehaviourPunCallbacks { [CompilerGenerated] private sealed class <ApplyIndestructibleOnRelease>d__25 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PhysGrabObject target; public float duration; public ItemDroneShrink <>4__this; private float <validDuration>5__1; private float <elapsed>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ApplyIndestructibleOnRelease>d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <validDuration>5__1 = Mathf.Max(0.1f, duration); <elapsed>5__2 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__2 < <validDuration>5__1 && (Object)(object)target != (Object)null) { target.OverrideIndestructible(0.1f); <elapsed>5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } return false; } 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 <EnlargeAnimation>d__24 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PhysGrabObject target; public Vector3 targetScale; public ItemDroneShrink <>4__this; private float <duration>5__1; private Vector3 <startScale>5__2; private float <elapsed>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <EnlargeAnimation>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.isEnlarging = true; <duration>5__1 = 1f / Mathf.Max(0.1f, <>4__this.shrinkSpeed); <startScale>5__2 = ((Component)target).transform.localScale; <elapsed>5__3 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__3 < <duration>5__1 && (Object)(object)target != (Object)null) { <elapsed>5__3 += Time.deltaTime; ((Component)target).transform.localScale = Vector3.Lerp(<startScale>5__2, targetScale, <elapsed>5__3 / <duration>5__1); <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)target != (Object)null) { ((Component)target).transform.localScale = targetScale; } <>4__this.isEnlarging = false; return false; } 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 <ShrinkAnimation>d__23 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PhysGrabObject target; public Vector3 targetScale; public ItemDroneShrink <>4__this; private float <duration>5__1; private Vector3 <startScale>5__2; private float <elapsed>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShrinkAnimation>d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.isShrinking = true; <duration>5__1 = 1f / Mathf.Max(0.1f, <>4__this.shrinkSpeed); <startScale>5__2 = ((Component)target).transform.localScale; <elapsed>5__3 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__3 < <duration>5__1 && (Object)(object)target != (Object)null) { <elapsed>5__3 += Time.deltaTime; ((Component)target).transform.localScale = Vector3.Lerp(<startScale>5__2, targetScale, <elapsed>5__3 / <duration>5__1); <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)target != (Object)null) { ((Component)target).transform.localScale = targetScale; } <>4__this.isShrinking = false; return false; } 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 ItemDrone itemDrone; private PhysGrabObject myPhysGrabObject; private ItemEquippable itemEquippable; private ItemBattery itemBattery; public float batteryDrainRate = 1f; public float shrinkMultiplier = 0.5f; public float shrinkSpeed = 2f; public bool enableIndestructible = true; public float indestructibleDuration = 3f; public float indestructibleOnReleaseDuration = 5f; private PhysGrabObject currentTarget; private Vector3 originalScale; private bool isShrinking = false; private bool isEnlarging = false; private bool wasActivated = false; private float indestructibleTimer = 0f; private static Dictionary<int, List<int>> targetOwners = new Dictionary<int, List<int>>(); private void Start() { itemDrone = ((Component)this).GetComponent<ItemDrone>(); myPhysGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); itemEquippable = ((Component)this).GetComponent<ItemEquippable>(); itemBattery = ((Component)this).GetComponent<ItemBattery>(); if (SemiFunc.IsMultiplayer() && PhotonNetwork.IsMasterClient) { SyncConfigToClients(); } } private void Update() { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown bool flag = SemiFunc.IsMultiplayer(); if (flag && !((MonoBehaviourPun)this).photonView.IsMine) { return; } bool flag2 = (bool)AccessTools.Field(typeof(ItemDrone), "itemActivated").GetValue(itemDrone); bool flag3 = !(bool)AccessTools.Field(typeof(ItemEquippable), "isEquipped").GetValue(itemEquippable) && (GameManager.instance.gameMode != 1 || !flag || PhotonNetwork.IsMasterClient) && flag2; if (flag3) { myPhysGrabObject.OverrideZeroGravity(0.1f); myPhysGrabObject.OverrideDrag(1f, 0.1f); myPhysGrabObject.OverrideAngularDrag(10f, 0.1f); bool flag4 = (bool)AccessTools.Field(typeof(ItemDrone), "magnetActive").GetValue(itemDrone); PhysGrabObject val = (PhysGrabObject)AccessTools.Field(typeof(ItemDrone), "magnetTargetPhysGrabObject").GetValue(itemDrone); if (flag4 && (Object)(object)val != (Object)null) { int num = (flag ? ((Component)val).GetComponent<PhotonView>().ViewID : ((Object)((Component)val).gameObject).GetInstanceID()); int num2 = (flag ? ((MonoBehaviourPun)this).photonView.ViewID : ((Object)((Component)this).gameObject).GetInstanceID()); if ((Object)(object)val != (Object)(object)currentTarget && !isShrinking && !isEnlarging) { if (flag) { ((MonoBehaviourPun)this).photonView.RPC("RPC_StartShrink", (RpcTarget)3, new object[1] { num }); } else { HandleStartShrink(val, num); } } if (enableIndestructible && indestructibleTimer > 0f && (Object)(object)currentTarget != (Object)null) { currentTarget.OverrideIndestructible(0.1f); indestructibleTimer -= Time.deltaTime; } DrenarBateria(); } } if (!flag3 && wasActivated && (Object)(object)currentTarget != (Object)null) { int num3 = (flag ? ((Component)currentTarget).GetComponent<PhotonView>().ViewID : ((Object)((Component)currentTarget).gameObject).GetInstanceID()); if (flag) { ((MonoBehaviourPun)this).photonView.RPC("RPC_StopShrink", (RpcTarget)3, new object[1] { num3 }); } else { HandleStopShrink(num3); } } wasActivated = flag3; } private void HandleStartShrink(PhysGrabObject target, int targetID) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) int num = (SemiFunc.IsMultiplayer() ? ((MonoBehaviourPun)this).photonView.ViewID : ((Object)((Component)this).gameObject).GetInstanceID()); if (!targetOwners.ContainsKey(targetID)) { targetOwners[targetID] = new List<int>(); } if (!targetOwners[targetID].Contains(num)) { targetOwners[targetID].Add(num); } if (targetOwners[targetID][0] == num) { currentTarget = target; originalScale = ((Component)target).transform.localScale; float num2 = 1f - Mathf.Clamp(shrinkMultiplier, 0f, 0.99f); ((MonoBehaviour)this).StartCoroutine(ShrinkAnimation(target, originalScale * num2)); if (enableIndestructible) { indestructibleTimer = Mathf.Max(0.1f, indestructibleDuration); } } } private void HandleStopShrink(int targetID) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) int item = (SemiFunc.IsMultiplayer() ? ((MonoBehaviourPun)this).photonView.ViewID : ((Object)((Component)this).gameObject).GetInstanceID()); if (targetOwners.ContainsKey(targetID)) { targetOwners[targetID].Remove(item); if (targetOwners[targetID].Count == 0) { if (isShrinking) { ((MonoBehaviour)this).StopAllCoroutines(); isShrinking = false; } ((MonoBehaviour)this).StartCoroutine(EnlargeAnimation(currentTarget, originalScale)); if (enableIndestructible) { ((MonoBehaviour)this).StartCoroutine(ApplyIndestructibleOnRelease(currentTarget, indestructibleOnReleaseDuration)); } targetOwners.Remove(targetID); } } currentTarget = null; } [PunRPC] private void RPC_StartShrink(int targetID) { PhotonView val = PhotonView.Find(targetID); if (Object.op_Implicit((Object)(object)val)) { HandleStartShrink(((Component)val).GetComponent<PhysGrabObject>(), targetID); } } [PunRPC] private void RPC_StopShrink(int targetID) { HandleStopShrink(targetID); } [IteratorStateMachine(typeof(<ShrinkAnimation>d__23))] private IEnumerator ShrinkAnimation(PhysGrabObject target, Vector3 targetScale) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShrinkAnimation>d__23(0) { <>4__this = this, target = target, targetScale = targetScale }; } [IteratorStateMachine(typeof(<EnlargeAnimation>d__24))] private IEnumerator EnlargeAnimation(PhysGrabObject target, Vector3 targetScale) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <EnlargeAnimation>d__24(0) { <>4__this = this, target = target, targetScale = targetScale }; } [IteratorStateMachine(typeof(<ApplyIndestructibleOnRelease>d__25))] private IEnumerator ApplyIndestructibleOnRelease(PhysGrabObject target, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ApplyIndestructibleOnRelease>d__25(0) { <>4__this = this, target = target, duration = duration }; } private void DrenarBateria() { if (Object.op_Implicit((Object)(object)itemBattery) && itemBattery.batteryLife > 0f) { ItemBattery obj = itemBattery; obj.batteryLife -= Time.deltaTime * Mathf.Max(0.1f, batteryDrainRate); int num = (int)Mathf.Round(itemBattery.batteryLife / (100f / (float)itemBattery.batteryBars)); AccessTools.Field(typeof(ItemBattery), "batteryLifeInt").SetValue(itemBattery, num); if (itemBattery.batteryLife <= 0f) { AccessTools.Field(typeof(ItemDrone), "itemActivated").SetValue(itemDrone, false); } } } private void SyncConfigToClients() { ((MonoBehaviourPun)this).photonView.RPC("ReceiveConfigFromHost", (RpcTarget)4, new object[6] { batteryDrainRate, shrinkMultiplier, shrinkSpeed, enableIndestructible, indestructibleDuration, indestructibleOnReleaseDuration }); } [PunRPC] private void ReceiveConfigFromHost(float _b, float _m, float _s, bool _e, float _d, float _r) { batteryDrainRate = _b; shrinkMultiplier = _m; shrinkSpeed = _s; enableIndestructible = _e; indestructibleDuration = _d; indestructibleOnReleaseDuration = _r; } } [BepInPlugin("com.Skript.droneshrink", "Shrinker Drone Mod", "1.0.0")] [BepInProcess("REPO.exe")] public class DroneShrinkPlugin : BaseUnityPlugin { public static ConfigEntry<float> BatteryDrainRate; public static ConfigEntry<float> ShrinkMultiplier; public static ConfigEntry<float> ShrinkSpeed; public static ConfigEntry<bool> EnableIndestructible; public static ConfigEntry<float> IndestructibleDuration; public static ConfigEntry<float> IndestructibleOnReleaseDuration; private void Awake() { //IL_00da: Unknown result type (might be due to invalid IL or missing references) BatteryDrainRate = ((BaseUnityPlugin)this).Config.Bind<float>("Battery", "BatteryDrainRate", 1f, "Tasa de drenaje de batería cuando se achica un objeto."); ShrinkMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Shrink", "ShrinkMultiplier", 0.5f, "Multiplicador para achicar (ej: 0.5 para mitad de tamaño)."); ShrinkSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Shrink", "ShrinkSpeed", 2f, "Velocidad de la animación de encogimiento (mayor = más rápido)."); EnableIndestructible = ((BaseUnityPlugin)this).Config.Bind<bool>("Indestructible", "EnableIndestructible", true, "Activar/desactivar invencibilidad en objetos."); IndestructibleDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Indestructible", "IndestructibleDuration", 3f, "Duración de invencibilidad mientras el drone agarra el objeto (segundos)."); IndestructibleOnReleaseDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Indestructible", "IndestructibleOnReleaseDuration", 5f, "Duración de invencibilidad al soltar el objeto (segundos)."); new Harmony("com.Skript.ShrinkDroneMod").PatchAll(); } } [HarmonyPatch(typeof(ItemDrone), "Start")] internal class ItemDroneStartPatch { private static void Postfix(ItemDrone __instance) { if (((Object)((Component)__instance).gameObject).name.Contains("Item Drone Shrinker")) { ItemDroneShrink itemDroneShrink = ((Component)__instance).gameObject.GetComponent<ItemDroneShrink>(); if ((Object)(object)itemDroneShrink == (Object)null) { itemDroneShrink = ((Component)__instance).gameObject.AddComponent<ItemDroneShrink>(); } itemDroneShrink.batteryDrainRate = DroneShrinkPlugin.BatteryDrainRate.Value; itemDroneShrink.shrinkMultiplier = DroneShrinkPlugin.ShrinkMultiplier.Value; itemDroneShrink.shrinkSpeed = DroneShrinkPlugin.ShrinkSpeed.Value; itemDroneShrink.enableIndestructible = DroneShrinkPlugin.EnableIndestructible.Value; itemDroneShrink.indestructibleDuration = DroneShrinkPlugin.IndestructibleDuration.Value; itemDroneShrink.indestructibleOnReleaseDuration = DroneShrinkPlugin.IndestructibleOnReleaseDuration.Value; } } }