using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using TMPro;
using ULTRARandomizer.Cheats;
using ULTRARandomizer.MonoBehaviours;
using ULTRARandomizer.PluginConfiguratorCOnfig;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ULTRARandomizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ULTRARandomizer")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81d38014-5865-42f2-a207-ef443dea36a1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ULTRARandomizer
{
[BepInPlugin("com.michi.ULTRARandomizer", "ULTRARandomizer", "1.0.0")]
public class ULTRARandomizerPlugin : BaseUnityPlugin
{
private const string MyGUID = "com.michi.ULTRARandomizer";
private const string PluginName = "ULTRARandomizer";
private const string VersionString = "1.0.0";
private static readonly Harmony Harmony = new Harmony("com.michi.ULTRARandomizer");
public static ManualLogSource Log = new ManualLogSource("ULTRARandomizer");
public static List<Material> materials = new List<Material>();
public static bool globalEnabled;
private bool enableSecretMissions;
private bool enableSanctums;
public static bool doMats = false;
public static bool doMeshes = false;
public static bool RandomizeText = false;
public static bool RandomizeImages = false;
public static bool RandomizeSounds = false;
public static bool RandomizeBeams = false;
public static bool RandomizeExplosions = false;
public static bool randomizeFonts = false;
public static bool randomizeLevelOnExit = false;
public static bool doPlayerHealth = false;
public static float min = 1f;
public static float max = 1000f;
public static int currentMaxHealth;
public static bool DoChangeEnemyHealth = false;
public static bool RandomizeEnemies = false;
public static bool RandomizeProj = false;
public static bool randomizeDamage = false;
public static List<SpawnableObject> enemies = new List<SpawnableObject>();
public static List<Nail> nails = new List<Nail>();
public static List<RevolverBeam> Beams = new List<RevolverBeam>();
public static List<ExplosionController> explosions = new List<ExplosionController>();
public static List<AudioClip> Clips = new List<AudioClip>();
public static List<Projectile> projectiles = new List<Projectile>();
public static List<Font> fonts = new List<Font>();
public static List<TMP_FontAsset> fontsAssets = new List<TMP_FontAsset>();
public static List<string> lesTexts = new List<string>();
public static List<Sprite> lesImages = new List<Sprite>();
public static List<AudioClip> cleanClips = new List<AudioClip>();
public static List<AudioClip> bossClips = new List<AudioClip>();
public static List<AudioClip> battleClips = new List<AudioClip>();
public static List<AudioClip> targetClips = new List<AudioClip>();
private List<string> FileNames = new List<string>();
private string resourceName = "ULTRARandomizer.Keys.Sounds.txt";
private void Awake()
{
Fields.SetFields();
Harmony.PatchAll();
Log = ((BaseUnityPlugin)this).Logger;
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
}
private IEnumerator LoadPlushies()
{
Assembly assembly = Assembly.GetExecutingAssembly();
using Stream stream = assembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
Debug.LogError((object)("Failed to load embedded resource: " + resourceName));
yield break;
}
using StreamReader reader = new StreamReader(stream);
while (true)
{
string text;
string line = (text = reader.ReadLine());
if (text == null)
{
break;
}
string key = line.TrimStart(new char[1] { ' ' });
string prefabKey = key ?? "";
AsyncOperationHandle<SoundtrackSong> plushieHandle = Addressables.LoadAssetAsync<SoundtrackSong>((object)prefabKey);
yield return (object)new WaitUntil((Func<bool>)(() => plushieHandle.IsDone));
if ((int)plushieHandle.Status == 1)
{
cleanClips.AddRange(plushieHandle.Result.clips);
battleClips.AddRange(plushieHandle.Result.clips);
bossClips.AddRange(plushieHandle.Result.clips);
}
else
{
Debug.LogError((object)("Failed to load prefab with key: " + key));
}
}
}
public static void CopyOverNecessaryStuff(EnemyIdentifier basething, EnemyIdentifier clonedEnemy)
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Invalid comparison between Unknown and I4
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Invalid comparison between Unknown and I4
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Invalid comparison between Unknown and I4
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Invalid comparison between Unknown and I4
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Invalid comparison between Unknown and I4
clonedEnemy.activateOnDeath = basething.activateOnDeath;
clonedEnemy.onDeath = basething.onDeath;
clonedEnemy.sandified = basething.sandified;
clonedEnemy.puppet = basething.puppet;
clonedEnemy.target = basething.target;
clonedEnemy.usingDoor = basething.usingDoor;
((Component)clonedEnemy).transform.parent = ((Component)basething).transform.parent;
clonedEnemy.madness = basething.madness;
clonedEnemy.ignorePlayer = basething.ignorePlayer;
clonedEnemy.ignoredByEnemies = basething.ignoredByEnemies;
clonedEnemy.attackEnemies = basething.attackEnemies;
clonedEnemy.dontCountAsKills = basething.dontCountAsKills;
if ((int)clonedEnemy.enemyType == 12)
{
clonedEnemy.sandified = true;
}
if ((int)basething.enemyType == 21 && (int)clonedEnemy.enemyType == 21)
{
Idol component = ((Component)basething).GetComponent<Idol>();
((Component)clonedEnemy).GetComponent<Idol>().target = component.target;
((Component)clonedEnemy).GetComponent<Idol>().target.Bless(false);
}
else if ((int)basething.enemyType == 21 && (int)clonedEnemy.enemyType != 21)
{
Idol component2 = ((Component)basething).GetComponent<Idol>();
component2.target.Unbless(false);
}
if (!basething.dontCountAsKills)
{
ActivateNextWave componentInParent = ((Component)basething).GetComponentInParent<ActivateNextWave>();
if ((Object)(object)componentInParent != (Object)null)
{
((Component)clonedEnemy).transform.parent = ((Component)componentInParent).transform;
}
}
if (Object.op_Implicit((Object)(object)((Component)clonedEnemy).GetComponent<Machine>()))
{
((Component)clonedEnemy).GetComponent<Machine>().dontDie = false;
}
if (basething.isBoss || Object.op_Implicit((Object)(object)((Component)basething).GetComponent<BossHealthBar>()))
{
((Component)clonedEnemy).gameObject.AddComponent<BossHealthBar>();
}
}
public static void CopyOverNecessaryStuffBeam(RevolverBeam basething, RevolverBeam clonedBeam)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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)
clonedBeam.target = basething.target;
clonedBeam.alternateStartPoint = basething.alternateStartPoint;
clonedBeam.sourceWeapon = basething.sourceWeapon;
clonedBeam.ignoreEnemyType = basething.ignoreEnemyType;
clonedBeam.attributes = basething.attributes;
clonedBeam.beamType = basething.beamType;
}
private bool IsNumberNumberFormat(string name)
{
string pattern = "\\d+-\\d+";
return Regex.IsMatch(name, pattern);
}
public static void ChangeSpawned(EnemySpawnRadius spawner, EnemyIdentifier toSwapwith, EnemyIdentifier original)
{
FieldInfo field = ((object)spawner).GetType().GetField("spawnedObjects", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = ((object)spawner).GetType().GetField("currentEnemies", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
List<GameObject> list = (List<GameObject>)field.GetValue(spawner);
List<EnemyIdentifier> list2 = (List<EnemyIdentifier>)field2.GetValue(spawner);
Log.LogInfo((object)list2.Count);
if (list2.Contains(original))
{
list2.Add(toSwapwith);
list2.Remove(original);
field2.SetValue(spawner, list2);
Log.LogInfo((object)(List<EnemyIdentifier>)field2.GetValue(spawner));
}
}
}
private void GetEnemies()
{
enemies.AddRange(Resources.FindObjectsOfTypeAll<SpawnableObject>().ToList());
List<EnemyIdentifier> list = Resources.FindObjectsOfTypeAll<EnemyIdentifier>().ToList();
enemies.RemoveAll((SpawnableObject enemy) => (int)enemy.spawnableObjectType != 1);
enemies.Distinct();
}
private void GetAudio()
{
List<AudioClip> source = Resources.FindObjectsOfTypeAll<AudioClip>().ToList();
IEnumerable<AudioClip> source2 = source.Where((AudioClip clip) => IsNumberNumberFormat(((Object)clip).name));
targetClips.AddRange(source2.Where((AudioClip clip) => !targetClips.Contains(clip)));
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
if (!globalEnabled)
{
return;
}
if (cleanClips.Count == 0 && bossClips.Count == 0 && battleClips.Count == 0)
{
((MonoBehaviour)this).StartCoroutine(LoadPlushies());
}
if (Object.op_Implicit((Object)(object)MonoSingleton<MusicManager>.Instance) && cleanClips.Count != 0 && bossClips.Count != 0 && battleClips.Count != 0 && Fields.ChangeMusic.value)
{
MonoSingleton<MusicManager>.Instance.cleanTheme.clip = cleanClips[Random.Range(0, cleanClips.Count)];
MonoSingleton<MusicManager>.Instance.bossTheme.clip = bossClips[Random.Range(0, bossClips.Count)];
MonoSingleton<MusicManager>.Instance.battleTheme.clip = battleClips[Random.Range(0, battleClips.Count)];
}
if (Object.op_Implicit((Object)(object)MonoSingleton<CheatsManager>.Instance))
{
MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)new RandomizeEnemiesCheat(), "UltraRandomizer");
MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)new RandomizeBeamsCheat(), "UltraRandomizer");
MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)new RandomizeExpCheat(), "UltraRandomizer");
MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)new RandomizeProjCheat(), "UltraRandomizer");
}
ReplaceItems();
GetEnemies();
nails = Resources.FindObjectsOfTypeAll<Nail>().ToList();
nails.Distinct();
projectiles = Resources.FindObjectsOfTypeAll<Projectile>().ToList();
projectiles.Distinct();
if (doMats)
{
ChangeMats();
}
if (doMeshes)
{
ChangeMeshes();
}
if (doPlayerHealth)
{
ChangePlayerHealth();
}
if (DoChangeEnemyHealth)
{
ChangeEnemyHealth();
}
ChangeImages();
ChangeText();
Beams = Resources.FindObjectsOfTypeAll<RevolverBeam>().ToList();
Beams.Distinct();
explosions = Resources.FindObjectsOfTypeAll<ExplosionController>().ToList();
explosions.Distinct();
explosions.RemoveAll((ExplosionController biem) => ((Object)biem).name.ToLower().Contains("fire"));
if (RandomizeSounds)
{
Clips.Clear();
Clips = Resources.FindObjectsOfTypeAll<AudioClip>().ToList();
AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
AudioSource[] array2 = array;
foreach (AudioSource val in array2)
{
val.clip = Clips[Random.Range(0, Clips.Count)];
}
}
}
private void ReplaceItems()
{
//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_004a: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
if (!Fields.ChangeItems.value)
{
return;
}
List<ItemIdentifier> list = Resources.FindObjectsOfTypeAll<ItemIdentifier>().ToList();
Scene activeScene = SceneManager.GetActiveScene();
List<ItemIdentifier> list2 = new List<ItemIdentifier>();
foreach (ItemIdentifier item in list)
{
if (((Component)item).gameObject.scene == activeScene)
{
list2.Add(item);
}
}
foreach (ItemIdentifier item2 in list2)
{
ItemIdentifier val = Object.Instantiate<ItemIdentifier>(list[Random.Range(0, list.Count)], ((Component)item2).transform.position, ((Component)item2).transform.rotation);
val.pickedUp = item2.pickedUp;
val.infiniteSource = item2.infiniteSource;
val.onPickUp = item2.onPickUp;
val.onPutDown = item2.onPutDown;
val.ipz = item2.ipz;
val.itemType = item2.itemType;
Object.Destroy((Object)(object)((Component)item2).gameObject);
}
}
public static void ChangeImages()
{
lesImages.AddRange(Resources.FindObjectsOfTypeAll<Sprite>());
if (RandomizeImages)
{
Image[] array = Resources.FindObjectsOfTypeAll<Image>();
Image[] array2 = array;
foreach (Image val in array2)
{
val.sprite = lesImages[Random.Range(0, lesImages.Count)];
}
}
}
public static void ChangeText()
{
lesTexts.AddRange(GetTexts());
lesTexts = lesTexts.Distinct().ToList();
ChangeTMP();
ChangeNormalText();
}
public static List<string> GetTexts()
{
//IL_0023: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
List<string> list = new List<string>();
TextMeshProUGUI[] array2 = array;
Scene scene;
foreach (TextMeshProUGUI val in array2)
{
scene = ((Component)val).gameObject.scene;
if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
{
fontsAssets.Add(((TMP_Text)val).font);
list.Add(((TMP_Text)val).text);
}
}
Text[] array3 = Resources.FindObjectsOfTypeAll<Text>();
Text[] array4 = array3;
foreach (Text val2 in array4)
{
scene = ((Component)val2).gameObject.scene;
if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
{
fonts.Add(val2.font);
list.Add(val2.text);
}
}
return list;
}
public static void ChangeTMP()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
for (int i = 0; i < array.Length; i++)
{
Scene scene = ((Component)array[i]).gameObject.scene;
if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
{
if (RandomizeText)
{
((TMP_Text)array[i]).text = lesTexts[Random.Range(0, lesTexts.Count)];
}
if (randomizeFonts)
{
((TMP_Text)array[i]).font = fontsAssets[Random.Range(0, fontsAssets.Count)];
}
}
}
}
public static void ChangeNormalText()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
Text[] array = Resources.FindObjectsOfTypeAll<Text>();
for (int i = 0; i < array.Length; i++)
{
Scene scene = ((Component)array[i]).gameObject.scene;
if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
{
if (RandomizeText)
{
array[i].text = lesTexts[Random.Range(0, lesTexts.Count)];
}
if (randomizeFonts)
{
array[i].font = fonts[Random.Range(0, fonts.Count)];
}
}
}
}
public static void ChangeMats()
{
Material[] array = Resources.FindObjectsOfTypeAll<Material>();
Renderer[] array2 = Resources.FindObjectsOfTypeAll<Renderer>();
materials.AddRange(array);
Renderer[] array3 = array2;
foreach (Renderer val in array3)
{
if (!Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<ParticleSystem>()) && ((Component)val).gameObject.layer != 19)
{
Material val2 = materials[Random.Range(0, array.Length)];
Material[] array4 = (Material[])(object)new Material[val.materials.Length];
for (int j = 0; j < array4.Length; j++)
{
array4[j] = val2;
}
val.materials = array4;
val.material = val2;
}
}
}
public static void ChangeMeshes()
{
MeshFilter[] array = Resources.FindObjectsOfTypeAll<MeshFilter>();
Mesh[] array2 = Resources.FindObjectsOfTypeAll<Mesh>();
MeshFilter[] array3 = array;
foreach (MeshFilter val in array3)
{
if (!Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<ParticleSystem>()) && ((Component)val).gameObject.layer != 19)
{
val.mesh = array2[Random.Range(0, array2.Length)];
}
}
}
public void ChangePlayerHealth()
{
MonoSingleton<NewMovement>.Instance.hp = (int)Random.Range(min, max);
currentMaxHealth = MonoSingleton<NewMovement>.Instance.hp;
}
public void ChangeEnemyHealth()
{
EnemyIdentifier[] array = Resources.FindObjectsOfTypeAll<EnemyIdentifier>();
EnemyIdentifier[] array2 = array;
foreach (EnemyIdentifier val in array2)
{
float health = val.Health;
Log.LogInfo((object)val.Health);
val.healthBuff = true;
val.healthBuffModifier = CalculateHealthBuffModifier(val.health, 1f, Random.Range(0.01f, health));
Log.LogInfo((object)val.health);
}
}
private float CalculateHealthBuffModifier(float enemyHealth, float num, float totalHealth)
{
return totalHealth / (enemyHealth * ((num > 1f) ? (0.75f + num / 4f) : num));
}
public static void LoadRandomScene()
{
int num = Random.Range(1, 29);
float num2 = Random.Range(0, 100);
if (num2 < 82.86f)
{
SceneHelper.LoadScene(GetMissionName.GetSceneName(num), false);
}
else if (num2 < 88.57f)
{
int num3 = Random.Range(666, 668);
SceneHelper.LoadScene(GetMissionName.GetSceneName(num3), false);
}
else
{
MonoSingleton<OptionsManager>.Instance.ChangeLevelAbrupt(GetSecretMissionName());
}
}
private static string GetSecretMissionName()
{
string[] array = new string[6] { "Level 0-S", "Level 1-S", "Level 2-S", "Level 4-S", "Level 5-S", "Level 7-S" };
int num = Random.Range(0, array.Length);
return array[num];
}
}
}
namespace ULTRARandomizer.Utils
{
internal static class ModUtils
{
}
}
namespace ULTRARandomizer.PluginConfiguratorCOnfig
{
public class Fields
{
private static BoolField randomizeMats;
private static BoolField randomizeMeshes;
private static BoolField randomizeText;
private static BoolField randomizeSounds;
private static BoolField randomizeFonts;
private static BoolField doPlayerHealth;
private static BoolField DoChangeEnemyHealth;
public static BoolField dontKillYourself;
public static BoolField ChangeMusic;
public static BoolField ChangeItems;
public static BoolField ChangeNails;
public static Dictionary<BoolField, SpawnableObject> enemies = new Dictionary<BoolField, SpawnableObject>();
public static Dictionary<BoolField, RevolverBeam> beams = new Dictionary<BoolField, RevolverBeam>();
public static Dictionary<BoolField, Projectile> projectiles = new Dictionary<BoolField, Projectile>();
public static Dictionary<BoolField, ExplosionController> explosions = new Dictionary<BoolField, ExplosionController>();
public static BoolField RandomizeWeapons;
private static PluginConfigurator rootPanel;
private static ConfigPanel configPanel;
private static ConfigPanel BeamsPanel;
private static ConfigPanel ProjPanel;
private static ConfigPanel ExplosionPanel;
public static void SetFields()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Expected O, but got Unknown
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Expected O, but got Unknown
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Expected O, but got Unknown
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Expected O, but got Unknown
rootPanel = PluginConfigurator.Create("Randomizer", "com.bananastudio.randomizer");
BoolField val = new BoolField(rootPanel.rootPanel, "enabled", "field.enabled", true, true);
configPanel = new ConfigPanel(rootPanel.rootPanel, "enemy Randomizer", "panel.randomizer");
ConfigHeader val2 = new ConfigHeader(configPanel, "if an enemy doesnt appear try loading in a level", 24);
DoChangeEnemyHealth = new BoolField(rootPanel.rootPanel, "randomize Enemy Health", "field.enemyhealthrandom", false);
AddChaosCategory(new ConfigPanel(rootPanel.rootPanel, "C H A O S", "panel.chaos"));
doPlayerHealth = new BoolField(rootPanel.rootPanel, "randomize Player Health", "field.playerhealthrandom", false);
FloatField val3 = new FloatField(rootPanel.rootPanel, "minimum health", "field.miniumumhealth", 0f, true);
FloatField val4 = new FloatField(rootPanel.rootPanel, "maximum health", "field.maximumhealth", 100f, true);
BoolField val5 = new BoolField(rootPanel.rootPanel, "randomize level on exit", "field.levelrandomize", false, true);
ButtonField val6 = new ButtonField(rootPanel.rootPanel, "go to random level", "button.randomlevel");
ButtonField val7 = new ButtonField(configPanel, "Refresh", "button.refresh");
val7.onClick += new OnClick(Refresh_onClick);
val6.onClick += new OnClick(RandomizeLevel_onClick);
ULTRARandomizerPlugin.min = val3.value;
ULTRARandomizerPlugin.globalEnabled = val.value;
ULTRARandomizerPlugin.max = val4.value;
ULTRARandomizerPlugin.randomizeLevelOnExit = val5.value;
val.onValueChange += new BoolValueChangeEventDelegate(GlobalEnabled_onValueChange);
val3.onValueChange += new FloatValueChangeEventDelegate(MinHealth_onValueChange);
val4.onValueChange += new FloatValueChangeEventDelegate(MaxHealth_onValueChange);
val5.onValueChange += new BoolValueChangeEventDelegate(RandomizeLevelOnExit_onValueChange);
SetCorrectValues();
SetCorrectVoids();
}
private static void RandomizeLevelOnExit_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.randomizeLevelOnExit = data.value;
}
private static void RandomizeLevel_onClick()
{
ULTRARandomizerPlugin.LoadRandomScene();
}
private static void GlobalEnabled_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.globalEnabled = data.value;
}
private static void SetCorrectVoids()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
DoChangeEnemyHealth.onValueChange += new BoolValueChangeEventDelegate(DoChangeEnemyHealth_onValueChange);
doPlayerHealth.onValueChange += new BoolValueChangeEventDelegate(DoPlayerHealth_onValueChange);
randomizeFonts.onValueChange += new BoolValueChangeEventDelegate(RandomizeFonts_onValueChange);
randomizeSounds.onValueChange += new BoolValueChangeEventDelegate(RandomizeSounds_onValueChange);
randomizeMats.onValueChange += new BoolValueChangeEventDelegate(RandomizeMats_onValueChange);
randomizeMeshes.onValueChange += new BoolValueChangeEventDelegate(RandomizeMeshes_onValueChange);
randomizeText.onValueChange += new BoolValueChangeEventDelegate(RandomizeText_onValueChange);
}
private static void SetCorrectValues()
{
ULTRARandomizerPlugin.DoChangeEnemyHealth = DoChangeEnemyHealth.value;
ULTRARandomizerPlugin.doPlayerHealth = doPlayerHealth.value;
ULTRARandomizerPlugin.randomizeFonts = randomizeFonts.value;
ULTRARandomizerPlugin.RandomizeSounds = randomizeSounds.value;
ULTRARandomizerPlugin.RandomizeText = randomizeText.value;
ULTRARandomizerPlugin.doMats = randomizeMats.value;
ULTRARandomizerPlugin.doMeshes = randomizeMeshes.value;
}
private static void MaxHealth_onValueChange(FloatValueChangeEvent data)
{
ULTRARandomizerPlugin.max = data.value;
}
private static void MinHealth_onValueChange(FloatValueChangeEvent data)
{
ULTRARandomizerPlugin.min = data.value;
}
public static void AddChaosCategory(ConfigPanel panel)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Expected O, but got Unknown
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Expected O, but got Unknown
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Expected O, but got Unknown
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Expected O, but got Unknown
randomizeText = new BoolField(panel, "randomize Text", "field.randomizetext", false);
randomizeMeshes = new BoolField(panel, "randomize meshes", "field.randomizemeshes", false);
randomizeMats = new BoolField(panel, "randomize materials", "field.randomizemats", false);
randomizeSounds = new BoolField(panel, "randomize sounds", "field.randomizesounds", false);
BeamsPanel = new ConfigPanel(panel, "beam randomizer", "panel.beamrandomizer");
ButtonField val = new ButtonField(BeamsPanel, "refresh", "button.beams.refresh");
val.onClick += new OnClick(RefreshBeams_onClick);
ExplosionPanel = new ConfigPanel(panel, "explosion randomizer", "panel.beamrandomizer");
ButtonField val2 = new ButtonField(ExplosionPanel, "refresh", "button.explosions.refresh");
val2.onClick += new OnClick(RefreshExplosions_onClick);
randomizeFonts = new BoolField(panel, "randomize Fonts", "field.randomizefonts", false);
ProjPanel = new ConfigPanel(panel, "projectile randomizer", "panel.projectilerandomizer");
ButtonField val3 = new ButtonField(ProjPanel, "refresh", "button.proj.refresh");
val3.onClick += new OnClick(RefreshProjs_onClick);
dontKillYourself = new BoolField(panel, "dont kill yourself (basically wont change deco proj", "field.nokys", true);
BoolField val4 = new BoolField(panel, "randomize images", "field.random.images", false, false);
ChangeMusic = new BoolField(panel, "randomize music", "field.random.music", false, true);
ChangeItems = new BoolField(panel, "randomize items", "field.random.items", false, true);
ChangeNails = new BoolField(panel, "randomize nails", "field.random.nails", false, true);
RandomizeWeapons = new BoolField(panel, "randomize Weapons", "fields.random.weapons", false, true);
ULTRARandomizerPlugin.RandomizeImages = val4.value;
val4.onValueChange += new BoolValueChangeEventDelegate(RandomizeImages_onValueChange);
}
private static void RandomizeImages_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.RandomizeImages = data.value;
ULTRARandomizerPlugin.ChangeImages();
}
private static void RefreshExplosions_onClick()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
foreach (ExplosionController explosion in ULTRARandomizerPlugin.explosions)
{
if (!explosions.ContainsValue(explosion))
{
string name = ((Object)((Component)explosion).gameObject).name;
BoolField key = new BoolField(ExplosionPanel, name, "field.explosion" + ((Object)explosion).name, true, false);
explosions.Add(key, explosion);
}
}
}
private static void RefreshProjs_onClick()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
foreach (Projectile projectile in ULTRARandomizerPlugin.projectiles)
{
if (!projectiles.ContainsValue(projectile))
{
string name = ((Object)((Component)projectile).gameObject).name;
BoolField key = new BoolField(ProjPanel, name, "field.proj" + ((Object)projectile).name, true, false);
projectiles.Add(key, projectile);
}
}
}
private static void RefreshBeams_onClick()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
foreach (RevolverBeam beam in ULTRARandomizerPlugin.Beams)
{
if (!beams.ContainsValue(beam))
{
string name = ((Object)((Component)beam).gameObject).name;
BoolField key = new BoolField(BeamsPanel, name, "field.beam" + ((Object)beam).name, true, false);
beams.Add(key, beam);
}
}
}
private static void Refresh_onClick()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
foreach (SpawnableObject enemy in ULTRARandomizerPlugin.enemies)
{
if (!enemies.ContainsValue(enemy))
{
string objectName = enemy.objectName;
BoolField key = new BoolField(configPanel, objectName, "field.enemy" + ((Object)enemy).name, true, false);
enemies.Add(key, enemy);
}
}
}
private static void RandomizeProj_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.RandomizeProj = data.value;
}
private static void DoChangeEnemyHealth_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.DoChangeEnemyHealth = data.value;
}
private static void DoPlayerHealth_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.doPlayerHealth = data.value;
}
private static void RandomizeFonts_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.randomizeFonts = data.value;
ULTRARandomizerPlugin.ChangeText();
}
private static void RandomizeExplosions_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.RandomizeExplosions = data.value;
}
private static void RandomizeBeams_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.RandomizeBeams = data.value;
}
private static void RandomizeSounds_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.RandomizeSounds = data.value;
}
private static void RandomizeMeshes_onValueChange(BoolValueChangeEvent data)
{
if (data.value)
{
ULTRARandomizerPlugin.ChangeMeshes();
}
ULTRARandomizerPlugin.doMeshes = data.value;
}
private static void RandomizeMats_onValueChange(BoolValueChangeEvent data)
{
if (data.value)
{
ULTRARandomizerPlugin.ChangeMats();
}
ULTRARandomizerPlugin.doMats = data.value;
}
private static void RandomizeText_onValueChange(BoolValueChangeEvent data)
{
if (data.value)
{
ULTRARandomizerPlugin.ChangeText();
}
ULTRARandomizerPlugin.RandomizeText = data.value;
}
private static void EnemiesRandomBool_onValueChange(BoolValueChangeEvent data)
{
ULTRARandomizerPlugin.RandomizeEnemies = data.value;
}
}
}
namespace ULTRARandomizer.Patches
{
[HarmonyPatch(typeof(EnemySimplifier))]
internal class EnemyPatches
{
[HarmonyPatch("ChangeMaterialNew")]
private static bool Prefix(MaterialState stateToTarget, Material newMaterial)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.doMats)
{
return true;
}
newMaterial = ULTRARandomizerPlugin.materials[Random.Range(0, ULTRARandomizerPlugin.materials.Count)];
return false;
}
}
[HarmonyPatch(typeof(EnemySpawnRadius), "SpawnEnemy")]
internal class SpawnEnemiesRandom
{
private static bool Prefix(ref EnemySpawnRadius __instance, ref List<GameObject> ___spawnedObjects, ref List<EnemyIdentifier> ___currentEnemies, ref float ___cooldown, ref GoreZone ___gz)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
RaycastHit val2 = default(RaycastHit);
for (int i = 0; i < 3; i++)
{
List<KeyValuePair<BoolField, SpawnableObject>> list = Fields.enemies.Where((KeyValuePair<BoolField, SpawnableObject> pair) => pair.Key.value).ToList();
if (list.Count == 0)
{
return true;
}
int index = Random.Range(0, list.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
SpawnableObject value = list[index].Value;
Vector3 val = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f));
Vector3 normalized = ((Vector3)(ref val)).normalized;
if (!Physics.Raycast(((Component)__instance).transform.position + normalized * Random.Range(__instance.minimumDistance, __instance.maximumDistance), Vector3.down, ref val2, 25f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1))))
{
continue;
}
___cooldown = __instance.spawnCooldown;
GameObject val3 = Object.Instantiate<GameObject>(value.gameObject, ((RaycastHit)(ref val2)).point, Quaternion.identity);
val3.transform.SetParent(((Component)___gz).transform, true);
___spawnedObjects.Add(val3);
EnemyIdentifier componentInChildren = val3.GetComponentInChildren<EnemyIdentifier>();
if (Object.op_Implicit((Object)(object)componentInChildren))
{
((Component)componentInChildren).gameObject.AddComponent<DontRandomize>();
___currentEnemies.Add(componentInChildren);
if (__instance.spawnAsPuppets)
{
componentInChildren.puppet = true;
}
}
else
{
___currentEnemies.Add(null);
}
val3.SetActive(true);
return false;
}
___cooldown = 1f;
return false;
}
}
[HarmonyPatch(typeof(EnemyIdentifier))]
internal class EnemyRandomPatches
{
[HarmonyPatch("Start")]
private static bool Prefix(ref EnemyIdentifier __instance)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeEnemies)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
{
return true;
}
if (Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<DontRandomize>()))
{
return true;
}
Scene scene = ((Component)__instance).gameObject.scene;
if (((Scene)(ref scene)).name == "6e981b1865c649749a610aafc471e198")
{
return true;
}
ULTRARandomizerPlugin.Log.LogInfo((object)((Object)((Component)__instance).gameObject).name);
List<KeyValuePair<BoolField, SpawnableObject>> list = Fields.enemies.Where((KeyValuePair<BoolField, SpawnableObject> pair) => pair.Key.value).ToList();
SpawnableObject val;
if (list.Count == 0)
{
int index = Random.Range(0, ULTRARandomizerPlugin.enemies.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.enemies.Count);
val = ULTRARandomizerPlugin.enemies[index];
}
else
{
int index2 = Random.Range(0, list.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
val = list[index2].Value;
}
GameObject val2 = Object.Instantiate<GameObject>(val.gameObject, ((Component)__instance).transform.position, ((Component)__instance).gameObject.transform.rotation);
EnemyIdentifier val3 = val2.GetComponent<EnemyIdentifier>();
if (!Object.op_Implicit((Object)(object)val3))
{
val3 = val2.AddComponent<EnemyIdentifier>();
}
else if (Object.op_Implicit((Object)(object)val3))
{
ULTRARandomizerPlugin.CopyOverNecessaryStuff(__instance, val3);
}
EnemyIdentifier obj = val3;
((Object)obj).name = ((Object)obj).name + "Random";
Object.Destroy((Object)(object)((Component)__instance).gameObject);
ULTRARandomizerPlugin.Log.LogInfo((object)((Object)val3).name);
return false;
}
}
[HarmonyPatch(typeof(Nail))]
internal class NailRandomPatches
{
[HarmonyPatch("Start")]
private static bool Prefix(ref Nail __instance)
{
//IL_00d0: 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_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!Fields.ChangeNails.value)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
{
return true;
}
if (Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<DontRandomize>()))
{
return true;
}
ULTRARandomizerPlugin.Log.LogInfo((object)((Object)((Component)__instance).gameObject).name);
int index = Random.Range(0, ULTRARandomizerPlugin.nails.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.nails.Count);
Nail val = ULTRARandomizerPlugin.nails[index];
GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)__instance).transform.position, ((Component)__instance).gameObject.transform.rotation);
Nail component = val2.GetComponent<Nail>();
component.sourceWeapon = __instance.sourceWeapon;
component.originalVelocity = __instance.originalVelocity;
component.nbc = __instance.nbc;
component.weaponType = __instance.weaponType;
Rigidbody val3 = default(Rigidbody);
Rigidbody val4 = default(Rigidbody);
if (((Component)component).TryGetComponent<Rigidbody>(ref val3) && ((Component)__instance).TryGetComponent<Rigidbody>(ref val4))
{
val3.velocity = val4.velocity;
}
if (component.sawblade)
{
component.ForceCheckSawbladeRicochet();
}
component.enemy = __instance.enemy;
((Object)component).name = ((Object)component).name + "Random";
Object.Destroy((Object)(object)((Component)__instance).gameObject);
ULTRARandomizerPlugin.Log.LogInfo((object)((Object)component).name);
return false;
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
public class RandoDamageo
{
public static bool Prefix(ref EnemyIdentifier __instance, ref float multiplier)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.randomizeDamage)
{
return true;
}
multiplier = Random.Range(0f, multiplier * 2f);
ULTRARandomizerPlugin.Log.LogInfo((object)multiplier);
return true;
}
}
[HarmonyPatch(typeof(FinalRank))]
public class RandomLevelAfterPit
{
[HarmonyPrefix]
[HarmonyPatch("LevelChange")]
public static bool GoToRandomLevelChange()
{
if (!ULTRARandomizerPlugin.randomizeLevelOnExit)
{
return true;
}
ULTRARandomizerPlugin.LoadRandomScene();
return false;
}
[HarmonyPrefix]
[HarmonyPatch("RanklessNextLevel")]
public static bool GoToRandomLevelRankless()
{
if (!ULTRARandomizerPlugin.randomizeLevelOnExit)
{
return true;
}
ULTRARandomizerPlugin.LoadRandomScene();
return false;
}
}
[HarmonyPatch(typeof(HudMessageReceiver), "ShowHudMessage")]
public class RandomHudMessage
{
public static void Postfix(ref HudMessageReceiver __instance)
{
if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
{
ULTRARandomizerPlugin.Log.LogInfo((object)"Prefix HudMessage");
ULTRARandomizerPlugin.Log.LogInfo((object)("Prefix HudMessage " + __instance.text.text));
if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.text.text))
{
ULTRARandomizerPlugin.lesTexts.Add(__instance.text.text);
}
__instance.text.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
}
}
}
[HarmonyPatch(typeof(StyleHUD), "GetLocalizedName")]
public class RandomStyleName
{
public static bool Prefix(ref string __result)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeText)
{
return true;
}
__result = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
return false;
}
}
[HarmonyPatch(typeof(HudMessage), "PlayMessage")]
public class RandomHudMessagePlay
{
public static bool Prefix(ref HudMessage __instance)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeText)
{
return true;
}
ULTRARandomizerPlugin.Log.LogInfo((object)"Prefix HudMessage");
ULTRARandomizerPlugin.Log.LogInfo((object)("Prefix HudMessage " + __instance.message));
if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.message))
{
ULTRARandomizerPlugin.lesTexts.Add(__instance.message);
}
__instance.message = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
ULTRARandomizerPlugin.Log.LogInfo((object)("Prefix HudMessage " + __instance.message2));
if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.message2))
{
ULTRARandomizerPlugin.lesTexts.Add(__instance.message2);
}
__instance.message2 = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
return true;
}
}
[HarmonyPatch(typeof(CheatsManager), "UpdateCheatState", new Type[]
{
typeof(CheatMenuItem),
typeof(ICheat)
})]
public class RandomCheatNames
{
public static void Postfix(CheatMenuItem item, ICheat cheat)
{
if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
{
if (!ULTRARandomizerPlugin.lesTexts.Contains(item.longName.text))
{
ULTRARandomizerPlugin.lesTexts.Add(item.longName.text);
}
item.longName.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
}
}
}
[HarmonyPatch(typeof(CheatBinds), "ResolveCheatKey")]
public class RandomCheatNamesInfo
{
public static bool Prefix(ref string __result, string cheatIdentifier)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeText)
{
return true;
}
__result = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
return false;
}
}
[HarmonyPatch(typeof(LevelNamePopup), "NameAppear")]
public class RandomLevelPopUP
{
public static bool Prefix(ref string ___layerString, ref string ___nameString, ref LevelNamePopup __instance)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeText)
{
return true;
}
string item = ___layerString;
___nameString = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
___layerString = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
string item2 = ___nameString;
if (!ULTRARandomizerPlugin.lesTexts.Contains(item))
{
ULTRARandomizerPlugin.lesTexts.Add(item);
}
if (!ULTRARandomizerPlugin.lesTexts.Contains(item2))
{
ULTRARandomizerPlugin.lesTexts.Add(item2);
}
item = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
item2 = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
return true;
}
}
[HarmonyPatch(typeof(ScanningStuff), "ScanBook")]
public class RandomBookText
{
public static void Postfix(ref TMP_Text ___readingText, ref ScanningStuff __instance, string text, bool noScan, int instanceId)
{
if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
{
if (!ULTRARandomizerPlugin.lesTexts.Contains(text))
{
ULTRARandomizerPlugin.lesTexts.Add(text);
}
TMP_Text val = ___readingText;
val.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
}
}
}
[HarmonyPatch(typeof(EnemyInfoPage), "DisplayInfo", new Type[] { typeof(SpawnableObject) })]
public class RandomInfo
{
public static void Postfix(ref TMP_Text ___enemyPageContent, ref TMP_Text ___enemyPageTitle, ref EnemyInfoPage __instance, SpawnableObject source)
{
if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
{
if (!ULTRARandomizerPlugin.lesTexts.Contains(source.description))
{
ULTRARandomizerPlugin.lesTexts.Add(source.description);
}
TMP_Text val = ___enemyPageContent;
val.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
TMP_Text val2 = ___enemyPageTitle;
val2.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
}
}
}
[HarmonyPatch(typeof(PrefsManager), "GetInt")]
public class randomWeapons
{
public static bool Prefix(ref int __result, string key)
{
if (!Fields.RandomizeWeapons.value)
{
return true;
}
if (key.Contains("weapon."))
{
__result = Random.Range(0, 3);
return false;
}
return true;
}
}
[HarmonyPatch(typeof(BossHealthBar), "Awake")]
public class randomBossname
{
public static bool Prefix(ref BossHealthBar __instance)
{
if (!ULTRARandomizerPlugin.RandomizeText)
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if (string.IsNullOrEmpty(__instance.bossName) && !ULTRARandomizerPlugin.lesTexts.Contains(__instance.source.FullName))
{
ULTRARandomizerPlugin.lesTexts.Add(__instance.source.FullName);
}
if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.bossName))
{
ULTRARandomizerPlugin.lesTexts.Add(__instance.bossName);
}
__instance.bossName = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
return true;
}
}
[HarmonyPatch(typeof(SubtitleController), "DisplaySubtitle", new Type[]
{
typeof(string),
typeof(AudioSource),
typeof(bool)
})]
public class RandoSubtitle
{
public static bool Prefix(ref Transform ___container, ref Subtitle ___subtitleLine, ref Subtitle ___previousSubtitle, ref SubtitleController __instance, string caption, AudioSource audioSource = null, bool ignoreSetting = false)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeText)
{
return true;
}
ULTRARandomizerPlugin.Log.LogInfo((object)caption);
if (!ULTRARandomizerPlugin.lesTexts.Contains(caption))
{
ULTRARandomizerPlugin.lesTexts.Add(caption);
}
caption = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
ULTRARandomizerPlugin.Log.LogInfo((object)caption);
Transform val = ___container;
Subtitle val2 = ___subtitleLine;
Subtitle val3 = ___previousSubtitle;
Subtitle val4 = Object.Instantiate<Subtitle>(val2, val, true);
((Component)val4).GetComponentInChildren<TMP_Text>().text = caption;
if ((Object)(object)audioSource != (Object)null)
{
val4.distanceCheckObject = audioSource;
}
((Component)val4).gameObject.SetActive(true);
if (!Object.op_Implicit((Object)(object)val3))
{
val4.ContinueChain();
}
else
{
val3.nextInChain = val4;
}
val3 = val4;
return false;
}
}
[HarmonyPatch(typeof(UnlockBestiary), "Start")]
public class DestroyBenjamin
{
public static bool Prefix(ref UnlockBestiary __instance)
{
//IL_012e: 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)
if (!ULTRARandomizerPlugin.RandomizeEnemies)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name != "Main")
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
{
return true;
}
List<KeyValuePair<BoolField, SpawnableObject>> list = Fields.enemies.Where((KeyValuePair<BoolField, SpawnableObject> pair) => pair.Key.value).ToList();
SpawnableObject val;
if (list.Count == 0)
{
int index = Random.Range(0, ULTRARandomizerPlugin.enemies.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.enemies.Count);
val = ULTRARandomizerPlugin.enemies[index];
}
else
{
int index2 = Random.Range(0, list.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
val = list[index2].Value;
}
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(0.3906f, -9.6951f, 651.7464f);
GameObject val3 = Object.Instantiate<GameObject>(val.gameObject, val2, val.gameObject.transform.rotation);
((Object)val3).name = ((Object)val3).name + "Random";
Object.Destroy((Object)(object)((Component)__instance).gameObject);
val3.AddComponent<BossHealthBar>();
return false;
}
}
[HarmonyPatch(typeof(Projectile))]
internal class ProjectileRandomPatches
{
[HarmonyPatch("Start")]
private static bool Prefix(ref Projectile __instance)
{
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: 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 (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeProj)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.ToLower().Contains("deco") && Fields.dontKillYourself.value)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
{
return true;
}
List<KeyValuePair<BoolField, Projectile>> list = Fields.projectiles.Where((KeyValuePair<BoolField, Projectile> pair) => pair.Key.value).ToList();
Projectile val;
if (list.Count == 0)
{
int index = Random.Range(0, ULTRARandomizerPlugin.projectiles.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.projectiles.Count);
val = ULTRARandomizerPlugin.projectiles[index];
}
else
{
int index2 = Random.Range(0, list.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
val = list[index2].Value;
}
Projectile val2 = Object.Instantiate<Projectile>(val, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
((Component)val2).transform.forward = ((Component)__instance).transform.forward;
((Object)val2).name = ((Object)val2).name + "Random";
val2.safeEnemyType = __instance.safeEnemyType;
val2.weaponType = __instance.weaponType;
val2.turnSpeed = __instance.turnSpeed;
val2.turningSpeedMultiplier = __instance.turningSpeedMultiplier;
val2.sourceWeapon = __instance.sourceWeapon;
val2.playerBullet = __instance.playerBullet;
val2.friendly = __instance.friendly;
val2.alreadyHitEnemies = __instance.alreadyHitEnemies;
val2.target = val.target;
Object.Destroy((Object)(object)((Component)__instance).gameObject);
return false;
}
}
[HarmonyPatch(typeof(ExplosionController))]
internal class ExplosionRandomPatches
{
[HarmonyPatch("Start")]
private static bool Prefix(ref ExplosionController __instance)
{
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeExplosions)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
{
return true;
}
List<KeyValuePair<BoolField, ExplosionController>> list = Fields.explosions.Where((KeyValuePair<BoolField, ExplosionController> pair) => pair.Key.value).ToList();
ExplosionController val;
if (list.Count == 0)
{
int index = Random.Range(0, ULTRARandomizerPlugin.explosions.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.explosions.Count);
val = ULTRARandomizerPlugin.explosions[index];
}
else
{
int index2 = Random.Range(0, list.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
val = list[index2].Value;
}
ExplosionController val2 = Object.Instantiate<ExplosionController>(val, ((Component)__instance).transform.position, ((Component)val).transform.rotation);
((Object)val2).name = ((Object)val2).name + "Random";
Object.Destroy((Object)(object)((Component)__instance).gameObject);
return false;
}
}
[HarmonyPatch(typeof(NewMovement), "Respawn")]
public class PlayerPatches
{
private static void Postfix()
{
if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.doPlayerHealth)
{
MonoSingleton<NewMovement>.Instance.hp = (int)Random.Range(ULTRARandomizerPlugin.min, ULTRARandomizerPlugin.max);
ULTRARandomizerPlugin.currentMaxHealth = MonoSingleton<NewMovement>.Instance.hp;
}
}
}
[HarmonyPatch(typeof(AudioSource), "Play", new Type[] { })]
public class RandomSound
{
private static bool Prefix(ref AudioSource __instance)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeSounds)
{
return true;
}
__instance.clip = ULTRARandomizerPlugin.Clips[Random.Range(0, ULTRARandomizerPlugin.Clips.Count)];
return true;
}
}
[HarmonyPatch(typeof(RevolverBeam), "Start")]
public class RandomBeam
{
private static bool Prefix(ref RevolverBeam __instance)
{
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.RandomizeBeams)
{
return true;
}
if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
{
return true;
}
List<KeyValuePair<BoolField, RevolverBeam>> list = Fields.beams.Where((KeyValuePair<BoolField, RevolverBeam> pair) => pair.Key.value).ToList();
RevolverBeam val;
if (list.Count == 0)
{
int index = Random.Range(0, ULTRARandomizerPlugin.Beams.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.Beams.Count);
val = ULTRARandomizerPlugin.Beams[index];
}
else
{
int index2 = Random.Range(0, list.Count);
ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
val = list[index2].Value;
}
ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.enemies.Count);
RevolverBeam val2 = Object.Instantiate<RevolverBeam>(val, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
((Object)val2).name = ((Object)val2).name + "Random";
ULTRARandomizerPlugin.CopyOverNecessaryStuffBeam(__instance, val2);
Object.Destroy((Object)(object)((Component)__instance).gameObject);
ULTRARandomizerPlugin.Log.LogInfo((object)((Object)val2).name);
return false;
}
}
[HarmonyPatch(typeof(NewMovement), "GetHealth")]
public class CheckPatch
{
private static int HealthBefore;
private static bool Prefix(ref NewMovement __instance, int health)
{
if (!ULTRARandomizerPlugin.globalEnabled)
{
return true;
}
if (!ULTRARandomizerPlugin.doPlayerHealth)
{
return true;
}
HealthBefore = __instance.hp;
return true;
}
private static void Postfix(int health)
{
if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.doPlayerHealth)
{
if (HealthBefore + health <= ULTRARandomizerPlugin.currentMaxHealth)
{
NewMovement instance = MonoSingleton<NewMovement>.Instance;
instance.hp += health;
}
if (MonoSingleton<NewMovement>.Instance.hp > ULTRARandomizerPlugin.currentMaxHealth)
{
MonoSingleton<NewMovement>.Instance.hp = ULTRARandomizerPlugin.currentMaxHealth;
}
}
}
}
[HarmonyPatch(typeof(MusicManager))]
public class randomoManageroMusico
{
[HarmonyPatch("OnEnable")]
[HarmonyPrefix]
public static bool Changethething(ref MusicManager __instance)
{
if (!Fields.ChangeMusic.value)
{
return true;
}
AddAndRandomizeClips(__instance);
return true;
}
private static void AddAndRandomizeClips(MusicManager instance)
{
RandomizeAudioClip(instance.cleanTheme, ULTRARandomizerPlugin.cleanClips);
RandomizeAudioClip(instance.bossTheme, ULTRARandomizerPlugin.bossClips);
RandomizeAudioClip(instance.battleTheme, ULTRARandomizerPlugin.battleClips);
}
private static void RandomizeAudioClip(AudioSource audioSource, List<AudioClip> clips)
{
if (Fields.ChangeMusic.value)
{
if ((Object)(object)audioSource != (Object)null && clips.Count > 0)
{
audioSource.clip = clips[Random.Range(0, clips.Count)];
}
else
{
Debug.LogWarning((object)"AudioSource or AudioClip list is null or empty.");
}
}
}
}
[HarmonyPatch(typeof(MusicChanger), "Change")]
public class RandomMusic
{
public static bool Prefix(ref MusicChanger __instance)
{
if (!Fields.ChangeMusic.value)
{
return true;
}
AudioClip clean = ULTRARandomizerPlugin.cleanClips[Random.Range(0, ULTRARandomizerPlugin.cleanClips.Count)];
AudioClip battle = ULTRARandomizerPlugin.battleClips[Random.Range(0, ULTRARandomizerPlugin.battleClips.Count)];
AudioClip boss = ULTRARandomizerPlugin.bossClips[Random.Range(0, ULTRARandomizerPlugin.bossClips.Count)];
__instance.clean = clean;
__instance.battle = battle;
__instance.boss = boss;
return true;
}
}
}
namespace ULTRARandomizer.MonoBehaviours
{
internal class DontRandomize : MonoBehaviour
{
public string nothing = "this is literally nothing";
}
internal class ULTRARandomizerComponent : MonoBehaviour
{
public void Awake()
{
}
public void Start()
{
}
public void Update()
{
}
public void LateUpdate()
{
}
}
}
namespace ULTRARandomizer.Cheats
{
internal class RandomizeExpCheat : ICheat
{
private bool active;
public string LongName => "Randomize Explosions";
public string Identifier => "UltraRandomizer.randomize_explosions";
public string ButtonEnabledOverride => "Explosions Enabled";
public string ButtonDisabledOverride => "Explosions Disabled";
public string Icon => "warning";
public bool IsActive => active;
public bool DefaultState => false;
public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1;
public void Disable()
{
active = false;
ULTRARandomizerPlugin.RandomizeExplosions = active;
}
public void Enable()
{
active = true;
ULTRARandomizerPlugin.RandomizeExplosions = active;
}
public void Update()
{
}
}
internal class RandomizeProjCheat : ICheat
{
private bool active;
public string LongName => "Randomize Projectiles";
public string Identifier => "UltraRandomizer.randomize_projectiles";
public string ButtonEnabledOverride => "Projectiles Enabled";
public string ButtonDisabledOverride => "Projectiles Disabled";
public string Icon => "warning";
public bool IsActive => active;
public bool DefaultState => false;
public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1;
public void Disable()
{
active = false;
ULTRARandomizerPlugin.RandomizeProj = active;
}
public void Enable()
{
active = true;
ULTRARandomizerPlugin.RandomizeProj = active;
}
public void Update()
{
}
}
internal class RandomizeBeamsCheat : ICheat
{
private bool active;
public string LongName => "Randomize Beams";
public string Identifier => "UltraRandomizer.randomize_beams";
public string ButtonEnabledOverride => "Beams Enabled";
public string ButtonDisabledOverride => "Beams Disabled";
public string Icon => "warning";
public bool IsActive => active;
public bool DefaultState => false;
public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1;
public void Disable()
{
active = false;
ULTRARandomizerPlugin.RandomizeBeams = active;
}
public void Enable()
{
active = true;
ULTRARandomizerPlugin.RandomizeBeams = active;
}
public void Update()
{
}
}
internal class RandomizeEnemiesCheat : ICheat
{
private bool active;
public string LongName => "RandomizeEnemies";
public string Identifier => "UltraRandomizer.randomize_enemies";
public string ButtonEnabledOverride => "Enemies Enabled";
public string ButtonDisabledOverride => "Enemies Disabled";
public string Icon => "warning";
public bool IsActive => active;
public bool DefaultState => false;
public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1;
public void Disable()
{
Debug.Log((object)"disables");
active = false;
ULTRARandomizerPlugin.RandomizeEnemies = active;
}
public void Enable()
{
Debug.Log((object)"enabled");
active = true;
ULTRARandomizerPlugin.RandomizeEnemies = active;
}
public void Update()
{
}
}
}