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.7.2
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-CSharp")] [assembly: AssemblyCompany("Vippy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.7.2.0")] [assembly: AssemblyInformationalVersion("0.7.2+15e4c6fefb9227762f6c7afee04ee80acf7e839a")] [assembly: AssemblyProduct("ShrinkerGun")] [assembly: AssemblyTitle("ShrinkerGun")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.7.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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.7.2"; } internal enum LevelCollapseMode { Auto, On, Off } internal enum GunMode { Shrink, Grow } public enum BatteryCharge { Default, Rechargeable, SingleUse } internal static class PluginConfig { internal static ConfigEntry<int> BatteryShotsPerCharge; internal static ConfigEntry<BatteryCharge> BatteryRechargeable; internal static ConfigEntry<bool> EnableDebugKeys; internal static ConfigEntry<KeyCode> ShrinkKey; internal static ConfigEntry<KeyCode> CollapseKey; private static ConfigEntry<GunMode> _gunMode; private static ConfigEntry<bool> _challengeMode; private static ConfigEntry<bool> _shrinkDeadHeads; private static ConfigEntry<LevelCollapseMode> _levelCollapse; internal static ScaleOptions ShrinkOptions; 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; } } } } internal static void Init(ConfigFile config) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown BatteryShotsPerCharge = config.Bind<int>("Battery", "ShotsPerCharge", 0, new ConfigDescription("Requires a game restart to apply. The host's setting rules in multiplayer.\nHow many shots a full battery gives the shrink gun. The meter keeps its normal bars. 0 leaves the gun's built-in amount alone.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); BatteryRechargeable = config.Bind<BatteryCharge>("Battery", "Rechargeable", BatteryCharge.Default, "Requires a game restart to apply. The host's setting rules in multiplayer.\nWhether the shrink gun's battery can be recharged (truck charger, drones, orbs). Default leaves the built-in setting."); _gunMode = config.Bind<GunMode>("Gun", "Mode", GunMode.Shrink, "What the gun does to whatever it hits. Shrink (default) makes things small; Grow makes them big (twice size, heavier, with the matching audio and reach). The host's setting rules in multiplayer."); ApplyGunMode(); _gunMode.SettingChanged += delegate { ApplyGunMode(); }; EnableDebugKeys = config.Bind<bool>("Debug", "EnableDebugKeys", false, "Turn on the debug keys below. Off by default."); ScaleController.AllowManualScale = EnableDebugKeys.Value; EnableDebugKeys.SettingChanged += delegate { ScaleController.AllowManualScale = EnableDebugKeys.Value; }; ShrinkKey = config.Bind<KeyCode>("Debug", "ShrinkKey", (KeyCode)290, "Shrink or unshrink yourself."); CollapseKey = config.Bind<KeyCode>("Debug", "CollapseKey", (KeyCode)279, "Start the level collapse by hand. Host only, and only while LevelCollapse is active."); _challengeMode = 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 { ApplyChallengeMode(); }; _shrinkDeadHeads = config.Bind<bool>("Targets", "ShrinkDeadHeads", false, "Let the shrink ray hit dead Semibot heads. Off by default: a shrunk head is easy to lose and reviving from a pea is its own problem."); ScaleManager.AllowDeadHeads = _shrinkDeadHeads.Value; _shrinkDeadHeads.SettingChanged += delegate { ScaleManager.AllowDeadHeads = _shrinkDeadHeads.Value; }; _levelCollapse = 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."); } private static void ApplyGunMode() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) ShrinkOptions = ((_gunMode.Value == GunMode.Grow) ? ScaleOptions.Growth : ScaleOptions.Default); Plugin.Log.LogInfo((object)$"Gun mode: {_gunMode.Value}"); } private static void ApplyChallengeMode() { ScaleController.ChallengeMode = _challengeMode.Value; if (!SemiFunc.RunIsLobbyMenu()) { return; } 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(); } } } } public class ItemGunShrink : MonoBehaviour { private void Start() { Shader val = Shader.Find("Fresnel Opaque"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Fresnel Opaque shader missing, leaving the gun's materials as they shipped"); return; } MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).material.shader = val; } } } public class ItemGunShrinkBullet : MonoBehaviour { private const float EnemyDuration = 120f; private const float ItemDuration = 0f; public static ScaleController? PendingSourceCtrl; private ScaleController? _sourceCtrl; private void Awake() { _sourceCtrl = PendingSourceCtrl; PendingSourceCtrl = null; } private void Start() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { ItemGunBullet component = ((Component)this).GetComponent<ItemGunBullet>(); if (!((Object)(object)component == (Object)null) && component.bulletHit && !ShrinkAtPoint(component.hitPosition) && PluginConfig.LevelCollapseEnabled) { MapCollapse.OnMapHit(); } } } private bool 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_008d: 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); int num2 = LayerMask.NameToLayer("Player"); bool result = false; 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); } if (!((Object)(object)val2 == (Object)null)) { result = true; if (!((Object)(object)val2 == (Object)(object)_sourceCtrl)) { Toggle(val2); return true; } } } return result; } 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_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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) ScaleOptions shrinkOptions = PluginConfig.ShrinkOptions; if ((int)ctrl.TargetType == 2) { shrinkOptions.Duration = 120f; } else if ((int)ctrl.TargetType == 4) { shrinkOptions.Duration = 0f; } ScaleManager.Apply(((Component)ctrl).gameObject, shrinkOptions); } } [HarmonyPatch(typeof(ItemBattery), "Awake")] internal static class BatteryConfigPatch { private static void Postfix(ItemBattery __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)((Component)__instance).GetComponent<ItemGunShrink>() == (Object)null)) { switch (PluginConfig.BatteryRechargeable.Value) { case BatteryCharge.Rechargeable: __instance.isUnchargable = false; break; case BatteryCharge.SingleUse: __instance.isUnchargable = true; break; } } } } [HarmonyPatch(typeof(ItemGun), "Start")] internal static class GunBatteryDrainPatch { private static void Postfix(ItemGun __instance) { if (SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)((Component)__instance).GetComponent<ItemGunShrink>() == (Object)null) && !((Object)(object)__instance.itemBattery == (Object)null)) { int value = PluginConfig.BatteryShotsPerCharge.Value; if (value > 0) { __instance.batteryDrainFullBar = false; __instance.batteryDrain = BatteryMath.ShotDrain(value, __instance.itemBattery.batteryBars); } } } } [HarmonyPatch(typeof(ChargingStation), "UpdateItemsInRange")] internal static class ChargerSingleUsePatch { private static void Postfix(ChargingStation __instance) { if (PluginConfig.BatteryRechargeable.Value == BatteryCharge.SingleUse && SemiFunc.IsMasterClientOrSingleplayer()) { __instance.itemsCharging.RemoveAll((ItemBattery b) => b.isUnchargable && (Object)(object)((Component)b).GetComponent<ItemGunShrink>() != (Object)null); } } } [HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")] internal static class GunSourcePatch { private static void Prefix(ItemGun __instance) { ItemGunShrinkBullet.PendingSourceCtrl = (((Object)(object)((Component)__instance).GetComponent<ItemGunShrink>() == (Object)null) ? null : ((Component)__instance).GetComponent<ScaleController>()); } } internal static class BatteryMath { public static float ShotDrain(int uses, int bars) { if (uses < 1) { uses = 1; } if (bars < 1) { bars = 1; } float num = 100f / (2f * (float)bars); return (100f - num) / ((float)uses - 0.5f); } } internal class DebugKeys : MonoBehaviour { private void Update() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.EnableDebugKeys.Value) { if (Input.GetKeyDown(PluginConfig.ShrinkKey.Value)) { ToggleSelf(); } if (Input.GetKeyDown(PluginConfig.CollapseKey.Value) && PluginConfig.LevelCollapseEnabled) { Collapse(); } } } private static void ToggleSelf() { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { return; } ScaleController component = ((Component)instance).GetComponent<ScaleController>(); if (!((Object)(object)component == (Object)null)) { if (component.IsScaled) { component.RequestManualExpand(); } else { component.RequestManualShrink(); } } } private static void Collapse() { if (!((Object)(object)LevelGenerator.Instance == (Object)null) && LevelGenerator.Instance.Generated && SemiFunc.IsMasterClientOrSingleplayer()) { MapCollapse.OnMapHit(); } } } [BepInPlugin("Vippy.ShrinkerGun", "ShrinkerGun", "0.7.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; PluginConfig.Init(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.AddComponent<DebugKeys>(); new Harmony("Vippy.ShrinkerGun").PatchAll(); } } }