using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Sandbox.Arm;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FastWeapons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FastWeapons")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("23d36fc0-8d09-4f8e-8e76-a404ffd2a1c5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FastWeaponsMod;
[BepInPlugin("com.syahbana.fastweapons", "Ultra Fast Weapons (Ultra*** Edition)", "3.2.0")]
public class Plugin : BaseUnityPlugin
{
public static float SpeedMultiplier = 40f;
public static bool UltraAsteriskMode = true;
private float fireTimer = 0f;
private GameObject cachedExplosion;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
new Harmony("com.syahbana.fastweapons").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Ultra*** Speed Mod v3.2 loaded! Press [U] to toggle.");
}
private void Update()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Invalid comparison between Unknown and I4
if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null || (Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null || ((Object)(object)MonoSingleton<OptionsManager>.Instance != (Object)null && MonoSingleton<OptionsManager>.Instance.paused) || (int)Cursor.lockState != 1)
{
return;
}
if (Input.GetKeyDown((KeyCode)117))
{
UltraAsteriskMode = !UltraAsteriskMode;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Ultra*** Mode: " + (UltraAsteriskMode ? "ON" : "OFF")));
}
if (UltraAsteriskMode && (!((Object)(object)MonoSingleton<GunControl>.Instance != (Object)null) || !((Object)(object)MonoSingleton<GunControl>.Instance.currentWeapon != (Object)null) || !((Object)(object)MonoSingleton<GunControl>.Instance.currentWeapon.GetComponent<SandboxArm>() != (Object)null)))
{
if (fireTimer > 0f)
{
fireTimer -= Time.deltaTime;
}
if (Input.GetMouseButton(0) && fireTimer <= 0f)
{
fireTimer = 0.02f;
FireUltraVolley(15, explosive: false);
}
else if (Input.GetMouseButton(1) && fireTimer <= 0f)
{
fireTimer = 0.04f;
FireUltraVolley(1, explosive: true);
}
}
}
private void FireUltraVolley(int pellets, bool explosive)
{
//IL_000d: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
Vector3 val = transform.position + transform.forward * 1.2f;
RaycastHit val4 = default(RaycastHit);
for (int i = 0; i < pellets; i++)
{
Vector3 val2 = (Vector3)(explosive ? Vector3.zero : new Vector3(Random.Range(-0.025f, 0.025f), Random.Range(-0.025f, 0.025f), Random.Range(-0.025f, 0.025f)));
Vector3 val3 = transform.forward + val2;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
if (!Physics.Raycast(val, normalized, ref val4, 250f))
{
continue;
}
if (explosive && ((RaycastHit)(ref val4)).distance > 3f)
{
SpawnExplosion(((RaycastHit)(ref val4)).point);
}
else if (!explosive)
{
EnemyIdentifier componentInParent = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<EnemyIdentifier>();
if ((Object)(object)componentInParent != (Object)null && !componentInParent.dead)
{
componentInParent.DeliverDamage(((Component)componentInParent).gameObject, normalized * 25f, ((RaycastHit)(ref val4)).point, 1.5f, false, 0f, (GameObject)null, false, false);
}
}
}
}
private void SpawnExplosion(Vector3 pos)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)cachedExplosion == (Object)null)
{
Explosion[] array = Resources.FindObjectsOfTypeAll<Explosion>();
if (array != null && array.Length != 0)
{
cachedExplosion = ((Component)(Explosion)array.GetValue(0)).gameObject;
}
}
if ((Object)(object)cachedExplosion != (Object)null)
{
Object.Instantiate<GameObject>(cachedExplosion, pos, Quaternion.identity);
}
}
public static void BoostWeapon(MonoBehaviour weapon, string shootMethodName, object[] args, bool autoFire)
{
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Invalid comparison between Unknown and I4
Traverse val = Traverse.Create((object)weapon);
string[] array = new string[3] { "gunReady", "readyToShoot", "canShoot" };
string[] array2 = array;
foreach (string text in array2)
{
Traverse val2 = val.Field(text);
if (val2.FieldExists())
{
val2.SetValue((object)true);
}
}
string[] array3 = new string[5] { "shootDelay", "fireCooldown", "cooldown", "primaryCharge", "pierceShotCharge" };
string[] array4 = array3;
foreach (string text2 in array4)
{
Traverse val3 = val.Field(text2);
if (val3.FieldExists() && val3.GetValueType() == typeof(float))
{
val3.SetValue((object)(text2.Contains("Charge") ? 100f : 0f));
}
}
Animator[] componentsInChildren = ((Component)weapon).GetComponentsInChildren<Animator>(true);
foreach (Animator val4 in componentsInChildren)
{
val4.speed = SpeedMultiplier;
}
if (!autoFire || !UltraAsteriskMode || !Input.GetMouseButton(0) || (int)Cursor.lockState != 1)
{
return;
}
Traverse val5 = ((args != null) ? val.Method(shootMethodName, new Type[1] { typeof(int) }, (object[])null) : val.Method(shootMethodName, Array.Empty<object>()));
if (val5.MethodExists())
{
if (args != null)
{
val5.GetValue(args);
}
else
{
val5.GetValue();
}
}
}
}
[HarmonyPatch(typeof(WeaponCharges), "Update")]
public static class InstantChargesPatch
{
private static void Postfix(WeaponCharges __instance)
{
__instance.raicharge = 5f;
__instance.rev0charge = 100f;
__instance.rev1charge = 100f;
__instance.rev2charge = 100f;
__instance.naiHeatsinks = 2f;
__instance.naiAmmo = 100f;
}
}
[HarmonyPatch(typeof(Revolver), "Update")]
public static class FastRevolverPatch
{
private static float revTimer;
private static void Postfix(Revolver __instance)
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Invalid comparison between Unknown and I4
Traverse val = Traverse.Create((object)__instance);
Traverse val2 = val.Field("gunReady");
if (val2.FieldExists())
{
val2.SetValue((object)true);
}
Traverse val3 = val.Field("shootDelay");
if (val3.FieldExists())
{
val3.SetValue((object)0f);
}
Animator[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<Animator>(true);
foreach (Animator val4 in componentsInChildren)
{
val4.speed = 25f;
}
if (revTimer > 0f)
{
revTimer -= Time.deltaTime;
}
if (Plugin.UltraAsteriskMode && Input.GetMouseButton(0) && (int)Cursor.lockState == 1 && revTimer <= 0f)
{
revTimer = 0.04f;
Traverse val5 = val.Method("Shoot", new Type[1] { typeof(int) }, (object[])null);
if (val5.MethodExists())
{
val5.GetValue(new object[1] { 0 });
}
}
}
}
[HarmonyPatch(typeof(Shotgun), "Update")]
public static class FastShotgunPatch
{
private static void Postfix(Shotgun __instance)
{
Plugin.BoostWeapon((MonoBehaviour)(object)__instance, "Shoot", null, autoFire: true);
}
}
[HarmonyPatch(typeof(Nailgun), "Update")]
public static class FastNailgunPatch
{
private static void Postfix(Nailgun __instance)
{
Plugin.BoostWeapon((MonoBehaviour)(object)__instance, "Shoot", null, autoFire: true);
}
}
[HarmonyPatch(typeof(Railcannon), "Update")]
public static class FastRailcannonPatch
{
private static void Postfix(Railcannon __instance)
{
Plugin.BoostWeapon((MonoBehaviour)(object)__instance, "Shoot", null, autoFire: true);
}
}
[HarmonyPatch(typeof(RocketLauncher), "Update")]
public static class FastRocketPatch
{
private static void Postfix(RocketLauncher __instance)
{
Plugin.BoostWeapon((MonoBehaviour)(object)__instance, "Shoot", null, autoFire: true);
}
}