using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using MelonLoader;
using SuperhotRandomizer;
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("SuperhotRandomizer")]
[assembly: AssemblyDescription("Mod for randomizing weapons on player and enemies.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SuperhotRandomizer")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5657e2cd-888b-4174-b3d0-3df38d7852fe")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: MelonInfo(typeof(MainClass), "Superhot Randomizer", "1.1.1", "Gasterbuzzer", "https://github.com/Gasterbuzzer/SuperhotRandomizer/releases/")]
[assembly: MelonGame("SUPERHOT_Team", "SUPERHOT")]
[assembly: MelonAuthorColor(255, 255, 0, 255)]
[assembly: MelonPriority(100)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.1.0")]
namespace SuperhotRandomizer;
public class MainClass : MelonMod
{
}
[HarmonyPatch(typeof(PejAiController), "Start")]
public static class PatchEnemyStart
{
private static readonly Random RandomSystem = new Random();
private static readonly MethodInfo PickupWeapon = typeof(PejAiController).GetMethod("PickupWeapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo CivilianWeapon = typeof(PejAiController).GetField("CivilianWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo MachineGunWeapon = typeof(PejAiController).GetField("MachineGunWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo MeleeWeapon = typeof(PejAiController).GetField("MeleeWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PistolWeapon = typeof(PejAiController).GetField("PistolWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo ShotgunWeapon = typeof(PejAiController).GetField("ShotGunWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo KatanaWeapon = typeof(PejAiController).GetField("KatanaWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo FollowWeapon = typeof(PejAiController).GetField("MeleeWWeaponPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo WalkingSpeed = typeof(PejAiController).GetField("WalkingSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo RunningSpeed = typeof(PejAiController).GetField("RunningSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo LookSpeed = typeof(PejAiController).GetField("LookSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo WeaponSpeedMultiplier = typeof(PejAiController).GetField("weaponSpeedMultiplier", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo StandsStillWhileShooting = typeof(PejAiController).GetField("standsStillWhileShooting", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static void Postfix(PejAiController __instance)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Expected O, but got Unknown
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Expected O, but got Unknown
//IL_038d: Unknown result type (might be due to invalid IL or missing references)
int num = RandomSystem.Next(0, 7);
if (PickupWeapon != null)
{
switch (num)
{
case 0:
{
GameObject val8 = (GameObject)CivilianWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val8, null, true });
break;
}
case 1:
{
GameObject val7 = (GameObject)MachineGunWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val7, null, true });
break;
}
case 2:
{
GameObject val6 = (GameObject)MeleeWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val6, null, true });
break;
}
case 3:
{
GameObject val5 = (GameObject)PistolWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val5, null, true });
break;
}
case 4:
{
GameObject val4 = (GameObject)ShotgunWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val4, null, true });
break;
}
case 5:
{
GameObject val3 = (GameObject)KatanaWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val3, null, true });
break;
}
case 6:
{
GameObject val2 = (GameObject)ShotgunWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val2, null, true });
break;
}
default:
{
GameObject val = (GameObject)FollowWeapon.GetValue(__instance);
PickupWeapon.Invoke(__instance, new object[3] { val, null, true });
break;
}
}
}
else
{
MelonLogger.Warning("PickUpWeapon method not found on the class.");
}
float num2 = RandomSystem.Next(0, 7);
float num3 = RandomSystem.Next((int)num2, 10);
float num4 = RandomSystem.Next(180, 640);
WalkingSpeed.SetValue(__instance, num2);
RunningSpeed.SetValue(__instance, num3);
LookSpeed.SetValue(__instance, num4);
float num5 = RandomSystem.Next(0, 3);
WeaponSpeedMultiplier.SetValue(__instance, num5);
switch (RandomSystem.Next(0, 2))
{
case 0:
StandsStillWhileShooting.SetValue(__instance, false);
break;
case 1:
StandsStillWhileShooting.SetValue(__instance, true);
break;
}
if (RandomSystem.Next(0, 4) == 0)
{
double num6 = RandomSystem.NextDouble();
if (num6 <= 0.1)
{
num6 += 0.1;
}
int num7 = RandomSystem.Next(1, 3);
GameObject gameObject = ((Component)__instance).gameObject;
if ((float)num6 * (float)num7 <= 0.2f)
{
num6 *= (double)num7;
}
gameObject.transform.localScale = new Vector3((float)num6 * (float)num7, (float)num6 * (float)num7, (float)num6 * (float)num7);
}
}
}
[HarmonyPatch(typeof(HandManager), "Start")]
public static class PatchHandStart
{
private static readonly Random RandomSystem = new Random();
private static readonly FieldInfo CurrentWeapon = typeof(HandManager).GetField("weapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly MethodInfo SpawnPlayerWeapon = typeof(HandManager).GetMethod("SpawnWeapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly MethodInfo BecomeUltra = typeof(HandManager).GetMethod("Ultra", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly MethodInfo RemoveCurrentWeapon = typeof(HandManager).GetMethod("RemoveWeapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static void Postfix(HandManager __instance)
{
int num = RandomSystem.Next(0, 5);
if (CurrentWeapon.GetValue(__instance) == null || CurrentWeapon.GetValue(__instance) is TakedownWeapon)
{
MelonLogger.Msg("No weapon equipped. 60% to gain one...");
if (num < 4)
{
MelonLogger.Msg("Giving player a random weapon.");
num = RandomSystem.Next(0, 4);
SpawnPlayerWeapon.Invoke(__instance, new object[1] { num });
}
num = RandomSystem.Next(0, 25);
if (num == 1)
{
BecomeUltra.Invoke(__instance, new object[1] { true });
}
}
else
{
MelonLogger.Msg("Already have weapon, replacing...");
RemoveCurrentWeapon.Invoke(__instance, new object[2] { false, true });
num = RandomSystem.Next(0, 5);
RemoveCurrentWeapon.Invoke(__instance, new object[1] { num });
}
}
}
[HarmonyPatch(typeof(PejAiSpawner), "Spawn")]
public static class PatchAiSpawner
{
private static readonly Random RandomSystem = new Random();
private static bool Prefix()
{
int num = RandomSystem.Next(0, 4);
if (num == 1)
{
MelonLogger.Msg("Skipping one spawn.");
return false;
}
return true;
}
private static void Postfix(MethodBase __originalMethod, PejAiSpawner __instance)
{
switch (RandomSystem.Next(0, 5))
{
case 1:
MelonLogger.Msg("Spawning extra enemy.");
__originalMethod.Invoke(__instance, null);
break;
case 2:
MelonLogger.Msg("Spawning extra 2 enemies.");
__originalMethod.Invoke(__instance, null);
__originalMethod.Invoke(__instance, null);
break;
}
}
}
[HarmonyPatch(typeof(PejAiBody), "Start")]
public static class EnemyHeadPatchRandom
{
private static readonly Random RandomSystem = new Random();
private static readonly FieldInfo PumpkinHeadPrefab = typeof(PejAiBody).GetField("PumpkinHeadPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly MethodInfo ReplaceHeadMethod = typeof(PejAiBody).GetMethod("ReplaceHead", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static void Postfix(PejAiBody __instance)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
int num = RandomSystem.Next(0, 5);
GameObject val = (GameObject)PumpkinHeadPrefab.GetValue(__instance);
if (num == 0)
{
ReplaceHeadMethod.Invoke(__instance, new object[1] { val });
}
}
}