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 ShrinkerGun v0.4.4
ShrinkerGun.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using ScalerCore; using ScalerCore.AprilFools; 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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Vippy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.4.0")] [assembly: AssemblyInformationalVersion("0.4.4+bf55062b08500b715da5365f6ea310dae29960b0")] [assembly: AssemblyProduct("ShrinkerGun")] [assembly: AssemblyTitle("ShrinkerGun")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.4.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 ShrinkerGun { internal static class BuildInfo { public const string Version = "0.4.4"; } public class ItemGunShrink : MonoBehaviour { private void Start() { MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).material.shader = Shader.Find("Fresnel Opaque"); } } } public class ItemGunShrinkBullet : MonoBehaviour { public static ScaleController? PendingSourceCtrl; private ScaleController? _sourceCtrl; private void Awake() { _sourceCtrl = PendingSourceCtrl; PendingSourceCtrl = null; } private void Start() { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogDebug((object)$"[SG] Bullet Start isMaster={SemiFunc.IsMasterClientOrSingleplayer()} instanceID={((Object)this).GetInstanceID()} GO={((Object)((Component)this).gameObject).name}"); if (SemiFunc.IsMasterClientOrSingleplayer()) { ItemGunBullet component = ((Component)this).GetComponent<ItemGunBullet>(); if ((Object)(object)component == (Object)null || !component.bulletHit) { Plugin.Log.LogDebug((object)$"[SG] Bullet SKIP bullet={(Object)(object)component != (Object)null} hit={component?.bulletHit}"); return; } Plugin.Log.LogDebug((object)$"[SG] Bullet HIT at {component.hitPosition}"); ShrinkAtPoint(component.hitPosition); } } private void ShrinkAtPoint(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()) + LayerMask.GetMask(new string[2] { "Enemy", "Player" }); Collider[] array = Physics.OverlapSphere(point, 0.3f, num, (QueryTriggerInteraction)2); Plugin.Log.LogDebug((object)$"[SG] OverlapSphere center={point} radius=0.3 hits={array.Length}"); int num2 = LayerMask.NameToLayer("Player"); Collider[] array2 = array; foreach (Collider val in array2) { ScaleController val2 = ((Component)val).GetComponent<PlayerShrinkLink>()?.Controller ?? ((Component)val).GetComponentInParent<ScaleController>(); if ((Object)(object)val2 == (Object)null && ((Component)val).gameObject.layer == num2) { val2 = FindNearestPlayerCtrl(((Component)val).transform.position); } Plugin.Log.LogDebug((object)$"[SG] collider={((Object)((Component)val).gameObject).name} layer={((Component)val).gameObject.layer} ctrl={(Object)(object)val2 != (Object)null} ctrlID={((val2 != null) ? new int?(((Object)val2).GetInstanceID()) : null)} IsScaled={((val2 != null) ? new bool?(val2.IsScaled) : null)}"); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)_sourceCtrl)) { Toggle(val2); return; } } Plugin.Log.LogDebug((object)"[SG] No target found"); } private static ScaleController? FindNearestPlayerCtrl(Vector3 pos) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (GameDirector.instance?.PlayerList == null) { return null; } ScaleController result = null; float num = 2f; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player == (Object)null || player.isDisabled) { continue; } ScaleController component = ((Component)player).GetComponent<ScaleController>(); if (!((Object)(object)component == (Object)null)) { PlayerAvatarCollision component2 = ((Component)player).GetComponent<PlayerAvatarCollision>(); float num2 = Vector3.Distance(((Object)(object)component2?.CollisionTransform != (Object)null) ? component2.CollisionTransform.position : ((Component)player).transform.position, pos); if (num2 < num) { num = num2; result = component; } } } return result; } private static void Toggle(ScaleController ctrl) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_0072: Unknown result type (might be due to invalid IL or missing references) Plugin.Log.LogDebug((object)$"[SG] Toggle ctrl={((Object)ctrl).GetInstanceID()} IsScaled={ctrl.IsScaled} currentScale={((Component)ctrl).transform.localScale}"); ScaleOptions shrinkOptions = Plugin.ShrinkOptions; if ((int)ctrl.TargetType == 2) { shrinkOptions.Duration = Plugin._enemyDuration; } else if ((int)ctrl.TargetType == 4) { shrinkOptions.Duration = Plugin._itemDuration; } ScaleManager.Apply(((Component)ctrl).gameObject, shrinkOptions); } } internal enum LevelCollapseMode { Auto, On, Off } [BepInPlugin("Vippy.ShrinkerGun", "ShrinkerGun", "0.4.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")] private class GunSourcePatch { private static void Prefix(ItemGun __instance) { ItemGunShrinkBullet.PendingSourceCtrl = ((Component)__instance).GetComponent<ScaleController>(); } } [HarmonyPatch(typeof(ItemGunBullet), "ActivateAll")] private class LevelCollapseHitPatch { private static void Postfix(ItemGunBullet __instance) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!LevelCollapseEnabled || !__instance.bulletHit) { return; } bool flag = false; MonoBehaviour[] components = ((Component)__instance).GetComponents<MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { if (((object)components[i]).GetType().Name == "ItemGunShrinkBullet") { flag = true; break; } } if (!flag) { return; } int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()) | LayerMask.GetMask(new string[2] { "Enemy", "Player" }); Collider[] array = Physics.OverlapSphere(__instance.hitPosition, 0.3f, num, (QueryTriggerInteraction)2); foreach (Collider val in array) { if ((Object)(object)((Component)val).GetComponent<PlayerShrinkLink>()?.Controller != (Object)null || (Object)(object)((Component)val).GetComponentInParent<ScaleController>() != (Object)null) { return; } } MapCollapse.OnMapHit(); } } internal static ManualLogSource Log = null; internal static ScaleOptions ShrinkOptions; internal static float _enemyDuration = 120f; internal static float _itemDuration = 0f; private static ConfigEntry<bool> _enableDebugKeys = null; private static ConfigEntry<bool> _challengeMode = null; private static ConfigEntry<LevelCollapseMode> _levelCollapse = null; internal static bool LevelCollapseEnabled { get { switch (_levelCollapse.Value) { case LevelCollapseMode.On: return true; case LevelCollapseMode.Off: return false; default: { DateTime now = DateTime.Now; return now.Month == 4 && now.Day == 1; } } } } private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ShrinkOptions = ScaleOptions.Default; _enableDebugKeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugKeys", false, "Enable F9/F10 keys to shrink/unshrink yourself. Off by default. Host controls this for all players."); ScaleController.AllowManualScale = _enableDebugKeys.Value; _enableDebugKeys.SettingChanged += delegate { ScaleController.AllowManualScale = _enableDebugKeys.Value; }; _challengeMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Challenge", "ShrinkChallengeMode", false, "All players start shrunken. Shrink guns temporarily grow you back to full size. Taking damage while full size shrinks you back down. Enemies behave normally."); ScaleController.ChallengeMode = _challengeMode.Value; _challengeMode.SettingChanged += delegate { ScaleController.ChallengeMode = _challengeMode.Value; if (SemiFunc.RunIsLobbyMenu()) { PlayerVoiceChat[] array = Object.FindObjectsOfType<PlayerVoiceChat>(); foreach (PlayerVoiceChat val in array) { if (_challengeMode.Value) { val.OverridePitch(1.3f, 0.2f, 0.5f, 9999f, 0f, 0f); } else { val.OverridePitchCancel(); } } } }; _levelCollapse = ((BaseUnityPlugin)this).Config.Bind<LevelCollapseMode>("Chaos", "LevelCollapse", LevelCollapseMode.Auto, "Shooting the map with the shrink gun triggers a 90-second collapse event. Auto = April 1st only. On = always. Off = never."); new Harmony("Vippy.ShrinkerGun").PatchAll(); } private void Update() { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { return; } ScaleController component = ((Component)instance).GetComponent<ScaleController>(); if ((Object)(object)component == (Object)null) { return; } if (Input.GetKeyDown((KeyCode)290)) { if (component.IsScaled) { component.RequestManualExpand(); } else { component.RequestManualShrink(); } } if (Input.GetKeyDown((KeyCode)279) && _levelCollapse.Value == LevelCollapseMode.On && (Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated && SemiFunc.IsMasterClientOrSingleplayer()) { MapCollapse.OnMapHit(); } } } }