using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.Projectile;
using RandomizerMod.RandomizerScripts.BuffRandomizers;
using RandomizerMod.RandomizerScripts.EnemyRandomizers;
using RandomizerMod.RandomizerScripts.ItemRandomizers;
using RandomizerMod.RandomizerScripts.MusicRandomizers;
using RandomizerMod.RandomizerScripts.ProjectileRandomizers;
using RandomizerMod.RandomizerScripts.StageRandomizers;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
[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("RoR2")]
[assembly: AssemblyCompany("RandomizerMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0a9ca7f841b6123a2d3ed9a24cf37a8afef6184d")]
[assembly: AssemblyProduct("RandomizerMod")]
[assembly: AssemblyTitle("RandomizerMod")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace RandomizerMod
{
public enum RandomizeOption
{
Disabled,
UniquePerKind,
UniquePerKindWithDuplicates,
AlwaysUnique
}
public class RandomConfigs
{
public static ConfigEntry<EnemyRandomOptions> randomizeEnemiesOption;
public static ConfigEntry<bool> replaceChampionsWithChampions;
public static Dictionary<string, ConfigEntry<bool>> blacklist = new Dictionary<string, ConfigEntry<bool>>();
public static ConfigEntry<RandomizeOption> randomizeItems;
public static ConfigEntry<bool> randomizeLunars;
public static ConfigEntry<bool> randomizeEquipment;
public static ConfigEntry<bool> randomizeDronePickups;
public static Dictionary<string, ConfigEntry<bool>> itemBlacklist = new Dictionary<string, ConfigEntry<bool>>();
public static ConfigEntry<RandomizeOption> randomizeBuffs;
public static Dictionary<string, ConfigEntry<bool>> buffBlacklist = new Dictionary<string, ConfigEntry<bool>>();
public static ConfigEntry<RandomizeOption> randomizeMusic;
public static ConfigEntry<RandomizeOption> randomizeProjectiles;
public static ConfigEntry<bool> separateStationaryProjectiles;
public static Dictionary<string, ConfigEntry<bool>> projectileBlacklist = new Dictionary<string, ConfigEntry<bool>>();
public static ConfigEntry<RandomizeOption> randomizeHitscans;
public static Dictionary<string, ConfigEntry<bool>> hitscanBlacklist = new Dictionary<string, ConfigEntry<bool>>();
public static ConfigEntry<bool> randomizeStages;
private static List<string> droneMasterNames = new List<string>
{
"BombardmentDroneMaster", "CleanupDroneMaster", "CopycatDroneMaster", "Drone1Master", "Drone2Master", "DroneBackupMaster", "DroneBomberMaster", "DroneCommanderMaster", "DroneMissileMaster", "EmergencyDroneMaster",
"EngiBeamTurretMaster", "EngiTurretMaster", "EngiWalkerTurretMaster", "EquipmentDroneMaster", "FlameDroneMaster", "HaulerDroneMaster", "JailerDroneMaster", "JunkDroneMaster", "MegaDroneMaster", "RechargeDroneMaster",
"SquidTurretMaster", "Turret1Master"
};
private static List<string> playerCharacterNames = new List<string>
{
"HuntressMonsterMaster", "DroneTechMonsterMaster", "ToolbotMonsterMaster", "Bandit2MonsterMaster", "CommandoMonsterMaster", "CrocoMonsterMaster", "EngiMonsterMaster", "HereticMonsterMaster", "LoaderMonsterMaster", "MageMonsterMaster",
"MercMonsterMaster", "VoidSurvivorMonsterMaster", "ChefMonsterMaster", "FalseSonMonsterMaster", "SeekerMonsterMaster", "DrifterMonsterMaster", "ToolbotMonsterMasterVariant", "RailgunnerMonsterMaster", "TreebotMonsterMaster"
};
public static void SetupConfigs(ConfigFile Config)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Expected O, but got Unknown
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Expected O, but got Unknown
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Expected O, but got Unknown
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Expected O, but got Unknown
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Expected O, but got Unknown
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Expected O, but got Unknown
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Expected O, but got Unknown
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Expected O, but got Unknown
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Expected O, but got Unknown
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Expected O, but got Unknown
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Expected O, but got Unknown
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Expected O, but got Unknown
randomizeEnemiesOption = Config.Bind<EnemyRandomOptions>("Enemies", "Randomize Enemies", EnemyRandomOptions.UniquePerEnemyType, (ConfigDescription)null);
replaceChampionsWithChampions = Config.Bind<bool>("Enemies", "Replace bosses with bosses", false, (ConfigDescription)null);
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)randomizeEnemiesOption));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(replaceChampionsWithChampions));
randomizeItems = Config.Bind<RandomizeOption>("Items", "Randomize Items", RandomizeOption.Disabled, "Disabled = no randomization. UniquePerKind = every item maps to one fixed replacement for the whole run. UniquePerKindWithDuplicates = Same as Unique Per Kind, but allows duplicates AlwaysUnique = a new random replacement is picked each time an item drops.");
randomizeLunars = Config.Bind<bool>("Items", "Randomize Lunars", false, "Mainly for the bazaar between times, for 5 free items");
randomizeDronePickups = Config.Bind<bool>("Items", "Randomize Drone Pickups", true, "When enabled, drone pickups will also be added to the pool.");
randomizeEquipment = Config.Bind<bool>("Items", "Randomize Equipment With Equipment", false, "When enabled, equipment will only randomize with itself (including aspect)");
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)randomizeItems));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(randomizeLunars));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(randomizeDronePickups));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(randomizeEquipment));
randomizeBuffs = Config.Bind<RandomizeOption>("Buffs", "Randomize Buffs", RandomizeOption.Disabled, "Disabled = no randomization. UniquePerKind = each buff always maps to the same replacement. UniquePerKindWithDuplicates = Same as Unique Per Kind, but allows duplicates AlwaysUnique = a new random buff is picked every time one is applied.");
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)randomizeBuffs));
randomizeMusic = Config.Bind<RandomizeOption>("Music", "Randomize Music", RandomizeOption.Disabled, "Disabled = no randomization. UniquePerKind = each track maps to one fixed replacement. UniquePerKindWithDuplicates = Same as Unique Per Kind, but allows duplicates AlwaysUnique = a new random track is picked every time.");
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)randomizeMusic));
randomizeProjectiles = Config.Bind<RandomizeOption>("Projectiles", "Randomize Projectiles", RandomizeOption.Disabled, "Disabled = no randomization. UniquePerKind = each projectile prefab maps to one fixed replacement. UniquePerKindWithDuplicates = Same as Unique Per Kind, but allows duplicates AlwaysUnique = a new random prefab is picked on every fire.");
separateStationaryProjectiles = Config.Bind<bool>("Projectiles", "Separate Stationary Projectiles", false, "When enabled, moving projectiles will only be randomized with other moving projectiles, and stationary projectiles with stationary projectiles. When disabled, all projectiles can be randomized together.");
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)randomizeProjectiles));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(separateStationaryProjectiles));
randomizeHitscans = Config.Bind<RandomizeOption>("Hitscans", "Randomize Hitscans", RandomizeOption.Disabled, "Disabled = no randomization. UniquePerKind = each hitscan visual/damage-type maps to one fixed replacement. UniquePerKindWithDuplicates = Same as Unique Per Kind, but allows duplicates AlwaysUnique = a new random hitscan is picked on every shot.");
ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)randomizeHitscans));
randomizeStages = Config.Bind<bool>("Stages", "Randomize Stages", false, "False = disabled, True = Enabled.");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(randomizeStages));
ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Blacklist all player monster", "Enemies/Blacklist", (UnityAction)delegate
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
List<string> list4 = new List<string>();
foreach (KeyValuePair<string, ConfigEntry<bool>> item in blacklist)
{
if (playerCharacterNames.Contains(item.Key))
{
item.Value.Value = true;
list4.Add(item.Key);
}
}
if (list4.Count < playerCharacterNames.Count)
{
foreach (string playerCharacterName in playerCharacterNames)
{
if (!list4.Contains(playerCharacterName))
{
bool flag4 = RandomizerPlugin.GetForbiddenMasters().Contains(playerCharacterName);
ConfigEntry<bool> val4 = Config.Bind<bool>("Enemies/Blacklist", playerCharacterName, flag4, (ConfigDescription)null);
blacklist.Add(playerCharacterName, val4);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val4));
val4.Value = true;
}
}
}
}));
ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Whitelist all player monster", "Enemies/Blacklist", (UnityAction)delegate
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
List<string> list3 = new List<string>();
foreach (KeyValuePair<string, ConfigEntry<bool>> item2 in blacklist)
{
if (playerCharacterNames.Contains(item2.Key))
{
item2.Value.Value = false;
list3.Add(item2.Key);
}
}
if (list3.Count < playerCharacterNames.Count)
{
foreach (string playerCharacterName2 in playerCharacterNames)
{
if (!list3.Contains(playerCharacterName2))
{
bool flag3 = RandomizerPlugin.GetForbiddenMasters().Contains(playerCharacterName2);
ConfigEntry<bool> val3 = Config.Bind<bool>("Enemies/Blacklist", playerCharacterName2, flag3, (ConfigDescription)null);
blacklist.Add(playerCharacterName2, val3);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val3));
val3.Value = false;
}
}
}
}));
ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Blacklist all drones", "Enemies/Blacklist", (UnityAction)delegate
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
List<string> list2 = new List<string>();
foreach (KeyValuePair<string, ConfigEntry<bool>> item3 in blacklist)
{
if (droneMasterNames.Contains(item3.Key))
{
item3.Value.Value = true;
list2.Add(item3.Key);
}
}
if (list2.Count < droneMasterNames.Count)
{
foreach (string droneMasterName in droneMasterNames)
{
if (!list2.Contains(droneMasterName))
{
bool flag2 = RandomizerPlugin.GetForbiddenMasters().Contains(droneMasterName);
ConfigEntry<bool> val2 = Config.Bind<bool>("Enemies/Blacklist", droneMasterName, flag2, (ConfigDescription)null);
blacklist.Add(droneMasterName, val2);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val2));
val2.Value = true;
}
}
}
}));
ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Whitelist all drones", "Enemies/Blacklist", (UnityAction)delegate
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
List<string> list = new List<string>();
foreach (KeyValuePair<string, ConfigEntry<bool>> item4 in blacklist)
{
if (droneMasterNames.Contains(item4.Key))
{
item4.Value.Value = false;
list.Add(item4.Key);
}
}
if (list.Count < droneMasterNames.Count)
{
foreach (string droneMasterName2 in droneMasterNames)
{
if (!list.Contains(droneMasterName2))
{
bool flag = RandomizerPlugin.GetForbiddenMasters().Contains(droneMasterName2);
ConfigEntry<bool> val = Config.Bind<bool>("Enemies/Blacklist", droneMasterName2, flag, (ConfigDescription)null);
blacklist.Add(droneMasterName2, val);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val));
val.Value = false;
}
}
}
}));
}
public static void SetupBlacklistOptionsMonsters(ConfigFile Config)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
foreach (CharacterMaster allMaster in MasterCatalog.allMasters)
{
try
{
if (!((Object)(object)allMaster == (Object)null) && !itemBlacklist.ContainsKey(((Object)((Component)allMaster).gameObject).name))
{
bool flag = RandomizerPlugin.GetForbiddenMasters().Contains(((Object)((Component)allMaster).gameObject).name);
ConfigEntry<bool> val = Config.Bind<bool>("Enemies/Blacklist", ((Object)((Component)allMaster).gameObject).name, flag, "Set to true to EXCLUDE this item from the randomization pool.");
itemBlacklist.Add(((Object)((Component)allMaster).gameObject).name, val);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val));
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[RandomConfigs] Error setting up monster blacklist for master: " + ex.Message));
}
}
}
public static void SetupBlacklistOptionsItem(ConfigFile Config)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Invalid comparison between Unknown and I4
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Invalid comparison between Unknown and I4
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
foreach (PickupDef allPickup in PickupCatalog.allPickups)
{
try
{
if (allPickup != null && (int)allPickup.artifactIndex == -1 && (int)allPickup.miscPickupIndex == -1 && ((int)allPickup.itemIndex != -1 || (int)allPickup.equipmentIndex != -1) && !itemBlacklist.ContainsKey(allPickup.internalName))
{
bool flag = RandomizerPlugin.GetBlacklist().Contains(allPickup.internalName);
ConfigEntry<bool> val = Config.Bind<bool>("Items/Blacklist", allPickup.internalName, flag, "Set to true to EXCLUDE this item from the randomization pool.");
itemBlacklist.Add(allPickup.internalName, val);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val));
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[RandomConfigs] Error setting up item blacklist for pickup: " + ex.Message));
}
}
}
public static void SetupBlacklistOptionsBuff(ConfigFile Config)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
BuffDef[] buffDefs = BuffCatalog.buffDefs;
foreach (BuffDef val in buffDefs)
{
try
{
if (!((Object)(object)val == (Object)null) && !buffBlacklist.ContainsKey(((Object)val).name))
{
ConfigEntry<bool> val2 = Config.Bind<bool>("Buffs/Blacklist", ((Object)val).name, false, "Set to true to EXCLUDE this buff from the randomization pool.");
buffBlacklist.Add(((Object)val).name, val2);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val2));
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[RandomConfigs] Error setting up buff blacklist for buff " + (((val != null) ? ((Object)val).name : null) ?? "null") + ": " + ex.Message));
}
}
}
public static void SetupBlacklistOptionsProjectile(ConfigFile Config)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
GameObject[] projectilePrefabs = ProjectileCatalog.projectilePrefabs;
foreach (GameObject val in projectilePrefabs)
{
try
{
if (!((Object)(object)val == (Object)null))
{
string name = ((Object)val).name;
if (!string.IsNullOrEmpty(name) && !projectileBlacklist.ContainsKey(name))
{
bool flag = RandomizerPlugin.GetForbiddenProjectiles().Contains(name);
ConfigEntry<bool> val2 = Config.Bind<bool>("Projectiles/Blacklist", name, flag, "Set to true to EXCLUDE this projectile from being used as a replacement in randomization.");
projectileBlacklist.Add(name, val2);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val2));
}
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[RandomConfigs] Error setting up projectile blacklist for prefab " + (((val != null) ? ((Object)val).name : null) ?? "null") + ": " + ex.Message));
}
}
}
public static void SetupBlacklistOptionsHitscan(ConfigFile Config)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Invalid comparison between Unknown and I4
//IL_003c: 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_006f: Invalid comparison between Unknown and I4
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Expected O, but got Unknown
foreach (BulletAttackIdentifier bulletAttackIdentifier in BulletAttackCatalog.bulletAttackIdentifiers)
{
try
{
if (bulletAttackIdentifier == null)
{
continue;
}
object obj;
if ((int)bulletAttackIdentifier.TracerEffectIndex == -1)
{
obj = "NoTracer";
}
else
{
EffectDef effectDef = EffectCatalog.GetEffectDef(bulletAttackIdentifier.TracerEffectIndex);
if (effectDef == null)
{
obj = null;
}
else
{
GameObject prefab = effectDef.prefab;
obj = ((prefab != null) ? ((Object)prefab).name : null);
}
if (obj == null)
{
obj = "NoTracer";
}
}
string text = (string)obj;
object obj2;
if ((int)bulletAttackIdentifier.HitEffectIndex == -1)
{
obj2 = "NoHit";
}
else
{
EffectDef effectDef2 = EffectCatalog.GetEffectDef(bulletAttackIdentifier.HitEffectIndex);
if (effectDef2 == null)
{
obj2 = null;
}
else
{
GameObject prefab2 = effectDef2.prefab;
obj2 = ((prefab2 != null) ? ((Object)prefab2).name : null);
}
if (obj2 == null)
{
obj2 = "NoHit";
}
}
string text2 = (string)obj2;
string text3 = $"{text}_{text2}_{bulletAttackIdentifier.DamageType}_{bulletAttackIdentifier.Flags}";
if (!hitscanBlacklist.ContainsKey(text3))
{
ConfigEntry<bool> val = Config.Bind<bool>("Hitscans/Blacklist", text3, false, "Set to true to EXCLUDE this hitscan (Tracer: " + text + ", Hit: " + text2 + ") from being used as a replacement in randomization.");
hitscanBlacklist.Add(text3, val);
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val));
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[RandomConfigs] Error setting up hitscan blacklist for identifier: " + ex.Message));
}
}
}
public static HashSet<string> GetBlacklistedItems()
{
return new HashSet<string>(from kv in itemBlacklist
where kv.Value.Value
select kv.Key);
}
public static HashSet<string> GetBlacklistedBuffs()
{
return new HashSet<string>(from kv in buffBlacklist
where kv.Value.Value
select kv.Key);
}
public static HashSet<string> GetBlacklistedProjectiles()
{
return new HashSet<string>(from kv in projectileBlacklist
where kv.Value.Value
select kv.Key);
}
public static HashSet<string> GetBlacklistedHitscans()
{
return new HashSet<string>(from kv in hitscanBlacklist
where kv.Value.Value
select kv.Key);
}
}
public enum EnemyRandomOptions
{
Disabled,
UniquePerEnemyType,
AlwaysUnique
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.bananastudio.randomizer", "RiskofInsanity", "1.0.0")]
public class RandomizerPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_Perform <0>__MasterSummon_Perform;
public static hook_PickNextStageScene <1>__Run_PickNextStageScene;
public static hook_FireProjectileServer <2>__ProjectileManager_FireProjectileServer;
public static hook_FireProjectile_FireProjectileInfo <3>__ProjectileManager_FireProjectile_FireProjectileInfo;
public static hook_AddBuff_BuffDef <4>__CharacterBody_AddBuff_BuffDef;
public static hook_RemoveBuff_BuffDef <5>__CharacterBody_RemoveBuff_BuffDef;
public static hook_AddTimedBuff_BuffDef_float <6>__CharacterBody_AddTimedBuff_BuffDef_float;
public static hook_AddTimedBuff_BuffDef_float_int <7>__CharacterBody_AddTimedBuff_BuffDef_float_int;
public static hook_Fire <8>__BulletAttack_Fire;
public static hook_FireSingle <9>__BulletAttack_FireSingle;
public static hook_PickCurrentTrack <10>__MusicController_PickCurrentTrack;
}
public const string PluginGUID = "com.bananastudio.randomizer";
public const string PluginName = "RiskofInsanity";
public const string PluginVersion = "1.0.0";
public static ManualLogSource log;
private Hook generateDropHook;
private Hook generatePickupHook;
public void Awake()
{
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Expected O, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Expected O, but got Unknown
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Expected O, but got Unknown
//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Expected O, but got Unknown
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Expected O, but got Unknown
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Expected O, but got Unknown
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Expected O, but got Unknown
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Expected O, but got Unknown
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"Randomizer Mod loaded!");
log = ((BaseUnityPlugin)this).Logger;
RandomConfigs.SetupConfigs(((BaseUnityPlugin)this).Config);
try
{
MethodInfo method = typeof(PickupDropTable).GetMethod("GenerateDrop", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method2 = typeof(ItemRandomizer).GetMethod("PickupDropTable_GenerateDrop", BindingFlags.Static | BindingFlags.Public);
if (method != null && method2 != null)
{
generateDropHook = new Hook((MethodBase)method, method2);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Hooked GenerateDrop");
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"Could not find methods - GenerateDrop: {method != null}, Hook: {method2 != null}");
}
MethodInfo method3 = typeof(PickupDropTable).GetMethod("GeneratePickup", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method4 = typeof(ItemRandomizer).GetMethod("PickupDropTable_GeneratePickup", BindingFlags.Static | BindingFlags.Public);
if (method3 != null && method4 != null)
{
generatePickupHook = new Hook((MethodBase)method3, method4);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Hooked GeneratePickup");
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"Could not find methods - GeneratePickup: {method3 != null}, Hook: {method4 != null}");
}
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"Error setting up pickup hooks: {arg}");
}
object obj = <>O.<0>__MasterSummon_Perform;
if (obj == null)
{
hook_Perform val = EnemyRandomizer.MasterSummon_Perform;
<>O.<0>__MasterSummon_Perform = val;
obj = (object)val;
}
MasterSummon.Perform += (hook_Perform)obj;
object obj2 = <>O.<1>__Run_PickNextStageScene;
if (obj2 == null)
{
hook_PickNextStageScene val2 = StageRandomizer.Run_PickNextStageScene;
<>O.<1>__Run_PickNextStageScene = val2;
obj2 = (object)val2;
}
Run.PickNextStageScene += (hook_PickNextStageScene)obj2;
Run.Start += new hook_Start(Run_Start);
object obj3 = <>O.<2>__ProjectileManager_FireProjectileServer;
if (obj3 == null)
{
hook_FireProjectileServer val3 = ProjectileRandomizer.ProjectileManager_FireProjectileServer;
<>O.<2>__ProjectileManager_FireProjectileServer = val3;
obj3 = (object)val3;
}
ProjectileManager.FireProjectileServer += (hook_FireProjectileServer)obj3;
object obj4 = <>O.<3>__ProjectileManager_FireProjectile_FireProjectileInfo;
if (obj4 == null)
{
hook_FireProjectile_FireProjectileInfo val4 = ProjectileRandomizer.ProjectileManager_FireProjectile_FireProjectileInfo;
<>O.<3>__ProjectileManager_FireProjectile_FireProjectileInfo = val4;
obj4 = (object)val4;
}
ProjectileManager.FireProjectile_FireProjectileInfo += (hook_FireProjectile_FireProjectileInfo)obj4;
object obj5 = <>O.<4>__CharacterBody_AddBuff_BuffDef;
if (obj5 == null)
{
hook_AddBuff_BuffDef val5 = BuffRandomizer.CharacterBody_AddBuff_BuffDef;
<>O.<4>__CharacterBody_AddBuff_BuffDef = val5;
obj5 = (object)val5;
}
CharacterBody.AddBuff_BuffDef += (hook_AddBuff_BuffDef)obj5;
object obj6 = <>O.<5>__CharacterBody_RemoveBuff_BuffDef;
if (obj6 == null)
{
hook_RemoveBuff_BuffDef val6 = BuffRandomizer.CharacterBody_RemoveBuff_BuffDef;
<>O.<5>__CharacterBody_RemoveBuff_BuffDef = val6;
obj6 = (object)val6;
}
CharacterBody.RemoveBuff_BuffDef += (hook_RemoveBuff_BuffDef)obj6;
object obj7 = <>O.<6>__CharacterBody_AddTimedBuff_BuffDef_float;
if (obj7 == null)
{
hook_AddTimedBuff_BuffDef_float val7 = BuffRandomizer.CharacterBody_AddTimedBuff_BuffDef_float;
<>O.<6>__CharacterBody_AddTimedBuff_BuffDef_float = val7;
obj7 = (object)val7;
}
CharacterBody.AddTimedBuff_BuffDef_float += (hook_AddTimedBuff_BuffDef_float)obj7;
object obj8 = <>O.<7>__CharacterBody_AddTimedBuff_BuffDef_float_int;
if (obj8 == null)
{
hook_AddTimedBuff_BuffDef_float_int val8 = BuffRandomizer.CharacterBody_AddTimedBuff_BuffDef_float_int;
<>O.<7>__CharacterBody_AddTimedBuff_BuffDef_float_int = val8;
obj8 = (object)val8;
}
CharacterBody.AddTimedBuff_BuffDef_float_int += (hook_AddTimedBuff_BuffDef_float_int)obj8;
object obj9 = <>O.<8>__BulletAttack_Fire;
if (obj9 == null)
{
hook_Fire val9 = HitscanRandomizer.BulletAttack_Fire;
<>O.<8>__BulletAttack_Fire = val9;
obj9 = (object)val9;
}
BulletAttack.Fire += (hook_Fire)obj9;
object obj10 = <>O.<9>__BulletAttack_FireSingle;
if (obj10 == null)
{
hook_FireSingle val10 = HitscanRandomizer.BulletAttack_FireSingle;
<>O.<9>__BulletAttack_FireSingle = val10;
obj10 = (object)val10;
}
BulletAttack.FireSingle += (hook_FireSingle)obj10;
object obj11 = <>O.<10>__MusicController_PickCurrentTrack;
if (obj11 == null)
{
hook_PickCurrentTrack val11 = MusicRandomizer.MusicController_PickCurrentTrack;
<>O.<10>__MusicController_PickCurrentTrack = val11;
obj11 = (object)val11;
}
MusicController.PickCurrentTrack += (hook_PickCurrentTrack)obj11;
MasterCatalog.Init += new hook_Init(MasterCatalog_Init);
ItemCatalog.Init += new hook_Init(ItemCatalog_Init);
BuffCatalog.Init += new hook_Init(BuffCatalog_Init);
ProjectileCatalog.Init += new hook_Init(ProjectileCatalog_Init);
}
private void ProjectileCatalog_Init(orig_Init orig)
{
orig.Invoke();
RandomConfigs.SetupBlacklistOptionsProjectile(((BaseUnityPlugin)this).Config);
}
private void BuffCatalog_Init(orig_Init orig)
{
orig.Invoke();
RandomConfigs.SetupBlacklistOptionsBuff(((BaseUnityPlugin)this).Config);
}
private void ItemCatalog_Init(orig_Init orig)
{
orig.Invoke();
RandomConfigs.SetupBlacklistOptionsItem(((BaseUnityPlugin)this).Config);
}
private void MasterCatalog_Init(orig_Init orig)
{
orig.Invoke();
RandomConfigs.SetupBlacklistOptionsMonsters(((BaseUnityPlugin)this).Config);
}
private void Update()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!Input.GetKeyDown((KeyCode)284))
{
return;
}
PlayerCharacterMasterController val = PlayerCharacterMasterController.instances[0];
CharacterMaster master = val.master;
MinionGroup val2 = MinionGroup.FindGroup(((NetworkBehaviour)master).netId);
if (val2 == null)
{
return;
}
MinionOwnership[] members = val2.members;
foreach (MinionOwnership val3 in members)
{
if ((Object)(object)val3 != (Object)null)
{
CharacterMaster component = ((Component)val3).GetComponent<CharacterMaster>();
if ((Object)(object)component != (Object)null)
{
CharacterBody body = component.GetBody();
((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)body).name);
}
}
}
}
private void Run_Start(orig_Start orig, Run self)
{
RandomConfigs.SetupBlacklistOptionsHitscan(((BaseUnityPlugin)this).Config);
RandomConfigs.SetupBlacklistOptionsProjectile(((BaseUnityPlugin)this).Config);
RandomConfigs.SetupBlacklistOptionsBuff(((BaseUnityPlugin)this).Config);
RandomConfigs.SetupBlacklistOptionsItem(((BaseUnityPlugin)this).Config);
EnemyRandomizer.Init();
ProjectileRandomizer.Init();
BulletAttackCatalog.Init();
ItemRandomizer.Init();
MusicRandomizer.Init();
BuffRandomizer.Init();
orig.Invoke(self);
}
private void OnDestroy()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
Hook obj = generateDropHook;
if (obj != null)
{
obj.Dispose();
}
Hook obj2 = generatePickupHook;
if (obj2 != null)
{
obj2.Dispose();
}
object obj3 = <>O.<0>__MasterSummon_Perform;
if (obj3 == null)
{
hook_Perform val = EnemyRandomizer.MasterSummon_Perform;
<>O.<0>__MasterSummon_Perform = val;
obj3 = (object)val;
}
MasterSummon.Perform -= (hook_Perform)obj3;
}
public static HashSet<string> GetBlacklist()
{
return new HashSet<string>
{
"ItemIndex.HealthDecay", "ItemIndex.MinHealthPercentage", "ItemIndex.Ghost", "ItemIndex.GummyCloneIdentifier", "ItemIndex.TransferDebuffOnHit", "ItemIndex.TonicAffliction", "ItemIndex.InvadingDoppelganger", "ItemIndex.Junk", "ItemIndex.UseAmbientLevel", "ItemIndex.VoidmanPassiveItem",
"ItemIndex.ConvertCritChanceToCritDamage", "ItemIndex.CutHp", "ItemIndex.ExtraLifeVoidConsumed", "ItemIndex.AdaptiveArmor", "ItemIndex.MonsoonPlayerHelper", "ItemIndex.TeleportWhenOob", "ItemIndex.RandomlyLunar", "ItemIndex.BurnNearby", "ItemIndex.ExtraLifeConsumed", "ItemIndex.FragileDamageBonusConsumed",
"ItemIndex.HealingPotionConsumed", "ItemIndex.AACannon", "ItemIndex.CrippleWardOnLevel", "ItemIndex.DroneDynamiteDisplay", "ItemIndex.DrizzlePlayerHelper", "ItemIndex.DroneWeaponsDisplay1", "ItemIndex.DroneWeaponsDisplay2", "ItemIndex.EmpowerAlways", "ItemIndex.LemurianHarness", "ItemIndex.LunarWings",
"ItemIndex.MageAttunement", "ItemIndex.MinionLeash", "ItemIndex.PlantOnHit", "ItemIndex.PlasmaCore", "ItemIndex.TeamSizeDamageBonus", "ItemIndex.DroneUpgradeHidden", "ItemIndex.CritHeal", "ItemIndex.SkullCounter", "ItemIndex.TempestOnKill", "DroneIndex.DroneCommander",
"DroneIndex.BackupDrone", "DroneIndex.EquipmentDrone", "DroneIndex.BomberDrone", "DroneIndex.DTGunnerDrone", "DroneIndex.DTHaulerDrone", "DroneIndex.DTHealDrone", "DroneIndex.MegaDrone", "EquipmentIndex.EliteSecretSpeedEquipment", "EquipmentIndex.EliteGoldEquipment", "EquipmentIndex.Enigma",
"EquipmentIndex.IrradiatingLaser", "EquipmentIndex.LunarPotion", "EquipmentIndex.OrbOnUse", "EquipmentIndex.OrbitalLaser", "EquipmentIndex.SoulJar", "EquipmentIndex.GhostGun"
};
}
public static HashSet<string> GetForbiddenMasters()
{
return new HashSet<string>
{
"MiniVoidRaidCrabMasterBase", "MiniVoidRaidCrabMasterPhase1", "MiniVoidRaidCrabMasterPhase2", "VoidRaidCrabJointMaster", "VoidRaidCrabMaster", "SolusHeartMaster", "SolusHeartMaster_Offering", "SolusMineMaster", "FalseSonBossLunarShardBrokenMaster", "MajorConstructMaster",
"NullifierAllyMaster", "VoidJailerAllyMaster", "VoidBarnacleAllyMaster", "MinorConstructAttachableMaster", "ArchWispMaster", "ParentPodMaster", "DTHaulerDroneMaster", "DTGunnerDroneMaster", "DTHeallingDroneMaster", "ArtifactShellMaster",
"BrotherHauntMaster", "LemurianBruiserMasterFire", "LemurianBruiserMasterIce", "LemurianBruiserMasterHaunted", "LemurianBruiserMasterPoison", "ShopkeeperMaster", "SolusVendorMaster", "EngiBeamTurretMaster", "RailgunnerMaster", "PlayerMaster"
};
}
public static HashSet<string> GetForbiddenProjectiles()
{
return new HashSet<string>
{
"AACannon", "BeetleGrubMine", "BellBallSmall", "BellDevice", "EngiMineDeployer", "EngiSeekerGrenadeProjectile", "Funball", "GatewayProjectile", "GummyCloneProjectle", "HaulerThrowProjectile",
"LoaderHook", "LoaderYankHook", "MinorConstructOnKillProjectile", "PaladinBigRocket", "PlasmaCore", "RedAffixMissileProjectile", "Rocket", "ScoutGrenade", "SoulSearchGhost", "SoulSearchProjectile",
"Spine", "ThrownObjectProjectile", "ThrownObjectProjectileNoStun", "ToolbotDroneHeal", "ToolbotDroneStun", "TransferDebuffOnHitProjectile", "TreebotPounderProjectile", "VultureHunterXiSpearProjectileTeleported"
};
}
public static bool isBlacklistedEnemy(string name)
{
if (RandomConfigs.blacklist.TryGetValue(name, out var value))
{
return value.Value;
}
return GetForbiddenMasters().Contains(name);
}
}
}
namespace RandomizerMod.RandomizerScripts.StageRandomizers
{
public class StageRandomizer
{
public static void Run_PickNextStageScene(orig_PickNextStageScene orig, Run self, WeightedSelection<SceneDef> choices)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, choices);
if (RandomConfigs.randomizeStages.Value)
{
SceneDef[] array = ((IEnumerable<SceneDef>)(object)SceneCatalog.allSceneDefs).Where((SceneDef x) => (int)x.sceneType == 1 && !x.baseSceneName.ToLower().Contains("simulacrum") && x.nameToken != "MAP_INFINITETOWER_TITLE").ToArray();
WeightedSelection<SceneDef> val = new WeightedSelection<SceneDef>(8);
SceneDef[] array2 = array;
foreach (SceneDef val2 in array2)
{
RandomizerPlugin.log.LogInfo((object)val2.nameToken);
val.AddChoice(val2, 1f);
}
orig.Invoke(self, val);
}
}
}
}
namespace RandomizerMod.RandomizerScripts.ProjectileRandomizers
{
public class BulletAttackIdentifier
{
public EffectIndex TracerEffectIndex;
public EffectIndex HitEffectIndex;
public DamageType DamageType;
public BulletAttackFlags Flags;
public BulletAttackIdentifier(EffectIndex tracerEffectIndex, EffectIndex hitEffectIndex, DamageType damageType, BulletAttackFlags flags)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
TracerEffectIndex = tracerEffectIndex;
HitEffectIndex = hitEffectIndex;
DamageType = damageType;
Flags = flags;
}
public string GetBlacklistKey()
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
try
{
object obj;
if ((int)TracerEffectIndex == -1)
{
obj = "NoTracer";
}
else
{
EffectDef effectDef = EffectCatalog.GetEffectDef(TracerEffectIndex);
if (effectDef == null)
{
obj = null;
}
else
{
GameObject prefab = effectDef.prefab;
obj = ((prefab != null) ? ((Object)prefab).name : null);
}
if (obj == null)
{
obj = "NoTracer";
}
}
string text = (string)obj;
object obj2;
if ((int)HitEffectIndex == -1)
{
obj2 = "NoHit";
}
else
{
EffectDef effectDef2 = EffectCatalog.GetEffectDef(HitEffectIndex);
if (effectDef2 == null)
{
obj2 = null;
}
else
{
GameObject prefab2 = effectDef2.prefab;
obj2 = ((prefab2 != null) ? ((Object)prefab2).name : null);
}
if (obj2 == null)
{
obj2 = "NoHit";
}
}
string text2 = (string)obj2;
return $"{text}_{text2}_{DamageType}_{Flags}";
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[BulletAttackIdentifier] Error generating blacklist key: " + ex.Message));
return "ErrorGeneratingKey";
}
}
public bool IsBlacklisted()
{
try
{
string blacklistKey = GetBlacklistKey();
HashSet<string> blacklistedHitscans = RandomConfigs.GetBlacklistedHitscans();
return blacklistedHitscans.Contains(blacklistKey);
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[BulletAttackIdentifier] Error checking blacklist status: " + ex.Message));
return false;
}
}
}
public class BulletAttackCatalog
{
public static readonly BulletAttackCatalog Instance = new BulletAttackCatalog();
public static List<BulletAttackIdentifier> bulletAttackIdentifiers = new List<BulletAttackIdentifier>();
public static Dictionary<BulletAttackIdentifier, BulletAttackIdentifier> toRandomize = new Dictionary<BulletAttackIdentifier, BulletAttackIdentifier>();
[SystemInitializer(new Type[] { typeof(EffectCatalog) })]
public static void Init()
{
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Expected O, but got Unknown
bulletAttackIdentifiers.Clear();
initIdentifier("TracerBanditPistol", "HitsparkBandit2Pistol", (DamageType)524292);
initIdentifier("TracerBanditPistol", "HitsparkBandit2Pistol", (DamageType)268959744);
initIdentifier(null, "OmniImpactVFXSlash", (DamageType)0);
initIdentifier("TracerClayBruiserMinigun", "Hitspark1", (DamageType)0);
initIdentifier("TracerCommandoBoost", "HitsparkCommandoBarrage", (DamageType)32);
initIdentifier("TracerBanditPistol", "HitsparkBanditPistol", (DamageType)4);
initIdentifier("TracerCommandoDefault", "HitsparkCommando", (DamageType)0);
initIdentifier("TracerBanditShotgun", "HitsparkBandit", (DamageType)0);
initIdentifier("TracerBanditPistol", "WeakPointProcEffect", (DamageType)0);
initIdentifier("TracerNoSmoke", "Hitspark1", (DamageType)0);
initIdentifier("TracerCommandoBoost", "MuzzleflashBarrage", (DamageType)0);
initIdentifier(null, "Hitspark1", (DamageType)8);
initIdentifier("TracerEngiTurret", "ImpactEngiTurret", (DamageType)0);
initIdentifier("TracerBandit2Rifle", "HitsparkBandit", (DamageType)0);
initIdentifier("TracerBandit2Shotgun", "HitsparkBandit", (DamageType)0);
initIdentifier("TracerCaptainShotgun", "HitsparkCaptainShotgun", (DamageType)0);
initIdentifier("TracerCommandoShotgun", "HitsparkCommandoShotgun", (DamageType)0);
initIdentifier("TracerHuntressSnipe", "OmniImpactVFXHuntress", (DamageType)0);
initIdentifier("TracerRailgunCryo", "ImpactRailgun", (DamageType)256, BulletAttackFlags.Sniper);
initIdentifier("TracerRailgun", "ImpactRailgun", (DamageType)0, BulletAttackFlags.Sniper);
initIdentifier("TracerRailgunLight", "ImpactRailgunLight", (DamageType)0, BulletAttackFlags.Sniper);
initIdentifier("TracerRailgunSuper", "ImpactRailgun", (DamageType)0, BulletAttackFlags.Sniper);
initIdentifier("TracerToolbotRebar", "ImpactSpear", (DamageType)0);
initIdentifier("TracerGoldGat", null, (DamageType)0);
initIdentifier("TracerLaserTurbine", null, (DamageType)0);
initIdentifier("TracerLaserTurbineReturn", null, (DamageType)0);
initIdentifier(null, "MissileExplosionVFX", (DamageType)0);
initIdentifier(null, "MissileExplosionVFX", (DamageType)128);
initIdentifier("TracerLunarWispMinigun", "LunarWispMinigunHitspark", (DamageType)0);
initIdentifier("TracerMageLightningLaser", "LightningFlash", (DamageType)0);
initIdentifier("TracerToolbotNails", "ImpactNailgun", (DamageType)0);
initIdentifier(null, "LaserImpactEffect", (DamageType)0);
initIdentifier(null, "VoidSurvivorBeamImpactCorrupt", (DamageType)0);
initIdentifier("VoidSurvivorBeamTracer", "VoidSurvivorBeamImpact", (DamageType)8);
initIdentifier("TracerEmbers", "OmniImpactVFX", (DamageType)0);
initIdentifier("TracerNanoPistolCharged", "NanoPistolImpactVFX", (DamageType)0);
initIdentifier("TracerNanoPistol", "NanoPistolImpactVFX", (DamageType)0);
toRandomize.Clear();
if (RandomConfigs.randomizeHitscans.Value != RandomizeOption.UniquePerKind && RandomConfigs.randomizeHitscans.Value != RandomizeOption.UniquePerKindWithDuplicates)
{
return;
}
try
{
Xoroshiro128Plus val = new Xoroshiro128Plus(Run.instance.seed);
List<BulletAttackIdentifier> list = new List<BulletAttackIdentifier>();
foreach (BulletAttackIdentifier bulletAttackIdentifier3 in bulletAttackIdentifiers)
{
if (bulletAttackIdentifier3 != null && !bulletAttackIdentifier3.IsBlacklisted())
{
list.Add(bulletAttackIdentifier3);
}
}
if (list.Count == 0)
{
RandomizerPlugin.log.LogWarning((object)"[HitRandomizer] All hitscan identifiers are blacklisted! Using full list instead.");
list = new List<BulletAttackIdentifier>(bulletAttackIdentifiers);
}
List<BulletAttackIdentifier> list2 = new List<BulletAttackIdentifier>(list);
bool flag = RandomConfigs.randomizeHitscans.Value == RandomizeOption.UniquePerKindWithDuplicates;
foreach (BulletAttackIdentifier bulletAttackIdentifier4 in bulletAttackIdentifiers)
{
if (bulletAttackIdentifier4 == null || toRandomize.ContainsKey(bulletAttackIdentifier4))
{
continue;
}
if (list2.Count == 0)
{
if (!flag)
{
break;
}
list2 = new List<BulletAttackIdentifier>(list);
}
BulletAttackIdentifier bulletAttackIdentifier = list2[val.RangeInt(0, list2.Count)];
toRandomize.Add(bulletAttackIdentifier4, bulletAttackIdentifier);
if (!flag)
{
list2.Remove(bulletAttackIdentifier);
}
}
RandomizerPlugin.log.LogInfo((object)$"[HitRandomizer] Initialized {toRandomize.Count} hitscan mappings from {list.Count} available identifiers.");
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[HitRandomizer] Error during hitscan randomization initialization: " + ex.Message));
}
static EffectIndex findEffectIndex(string name)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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)
if (string.IsNullOrEmpty(name))
{
return (EffectIndex)(-1);
}
try
{
for (int i = 0; i < EffectCatalog.effectCount; i++)
{
EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)i);
if (Object.op_Implicit((Object)(object)((effectDef != null) ? effectDef.prefab : null)) && ((Object)effectDef.prefab).name == name)
{
return effectDef.index;
}
}
}
catch (Exception ex2)
{
RandomizerPlugin.log.LogError((object)("[HitRandomizer] Error finding effect index for " + name + ": " + ex2.Message));
}
return (EffectIndex)(-1);
}
static void initIdentifier(string tracerEffectName, string hitEffectName, DamageType damageType = 0u, BulletAttackFlags flags = BulletAttackFlags.None)
{
//IL_0020: 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_002b: 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)
try
{
RandomizerPlugin.log.LogInfo((object)("[HitRandomizer] Generating bulletattack for " + tracerEffectName + " with effect name " + hitEffectName));
BulletAttackIdentifier bulletAttackIdentifier2 = new BulletAttackIdentifier(findEffectIndex(tracerEffectName), findEffectIndex(hitEffectName), damageType, flags);
RandomizerPlugin.log.LogInfo((object)("[HitRandomizer] Generated bulletattack for " + tracerEffectName + $"effect index is {bulletAttackIdentifier2.HitEffectIndex}"));
bulletAttackIdentifiers.Add(bulletAttackIdentifier2);
}
catch (Exception ex3)
{
RandomizerPlugin.log.LogError((object)("[HitRandomizer] Error initializing identifier for " + tracerEffectName + "/" + hitEffectName + ": " + ex3.Message));
}
}
}
public static bool TryGetIdentifier(BulletAttack bulletAttack, out BulletAttackIdentifier identifier)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Invalid comparison between Unknown and I4
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
identifier = null;
try
{
RandomizerPlugin.log.LogInfo((object)$"[HitscanRandomizer] TryGetIdentifier - bulletAttackIdentifiers.Count={bulletAttackIdentifiers.Count}");
GameObject tracerEffectPrefab = bulletAttack.tracerEffectPrefab;
GameObject hitEffectPrefab = bulletAttack.hitEffectPrefab;
for (int i = 0; i < bulletAttackIdentifiers.Count; i++)
{
BulletAttackIdentifier bulletAttackIdentifier = bulletAttackIdentifiers[i];
object obj;
if ((int)bulletAttackIdentifier.TracerEffectIndex == -1)
{
obj = null;
}
else
{
EffectDef effectDef = EffectCatalog.GetEffectDef(bulletAttackIdentifier.TracerEffectIndex);
obj = ((effectDef != null) ? effectDef.prefab : null);
}
GameObject val = (GameObject)obj;
object obj2;
if ((int)bulletAttackIdentifier.HitEffectIndex == -1)
{
obj2 = null;
}
else
{
EffectDef effectDef2 = EffectCatalog.GetEffectDef(bulletAttackIdentifier.HitEffectIndex);
obj2 = ((effectDef2 != null) ? effectDef2.prefab : null);
}
GameObject val2 = (GameObject)obj2;
if (i == 0)
{
RandomizerPlugin.log.LogInfo((object)("[HitscanRandomizer] TryGetIdentifier - Looking for tracer=" + (((tracerEffectPrefab != null) ? ((Object)tracerEffectPrefab).name : null) ?? "null") + ", hit=" + (((hitEffectPrefab != null) ? ((Object)hitEffectPrefab).name : null) ?? "null")));
RandomizerPlugin.log.LogInfo((object)("[HitscanRandomizer] TryGetIdentifier - First candidate: tracer=" + (((val != null) ? ((Object)val).name : null) ?? "null") + ", hit=" + (((val2 != null) ? ((Object)val2).name : null) ?? "null")));
}
if ((Object)(object)val == (Object)(object)tracerEffectPrefab && (Object)(object)val2 == (Object)(object)hitEffectPrefab)
{
identifier = bulletAttackIdentifier;
return true;
}
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[HitscanRandomizer] Error in TryGetIdentifier: " + ex.Message));
}
return false;
}
public static BulletAttackIdentifier RandomizeAttack(BulletAttackIdentifier attack)
{
try
{
switch (RandomConfigs.randomizeHitscans.Value)
{
case RandomizeOption.Disabled:
return attack;
case RandomizeOption.UniquePerKind:
case RandomizeOption.UniquePerKindWithDuplicates:
{
BulletAttackIdentifier value;
return toRandomize.TryGetValue(attack, out value) ? value : attack;
}
case RandomizeOption.AlwaysUnique:
{
if (bulletAttackIdentifiers.Count == 0)
{
return attack;
}
List<BulletAttackIdentifier> list = new List<BulletAttackIdentifier>();
foreach (BulletAttackIdentifier bulletAttackIdentifier in bulletAttackIdentifiers)
{
if (bulletAttackIdentifier != null && !bulletAttackIdentifier.IsBlacklisted())
{
list.Add(bulletAttackIdentifier);
}
}
if (list.Count == 0)
{
RandomizerPlugin.log.LogWarning((object)"[HitscanRandomizer] All hitscan identifiers are blacklisted! Using original attack.");
return attack;
}
return list[Random.Range(0, list.Count)];
}
default:
return attack;
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[HitscanRandomizer] Error in RandomizeAttack: " + ex.Message));
return attack;
}
}
public static void ApplyIdentifier(BulletAttack bulletAttack, BulletAttackIdentifier identifier)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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)
//IL_008a: 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)
try
{
if ((int)identifier.TracerEffectIndex != -1)
{
EffectDef effectDef = EffectCatalog.GetEffectDef(identifier.TracerEffectIndex);
bulletAttack.tracerEffectPrefab = ((effectDef != null) ? effectDef.prefab : null);
}
if ((int)identifier.HitEffectIndex != -1)
{
EffectDef effectDef2 = EffectCatalog.GetEffectDef(identifier.HitEffectIndex);
bulletAttack.hitEffectPrefab = ((effectDef2 != null) ? effectDef2.prefab : null);
}
DamageTypeCombo damageType = default(DamageTypeCombo);
((DamageTypeCombo)(ref damageType))..ctor(DamageTypeCombo.op_Implicit(identifier.DamageType), bulletAttack.damageType.damageTypeExtended, bulletAttack.damageType.damageSource);
bulletAttack.damageType = damageType;
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[HitscanRandomizer] Error applying identifier to bullet attack: " + ex.Message));
}
}
}
[Flags]
public enum BulletAttackFlags : uint
{
None = 0u,
Sniper = 1u
}
public class HitscanRandomizer
{
public static void BulletAttack_Fire(orig_Fire orig, BulletAttack self)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
if (RandomConfigs.randomizeHitscans.Value == RandomizeOption.Disabled)
{
orig.Invoke(self);
return;
}
try
{
ManualLogSource log = RandomizerPlugin.log;
GameObject tracerEffectPrefab = self.tracerEffectPrefab;
string arg = ((tracerEffectPrefab != null) ? ((Object)tracerEffectPrefab).name : null) ?? "null";
GameObject hitEffectPrefab = self.hitEffectPrefab;
log.LogInfo((object)string.Format("[HitscanRandomizer] BulletAttack.Fire called. tracerEffectPrefab={0}, hitEffectPrefab={1}, damageType={2}", arg, ((hitEffectPrefab != null) ? ((Object)hitEffectPrefab).name : null) ?? "null", self.damageType));
if (BulletAttackCatalog.TryGetIdentifier(self, out var identifier))
{
RandomizerPlugin.log.LogInfo((object)$"[HitscanRandomizer] Fire - Matched identifier. Tracer={identifier.TracerEffectIndex}, Hit={identifier.HitEffectIndex}, DamageType={identifier.DamageType}");
BulletAttackIdentifier bulletAttackIdentifier = BulletAttackCatalog.RandomizeAttack(identifier);
RandomizerPlugin.log.LogInfo((object)$"[HitscanRandomizer] Fire - Randomized to. Tracer={bulletAttackIdentifier.TracerEffectIndex}, Hit={bulletAttackIdentifier.HitEffectIndex}, DamageType={bulletAttackIdentifier.DamageType}");
BulletAttackCatalog.ApplyIdentifier(self, bulletAttackIdentifier);
}
else
{
RandomizerPlugin.log.LogInfo((object)"[HitscanRandomizer] Fire - No identifier match found, skipping.");
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[HitscanRandomizer] Error in BulletAttack_Fire hook: " + ex.Message + "\n" + ex.StackTrace));
}
orig.Invoke(self);
}
public static void BulletAttack_FireSingle(orig_FireSingle orig, BulletAttack self, FireSingleArgs args)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
if (RandomConfigs.randomizeHitscans.Value == RandomizeOption.Disabled)
{
orig.Invoke(self, args);
return;
}
try
{
ManualLogSource log = RandomizerPlugin.log;
GameObject tracerEffectPrefab = self.tracerEffectPrefab;
string arg = ((tracerEffectPrefab != null) ? ((Object)tracerEffectPrefab).name : null) ?? "null";
GameObject hitEffectPrefab = self.hitEffectPrefab;
log.LogInfo((object)string.Format("[HitscanRandomizer] BulletAttack.FireSingle called. tracerEffectPrefab={0}, hitEffectPrefab={1}, damageType={2}", arg, ((hitEffectPrefab != null) ? ((Object)hitEffectPrefab).name : null) ?? "null", self.damageType));
if (BulletAttackCatalog.TryGetIdentifier(self, out var identifier))
{
RandomizerPlugin.log.LogInfo((object)$"[HitscanRandomizer] FireSingle - Matched identifier. Tracer={identifier.TracerEffectIndex}, Hit={identifier.HitEffectIndex}, DamageType={identifier.DamageType}");
BulletAttackIdentifier bulletAttackIdentifier = BulletAttackCatalog.RandomizeAttack(identifier);
RandomizerPlugin.log.LogInfo((object)$"[HitscanRandomizer] FireSingle - Randomized to. Tracer={bulletAttackIdentifier.TracerEffectIndex}, Hit={bulletAttackIdentifier.HitEffectIndex}, DamageType={bulletAttackIdentifier.DamageType}");
BulletAttackCatalog.ApplyIdentifier(self, bulletAttackIdentifier);
}
else
{
RandomizerPlugin.log.LogInfo((object)"[HitscanRandomizer] FireSingle - No identifier match found, skipping.");
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[HitscanRandomizer] Error in BulletAttack_FireSingle hook: " + ex.Message + "\n" + ex.StackTrace));
}
orig.Invoke(self, args);
}
}
public class ProjectileRandomizer
{
public static Dictionary<GameObject, GameObject> projectileRandomized = new Dictionary<GameObject, GameObject>();
private static GameObject[] allPrefabs;
private static List<GameObject> movingProjectiles = new List<GameObject>();
private static List<GameObject> stationaryProjectiles = new List<GameObject>();
public static void Init()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
projectileRandomized.Clear();
movingProjectiles.Clear();
stationaryProjectiles.Clear();
allPrefabs = ProjectileCatalog.projectilePrefabs;
try
{
Xoroshiro128Plus val = new Xoroshiro128Plus(Run.instance.seed);
HashSet<string> blacklistedProjectiles = RandomConfigs.GetBlacklistedProjectiles();
if (RandomConfigs.separateStationaryProjectiles.Value || RandomConfigs.randomizeProjectiles.Value == RandomizeOption.UniquePerKind || RandomConfigs.randomizeProjectiles.Value == RandomizeOption.UniquePerKindWithDuplicates)
{
GameObject[] array = allPrefabs;
foreach (GameObject val2 in array)
{
try
{
if ((Object)(object)val2 == (Object)null)
{
continue;
}
if (blacklistedProjectiles.Contains(((Object)val2).name))
{
RandomizerPlugin.log.LogInfo((object)("[ProjectileRandomizer] Skipping blacklisted projectile: " + ((Object)val2).name));
continue;
}
ProjectileSimple component = val2.GetComponent<ProjectileSimple>();
if ((Object)(object)component != (Object)null && component.desiredForwardSpeed > 0f)
{
movingProjectiles.Add(val2);
}
else
{
stationaryProjectiles.Add(val2);
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error categorizing projectile " + (((val2 != null) ? ((Object)val2).name : null) ?? "null") + ": " + ex.Message));
}
}
}
if (RandomConfigs.randomizeProjectiles.Value != RandomizeOption.UniquePerKind && RandomConfigs.randomizeProjectiles.Value != RandomizeOption.UniquePerKindWithDuplicates)
{
return;
}
bool flag = RandomConfigs.randomizeProjectiles.Value == RandomizeOption.UniquePerKindWithDuplicates;
if (RandomConfigs.separateStationaryProjectiles.Value)
{
if (movingProjectiles.Count == 0)
{
RandomizerPlugin.log.LogWarning((object)"[ProjectileRandomizer] No non-blacklisted moving projectiles available!");
}
else
{
List<GameObject> list = new List<GameObject>(movingProjectiles);
foreach (GameObject movingProjectile in movingProjectiles)
{
try
{
if (projectileRandomized.ContainsKey(movingProjectile))
{
continue;
}
if (list.Count == 0)
{
if (!flag)
{
break;
}
list = new List<GameObject>(movingProjectiles);
}
GameObject val3 = list[val.RangeInt(0, list.Count)];
projectileRandomized.Add(movingProjectile, val3);
if (!flag)
{
list.Remove(val3);
}
}
catch (Exception ex2)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error randomizing moving projectile " + (((movingProjectile != null) ? ((Object)movingProjectile).name : null) ?? "null") + ": " + ex2.Message));
}
}
}
if (stationaryProjectiles.Count == 0)
{
RandomizerPlugin.log.LogWarning((object)"[ProjectileRandomizer] No non-blacklisted stationary projectiles available!");
}
else
{
List<GameObject> list2 = new List<GameObject>(stationaryProjectiles);
foreach (GameObject stationaryProjectile in stationaryProjectiles)
{
try
{
if (projectileRandomized.ContainsKey(stationaryProjectile))
{
continue;
}
if (list2.Count == 0)
{
if (!flag)
{
break;
}
list2 = new List<GameObject>(stationaryProjectiles);
}
GameObject val4 = list2[val.RangeInt(0, list2.Count)];
projectileRandomized.Add(stationaryProjectile, val4);
if (!flag)
{
list2.Remove(val4);
}
}
catch (Exception ex3)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error randomizing stationary projectile " + (((stationaryProjectile != null) ? ((Object)stationaryProjectile).name : null) ?? "null") + ": " + ex3.Message));
}
}
}
}
else
{
List<GameObject> list3 = new List<GameObject>();
GameObject[] array2 = allPrefabs;
foreach (GameObject val5 in array2)
{
if ((Object)(object)val5 != (Object)null && !blacklistedProjectiles.Contains(((Object)val5).name))
{
list3.Add(val5);
}
}
if (list3.Count == 0)
{
RandomizerPlugin.log.LogWarning((object)"[ProjectileRandomizer] All projectiles are blacklisted! Using full list instead.");
list3 = new List<GameObject>(allPrefabs);
}
List<GameObject> list4 = new List<GameObject>(list3);
GameObject[] array3 = allPrefabs;
foreach (GameObject val6 in array3)
{
try
{
if (projectileRandomized.ContainsKey(val6))
{
continue;
}
if (list4.Count == 0)
{
if (!flag)
{
break;
}
list4 = new List<GameObject>(list3);
}
GameObject val7 = list4[val.RangeInt(0, list4.Count)];
projectileRandomized.Add(val6, val7);
if (!flag)
{
list4.Remove(val7);
}
}
catch (Exception ex4)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error randomizing projectile " + (((val6 != null) ? ((Object)val6).name : null) ?? "null") + ": " + ex4.Message));
}
}
}
RandomizerPlugin.log.LogInfo((object)($"[ProjectileRandomizer] Initialized {projectileRandomized.Count} projectile mappings. " + $"Moving: {movingProjectiles.Count}, Stationary: {stationaryProjectiles.Count}"));
}
catch (Exception ex5)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error during projectile randomization initialization: " + ex5.Message));
}
}
private static GameObject Resolve(GameObject original)
{
try
{
HashSet<string> blacklistedProjectiles = RandomConfigs.GetBlacklistedProjectiles();
switch (RandomConfigs.randomizeProjectiles.Value)
{
case RandomizeOption.Disabled:
return original;
case RandomizeOption.UniquePerKind:
case RandomizeOption.UniquePerKindWithDuplicates:
{
if (projectileRandomized.TryGetValue(original, out var value))
{
return value;
}
if (RandomConfigs.separateStationaryProjectiles.Value)
{
ProjectileSimple component2 = original.GetComponent<ProjectileSimple>();
List<GameObject> list3 = (((Object)(object)component2 != (Object)null && component2.desiredForwardSpeed > 0f) ? movingProjectiles : stationaryProjectiles);
if (list3.Count > 0)
{
GameObject val2 = list3[Random.Range(0, list3.Count)];
projectileRandomized[original] = val2;
return val2;
}
}
return original;
}
case RandomizeOption.AlwaysUnique:
{
if (allPrefabs == null || allPrefabs.Length == 0)
{
return original;
}
if (RandomConfigs.separateStationaryProjectiles.Value)
{
ProjectileSimple component = original.GetComponent<ProjectileSimple>();
bool flag = (Object)(object)component != (Object)null && component.desiredForwardSpeed > 0f;
List<GameObject> list = (flag ? movingProjectiles : stationaryProjectiles);
if (list.Count > 0)
{
return list[Random.Range(0, list.Count)];
}
RandomizerPlugin.log.LogWarning((object)("[ProjectileRandomizer] No available projectiles in pool for " + (flag ? "moving" : "stationary") + " projectile " + (((original != null) ? ((Object)original).name : null) ?? "null")));
return original;
}
List<GameObject> list2 = new List<GameObject>();
GameObject[] array = allPrefabs;
foreach (GameObject val in array)
{
if ((Object)(object)val != (Object)null && !blacklistedProjectiles.Contains(((Object)val).name))
{
list2.Add(val);
}
}
if (list2.Count == 0)
{
RandomizerPlugin.log.LogWarning((object)"[ProjectileRandomizer] All projectiles are blacklisted! Using original.");
return original;
}
return list2[Random.Range(0, list2.Count)];
}
default:
return original;
}
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error in Resolve for " + (((original != null) ? ((Object)original).name : null) ?? "null") + ": " + ex.Message));
return original;
}
}
public static void ProjectileManager_FireProjectileServer(orig_FireProjectileServer orig, ProjectileManager self, FireProjectileInfo fireProjectileInfo, NetworkConnection clientAuthorityOwner, ushort predictionId, double fastForwardTime)
{
//IL_0004: 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)
try
{
fireProjectileInfo.projectilePrefab = Resolve(fireProjectileInfo.projectilePrefab);
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error in ProjectileManager_FireProjectileServer hook: " + ex.Message));
}
orig.Invoke(self, fireProjectileInfo, clientAuthorityOwner, predictionId, fastForwardTime);
}
public static void ProjectileManager_FireProjectile_FireProjectileInfo(orig_FireProjectile_FireProjectileInfo orig, ProjectileManager self, FireProjectileInfo fireProjectileInfo)
{
//IL_0004: 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)
try
{
fireProjectileInfo.projectilePrefab = Resolve(fireProjectileInfo.projectilePrefab);
}
catch (Exception ex)
{
RandomizerPlugin.log.LogError((object)("[ProjectileRandomizer] Error in ProjectileManager_FireProjectile_FireProjectileInfo hook: " + ex.Message));
}
orig.Invoke(self, fireProjectileInfo);
}
}
}
namespace RandomizerMod.RandomizerScripts.MusicRandomizers
{
public class MusicRandomizer
{
public static Dictionary<MusicTrackDef, MusicTrackDef> toRandomize = new Dictionary<MusicTrackDef, MusicTrackDef>();
private static MusicTrackDef[] allTracks;
public static void Init()
{
toRandomize.Clear();
allTracks = MusicTrackCatalog.musicTrackDefs;
if (RandomConfigs.randomizeMusic.Value != RandomizeOption.UniquePerKind && RandomConfigs.randomizeMusic.Value != RandomizeOption.UniquePerKindWithDuplicates)
{
return;
}
List<MusicTrackDef> list = new List<MusicTrackDef>(allTracks);
bool flag = RandomConfigs.randomizeMusic.Value == RandomizeOption.UniquePerKindWithDuplicates;
MusicTrackDef[] array = allTracks;
foreach (MusicTrackDef key in array)
{
if (!toRandomize.ContainsKey(key))
{
if (list.Count == 0)
{
break;
}
MusicTrackDef val = list[Random.Range(0, list.Count)];
toRandomize.Add(key, val);
if (!flag)
{
list.Remove(val);
}
}
}
}
public static void MusicController_PickCurrentTrack(orig_PickCurrentTrack orig, MusicController self, ref MusicTrackDef newTrack)
{
orig.Invoke(self, ref newTrack);
if ((Object)(object)newTrack == (Object)null)
{
return;
}
switch (RandomConfigs.randomizeMusic.Value)
{
case RandomizeOption.Disabled:
break;
case RandomizeOption.UniquePerKind:
case RandomizeOption.UniquePerKindWithDuplicates:
{
if (toRandomize.TryGetValue(newTrack, out var value))
{
newTrack = value;
}
break;
}
case RandomizeOption.AlwaysUnique:
if (allTracks != null && allTracks.Length != 0)
{
newTrack = allTracks[Random.Range(0, allTracks.Length)];
}
break;
}
}
}
}
namespace RandomizerMod.RandomizerScripts.ItemRandomizers
{
public class ItemRandomizer
{
public delegate PickupIndex orig_GenerateDrop(PickupDropTable self, Xoroshiro128Plus rng);
public delegate UniquePickup orig_GeneratePickup(PickupDropTable self, Xoroshiro128Plus rng);
private static Dictionary<PickupDef, PickupDef> toRandomize = new Dictionary<PickupDef, PickupDef>();
private static List<PickupDef> candidatePool = new List<PickupDef>();
private static List<PickupDef> equipmentPool = new List<PickupDef>();
public static void Init()
{
toRandomize.Clear();
candidatePool.Clear();
equipmentPool.Clear();
HashSet<string> blacklist = RandomizerPlugin.GetBlacklist();
bool droneBlacklist = RandomConfigs.randomizeDronePickups.Value;
List<PickupDef> list = (from p in PickupCatalog.allPickups
where !blacklist.Contains(p.internalName)
where (int)p.artifactIndex == -1 && (int)p.miscPickupIndex == -1 && (droneBlacklist || (int)p.droneIndex == -1)
select p).ToList();
if (RandomConfigs.randomizeEquipment.Value)
{
equipmentPool.AddRange(list.Where((PickupDef p) => (int)p.equipmentIndex != -1));
candidatePool.AddRange(list.Where((PickupDef p) => (int)p.equipmentIndex == -1));
}
else
{
candidatePool.AddRange(list);
}
if (RandomConfigs.randomizeItems.Value != RandomizeOption.UniquePerKind && RandomConfigs.randomizeItems.Value != RandomizeOption.UniquePerKindWithDuplicates)
{
return;
}
bool flag = RandomConfigs.randomizeItems.Value == RandomizeOption.UniquePerKindWithDuplicates;
List<PickupDef> list2 = new List<PickupDef>(candidatePool);
foreach (PickupDef item in candidatePool)
{
if (!toRandomize.ContainsKey(item))
{
if (list2.Count == 0)
{
break;
}
PickupDef val = list2[Random.Range(0, list2.Count)];
toRandomize.Add(item, val);
if (!flag)
{
list2.Remove(val);
}
}
}
if (!RandomConfigs.randomizeEquipment.Value || equipmentPool.Count <= 0)
{
return;
}
List<PickupDef> list3 = new List<PickupDef>(equipmentPool);
foreach (PickupDef item2 in equipmentPool)
{
if (!toRandomize.ContainsKey(item2))
{
if (list3.Count == 0)
{
break;
}
PickupDef val2 = list3[Random.Range(0, list3.Count)];
toRandomize.Add(item2, val2);
if (!flag)
{
list3.Remove(val2);
}
}
}
}
public static PickupIndex PickupDropTable_GenerateDrop(orig_GenerateDrop orig, PickupDropTable self, Xoroshiro128Plus rng)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
PickupIndex val = orig(self, rng);
if (val == PickupIndex.none || !((PickupIndex)(ref val)).isValid)
{
return val;
}
return ApplyPickupRandomization(val, rng);
}
public static UniquePickup PickupDropTable_GeneratePickup(orig_GeneratePickup orig, PickupDropTable self, Xoroshiro128Plus rng)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_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_007c: 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_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)
UniquePickup val = orig(self, rng);
if (val.pickupIndex == PickupIndex.none || !((PickupIndex)(ref val.pickupIndex)).isValid)
{
return val;
}
ItemDef itemDef = ItemCatalog.GetItemDef(((PickupIndex)(ref val.pickupIndex)).itemIndex);
if ((Object)(object)itemDef != (Object)null && itemDef.tags.Contains((ItemTag)33))
{
return val;
}
PickupIndex val2 = ApplyPickupRandomization(val.pickupIndex, rng);
return ((UniquePickup)(ref val)).WithPickupIndex(val2);
}
public static PickupIndex ApplyPickupRandomization(PickupIndex pickupIndex, Xoroshiro128Plus rng)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
//IL_002b: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Invalid comparison between Unknown and I4
//IL_0072: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if (RandomConfigs.randomizeItems.Value == RandomizeOption.Disabled)
{
return pickupIndex;
}
PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
if (pickupDef == null)
{
return pickupIndex;
}
if ((int)pickupDef.itemTier == 3 && !RandomConfigs.randomizeLunars.Value)
{
return pickupIndex;
}
HashSet<string> blacklist = RandomizerPlugin.GetBlacklist();
if (blacklist.Contains(pickupDef.internalName))
{
return pickupIndex;
}
bool flag = (int)pickupDef.equipmentIndex != -1;
switch (RandomConfigs.randomizeItems.Value)
{
case RandomizeOption.UniquePerKind:
case RandomizeOption.UniquePerKindWithDuplicates:
{
if (toRandomize.TryGetValue(pickupDef, out var value))
{
return value.pickupIndex;
}
return pickupIndex;
}
case RandomizeOption.AlwaysUnique:
{
List<PickupDef> list = ((flag && RandomConfigs.randomizeEquipment.Value) ? equipmentPool : candidatePool);
if (list.Count == 0)
{
return pickupIndex;
}
return list[rng.RangeInt(0, list.Count)].pickupIndex;
}
default:
return pickupIndex;
}
}
}
}
namespace RandomizerMod.RandomizerScripts.EnemyRandomizers
{
public class EnemyRandomizer
{
public static Dictionary<CharacterSpawnCard, CharacterSpawnCard> toRandomizeWith = new Dictionary<CharacterSpawnCard, CharacterSpawnCard>();
public static Dictionary<GameObject, GameObject> masterPrefabToRandomMaster = new Dictionary<GameObject, GameObject>();
public static void Init()
{
toRandomizeWith.Clear();
masterPrefabToRandomMaster.Clear();
if (RandomConfigs.randomizeEnemiesOption.Value == EnemyRandomOptions.Disabled || RandomConfigs.randomizeEnemiesOption.Value == EnemyRandomOptions.AlwaysUnique)
{
return;
}
CharacterSpawnCard[] source = (from c in Resources.FindObjectsOfTypeAll<CharacterSpawnCard>()
where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((SpawnCard)c).prefab)
select c).ToArray();
var array = (from <>h__TransparentIdentifier1 in source.Select((CharacterSpawnCard c) => new
{
c = c,
master = ((SpawnCard)c).prefab.GetComponent<CharacterMaster>()
}).Select(<>h__TransparentIdentifier0 =>
{
CharacterMaster master = <>h__TransparentIdentifier0.master;
object body;
if (master == null)
{
body = null;
}
else
{
GameObject bodyPrefab = master.bodyPrefab;
body = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
}
return new
{
<>h__TransparentIdentifier0 = <>h__TransparentIdentifier0,
body = (CharacterBody)body
};
})
where (Object)(object)<>h__TransparentIdentifier1.body != (Object)null && !RandomizerPlugin.isBlacklistedEnemy(((Object)((SpawnCard)<>h__TransparentIdentifier1.<>h__TransparentIdentifier0.c).prefab).name)
select new
{
card = <>h__TransparentIdentifier1.<>h__TransparentIdentifier0.c,
body = <>h__TransparentIdentifier1.body
}).ToArray();
List<CharacterSpawnCard> list = new List<CharacterSpawnCard>();
list.AddRange(array.Select(p => p.card));
var array2 = array;
foreach (var anon in array2)
{
if (!toRandomizeWith.ContainsKey(anon.card))
{
CharacterSpawnCard randomCard = getRandomCard(list, anon.body.isChampion);
toRandomizeWith.Add(anon.card, randomCard);
if (!masterPrefabToRandomMaster.ContainsKey(((SpawnCard)anon.card).prefab))
{
masterPrefabToRandomMaster.Add(((SpawnCard)anon.card).prefab, ((SpawnCard)randomCard).prefab);
}
list.Remove(randomCard);
}
}
}
public static CharacterSpawnCard getRandomCard(List<CharacterSpawnCard> pool, bool isChampion)
{
var source = from <>h__TransparentIdentifier1 in pool.Select((CharacterSpawnCard c) => new
{
c = c,
master = ((SpawnCard)c).prefab.GetComponent<CharacterMaster>()
}).Select(<>h__TransparentIdentifier0 =>
{
CharacterMaster master = <>h__TransparentIdentifier0.master;
object body;
if (master == null)
{
body = null;
}
else
{
GameObject bodyPrefab = master.bodyPrefab;
body = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
}
return new
{
<>h__TransparentIdentifier0 = <>h__TransparentIdentifier0,
body = (CharacterBody)body
};
})
where (Object)(object)<>h__TransparentIdentifier1.body != (Object)null && !RandomizerPlugin.isBlacklistedEnemy(((Object)((SpawnCard)<>h__TransparentIdentifier1.<>h__TransparentIdentifier0.c).prefab).name) && (!RandomConfigs.replaceChampionsWithChampions.Value || isChampion == <>h__TransparentIdentifier1.body.isChampion)
select new
{
card = <>h__TransparentIdentifier1.<>h__TransparentIdentifier0.c,
body = <>h__TransparentIdentifier1.body
};
List<CharacterSpawnCard> list = new List<CharacterSpawnCard>();
list.AddRange(source.Select(p => p.card));
return list[Random.Range(0, list.Count)];
}
public static CharacterMaster MasterSummon_Perform(orig_Perform orig, MasterSummon self)
{
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Expected O, but got Unknown
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
if (RandomConfigs.randomizeEnemiesOption.Value == EnemyRandomOptions.Disabled)
{
return orig.Invoke(self);
}
GameObject masterPrefab = self.masterPrefab;
bool flag = false;
DeployableSlot? val = null;
if ((Object)(object)masterPrefab != (Object)null)
{
CharacterMaster component = masterPrefab.GetComponent<CharacterMaster>();
object obj;
if (component == null)
{
obj = null;
}
else
{
GameObject bodyPrefab = component.bodyPrefab;
obj = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
}
CharacterBody val2 = (CharacterBody)obj;
if ((Object)(object)component != (Object)null && ((Object)component).name == "BeetleGuardAllyMaster")
{
val = (DeployableSlot)2;
}
if ((Object)(object)component != (Object)null && ((Object)component).name == "FriendUnitMaster")
{
val = (DeployableSlot)32;
}
bool flag2 = (Object)(object)component != (Object)null && RandomizerPlugin.isBlacklistedEnemy(((Object)component).name);
if ((Object)(object)val2 != (Object)null)
{
string name = ((Object)val2).name;
if (name.StartsWith("DTGunnerDroneBody") || name.StartsWith("DTHealingDroneBody") || name.StartsWith("DTHaulerDroneBody"))
{
flag2 = true;
}
}
if (!flag2)
{
if ((Object)(object)component != (Object)null && (((Object)component).name == "Turret1Master" || ((Object)component).name == "EngiTurretMaster" || ((Object)component).name == "EngiWalkerTurretMaster"))
{
flag = true;
}
GameObject val3 = ((RandomConfigs.randomizeEnemiesOption.Value != EnemyRandomOptions.AlwaysUnique) ? GetRandomSimilarMaster(masterPrefab, component, val2, self.teamIndexOverride) : GetRandomMasterDirect(masterPrefab, val2));
if ((Object)(object)val3 != (Object)(object)masterPrefab)
{
if (Object.op_Implicit((Object)(object)masterPrefab.GetComponent<SetDontDestroyOnLoad>()))
{
val3.AddComponent<SetDontDestroyOnLoad>();
}
self.masterPrefab = val3;
}
}
}
CharacterMaster val4 = orig.Invoke(self);
if ((Object)(object)val4 != (Object)null && val.HasValue && (Object)(object)val4.minionOwnership.ownerMaster != (Object)null)
{
Deployable val5 = ((Component)val4).gameObject.AddComponent<Deployable>();
val5.onUndeploy = new UnityEvent();
val4.minionOwnership.ownerMaster.AddDeployable(val5, val.Value);
}
if (!flag || !((Object)(object)val4 != (Object)null) || (Object)(object)val4.minionOwnership.ownerMaster != (Object)null)
{
}
return val4;
}
public static GameObject GetRandomMasterDirect(GameObject originalPrefab, CharacterBody originalBody)
{
bool isChampion = originalBody?.isChampion ?? false;
GameObject[] array = (from m in Resources.FindObjectsOfTypeAll<CharacterMaster>()
where Object.op_Implicit((Object)(object)((Component)m).gameObject) && Object.op_Implicit((Object)(object)m.bodyPrefab)
select ((Component)m).gameObject).Where(delegate(GameObject go)
{
CharacterMaster component = go.GetComponent<CharacterMaster>();
object obj;
if (component == null)
{
obj = null;
}
else
{
GameObject bodyPrefab = component.bodyPrefab;
obj = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
}
CharacterBody val = (CharacterBody)obj;
if ((Object)(object)val == (Object)null)
{
return false;
}
if (RandomizerPlugin.isBlacklistedEnemy(((Object)component).name))
{
return false;
}
if (((Object)val).name.StartsWith("DTGunnerDroneBody") || ((Object)val).name.StartsWith("DTHealingDroneBody") || ((Object)val).name.StartsWith("DTHaulerDroneBody"))
{
return false;
}
return (!RandomConfigs.replaceChampionsWithChampions.Value || isChampion == val.isChampion) ? true : false;
}).ToArray();
if (array.Length == 0)
{
return originalPrefab;
}
return array[Random.Range(0, array.Length)];
}
public static GameObject GetRandomSimilarMaster(GameObject originalPrefab, CharacterMaster originalMaster, CharacterBody originalBody, TeamIndex? teamIndexOverride)
{
if (masterPrefabToRandomMaster.ContainsKey(originalPrefab))
{
return masterPrefabToRandomMaster[originalPrefab];
}
CharacterSpawnCard[] source = (from c in Resources.FindObjectsOfTypeAll<CharacterSpawnCard>()
where Object.op_Implicit((Object)(object)c) && Object.op_Implicit((Object)(object)((SpawnCard)c).prefab)
select c).ToArray();
CharacterSpawnCard val = ((IEnumerable<CharacterSpawnCard>)source).FirstOrDefault((Func<CharacterSpawnCard, bool>)((CharacterSpawnCard c) => (Object)(object)((SpawnCard)c).prefab == (Object)(object)originalPrefab));
if ((Object)(object)val == (Object)null)
{
GameObject[] array = (from m in Resources.FindObjectsOfTypeAll<CharacterMaster>()
where Object.op_Implicit((Object)(object)((Component)m).gameObject) && Object.op_Implicit((Object)(object)m.bodyPrefab)
select ((Component)m).gameObject).Where(delegate(GameObject go)
{
CharacterMaster component = go.GetComponent<CharacterMaster>();
object obj;
if (component == null)
{
obj = null;
}
else
{
GameObject bodyPrefab = component.bodyPrefab;
obj = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
}
CharacterBody val4 = (CharacterBody)obj;
return (Object)(object)val4 != (Object)null && !RandomizerPlugin.isBlacklistedEnemy(((Object)component).name) && !((Object)val4).name.StartsWith("DTGunnerDroneBody") && !((Object)val4).name.StartsWith("DTHealingDroneBody") && !((Object)val4).name.StartsWith("DTHaulerDroneBody");
}).ToArray();
if (array.Length != 0)
{
GameObject val2 = array[Random.Range(0, array.Length)];
masterPrefabToRandomMaster[originalPrefab] = val2;
return val2;
}
return originalPrefab;
}
if (RandomizerPlugin.isBlacklistedEnemy(((Object)((SpawnCard)val).prefab).name))
{
return originalPrefab;
}
CharacterSpawnCard val3 = null;
if (toRandomizeWith.ContainsKey(val))
{
val3 = toRandomizeWith[val];
}
return ((Object)(object)val3 == (Object)null) ? originalPrefab : ((SpawnCard)val3).prefab;
}
}
}
namespace RandomizerMod.RandomizerScripts.BuffRandomizers
{
public class BuffRandomizer
{
private static Dictionary<BuffDef, BuffDef> toRandomizeWith = new Dictionary<BuffDef, BuffDef>();
private static List<BuffDef> availablePool = new List<BuffDef>();
public static void Init()
{
toRandomizeWith.Clear();
availablePool.Clear();
try
{
HashSet<string> blacklisted = RandomConfigs.GetBlacklistedBuffs();
BuffDef[] buffDefs = BuffCatalog.buffDefs;
availablePool.AddRange(buffDefs.Where((BuffDef b) => (Object)(object)b != (Object)null && !blacklisted.Contains(((Object)b).name)));
if (RandomConfigs.randomizeBuffs.Value != RandomizeOption.UniquePerKind && RandomConfigs.randomizeBuffs.Value != RandomizeOption.UniquePerKindWithDuplicates)
{
return;
}
List<BuffDef> list = new List<BuffDef>(availablePool);
bool flag = RandomConfigs.randomizeBuffs.Value == RandomizeOption.UniquePerKindWithDuplicates;
foreach (BuffDef item in availablePool.ToList())
{
if (!toRandomizeWith.ContainsKey(item))
{
if (list.Count == 0)
{
break;
}
BuffDef val = list[Random.Range(0, list.Count)];
toRandomizeWith.Add(item, val);
if (!flag)
{
list.Remove(val);
}
}
}
}
catch (Exception arg)
{
RandomizerPlugin.log.LogError((object)$"[BuffRandomizer] Init failed: {arg}");
}
}
private static BuffDef Resolve(BuffDef buffDef)
{
switch (RandomConfigs.randomizeBuffs.Value)
{
case RandomizeOption.Disabled:
return buffDef;
case RandomizeOption.UniquePerKind:
case RandomizeOption.UniquePerKindWithDuplicates:
{
BuffDef value;
return toRandomizeWith.TryGetValue(buffDef, out value) ? value : buffDef;
}
case RandomizeOption.AlwaysUnique:
if (availablePool.Count == 0)
{
return buffDef;
}
return availablePool[Random.Range(0, availablePool.Count)];
default:
return buffDef;
}
}
public static void CharacterBody_AddBuff_BuffDef(orig_AddBuff_BuffDef orig, CharacterBody self, BuffDef buffDef)
{
orig.Invoke(self, Resolve(buffDef));
}
public static void CharacterBody_RemoveBuff_BuffDef(orig_RemoveBuff_BuffDef orig, CharacterBody self, BuffDef buffDef)
{
orig.Invoke(self, Resolve(buffDef));
}
public static void CharacterBody_AddTimedBuff_BuffDef_float_int(orig_AddTimedBuff_BuffDef_float_int orig, CharacterBody self, BuffDef buffDef, float duration, int maxStacks)
{
orig.Invoke(self, Resolve(buffDef), duration, maxStacks);
}
public static void CharacterBody_AddTimedBuff_BuffDef_float(orig_AddTimedBuff_BuffDef_float orig, CharacterBody self, BuffDef buffDef, float duration)
{
orig.Invoke(self, Resolve(buffDef), duration);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}