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 M79 Grenade Launcher v1.0.1
EmpressLauncher.dll
Decompiled 3 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; 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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressLauncher")] [assembly: AssemblyTitle("EmpressLauncher")] [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; } } } namespace Empress.REPO.Launcher { [BepInPlugin("Empress.REPO.Launcher", "Empress Launcher", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class EmpressLauncherPlugin : BaseUnityPlugin { private Harmony? _harmony; internal static EmpressLauncherPlugin Instance { get; private set; } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Instance = this; _harmony = new Harmony("Empress.REPO.Launcher"); _harmony.PatchAll(typeof(ItemGunShootRpcPatch)); } } [DisallowMultipleComponent] public sealed class EmpressLauncherGun : MonoBehaviour { public Transform? Spot; public string GrenadeItemName = "Item Grenade Explosive"; public float LaunchSpeed = 18f; public float UpwardSpeed = 1.5f; public float SpawnForwardOffset = 0.14f; public float SpawnUpOffset = 0f; public float SpinSpeed = 8f; public float ArmDelay = 0.05f; public bool ActivateGrenade = true; public bool UseSpotForMuzzle = true; private void Reset() { EnsureSpot(); SyncGunReferences(); } private void Awake() { EnsureSpot(); SyncGunReferences(); } private void OnValidate() { EnsureSpot(); SyncGunReferences(); } internal Transform GetLaunchTransform(ItemGun gun) { if ((Object)(object)Spot != (Object)null) { return Spot; } if ((Object)(object)gun.gunMuzzle != (Object)null) { return gun.gunMuzzle; } return ((Component)this).transform; } private void EnsureSpot() { if (!((Object)(object)Spot != (Object)null)) { Transform val = ((Component)this).transform.Find("Spot"); if ((Object)(object)val != (Object)null) { Spot = val; } } } private void SyncGunReferences() { if (!UseSpotForMuzzle || (Object)(object)Spot == (Object)null) { return; } ItemGun component = ((Component)this).GetComponent<ItemGun>(); if (!((Object)(object)component == (Object)null)) { component.gunMuzzle = Spot; if ((Object)(object)component.gunTrigger == (Object)null) { component.gunTrigger = Spot; } } } } [HarmonyPatch(typeof(ItemGun), "ShootRPC")] internal static class ItemGunShootRpcPatch { private static bool Prefix(ItemGun __instance, PhotonMessageInfo _info = default(PhotonMessageInfo)) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) EmpressLauncherGun component = ((Component)__instance).GetComponent<EmpressLauncherGun>(); if ((Object)(object)component == (Object)null) { return true; } if (!SemiFunc.MasterOnlyRPC(_info)) { return false; } bool flag = EmpressLauncherRuntime.TryFire(__instance, component); return !flag; } } internal static class EmpressLauncherRuntime { internal static bool TryFire(ItemGun gun, EmpressLauncherGun launcher) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gun == (Object)null || (Object)(object)launcher == (Object)null) { return false; } Item val = FindGrenadeItem(launcher.GrenadeItemName); if ((Object)(object)val == (Object)null) { return false; } Transform launchTransform = launcher.GetLaunchTransform(gun); PlayFireEffects(gun, launchTransform); if (!SemiFunc.IsMasterClientOrSingleplayer()) { return true; } if (gun.investigateRadius > 0f) { EnemyDirector.instance.SetInvestigate(((Component)gun).transform.position, gun.investigateRadius, false); } if ((Object)(object)gun.physGrabObject != (Object)null && (Object)(object)gun.physGrabObject.rb != (Object)null) { gun.physGrabObject.rb.AddForceAtPosition(-launchTransform.forward * gun.gunRecoilForce, launchTransform.position, (ForceMode)1); } DrainBattery(gun); GameObject val2 = SpawnGrenade(val, launchTransform, launcher); return (Object)(object)val2 != (Object)null; } private static void PlayFireEffects(ItemGun gun, Transform origin) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) float num = 3f * gun.cameraShakeMultiplier; float num2 = 16f * gun.cameraShakeMultiplier; SemiFunc.CameraShakeImpactDistance(origin.position, 5f * gun.cameraShakeMultiplier, 0.1f, num, num2); SemiFunc.CameraShakeDistance(origin.position, 0.1f * gun.cameraShakeMultiplier, 0.1f * gun.cameraShakeMultiplier, num, num2); if (gun.soundShoot != null) { gun.soundShoot.Play(origin.position, 1f, 1f, 1f, 1f); } if (gun.soundShootGlobal != null) { gun.soundShootGlobal.Play(origin.position, 1f, 1f, 1f, 1f); } if ((Object)(object)gun.muzzleFlashPrefab != (Object)null && (Object)(object)gun.gunMuzzle != (Object)null) { gun.MuzzleFlash(); } if ((Object)(object)gun.gunTrigger != (Object)null) { gun.StartTriggerAnimation(); } } private static void DrainBattery(ItemGun gun) { if (!((Object)(object)gun.itemBattery == (Object)null)) { if (!gun.batteryDrainFullBar) { ItemBattery itemBattery = gun.itemBattery; itemBattery.batteryLife -= gun.batteryDrain; } else { gun.itemBattery.RemoveFullBar(gun.batteryDrainFullBars); } } } private static GameObject? SpawnGrenade(Item grenadeItem, Transform origin, EmpressLauncherGun launcher) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Vector3 val = origin.forward + origin.up * launcher.UpwardSpeed; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = origin.position + origin.forward * launcher.SpawnForwardOffset + origin.up * launcher.SpawnUpOffset; Quaternion val3 = Quaternion.LookRotation(normalized, origin.up); GameObject val4 = Items.SpawnItem(grenadeItem, val2, val3); if ((Object)(object)val4 == (Object)null) { return null; } ((MonoBehaviour)EmpressLauncherPlugin.Instance).StartCoroutine(LaunchGrenade(val4, normalized, launcher)); return val4; } private static IEnumerator LaunchGrenade(GameObject grenadeObject, Vector3 launchDirection, EmpressLauncherGun launcher) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)grenadeObject == (Object)null) { yield break; } Rigidbody rb = grenadeObject.GetComponent<Rigidbody>(); PhysGrabObject physGrabObject = grenadeObject.GetComponent<PhysGrabObject>(); ItemGrenade grenade = grenadeObject.GetComponent<ItemGrenade>(); if ((Object)(object)grenade != (Object)null) { grenade.isSpawnedGrenade = true; } while ((Object)(object)grenadeObject != (Object)null && (Object)(object)physGrabObject != (Object)null && (!physGrabObject.spawned || (Object)(object)rb == (Object)null || rb.isKinematic)) { yield return null; if ((Object)(object)rb == (Object)null) { rb = grenadeObject.GetComponent<Rigidbody>(); } } if (!((Object)(object)grenadeObject == (Object)null) && !((Object)(object)rb == (Object)null)) { rb.isKinematic = false; rb.detectCollisions = true; rb.WakeUp(); rb.velocity = launchDirection * launcher.LaunchSpeed; if (launcher.SpinSpeed > 0f) { rb.angularVelocity = Random.onUnitSphere * launcher.SpinSpeed; } else { rb.angularVelocity = Vector3.zero; } if (launcher.ActivateGrenade) { yield return ArmGrenade(grenadeObject, launcher.ArmDelay); } } } private static IEnumerator ArmGrenade(GameObject grenadeObject, float delay) { if ((Object)(object)grenadeObject == (Object)null) { yield break; } if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } else { yield return null; } if (!((Object)(object)grenadeObject == (Object)null)) { ItemToggle itemToggle = grenadeObject.GetComponent<ItemToggle>(); if ((Object)(object)itemToggle != (Object)null) { itemToggle.ToggleItem(true, -1); } } } private static Item? FindGrenadeItem(string itemName) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Invalid comparison between Unknown and I4 if ((Object)(object)StatsManager.instance == (Object)null) { return null; } if (!string.IsNullOrWhiteSpace(itemName) && StatsManager.instance.itemDictionary.TryGetValue(itemName, out var value) && (Object)(object)value != (Object)null) { return value; } string key; Item value2; foreach (KeyValuePair<string, Item> item in StatsManager.instance.itemDictionary) { item.Deconstruct(out key, out value2); string a = key; Item val = value2; if ((Object)(object)val == (Object)null || (int)val.itemType != 6 || (!string.Equals(a, itemName, StringComparison.OrdinalIgnoreCase) && !string.Equals(val.itemName, itemName, StringComparison.OrdinalIgnoreCase))) { continue; } return val; } foreach (KeyValuePair<string, Item> item2 in StatsManager.instance.itemDictionary) { item2.Deconstruct(out key, out value2); string text = key; Item val2 = value2; if ((Object)(object)val2 == (Object)null || (int)val2.itemType != 6 || ((string.IsNullOrWhiteSpace(itemName) || text.IndexOf(itemName, StringComparison.OrdinalIgnoreCase) < 0) && (string.IsNullOrWhiteSpace(itemName) || val2.itemName.IndexOf(itemName, StringComparison.OrdinalIgnoreCase) < 0))) { continue; } return val2; } return null; } } }