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 JetpackWarning v2.3.0
plugins/JetpackWarning.dll
Decompiled a day agousing System; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("JetpackWarning")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.3.0.0")] [assembly: AssemblyInformationalVersion("2.3.0+4e614c782a33ebf7b495b0eb76371f853b09360f")] [assembly: AssemblyProduct("JetpackWarning")] [assembly: AssemblyTitle("JetpackWarning")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Hamunii/JetpackWarning")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace JetpackWarning { internal class Patches { private static bool playJetpackCritical = false; private static bool playingJetpackCritical = false; private static float criticalFill = 0.75f; [HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")] [HarmonyPostfix] private static void PlayerControllerB_LateUpdate_Postfix(ref PlayerControllerB __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)__instance).IsOwner) { return; } if (__instance.isPlayerDead) { JetpackWarningPlugin.meterContainer.SetActive(false); return; } if (__instance.isHoldingObject) { GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer; JetpackItem val = (JetpackItem)(object)((currentlyHeldObjectServer is JetpackItem) ? currentlyHeldObjectServer : null); if (val != null) { JetpackWarningPlugin.meterContainer.SetActive(true); Vector3 forces = val.forces; float jetpackPower = val.jetpackPower; float num = ((!(jetpackPower < 80f)) ? (0.5f - Mathf.Clamp(jetpackPower / 20f - 4f, 0f, 1f) / 2f) : (Mathf.Clamp(jetpackPower / 25f - 2.2f, 0f, 1f) / 2f)); if (((Vector3)(ref forces)).magnitude > 47f) { num = Mathf.Clamp(((Vector3)(ref forces)).magnitude / 3f - 15.6666f, 0f, 1f); } float num2 = ((((Vector3)(ref forces)).magnitude >= 0f) ? (((Vector3)(ref forces)).magnitude / 50f) : 0f); float num3 = ((((Vector3)(ref forces)).magnitude / 2f + jetpackPower / 2.25f >= 0f) ? ((((Vector3)(ref forces)).magnitude / 2f + jetpackPower / 2.25f) / 50f) : 0f); float num4 = Mathf.Lerp(num3, num2, num); JetpackWarningPlugin.meterImage.fillAmount = num4; JetpackWarningPlugin.warning.SetActive(num4 > criticalFill); playJetpackCritical = num4 > criticalFill; Color color = Color.Lerp(new Color(1f, 0.82f, 0.405f, 1f), new Color(0.769f, 0.243f, 0.243f, 1f), num4); ((Graphic)JetpackWarningPlugin.meterImage).color = color; ((Graphic)JetpackWarningPlugin.frameImage).color = color; ((Graphic)JetpackWarningPlugin.warningImage).color = color; if (playJetpackCritical) { if (!playingJetpackCritical) { playingJetpackCritical = true; val.jetpackBeepsAudio.clip = JetpackWarningPlugin.jetpackCriticalBeep; val.jetpackBeepsAudio.Play(); } } else { playingJetpackCritical = false; } return; } } JetpackWarningPlugin.meterContainer.SetActive(false); } [HarmonyPatch(typeof(JetpackItem), "SetJetpackAudios")] [HarmonyPrefix] private static bool JetpackItem_SetJetpackAudios_Prefix() { return !playingJetpackCritical; } [HarmonyPatch(typeof(JetpackItem), "JetpackEffect")] [HarmonyPostfix] private static void JetpackItem_JetpackEffect_Postfix(ref bool __0, JetpackItem __instance) { if (__0 && playJetpackCritical) { playingJetpackCritical = true; __instance.jetpackBeepsAudio.clip = JetpackWarningPlugin.jetpackCriticalBeep; __instance.jetpackBeepsAudio.Play(); } } } [BepInPlugin("JetpackWarning", "JetpackWarning", "2.3.0")] public class JetpackWarningPlugin : BaseUnityPlugin { internal static Harmony _harmony; internal static AudioClip jetpackCriticalBeep; private static AssetBundle MainAssetBundle; internal static GameObject meterContainer; internal static GameObject meter; internal static GameObject frame; internal static GameObject warning; internal static Image meterImage; internal static Image frameImage; internal static Image warningImage; public const string Id = "JetpackWarning"; internal static ManualLogSource Log { get; private set; } public static string Name => "JetpackWarning"; public static string Version => "2.3.0"; private void Awake() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin JetpackWarning is loaded!"); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "jetpackAssets"); MainAssetBundle = AssetBundle.LoadFromFile(text); _harmony = new Harmony("JetpackWarning"); _harmony.PatchAll(typeof(Patches)); SceneManager.sceneLoaded += OnSceneRelayLoaded; jetpackCriticalBeep = MainAssetBundle.LoadAsset<AudioClip>("JetpackCriticalBeep") ?? throw new InvalidOperationException("Asset 'JetpackCriticalBeep' not found"); } private void OnSceneRelayLoaded(Scene scene, LoadSceneMode loadMode) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00a3: 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) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) if (((Scene)(ref scene)).name != "SampleSceneRelay") { return; } try { GameObject val = GameObject.Find("IngamePlayerHUD"); meterContainer = new GameObject("jetpackMeterContainer"); meterContainer.AddComponent<CanvasGroup>(); RectTransform val2 = meterContainer.AddComponent<RectTransform>(); ((Transform)val2).parent = val.transform; ((Transform)val2).localScale = Vector3.one; val2.anchoredPosition = Vector2.zero; ((Transform)val2).localPosition = Vector2.op_Implicit(new Vector2(50f, 0f)); val2.sizeDelta = Vector2.one; meter = AddImageToHUD("jetpackMeter", scene); frame = AddImageToHUD("jetpackMeterFrame", scene); warning = AddImageToHUD("jetpackMeterWarning", scene); meterImage = meter.GetComponent<Image>(); frameImage = frame.GetComponent<Image>(); warningImage = warning.GetComponent<Image>(); GameObject[] array = (GameObject[])(object)new GameObject[3] { meter, frame, warning }; GameObject[] array2 = array; foreach (GameObject val3 in array2) { val3.transform.parent = meterContainer.transform; val3.transform.localPosition = Vector2.op_Implicit(Vector2.zero); } meter.GetComponent<Image>().type = (Type)3; meter.GetComponent<Image>().fillMethod = (FillMethod)1; Transform transform = warning.transform; transform.localPosition += new Vector3(30f, 0f); meterContainer.SetActive(false); } catch (Exception ex) { Log.LogError((object)("Failed to initialize: " + ex)); SceneManager.sceneLoaded -= OnSceneRelayLoaded; _harmony.UnpatchSelf(); } } private GameObject AddImageToHUD(string imageName, Scene scene) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) Sprite val = MainAssetBundle.LoadAsset<Sprite>(imageName) ?? throw new InvalidOperationException("Asset '" + imageName + "' not found"); GameObject val2 = new GameObject(imageName); SceneManager.MoveGameObjectToScene(val2, scene); GameObject val3 = GameObject.Find("IngamePlayerHUD") ?? throw new InvalidOperationException("GameObject 'IngamePlayerHUD' not found"); RectTransform val4 = val2.AddComponent<RectTransform>(); ((Transform)val4).parent = val3.transform; ((Transform)val4).localScale = Vector2.op_Implicit(Vector2.one); val4.anchoredPosition = Vector2.zero; ((Transform)val4).localPosition = Vector2.op_Implicit(Vector2.zero); Rect rect = val.rect; float num = ((Rect)(ref rect)).width / 2f; rect = val.rect; val4.sizeDelta = new Vector2(num, ((Rect)(ref rect)).height / 2f); Image val5 = val2.AddComponent<Image>(); val5.sprite = val; CanvasRenderer val6 = val2.AddComponent<CanvasRenderer>(); return val2; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ConstantExpectedAttribute : Attribute { public object? Min { get; set; } public object? Max { get; set; } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ExperimentalAttribute : Attribute { public string DiagnosticId { get; } public string? UrlFormat { get; set; } public ExperimentalAttribute(string diagnosticId) { DiagnosticId = diagnosticId; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SetsRequiredMembersAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class StringSyntaxAttribute : Attribute { public const string CompositeFormat = "CompositeFormat"; public const string DateOnlyFormat = "DateOnlyFormat"; public const string DateTimeFormat = "DateTimeFormat"; public const string EnumFormat = "EnumFormat"; public const string GuidFormat = "GuidFormat"; public const string Json = "Json"; public const string NumericFormat = "NumericFormat"; public const string Regex = "Regex"; public const string TimeOnlyFormat = "TimeOnlyFormat"; public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; public const string Xml = "Xml"; public string Syntax { get; } public object?[] Arguments { get; } public StringSyntaxAttribute(string syntax) { Syntax = syntax; Arguments = new object[0]; } public StringSyntaxAttribute(string syntax, params object?[] arguments) { Syntax = syntax; Arguments = arguments; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class UnscopedRefAttribute : Attribute { } } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiresPreviewFeaturesAttribute : Attribute { public string? Message { get; } public string? Url { get; set; } public RequiresPreviewFeaturesAttribute() { } public RequiresPreviewFeaturesAttribute(string? message) { Message = message; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CallerArgumentExpressionAttribute : Attribute { public string ParameterName { get; } public CallerArgumentExpressionAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CollectionBuilderAttribute : Attribute { public Type BuilderType { get; } public string MethodName { get; } public CollectionBuilderAttribute(Type builderType, string methodName) { BuilderType = builderType; MethodName = methodName; } } [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CompilerFeatureRequiredAttribute : Attribute { public const string RefStructs = "RefStructs"; public const string RequiredMembers = "RequiredMembers"; public string FeatureName { get; } public bool IsOptional { get; set; } public CompilerFeatureRequiredAttribute(string featureName) { FeatureName = featureName; } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute { public string[] Arguments { get; } public InterpolatedStringHandlerArgumentAttribute(string argument) { Arguments = new string[1] { argument }; } public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) { Arguments = arguments; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerAttribute : Attribute { } [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal static class IsExternalInit { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ModuleInitializerAttribute : Attribute { } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class OverloadResolutionPriorityAttribute : Attribute { public int Priority { get; } public OverloadResolutionPriorityAttribute(int priority) { Priority = priority; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] [ExcludeFromCodeCoverage] internal sealed class ParamCollectionAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiredMemberAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal sealed class RequiresLocationAttribute : Attribute { } [AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SkipLocalsInitAttribute : Attribute { } }