using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.BrotherMonster; using EntityStates.Engi.EngiWeapon; using EntityStates.FalseSonBoss; using EntityStates.Loader; using EntityStates.MeridianEvent; using EntityStates.Missions.BrotherEncounter; using EntityStates.Missions.Goldshores; using EntityStates.Missions.LunarScavengerEncounter; using EntityStates.NewtMonster; using EntityStates.ScavMonster; using EntityStates.SolusWing2; using EntityStates.Toolbot; using EntityStates.VoidRaidCrab; using HG; using HG.GeneralSerializer; using HG.Reflection; using HarmonyLib; using IL.EntityStates.BeetleQueenMonster; using IL.EntityStates.BrotherMonster; using IL.EntityStates.CaptainSupplyDrop; using IL.EntityStates.Commando.CommandoWeapon; using IL.EntityStates.Engi.EngiWeapon; using IL.EntityStates.GoldGat; using IL.EntityStates.MinePod; using IL.EntityStates.Missions.BrotherEncounter; using IL.EntityStates.Missions.Goldshores; using IL.EntityStates.Missions.SuperRoboBallEncounter; using IL.EntityStates.NewtMonster; using IL.EntityStates.ParentEgg; using IL.EntityStates.RoboBallBoss.Weapon; using IL.EntityStates.ScavMonster; using IL.EntityStates.Scrapper; using IL.EntityStates.VoidJailer; using IL.EntityStates.VoidRaidCrab; using IL.RoR2; using IL.RoR2.Artifacts; using IL.RoR2.CharacterSpeech; using IL.RoR2.Items; using IL.RoR2.Orbs; using IL.RoR2.Projectile; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using MonoMod.Utils; using On.EntityStates; using On.EntityStates.BrotherMonster; using On.EntityStates.MeridianEvent; using On.EntityStates.Missions.BrotherEncounter; using On.EntityStates.Missions.Goldshores; using On.EntityStates.Missions.LunarScavengerEncounter; using On.EntityStates.ScavMonster; using On.EntityStates.SolusWing2; using On.EntityStates.Toolbot; using On.EntityStates.VoidRaidCrab; using On.RoR2; using On.RoR2.Artifacts; using On.RoR2.Orbs; using On.RoR2.Projectile; using On.RoR2.UI; using On.RoR2.UI.MainMenu; using R2API; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Artifacts; using RoR2.CharacterSpeech; using RoR2.ContentManagement; using RoR2.EntitlementManagement; using RoR2.ExpansionManagement; using RoR2.Items; using RoR2.Networking; using RoR2.Orbs; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI; using RoR2.UI.MainMenu; using RoR2Randomizer.BodyAnimationMirroring; using RoR2Randomizer.CharacterLimiter; using RoR2Randomizer.ChildTransformAdditions; using RoR2Randomizer.Configuration; using RoR2Randomizer.Configuration.ConfigValue; using RoR2Randomizer.Configuration.ConfigValue.ParsedList; using RoR2Randomizer.CustomContent; using RoR2Randomizer.Extensions; using RoR2Randomizer.ModCompatibility; using RoR2Randomizer.Networking; using RoR2Randomizer.Networking.BossRandomizer; using RoR2Randomizer.Networking.CharacterReplacements; using RoR2Randomizer.Networking.DamageOrbTargetDummy; using RoR2Randomizer.Networking.EffectRandomizer; using RoR2Randomizer.Networking.ExplicitSpawnRandomizer; using RoR2Randomizer.Networking.Generic; using RoR2Randomizer.Networking.Generic.Chunking; using RoR2Randomizer.Networking.ItemRandomizer; using RoR2Randomizer.Networking.ItemTierRandomizer; using RoR2Randomizer.Networking.ProjectileRandomizer; using RoR2Randomizer.Networking.ProjectileRandomizer.Bullet; using RoR2Randomizer.Networking.ProjectileRandomizer.Orbs; using RoR2Randomizer.Networking.ProjectileRandomizer.Orbs.GenericDamage; using RoR2Randomizer.Networking.ProjectileRandomizer.Orbs.Lightning; using RoR2Randomizer.Networking.ProjectileRandomizer.SpiteBomb; using RoR2Randomizer.Networking.SniperWeakPointRandomizer; using RoR2Randomizer.Networking.SurvivorPodRandomizer; using RoR2Randomizer.Patches; using RoR2Randomizer.Patches.BossRandomizer; using RoR2Randomizer.Patches.BossRandomizer.AlloyWorshipUnit; using RoR2Randomizer.Patches.BossRandomizer.Aurelionite; using RoR2Randomizer.Patches.BossRandomizer.FalseSon; using RoR2Randomizer.Patches.BossRandomizer.LunarScav; using RoR2Randomizer.Patches.BossRandomizer.Mithrix; using RoR2Randomizer.Patches.BossRandomizer.SolusWing; using RoR2Randomizer.Patches.BossRandomizer.Voidling; using RoR2Randomizer.Patches.ExplicitSpawnRandomizer; using RoR2Randomizer.Patches.OrbEffectOverrideTarget; using RoR2Randomizer.Patches.ProjectileParentChainTrackerPatches; using RoR2Randomizer.Patches.ProjectileRandomizer.Orbs; using RoR2Randomizer.Patches.ProjectileRandomizer.SpiteBomb; using RoR2Randomizer.Patches.Reverse; using RoR2Randomizer.PrefabMarkers; using RoR2Randomizer.Properties; using RoR2Randomizer.RandomizerControllers; using RoR2Randomizer.RandomizerControllers.Boss; using RoR2Randomizer.RandomizerControllers.Boss.BossReplacementInfo; using RoR2Randomizer.RandomizerControllers.Buff; using RoR2Randomizer.RandomizerControllers.Effect; using RoR2Randomizer.RandomizerControllers.ExplicitSpawn; using RoR2Randomizer.RandomizerControllers.Item; using RoR2Randomizer.RandomizerControllers.Item_Tier; using RoR2Randomizer.RandomizerControllers.Projectile; using RoR2Randomizer.RandomizerControllers.Projectile.BulletAttackHandling; using RoR2Randomizer.RandomizerControllers.Projectile.Orbs; using RoR2Randomizer.RandomizerControllers.Projectile.Orbs.DamageOrbHandling; using RoR2Randomizer.RandomizerControllers.Projectile.Orbs.LightningOrbHandling; using RoR2Randomizer.RandomizerControllers.SniperWeakPoint; using RoR2Randomizer.RandomizerControllers.Stage; using RoR2Randomizer.RandomizerControllers.SurvivorPod; using RoR2Randomizer.Utility; using RoR2Randomizer.Utility.Catalog; using RoR2Randomizer.Utility.Comparers; using RoR2Randomizer.Utility.EnemyInfoEquipmentDisplay; using RoR2Randomizer.Utility.Patching; using TMPro; using Unity; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityModdingUtility; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: AssemblyCompany("RoR2Randomizer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.9.0")] [assembly: AssemblyInformationalVersion("1.0.0+3b1c7f3e26352eead8b86684335b3989af48174b")] [assembly: AssemblyProduct("RoR2Randomizer")] [assembly: AssemblyTitle("RoR2Randomizer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 RoR2Randomizer { public static class LanguageTokens { private const string TOKEN_PREFIX = "Gorakh.RoR2Randomizer_"; public const string MOD_INFO_POPUP_HEADER = "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_HEADER"; public const string MOD_INFO_POPUP_DESCRIPTION = "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_DESCRIPTION"; public const string MOD_INFO_POPUP_DISMISS = "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_DISMISS"; private static readonly Dictionary _tokenPairs = new Dictionary { { "ARCHWISP_BODY_NAME", "Arch Wisp" }, { "BEETLE_CRYSTAL_BODY_NAME", "Crystal Beetle" }, { "MAJORCONSTRUCT_BODY_NAME", "Major Construct" }, { "MAJORCONSTRUCT_BODY_SUBTITLE", "Defense System" }, { "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_HEADER", "Welcome to Risk of Rain 2 Randomizer!" }, { "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_DESCRIPTION", "Thank you for wanting to play with my silly little mod! Before you start playing though, please check the mod settings (Settings -> Mod Options) if you don't want absolute chaos (almost all randomizers are enabled by default), or don't, up to you :)" }, { "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_DISMISS", "OK" } }; [SystemInitializer(new Type[] { })] private static void Init() { LanguageAPI.Add(_tokenPairs); } } internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber) { int num = callerPath.LastIndexOf("RoR2Randomizer"); if (num >= 0) { callerPath = callerPath.Substring(num + "RoR2Randomizer".Length + 1); } return $"{callerPath}:{callerLineNumber} ({callerMemberName}) "; } internal static void Error(string data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { Error_NoCallerPrefix(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data); } internal static void Error_NoCallerPrefix(string data) { _logSource.LogError((object)data); } internal static void Fatal(string data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { Fatal_NoCallerPrefix(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data); } internal static void Fatal_NoCallerPrefix(string data) { _logSource.LogFatal((object)data); } internal static void Info(string data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { Info_NoCallerPrefix(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data); } internal static void Info_NoCallerPrefix(string data) { _logSource.LogInfo((object)data); } internal static void Message(string data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { Message_NoCallerPrefix(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data); } internal static void Message_NoCallerPrefix(string data) { _logSource.LogMessage((object)data); } internal static void Warning(string data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { Warning_NoCallerPrefix(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data); } internal static void Warning_NoCallerPrefix(string data) { _logSource.LogWarning((object)data); } internal static void LogType(string data, LogLevel level) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) if ((level & 0x20) == 0) { _logSource.Log(level, (object)data); } } } [BepInPlugin("Gorakh.RoR2Randomizer", "RoR2Randomizer", "0.9.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Main : BaseUnityPlugin { public const string PluginGUID = "Gorakh.RoR2Randomizer"; public const string PluginAuthor = "Gorakh"; public const string PluginName = "RoR2Randomizer"; public const string PluginVersion = "0.9.0"; public static Main Instance { get; private set; } private void Awake() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Log.Init(((BaseUnityPlugin)this).Logger); Instance = this; CustomNetworkMessageManager.RegisterMessages(); if (InitializeOnAccess.op_Implicit(RiskOfOptionsCompat.IsEnabled)) { RiskOfOptionsCompat.Setup(); } ConfigManager.Initialize(((BaseUnityPlugin)this).Config); InitializationManager.Init(); new ContentPackManager().Init(); stopwatch.Stop(); Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F1} seconds"); } private void OnDestroy() { InitializationManager.Cleanup(); CharacterReplacements.Uninitialize(); NetworkingManager.Uninitialize(); } } } namespace RoR2Randomizer.Utility { public static class Caches { public static class Masters { public static MasterIndex Gup { get; private set; } = MasterIndex.none; public static MasterIndex Heretic { get; private set; } = MasterIndex.none; public static MasterIndex MalachiteUrchin { get; private set; } = MasterIndex.none; public static MasterIndex VoidInfestor { get; private set; } = MasterIndex.none; public static MasterIndex SoulWisp { get; private set; } = MasterIndex.none; public static MasterIndex HealingCore { get; private set; } = MasterIndex.none; public static MasterIndex ShopkeeperNewt { get; private set; } = MasterIndex.none; [SystemInitializer(new Type[] { typeof(MasterCatalog) })] private static void Init() { //IL_0005: 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_0023: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Gup = MasterCatalog.FindMasterIndex("GupMaster"); Heretic = MasterCatalog.FindMasterIndex("HereticMonsterMaster"); MalachiteUrchin = MasterCatalog.FindMasterIndex("UrchinTurretMaster"); VoidInfestor = MasterCatalog.FindMasterIndex("VoidInfestorMaster"); SoulWisp = MasterCatalog.FindMasterIndex("WispSoulMaster"); HealingCore = MasterCatalog.FindMasterIndex("AffixEarthHealerMaster"); ShopkeeperNewt = MasterCatalog.FindMasterIndex("ShopkeeperMaster"); } } public static class Bodies { public static BodyIndex VoidlingBaseBodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex VoidlingPhase1BodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex VoidlingPhase2BodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex VoidlingPhase3BodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex BeetleQueenBodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex ClayBossBodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex LunarGolemBodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex HereticBodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex SquidTurretBodyIndex { get; private set; } = (BodyIndex)(-1); public static BodyIndex MinorConstructOnKillBodyIndex { get; private set; } = (BodyIndex)(-1); [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static void Init() { //IL_0005: 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_0023: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) VoidlingBaseBodyIndex = BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyBase"); VoidlingPhase1BodyIndex = BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyPhase1"); VoidlingPhase2BodyIndex = BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyPhase2"); VoidlingPhase3BodyIndex = BodyCatalog.FindBodyIndex("MiniVoidRaidCrabBodyPhase3"); BeetleQueenBodyIndex = BodyCatalog.FindBodyIndex("BeetleQueen2Body"); ClayBossBodyIndex = BodyCatalog.FindBodyIndex("ClayBossBody"); LunarGolemBodyIndex = BodyCatalog.FindBodyIndex("LunarGolemBody"); HereticBodyIndex = BodyCatalog.FindBodyIndex("HereticBody"); SquidTurretBodyIndex = BodyCatalog.FindBodyIndex("SquidTurretBody"); MinorConstructOnKillBodyIndex = BodyCatalog.FindBodyIndex("MinorConstructOnKillBody"); } } public static class Scene { public static SceneIndex ArtifactTrialSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex NewtShopSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex GoldShoresSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex ObliterateSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex LunarScavFightSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex CommencementSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex VoidlingFightSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex VoidLocusSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex AbandonedAqueductSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex OldCommencementSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex AITestSceneIndex { get; private set; } = (SceneIndex)(-1); public static SceneIndex TestSceneSceneIndex { get; private set; } = (SceneIndex)(-1); public static ReadOnlyArray SimulacrumStageIndices { get; private set; } public static ReadOnlyArray PossibleStartingStagesIndices { get; private set; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsSimulacrumStage(SceneDef scene) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return IsSimulacrumStage(scene.sceneDefIndex); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsSimulacrumStage(SceneIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return ReadOnlyArray.BinarySearch(SimulacrumStageIndices, index) >= 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPossibleStartingStage(SceneDef scene) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return IsPossibleStartingStage(scene.sceneDefIndex); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPossibleStartingStage(SceneIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return ReadOnlyArray.BinarySearch(PossibleStartingStagesIndices, index) >= 0; } [SystemInitializer(new Type[] { typeof(SceneCatalog), typeof(GameModeCatalog) })] private static void Init() { //IL_0005: 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_0023: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected I4, but got Unknown ArtifactTrialSceneIndex = SceneCatalog.FindSceneIndex("artifactworld"); NewtShopSceneIndex = SceneCatalog.FindSceneIndex("bazaar"); GoldShoresSceneIndex = SceneCatalog.FindSceneIndex("goldshores"); ObliterateSceneIndex = SceneCatalog.FindSceneIndex("mysteryspace"); LunarScavFightSceneIndex = SceneCatalog.FindSceneIndex("limbo"); CommencementSceneIndex = SceneCatalog.FindSceneIndex("moon2"); VoidlingFightSceneIndex = SceneCatalog.FindSceneIndex("voidraid"); VoidLocusSceneIndex = SceneCatalog.FindSceneIndex("voidstage"); AbandonedAqueductSceneIndex = SceneCatalog.FindSceneIndex("goolake"); OldCommencementSceneIndex = SceneCatalog.FindSceneIndex("moon"); AITestSceneIndex = SceneCatalog.FindSceneIndex("ai_test"); TestSceneSceneIndex = SceneCatalog.FindSceneIndex("testscene"); HashSet stageIndices = new HashSet(); Run val = GameModeCatalog.FindGameModePrefabComponent("InfiniteTowerRun"); if (Object.op_Implicit((Object)(object)val)) { SceneCollection startingSceneGroup = val.startingSceneGroup; if (Object.op_Implicit((Object)(object)startingSceneGroup)) { handleCollection(startingSceneGroup, new HashSet(), in stageIndices); } } else { Log.Warning("Unable to find run prefab 'InfiniteTowerRun'", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Utility\\Caches.cs", "Init", 361); } SimulacrumStageIndices = new ReadOnlyArray((from i in stageIndices where (int)i != -1 orderby i select i).ToArray()); SceneIndex[] array = Array.Empty(); Run val2 = GameModeCatalog.FindGameModePrefabComponent("ClassicRun"); if (Object.op_Implicit((Object)(object)val2)) { SceneCollection startingSceneGroup2 = val2.startingSceneGroup; if (Object.op_Implicit((Object)(object)startingSceneGroup2)) { ReadOnlyArray sceneEntries = startingSceneGroup2.sceneEntries; array = (SceneIndex[])(object)new SceneIndex[sceneEntries.Length]; for (int num = 0; num < sceneEntries.Length; num++) { array[num] = (SceneIndex)(int)((SceneEntry)sceneEntries[num]).sceneDef.sceneDefIndex; } } } else { Log.Warning("Unable to find run prefab 'ClassicRun'", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Utility\\Caches.cs", "Init", 385); } PossibleStartingStagesIndices = new ReadOnlyArray((from i in array.Where((SceneIndex i) => (int)i != -1).Distinct() orderby i select i).ToArray()); static void handleCollection(SceneCollection collection, in HashSet alreadyHandledCollections, in HashSet reference) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (alreadyHandledCollections.Add(collection)) { Enumerator enumerator = collection.sceneEntries.GetEnumerator(); try { while (enumerator.MoveNext()) { SceneDef sceneDef = enumerator.Current.sceneDef; if (Object.op_Implicit((Object)(object)sceneDef)) { reference.Add(sceneDef.sceneDefIndex); SceneCollection destinationsGroup = sceneDef.destinationsGroup; if (Object.op_Implicit((Object)(object)destinationsGroup)) { handleCollection(destinationsGroup, in alreadyHandledCollections, in reference); } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } } } public static class DLC { public static ExpansionDef SOTV { get; private set; } [SystemInitializer(new Type[] { typeof(ExpansionCatalog) })] private static void Init() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) SOTV = ((IEnumerable)(object)ExpansionCatalog.expansionDefs).FirstOrDefault((Func)((ExpansionDef e) => ((Object)e).name == "DLC1")); } } public static readonly InitializeOnAccessDictionary MasterPrefabs = new InitializeOnAccessDictionary((Func)delegate(string name) { GameObject obj = MasterCatalog.FindMasterPrefab(name); return (obj == null) ? null : obj.GetComponent(); }); public static readonly InitializeOnAccessDictionary CharacterBodyRadius = new InitializeOnAccessDictionary((ValueSelectorTryGet)delegate(GameObject bodyPrefab, out float radius) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00ba: 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_00c6: 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_00da: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = default(CharacterBody); if (!bodyPrefab.TryGetComponent(ref val) || (int)val.bodyIndex == -1 || (val.bodyIndex != Bodies.BeetleQueenBodyIndex && val.bodyIndex != Bodies.ClayBossBodyIndex && val.bodyIndex != Bodies.LunarGolemBodyIndex)) { Collider[] components = bodyPrefab.GetComponents(); foreach (Collider val2 in components) { if (val2.enabled && tryGetRadius(val2, out radius)) { return true; } static bool tryGetRadius(Collider collider, out float reference) { SphereCollider val4 = (SphereCollider)(object)((collider is SphereCollider) ? collider : null); if (val4 != null) { reference = val4.radius; return true; } CapsuleCollider val5 = (CapsuleCollider)(object)((collider is CapsuleCollider) ? collider : null); if (val5 != null) { reference = Mathf.Max(val5.radius, val5.height); return true; } reference = -1f; return false; } } } ModelLocator val3 = default(ModelLocator); if (((Component)val).TryGetComponent(ref val3)) { Transform modelTransform = val3.modelTransform; CharacterModel root = default(CharacterModel); if (Object.op_Implicit((Object)(object)modelTransform) && ((Component)modelTransform).TryGetComponent(ref root) && root.TryGetModelBounds(out var bounds)) { Vector3 position = ((Component)val).transform.position; Vector3 max = ((Bounds)(ref bounds)).max; Vector3 min = ((Bounds)(ref bounds)).min; radius = (Mathf.Abs(position.x - max.x) + Mathf.Abs(position.x - min.x) + Mathf.Abs(position.y - max.y) + Mathf.Abs(position.y - min.y) + Mathf.Abs(position.z - max.z) + Mathf.Abs(position.z - min.z)) / 6f; return true; } } radius = -1f; return false; }); } public static class Constants { public static class SceneNames { public const string ARTIFACT_TRIAL_SCENE_NAME = "artifactworld"; public const string COMMENCEMENT_SCENE_NAME = "moon2"; public const string GOLD_SHORES_SCENE_NAME = "goldshores"; public const string OBLITERATE_SCENE_NAME = "mysteryspace"; public const string LUNAR_SCAV_FIGHT_SCENE_NAME = "limbo"; public const string VOIDLING_FIGHT_SCENE_NAME = "voidraid"; public const string VOID_FIELDS_SCENE_NAME = "arena"; public const string VOID_LOCUS_SCENE_NAME = "voidstage"; public const string SIRENS_CALL_SCENE_NAME = "shipgraveyard"; public const string ABANDONED_AQUEDUCT_SCENE_NAME = "goolake"; public const string NEWT_SHOP_SCENE_NAME = "bazaar"; public const string OLD_COMMENCEMENT_SCENE_NAME = "moon"; public const string AI_TEST_SCENE_NAME = "ai_test"; public const string TESTSCENE_SCENE_NAME = "testscene"; } public static class BodyNames { public const string VOIDLING_BASE_NAME = "MiniVoidRaidCrabBodyBase"; public const string VOIDLING_PHASE_1_NAME = "MiniVoidRaidCrabBodyPhase1"; public const string VOIDLING_PHASE_2_NAME = "MiniVoidRaidCrabBodyPhase2"; public const string VOIDLING_PHASE_3_NAME = "MiniVoidRaidCrabBodyPhase3"; public const string HERETIC_NAME = "HereticBody"; public const string BEETLE_QUEEN_NAME = "BeetleQueen2Body"; public const string CLAY_BOSS_NAME = "ClayBossBody"; public const string LUNAR_GOLEM_NAME = "LunarGolemBody"; public const string SQUID_TURRET_NAME = "SquidTurretBody"; public const string MINOR_CONSTRUCT_ON_KILL_NAME = "MinorConstructOnKillBody"; } public static class MasterNames { public const string GUP_NAME = "GupMaster"; public const string HERETIC_NAME = "HereticMonsterMaster"; public const string MALACHITE_URCHIN_NAME = "UrchinTurretMaster"; public const string VOID_INFESTOR_NAME = "VoidInfestorMaster"; public const string SOUL_WISP_NAME = "WispSoulMaster"; public const string HEALING_CORE_NAME = "AffixEarthHealerMaster"; public const string SHOPKEEPER_NEWT_NAME = "ShopkeeperMaster"; } public static class BuffNames { public const string VOIDSURVIVOR_CORRUPT_MODE_NAME = "bdVoidSurvivorCorruptMode"; } public static class DLCNames { public const string SOTV_NAME = "DLC1"; } public const string RISK_OF_OPTIONS_GUID = "com.rune580.riskofoptions"; } public delegate bool TryConvertDelegate(T input, out T output); public delegate bool TryConvertToNextValue(ref T value); public static class EntityStateOwnerTracker { private static readonly Dictionary _stateToOwnerCache = new Dictionary(); public static GenericSkill SkillOwnerForNextCall; public static void AddSkillOwner(GenericSkill skill, EntityState state) { if (Object.op_Implicit((Object)(object)skill) && state != null) { _stateToOwnerCache[state] = skill; } } public static GenericSkill GetOwner(EntityState state) { if (_stateToOwnerCache.TryGetValue(state, out var value)) { return value; } ISkillState val = (ISkillState)(object)((state is ISkillState) ? state : null); if (val != null) { return val.activatorSkillSlot; } return null; } public static void SetNextOwnerToOwnerOfState(EntityState state) { GenericSkill owner = GetOwner(state); if (Object.op_Implicit((Object)(object)owner)) { SkillOwnerForNextCall = owner; } } } public readonly struct IndexReplacementsCollection : IEnumerable, IEnumerable, IEquatable { public readonly int Length; private readonly int[] _replacementIndices; private readonly int[] _originalIndices; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IndexReplacementsCollection Create(ReplacementDictionary input, int length) where T : Enum { return new IndexReplacementsCollection(new ReplacementDictionary(input.ToDictionary((KeyValuePair kvp) => (int)(object)kvp.Key, (KeyValuePair kvp) => (int)(object)kvp.Value)), length); } public IndexReplacementsCollection(ReplacementDictionary input, int length) { Length = length; _replacementIndices = new int[length]; int[] replacementIndices = _replacementIndices; int num = -1; ArrayUtils.SetAll(replacementIndices, ref num); _originalIndices = new int[length]; int[] originalIndices = _originalIndices; num = -1; ArrayUtils.SetAll(originalIndices, ref num); for (int i = 0; i < length; i++) { if (input.TryGetReplacement(i, out var replacement)) { _replacementIndices[i] = replacement; _originalIndices[replacement] = i; } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IndexReplacementsCollection Create(T[] replacementIndices) where T : Enum { return new IndexReplacementsCollection(Array.ConvertAll(replacementIndices, (T t) => (int)(object)t)); } public IndexReplacementsCollection(int[] replacementIndices, int? length = null) { Length = length ?? replacementIndices.Length; _replacementIndices = replacementIndices; _originalIndices = new int[Length]; int[] originalIndices = _originalIndices; int num = -1; ArrayUtils.SetAll(originalIndices, ref num); for (int i = 0; i < Length; i++) { int num2 = _replacementIndices[i]; if (num2 != -1) { _originalIndices[num2] = i; } } } public bool HasReplacement(int original) { int replacement; return TryGetReplacement(original, out replacement); } public bool TryGetReplacement(int original, out int replacement) { if (original < 0 || original >= Length) { replacement = -1; return false; } return (replacement = _replacementIndices[original]) != -1; } public bool HasOriginal(int replacement) { int original; return TryGetOriginal(replacement, out original); } public bool TryGetOriginal(int replacement, out int original) { if (replacement < 0 || replacement >= Length) { original = -1; return false; } return (original = _originalIndices[replacement]) != -1; } public void Serialize(NetworkWriter writer) { writer.WritePackedUInt32((uint)Length); int[] replacementIndices = _replacementIndices; foreach (int num in replacementIndices) { NetworkExtensions.WritePackedIndex32(writer, num); } } public static IndexReplacementsCollection Deserialize(NetworkReader reader) { uint num = reader.ReadPackedUInt32(); int[] array = new int[num]; for (int i = 0; i < num; i++) { array[i] = NetworkExtensions.ReadPackedIndex32(reader); } return new IndexReplacementsCollection(array); } public IEnumerator GetEnumerator() { return ((IEnumerable)_replacementIndices).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return _replacementIndices.GetEnumerator(); } public bool Equals(IndexReplacementsCollection other) { if (Length == other.Length) { return _replacementIndices == other._replacementIndices; } return false; } } public static class InitializationManager { private static Harmony _harmonyInstance; private static GameObject _controllersRoot; public static void Init() { ((MonoBehaviour)Main.Instance).StartCoroutine(DelayedInitialize()); } public static IEnumerator DelayedInitialize() { yield return (object)new WaitForSeconds(1f); _harmonyInstance = new Harmony("Gorakh.RoR2Randomizer"); _harmonyInstance.PatchAll(Assembly.GetExecutingAssembly()); PatchClassAttribute.ApplyAllPatches(); _controllersRoot = new GameObject("RoR2Randomizer.Controllers"); Object.DontDestroyOnLoad((Object)(object)_controllersRoot); ((Object)_controllersRoot).hideFlags = (HideFlags)4; List instances = SearchableAttribute.GetInstances(); if (instances != null) { foreach (SearchableAttribute item in instances) { if (item != null && item.target is Type type) { _controllersRoot.AddComponent(type); } } } OrbTargetDummyObjectMarker.InitNetworkPrefab(); } public static void Cleanup() { Object.Destroy((Object)(object)_controllersRoot); _controllersRoot = null; _harmonyInstance.UnpatchSelf(); _harmonyInstance = null; PatchClassAttribute.CleanupAllPatches(); } } public static class MiscUtils { public static void AddItems(ref T[] array, IEnumerable items) { AddItems(ref array, (items is T[] array2) ? array2 : items.ToArray()); } public static void AddItems(ref T[] array, params T[] items) { int num = items.Length; if (num > 0) { int num2 = array.Length; Array.Resize(ref array, num2 + num); Array.Copy(items, 0, array, num2, num); } } public static bool ArrayEqual(T[] a, T[] b, IEqualityComparer equalityComparer = null) { if (a == null) { throw new ArgumentNullException("a"); } if (b == null) { throw new ArgumentNullException("b"); } if (equalityComparer == null) { equalityComparer = EqualityComparer.Default; } if (a.Length != b.Length) { return false; } for (int i = 0; i < a.Length; i++) { if (!equalityComparer.Equals(a[i], b[i])) { return false; } } return true; } public static bool TryAssign(ref T dest, T value, IEqualityComparer comparer = null) { if ((comparer ?? EqualityComparer.Default).Equals(dest, value)) { return false; } dest = value; return true; } public static LinkedList CreateReverseLinkedListFromLinks(T value, TryConvertToNextValue tryConvertToNext) { LinkedList linkedList = new LinkedList(); do { linkedList.AddFirst(value); } while (tryConvertToNext(ref value)); return linkedList; } public static LinkedList CreateReverseLinkedListFromLinks(T value, TryConvertDelegate tryConvert) { return CreateReverseLinkedListFromLinks(value, tryConvert.ToConvertToNextValue()); } public static LinkedList CreateReverseLinkedListFromLinks(T value, Func tryGetNextValue) where T : class { return CreateReverseLinkedListFromLinks(value, tryGetNextValue.AddNullCheck()); } public static void AppendDelegate(ref T original, T additional) where T : Delegate { original = (T)Delegate.Combine(original, additional); } } public delegate void PrefabUndoModificationDelegate(GameObject prefab); public delegate PrefabUndoModificationDelegate PrefabPerformModificationDelegate(GameObject prefab); public class PrefabModificationTracker : MonoBehaviour { private readonly List _undoCallbacks = new List(); public void PerformModification(PrefabPerformModificationDelegate modification) { if (modification == null) { throw new ArgumentNullException("modification"); } PrefabUndoModificationDelegate prefabUndoModificationDelegate = modification(((Component)this).gameObject); if (prefabUndoModificationDelegate != null) { _undoCallbacks.Add(prefabUndoModificationDelegate); } } public void Undo() { foreach (PrefabUndoModificationDelegate undoCallback in _undoCallbacks) { undoCallback(((Component)this).gameObject); } Object.Destroy((Object)(object)this); } } public class ProjectileParentChainNode : ISerializableObject { public ProjectileParentChainNode Parent; public ProjectileTypeIdentifier NodeIdentifier { get; private set; } public ProjectileParentChainNode(ProjectileTypeIdentifier nodeIdentifier) { NodeIdentifier = nodeIdentifier; } public ProjectileParentChainNode() { } public IEnumerable ConstructChain() { return from n in MiscUtils.CreateReverseLinkedListFromLinks(this, (ProjectileParentChainNode t) => t.Parent) select n.NodeIdentifier; } public bool IsChildOf(ProjectileTypeIdentifier identifier) { if (identifier.IsValid) { return ConstructChain().Contains(identifier); } return false; } public void Deserialize(NetworkReader reader) { NodeIdentifier = new ProjectileTypeIdentifier(reader); if (reader.ReadBoolean()) { Parent = new ProjectileParentChainNode(); Parent.Deserialize(reader); } } public void Serialize(NetworkWriter writer) { NodeIdentifier.Serialize(writer); bool flag = Parent != null; writer.Write(flag); if (flag) { Parent.Serialize(writer); } } } [RequireComponent(typeof(ProjectileController))] public sealed class ProjectileParentChainTracker : MonoBehaviour { public ProjectileParentChainNode ChainNode { get; private set; } private void Awake() { ProjectileController component = ((Component)this).GetComponent(); ChainNode = new ProjectileParentChainNode(new ProjectileTypeIdentifier(ProjectileType.OrdinaryProjectile, component.catalogIndex)); } public void TrySetParent(GameObject parentObj) { ProjectileParentChainTracker projectileParentChainTracker = default(ProjectileParentChainTracker); if (parentObj.TryGetComponent(ref projectileParentChainTracker)) { SetParent(projectileParentChainTracker.ChainNode); } } public void SetParent(ProjectileParentChainNode node) { ChainNode.Parent = node; } public bool IsChildOf(ProjectileTypeIdentifier identifier) { if (ChainNode != null) { return ChainNode.IsChildOf(identifier); } return false; } } public static class ReflectionUtils { public static MethodInfo FindImplicitConversion(Type from, Type to) { foreach (MethodInfo item in from.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public).Concat(to.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public))) { if (item.IsSpecialName && item.Name == "op_Implicit" && item.ReturnType == to) { ParameterInfo[] parameters = item.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == from) { return item; } } } throw new MissingMethodException("No implicit conversion " + GeneralExtensions.FullDescription(from) + " -> " + GeneralExtensions.FullDescription(to) + " could be found"); } public static LinkedList GetTypeHierarchyList(Type type) { return MiscUtils.CreateReverseLinkedListFromLinks(type, (Type t) => t.BaseType); } } public class ReplacementDictionary : ReadOnlyDictionary { private readonly InitializeOnAccess> _reverseDictionary; public static ReplacementDictionary CreateFrom(IEnumerable collection, Xoroshiro128Plus rng, Func converter, Func canReplaceFunc) { return CreateFrom(collection, rng, converter, canReplaceFunc, null); } public static ReplacementDictionary CreateFrom(IEnumerable collection, Xoroshiro128Plus rng, Func converter, Func canReplaceFunc, Func weightSelector) { Dictionary dictionary = new Dictionary(); List list = new List(collection); List list2 = new List(list); bool flag = canReplaceFunc != null; bool flag2 = weightSelector != null; while (list.Count > 0) { TSrc key = list.GetAndRemoveAt(0); IEnumerable enumerable2; if (!flag) { IEnumerable enumerable = list2; enumerable2 = enumerable; } else { enumerable2 = list2.Where((TSrc v) => canReplaceFunc(key, v)); } IEnumerable enumerable3 = enumerable2; if (enumerable3.Any()) { TSrc val = ((!flag2) ? enumerable3.GetRandomOrDefault(rng) : enumerable3.PickWeighted(rng, (TSrc v) => weightSelector(key, v))); list2.Remove(val); dictionary.Add(converter(key), converter(val)); } else { Log.Warning(string.Format("({0}={1}, {2}={3}) No valid replacement exists for key '{4}'. It will be excluded from the resulting dictionary", "T", typeof(T).Name, "TSrc", typeof(TSrc).Name, key), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Utility\\ReplacementDictionary.cs", "CreateFrom", 51); list2.Remove(key); } } return new ReplacementDictionary(dictionary); } public static ReplacementDictionary CreateFrom(IEnumerable collection, Xoroshiro128Plus rng) { return CreateFrom(collection, rng, (Func)null, (Func)null); } public static ReplacementDictionary CreateFrom(IEnumerable collection, Xoroshiro128Plus rng, Func canReplaceFunc, Func weightSelector) { return CreateFrom(collection, rng, (T t) => t, canReplaceFunc, weightSelector); } public static ReplacementDictionary CreateFrom(IEnumerable collection, Xoroshiro128Plus rng, Func canReplaceFunc) { return CreateFrom(collection, rng, (T t) => t, canReplaceFunc, null); } public ReplacementDictionary(IDictionary dict) : base(dict) { _reverseDictionary = (InitializeOnAccess>)(object)new InitializeOnAccess, ReadOnlyDictionary>>((Func, ReadOnlyDictionary>>)(object)(Func>)delegate { Dictionary dictionary = new Dictionary(); using (IEnumerator> enumerator = GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair current = enumerator.Current; dictionary[current.Value] = current.Key; } } return new ReadOnlyDictionary(dictionary); }); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryGetReplacement(T original, out T replacement) { return TryGetValue(original, out replacement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool HasReplacement(T original) { return ContainsKey(original); } public bool TryGetOriginal(T replacement, out T original) { return ((InitializeOnAccess, ReadOnlyDictionary>>)(object)_reverseDictionary).Get.TryGetValue(replacement, out original); } } public static class RNGManager { public static RunSpecific RandomizerServerRNG { get; private set; } [SystemInitializer(new Type[] { })] private static void Init() { RandomizerServerRNG = new RunSpecific(delegate(out Xoroshiro128Plus result) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (NetworkServer.active) { result = new Xoroshiro128Plus(Run.instance.runRNG.Next()); return true; } result = null; return false; }, 10); } } public class RunSpecific : IDisposable { public delegate bool TryGetNewValueDelegate(out T value); private ulong? _callbackHandle; private readonly TryGetNewValueDelegate _getNewValue; private readonly T _defaultValue; private T _value; public bool HasValue { get; private set; } public T Value { get { return _value; } set { _value = value; bool flag = ((!(value is IEquatable equatable)) ? ((!(_defaultValue is IEquatable equatable2)) ? EqualityComparer.Default.Equals(value, _defaultValue) : equatable2.Equals(value)) : equatable.Equals(_defaultValue)); HasValue = !flag; } } public RunSpecific(int priority = 0, T defaultValue = default(T)) : this((TryGetNewValueDelegate)null, priority, defaultValue) { } public RunSpecific(Func getValueFunc, int priority = 0, T defaultValue = default(T)) : this((TryGetNewValueDelegate)delegate(out T value) { value = getValueFunc(); return true; }, priority, defaultValue) { } public RunSpecific(TryGetNewValueDelegate getNewValue, int priority = 0, T defaultValue = default(T)) { _getNewValue = getNewValue; Value = (_defaultValue = defaultValue); HasValue = false; _callbackHandle = RunSpecificCallbacksManager.AddEntry(onRunStart, onRunEnd, priority); } ~RunSpecific() { if (_callbackHandle.HasValue) { Dispose(); } } private void onRunStart(Run instance) { if (_getNewValue != null && !HasValue) { if (_getNewValue(out var value)) { Value = value; } else { Value = _defaultValue; } } } private void onRunEnd(Run instance) { Value = _defaultValue; } public void Dispose() { if (_callbackHandle.HasValue) { RunSpecificCallbacksManager.RemoveEntry(_callbackHandle.Value); _callbackHandle = null; } } public static implicit operator T(RunSpecific runSpecific) { return runSpecific.Value; } } internal static class RunSpecificCallbacksManager { private readonly struct CallbackEntry { private class Comparer : IComparer { int IComparer.Compare(CallbackEntry x, CallbackEntry y) { return y._priority.CompareTo(x._priority); } } private static ulong _nextHandleIndex = 0uL; public readonly ulong Handle; public readonly Action OnStartRun; public readonly Action OnEndRun; private readonly int _priority; public static readonly IComparer PriorityComparer = new Comparer(); public CallbackEntry(int priority, Action onStartRun, Action onEndRun) { _priority = priority; OnStartRun = onStartRun; OnEndRun = onEndRun; Handle = _nextHandleIndex; checked { try { _nextHandleIndex++; } catch (OverflowException) { _nextHandleIndex = 0uL; } } } } private static readonly List _callbackEntries; static RunSpecificCallbacksManager() { _callbackEntries = new List(); Run.onRunStartGlobal += onRunStart; Run.onRunDestroyGlobal += onRunEnd; } private static void onRunStart(Run instance) { foreach (CallbackEntry callbackEntry in _callbackEntries) { callbackEntry.OnStartRun?.Invoke(instance); } } private static void onRunEnd(Run instance) { foreach (CallbackEntry callbackEntry in _callbackEntries) { callbackEntry.OnEndRun?.Invoke(instance); } } public static ulong AddEntry(Action onStart, Action onEnd, int priority) { return AddEntry(convertToRunCallback(onStart), convertToRunCallback(onEnd), priority); static Action convertToRunCallback(Action original) { if (original == null) { return null; } return delegate { original(); }; } } public static ulong AddEntry(Action onStart, Action onEnd, int priority) { CallbackEntry item = new CallbackEntry(priority, onStart, onEnd); _callbackEntries.Add(item); _callbackEntries.Sort(CallbackEntry.PriorityComparer); return item.Handle; } public static void RemoveEntry(ulong callbackHandle) { int num = _callbackEntries.FindIndex((CallbackEntry c) => c.Handle == callbackHandle); if (num != -1) { _callbackEntries.RemoveAt(num); } else { Log.Warning($"Attempted to remove entry with handle {callbackHandle}, but it was not found in the list", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Utility\\RunSpecificCallbacksManager.cs", "RemoveEntry", 104); } } } public static class RunSpecificLanguageOverlay { private static readonly List _activeOverlays; static RunSpecificLanguageOverlay() { _activeOverlays = new List(); Run.onRunDestroyGlobal += onRunEnd; } private static void onRunEnd(Run _) { foreach (LanguageOverlay activeOverlay in _activeOverlays) { activeOverlay.Remove(); } _activeOverlays.Clear(); } public static void AddRunLanguageOverlay(LanguageOverlay overlay) { _activeOverlays.Add(overlay); } } public static class SpawnCardTracker { public static SpawnCard MithrixNormalSpawnCard; public static SpawnCard MithrixHurtSpawnCard; public static SpawnCard[] MithrixPhase2SpawnCards; public static SpawnCard[] VoidlingPhasesSpawnCards; public static SpawnCard[] FalseSonPhasesSpawnCards; public static SpawnCard AurelioniteSpawnCard; public static SpawnCard SolusWingSpawnCard; public static MultiCharacterSpawnCard LunarScavSpawnCard; public static SpawnCard AlloyWorshipUnitSpawnCard; private static bool isPartOf(SpawnCard[] array, SpawnCard card, out int index) { if (array != null) { index = Array.IndexOf(array, card); return index != -1; } index = -1; return false; } public static bool IsPartOfMithrixPhase2(SpawnCard card) { int index; return isPartOf(MithrixPhase2SpawnCards, card, out index); } public static bool IsAnyVoidlingPhase(SpawnCard card) { int index; return isPartOf(VoidlingPhasesSpawnCards, card, out index); } public static bool IsAnyFalseSonPhase(SpawnCard card) { return ((Object)card).name.Contains("FalseSon"); } } public class TempComponentsTracker : MonoBehaviour { private readonly List _trackedComponents = new List(); private void track(Component component) { _trackedComponents.Add(component); } public void RemoveAll() { foreach (Component trackedComponent in _trackedComponents) { if (Object.op_Implicit((Object)(object)trackedComponent)) { Object.Destroy((Object)(object)trackedComponent); } } Object.Destroy((Object)(object)this); } public bool TryRemove() where T : Component { return TryRemove(typeof(T)); } public bool TryRemove(Type componentType) { for (int num = _trackedComponents.Count - 1; num >= 0; num--) { if (Object.op_Implicit((Object)(object)_trackedComponents[num])) { if (((object)_trackedComponents[num]).GetType() == componentType) { Object.Destroy((Object)(object)_trackedComponents[num]); _trackedComponents.RemoveAt(num); if (_trackedComponents.Count == 0) { Object.Destroy((Object)(object)this); } return true; } } else { _trackedComponents.RemoveAt(num); } } if (_trackedComponents.Count == 0) { Object.Destroy((Object)(object)this); } return false; } public static T AddTempComponent(MonoBehaviour owner) where T : Component { return (T)(object)AddTempComponent(owner, typeof(T)); } public static Component AddTempComponent(MonoBehaviour owner, Type type) { GameObject gameObject = ((Component)owner).gameObject; Component val = gameObject.AddComponent(type); gameObject.GetOrAddComponent().track(val); return val; } public static TempComponentsTracker AddTempComponents(MonoBehaviour owner, params Type[] componentTypes) { GameObject gameObject = ((Component)owner).gameObject; TempComponentsTracker orAddComponent = gameObject.GetOrAddComponent(); foreach (Type type in componentTypes) { orAddComponent.track(gameObject.AddComponent(type)); } return orAddComponent; } public static bool RemoveAllTempComponents(MonoBehaviour owner) { TempComponentsTracker component = ((Component)owner).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return false; } component.RemoveAll(); return true; } public static bool TryRemoveTempComponent(MonoBehaviour owner) where T : Component { return TryRemoveTempComponent(owner, typeof(T)); } public static bool TryRemoveTempComponent(MonoBehaviour owner, Type componentType) { if (!Object.op_Implicit((Object)(object)owner)) { return false; } TempComponentsTracker component = ((Component)owner).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { return component.TryRemove(componentType); } return false; } } public readonly struct TimeoutActionResult { public readonly float TimeElapsed; public readonly TimeoutActionResultState State; public TimeoutActionResult(float timeElapsed, TimeoutActionResultState state) { TimeElapsed = timeElapsed; State = state; } } public enum TimeoutActionResultState : byte { Finished, TimedOut } public struct TrackedValue { private readonly IEqualityComparer _comparer; private T _value; public T Value { get { return _value; } set { if (MiscUtils.TryAssign(ref _value, value, _comparer)) { this.OnChanged?.Invoke(value); } } } public event Action OnChanged; public TrackedValue(T value = default(T), IEqualityComparer comparer = null) { this.OnChanged = null; _value = value; _comparer = comparer; } public static implicit operator T(TrackedValue tracked) { return tracked.Value; } } } namespace RoR2Randomizer.Utility.Patching { internal static class Discard { public static T Value; } public static class StaticReflectionCache { public static readonly MethodInfo Animator_GetFloat_name_MI = SymbolExtensions.GetMethodInfo((Expression>)((Animator _) => _.GetFloat((string)null))); public static readonly MethodInfo Physics_Raycast_Ray_outRaycastHit_float_MI = SymbolExtensions.GetMethodInfo((Expression)(() => Physics.Raycast(default(Ray), ref Discard.Value, 0f))); public static readonly MethodInfo EntityState_get_skillLocator = AccessTools.PropertyGetter(typeof(EntityState), "skillLocator"); public static readonly MethodInfo EntityStateCatalog_InstantiateState_Type_MI = SymbolExtensions.GetMethodInfo((Expression)(() => EntityStateCatalog.InstantiateState((Type)null))); public static readonly MethodInfo EntityStateCatalog_InstantiateState_SerializableEntityStateType_MI = SymbolExtensions.GetMethodInfo((Expression)(() => EntityStateCatalog.InstantiateState((EntityStateIndex)0))); } } namespace RoR2Randomizer.Utility.EnemyInfoEquipmentDisplay { [RequireComponent(typeof(EnemyInfoPanel))] public class EnemyInfoPanelEquipmentDisplayController : MonoBehaviour { private EnemyInfoPanel _enemyInfoPanel; private GameObject _equipmentContainer; private EquipmentInventoryDisplay _equipmentDisplay; private EquipmentIndex[] _lastEquipmentIndices = Array.Empty(); private const string EQUIPMENT_LABEL_TOKEN = "ARENA_HUD_MONSTER_EQUIPMENTS_LABEL"; [SystemInitializer(new Type[] { })] private static void Init() { LanguageAPI.Add("ARENA_HUD_MONSTER_EQUIPMENTS_LABEL", "Monsters' Equipment"); } private void Awake() { _enemyInfoPanel = ((Component)this).GetComponent(); initializeEquipmentContainer(); } private void initializeEquipmentContainer() { _equipmentContainer = Object.Instantiate(_enemyInfoPanel.inventoryContainer, _enemyInfoPanel.inventoryContainer.transform.parent); ((Object)_equipmentContainer).name = "EquipmentContainer"; Transform obj = _equipmentContainer.transform.Find("InventoryLabel"); ((Object)obj).name = "EquipmentLabel"; ((Component)obj).GetComponent().token = "ARENA_HUD_MONSTER_EQUIPMENTS_LABEL"; Transform val = _equipmentContainer.transform.Find("InventoryDisplay"); ((Object)val).name = "EquipmentDisplay"; Object.Destroy((Object)(object)((Component)val).GetComponent()); _equipmentDisplay = ((Component)val).gameObject.AddComponent(); _equipmentContainer.SetActive(false); } public void TrySetEquipments(EquipmentIndex[] equipments) { if (!MiscUtils.ArrayEqual(_lastEquipmentIndices, equipments)) { _equipmentContainer.SetActive(equipments.Length != 0); _lastEquipmentIndices = equipments; _equipmentDisplay.SetEquipments(equipments); } } } [RequireComponent(typeof(RectTransform))] public class EquipmentInventoryDisplay : UIBehaviour, ILayoutElement { private struct LayoutValues { public float Width; public float Height; public float IconSize; public int IconsPerRow; public float RowWidth; public int RowCount; public Vector3 IconLocalScale; public Vector3 TopLeftCorner; } private const float EQUIPMENT_ICON_PREFAB_WIDTH = 32f; private const float MAX_ICON_WIDTH = 32f; private const float MAX_HEIGHT = 256f; private const float VERTICAL_MARGIN = 8f; private RectTransform _rectTransform; private readonly List _equipmentIcons = new List(); private EquipmentIndex[] _equipments; private float _currentIconScale = 1f; private float _previousWidth; private bool _updateRequestPending; private Inventory _inventory; private bool _inventoryWasValid; private bool isUninitialized => (Object)(object)_rectTransform == (Object)null; public float minWidth => preferredWidth; public float preferredWidth { get { //IL_0006: 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) Rect rect = _rectTransform.rect; return ((Rect)(ref rect)).width; } } public float flexibleWidth => 0f; public float minHeight => preferredHeight; public float preferredHeight { get; set; } public float flexibleHeight => 0f; public int layoutPriority => 0; public void SetSubscribedInventory(Inventory newInventory) { if (!((Object)(object)_inventory == (Object)(object)newInventory) || Object.op_Implicit((Object)(object)_inventory) != _inventoryWasValid) { if ((Object)(object)_inventory != (Object)null) { _inventory.onInventoryChanged -= onInventoryChanged; _inventory = null; } _inventory = newInventory; _inventoryWasValid = Object.op_Implicit((Object)(object)_inventory); if (Object.op_Implicit((Object)(object)_inventory)) { _inventory.onInventoryChanged += onInventoryChanged; } onInventoryChanged(); } } private void onInventoryChanged() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown if (!((Behaviour)this).isActiveAndEnabled) { return; } if (Object.op_Implicit((Object)(object)_inventory)) { int equipmentSlotCount = _inventory.GetEquipmentSlotCount(); _equipments = (EquipmentIndex[])(object)new EquipmentIndex[equipmentSlotCount]; for (uint num = 0u; num < equipmentSlotCount; num++) { _equipments[num] = (EquipmentIndex)(int)_inventory.GetEquipment(num).equipmentIndex; } } else { Array.Clear(_equipments, 0, _equipments.Length); } requestUpdateDisplay(); } private void allocateIcons(int desiredItemCount) { if (desiredItemCount != _equipmentIcons.Count) { while (_equipmentIcons.Count > desiredItemCount) { Object.Destroy((Object)(object)((Component)_equipmentIcons[_equipmentIcons.Count - 1]).gameObject); _equipmentIcons.RemoveAt(_equipmentIcons.Count - 1); } calculateLayoutValues(out var v, desiredItemCount); while (_equipmentIcons.Count < desiredItemCount) { GenericPickupIcon component = Object.Instantiate(GenericPickupIcon.Prefab, (Transform)(object)_rectTransform).GetComponent(); _equipmentIcons.Add(component); layoutIndividualIcon(in v, _equipmentIcons.Count - 1); } } onIconCountChanged(); } private float calculateIconScale(int iconCount) { //IL_0006: 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) Rect rect = _rectTransform.rect; int num = (int)((Rect)(ref rect)).width; int num2 = 256; int num3 = 32; int num4 = num3; int num5 = num3 / 8; int num6 = Math.Max(num / num4, 1); int num7 = HGMath.IntDivCeil(iconCount, num6); while (num4 * num7 > num2) { num6++; num4 = Math.Min(num / num6, num3); num7 = HGMath.IntDivCeil(iconCount, num6); if (num4 <= num5) { num4 = num5; break; } } num4 = Math.Min(num4, 32); return (float)num4 / (float)num3; } private void onIconCountChanged() { float num = calculateIconScale(_equipmentIcons.Count); if (num != _currentIconScale) { _currentIconScale = num; onIconScaleChanged(); } } private void onIconScaleChanged() { layoutAllIcons(); } private void calculateLayoutValues(out LayoutValues v, int iconCount) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) float num = calculateIconScale(_equipmentIcons.Count); Rect rect = _rectTransform.rect; v.Width = ((Rect)(ref rect)).width; v.IconSize = 32f * num; v.IconsPerRow = Math.Max((int)v.Width / (int)v.IconSize, 1); v.RowWidth = (float)v.IconsPerRow * v.IconSize; float num2 = (v.Width - v.RowWidth) * 0.5f; v.RowCount = HGMath.IntDivCeil(_equipmentIcons.Count, v.IconsPerRow); v.IconLocalScale = new Vector3(num, num, 1f); v.TopLeftCorner = new Vector3(((Rect)(ref rect)).xMin + num2, ((Rect)(ref rect)).yMax - 8f); v.Height = v.IconSize * (float)v.RowCount + 16f; } private void layoutAllIcons() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) calculateLayoutValues(out var v, _equipmentIcons.Count); int num = _equipmentIcons.Count - (v.RowCount - 1) * v.IconsPerRow; int i = 0; int num2 = 0; for (; i < v.RowCount; i++) { Vector3 topLeftCorner = v.TopLeftCorner; topLeftCorner.y += (float)i * (0f - v.IconSize); int num3 = v.IconsPerRow; if (i == v.RowCount - 1) { num3 = num; } int num4 = 0; while (num4 < num3) { RectTransform rectTransform = _equipmentIcons[num2].rectTransform; ((Transform)rectTransform).localScale = v.IconLocalScale; ((Transform)rectTransform).localPosition = topLeftCorner; topLeftCorner.x += v.IconSize; num4++; num2++; } } } private void layoutIndividualIcon(in LayoutValues layoutValues, int i) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) int num = i / layoutValues.IconsPerRow; int num2 = i - num * layoutValues.IconsPerRow; Vector3 topLeftCorner = layoutValues.TopLeftCorner; topLeftCorner.x += (float)num2 * layoutValues.IconSize; topLeftCorner.y += (float)num * (0f - layoutValues.IconSize); RectTransform rectTransform = _equipmentIcons[i].rectTransform; ((Transform)rectTransform).localPosition = topLeftCorner; ((Transform)rectTransform).localScale = layoutValues.IconLocalScale; } private void cacheComponents() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown _rectTransform = (RectTransform)((Component)this).transform; } protected override void Awake() { ((UIBehaviour)this).Awake(); cacheComponents(); _equipments = Array.Empty(); } protected override void OnDestroy() { SetSubscribedInventory(null); ((UIBehaviour)this).OnDestroy(); } protected override void OnEnable() { ((UIBehaviour)this).OnEnable(); if (Object.op_Implicit((Object)(object)_inventory)) { onInventoryChanged(); } requestUpdateDisplay(); layoutAllIcons(); } private void requestUpdateDisplay() { if (!_updateRequestPending) { _updateRequestPending = true; RoR2Application.onNextUpdate += UpdateDisplay; } } public void UpdateDisplay() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) _updateRequestPending = false; if (Object.op_Implicit((Object)(object)this) && ((Behaviour)this).isActiveAndEnabled) { allocateIcons(_equipments.Length); for (int i = 0; i < _equipments.Length; i++) { _equipmentIcons[i].SetPickupIndex(PickupCatalog.FindPickupIndex(_equipments[i])); } } } public void SetEquipments(EquipmentIndex[] newEquipments) { _equipments = newEquipments; requestUpdateDisplay(); } public void ResetEquipments() { Array.Clear(_equipments, 0, _equipments.Length); requestUpdateDisplay(); } protected override void OnRectTransformDimensionsChange() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ((UIBehaviour)this).OnRectTransformDimensionsChange(); if (Object.op_Implicit((Object)(object)_rectTransform)) { Rect rect = _rectTransform.rect; float width = ((Rect)(ref rect)).width; if (width != _previousWidth) { _previousWidth = width; layoutAllIcons(); } } } public void CalculateLayoutInputHorizontal() { } public void CalculateLayoutInputVertical() { if (!isUninitialized) { calculateLayoutValues(out var v, _equipmentIcons.Count); preferredHeight = v.Height; } } protected void OnValidate() { cacheComponents(); } } [RequireComponent(typeof(RectTransform))] public class GenericPickupIcon : MonoBehaviour { public static readonly GameObject Prefab; [SerializeField] private RawImage _glowImage; [SerializeField] private RawImage _image; [SerializeField] private TextMeshProUGUI _stackText; [SerializeField] private TooltipProvider _tooltipProvider; private PickupIndex _pickupIndex; private int _count; public RectTransform rectTransform { get; private set; } static GenericPickupIcon() { //IL_0005: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) Prefab = Object.Instantiate(Addressables.LoadAssetAsync((object)"RoR2/Base/UI/ItemIcon.prefab").WaitForCompletion()); Object.DontDestroyOnLoad((Object)(object)Prefab); ((Object)Prefab).hideFlags = (HideFlags)61; ((Object)Prefab).name = "PickupIcon"; ItemIcon component = Prefab.GetComponent(); GenericPickupIcon genericPickupIcon = Prefab.AddComponent(); genericPickupIcon._glowImage = component.glowImage; genericPickupIcon._image = component.image; genericPickupIcon._stackText = component.stackText; genericPickupIcon._tooltipProvider = component.tooltipProvider; ((RectTransform)((Component)genericPickupIcon).transform).sizeDelta = new Vector2(32f, 32f); Object.Destroy((Object)(object)component); } private void Awake() { CacheRectTransform(); } public void CacheRectTransform() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if ((Object)(object)rectTransform == (Object)null) { rectTransform = (RectTransform)((Component)this).transform; } } public void SetPickupIndex(PickupIndex newPickupIndex, int newPickupCount = 1) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0108: Unknown result type (might be due to invalid IL or missing references) if (_pickupIndex == newPickupIndex && _count == newPickupCount) { return; } _pickupIndex = newPickupIndex; _count = newPickupCount; string titleToken = ""; string bodyToken = ""; Color val = Color.white; Color bodyColor = default(Color); ((Color)(ref bodyColor))..ctor(0.6f, 0.6f, 0.6f, 1f); PickupDef pickupDef = PickupCatalog.GetPickupDef(_pickupIndex); if (pickupDef != null) { _image.texture = pickupDef.iconTexture; if (_count > 1) { ((Behaviour)_stackText).enabled = true; ((TMP_Text)_stackText).text = $"x{_count}"; } else { ((Behaviour)_stackText).enabled = false; } titleToken = pickupDef.nameToken; val = pickupDef.darkColor; bodyToken = "???"; if (pickupDef.IsItem()) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if ((Object)(object)itemDef != (Object)null) { bodyToken = itemDef.pickupToken; } } else if (pickupDef.IsEquipment()) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); if ((Object)(object)equipmentDef != (Object)null) { bodyToken = equipmentDef.pickupToken; } } } if (Object.op_Implicit((Object)(object)_glowImage)) { ((Graphic)_glowImage).color = new Color(val.r, val.g, val.b, 0.75f); } if (Object.op_Implicit((Object)(object)_tooltipProvider)) { _tooltipProvider.titleToken = titleToken; _tooltipProvider.bodyToken = bodyToken; _tooltipProvider.titleColor = val; _tooltipProvider.bodyColor = bodyColor; } } } } namespace RoR2Randomizer.Utility.Comparers { public sealed class MasterIndexComparer : IComparer { public static readonly MasterIndexComparer Instance = new MasterIndexComparer(); private MasterIndexComparer() { } public int Compare(MasterIndex x, MasterIndex y) { //IL_0000: 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) return ((int)x).CompareTo((int)y); } } public sealed class PickupIndexComparer : IComparer { public static readonly PickupIndexComparer Instance = new PickupIndexComparer(); private PickupIndexComparer() { } public int Compare(PickupIndex x, PickupIndex y) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return x.value.CompareTo(y.value); } } } namespace RoR2Randomizer.Utility.Catalog { public abstract class GenericCatalog : IEnumerable, IEnumerable where TIdentifier : ICatalogIdentifier { public delegate void IdentifierAppendedDelegate(in TIdentifier identifier); protected static readonly string LOG_PREFIX_TYPE = "(TObjects=" + typeof(TObjects).Name + ", TIdentifier=" + typeof(TIdentifier).Name + ") "; protected int _identifiersCount; protected TIdentifier[] _identifiers = new TIdentifier[20]; protected virtual TIdentifier InvalidIdentifier => default(TIdentifier); public event IdentifierAppendedDelegate OnIdentifierAppended; public TIdentifier GetIdentifier(int index) { if (index < 0 || index >= _identifiersCount) { return InvalidIdentifier; } return _identifiers[index]; } protected void appendIdentifier(ref TIdentifier identifier, bool checkExisting) { if (checkExisting) { for (int i = 0; i < _identifiersCount; i++) { if (_identifiers[i].Equals(in identifier, compareIndex: false)) { return; } } } int identifiersCount = _identifiersCount; identifier.Index = identifiersCount; ArrayUtils.ArrayAppend(ref _identifiers, ref _identifiersCount, ref identifier); this.OnIdentifierAppended?.Invoke(in identifier); } protected bool tryGetAttackIdentifier(TObjects obj, out TIdentifier identifier) { foreach (TIdentifier item in _identifiers.Take(_identifiersCount)) { if (item.Matches(obj)) { identifier = item; return true; } } identifier = default(TIdentifier); return false; } public virtual TIdentifier GetIdentifier(TObjects obj) { if (!tryGetAttackIdentifier(obj, out var identifier)) { return InvalidIdentifier; } return identifier; } public IEnumerator GetEnumerator() { return _identifiers.Take(_identifiersCount).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public abstract class GenericNetworkedCatalog : GenericCatalog, INetMessageProvider where TIdentifier : ICatalogIdentifier { public virtual bool SendMessages => true; protected GenericNetworkedCatalog() { NetworkingManager.RegisterMessageProvider(this, MessageProviderFlags.Persistent); } protected abstract bool tryCreateIdentifierForObject(TObject obj, out TIdentifier identifier); public override TIdentifier GetIdentifier(TObject obj) { TIdentifier identifier = base.GetIdentifier(obj); if (!identifier.IsValid) { if (!tryCreateIdentifierForObject(obj, out identifier)) { return InvalidIdentifier; } if (!NetworkServer.active) { if (NetworkClient.active) { NetworkMessageBase syncIdentifierNeededMessage = getSyncIdentifierNeededMessage(in identifier); if (syncIdentifierNeededMessage != null) { syncIdentifierNeededMessage.SendTo((NetworkDestination)2); } else { Log.Warning(GenericCatalog.LOG_PREFIX_TYPE + "catalog is networked, but syncIdentifierNeededMessage is null", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Utility\\Catalog\\GenericNetworkedCatalog.cs", "GetIdentifier", 52); } } return InvalidIdentifier; } appendIdentifier(ref identifier, checkExisting: false); if (!NetworkServer.dontListen) { this.TrySendAll((NetworkDestination)1); } } return identifier; } protected abstract NetworkMessageBase getSyncIdentifierNeededMessage(in TIdentifier identifier); public abstract IEnumerable GetNetMessages(); protected void SyncCatalog_OnReceive(TIdentifier[] identifiers, int identifiersCount) { if (!NetworkServer.active && NetworkClient.active) { _identifiersCount = identifiersCount; ArrayUtils.EnsureCapacity(ref _identifiers, identifiersCount); Array.Copy(identifiers, _identifiers, identifiersCount); } } protected void SyncIndexNeeded_OnReceive(TIdentifier required) { if (!NetworkServer.active) { return; } bool flag = false; for (int i = 0; i < _identifiersCount; i++) { if (_identifiers[i].Equals(in required, compareIndex: false)) { required.Index = _identifiers[i].Index; flag = true; break; } } if (!flag) { appendIdentifier(ref required, checkExisting: true); } foreach (NetworkMessageBase netMessage in GetNetMessages()) { netMessage.SendTo((NetworkDestination)1); } } } public interface ICatalogIdentifier { int Index { get; set; } bool IsValid { get; } bool Matches(T value); bool Equals(in TIdentifier other, bool compareIndex); T CreateInstance(); } } namespace RoR2Randomizer.RandomizerControllers { public abstract class BaseRandomizerController : MonoBehaviour, INetMessageProvider { public readonly RunSpecific RNG = new RunSpecific(delegate(out Xoroshiro128Plus result) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (RNGManager.RandomizerServerRNG.HasValue) { result = new Xoroshiro128Plus(RNGManager.RandomizerServerRNG.Value.Next()); return true; } result = null; return false; }, 9); public abstract bool IsRandomizerEnabled { get; } protected abstract bool isNetworked { get; } bool INetMessageProvider.SendMessages => IsRandomizerEnabled; protected virtual void Awake() { if (isNetworked) { NetworkingManager.RegisterMessageProvider(this, MessageProviderFlags.Persistent); } } protected virtual void OnDestroy() { if (isNetworked) { NetworkingManager.UnregisterMessageProvider(this); } RNG.Dispose(); } IEnumerable INetMessageProvider.GetNetMessages() { return getNetMessages(); } protected virtual IEnumerable getNetMessages() { yield break; } } public abstract class CharacterReplacementInfo : MonoBehaviour, INetMessageProvider { protected enum SetSubtitleMode : byte { DontOverride, OnlyIfExistingIsNull, DontOverrideIfBothNotNull, AlwaysOverride } private bool _initializeOnEnable; protected CharacterMaster _master; protected CharacterBody _body; private CharacterMaster _masterPrefab; protected virtual CharacterMaster originalMasterPrefab => _masterPrefab; protected CharacterBody originalBodyPrefab { get { CharacterMaster val = originalMasterPrefab; CharacterBody result = default(CharacterBody); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.bodyPrefab) && val.bodyPrefab.TryGetComponent(ref result)) { return result; } return null; } } protected abstract bool isNetworked { get; } bool INetMessageProvider.SendMessages => isNetworked; protected virtual SetSubtitleMode subtitleOverrideMode => SetSubtitleMode.DontOverride; public void SetOriginalMasterIndex(MasterIndex index) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) GameObject masterPrefab = MasterCatalog.GetMasterPrefab(index); _masterPrefab = ((masterPrefab != null) ? masterPrefab.GetComponent() : null); } private void Awake() { _master = ((Component)this).GetComponent(); if (isNetworked) { NetworkingManager.RegisterMessageProvider(this); } } private void OnDestroy() { if (isNetworked) { NetworkingManager.UnregisterMessageProvider(this); } } private void Start() { if (_initializeOnEnable) { _initializeOnEnable = false; Initialize(); } } public void Initialize() { if (((Component)this).gameObject.activeInHierarchy) { ((MonoBehaviour)this).StartCoroutine(waitForBodyInitialized()); if (NetworkServer.active) { initializeServer(); } initializeClient(); } else { _initializeOnEnable = true; } } private IEnumerator waitForBodyInitialized() { if (!Object.op_Implicit((Object)(object)_body)) { _body = _master.GetBody(); if (!Object.op_Implicit((Object)(object)_body)) { while (Object.op_Implicit((Object)(object)_master) && !_master.hasBody) { yield return 0; } if (!Object.op_Implicit((Object)(object)_master)) { yield break; } _body = _master.GetBody(); } } if (Object.op_Implicit((Object)(object)_body)) { bodyResolved(); } } protected virtual void bodyResolved() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = _master.inventory; if (Object.op_Implicit((Object)(object)inventory)) { giveAdaptiveArmorFromOriginalMaster(inventory); GivePickupsOnStart component = ((Component)_master).GetComponent(); if (_body.bodyIndex == BodyCatalog.FindBodyIndex("EquipmentDroneBody")) { giveDroneEquipment(inventory, component); } else if (_body.bodyIndex == BodyCatalog.FindBodyIndex("DroneCommanderBody")) { DroneWeaponsBehavior.SetNumDroneParts(inventory, 1); } } tryOverrideBodySubtitle(); } private void giveDroneEquipment(Inventory inventory, GivePickupsOnStart droneGivePickupsOnStart) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((!Object.op_Implicit((Object)(object)droneGivePickupsOnStart) || !droneGivePickupsOnStart.HasAnyEquipment()) && (int)inventory.GetEquipmentIndex() == -1) { EquipmentIndex randomOrDefault = ((IEnumerable)(object)CharacterReplacements.AvailableDroneEquipments).GetRandomOrDefault(RoR2Application.rng, (EquipmentIndex)(-1)); inventory.SetEquipmentIndex(randomOrDefault); } } private void giveAdaptiveArmorFromOriginalMaster(Inventory inventory) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) CharacterMaster val = originalMasterPrefab; if (Object.op_Implicit((Object)(object)val)) { GivePickupsOnStart component = ((Component)val).GetComponent(); ItemIndex itemIndex = Items.AdaptiveArmor.itemIndex; if (Object.op_Implicit((Object)(object)component) && component.HasItems(itemIndex, out var count)) { inventory.GiveItemPermanent(itemIndex, count); } } } protected virtual void initializeClient() { syncDontDestroyOnLoadStatusWithOriginal(); } private void syncDontDestroyOnLoadStatusWithOriginal() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_master) || Object.op_Implicit((Object)(object)((Component)_master).GetComponent())) { return; } CharacterMaster val = originalMasterPrefab; if (!Object.op_Implicit((Object)(object)val)) { return; } SetDontDestroyOnLoad val2 = default(SetDontDestroyOnLoad); if (Object.op_Implicit((Object)(object)((Component)val).GetComponent())) { ((Component)_master).gameObject.GetOrAddComponent(); } else if (((Component)_master).TryGetComponent(ref val2)) { Object.Destroy((Object)(object)val2); if (Util.IsDontDestroyOnLoad(((Component)_master).gameObject)) { SceneManager.MoveGameObjectToScene(((Component)_master).gameObject, SceneManager.GetActiveScene()); } } } protected virtual void initializeServer() { if (!isNetworked || NetworkServer.dontListen) { return; } foreach (NetworkMessageBase netMessage in getNetMessages()) { netMessage.SendTo((NetworkDestination)1); } } protected virtual IEnumerable getNetMessages() { yield break; } IEnumerable INetMessageProvider.GetNetMessages() { return getNetMessages(); } private void tryOverrideBodySubtitle() { if (!Object.op_Implicit((Object)(object)_body)) { return; } CharacterBody val = originalBodyPrefab; if (!Object.op_Implicit((Object)(object)val)) { return; } string subtitleNameToken = val.subtitleNameToken; if (string.Equals(_body.subtitleNameToken, subtitleNameToken)) { return; } switch (subtitleOverrideMode) { case SetSubtitleMode.DontOverride: return; case SetSubtitleMode.OnlyIfExistingIsNull: if (!string.IsNullOrEmpty(_body.subtitleNameToken)) { return; } break; case SetSubtitleMode.DontOverrideIfBothNotNull: if (!string.IsNullOrEmpty(_body.subtitleNameToken) && !string.IsNullOrEmpty(subtitleNameToken)) { return; } break; } _body.subtitleNameToken = subtitleNameToken; if (Object.op_Implicit((Object)(object)_master) && _master.isBoss) { forceRefreshBossGroupSubtitle(); } } private void forceRefreshBossGroupSubtitle() { foreach (BossGroup instances in InstanceTracker.GetInstancesList()) { for (int i = 0; i < instances.bossMemoryCount; i++) { if ((Object)(object)instances.bossMemories[i].cachedMaster == (Object)(object)_master) { instances.bestObservedName = string.Empty; instances.bestObservedSubtitle = string.Empty; return; } } } } } public enum CharacterReplacementMode { None = -1, Random, Gup } public class CharacterReplacements : INetMessageProvider { public delegate void OnDirectorSpawnReplacedCallback(GameObject result, MasterIndex originalMasterIndex); private static CharacterReplacements _instance; public static ReadOnlyArray AvailableDroneEquipments; private static int[] _masterIndicesToRandomize; private static bool _hasInvokedReplacementsInitialized = false; private static ulong _invokeReplacementsInitializedRunCallbackHandle; private static readonly RunSpecific _rng = new RunSpecific(delegate(out Xoroshiro128Plus result) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (RNGManager.RandomizerServerRNG.HasValue) { result = new Xoroshiro128Plus(RNGManager.RandomizerServerRNG.Value.Next()); return true; } result = null; return false; }, 9); private static readonly RunSpecific _hasReceivedMasterIndexReplacementsFromServer = new RunSpecific(1, defaultValue: false); private static readonly RunSpecific _masterIndexReplacements = new RunSpecific(delegate(out IndexReplacementsCollection result) { if (NetworkServer.active && _replacementMode.Value == CharacterReplacementMode.Random) { IEnumerable collection = _masterIndicesToRandomize.Where((int i) => !ConfigManager.ExplicitSpawnRandomizer.IsBlacklisted((MasterIndex)i)); result = new IndexReplacementsCollection(ReplacementDictionary.CreateFrom(collection, _rng, delegate(int key, int value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_001d: Unknown result type (might be due to invalid IL or missing references) MasterIndex heretic = Caches.Masters.Heretic; CharacterMaster val = default(CharacterMaster); CharacterBody val2 = default(CharacterBody); return (!((MasterIndex)(ref heretic)).isValid || key != Caches.Masters.Heretic.i || !MasterCatalog.GetMasterPrefab((MasterIndex)value).TryGetComponent(ref val) || !Object.op_Implicit((Object)(object)val.bodyPrefab) || !val.bodyPrefab.TryGetComponent(ref val2) || !(val2.baseMoveSpeed <= 0f)) ? true : false; }), MasterCatalog.masterPrefabs.Length); return true; } result = default(IndexReplacementsCollection); return false; }, 1); private static readonly RunSpecific _replacementMode = new RunSpecific(delegate(out CharacterReplacementMode result) { if (NetworkServer.active) { if (ConfigManager.Fun.GupModeActive) { result = CharacterReplacementMode.Gup; } else { result = CharacterReplacementMode.Random; } return true; } result = CharacterReplacementMode.None; return false; }, 2, CharacterReplacementMode.None); public static bool IsEnabled { get { if (!NetworkServer.active) { if (NetworkClient.active) { if (!_hasReceivedMasterIndexReplacementsFromServer) { return _replacementMode.HasValue; } return true; } return false; } return true; } } public static bool IsAnyForcedCharacterModeEnabled { get { if (_replacementMode.HasValue) { return _replacementMode.Value >= CharacterReplacementMode.Gup; } return false; } } public bool SendMessages { get { if (!_masterIndexReplacements.HasValue) { return IsAnyForcedCharacterModeEnabled; } return true; } } public static event Action OnCharacterReplacementsInitialized; public static bool ShouldRandomizeMaster(CharacterMaster masterPrefab) { if (!Object.op_Implicit((Object)(object)masterPrefab)) { return false; } if (!Object.op_Implicit((Object)(object)masterPrefab.bodyPrefab)) { return false; } CharacterBody val = default(CharacterBody); if (!masterPrefab.bodyPrefab.TryGetComponent(ref val)) { return false; } ModelLocator val2 = default(ModelLocator); Transform modelTransform; if (!((Component)val).TryGetComponent(ref val2) || !Object.op_Implicit((Object)(object)(modelTransform = val2.modelTransform))) { return false; } if (modelTransform.childCount == 0) { return false; } switch (((Object)masterPrefab).name) { case "AncientWispMaster": case "SolusVendorMaster": case "ArtifactShellMaster": case "ClaymanMaster": case "EngiBeamTurretMaster": case "MinorConstructAttachableMaster": case "VoidRaidCrabJointMaster": case "SolusHeartMaster": case "SolusHeartMaster_Offering": case "ExhaustPortWeakpointMaster": case "VoidRaidCrabMaster": return false; default: return true; } } [SystemInitializer(new Type[] { typeof(EquipmentCatalog), typeof(MasterCatalog) })] private static void Init() { //IL_0076: 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) AvailableDroneEquipments = ReadOnlyArray.op_Implicit((from e in EquipmentCatalog.equipmentDefs where Object.op_Implicit((Object)(object)e) && (e.canDrop || Object.op_Implicit((Object)(object)e.passiveBuffDef) || (Object)(object)e == (Object)(object)Equipment.QuestVolatileBattery || (Object)(object)e == (Object)(object)Equipment.BossHunterConsumed || (Object)(object)e == (Object)(object)Equipment.LunarPortalOnUse) && (Object)(object)e != (Object)(object)Equipment.EliteVoidEquipment select e.equipmentIndex into ei orderby ei select ei).ToArray()); _masterIndicesToRandomize = (from go in MasterCatalog.masterPrefabs.Where(delegate(GameObject master) { if (!Object.op_Implicit((Object)(object)master)) { return false; } CharacterMaster masterPrefab = default(CharacterMaster); return master.TryGetComponent(ref masterPrefab) && ShouldRandomizeMaster(masterPrefab); }).Distinct() select (int)MasterCatalog.FindMasterIndex(go)).ToArray(); _instance = new CharacterReplacements(); NetworkingManager.RegisterMessageProvider(_instance, MessageProviderFlags.Persistent); SyncCharacterMasterReplacements.OnReceive += onMasterReplacementsReceivedFromServer; SyncCharacterMasterReplacementMode.OnReceive += onMasterReplacementModeReceivedFromServer; _invokeReplacementsInitializedRunCallbackHandle = RunSpecificCallbacksManager.AddEntry((Action)delegate { if (IsEnabled) { tryInvokeCharacterReplacementsInitialized(); } }, (Action)delegate { _hasInvokedReplacementsInitialized = false; }, 0); } public IEnumerable GetNetMessages() { if (_replacementMode.HasValue) { yield return new SyncCharacterMasterReplacementMode(_replacementMode); } if (!_replacementMode.HasValue || _replacementMode.Value == CharacterReplacementMode.Random) { yield return new SyncCharacterMasterReplacements((IndexReplacementsCollection)_masterIndexReplacements); } } private static void onMasterReplacementsReceivedFromServer(in IndexReplacementsCollection masterIndexReplacements) { _masterIndexReplacements.Value = masterIndexReplacements; _hasReceivedMasterIndexReplacementsFromServer.Value = true; tryInvokeCharacterReplacementsInitialized(); } private static void onMasterReplacementModeReceivedFromServer(CharacterReplacementMode mode) { _replacementMode.Value = mode; if (IsAnyForcedCharacterModeEnabled) { tryInvokeCharacterReplacementsInitialized(); } } private static void tryInvokeCharacterReplacementsInitialized() { if (!_hasInvokedReplacementsInitialized) { CharacterReplacements.OnCharacterReplacementsInitialized?.Invoke(); _hasInvokedReplacementsInitialized = true; } } public static void Uninitialize() { _replacementMode.Dispose(); _masterIndexReplacements.Dispose(); _hasReceivedMasterIndexReplacementsFromServer.Dispose(); SyncCharacterMasterReplacements.OnReceive -= onMasterReplacementsReceivedFromServer; SyncCharacterMasterReplacementMode.OnReceive -= onMasterReplacementModeReceivedFromServer; RunSpecificCallbacksManager.RemoveEntry(_invokeReplacementsInitializedRunCallbackHandle); _instance = null; } public static GameObject GetReplacementMasterPrefab(string originalMasterName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0015: Unknown result type (might be due to invalid IL or missing references) MasterIndex replacementForMasterIndex = GetReplacementForMasterIndex(MasterCatalog.FindMasterIndex(originalMasterName)); if (((MasterIndex)(ref replacementForMasterIndex)).isValid) { return MasterCatalog.GetMasterPrefab(replacementForMasterIndex); } return null; } public static bool TryReplaceMasterPrefab(ref GameObject prefab) { GameObject replacementMasterPrefab = GetReplacementMasterPrefab(((Object)prefab).name); if (Object.op_Implicit((Object)(object)replacementMasterPrefab)) { prefab = replacementMasterPrefab; return true; } return false; } private static MasterIndex getMasterIndexForBody(BodyIndex bodyIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_003c: 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) if ((int)bodyIndex != -1) { CharacterBody val2 = default(CharacterBody); CharacterMaster val = MasterCatalog.allMasters.FirstOrDefault((Func)((CharacterMaster m) => Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.bodyPrefab) && m.bodyPrefab.TryGetComponent(ref val2) && val2.bodyIndex == bodyIndex)); if (Object.op_Implicit((Object)(object)val)) { return val.masterIndex; } } return MasterIndex.none; } private static BodyIndex getBodyIndexForMaster(MasterIndex index) { //IL_0009: 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) if (((MasterIndex)(ref index)).isValid) { GameObject masterPrefab = MasterCatalog.GetMasterPrefab(index); CharacterMaster val = default(CharacterMaster); CharacterBody val2 = default(CharacterBody); if (Object.op_Implicit((Object)(object)masterPrefab) && masterPrefab.TryGetComponent(ref val) && Object.op_Implicit((Object)(object)val.bodyPrefab) && val.bodyPrefab.TryGetComponent(ref val2)) { return val2.bodyIndex; } } return (BodyIndex)(-1); } public static BodyIndex GetReplacementBodyIndex(BodyIndex original) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) if (IsEnabled) { return getBodyIndexForMaster(GetReplacementForMasterIndex(getMasterIndexForBody(original))); } return (BodyIndex)(-1); } public static BodyIndex GetOriginalBodyIndex(BodyIndex replacement) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) if (IsEnabled) { return getBodyIndexForMaster(GetOriginalMasterIndex(getMasterIndexForBody(replacement))); } return (BodyIndex)(-1); } public static MasterIndex GetReplacementForMasterIndex(MasterIndex original) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_006e: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && ConfigManager.ExplicitSpawnRandomizer.IsBlacklisted(original)) { return MasterIndex.none; } if (((MasterIndex)(ref original)).isValid && IsEnabled) { if (_replacementMode.HasValue && _replacementMode.Value == CharacterReplacementMode.Gup) { MasterIndex gup = Caches.Masters.Gup; if (!((MasterIndex)(ref gup)).isValid) { Log.Error("Gup mode enabled, but master index is invalid!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\CharacterReplacements.cs", "GetReplacementForMasterIndex", 497); return MasterIndex.none; } return Caches.Masters.Gup; } if (_masterIndexReplacements.HasValue && _masterIndexReplacements.Value.TryGetReplacement((int)original, out var replacement)) { return (MasterIndex)replacement; } } return MasterIndex.none; } public static MasterIndex GetOriginalMasterIndex(MasterIndex replacement) { //IL_003f: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (((MasterIndex)(ref replacement)).isValid && IsEnabled && _masterIndexReplacements.HasValue && _masterIndexReplacements.Value.TryGetOriginal((int)replacement, out var original)) { return (MasterIndex)original; } return MasterIndex.none; } public static Manipulator FixMasterIndexReferences(Func patchEnabled, params string[] names) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return (Manipulator)delegate(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); MemberReference member = null; int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => x.MatchGetMemberValue(out member) })) { int index = val.Index; val.Index = index + 1; if (member != null && Array.IndexOf(names, member.Name) != -1) { TypeReference val2 = null; MemberReference obj = member; MethodReference val3 = (MethodReference)(object)((obj is MethodReference) ? obj : null); if (val3 != null) { val2 = val3.ReturnType; } else { MemberReference obj2 = member; FieldReference val4 = (FieldReference)(object)((obj2 is FieldReference) ? obj2 : null); if (val4 != null) { val2 = val4.FieldType; } else { Log.Warning("unimplemented member type of " + ((object)member).GetType().FullName, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\CharacterReplacements.cs", "FixMasterIndexReferences", 552); } } if (val2 != null) { if (Extensions.Is((MemberReference)(object)val2, (MemberInfo)typeof(MasterIndex))) { val.EmitDelegate>((Func)replacefunc); num++; } else if (Extensions.Is((MemberReference)(object)val2, (MemberInfo)typeof(int))) { val.EmitDelegate>((Func)((int original) => (int)replacefunc((MasterIndex)original))); num++; } else { Log.Warning("unimplemented value type of " + ((MemberReference)val2).FullName, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\CharacterReplacements.cs", "FixMasterIndexReferences", 588); } } } } if (num <= 0) { Log.Warning("[" + string.Join(", ", names) + "] patched 0 locations", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\CharacterReplacements.cs", "FixMasterIndexReferences", 602); } }; MasterIndex replacefunc(MasterIndex original) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (patchEnabled == null || patchEnabled()) { MasterIndex replacementForMasterIndex = GetReplacementForMasterIndex(original); if (((MasterIndex)(ref replacementForMasterIndex)).isValid) { return replacementForMasterIndex; } } return original; } } public static void TryReplaceDirectorSpawnRequest(DirectorSpawnRequest spawnRequest, OnDirectorSpawnReplacedCallback onDirectorSpawnReplaced) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (spawnRequest == null) { return; } SpawnCard spawnCard = spawnRequest.spawnCard; if ((Object)(object)spawnCard == (Object)null) { return; } MasterIndex replacementForMasterIndex = GetReplacementForMasterIndex(MasterCatalog.FindMasterIndex(spawnCard.prefab)); GameObject originalPrefab; if (((MasterIndex)(ref replacementForMasterIndex)).isValid) { GameObject masterPrefab = MasterCatalog.GetMasterPrefab(replacementForMasterIndex); if (Object.op_Implicit((Object)(object)masterPrefab)) { originalPrefab = spawnCard.prefab; spawnCard.prefab = masterPrefab; DirectorCore_TrySpawnObject.Postfix += trySpawnObjectPostfix; } } void trySpawnObjectPostfix(ref GameObject result, DirectorSpawnRequest val) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)val.spawnCard == (Object)(object)spawnCard) { spawnCard.prefab = originalPrefab; CharacterMaster val2 = default(CharacterMaster); if (Object.op_Implicit((Object)(object)result) && Object.op_Implicit((Object)(object)originalPrefab) && originalPrefab.TryGetComponent(ref val2)) { onDirectorSpawnReplaced?.Invoke(result, val2.masterIndex); } DirectorCore_TrySpawnObject.Postfix -= trySpawnObjectPostfix; } } } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public sealed class RandomizerControllerAttribute : SearchableAttribute { } } namespace RoR2Randomizer.RandomizerControllers.SurvivorPod { [RequireComponent(typeof(CharacterBody))] public class MirroredIntroAnimationTracker : NetworkBehaviour { private enum State : byte { WaitingForIntro, HasEnteredIntro, HasEnteredMain } public SerializableEntityStateType IntroState; private CharacterBody _body; [SyncVar(hook = "onMirrorBodyIndexModified")] private int _mirrorBodyIndex = -1; private const uint _mirrorBodyIndex_DIRTY_BIT = 1u; [SyncVar(hook = "onIntroStateModified")] private byte _introStateByte; private const uint _introStateByte_DIRTY_BIT = 2u; [SyncVar] private float _tweenTime; private const uint _tweenTime_DIRTY_BIT = 4u; public CharacterAnimationMirrorOwner AnimationMirrorController; private EntityStateMachine _bodyEntityStateMachine; private bool _isWaitingForModel; public BodyIndex mirrorBodyIndex => (BodyIndex)_mirrorBodyIndex; public BodyIndex Network_mirrorBodyIndex { [param: In] set { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected I4, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.localClientActive && !((NetworkBehaviour)this).syncVarHookGuard) { ((NetworkBehaviour)this).syncVarHookGuard = true; onMirrorBodyIndexModified(value); ((NetworkBehaviour)this).syncVarHookGuard = false; } ((NetworkBehaviour)this).SetSyncVar((int)value, ref _mirrorBodyIndex, 1u); } } private State introState => (State)_introStateByte; private State Network_introState { [param: In] set { if (NetworkServer.localClientActive && !((NetworkBehaviour)this).syncVarHookGuard) { ((NetworkBehaviour)this).syncVarHookGuard = true; onIntroStateModified(value); ((NetworkBehaviour)this).syncVarHookGuard = false; } ((NetworkBehaviour)this).SetSyncVar((byte)value, ref _introStateByte, 2u); } } public float Network_tweenTime { [param: In] set { ((NetworkBehaviour)this).SetSyncVar(value, ref _tweenTime, 4u); } } private void Awake() { _body = ((Component)this).GetComponent(); if (RoR2Application.rng.nextNormalizedFloat <= 0.05f) { Network_tweenTime = RoR2Application.rng.RangeFloat(3f, 20f); } else { Network_tweenTime = 0.3f; } } private void Start() { _bodyEntityStateMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body"); if (!Object.op_Implicit((Object)(object)_bodyEntityStateMachine)) { Log.Warning(((Object)this).name + " has no state machine with the name Body", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SurvivorPod\\MirroredIntroAnimationTracker.cs", "Start", 112); } } private void Update() { if (Object.op_Implicit((Object)(object)_bodyEntityStateMachine) && ((NetworkBehaviour)this).isServer) { switch (introState) { case State.WaitingForIntro: checkHasEnteredIntroState(); break; case State.HasEnteredIntro: checkIsMainState(); break; } } } private bool isInState(SerializableEntityStateType entityStateType) { if (!Object.op_Implicit((Object)(object)_bodyEntityStateMachine)) { return false; } EntityState state = _bodyEntityStateMachine.state; if (state != null) { return ((object)state).GetType() == ((SerializableEntityStateType)(ref entityStateType)).stateType; } return false; } private void checkHasEnteredIntroState() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) if (isInState(IntroState)) { Network_introState = State.HasEnteredIntro; } } private void checkIsMainState() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (isInState(_bodyEntityStateMachine.mainStateType)) { Network_introState = State.HasEnteredMain; } } private void onIntroStateModified(State newIntroState) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 if ((int)newIntroState >= 2) { if (Object.op_Implicit((Object)(object)AnimationMirrorController)) { AnimationMirrorController.StopMirroring(_tweenTime); } } else if ((int)newIntroState >= 0 && (int)mirrorBodyIndex != -1) { updateMirrorController(); } Network_introState = newIntroState; } private void onMirrorBodyIndexModified(BodyIndex newBodyIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Network_mirrorBodyIndex = newBodyIndex; updateMirrorController(); } private void updateMirrorController() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 ModelLocator modelLocator; if (!_isWaitingForModel && (int)mirrorBodyIndex != -1 && !Object.op_Implicit((Object)(object)AnimationMirrorController)) { modelLocator = _body.modelLocator; Transform modelTransform = modelLocator.modelTransform; if (Object.op_Implicit((Object)(object)modelTransform)) { setupModel(modelTransform); return; } _isWaitingForModel = true; modelLocator.onModelChanged += setupModel; } void setupModel(Transform model) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)model)) { AnimationMirrorController = CharacterAnimationMirrorOwner.SetupForModelTransform(model, mirrorBodyIndex); } if (Object.op_Implicit((Object)(object)modelLocator)) { modelLocator.onModelChanged -= setupModel; } _isWaitingForModel = false; } } public override bool OnSerialize(NetworkWriter writer, bool initialState) { if (initialState) { NetworkExtensions.WritePackedIndex32(writer, _mirrorBodyIndex); writer.Write(_introStateByte); writer.Write(_tweenTime); return true; } uint syncVarDirtyBits = ((NetworkBehaviour)this).syncVarDirtyBits; writer.WritePackedUInt32(syncVarDirtyBits); bool result = false; if ((syncVarDirtyBits & 1) != 0) { NetworkExtensions.WritePackedIndex32(writer, _mirrorBodyIndex); result = true; } if ((syncVarDirtyBits & 2) != 0) { writer.Write(_introStateByte); result = true; } if ((syncVarDirtyBits & 4) != 0) { writer.Write(_tweenTime); result = true; } return result; } public override void OnDeserialize(NetworkReader reader, bool initialState) { if (initialState) { _mirrorBodyIndex = NetworkExtensions.ReadPackedIndex32(reader); _introStateByte = reader.ReadByte(); _tweenTime = reader.ReadSingle(); return; } uint num = reader.ReadPackedUInt32(); if ((num & 1) != 0) { onMirrorBodyIndexModified((BodyIndex)NetworkExtensions.ReadPackedIndex32(reader)); } if ((num & 2) != 0) { onIntroStateModified((State)reader.ReadByte()); } if ((num & 4) != 0) { _tweenTime = reader.ReadSingle(); } } } public readonly struct SpawnPodPrefabData { private class PodEqualityComparer : IEqualityComparer { public bool Equals(SpawnPodPrefabData x, SpawnPodPrefabData y) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) if (x.IsSpawnState != y.IsSpawnState) { return false; } if (x.IsSpawnState) { SerializableEntityStateType spawnState = x.SpawnState; Type stateType = ((SerializableEntityStateType)(ref spawnState)).stateType; spawnState = y.SpawnState; return stateType == ((SerializableEntityStateType)(ref spawnState)).stateType; } return (Object)(object)x.PodPrefab == (Object)(object)y.PodPrefab; } public int GetHashCode(SpawnPodPrefabData pod) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) int num = 1489032728; num = num * -1521134295 + pod.IsSpawnState.GetHashCode(); if (pod.IsSpawnState) { return num * -1521134295 + ((object)pod.SpawnState/*cast due to .constrained prefix*/).GetHashCode(); } return num * -1521134295 + ((object)pod.PodPrefab).GetHashCode(); } } public readonly bool IsSpawnState; public readonly BodyIndex TargetBodyIndex; public readonly GameObject PodPrefab; public readonly SerializableEntityStateType SpawnState; public static readonly IEqualityComparer EqualityComparer = new PodEqualityComparer(); public SpawnPodPrefabData(BodyIndex bodyIndex) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0054: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) IsSpawnState = false; PodPrefab = null; SpawnState = default(SerializableEntityStateType); CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(bodyIndex); if (!Object.op_Implicit((Object)(object)bodyPrefabBodyComponent)) { Log.Error($"null body prefab at index {bodyIndex}!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SurvivorPod\\SpawnPodPrefabData.cs", ".ctor", 23); TargetBodyIndex = (BodyIndex)(-1); return; } TargetBodyIndex = bodyIndex; if (Object.op_Implicit((Object)(object)bodyPrefabBodyComponent.preferredPodPrefab)) { IsSpawnState = false; PodPrefab = bodyPrefabBodyComponent.preferredPodPrefab; } else { IsSpawnState = true; SpawnState = bodyPrefabBodyComponent.preferredInitialStateType; } } public SpawnPodPrefabData(NetworkReader reader) { //IL_0014: 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) //IL_0021: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) IsSpawnState = false; PodPrefab = null; SpawnState = default(SerializableEntityStateType); TargetBodyIndex = NetworkExtensions.ReadBodyIndex(reader); CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(TargetBodyIndex); if (Object.op_Implicit((Object)(object)bodyPrefabBodyComponent)) { if (IsSpawnState = reader.ReadBoolean()) { SpawnState = bodyPrefabBodyComponent.preferredInitialStateType; } else { PodPrefab = bodyPrefabBodyComponent.preferredPodPrefab; } } else { Log.Error($"null body prefab at index {TargetBodyIndex}!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SurvivorPod\\SpawnPodPrefabData.cs", ".ctor", 59); } } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) NetworkExtensions.WriteBodyIndex(writer, TargetBodyIndex); writer.Write(IsSpawnState); } public static bool operator ==(in SpawnPodPrefabData a, in SpawnPodPrefabData b) { return EqualityComparer.Equals(a, b); } public static bool operator !=(in SpawnPodPrefabData a, in SpawnPodPrefabData b) { return !(a == b); } public override bool Equals(object obj) { if (obj is SpawnPodPrefabData y) { return EqualityComparer.Equals(this, y); } return false; } public override int GetHashCode() { return EqualityComparer.GetHashCode(this); } public void OverrideIntroAnimationOnBody(CharacterBody body) { //IL_005b: 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_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) if (IsSpawnState) { SerializableEntityStateType introState = (body.preferredInitialStateType = SpawnState); body.preferredPodPrefab = null; if (TargetBodyIndex != body.bodyIndex) { MirroredIntroAnimationTracker mirroredIntroAnimationTracker = ((Component)body).gameObject.AddComponent(); mirroredIntroAnimationTracker.IntroState = introState; mirroredIntroAnimationTracker.Network_mirrorBodyIndex = TargetBodyIndex; } } else { body.preferredPodPrefab = PodPrefab; body.preferredInitialStateType = default(SerializableEntityStateType); } } } [RandomizerController] public class SurvivorPodRandomizerController : BaseRandomizerController { private static SurvivorPodRandomizerController _instance; private static CharacterBody[] _bodiesWithPods; private static SpawnPodPrefabData[] _distinctPodPrefabs; private static readonly RunSpecific> _overrideSpawnPodPrefabs = new RunSpecific>(delegate(out Dictionary result) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (shouldBeActive && Object.op_Implicit((Object)(object)Instance)) { result = new Dictionary(); CharacterBody[] bodiesWithPods = _bodiesWithPods; foreach (CharacterBody val in bodiesWithPods) { SpawnPodPrefabData defaultSpawnData = getDefaultSpawnData(val); result.Add(val.bodyIndex, _distinctPodPrefabs.PickWeighted(Instance.RNG, (SpawnPodPrefabData s) => (!(s == defaultSpawnData)) ? 1f : 0.5f)); } return true; } result = null; return false; }); private static readonly RunSpecific _hasReceivedPodReplacementsFromServer = new RunSpecific(0, defaultValue: false); private static ulong _clearOverrideIntroBodiesListCallbackHandle; private static readonly HashSet _bodiesToOverrideIntroAnimationForOncePodReplacementsReceived = new HashSet(); public static SurvivorPodRandomizerController Instance => _instance; private static bool shouldBeActive { get { if (!NetworkServer.active || !ConfigManager.Misc.SurvivorPodRandomizerEnabled) { if (NetworkClient.active) { return _hasReceivedPodReplacementsFromServer; } return false; } return true; } } public override bool IsRandomizerEnabled => shouldBeActive; protected override bool isNetworked => true; [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static void Init() { IEnumerable source = BodyCatalog.allBodyPrefabBodyBodyComponents.Where((CharacterBody b) => Object.op_Implicit((Object)(object)b) && (Object.op_Implicit((Object)(object)b.preferredPodPrefab) || !b.preferredInitialStateType.IsNothing())); _bodiesWithPods = source.ToArray(); _distinctPodPrefabs = source.Select(getDefaultSpawnData).Distinct(SpawnPodPrefabData.EqualityComparer).ToArray(); } private static SpawnPodPrefabData getDefaultSpawnData(CharacterBody body) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new SpawnPodPrefabData(body.bodyIndex); } protected override IEnumerable getNetMessages() { if (_overrideSpawnPodPrefabs.HasValue) { yield return new SyncSurvivorPodReplacements(_overrideSpawnPodPrefabs); } } private static void SyncSurvivorPodReplacements_OnReceive(Dictionary overrideSpawnPods) { if (NetworkServer.active || !NetworkClient.active) { return; } _overrideSpawnPodPrefabs.Value = overrideSpawnPods; _hasReceivedPodReplacementsFromServer.Value = true; foreach (CharacterBody item in _bodiesToOverrideIntroAnimationForOncePodReplacementsReceived) { TryOverrideIntroAnimation(item); } _bodiesToOverrideIntroAnimationForOncePodReplacementsReceived.Clear(); } protected override void Awake() { base.Awake(); SyncSurvivorPodReplacements.OnReceive += SyncSurvivorPodReplacements_OnReceive; _clearOverrideIntroBodiesListCallbackHandle = RunSpecificCallbacksManager.AddEntry((Action)null, (Action)delegate { _bodiesToOverrideIntroAnimationForOncePodReplacementsReceived.Clear(); }, 0); SingletonHelper.Assign(ref _instance, this); } protected override void OnDestroy() { base.OnDestroy(); _overrideSpawnPodPrefabs.Dispose(); _hasReceivedPodReplacementsFromServer.Dispose(); RunSpecificCallbacksManager.RemoveEntry(_clearOverrideIntroBodiesListCallbackHandle); SyncSurvivorPodReplacements.OnReceive -= SyncSurvivorPodReplacements_OnReceive; SingletonHelper.Unassign(ref _instance, this); } public static void TryOverrideIntroAnimation(CharacterBody body) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (shouldBeActive) { if (_overrideSpawnPodPrefabs.HasValue && _overrideSpawnPodPrefabs.Value.TryGetValue(body.bodyIndex, out var value)) { value.OverrideIntroAnimationOnBody(body); } } else if (!NetworkServer.active && NetworkClient.active && !_hasReceivedPodReplacementsFromServer) { _bodiesToOverrideIntroAnimationForOncePodReplacementsReceived.Add(body); } } } } namespace RoR2Randomizer.RandomizerControllers.Stage { [Flags] public enum StageFlags : byte { None = 0, FirstStageBlacklist = 1, PossibleStartingStage = 2, Inaccessible = 4, EndsRun = 8 } public class StageRandomizerConfig : BaseRandomizerConfig { public readonly BoolConfigValue FirstStageBlacklistEnabled; private const float FIRST_STAGE_WEIGHT_MULT_DEFAULT = 0.35f; public readonly SliderConfigValue PossibleFirstStageWeightMult; private readonly ParsedSceneIndexListConfigValue _stageBlacklist; public bool IsStageBlacklisted(SceneIndex sceneIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _stageBlacklist.BinarySearch(sceneIndex) >= 0; } public StageRandomizerConfig(ConfigFile file) : base("Stage", file) { FirstStageBlacklistEnabled = new BoolConfigValue(getEntry("Starting Stage Blacklist", "Ensures the first stage is always normal(ish) (No run-ending stages will get picked as the first stage)", defaultValue: true)); PossibleFirstStageWeightMult = new SliderConfigValue(getEntry("Normal starting stage weight multiplier", $"If set to 0.50: Stages that have a chance to be selected as the first stage in a run are half as likely to get picked as the first stage by the stage randomizer.\n\nIf set to 0.25: Starting stages have a 4 times smaller chance to get picked as the first stage.\n\nIf set to 1.00: Feature is effectively disabled, and all stages will be equally likely to get picked.\n\nDefault value: {0.35f:F2}", 0.35f), SliderType.StepSlider, 0f, 1.5f, "F2", 0.05f); _stageBlacklist = new ParsedSceneIndexListConfigValue(getEntry("Stage Blacklist", "A comma separated list of stages to exclude from the randomizer\n\nThe internal names of the stages are used for this field", string.Empty)); } } [RandomizerController] public class StageRandomizerController : BaseRandomizerController { private static StageRandomizerController _instance; private static bool _isInitialized; private static StageRandomizingInfo[] _stages; private static IndexReplacementsCollection? _stageIndexReplacements; public static StageRandomizerController Instance => _instance; private static bool shouldBeActive { get { if (NetworkServer.active) { return ConfigManager.StageRandomizer.Enabled; } return false; } } public override bool IsRandomizerEnabled => shouldBeActive; protected override bool isNetworked => false; [SystemInitializer(new Type[] { typeof(Caches.Scene), typeof(SceneCatalog) })] private static void Init() { //IL_0000: 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) //IL_003c: Expected I4, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected I4, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected I4, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected I4, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected I4, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected I4, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected I4, but got Unknown _stages = ((IEnumerable)(object)SceneCatalog.allStageSceneDefs).Where((SceneDef s) => !Caches.Scene.IsSimulacrumStage(s)).Concat(((IEnumerable)(object)new SceneIndex[8] { (SceneIndex)(int)Caches.Scene.ArtifactTrialSceneIndex, (SceneIndex)(int)Caches.Scene.NewtShopSceneIndex, (SceneIndex)(int)Caches.Scene.GoldShoresSceneIndex, (SceneIndex)(int)Caches.Scene.ObliterateSceneIndex, (SceneIndex)(int)Caches.Scene.LunarScavFightSceneIndex, (SceneIndex)(int)Caches.Scene.OldCommencementSceneIndex, (SceneIndex)(int)Caches.Scene.AITestSceneIndex, (SceneIndex)(int)Caches.Scene.TestSceneSceneIndex }).Where((SceneIndex s) => (int)s != -1).Select((Func)SceneCatalog.GetSceneDef)).Select(delegate(SceneDef scene) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_000f: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 //IL_0011: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0031: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_008c: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00a6: Unknown result type (might be due to invalid IL or missing references) SceneIndex sceneDefIndex = scene.sceneDefIndex; StageFlags stageFlags = StageFlags.None; if (((int)Caches.Scene.OldCommencementSceneIndex != -1 && sceneDefIndex == Caches.Scene.OldCommencementSceneIndex) || ((int)Caches.Scene.AITestSceneIndex != -1 && sceneDefIndex == Caches.Scene.AITestSceneIndex) || ((int)Caches.Scene.TestSceneSceneIndex != -1 && sceneDefIndex == Caches.Scene.TestSceneSceneIndex)) { stageFlags |= StageFlags.Inaccessible; } if (((int)Caches.Scene.CommencementSceneIndex != -1 && sceneDefIndex == Caches.Scene.CommencementSceneIndex) || ((int)Caches.Scene.LunarScavFightSceneIndex != -1 && sceneDefIndex == Caches.Scene.LunarScavFightSceneIndex) || ((int)Caches.Scene.VoidlingFightSceneIndex != -1 && sceneDefIndex == Caches.Scene.VoidlingFightSceneIndex) || ((int)Caches.Scene.OldCommencementSceneIndex != -1 && sceneDefIndex == Caches.Scene.OldCommencementSceneIndex)) { stageFlags |= StageFlags.EndsRun; } if ((stageFlags & StageFlags.EndsRun) != StageFlags.None || ((int)Caches.Scene.VoidLocusSceneIndex != -1 && sceneDefIndex == Caches.Scene.VoidLocusSceneIndex)) { stageFlags |= StageFlags.FirstStageBlacklist; } if (Caches.Scene.IsPossibleStartingStage(sceneDefIndex)) { stageFlags |= StageFlags.PossibleStartingStage; } return new StageRandomizingInfo(sceneDefIndex, stageFlags); }) .ToArray(); _isInitialized = true; } protected override void Awake() { base.Awake(); SceneCatalog.onMostRecentSceneDefChanged += sceneLoaded; SingletonHelper.Assign(ref _instance, this); } protected override void OnDestroy() { base.OnDestroy(); SceneCatalog.onMostRecentSceneDefChanged -= sceneLoaded; SingletonHelper.Unassign(ref _instance, this); } private void sceneLoaded(SceneDef scene) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) //IL_00a6: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0133: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Transform zonesHolder; if (shouldBeActive) { ((MonoBehaviour)this).StartCoroutine(waitThenCheckForStageLooping(scene)); if ((int)Caches.Scene.AITestSceneIndex != -1 && scene.sceneDefIndex == Caches.Scene.AITestSceneIndex) { zonesHolder = ((GameObject)(((object)GameObject.Find("HOLDER: Zones")) ?? ((object)new GameObject("HOLDER: Zones")))).transform; addOOBTrigger(new Vector3(0f, -300f, 0f), new Vector3(1000f, 500f, 1000f)); addOOBTrigger(new Vector3(600f, 200f, 0f), new Vector3(1000f, 500f, 1000f)); addOOBTrigger(new Vector3(-800f, 200f, 0f), new Vector3(1000f, 500f, 1000f)); addOOBTrigger(new Vector3(0f, 200f, 750f), new Vector3(1000f, 500f, 1000f)); addOOBTrigger(new Vector3(0f, 200f, -750f), new Vector3(1000f, 500f, 1000f)); addOOBTrigger(new Vector3(0f, 500f, 0f), new Vector3(1000f, 500f, 1000f)); } } void addOOBTrigger(Vector3 position, Vector3 scale) { //IL_0005: 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_001a: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OOB_TRIGGER") { layer = LayerIndex.collideWithCharacterHullOnly.intVal }; val.transform.SetParent(zonesHolder, false); val.transform.position = position; val.transform.localScale = scale; ((Collider)val.AddComponent()).isTrigger = true; MapZone obj = val.AddComponent(); obj.triggerType = (TriggerType)1; obj.zoneType = (ZoneType)0; } } private static IEnumerator waitThenCheckForStageLooping(SceneDef scene) { for (int i = 0; i < 5; i++) { yield return (object)new WaitForEndOfFrame(); } if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)Run.instance.nextStageScene) && TryGetReplacementSceneDef(Run.instance.nextStageScene, out var replacement) && (Object)(object)replacement == (Object)(object)scene && TryGetOriginalSceneDef(scene, out var originalScene)) { Run.PickNextStageSceneFromSceneDestinations(Run.instance, originalScene); } } public static void InitializeStageReplacements(string firstStageSceneName) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown if (!_isInitialized) { return; } if (shouldBeActive) { SceneIndex firstStageIndex = SceneCatalog.FindSceneIndex(firstStageSceneName); if ((int)firstStageIndex == -1) { Log.Warning("Could not find scene index for " + firstStageSceneName, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Stage\\StageRandomizerController.cs", "InitializeStageReplacements", 212); } Xoroshiro128Plus rng = new Xoroshiro128Plus(Run.instance.seed); IEnumerable collection = _stages.Where((StageRandomizingInfo stageInfo) => !ConfigManager.StageRandomizer.IsStageBlacklisted(stageInfo.SceneIndex)); _stageIndexReplacements = IndexReplacementsCollection.Create(ReplacementDictionary.CreateFrom(collection, rng, (StageRandomizingInfo s) => s.SceneIndex, delegate(StageRandomizingInfo key, StageRandomizingInfo value) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((bool)ConfigManager.StageRandomizer.FirstStageBlacklistEnabled && (int)firstStageIndex != -1 && key.SceneIndex == firstStageIndex && (value.Flags & StageFlags.FirstStageBlacklist) != StageFlags.None) { return false; } return ((key.Flags & StageFlags.Inaccessible) == 0 || (value.Flags & StageFlags.EndsRun) == 0) ? true : false; }, delegate(StageRandomizingInfo key, StageRandomizingInfo value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) float num = 1f; if ((int)firstStageIndex != -1 && key.SceneIndex == firstStageIndex && (value.Flags & StageFlags.PossibleStartingStage) != StageFlags.None) { num *= (float)ConfigManager.StageRandomizer.PossibleFirstStageWeightMult; } return value.BaseSelectionWeight * num; }), SceneCatalog.sceneDefCount); } else { _stageIndexReplacements = null; } } public static bool TryGetReplacementSceneIndex(SceneIndex original, out SceneIndex replacement) { if (shouldBeActive && _stageIndexReplacements.HasValue) { return IndexReplacementsCollectionExtensions.TryGetReplacement(in ILSpyHelper_AsRefReadOnly(_stageIndexReplacements.Value), in original, out replacement); } replacement = (SceneIndex)(-1); return false; static ref readonly T ILSpyHelper_AsRefReadOnly(in T temp) { //ILSpy generated this function to help ensure overload resolution can pick the overload using 'in' return ref temp; } } public static bool TryGetReplacementSceneName(string original, out string replacement) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) SceneIndex val = SceneCatalog.FindSceneIndex(original); if ((int)val != -1 && TryGetReplacementSceneIndex(val, out var replacement2)) { SceneDef sceneDef = SceneCatalog.GetSceneDef(replacement2); if (Object.op_Implicit((Object)(object)sceneDef)) { replacement = sceneDef.cachedName; return true; } } replacement = null; return false; } public static bool TryGetReplacementSceneDef(SceneDef original, out SceneDef replacement) { //IL_0001: 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) if (TryGetReplacementSceneIndex(original.sceneDefIndex, out var replacement2)) { replacement = SceneCatalog.GetSceneDef(replacement2); return Object.op_Implicit((Object)(object)replacement); } replacement = null; return false; } public static bool TryGetOriginalSceneDef(SceneDef replacement, out SceneDef originalScene) { //IL_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references) if (shouldBeActive && Object.op_Implicit((Object)(object)replacement) && _stageIndexReplacements.HasValue && IndexReplacementsCollectionExtensions.TryGetOriginal(in ILSpyHelper_AsRefReadOnly(_stageIndexReplacements.Value), in ILSpyHelper_AsRefReadOnly(replacement.sceneDefIndex), out SceneIndex original)) { originalScene = SceneCatalog.GetSceneDef(original); return Object.op_Implicit((Object)(object)originalScene); } originalScene = null; return false; static ref readonly T ILSpyHelper_AsRefReadOnly(in T temp) { //ILSpy generated this function to help ensure overload resolution can pick the overload using 'in' return ref temp; } } } public readonly struct StageRandomizingInfo { public readonly SceneIndex SceneIndex; public readonly StageFlags Flags; public readonly float BaseSelectionWeight; public StageRandomizingInfo(SceneIndex sceneIndex, StageFlags flags, float baseSelectionWeight = 1f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) SceneIndex = sceneIndex; Flags = flags; BaseSelectionWeight = baseSelectionWeight; } public override string ToString() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return string.Format("{0} {1}={2:F}", SceneCatalog.GetSceneDef(SceneIndex).cachedName, "Flags", Flags); } } } namespace RoR2Randomizer.RandomizerControllers.SniperWeakPoint { [RequireComponent(typeof(HurtBoxGroup))] public sealed class HurtBoxGroupRandomizerData : MonoBehaviour, INetMessageProvider { public CharacterBody OwnerBody; public bool[] OriginalIsSniperTargetValues; private HurtBoxGroup _group; private bool _isInitialized; public bool SendMessages { get { if (_isInitialized && Object.op_Implicit((Object)(object)OwnerBody)) { return Object.op_Implicit((Object)(object)_group); } return false; } } private void Awake() { _group = ((Component)this).GetComponent(); CharacterModel val = default(CharacterModel); if (((Component)this).TryGetComponent(ref val)) { OwnerBody = val.body; } else { Log.Warning("could not find owner body", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SniperWeakPoint\\HurtBoxGroupRandomizerData.cs", "Awake", 33); } } private void OnEnable() { NetworkingManager.RegisterMessageProvider(this); if (_isInitialized) { sendToClientsOrSetupHurtboxes(); } } private void OnDisable() { NetworkingManager.UnregisterMessageProvider(this); } public void Initialize(bool[] originalIsSniperTargetValues, bool?[] overrideIsSniperTargetValues) { if (_isInitialized) { return; } if (!Object.op_Implicit((Object)(object)_group) || _group.hurtBoxes == null) { Log.Warning("unable to initialize: invalid group reference", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SniperWeakPoint\\HurtBoxGroupRandomizerData.cs", "Initialize", 64); return; } OriginalIsSniperTargetValues = originalIsSniperTargetValues; for (int i = 0; i < _group.hurtBoxes.Length; i++) { bool? safe = ArrayUtils.GetSafe(overrideIsSniperTargetValues, i); if (safe.HasValue) { _group.hurtBoxes[i].isSniperTarget = safe.Value; } } _isInitialized = true; sendToClientsOrSetupHurtboxes(); } private void sendToClientsOrSetupHurtboxes() { if (NetworkServer.active) { if (!NetworkServer.dontListen) { this.TrySendAll((NetworkDestination)1); } } else if (NetworkClient.active) { setupHurtboxesClient(); } } private void setupHurtboxesClient() { if (!Object.op_Implicit((Object)(object)_group) || _group.hurtBoxes == null) { Log.Warning("invalid _group reference", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SniperWeakPoint\\HurtBoxGroupRandomizerData.cs", "setupHurtboxesClient", 102); return; } if (OriginalIsSniperTargetValues.Length != _group.hurtBoxes.Length) { Log.Warning(string.Format("mismatched group sizes! {0}.Length={1} {2}.hurtBoxes.Length={3}", "OriginalIsSniperTargetValues", OriginalIsSniperTargetValues.Length, "_group", _group.hurtBoxes.Length), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SniperWeakPoint\\HurtBoxGroupRandomizerData.cs", "setupHurtboxesClient", 108); } for (int i = 0; i < _group.hurtBoxes.Length; i++) { HurtBox val = _group.hurtBoxes[i]; if (Object.op_Implicit((Object)(object)val)) { overrideHurtboxIsSniperTarget(val, ArrayUtils.GetSafe(OriginalIsSniperTargetValues, i)); } } } private void overrideHurtboxIsSniperTarget(HurtBox hurtBox, bool originalIsSniperTarget) { if (hurtBox.isSniperTarget == originalIsSniperTarget) { return; } if (hurtBox.isSniperTarget) { if (!hurtBox.isInSniperTargetList) { HurtBox.sniperTargetsList.Add(hurtBox); hurtBox.isInSniperTargetList = true; } } else if (hurtBox.isInSniperTargetList) { HurtBox.sniperTargetsList.Remove(hurtBox); hurtBox.isInSniperTargetList = false; } } public IEnumerable GetNetMessages() { if (Object.op_Implicit((Object)(object)OwnerBody) && Object.op_Implicit((Object)(object)_group)) { if (OriginalIsSniperTargetValues.Length != _group.hurtBoxes.Length) { Log.Warning(string.Format("mismatched group sizes! {0}.Length={1} {2}.hurtBoxes.Length={3}", "OriginalIsSniperTargetValues", OriginalIsSniperTargetValues.Length, "_group", _group.hurtBoxes.Length), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SniperWeakPoint\\HurtBoxGroupRandomizerData.cs", "GetNetMessages", 152); } yield return new SyncSniperWeakPointReplacements(OwnerBody, _group.hurtBoxes.Where((HurtBox h, int i) => h.isSniperTarget != ArrayUtils.GetSafe(OriginalIsSniperTargetValues, i)), _group.hurtBoxes.Length); } else { Log.Warning(string.Format("{0} or {1} is null or destroyed!", "OwnerBody", _group), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\SniperWeakPoint\\HurtBoxGroupRandomizerData.cs", "GetNetMessages", 159); } } } public static class SniperWeakPointRandomizerController { public static bool IsEnabled { get { if (NetworkServer.active) { return ConfigManager.Misc.SniperWeakPointRandomizerEnabled; } return false; } } public static void TryRandomizeSniperTargets(HurtBoxGroup hurtBoxGroup) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled) { return; } HurtBox[] hurtBoxes = hurtBoxGroup.hurtBoxes; int num = hurtBoxes.Length; if (num <= 1) { return; } bool[] array = new bool[num]; WeightedSelection val = new WeightedSelection(num); bool?[] array2 = new bool?[num]; int num2 = 0; for (int i = 0; i < num; i++) { HurtBox val2 = hurtBoxes[i]; if (Object.op_Implicit((Object)(object)val2)) { bool flag = (array[i] = val2.isSniperTarget); val.AddChoice(i, flag ? 0.3f : 1f); if (flag) { num2++; array2[i] = false; } } } if (num2 <= 0) { return; } while (num2 > 0) { int num3 = val.EvaluateToChoiceIndex(Random.value); int value = val.GetChoice(num3).value; val.RemoveChoice(num3); if (array[value]) { array2[value] = null; } else { array2[value] = true; } num2--; } ((Component)hurtBoxGroup).gameObject.AddComponent().Initialize(array, array2); } } } namespace RoR2Randomizer.RandomizerControllers.Projectile { public struct GenericFireProjectileArgs : ISerializableObject { public GameObject Owner; public DamageType? DamageType; public HurtBox Target; public GameObject Weapon; public string MuzzleName; public float MaxDistance; public CharacterBody OwnerBody { get { if (Object.op_Implicit((Object)(object)Owner)) { CharacterMaster val = default(CharacterMaster); if (Owner.TryGetComponent(ref val)) { return val.GetBody(); } CharacterBody result = default(CharacterBody); if (Owner.TryGetComponent(ref result)) { return result; } } return null; } } public GameObject TargetGO { get { if (Object.op_Implicit((Object)(object)Target)) { return ((Component)Target).gameObject; } return null; } } public TeamIndex OwnerTeam => TeamComponent.GetObjectTeam(Owner); public GenericFireProjectileArgs() { Owner = null; DamageType = null; Target = null; Weapon = null; MuzzleName = null; MaxDistance = -1f; } public GenericFireProjectileArgs(BulletAttack bulletAttack) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Target = null; MaxDistance = -1f; Owner = bulletAttack.owner; DamageType = DamageTypeCombo.op_Implicit(bulletAttack.damageType); Weapon = bulletAttack.weapon; MuzzleName = bulletAttack.muzzleName; MaxDistance = bulletAttack.maxDistance; } public void ModifyArgs(ref Vector3 position) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Weapon) || string.IsNullOrEmpty(MuzzleName)) { return; } ModelLocator component = Weapon.GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.modelTransform)) { return; } ChildLocator component2 = ((Component)component.modelTransform).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { Transform val = component2.FindChild(MuzzleName); if (Object.op_Implicit((Object)(object)val)) { position = val.position; } } } void ISerializableObject.Serialize(NetworkWriter writer) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) writer.Write(Owner); writer.WriteNullableDamageType(DamageType); HurtBoxReference val = HurtBoxReference.FromHurtBox(Target); ((HurtBoxReference)(ref val)).Write(writer); writer.Write(Weapon); writer.Write(MuzzleName); writer.Write(MaxDistance); } void ISerializableObject.Deserialize(NetworkReader reader) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) Owner = reader.ReadGameObject(); DamageType = reader.ReadNullableDamageType(); HurtBoxReference val = default(HurtBoxReference); ((HurtBoxReference)(ref val)).Read(reader); Target = ((HurtBoxReference)(ref val)).ResolveHurtBox(); Weapon = reader.ReadGameObject(); MuzzleName = reader.ReadString(); MaxDistance = reader.ReadSingle(); } } public sealed class ProjectileRandomizerConfig : BaseRandomizerConfig { public readonly BoolConfigValue RandomizeHitscanAttacks; public readonly BoolConfigValue ExcludeInstakillProjeciles; public ProjectileRandomizerConfig(ConfigFile file) : base("Projectile", file) { RandomizeHitscanAttacks = new BoolConfigValue(getEntry("Randomize Hitscan Attacks", "If Hitscan attacks can be randomized into projectiles, and vice verse.", defaultValue: true)); ExcludeInstakillProjeciles = new BoolConfigValue(getEntry("Exclude Instakill Projectiles", "Excludes instakill projectiles from the projectile randomizer", defaultValue: false)); } } [RandomizerController] public class ProjectileRandomizerController : BaseRandomizerController { private static ProjectileRandomizerController _instance; private static int[] _projectileIndicesToRandomize; private static readonly RunSpecific _hasReceivedProjectileReplacementsFromServer = new RunSpecific(0, defaultValue: false); private static readonly RunSpecific> _projectileIndicesReplacements = new RunSpecific>(delegate(out ReplacementDictionary result) { if (shouldBeActive && Object.op_Implicit((Object)(object)Instance)) { result = ReplacementDictionary.CreateFrom(getAllProjectileIdentifiers(), Instance.RNG); return true; } result = null; return false; }); private static readonly RunSpecific> _appendedProjectileReplacements = new RunSpecific>(); private static readonly RunSpecific _shouldRandomizeHitscanServer = new RunSpecific(delegate(out bool result) { if (NetworkServer.active) { result = ConfigManager.ProjectileRandomizer.RandomizeHitscanAttacks; return true; } result = false; return false; }, 0, defaultValue: false); private static bool _replacingTempDisabled = false; public static ProjectileRandomizerController Instance => _instance; private static bool shouldBeActive { get { if (NetworkServer.active) { return ConfigManager.ProjectileRandomizer.Enabled; } return false; } } public static bool IsActive { get { if (shouldBeActive || (NetworkClient.active && (bool)_hasReceivedProjectileReplacementsFromServer)) { return _projectileIndicesReplacements.HasValue; } return false; } } public static bool ShouldRandomizeBulletAttacks { get { if (IsActive) { return _shouldRandomizeHitscanServer; } return false; } } public override bool IsRandomizerEnabled => IsActive; protected override bool isNetworked => true; [SystemInitializer(new Type[] { typeof(ProjectileCatalog) })] private static void Init() { _projectileIndicesToRandomize = (from p in ProjectileCatalog.projectilePrefabProjectileControllerComponents.Where(delegate(ProjectileController projectile) { if (!Object.op_Implicit((Object)(object)projectile)) { return false; } ProjectileFireChildren val = default(ProjectileFireChildren); if (((Component)projectile).TryGetComponent(ref val) && (!Object.op_Implicit((Object)(object)val.childProjectilePrefab) || (Object)(object)val.childProjectilePrefab == (Object)null)) { return false; } switch (((Object)projectile).name) { case "AncientWispCannon": case "GatewayProjectile": case "BanditBomblets": case "EngiWallShield": case "TreebotFlower1": case "BanditClusterBombSeed": case "ChefCleaverProjectile": case "HaulerThrowProjectile": case "BanditClusterGrenadeProjectile": case "MinorConstructOnKillProjectile": case "ChefCleaver": case "DroneRocket": case "PaladinBigRocket": case "EngiMineDeployer": case "ToolbotDroneHeal": case "ToolbotDroneStun": case "EngiSeekerGrenadeProjectile": case "MageIcewallWalkerProjectile": case "MageFirewallWalkerProjectile": case "ThrownObjectProjectileNoStun": case "AACannon": case "BeetleQueenAcid": case "BellBallSmall": case "NullifierBombProjectile": case "RedAffixMissileProjectile": case "ScoutGrenade": case "Rocket": case "Spine": case "TreebotPounderProjectile": case "ThrownObjectProjectile": case "LunarSunProjectile": return false; default: return true; } }) select p.catalogIndex).ToArray(); } private static IEnumerable getAllProjectileIdentifiers() { IEnumerable first = _projectileIndicesToRandomize.Select((int i) => new ProjectileTypeIdentifier(ProjectileType.OrdinaryProjectile, i)); if ((bool)ConfigManager.ProjectileRandomizer.RandomizeHitscanAttacks) { first = first.Concat(BulletAttackCatalog.Instance.GetAllBulletAttackProjectileIdentifiers()); } first = first.Concat(DamageOrbCatalog.Instance.GetAllDamageOrbProjectileIdentifiers()); first = first.Concat(LightningOrbCatalog.Instance.GetAllLightningOrbProjectileIdentifiers()); first = CollectionExtensions.AddItem(first, ProjectileTypeIdentifier.SpiteBomb); first = first.Distinct(); if ((bool)ConfigManager.ProjectileRandomizer.ExcludeInstakillProjeciles) { first = first.Where((ProjectileTypeIdentifier i) => !i.IsInstaKill); } return first; } protected override IEnumerable getNetMessages() { if (_projectileIndicesReplacements.HasValue) { yield return new SyncProjectileReplacements(_projectileIndicesReplacements, isAppendedReplacements: false); } if (_appendedProjectileReplacements.HasValue) { yield return new SyncProjectileReplacements(new ReplacementDictionary(_appendedProjectileReplacements.Value), isAppendedReplacements: true); } } private static void onProjectileReplacementsReceivedFromServer(ReplacementDictionary replacements, bool isAppendedReplacements) { if (isAppendedReplacements) { _appendedProjectileReplacements.Value = new Dictionary(replacements); } else { _projectileIndicesReplacements.Value = replacements; _hasReceivedProjectileReplacementsFromServer.Value = true; } if (!_shouldRandomizeHitscanServer) { _shouldRandomizeHitscanServer.Value |= replacements.Keys.Any((ProjectileTypeIdentifier i) => i.Type == ProjectileType.Bullet); } } private static void appendProjectileReplacement(in ProjectileTypeIdentifier identifier) { if (!NetworkServer.active) { return; } if (!_appendedProjectileReplacements.HasValue) { _appendedProjectileReplacements.Value = new Dictionary(); } if (!_appendedProjectileReplacements.Value.ContainsKey(identifier)) { _appendedProjectileReplacements.Value.Add(identifier, getAllProjectileIdentifiers().GetRandomOrDefault(Instance.RNG)); if (!NetworkServer.dontListen) { new SyncProjectileReplacements(new ReplacementDictionary(_appendedProjectileReplacements.Value), isAppendedReplacements: true).SendTo((NetworkDestination)1); } } } private static void BulletAttackCatalog_OnIdentifierAppendedServer(in BulletAttackIdentifier identifier) { if (Object.op_Implicit((Object)(object)Run.instance) && NetworkServer.active) { appendProjectileReplacement((ProjectileTypeIdentifier)identifier); } } private static void DamageOrbCatalog_OnIdentifierAppended(in DamageOrbIdentifier identifier) { if (Object.op_Implicit((Object)(object)Run.instance) && NetworkServer.active) { appendProjectileReplacement((ProjectileTypeIdentifier)identifier); } } private static void LightningOrbCatalog_OnIdentifierAppended(in LightningOrbIdentifier identifier) { if (Object.op_Implicit((Object)(object)Run.instance) && NetworkServer.active) { appendProjectileReplacement((ProjectileTypeIdentifier)identifier); } } protected override void Awake() { base.Awake(); SyncProjectileReplacements.OnReceive += onProjectileReplacementsReceivedFromServer; BulletAttackCatalog.Instance.OnIdentifierAppended += BulletAttackCatalog_OnIdentifierAppendedServer; DamageOrbCatalog.Instance.OnIdentifierAppended += DamageOrbCatalog_OnIdentifierAppended; LightningOrbCatalog.Instance.OnIdentifierAppended += LightningOrbCatalog_OnIdentifierAppended; SingletonHelper.Assign(ref _instance, this); } protected override void OnDestroy() { base.OnDestroy(); SyncProjectileReplacements.OnReceive -= onProjectileReplacementsReceivedFromServer; BulletAttackCatalog.Instance.OnIdentifierAppended -= BulletAttackCatalog_OnIdentifierAppendedServer; DamageOrbCatalog.Instance.OnIdentifierAppended -= DamageOrbCatalog_OnIdentifierAppended; LightningOrbCatalog.Instance.OnIdentifierAppended -= LightningOrbCatalog_OnIdentifierAppended; _projectileIndicesReplacements.Dispose(); _appendedProjectileReplacements.Dispose(); _shouldRandomizeHitscanServer.Dispose(); _hasReceivedProjectileReplacementsFromServer.Dispose(); SingletonHelper.Unassign(ref _instance, this); } public static bool TryReplaceProjectileInstantiateFire(ref GameObject projectilePrefab, out GameObject originalPrefab, Vector3 origin, Quaternion rotation, float damage, float force, bool isCrit, GenericFireProjectileArgs genericArgs) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) originalPrefab = projectilePrefab; if (TryGetOverrideProjectileIdentifier(ProjectileTypeIdentifier.FromProjectilePrefab(projectilePrefab), out var replacement)) { if (replacement.Type == ProjectileType.OrdinaryProjectile) { projectilePrefab = ProjectileCatalog.GetProjectilePrefab(replacement.Index); return true; } _replacingTempDisabled = true; replacement.Fire(origin, rotation, damage, force, isCrit, genericArgs); _replacingTempDisabled = false; return false; } return true; } public static bool TryReplaceFire(Orb orb) { //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (!IsActive) { return false; } ProjectileTypeIdentifier identifier = ProjectileTypeIdentifier.Invalid; float damage = 0f; float force = 0f; bool isCrit = false; GenericFireProjectileArgs genericArgs = new GenericFireProjectileArgs { Target = orb.target }; Orb obj = orb; GenericDamageOrb val = (GenericDamageOrb)(object)((obj is GenericDamageOrb) ? obj : null); if (val != null) { damage = val.damageValue; force = ((SquidOrb)(((val is SquidOrb) ? val : null)?)).forceScalar ?? 0f; isCrit = val.isCrit; DamageOrbIdentifier damageOrbIdentifier = DamageOrbCatalog.Instance.GetIdentifier(val); if (damageOrbIdentifier.IsValid) { genericArgs.Owner = val.attacker; genericArgs.DamageType = DamageTypeCombo.op_Implicit(val.damageType); identifier = damageOrbIdentifier; return tryReplaceOrb(); } } else { Orb obj2 = orb; LightningOrb val2 = (LightningOrb)(object)((obj2 is LightningOrb) ? obj2 : null); if (val2 != null) { damage = val2.damageValue; force = 0f; isCrit = val2.isCrit; LightningOrbIdentifier lightningOrb = LightningOrbCatalog.Instance.GetIdentifier(val2); if (lightningOrb.IsValid) { genericArgs.Owner = val2.attacker; genericArgs.DamageType = DamageTypeCombo.op_Implicit(val2.damageType); genericArgs.Weapon = val2.inflictor; identifier = lightningOrb; return tryReplaceOrb(); } } } return false; bool tryReplaceOrb() { //IL_0006: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) _ = orb.origin; Quaternion rotation; if (Object.op_Implicit((Object)(object)orb.target)) { Vector3 val3 = ((Component)orb.target).transform.position - orb.origin; rotation = Util.QuaternionSafeLookRotation(((Vector3)(ref val3)).normalized); } else { rotation = Quaternion.identity; } if (identifier.IsValid) { return TryReplaceFire(in identifier, orb.origin, rotation, damage, force, isCrit, genericArgs); } return false; } } public static bool TryReplaceFire(BulletAttack bulletAttack, Vector3 fireDirection) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) BulletAttackIdentifier bulletAttack2 = BulletAttackCatalog.Instance.GetIdentifier(bulletAttack); if (bulletAttack2.IsValid) { return TryReplaceFire((ProjectileTypeIdentifier)bulletAttack2, bulletAttack.origin, Util.QuaternionSafeLookRotation(fireDirection), bulletAttack.damage, bulletAttack.force, bulletAttack.isCrit, new GenericFireProjectileArgs(bulletAttack)); } return false; } public static bool TryReplaceFire(in FireProjectileInfo info, GameObject weapon) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (!IsActive) { return false; } HurtBox val = null; if (Object.op_Implicit((Object)(object)info.target)) { HurtBox val2 = default(HurtBox); HurtBoxGroup val3 = default(HurtBoxGroup); if (info.target.TryGetComponent(ref val2)) { val = val2; } else if (info.target.TryGetComponent(ref val3)) { val = ((!Object.op_Implicit((Object)(object)val3.mainHurtBox)) ? val3.hurtBoxes.GetRandomOrDefault(RoR2Application.rng) : val3.mainHurtBox); } else { CharacterBody body = default(CharacterBody); CharacterMaster val4 = default(CharacterMaster); if (!info.target.TryGetComponent(ref body) && info.target.TryGetComponent(ref val4)) { body = val4.GetBody(); } if (Object.op_Implicit((Object)(object)body)) { val = body.mainHurtBox; } } if (!Object.op_Implicit((Object)(object)val)) { Log.Warning("projectile has target GO (" + ((Object)info.target).name + "), but no HurtBox reference could be found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Projectile\\ProjectileRandomizerController.cs", "TryReplaceFire", 439); } } ProjectileTypeIdentifier identifier = ProjectileTypeIdentifier.FromProjectilePrefab(info.projectilePrefab); Vector3 position = info.position; Quaternion rotation = info.rotation; float damage = info.damage; float force = info.force; bool crit = info.crit; GenericFireProjectileArgs genericArgs = new GenericFireProjectileArgs { Owner = info.owner, Weapon = weapon }; DamageTypeCombo? damageTypeOverride = info.damageTypeOverride; genericArgs.DamageType = (damageTypeOverride.HasValue ? new DamageType?(DamageTypeCombo.op_Implicit(damageTypeOverride.GetValueOrDefault())) : ((DamageType?)null)); genericArgs.Target = val; return TryReplaceFire(in identifier, position, rotation, damage, force, crit, genericArgs); } public static bool TryReplaceFire(in BombRequest spiteBombRequest) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!IsActive) { return false; } Quaternion rotation = Util.QuaternionSafeLookRotation(Quaternion.Euler(Random.Range(-5f, 5f), Random.Range(0f, 360f), Random.Range(-5f, 5f)) * Vector3.up); return TryReplaceFire(in ProjectileTypeIdentifier.SpiteBomb, spiteBombRequest.spawnPosition + new Vector3(0f, 1f, 0f), rotation, spiteBombRequest.bombBaseDamage, 0f, isCrit: false, new GenericFireProjectileArgs { Owner = spiteBombRequest.attacker }); } public static bool TryReplaceFire(in ProjectileTypeIdentifier identifier, Vector3 origin, Quaternion rotation, float damage, float force, bool isCrit, GenericFireProjectileArgs genericArgs) { //IL_004e: 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) if (!IsActive || _replacingTempDisabled) { return false; } if (identifier.Type == ProjectileType.Invalid) { return false; } if (identifier.Type == ProjectileType.Bullet && !ShouldRandomizeBulletAttacks) { return false; } if (TryGetOverrideProjectileIdentifier(in identifier, out var replacement) && replacement.IsValid) { _replacingTempDisabled = true; replacement.Fire(origin, rotation, damage, force, isCrit, genericArgs); _replacingTempDisabled = false; if (Object.op_Implicit((Object)(object)genericArgs.Owner) && identifier.Type == ProjectileType.OrdinaryProjectile && replacement.Type != ProjectileType.OrdinaryProjectile && Object.op_Implicit((Object)(object)ProjectileCatalog.GetProjectilePrefab(identifier.Index).GetComponent())) { EntityStateMachine val = EntityStateMachine.FindByCustomName(genericArgs.Owner, "Hook"); if (Object.op_Implicit((Object)(object)val)) { if (!(val.state is FireHook)) { } } else { Log.Warning(string.Format("Tried to initialize grapple {0}, but owner has no '{1}' state machine", replacement.Type, "Hook"), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Projectile\\ProjectileRandomizerController.cs", "TryReplaceFire", 504); } } return true; } return false; } public static bool TryGetOriginalProjectilePrefab(GameObject replacementPrefab, out GameObject originalPrefab) { if (IsActive) { int projectileIndex = ProjectileCatalog.GetProjectileIndex(replacementPrefab); if (TryGetOriginalProjectileIdentifier(new ProjectileTypeIdentifier(ProjectileType.OrdinaryProjectile, projectileIndex), out var original) && original.Type == ProjectileType.OrdinaryProjectile) { originalPrefab = ProjectileCatalog.GetProjectilePrefab(original.Index); return Object.op_Implicit((Object)(object)originalPrefab); } } originalPrefab = null; return false; } public static bool TryGetOriginalProjectileIdentifier(in ProjectileTypeIdentifier replacement, out ProjectileTypeIdentifier original) { if (IsActive) { return _projectileIndicesReplacements.Value.TryGetOriginal(replacement, out original); } original = default(ProjectileTypeIdentifier); return false; } public static bool TryGetOverrideProjectileIdentifier(in ProjectileTypeIdentifier original, out ProjectileTypeIdentifier replacement) { if (IsActive && (_projectileIndicesReplacements.Value.TryGetReplacement(original, out replacement) || (_appendedProjectileReplacements.HasValue && _appendedProjectileReplacements.Value.TryGetValue(original, out replacement)))) { return true; } replacement = default(ProjectileTypeIdentifier); return false; } } public enum ProjectileType { Invalid = -1, OrdinaryProjectile, Bullet, DamageOrb, LightningOrb, SpiteBomb } public readonly struct ProjectileTypeIdentifier : IEquatable { public static readonly ProjectileTypeIdentifier Invalid = new ProjectileTypeIdentifier(ProjectileType.Invalid, -1, null); public static readonly ProjectileTypeIdentifier SpiteBomb = new ProjectileTypeIdentifier(ProjectileType.SpiteBomb, -1, null); public readonly ProjectileType Type; public readonly int Index; public readonly DamageType? DamageType; public bool IsValid { get { if (Type != ProjectileType.Invalid) { if (Type != ProjectileType.SpiteBomb) { return Index != -1; } return true; } return false; } } public bool IsInstaKill { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Invalid comparison between Unknown and I4 if (DamageType.HasValue) { return (DamageType.Value & 0x10000) > 0; } return false; } } public ProjectileTypeIdentifier(ProjectileType type, int index, DamageType? damageType) { Type = type; Index = index; DamageType = damageType; } private static DamageType? getDamageType(ProjectileType type, int index) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) switch (type) { case ProjectileType.OrdinaryProjectile: { GameObject projectilePrefab = ProjectileCatalog.GetProjectilePrefab(index); ProjectileDamage val2 = default(ProjectileDamage); if (Object.op_Implicit((Object)(object)projectilePrefab) && projectilePrefab.TryGetComponent(ref val2)) { return DamageTypeCombo.op_Implicit(val2.damageType); } break; } case ProjectileType.Bullet: { BulletAttackIdentifier identifier2 = BulletAttackCatalog.Instance.GetIdentifier(index); if (identifier2.IsValid) { return DamageTypeCombo.op_Implicit(identifier2.CreateInstance().damageType); } break; } case ProjectileType.DamageOrb: { DamageOrbIdentifier identifier3 = DamageOrbCatalog.Instance.GetIdentifier(index); if (identifier3.IsValid) { DamageTypeCombo? val = identifier3.CreateInstance()?.damageType; if (!val.HasValue) { return null; } return DamageTypeCombo.op_Implicit(val.GetValueOrDefault()); } break; } case ProjectileType.LightningOrb: { LightningOrbIdentifier identifier = LightningOrbCatalog.Instance.GetIdentifier(index); if (identifier.IsValid) { return DamageTypeCombo.op_Implicit(identifier.CreateInstance().damageType); } break; } default: Log.Warning(string.Format("unhandled {0} {1}", "ProjectileType", type), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Projectile\\ProjectileTypeIdentifier.cs", "getDamageType", 77); break; case ProjectileType.SpiteBomb: break; } return null; } public ProjectileTypeIdentifier(ProjectileType type, int index) : this(type, index, getDamageType(type, index)) { } public ProjectileTypeIdentifier(NetworkReader reader) : this((ProjectileType)NetworkExtensions.ReadPackedIndex32(reader), NetworkExtensions.ReadPackedIndex32(reader), reader.ReadNullableDamageType()) { } public static ProjectileTypeIdentifier FromProjectilePrefab(GameObject prefab) { //IL_000d: 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) ProjectileDamage val = default(ProjectileDamage); return new ProjectileTypeIdentifier(damageType: (!prefab.TryGetComponent(ref val)) ? ((DamageType?)null) : new DamageType?(DamageTypeCombo.op_Implicit(val.damageType)), type: ProjectileType.OrdinaryProjectile, index: ProjectileCatalog.GetProjectileIndex(prefab)); } public void Serialize(NetworkWriter writer) { NetworkExtensions.WritePackedIndex32(writer, (int)Type); NetworkExtensions.WritePackedIndex32(writer, Index); writer.WriteNullableDamageType(DamageType); } public void Fire(Vector3 origin, Quaternion rotation, float damage, float force, bool isCrit, GenericFireProjectileArgs genericArgs) { //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_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_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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) genericArgs.ModifyArgs(ref origin); Vector3 val = rotation * Vector3.forward; Vector3 normalized = ((Vector3)(ref val)).normalized; switch (Type) { case ProjectileType.OrdinaryProjectile: ProjectileManager.instance.FireProjectile(new FireProjectileInfo { projectilePrefab = ProjectileCatalog.GetProjectilePrefab(Index), crit = isCrit, damage = damage, force = force, owner = genericArgs.Owner, position = origin, rotation = rotation, target = genericArgs.TargetGO }); break; case ProjectileType.Bullet: { BulletAttackIdentifier identifier = BulletAttackCatalog.Instance.GetIdentifier(Index); if (!identifier.IsValid) { Log.Warning($"invalid bullet attack at index {Index}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Projectile\\ProjectileTypeIdentifier.cs", "Fire", 147); break; } BulletAttack val2 = identifier.CreateInstance(); val2.aimVector = normalized; val2.bulletCount = 1u; val2.damage = damage; val2.force = force; EffectDef effectDef = EffectCatalog.GetEffectDef(identifier.HitEffectIndex); val2.hitEffectPrefab = ((effectDef != null) ? effectDef.prefab : null); val2.isCrit = isCrit; val2.origin = origin; val2.owner = genericArgs.Owner; val2.weapon = genericArgs.Weapon; val2.muzzleName = genericArgs.MuzzleName; EffectDef effectDef2 = EffectCatalog.GetEffectDef(identifier.TracerEffectIndex); val2.tracerEffectPrefab = ((effectDef2 != null) ? effectDef2.prefab : null); if (genericArgs.MaxDistance >= 0f) { val2.maxDistance = genericArgs.MaxDistance; } val2.Fire(); break; } case ProjectileType.DamageOrb: case ProjectileType.LightningOrb: new SpawnRandomizedOrbMessage(this, origin, rotation, damage, force, isCrit, genericArgs).SpawnOrSendMessage(); break; case ProjectileType.SpiteBomb: new SpawnRandomizedSpiteBombMessage(damage, origin, genericArgs).SendTo((NetworkDestination)2); break; default: Log.Warning($"unhandled type {Type}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Projectile\\ProjectileTypeIdentifier.cs", "Fire", 185); break; } } public bool Equals(ProjectileTypeIdentifier other) { if (Type == other.Type) { return Index == other.Index; } return false; } public override bool Equals(object obj) { if (obj is ProjectileTypeIdentifier other) { return Equals(other); } return false; } public override int GetHashCode() { return (686506176 * -1521134295 + Type.GetHashCode()) * -1521134295 + Index.GetHashCode(); } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"{Type}: {Index}"); if (Type == ProjectileType.OrdinaryProjectile) { GameObject projectilePrefab = ProjectileCatalog.GetProjectilePrefab(Index); stringBuilder.Append(" (" + (((projectilePrefab != null) ? ((Object)projectilePrefab).name : null) ?? "null") + ")"); } return stringBuilder.ToString(); } public static bool operator ==(ProjectileTypeIdentifier a, ProjectileTypeIdentifier b) { return a.Equals(b); } public static bool operator !=(ProjectileTypeIdentifier a, ProjectileTypeIdentifier b) { return !a.Equals(b); } } } namespace RoR2Randomizer.RandomizerControllers.Projectile.Orbs { public class OrbTargetDummyObjectMarker : NetworkBehaviour { private const int MIN_ALLOWED_LOCAL_OBJECTS = 15; private static bool _availableLocalInstancesRefreshScheduled = false; private static readonly Stack _availableLocalInstances = new Stack(); private bool _isInUse; private float _timeToDisable; public static GameObject Prefab { get; private set; } public bool IsAvailableToLocalPlayer { get; internal set; } private bool isAuthority { get { if (!((NetworkBehaviour)this).hasAuthority) { if (((NetworkBehaviour)this).isServer) { return IsAvailableToLocalPlayer; } return false; } return true; } } public bool isInUse { get { return _isInUse; } set { if (MiscUtils.TryAssign(ref _isInUse, value)) { updateInUse(); } } } internal static void InitNetworkPrefab() { //IL_0005: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0065: Expected O, but got Unknown GameObject val = new GameObject("OrbTargetDummy_tmp"); NetworkIdentity obj = val.AddComponent(); obj.serverOnly = false; obj.localPlayerAuthority = true; NetworkTransform obj2 = val.AddComponent(); obj2.transformSyncMode = (TransformSyncMode)1; obj2.syncRotationAxis = (AxisSyncMode)0; obj2.syncSpin = false; obj2.interpolateMovement = 0f; val.AddComponent(); val.AddComponent(); Prefab = PrefabAPI.InstantiateClone(val, "OrbTargetDummy"); Object.Destroy((Object)val); } [SystemInitializer(new Type[] { })] private static void Init() { Run.onRunStartGlobal += onRunStart; ClientRequestOrbTargetMarkerObjects.Reply.OnReceive += ClientRequestDamageOrbTargetMarkerObjects_Reply_OnReceived; } private static void onRunStart(Run _) { _availableLocalInstances.Clear(); refillLocalInstances(15); } private static void markLocalInstancesDirty() { if (_availableLocalInstancesRefreshScheduled) { return; } _availableLocalInstancesRefreshScheduled = true; RoR2Application.onNextUpdate += delegate { OrbTargetDummyObjectMarker[] array = _availableLocalInstances.ToArray(); _availableLocalInstances.Clear(); OrbTargetDummyObjectMarker[] array2 = array; foreach (OrbTargetDummyObjectMarker orbTargetDummyObjectMarker in array2) { if (Object.op_Implicit((Object)(object)orbTargetDummyObjectMarker)) { _availableLocalInstances.Push(orbTargetDummyObjectMarker); } } _availableLocalInstancesRefreshScheduled = false; }; } public static OrbTargetDummyObjectMarker GetMarker(Vector3 position, float? duration) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (_availableLocalInstances.Count > 0) { OrbTargetDummyObjectMarker orbTargetDummyObjectMarker; do { orbTargetDummyObjectMarker = _availableLocalInstances.Pop(); } while (_availableLocalInstances.Count > 0 && (!Object.op_Implicit((Object)(object)orbTargetDummyObjectMarker) || orbTargetDummyObjectMarker.isInUse)); if (_availableLocalInstances.Count < 15) { refillLocalInstances((15 - _availableLocalInstances.Count) * (NetworkServer.active ? 1 : 3)); } if (Object.op_Implicit((Object)(object)orbTargetDummyObjectMarker)) { ((Component)orbTargetDummyObjectMarker).transform.position = position; orbTargetDummyObjectMarker.setInUse(duration); return orbTargetDummyObjectMarker; } } else { refillLocalInstances(15); } return null; } private static void refillLocalInstances(int amount) { if (amount <= 0) { return; } if (NetworkServer.active) { for (int i = 0; i < amount; i++) { OrbTargetDummyObjectMarker orbTargetDummyObjectMarker = InstantiateNew(); orbTargetDummyObjectMarker.IsAvailableToLocalPlayer = true; NetworkServer.Spawn(((Component)orbTargetDummyObjectMarker).gameObject); _availableLocalInstances.Push(orbTargetDummyObjectMarker); } } else { if (!NetworkClient.active) { return; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if (firstLocalUser != null) { NetworkUser currentNetworkUser = firstLocalUser.currentNetworkUser; if (Object.op_Implicit((Object)(object)currentNetworkUser)) { ((MonoBehaviour)Main.Instance).StartCoroutine(waitForUserInitAndSendRequest((uint)amount, currentNetworkUser)); } } } static IEnumerator waitForUserInitAndSendRequest(uint amount2, NetworkUser networkUser) { while (Object.op_Implicit((Object)(object)networkUser)) { NetworkUserId id = networkUser.id; if (((NetworkUserId)(ref id)).HasValidValue()) { break; } yield return 0; } if (Object.op_Implicit((Object)(object)networkUser)) { new ClientRequestOrbTargetMarkerObjects(amount2, networkUser.id).SendTo((NetworkDestination)2); } } } private static void ClientRequestDamageOrbTargetMarkerObjects_Reply_OnReceived(OrbTargetDummyObjectMarker[] newTargetObjects) { foreach (OrbTargetDummyObjectMarker item in newTargetObjects.Where((OrbTargetDummyObjectMarker o) => Object.op_Implicit((Object)(object)o))) { _availableLocalInstances.Push(item); } } public static OrbTargetDummyObjectMarker InstantiateNew() { return Object.Instantiate(Prefab).GetComponent(); } private void Awake() { Run.onRunDestroyGlobal += Run_onRunDestroyGlobal; } private void Run_onRunDestroyGlobal(Run obj) { Object.Destroy((Object)(object)((Component)this).gameObject); } private void OnDestroy() { Run.onRunDestroyGlobal -= Run_onRunDestroyGlobal; if (_availableLocalInstances.Contains(this)) { markLocalInstancesDirty(); } } private void setInUse(float? duration) { isInUse = true; if (duration.HasValue) { _timeToDisable = Time.time + duration.Value; } else { _timeToDisable = -1f; } } private void updateInUse() { if (!isInUse && isAuthority && !_availableLocalInstances.Contains(this)) { _availableLocalInstances.Push(this); } } private void Update() { if (isAuthority && isInUse && _timeToDisable > 0f && Time.time >= _timeToDisable) { isInUse = false; } } } } namespace RoR2Randomizer.RandomizerControllers.Projectile.Orbs.LightningOrbHandling { public class LightningOrbCatalog : GenericNetworkedCatalog { public static readonly LightningOrbCatalog Instance; protected override LightningOrbIdentifier InvalidIdentifier => LightningOrbIdentifier.Invalid; static LightningOrbCatalog() { Instance = new LightningOrbCatalog(); SyncLightningOrbCatalog.OnReceive += Instance.SyncCatalog_OnReceive; SyncLightningOrbIndexNeeded.OnReceive += Instance.SyncIndexNeeded_OnReceive; } [SystemInitializer(new Type[] { typeof(EntityStateCatalog) })] private static void Init() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) LightningType val = (LightningType)0; _ = 10; } protected override bool tryCreateIdentifierForObject(LightningOrb lightningOrb, out LightningOrbIdentifier identifier) { identifier = new LightningOrbIdentifier(lightningOrb); return true; } protected override NetworkMessageBase getSyncIdentifierNeededMessage(in LightningOrbIdentifier identifier) { return new SyncLightningOrbIndexNeeded(identifier); } public override IEnumerable GetNetMessages() { yield return new SyncLightningOrbCatalog(_identifiers, _identifiersCount); } public IEnumerable GetAllLightningOrbProjectileIdentifiers() { return ((IEnumerable)this).Select((Func)((LightningOrbIdentifier i) => i)); } } public struct LightningOrbIdentifier : ICatalogIdentifier { public static readonly LightningOrbIdentifier Invalid = new LightningOrbIdentifier { Index = -1 }; public readonly LightningType LightningType; public readonly uint DefaultNumBounces; public readonly uint TargetsToFindPerBounce; public int Index { get; set; } public readonly bool IsValid => Index >= 0; public LightningOrbIdentifier(LightningType lightningType, uint defaultNumBounces, uint targetsToFindPerBounce) { //IL_0008: 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) Index = 0; LightningType = lightningType; DefaultNumBounces = defaultNumBounces; TargetsToFindPerBounce = targetsToFindPerBounce; } public LightningOrbIdentifier(LightningOrb lightningOrb) : this(lightningOrb.lightningType, 0u, 1u) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) public LightningOrbIdentifier(NetworkReader reader) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Index = NetworkExtensions.ReadPackedIndex32(reader); LightningType = (LightningType)reader.ReadPackedUInt32(); DefaultNumBounces = reader.ReadPackedUInt32(); TargetsToFindPerBounce = reader.ReadPackedUInt32(); } public readonly void Serialize(NetworkWriter writer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown NetworkExtensions.WritePackedIndex32(writer, Index); writer.WritePackedUInt32((uint)(int)LightningType); writer.WritePackedUInt32(DefaultNumBounces); writer.WritePackedUInt32(TargetsToFindPerBounce); } public readonly bool Matches(LightningOrb lightningOrb) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return LightningType == lightningOrb.lightningType; } public readonly bool Equals(in LightningOrbIdentifier other, bool compareIndex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (compareIndex) { return Index == other.Index; } return LightningType == other.LightningType; } public override readonly bool Equals(object obj) { if (obj is LightningOrbIdentifier other) { return Equals(in other, compareIndex: true); } return false; } public static bool operator ==(in LightningOrbIdentifier a, in LightningOrbIdentifier b) { return a.Equals(in b, compareIndex: true); } public static bool operator !=(in LightningOrbIdentifier a, in LightningOrbIdentifier b) { return !(a == b); } public override int GetHashCode() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) return (1383804432 * -1521134295 + Index.GetHashCode()) * -1521134295 + ((object)LightningType/*cast due to .constrained prefix*/).GetHashCode(); } public readonly LightningOrb CreateInstance() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_001d: 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_0035: Expected O, but got Unknown return new LightningOrb { lightningType = LightningType, bouncesRemaining = (int)DefaultNumBounces, bouncedObjects = new List(), targetsToFindPerBounce = (int)TargetsToFindPerBounce }; } public override readonly string ToString() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return $"{LightningType} ({Index})"; } public static implicit operator ProjectileTypeIdentifier(in LightningOrbIdentifier lightningOrb) { return new ProjectileTypeIdentifier(ProjectileType.LightningOrb, lightningOrb.Index); } bool ICatalogIdentifier.Equals(in LightningOrbIdentifier other, bool compareIndex) { return Equals(in other, compareIndex); } } } namespace RoR2Randomizer.RandomizerControllers.Projectile.Orbs.DamageOrbHandling { public class DamageOrbCatalog : GenericNetworkedCatalog { public static readonly DamageOrbCatalog Instance; protected override DamageOrbIdentifier InvalidIdentifier => DamageOrbIdentifier.Invalid; static DamageOrbCatalog() { Instance = new DamageOrbCatalog(); SyncDamageOrbCatalog.OnReceive += Instance.SyncCatalog_OnReceive; SyncDamageOrbIndexNeeded.OnReceive += Instance.SyncIndexNeeded_OnReceive; } [SystemInitializer(new Type[] { typeof(EffectCatalog) })] private static void Init() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) initIdentifiersForType(); initIdentifiersForType(); initIdentifiersForType(); initIdentifiersForType(); initIdentifiersForType(); initIdentifiersForType(); initIdentifiersForType(); GameObject val = Addressables.LoadAssetAsync((object)"RoR2/DLC1/DroneWeapons/ChainGunOrbEffect.prefab").WaitForCompletion(); initIdentifiersForType_Arg(new object[1] { val }); static void initIdentifier(GenericDamageOrb damageOrb) { DamageOrbIdentifier identifier = new DamageOrbIdentifier(damageOrb); Instance.appendIdentifier(ref identifier, checkExisting: true); } static void initIdentifiersForType() where T : GenericDamageOrb, new() { initIdentifier((GenericDamageOrb)(object)new T()); T val2 = new T(); ((GenericDamageOrb)val2).isCrit = true; initIdentifier((GenericDamageOrb)(object)val2); } static void initIdentifiersForType_Arg(params object[] constructorParams) where T : GenericDamageOrb { initIdentifier((GenericDamageOrb)(object)(T)Activator.CreateInstance(typeof(T), constructorParams)); T obj = (T)Activator.CreateInstance(typeof(T), constructorParams); ((GenericDamageOrb)obj).isCrit = true; initIdentifier((GenericDamageOrb)(object)obj); } } protected override bool tryCreateIdentifierForObject(GenericDamageOrb damageOrb, out DamageOrbIdentifier identifier) { if (damageOrb != null) { Type type = ((object)damageOrb).GetType(); if (type == typeof(ChainGunOrb) || type.GetConstructor(Array.Empty()) != null) { identifier = new DamageOrbIdentifier(damageOrb); return true; } } identifier = DamageOrbIdentifier.Invalid; return false; } protected override NetworkMessageBase getSyncIdentifierNeededMessage(in DamageOrbIdentifier identifier) { return new SyncDamageOrbIndexNeeded(in identifier); } public override IEnumerable GetNetMessages() { yield return new SyncDamageOrbCatalog(_identifiers, _identifiersCount); } public IEnumerable GetAllDamageOrbProjectileIdentifiers() { return ((IEnumerable)this).Select((Func)((DamageOrbIdentifier i) => i)); } } public struct DamageOrbIdentifier : ICatalogIdentifier, IEquatable { public static readonly DamageOrbIdentifier Invalid = new DamageOrbIdentifier { Index = -1 }; public readonly EffectIndex OrbEffectIndex; public readonly SerializableSystemType OrbType; public int Index { get; set; } public readonly bool IsValid { get { if (IndexValid) { return ValuesValid; } return false; } } public readonly bool IndexValid => Index != -1; public readonly bool ValuesValid { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((int)OrbEffectIndex != -1) { return (Type)OrbType != null; } return false; } } public DamageOrbIdentifier(EffectIndex orbEffectIndex, SerializableSystemType orbType) { //IL_0008: 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_000f: 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) Index = 0; OrbEffectIndex = orbEffectIndex; OrbType = orbType; } public DamageOrbIdentifier(GenericDamageOrb damageOrb) : this(EffectCatalog.FindEffectIndexFromPrefab(damageOrb.GetOrbEffect()), (SerializableSystemType)((object)damageOrb).GetType()) { }//IL_0007: 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) public DamageOrbIdentifier(NetworkReader reader) { //IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Index = NetworkExtensions.ReadPackedIndex32(reader); OrbEffectIndex = NetworkExtensions.ReadEffectIndex(reader); OrbType = reader.ReadSerializableType(); } public readonly void Serialize(NetworkWriter writer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) NetworkExtensions.WritePackedIndex32(writer, Index); NetworkExtensions.WriteEffectIndex(writer, OrbEffectIndex); writer.WriteSerializableType(OrbType); } public readonly bool Equals(in DamageOrbIdentifier other, bool compareIndex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (compareIndex) { return Index == other.Index; } if (OrbEffectIndex == other.OrbEffectIndex) { return OrbType == other.OrbType; } return false; } public readonly bool Equals(DamageOrbIdentifier other) { return Equals(in other, compareIndex: true); } public override readonly string ToString() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) return string.Format("{0}={1} {2}={3} {4}={5}", "Index", Index, "OrbEffectIndex", OrbEffectIndex, "OrbType", ((Type)OrbType)?.Name ?? "null"); } public readonly bool Matches(GenericDamageOrb damageOrb) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return OrbEffectIndex == EffectCatalog.FindEffectIndexFromPrefab(damageOrb.GetOrbEffect()); } public readonly GenericDamageOrb CreateInstance() { //IL_0001: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown Type type = (Type)OrbType; if (type == typeof(ChainGunOrb)) { object[] array = new object[1]; EffectDef effectDef = EffectCatalog.GetEffectDef(OrbEffectIndex); array[0] = ((effectDef != null) ? effectDef.prefab : null); return (GenericDamageOrb)Activator.CreateInstance(type, array); } try { return (GenericDamageOrb)Activator.CreateInstance(type); } catch (MissingMethodException) { Log.Error("No valid constructor found for orb type " + type.FullName, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Projectile\\Orbs\\DamageOrbHandling\\DamageOrbIdentifier.cs", "CreateInstance", 93); return null; } } public static implicit operator ProjectileTypeIdentifier(in DamageOrbIdentifier damageOrbIdentifier) { return new ProjectileTypeIdentifier(ProjectileType.DamageOrb, damageOrbIdentifier.Index); } bool ICatalogIdentifier.Equals(in DamageOrbIdentifier other, bool compareIndex) { return Equals(in other, compareIndex); } } } namespace RoR2Randomizer.RandomizerControllers.Projectile.BulletAttackHandling { public class BulletAttackCatalog : GenericNetworkedCatalog { public static readonly BulletAttackCatalog Instance = new BulletAttackCatalog(); protected override BulletAttackIdentifier InvalidIdentifier => BulletAttackIdentifier.Invalid; private BulletAttackCatalog() { SyncBulletAttackCatalog.OnReceive += base.SyncCatalog_OnReceive; SyncBulletAttackIndexNeeded.OnReceive += base.SyncIndexNeeded_OnReceive; } [SystemInitializer(new Type[] { typeof(EffectCatalog) })] private static void Init() { 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); static EffectIndex findEffectIndex(string name) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(name)) { for (int i = 0; i < EffectCatalog.effectCount; i++) { EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)i); if (effectDef != null && effectDef.prefabName == name) { return effectDef.index; } } } return (EffectIndex)(-1); } static void initIdentifier(string tracerEffectName, string hitEffectName, DamageType damageType = (DamageType)0u, BulletAttackFlags flags = BulletAttackFlags.None) { //IL_0003: 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_000e: Unknown result type (might be due to invalid IL or missing references) BulletAttackIdentifier identifier = new BulletAttackIdentifier(findEffectIndex(tracerEffectName), findEffectIndex(hitEffectName), damageType, flags); Instance.appendIdentifier(ref identifier, checkExisting: false); } } protected override bool tryCreateIdentifierForObject(BulletAttack bulletAttack, out BulletAttackIdentifier identifier) { identifier = new BulletAttackIdentifier(bulletAttack, BulletAttackFlags.None); return true; } protected override NetworkMessageBase getSyncIdentifierNeededMessage(in BulletAttackIdentifier identifier) { return new SyncBulletAttackIndexNeeded(in identifier); } public override IEnumerable GetNetMessages() { yield return new SyncBulletAttackCatalog(_identifiers, _identifiersCount); } public IEnumerable GetAllBulletAttackProjectileIdentifiers() { return ((IEnumerable)this).Select((Func)((BulletAttackIdentifier i) => i)); } } [Flags] public enum BulletAttackFlags : uint { None = 0u, Sniper = 1u } public struct BulletAttackIdentifier : ICatalogIdentifier { public static readonly BulletAttackIdentifier Invalid = new BulletAttackIdentifier((EffectIndex)0, (EffectIndex)0, (DamageType)0, BulletAttackFlags.None) { Index = -1 }; public readonly EffectIndex TracerEffectIndex; public readonly EffectIndex HitEffectIndex; public readonly DamageType DamageType; public readonly BulletAttackFlags Flags; public int Index { get; set; } public readonly bool IsValid => Index != -1; public BulletAttackIdentifier(BulletAttack bulletAttack, BulletAttackFlags flags) : this(EffectCatalog.FindEffectIndexFromPrefab(bulletAttack.tracerEffectPrefab), EffectCatalog.FindEffectIndexFromPrefab(bulletAttack.hitEffectPrefab), DamageTypeCombo.op_Implicit(bulletAttack.damageType), flags) { }//IL_0007: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) public BulletAttackIdentifier(EffectIndex tracerEffectIndex, EffectIndex hitEffectIndex, DamageType damageType, BulletAttackFlags flags) { //IL_0008: 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_000f: 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_0016: 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) Index = 0; TracerEffectIndex = tracerEffectIndex; HitEffectIndex = hitEffectIndex; DamageType = damageType; Flags = flags; } public BulletAttackIdentifier(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001f: Unknown result type (might be due to invalid IL or missing references) TracerEffectIndex = NetworkExtensions.ReadEffectIndex(reader); HitEffectIndex = NetworkExtensions.ReadEffectIndex(reader); DamageType = (DamageType)reader.ReadPackedUInt32(); Flags = (BulletAttackFlags)reader.ReadPackedUInt32(); Index = (int)reader.ReadPackedUInt32(); } public readonly bool Matches(BulletAttack bulletAttack) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (bulletAttack != null && EffectCatalog.FindEffectIndexFromPrefab(bulletAttack.tracerEffectPrefab) == TracerEffectIndex && EffectCatalog.FindEffectIndexFromPrefab(bulletAttack.hitEffectPrefab) == HitEffectIndex) { return DamageTypeCombo.op_Implicit(bulletAttack.damageType) == DamageType; } return false; } public readonly bool Equals(in BulletAttackIdentifier other, bool compareIndex) { //IL_0004: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!compareIndex) { if (TracerEffectIndex == other.TracerEffectIndex && HitEffectIndex == other.HitEffectIndex && DamageType == other.DamageType) { return Flags == other.Flags; } return false; } return Index == other.Index; } public readonly BulletAttack CreateInstance() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown BulletAttack val = new BulletAttack { sniper = ((Flags & BulletAttackFlags.Sniper) != 0) }; val.damageType |= DamageTypeCombo.op_Implicit(DamageType); return val; } public readonly void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected I4, but got Unknown NetworkExtensions.WriteEffectIndex(writer, TracerEffectIndex); NetworkExtensions.WriteEffectIndex(writer, HitEffectIndex); writer.WritePackedUInt32((uint)(int)DamageType); writer.WritePackedUInt32((uint)Flags); writer.WritePackedUInt32((uint)Index); } public override readonly string ToString() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) return string.Format("{0}={1}, {2}={3}, {4}={5}, {6}={7}, {8}={9}", "Index", Index, "TracerEffectIndex", TracerEffectIndex, "HitEffectIndex", HitEffectIndex, "DamageType", DamageType, "Flags", Flags); } public static implicit operator ProjectileTypeIdentifier(in BulletAttackIdentifier bulletAttack) { return new ProjectileTypeIdentifier(ProjectileType.Bullet, bulletAttack.Index); } bool ICatalogIdentifier.Equals(in BulletAttackIdentifier other, bool compareIndex) { return Equals(in other, compareIndex); } } } namespace RoR2Randomizer.RandomizerControllers.Item { public sealed class ItemRandomizerConfig : BaseRandomizerConfig { private readonly ParsedPickupIndexListConfigValue _pickupBlacklist; public bool IsBlacklisted(PickupIndex pickupIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _pickupBlacklist.BinarySearch(pickupIndex, PickupIndexComparer.Instance) >= 0; } public ItemRandomizerConfig(ConfigFile file) : base("Item", file) { _pickupBlacklist = new ParsedPickupIndexListConfigValue(getEntry("Item Blacklist", "A comma separated list of items or equipment to exclude from the item randomizer\n\nThe internal names are used for this field", string.Empty)); } } [RandomizerController] public class ItemRandomizerController : BaseRandomizerController { private static ItemRandomizerController _instance; private static int[] _pickupIndicesToRandomize; private static readonly ulong _registerItemNameLanguageOverlaysCallbackHandle; private static readonly RunSpecific _hasReceivedPickupIndexReplacementsFromServer; private static readonly RunSpecific _pickupIndexReplacements; public override bool IsRandomizerEnabled => IsEnabled; public static bool IsEnabled { get { if (!NetworkClient.active || !_hasReceivedPickupIndexReplacementsFromServer) { if (NetworkServer.active) { return ConfigManager.ItemRandomizer.Enabled; } return false; } return true; } } protected override bool isNetworked => true; static ItemRandomizerController() { _hasReceivedPickupIndexReplacementsFromServer = new RunSpecific(0, defaultValue: false); _pickupIndexReplacements = new RunSpecific(tryComputePickupIndexReplacements); _registerItemNameLanguageOverlaysCallbackHandle = RunSpecificCallbacksManager.AddEntry(registerItemNameLanguageOverlays, null, -1); } [SystemInitializer(new Type[] { typeof(PickupCatalog), typeof(ItemCatalog), typeof(NullModelMarker) })] private static void InitPickupIndicesToRandomize() { _pickupIndicesToRandomize = (from pd in PickupCatalog.allPickups.Where(delegate(PickupDef pd) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) if ((int)pd.artifactIndex != -1) { return false; } if ((int)pd.miscPickupIndex != -1) { return false; } if (pd.internalName.StartsWith("ItemTier.")) { return false; } if (pd.IsEquipment() && ReadOnlyArray.BinarySearch(CharacterReplacements.AvailableDroneEquipments, pd.equipmentIndex) < 0) { return false; } if (!Object.op_Implicit((Object)(object)pd.dropletDisplayPrefab)) { return false; } if (!Object.op_Implicit((Object)(object)pd.displayPrefab) || Object.op_Implicit((Object)(object)pd.displayPrefab.GetComponent())) { return false; } if (string.IsNullOrEmpty(pd.nameToken) || Language.GetString(pd.nameToken) == pd.nameToken) { return false; } if (pd.IsItem()) { ItemDef itemDef = ItemCatalog.GetItemDef(pd.itemIndex); if ((Object)(object)itemDef == (Object)null || itemDef.hidden) { return false; } } return true; }) select pd.pickupIndex.value).ToArray(); } private static bool tryComputePickupIndexReplacements(out IndexReplacementsCollection result) { if (IsEnabled && Object.op_Implicit((Object)(object)_instance)) { IEnumerable collection = _pickupIndicesToRandomize.Where((int i) => !ConfigManager.ItemRandomizer.IsBlacklisted(new PickupIndex(i))); result = new IndexReplacementsCollection(ReplacementDictionary.CreateFrom(collection, _instance.RNG), PickupCatalog.pickupCount); return true; } result = default(IndexReplacementsCollection); return false; } protected override IEnumerable getNetMessages() { yield return new SyncItemReplacements(_pickupIndexReplacements); } protected override void Awake() { base.Awake(); SyncItemReplacements.OnReceive += SyncItemReplacements_OnReceive; SingletonHelper.Assign(ref _instance, this); if (IsEnabled && !_pickupIndexReplacements.HasValue && tryComputePickupIndexReplacements(out var result)) { _pickupIndexReplacements.Value = result; } } protected override void OnDestroy() { base.OnDestroy(); _pickupIndexReplacements.Dispose(); RunSpecificCallbacksManager.RemoveEntry(_registerItemNameLanguageOverlaysCallbackHandle); SyncItemReplacements.OnReceive -= SyncItemReplacements_OnReceive; SingletonHelper.Unassign(ref _instance, this); } private static void SyncItemReplacements_OnReceive(in IndexReplacementsCollection itemIndexReplacements) { _pickupIndexReplacements.Value = itemIndexReplacements; _hasReceivedPickupIndexReplacementsFromServer.Value = true; registerItemNameLanguageOverlays(); } private static void registerItemNameLanguageOverlays() { //IL_000d: 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_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) if (IsEnabled) { createCostTypeOverlays(PickupCatalog.FindPickupIndex(Items.ArtifactKey.itemIndex), "COST_ARTIFACTSHELLKILLERITEM_FORMAT"); createCostTypeOverlays(PickupCatalog.FindPickupIndex(Equipment.QuestVolatileBattery.equipmentIndex), "COST_VOLATILEBATTERY_FORMAT"); } static void createCostTypeOverlays(PickupIndex originalPickupIndex, string key) { if (TryGetReplacementPickupIndex(in originalPickupIndex, out var replacement)) { PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; foreach (Language allLanguage in Language.GetAllLanguages()) { RunSpecificLanguageOverlay.AddRunLanguageOverlay(LanguageAPI.AddOverlay(key, "{0} " + allLanguage.GetLocalizedStringByToken(pickupDef.nameToken), allLanguage.name)); } } } } public static bool TryGetReplacementPickupIndex(in PickupIndex original, out PickupIndex replacement) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled && ((PickupIndex)(ref original)).isValid && _pickupIndexReplacements.HasValue && _pickupIndexReplacements.Value.TryGetReplacement(original.value, out var replacement2)) { replacement = new PickupIndex(replacement2); return ((PickupIndex)(ref replacement)).isValid; } replacement = PickupIndex.none; return false; } public static PickupIndex GetReplacementPickupIndex(PickupIndex pickupIndex) { //IL_000d: 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) if (TryGetReplacementPickupIndex(in pickupIndex, out var replacement)) { return replacement; } return pickupIndex; } public static void HandleCharacterGrantedRandomizedEquipment(CharacterMaster master) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)master) && IsEnabled && !Object.op_Implicit((Object)(object)master.playerCharacterMasterController)) { Inventory inventory = master.inventory; if (Object.op_Implicit((Object)(object)inventory) && (int)inventory.currentEquipmentIndex != -1) { inventory.GiveItemIfMissing(ContentPackManager.Items.MonsterUseEquipmentDummyItem); } } } } } namespace RoR2Randomizer.RandomizerControllers.Item_Tier { public sealed class ItemTierRandomizerConfig : BaseRandomizerConfig { public readonly BoolConfigValue RandomizeScrap; private readonly ParsedItemIndexListConfigValue _itemBlacklist; public bool IsBlacklisted(ItemIndex itemIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _itemBlacklist.BinarySearch(itemIndex) >= 0; } public ItemTierRandomizerConfig(ConfigFile file) : base("Item Tier", file) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown RandomizeScrap = new BoolConfigValue(getEntry("Randomize Scrap", new ConfigDescription("If the tiers of scrap items should be randomized", (AcceptableValueBase)null, Array.Empty()), defaultValue: true)); _itemBlacklist = new ParsedItemIndexListConfigValue(getEntry("Item Blacklist", "A comma separated list of items to exclude from the item tier randomizer.\n\nThe internal names are used for this field", string.Empty)); } } [RandomizerController] public sealed class ItemTierRandomizerController : BaseRandomizerController { private static ItemTierRandomizerController _instance; private static ItemTier[] _originalItemTiers; private static ItemIndex[] _itemIndicesToRandomize; private static readonly RunSpecific _hasReceivedOverrideItemTiersFromServer = new RunSpecific(0, defaultValue: false); private static readonly RunSpecific _overrideItemTiers = new RunSpecific(delegate(out ItemTier?[] result) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled) { result = ItemCatalog.GetPerItemBuffer(); if (result == null) { return false; } if ((Object)(object)Instance == (Object)null) { result = null; return false; } IEnumerable enumerable = _itemIndicesToRandomize.Where(delegate(ItemIndex i) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ItemCatalog.GetItemDef(i); if (!Object.op_Implicit((Object)(object)itemDef)) { return false; } if (ConfigManager.ItemTierRandomizer.IsBlacklisted(i)) { return false; } return ((bool)ConfigManager.ItemTierRandomizer.RandomizeScrap || (!itemDef.ContainsTag((ItemTag)14) && !itemDef.ContainsTag((ItemTag)10))) ? true : false; }); List list = new List(enumerable.Select(GetOriginalItemTier)); foreach (ItemIndex item in enumerable) { if (list.Count == 0) { break; } ItemTier andRemoveRandom = list.GetAndRemoveRandom(Instance.RNG); if (GetOriginalItemTier(item) != andRemoveRandom) { result[item] = andRemoveRandom; } } _ = list.Count; _ = 0; return true; } result = null; return false; }); private static ulong _itemTierReplacementsCallbacksHandle; public static ItemTierRandomizerController Instance => _instance; public static bool IsEnabled { get { if (!NetworkClient.active || !_hasReceivedOverrideItemTiersFromServer) { if (NetworkServer.active) { return ConfigManager.ItemTierRandomizer.Enabled; } return false; } return true; } } public override bool IsRandomizerEnabled => IsEnabled; protected override bool isNetworked => true; [SystemInitializer(new Type[] { typeof(ItemCatalog) })] private unsafe static void InitOriginalItemTiers() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) _originalItemTiers = ItemCatalog.GetPerItemBuffer(); GenericStaticEnumerable allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; ItemDef itemDef = ItemCatalog.GetItemDef(current); if (Object.op_Implicit((Object)(object)itemDef)) { _originalItemTiers[current] = (ItemTier)(int)itemDef.tier; } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } _itemIndicesToRandomize = (from item in ((IEnumerable)(object)ItemCatalog.allItemDefs).Where(delegate(ItemDef item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 ItemTier tier = item.tier; if ((int)tier > 4 && tier - 6 > 3) { return false; } if (item.hidden) { return false; } if (!Object.op_Implicit((Object)(object)item.pickupModelPrefab) || Object.op_Implicit((Object)(object)item.pickupModelPrefab.GetComponent())) { return false; } return (!string.IsNullOrEmpty(item.nameToken) && !(Language.GetString(item.nameToken) == item.nameToken)) ? true : false; }) select item.itemIndex).ToArray(); } protected override IEnumerable getNetMessages() { yield return new SyncItemTierReplacements(_overrideItemTiers); } protected override void Awake() { base.Awake(); SingletonHelper.Assign(ref _instance, this); _itemTierReplacementsCallbacksHandle = RunSpecificCallbacksManager.AddEntry(tryApplyItemTierReplacements, restoreItemTierReplacements, -1); SyncItemTierReplacements.OnReceive += SyncItemTierReplacements_OnReceive; } protected override void OnDestroy() { base.OnDestroy(); SingletonHelper.Unassign(ref _instance, this); _overrideItemTiers.Dispose(); _hasReceivedOverrideItemTiersFromServer.Dispose(); SyncItemTierReplacements.OnReceive -= SyncItemTierReplacements_OnReceive; RunSpecificCallbacksManager.RemoveEntry(_itemTierReplacementsCallbacksHandle); } private static void SyncItemTierReplacements_OnReceive(ItemTier?[] itemTierOverrides) { _overrideItemTiers.Value = itemTierOverrides; _hasReceivedOverrideItemTiersFromServer.Value = true; tryApplyItemTierReplacements(); } private static void refreshPickupDef(ItemDef item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 ItemTier tier = item.tier; ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(tier); if (!Object.op_Implicit((Object)(object)itemTierDef)) { return; } PickupIndex val = PickupCatalog.FindPickupIndex(item.itemIndex); if (((PickupIndex)(ref val)).isValid) { PickupDef pickupDef = PickupCatalog.GetPickupDef(val); if (pickupDef != null) { pickupDef.itemTier = tier; pickupDef.baseColor = Color32.op_Implicit(ColorCatalog.GetColor(itemTierDef.colorIndex)); pickupDef.darkColor = Color32.op_Implicit(ColorCatalog.GetColor(itemTierDef.darkColorIndex)); pickupDef.isLunar = (int)tier == 3; pickupDef.isBoss = (int)tier == 4; pickupDef.dropletDisplayPrefab = itemTierDef.dropletDisplayPrefab; pickupDef.iconSprite = item.pickupIconSprite; pickupDef.iconTexture = item.pickupIconTexture; } } } private unsafe static void tryApplyItemTierReplacements() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled && Object.op_Implicit((Object)(object)Instance)) { return; } if (!_overrideItemTiers.HasValue || _overrideItemTiers.Value == null) { Log.Warning("Trying to apply item tier replacements, but no override tiers are defined", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\ItemTier\\ItemTierRandomizerController.cs", "tryApplyItemTierReplacements", 261); return; } GenericStaticEnumerable allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; ItemDef itemDef = ItemCatalog.GetItemDef(current); if (!Object.op_Implicit((Object)(object)itemDef)) { continue; } ItemTier tier = itemDef.tier; itemDef.tier = GetOverrideItemTier(current); if (tier == itemDef.tier) { continue; } refreshPickupDef(itemDef); if ((int)tier == 4 == ((int)itemDef.tier == 4)) { continue; } int index2; if ((int)tier == 4) { if (itemCorrupts(current, out var index)) { RemoveTransformationInfoAt(index); } } else if (!itemCorrupts(current, out index2)) { AppendTransformationInfo(new TransformationInfo { originalItem = current, transformedItem = Items.VoidMegaCrabItem.itemIndex }); } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } Run.instance.BuildDropTable(); FieldInfo fieldInfo = AccessTools.DeclaredField(typeof(Run), "onAvailablePickupsModified"); if (fieldInfo != null) { ((Action)fieldInfo.GetValue(null))?.Invoke(Run.instance); } static bool itemCorrupts(ItemIndex itemIndex, out int reference) { //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) for (int i = 0; i < ContagiousItemManager.transformationInfos.Length; i++) { if (((TransformationInfo)ContagiousItemManager.transformationInfos[i]).originalItem == itemIndex) { reference = i; return true; } } reference = -1; return false; } } private static void AppendTransformationInfo(TransformationInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) TransformationInfo[] array = ((IEnumerable)(object)ContagiousItemManager.transformationInfos).ToArray(); ArrayUtils.ArrayAppend(ref array, ref info); ContagiousItemManager.transformationInfos = new ReadOnlyArray(array); } private static void RemoveTransformationInfoAt(int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) TransformationInfo[] array = ((IEnumerable)(object)ContagiousItemManager.transformationInfos).ToArray(); ArrayUtils.ArrayRemoveAtAndResize(ref array, index, 1); ContagiousItemManager.transformationInfos = new ReadOnlyArray(array); } private unsafe static void restoreItemTierReplacements() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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) //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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) GenericStaticEnumerable allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; ItemDef itemDef = ItemCatalog.GetItemDef(current); if (Object.op_Implicit((Object)(object)itemDef)) { itemDef.tier = GetOriginalItemTier(current); refreshPickupDef(itemDef); } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } ContagiousItemManager.transformationInfos = ReadOnlyArray.op_Implicit(Array.Empty()); } public static ItemTier GetOriginalItemTier(ItemIndex itemIndex) { //IL_0005: 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_0013: Expected I4, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) ItemTier[] originalItemTiers = _originalItemTiers; ItemTier val = (ItemTier)1000; return ArrayUtils.GetSafe(originalItemTiers, (int)itemIndex, ref val); } public static ItemTier GetOverrideItemTier(ItemIndex index) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0038: Expected I4, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled && _overrideItemTiers.HasValue && _overrideItemTiers.Value != null) { ItemTier?[] value = _overrideItemTiers.Value; ItemTier? val = null; ItemTier? safe = ArrayUtils.GetSafe(value, (int)index, ref val); if (safe.HasValue) { return safe.Value; } } return GetOriginalItemTier(index); } } } namespace RoR2Randomizer.RandomizerControllers.ExplicitSpawn { public sealed class ExplicitSpawnRandomizerConfig : BaseRandomizerConfig { private readonly ParsedMasterIndexListConfigValue _masterBlacklist; public readonly BoolConfigValue RandomizeDirectorSpawns; public readonly BoolConfigValue RandomizeAbandonedAqueductRingEvent; public readonly BoolConfigValue RandomizeBeetleQueenSummonGuards; public readonly BoolConfigValue RandomizeVoidSeedMonsters; public readonly BoolConfigValue RandomizeRoboBallBuddies; public readonly BoolConfigValue RandomizeHeretic; public readonly BoolConfigValue RandomizeEngiTurrets; public readonly BoolConfigValue RandomizeMalachiteUrchins; public readonly BoolConfigValue RandomizeSoulWisps; public readonly BoolConfigValue RandomizeHealingCores; public readonly BoolConfigValue RandomizeVoidInfestors; public readonly BoolConfigValue RandomizeDefenseNucleusAlphaConstruct; public readonly BoolConfigValue RandomizeQueensGlandBeetleGuards; public readonly BoolConfigValue RandomizeRoboBallBossMinions; public readonly BoolConfigValue RandomizeShopkeeperNewt; public readonly BoolConfigValue RandomizeSquidTurrets; public readonly BoolConfigValue RandomizeDrones; public readonly BoolConfigValue RandomizeZoeaVoidAllies; public readonly BoolConfigValue RandomizeAncestralPods; public readonly BoolConfigValue RandomizeDoppelgangers; public bool IsBlacklisted(MasterIndex index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _masterBlacklist.BinarySearch(index, MasterIndexComparer.Instance) >= 0; } public ExplicitSpawnRandomizerConfig(ConfigFile file) : base("Summon", file) { _masterBlacklist = new ParsedMasterIndexListConfigValue(getEntry("Character Blacklist", "A comma-separated list of characters to exclude from the summon randomizer.\n\nUse the internal master names for this field", string.Empty)); RandomizeBeetleQueenSummonGuards = new BoolConfigValue(getEntry("Randomize Beetle Queen Guards", "Randomizes the character types of Beetle Guards spawned by Beetle Queens", defaultValue: true)); RandomizeVoidSeedMonsters = new BoolConfigValue(getEntry("Randomize Void Seed enemies", "Randomizes the character types of Void enemies spawned in Void Seeds (Barnacles, Reavers, and Jailers).\n\nThis does not affect the voidtouched elites that are also spawned by the void seed.", defaultValue: true)); RandomizeRoboBallBuddies = new BoolConfigValue(getEntry("Randomize Quiet & Delighted Probes", "Randomizes the character types of Quiet and Delighted Probes.", defaultValue: true)); RandomizeHeretic = new BoolConfigValue(getEntry("Randomize Heretic", "Randomizes the character type you become when getting all the Heresy items (You still get the Heretic skills no matter which character type you become).", defaultValue: true)); RandomizeEngiTurrets = new BoolConfigValue(getEntry("Randomize Engineer Turrets", "Randomizes the character type of Engineer Turrets.", defaultValue: true)); RandomizeMalachiteUrchins = new BoolConfigValue(getEntry("Randomize Malachite Urchins", "Randomizes the character type of Malachite Urchins", defaultValue: true)); RandomizeSoulWisps = new BoolConfigValue(getEntry("Randomize Soul Wisps", "Randomizes the character types of soul wisps", defaultValue: true)); RandomizeHealingCores = new BoolConfigValue(getEntry("Randomize Healing Cores", "Randomizes the character type of Healing Cores", defaultValue: true)); RandomizeVoidInfestors = new BoolConfigValue(getEntry("Randomize Void Infestors", "Randomizes the character type of Void Infestors", defaultValue: true)); RandomizeDefenseNucleusAlphaConstruct = new BoolConfigValue(getEntry("Randomize Defense Nucleus Constructs", "Randomizes the character type of Alpha Constructs spawned by Defense Nucleus", defaultValue: true)); RandomizeQueensGlandBeetleGuards = new BoolConfigValue(getEntry("Randomize Queens Gland Beetle Guards", "Randomizes the character type of Beetle Guards spawned by Queens Gland", defaultValue: true)); RandomizeRoboBallBossMinions = new BoolConfigValue(getEntry("Randomize Solus Control Unit Probes", "Randomizes the character types of Solus Probes spawned by Solus Control Unit and Alloy Worship Unit", defaultValue: true)); RandomizeShopkeeperNewt = new BoolConfigValue(getEntry("Randomize Shopkeeper Newt", "Randomizes the character type of the Shopkeeper Newt", defaultValue: true)); RandomizeSquidTurrets = new BoolConfigValue(getEntry("Randomize Squid Turrets", "Randomizes the character type of Squid Turrets", defaultValue: true)); RandomizeDrones = new BoolConfigValue(getEntry("Randomize Drones", "Randomizes the character types of drones and turrets", defaultValue: true)); RandomizeZoeaVoidAllies = new BoolConfigValue(getEntry("Randomize Newly Hatched Zoea", "Randomizes the character types of the allies spawned by Newly Hatched Zoea", defaultValue: true)); RandomizeDirectorSpawns = new BoolConfigValue(getEntry("Randomize Director Spawns", "Randomizes stage director spawns, no measures have been taken to \"balance\" the spawns, and anything can spawn. Basically Artifact of Dissonance on crack.\n\nDisabled by default.", defaultValue: false)); RandomizeAncestralPods = new BoolConfigValue(getEntry("Randomize Ancestral Pods", "Randomizes the character types of the Parents hatched from Ancestral Pods", defaultValue: true)); RandomizeDoppelgangers = new BoolConfigValue(getEntry("Randomize Umbras", "Randomizes the character types of Umbras", defaultValue: true)); } } [RandomizerController] public sealed class ExplicitSpawnRandomizerController : BaseRandomizerController { private static readonly RunSpecific _isEnabledServer = new RunSpecific(0, defaultValue: false); public static readonly RunSpecific IsHereticRandomized = new RunSpecific(delegate(out bool result) { if (NetworkServer.active) { result = IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeHeretic; return true; } result = false; return false; }, 0, defaultValue: false); public override bool IsRandomizerEnabled => IsActive; public static bool IsActive { get { if (!NetworkServer.active || (!ConfigManager.ExplicitSpawnRandomizer.Enabled && !CharacterReplacements.IsAnyForcedCharacterModeEnabled)) { if (NetworkClient.active) { return _isEnabledServer; } return false; } return true; } } protected override bool isNetworked => true; [SystemInitializer(new Type[] { typeof(Caches.Bodies) })] private static void Init() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_000d: 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) if ((int)Caches.Bodies.SquidTurretBodyIndex != -1) { ItemDescriptionNameReplacementManager.AddEntry("ITEM_SQUIDTURRET_PICKUP", Caches.Bodies.SquidTurretBodyIndex, ConfigManager.ExplicitSpawnRandomizer.RandomizeSquidTurrets); } if ((int)Caches.Bodies.MinorConstructOnKillBodyIndex != -1) { ItemDescriptionNameReplacementManager.AddEntry("ITEM_MINORCONSTRUCTONKILL_PICKUP", Caches.Bodies.MinorConstructOnKillBodyIndex, ConfigManager.ExplicitSpawnRandomizer.RandomizeDefenseNucleusAlphaConstruct); } } protected override IEnumerable getNetMessages() { yield return new SyncExplicitSpawnRandomizerEnabled(IsActive, ConfigManager.ExplicitSpawnRandomizer.RandomizeHeretic); } public static MasterIndex GetOriginalMasterIndex(GameObject replacementObject) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) CharacterMaster val = default(CharacterMaster); if (IsActive && Object.op_Implicit((Object)(object)replacementObject) && replacementObject.TryGetComponent(ref val)) { MasterIndex masterIndex = val.masterIndex; if (((MasterIndex)(ref masterIndex)).isValid) { return GetOriginalMasterIndex(val.masterIndex); } } return MasterIndex.none; } public static MasterIndex GetOriginalMasterIndex(MasterIndex replacement) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (IsActive) { return CharacterReplacements.GetOriginalMasterIndex(replacement); } return MasterIndex.none; } public static bool TryReplaceSummon(ref GameObject prefab, out GameObject originalPrefab) { originalPrefab = prefab; return TryReplaceSummon(ref prefab); } public static bool TryReplaceSummon(ref GameObject prefab) { if (IsActive) { return CharacterReplacements.TryReplaceMasterPrefab(ref prefab); } return false; } public static GameObject GetSummonReplacement(GameObject original) { TryReplaceSummon(ref original); return original; } public static CharacterMaster GetSummonReplacement(CharacterMaster original) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) GameObject masterPrefab = MasterCatalog.GetMasterPrefab(GetSummonReplacement(original.masterIndex)); if (Object.op_Implicit((Object)(object)masterPrefab)) { return masterPrefab.GetComponent(); } return null; } public static MasterIndex GetSummonReplacement(MasterIndex original) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (IsActive) { return CharacterReplacements.GetReplacementForMasterIndex(original); } return MasterIndex.none; } public static bool TryGetReplacementMaster(CharacterMaster originalPrefab, out CharacterMaster replacementPrefab) { if (IsActive) { GameObject replacementMasterPrefab = CharacterReplacements.GetReplacementMasterPrefab(((Object)originalPrefab).name); if (Object.op_Implicit((Object)(object)replacementMasterPrefab) && replacementMasterPrefab.TryGetComponent(ref replacementPrefab)) { return true; } } replacementPrefab = null; return false; } public static void TryReplaceDirectorSpawnRequest(DirectorSpawnRequest spawnRequest) { if (IsActive) { CharacterReplacements.TryReplaceDirectorSpawnRequest(spawnRequest, RegisterSpawnedReplacement); } } public static bool TryGetReplacementBodyName(string originalName, out string replacementName) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: 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) if (IsActive) { BodyIndex val = BodyCatalog.FindBodyIndex(originalName); if ((int)val != -1 && TryGetReplacementBodyIndex(val, out var replacement)) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(replacement); if (Object.op_Implicit((Object)(object)bodyPrefab)) { replacementName = ((Object)bodyPrefab).name; return true; } } } replacementName = null; return false; } public static bool TryGetReplacementBodyIndex(BodyIndex original, out BodyIndex replacement) { //IL_0008: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected I4, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (IsActive) { BodyIndex replacementBodyIndex; replacement = (BodyIndex)(int)(replacementBodyIndex = CharacterReplacements.GetReplacementBodyIndex(original)); return (int)replacementBodyIndex != -1; } replacement = (BodyIndex)(-1); return false; } public static bool TryGetOriginalBodyName(string replacementName, out string originalName) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (IsActive) { BodyIndex val = BodyCatalog.FindBodyIndex(replacementName); if ((int)val != -1) { BodyIndex originalBodyIndex = CharacterReplacements.GetOriginalBodyIndex(val); if ((int)originalBodyIndex != -1) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(originalBodyIndex); if (Object.op_Implicit((Object)(object)bodyPrefab)) { originalName = ((Object)bodyPrefab).name; return true; } } } } originalName = null; return false; } protected override void Awake() { base.Awake(); SyncExplicitSpawnReplacement.OnReceive += RegisterSpawnedReplacement; SyncExplicitSpawnRandomizerEnabled.OnReceive += SyncExplicitSpawnRandomizerEnabled_OnReceive; } protected override void OnDestroy() { base.OnDestroy(); SyncExplicitSpawnReplacement.OnReceive -= RegisterSpawnedReplacement; SyncExplicitSpawnRandomizerEnabled.OnReceive -= SyncExplicitSpawnRandomizerEnabled_OnReceive; } private static void SyncExplicitSpawnRandomizerEnabled_OnReceive(bool isEnabled, bool randomizeHeretic) { _isEnabledServer.Value = isEnabled; IsHereticRandomized.Value = randomizeHeretic; } public static void RegisterSpawnedReplacement(GameObject masterObject, MasterIndex originalMasterIndex) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((!NetworkServer.active || IsActive) && Object.op_Implicit((Object)(object)masterObject) && ((MasterIndex)(ref originalMasterIndex)).isValid) { ExplicitSpawnReplacementInfo explicitSpawnReplacementInfo = masterObject.AddComponent(); explicitSpawnReplacementInfo.OriginalMasterIndex = originalMasterIndex; explicitSpawnReplacementInfo.Initialize(); } } public static void RegisterSpawnedReplacement(GameObject masterObject) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) RegisterSpawnedReplacement(masterObject, GetOriginalMasterIndex(masterObject)); } public static Manipulator GetSimpleDirectorSpawnRequestHook(BoolConfigValue isEnabledConfigValue) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return (Manipulator)delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TrySpawnObject") })) { num++; val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(DirectorSpawnRequest spawnRequest) { if (isEnabledConfigValue == null || (bool)isEnabledConfigValue) { TryReplaceDirectorSpawnRequest(spawnRequest); } }); int index = val.Index; val.Index = index + 1; } if (num == 0) { Log.Warning("failed to find any patch locations for TrySpawnObject", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\ExplicitSpawn\\ExplicitSpawnRandomizerController.cs", "GetSimpleDirectorSpawnRequestHook", 274); } }; } } public class ExplicitSpawnReplacementInfo : CharacterReplacementInfo { private MasterIndex _originalMasterIndex; private CharacterMaster _cachedMasterPrefab; public MasterIndex OriginalMasterIndex { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _originalMasterIndex; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _originalMasterIndex = value; GameObject masterPrefab = MasterCatalog.GetMasterPrefab(value); if (!Object.op_Implicit((Object)(object)masterPrefab) || !masterPrefab.TryGetComponent(ref _cachedMasterPrefab)) { _cachedMasterPrefab = null; } } } protected override CharacterMaster originalMasterPrefab => _cachedMasterPrefab; protected override SetSubtitleMode subtitleOverrideMode => SetSubtitleMode.OnlyIfExistingIsNull; protected override bool isNetworked => true; protected override IEnumerable getNetMessages() { yield return new SyncExplicitSpawnReplacement(((Component)_master).gameObject, _originalMasterIndex); } } internal static class FullExplicitSpawnInitListener { private static readonly RunSpecific _explicitSpawnRandomizerEnabledAvailable = new RunSpecific(() => NetworkServer.active && ExplicitSpawnRandomizerController.IsActive, 0, defaultValue: false); private static readonly RunSpecific _characterReplacementsInitialized = new RunSpecific(0, defaultValue: false); private static readonly RunSpecific _hasDispatchedInitForCurrentRun = new RunSpecific(0, defaultValue: false); public static event Action OnFullInit; [SystemInitializer(new Type[] { })] private static void Init() { SyncExplicitSpawnRandomizerEnabled.OnReceive += SyncExplicitSpawnRandomizerEnabled_OnReceive; CharacterReplacements.OnCharacterReplacementsInitialized += characterReplacementsInitialized; RoR2Application.onUpdate += update; } private static void SyncExplicitSpawnRandomizerEnabled_OnReceive(bool isEnabled, bool randomizeHeretic) { _explicitSpawnRandomizerEnabledAvailable.Value = true; } private static void characterReplacementsInitialized() { _characterReplacementsInitialized.Value = true; } private static void update() { if (Object.op_Implicit((Object)(object)Run.instance) && !_hasDispatchedInitForCurrentRun && (bool)_explicitSpawnRandomizerEnabledAvailable && (bool)_characterReplacementsInitialized) { FullExplicitSpawnInitListener.OnFullInit?.Invoke(); _hasDispatchedInitForCurrentRun.Value = true; } } } internal static class HereticNameInDialogueOverrideManager { private static LanguageOverlay[] _hereticNameOverlays; [SystemInitializer(new Type[] { })] private static void Init() { Run.onRunDestroyGlobal += onRunEnd; FullExplicitSpawnInitListener.OnFullInit += FullExplicitSpawnInitListener_OnFullInit; } private static void FullExplicitSpawnInitListener_OnFullInit() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((bool)ExplicitSpawnRandomizerController.IsHereticRandomized && ExplicitSpawnRandomizerController.TryGetReplacementBodyIndex(Caches.Bodies.HereticBodyIndex, out var replacement)) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(replacement); CharacterBody val = default(CharacterBody); if (Object.op_Implicit((Object)(object)bodyPrefab) && bodyPrefab.TryGetComponent(ref val)) { _hereticNameOverlays = replaceHereticNames(val.baseNameToken); } } } private static LanguageOverlay[] replaceHereticNames(string replacementBodyNameToken) { Language[] array = Language.GetAllLanguages().ToArray(); LanguageOverlay[] array2 = (LanguageOverlay[])(object)new LanguageOverlay[array.Length]; for (int i = 0; i < array.Length; i++) { string languageName = array[i].name; Dictionary tokenDictionary = new Dictionary(); replaceHereticNameReference("BROTHER_SEE_HERETIC_1", uppercase: false); replaceHereticNameReference("BROTHER_SEE_HERETIC_2", uppercase: false); replaceHereticNameReference("BROTHER_KILL_HERETIC_1", uppercase: false); replaceHereticNameReference("BROTHER_KILL_HERETIC_2", uppercase: false); replaceHereticNameReference("BROTHERHURT_SEE_TITANGOLD_AND_HERETIC_1", uppercase: true); replaceHereticNameReference("BROTHERHURT_KILL_HERETIC_1", uppercase: true); replaceHereticNameReference("BROTHERHURT_KILL_HERETIC_2", uppercase: true); array2[i] = LanguageAPI.AddOverlay(tokenDictionary, languageName); void replaceHereticNameReference(string baseToken, bool uppercase) { string text = Language.GetString(baseToken, languageName); string text2 = Language.GetString("HERETIC_BODY_NAME", languageName); string text3 = Language.GetString(replacementBodyNameToken, languageName); if (uppercase) { text2 = text2.ToUpper(); text3 = text3.ToUpper(); } tokenDictionary.Add(baseToken, text.Replace(text2, text3)); } } return array2; } private static void onRunEnd(Run _) { if (_hereticNameOverlays == null) { return; } LanguageOverlay[] hereticNameOverlays = _hereticNameOverlays; foreach (LanguageOverlay obj in hereticNameOverlays) { if (obj != null) { obj.Remove(); } } _hereticNameOverlays = null; } } internal static class HereticReplacementPrefabModificationManager { private static SkillLocator _hereticPrefabSkillLocator; private static PrefabModificationTracker _hereticModificationTracker; [SystemInitializer(new Type[] { typeof(BodyCatalog) })] private static void Init() { GameObject val = BodyCatalog.FindBodyPrefab("HereticBody"); if (Object.op_Implicit((Object)(object)val)) { _hereticPrefabSkillLocator = val.GetComponent(); } FullExplicitSpawnInitListener.OnFullInit += delegate { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_0033: Unknown result type (might be due to invalid IL or missing references) MasterIndex heretic = Caches.Masters.Heretic; if (((MasterIndex)(ref heretic)).isValid && (bool)ExplicitSpawnRandomizerController.IsHereticRandomized) { MasterIndex replacementForMasterIndex = CharacterReplacements.GetReplacementForMasterIndex(Caches.Masters.Heretic); if (((MasterIndex)(ref replacementForMasterIndex)).isValid) { GameObject masterPrefab = MasterCatalog.GetMasterPrefab(replacementForMasterIndex); CharacterMaster val2 = default(CharacterMaster); if (Object.op_Implicit((Object)(object)masterPrefab) && masterPrefab.TryGetComponent(ref val2)) { GameObject bodyPrefab = val2.bodyPrefab; if (Object.op_Implicit((Object)(object)bodyPrefab) && Object.op_Implicit((Object)(object)bodyPrefab.GetComponent())) { _hereticModificationTracker = bodyPrefab.AddComponent(); _hereticModificationTracker.PerformModification(initHereticReplacementPrefab_Equipment); _hereticModificationTracker.PerformModification(initHereticReplacementPrefab_Interaction); _hereticModificationTracker.PerformModification(initHereticReplacementPrefab_Skills); } } } } }; Run.onRunDestroyGlobal += delegate { if (Object.op_Implicit((Object)(object)_hereticModificationTracker)) { _hereticModificationTracker.Undo(); _hereticModificationTracker = null; } }; } private static PrefabUndoModificationDelegate initHereticReplacementPrefab_Equipment(GameObject replacementPrefab) { if (!Object.op_Implicit((Object)(object)replacementPrefab.GetComponent())) { EquipmentSlot equipmentSlot = replacementPrefab.AddComponent(); return delegate { Object.Destroy((Object)(object)equipmentSlot); }; } return null; } private static PrefabUndoModificationDelegate initHereticReplacementPrefab_Interaction(GameObject replacementPrefab) { PrefabUndoModificationDelegate original = null; Interactor interactor = default(Interactor); if (!replacementPrefab.TryGetComponent(ref interactor)) { interactor = replacementPrefab.AddComponent(); interactor.maxInteractionDistance = 3f; MiscUtils.AppendDelegate(ref original, delegate { Object.Destroy((Object)(object)interactor); }); } if (!Object.op_Implicit((Object)(object)((Component)interactor).GetComponent())) { InteractionDriver interactionDriver = ((Component)interactor).gameObject.AddComponent(); interactionDriver.highlightInteractor = true; MiscUtils.AppendDelegate(ref original, delegate { Object.Destroy((Object)(object)interactionDriver); }); } float num; try { num = Caches.CharacterBodyRadius[replacementPrefab]; } catch (KeyNotFoundException) { num = 1.82f; } num *= 1f + 2.5934062f / ((num - 4f) / 4f + 4f); CharacterMotor component = replacementPrefab.GetComponent(); if (!Object.op_Implicit((Object)(object)component) || component.isFlying) { num *= 2f; } float oldDistance = interactor.maxInteractionDistance; interactor.maxInteractionDistance = Mathf.Max(interactor.maxInteractionDistance, num); if (oldDistance != interactor.maxInteractionDistance) { MiscUtils.AppendDelegate(ref original, delegate { if (Object.op_Implicit((Object)(object)interactor)) { interactor.maxInteractionDistance = oldDistance; } }); } return original; } private static PrefabUndoModificationDelegate initHereticReplacementPrefab_Skills(GameObject replacementPrefab) { SkillLocator val = default(SkillLocator); if (!replacementPrefab.TryGetComponent(ref val)) { return null; } PrefabUndoModificationDelegate undoCallback = null; if (Object.op_Implicit((Object)(object)_hereticPrefabSkillLocator)) { initializeHereticSkill(ref val.primary, _hereticPrefabSkillLocator.primary, "randomizedHereticPrimary"); initializeHereticSkill(ref val.secondary, _hereticPrefabSkillLocator.secondary, "randomizedHereticSecondary"); initializeHereticSkill(ref val.utility, _hereticPrefabSkillLocator.utility, "randomizedHereticUtility"); initializeHereticSkill(ref val.special, _hereticPrefabSkillLocator.special, "randomizedHereticSpecial"); } return undoCallback; void initializeHereticSkill(ref GenericSkill skill, GenericSkill hereticSkill, string fallbackName) { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)skill)) { skill = replacementPrefab.gameObject.AddComponent(); GenericSkill createdSkillDummyVar = skill; MiscUtils.AppendDelegate(ref undoCallback, delegate { Object.Destroy((Object)(object)createdSkillDummyVar); }); } ref string skillName = ref skill.skillName; if (string.IsNullOrEmpty(skillName)) { string originalName = skillName; string skillName2 = hereticSkill.skillName; if (!string.IsNullOrEmpty(skillName2)) { skillName = skillName2; } else { skillName = "Gorakh.RoR2Randomizer_" + fallbackName; } GenericSkill skillDummyVar = skill; MiscUtils.AppendDelegate(ref undoCallback, delegate { if (Object.op_Implicit((Object)(object)skillDummyVar)) { skillDummyVar.skillName = originalName; } }); } if (!Object.op_Implicit((Object)(object)skill.skillFamily)) { SkillFamily originalSkillFamily = skill.skillFamily; if (MiscUtils.TryAssign(ref skill._skillFamily, hereticSkill.skillFamily)) { GenericSkill skillDummyVar2 = skill; MiscUtils.AppendDelegate(ref undoCallback, delegate { if (Object.op_Implicit((Object)(object)skillDummyVar2)) { skillDummyVar2._skillFamily = originalSkillFamily; } }); } } string activationStateMachineName = hereticSkill.skillFamily.defaultSkillDef.activationStateMachineName; if (!Object.op_Implicit((Object)(object)EntityStateMachine.FindByCustomName(replacementPrefab.gameObject, activationStateMachineName))) { EntityStateMachine stateMachine = replacementPrefab.gameObject.AddComponent(); stateMachine.customName = activationStateMachineName; stateMachine.initialStateType = new SerializableEntityStateType(typeof(Idle)); stateMachine.mainStateType = new SerializableEntityStateType(typeof(Idle)); MiscUtils.AppendDelegate(ref undoCallback, delegate { Object.Destroy((Object)(object)stateMachine); }); } } } } public static class ItemDescriptionNameReplacementManager { private class Entry { public readonly string ItemPickupToken; public readonly BodyIndex SearchIndex; public readonly string SearchToken; public readonly BoolConfigValue IsEnabledConfigValue; private LanguageOverlay[] _currentOverlays; public Entry(string itemPickupToken, BodyIndex searchIndex, BoolConfigValue isEnabledConfigValue) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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) ItemPickupToken = itemPickupToken; SearchIndex = searchIndex; CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(searchIndex); if (Object.op_Implicit((Object)(object)bodyPrefabBodyComponent)) { SearchToken = bodyPrefabBodyComponent.baseNameToken; } else { Log.Warning($"null body prefab for search index {searchIndex}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\ExplicitSpawn\\ItemDescriptionNameReplacements.cs", ".ctor", 32); SearchToken = "UNKNOWN"; } IsEnabledConfigValue = isEnabledConfigValue; } public void ApplyOverlays() { //IL_0017: 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) if ((IsEnabledConfigValue != null && !IsEnabledConfigValue) || !ExplicitSpawnRandomizerController.TryGetReplacementBodyIndex(SearchIndex, out var replacement)) { return; } CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(replacement); if (Object.op_Implicit((Object)(object)bodyPrefabBodyComponent)) { string baseNameToken = bodyPrefabBodyComponent.baseNameToken; Language[] array = Language.GetAllLanguages().ToArray(); _currentOverlays = (LanguageOverlay[])(object)new LanguageOverlay[array.Length]; for (int i = 0; i < array.Length; i++) { string name = array[i].name; string text = Language.GetString(ItemPickupToken); text = text.Replace(Language.GetString(SearchToken), Language.GetString(baseNameToken)); _currentOverlays[i] = LanguageAPI.AddOverlay(ItemPickupToken, text, name); } } } public void UndoOverlays() { if (_currentOverlays == null) { return; } LanguageOverlay[] currentOverlays = _currentOverlays; foreach (LanguageOverlay obj in currentOverlays) { if (obj != null) { obj.Remove(); } } _currentOverlays = null; } } private static readonly List _entries = new List(); [SystemInitializer(new Type[] { })] private static void Init() { FullExplicitSpawnInitListener.OnFullInit += FullExplicitSpawnInitListener_OnFullInit; Run.onRunDestroyGlobal += Run_onRunDestroyGlobal; } private static void FullExplicitSpawnInitListener_OnFullInit() { foreach (Entry entry in _entries) { entry?.ApplyOverlays(); } } private static void Run_onRunDestroyGlobal(Run obj) { foreach (Entry entry in _entries) { entry?.UndoOverlays(); } } public static void AddEntry(string itemPickupToken, BodyIndex searchIndex, BoolConfigValue isEnabledConfigValue) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _entries.Add(new Entry(itemPickupToken, searchIndex, isEnabledConfigValue)); } } } namespace RoR2Randomizer.RandomizerControllers.Effect { [RandomizerController] public sealed class EffectRandomizerController : BaseRandomizerController { private static EffectRandomizerController _instance; private static readonly RunSpecific _hasRecievedEffectReplacementsFromServer = new RunSpecific(0, defaultValue: false); private static readonly RunSpecific _effectReplacements = new RunSpecific(delegate(out IndexReplacementsCollection result) { if (NetworkServer.active && (bool)ConfigManager.Misc.EffectRandomizerEnabled) { result = new IndexReplacementsCollection(ReplacementDictionary.CreateFrom(Enumerable.Range(0, EffectCatalog.effectCount), Instance.RNG), EffectCatalog.effectCount); return true; } result = default(IndexReplacementsCollection); return false; }); public static EffectRandomizerController Instance => _instance; private static bool shouldBeEnabled { get { if ((NetworkServer.active && (bool)ConfigManager.Misc.EffectRandomizerEnabled) || (NetworkClient.active && (bool)_hasRecievedEffectReplacementsFromServer)) { return _effectReplacements.HasValue; } return false; } } public override bool IsRandomizerEnabled => shouldBeEnabled; protected override bool isNetworked => true; protected override IEnumerable getNetMessages() { yield return new SyncEffectReplacements((IndexReplacementsCollection)_effectReplacements); } private void setEffectReplacementsFromServerEvent(in IndexReplacementsCollection replacements) { if (!NetworkServer.active && NetworkClient.active) { _effectReplacements.Value = replacements; _hasRecievedEffectReplacementsFromServer.Value = _effectReplacements.HasValue; } } protected override void Awake() { base.Awake(); SyncEffectReplacements.OnReceive += setEffectReplacementsFromServerEvent; SingletonHelper.Assign(ref _instance, this); } protected override void OnDestroy() { base.OnDestroy(); _hasRecievedEffectReplacementsFromServer.Dispose(); _effectReplacements.Dispose(); SyncEffectReplacements.OnReceive -= setEffectReplacementsFromServerEvent; SingletonHelper.Unassign(ref _instance, this); } public static void TryReplaceEffectIndex(ref EffectIndex index) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected I4, but got Unknown if (shouldBeEnabled && IndexReplacementsCollectionExtensions.TryGetReplacement(in ILSpyHelper_AsRefReadOnly(_effectReplacements.Value), in index, out EffectIndex replacement)) { index = (EffectIndex)(int)replacement; } static ref readonly T ILSpyHelper_AsRefReadOnly(in T temp) { //ILSpy generated this function to help ensure overload resolution can pick the overload using 'in' return ref temp; } } } } namespace RoR2Randomizer.RandomizerControllers.Buff { public sealed class BuffRandomizerConfig : BaseRandomizerConfig { public BoolConfigValue MixBuffsAndDebuffs; private readonly SliderConfigValue _swapBuffDebuffWeightMult; public BoolConfigValue ExcludeInvincibility; public BoolConfigValue ExcludeEliteBuffs; private readonly ParsedBuffIndexListConfigValue _buffBlacklist; public float SwapBuffDebuffWeightMult => Mathf.Max(0f, (float)_swapBuffDebuffWeightMult); public bool IsBlacklisted(BuffIndex buffIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _buffBlacklist.BinarySearch(buffIndex) >= 0; } public BuffRandomizerConfig(ConfigFile file) : base("Status Effect", file) { MixBuffsAndDebuffs = new BoolConfigValue(getEntry("Mix buffs and debuffs", "If the randomizer should be able to turn a buff (positive effect) into a debuff (negative effect) and vice versa.", defaultValue: true)); _swapBuffDebuffWeightMult = new SliderConfigValue(getEntry("Buff-Debuff Weight Multiplier", "The weight multiplier to apply to buffs randomizing into debuffs and vice verse.\n\nThe lower the value, the less likely a buff will be to get randomized into a debuff, and vice versa.", 0.6f), SliderType.StepSlider, 0f, 1f, "F2", 0.05f); ExcludeInvincibility = new BoolConfigValue(getEntry("Blacklist Invincibility Effects", "Disables randomization (both from and to) of status effects that make the user invincible. Turning this off can potentially softlock a run due to a boss becoming invincible.", defaultValue: true)); ExcludeEliteBuffs = new BoolConfigValue(getEntry("Blacklist Elite aspects", "Disables randomization (both from and to) of status effects that are associated with an elite aspect", defaultValue: false)); _buffBlacklist = new ParsedBuffIndexListConfigValue(getEntry("Status Effect Blacklist", "Comma separated list of status effects to exclude from the randomizer\n\nList of status effects: https://riskofrain2.fandom.com/wiki/Status_Effects (use the \"Internal Name\" of the effect for this value)\n\nExample value: \"ElementalRingVoidReady,BearVoidCooldown\" will make the randomizer not change Singularity Band Ready and Safer Spaces cooldown", string.Empty)); } } [RandomizerController] public class BuffRandomizerController : BaseRandomizerController { private static BuffRandomizerController _instance; private static BuffDef[] _validBuffDefs; private static BuffIndex[] _invincibilityBuffs; private static BuffIndex[] _eliteBuffsOrdered; private static Dictionary _buffToDotIndex; private static readonly RunSpecific _buffReplacements = new RunSpecific(delegate(out IndexReplacementsCollection result) { if (shouldBeActive && Object.op_Implicit((Object)(object)Instance)) { ReplacementDictionary input = ReplacementDictionary.CreateFrom(_validBuffDefs.Where(delegate(BuffDef b) { //IL_0006: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (ConfigManager.BuffRandomizer.IsBlacklisted(b.buffIndex)) { return false; } if ((bool)ConfigManager.BuffRandomizer.ExcludeInvincibility && Array.BinarySearch(_invincibilityBuffs, b.buffIndex) >= 0) { return false; } return (!ConfigManager.BuffRandomizer.ExcludeEliteBuffs || Array.BinarySearch(_eliteBuffsOrdered, b.buffIndex) < 0) ? true : false; }), Instance.RNG, (BuffDef b) => b.buffIndex, (BuffDef key, BuffDef value) => (((bool)ConfigManager.BuffRandomizer.MixBuffsAndDebuffs && ConfigManager.BuffRandomizer.SwapBuffDebuffWeightMult != 0f) || key.isDebuff == value.isDebuff) ? true : false, delegate(BuffDef key, BuffDef value) { float num = 1f; if (key.isDebuff != value.isDebuff) { num *= ConfigManager.BuffRandomizer.SwapBuffDebuffWeightMult; } return num; }); result = IndexReplacementsCollection.Create(input, BuffCatalog.buffCount); return true; } result = default(IndexReplacementsCollection); return false; }); public static BuffRandomizerController Instance => _instance; private static bool shouldBeActive { get { if (NetworkServer.active) { return ConfigManager.BuffRandomizer.Enabled; } return false; } } public override bool IsRandomizerEnabled { get { if (shouldBeActive) { return _buffReplacements.HasValue; } return false; } } protected override bool isNetworked => false; public static bool IsActive { get { if (Object.op_Implicit((Object)(object)_instance)) { return _instance.IsRandomizerEnabled; } return false; } } [SystemInitializer(new Type[] { typeof(BuffCatalog), typeof(DotController) })] private static void Init() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected I4, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected I4, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected I4, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected I4, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected I4, but got Unknown //IL_00ab: 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_00b6: 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) _invincibilityBuffs = ((IEnumerable)(object)new BuffIndex[6] { (BuffIndex)(int)BuffCatalog.FindBuffIndex("bdBodyArmor"), (BuffIndex)(int)BuffCatalog.FindBuffIndex("bdGoldEmpowered"), (BuffIndex)(int)BuffCatalog.FindBuffIndex("bdHiddenInvincibility"), (BuffIndex)(int)BuffCatalog.FindBuffIndex("bdImmune"), (BuffIndex)(int)BuffCatalog.FindBuffIndex("bdIntangible"), (BuffIndex)(int)BuffCatalog.FindBuffIndex("bdBearVoidReady") }).OrderBy((BuffIndex i) => i).ToArray(); _buffToDotIndex = new Dictionary(); for (int num = 0; num < DotController.dotDefs.Length; num++) { DotDef val = DotController.dotDefs[num]; if (val == null) { continue; } BuffDef associatedBuff = val.associatedBuff; if (Object.op_Implicit((Object)(object)associatedBuff)) { BuffIndex buffIndex = associatedBuff.buffIndex; if (!_buffToDotIndex.ContainsKey(buffIndex)) { _buffToDotIndex.Add(buffIndex, (DotIndex)num); } } } _validBuffDefs = BuffCatalog.buffDefs.Where((BuffDef b) => Object.op_Implicit((Object)(object)b) && (int)b.buffIndex != -1 && !b.isHidden).ToArray(); _eliteBuffsOrdered = (from i in BuffCatalog.eliteBuffIndices where _validBuffDefs.Any((BuffDef bd) => bd.buffIndex == i) orderby i select i).ToArray(); } protected override void Awake() { base.Awake(); SingletonHelper.Assign(ref _instance, this); } protected override void OnDestroy() { base.OnDestroy(); _buffReplacements.Dispose(); SingletonHelper.Unassign(ref _instance, this); } public static bool TryReplaceBuffIndex(ref BuffIndex index) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected I4, but got Unknown if (TryGetReplacementBuffIndex(index, out var replacement)) { index = (BuffIndex)(int)replacement; return true; } return false; } public static bool TryGetReplacementBuffIndex(BuffIndex original, out BuffIndex replacement) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)original != -1 && IsActive && IndexReplacementsCollectionExtensions.TryGetReplacement(in ILSpyHelper_AsRefReadOnly(_buffReplacements.Value), in original, out replacement)) { return (int)replacement != -1; } replacement = (BuffIndex)(-1); return false; static ref readonly T ILSpyHelper_AsRefReadOnly(in T temp) { //ILSpy generated this function to help ensure overload resolution can pick the overload using 'in' return ref temp; } } public static bool TryReplaceBuffIndex(ref int index) { //IL_0002: 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_000d: Expected I4, but got Unknown BuffIndex index2 = (BuffIndex)index; bool result = TryReplaceBuffIndex(ref index2); index = (int)index2; return result; } public static bool TryGetDotIndex(BuffIndex buff, out DotIndex dot) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return _buffToDotIndex.TryGetValue(buff, out dot); } public static bool TryGetBuffIndex(DotIndex dot, out BuffIndex buff) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected I4, but got Unknown DotDef dotDef = DotController.GetDotDef(dot); if (dotDef != null) { BuffDef associatedBuff = dotDef.associatedBuff; if (Object.op_Implicit((Object)(object)associatedBuff)) { buff = (BuffIndex)(int)associatedBuff.buffIndex; return true; } } buff = (BuffIndex)(-1); return false; } } } namespace RoR2Randomizer.RandomizerControllers.Boss { public class BossRandomizerConfig : BaseRandomizerConfig { public readonly BoolConfigValue RandomizeMithrix; public readonly BoolConfigValue RandomizeMithrixPhase2; public readonly BoolConfigValue RandomizeVoidling; public readonly BoolConfigValue RandomizeFalseSon; public readonly BoolConfigValue RandomizeAurelionite; public readonly BoolConfigValue RandomizeLunarScav; public readonly BoolConfigValue RandomizeAlloyWorshipUnit; public readonly BoolConfigValue RandomizeTeleporterBosses; public bool AnyMithrixRandomizerEnabled { get { if ((bool)Enabled) { if (!RandomizeMithrix) { return RandomizeMithrixPhase2; } return true; } return false; } } public BossRandomizerConfig(ConfigFile file) : base("Boss", file) { RandomizeMithrix = new BoolConfigValue(getEntry("Randomize Mithrix", "Randomizes the character type of Mithrix", defaultValue: true)); RandomizeMithrixPhase2 = new BoolConfigValue(getEntry("Randomize Mithrix Phase 2", "Randomizes the character type of all the characters spawned during Mithrix phase 2", defaultValue: true)); RandomizeVoidling = new BoolConfigValue(getEntry("Randomize Voidling", "Randomizes the character type of Voidling", defaultValue: true)); RandomizeFalseSon = new BoolConfigValue(getEntry("Randomize False Son", "Randomizes the character type of False Son", defaultValue: true)); RandomizeAurelionite = new BoolConfigValue(getEntry("Randomize Aurelionite", "Randomizes the character type of Aurelionite", defaultValue: true)); RandomizeLunarScav = new BoolConfigValue(getEntry("Randomize Twisted Scavengers", "Randomizes the character type of Twisted Scavengers", defaultValue: true)); RandomizeAlloyWorshipUnit = new BoolConfigValue(getEntry("Randomize Alloy Worship Unit", "Randomizes the character type of Alloy Worship Unit on Siren's Call", defaultValue: true)); RandomizeTeleporterBosses = new BoolConfigValue(getEntry("Randomize Teleporter Bosses", "Randomizes the character types of teleporter bosses", defaultValue: true)); } } [RandomizerController] public class BossRandomizerController : BaseRandomizerController { public static class AlloyWorshipUnit { private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeAlloyWorshipUnit) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { if ((Object)(object)card == (Object)(object)SpawnCardTracker.AlloyWorshipUnitSpawnCard) { GameObject originalPrefab = card.prefab; resetCardFunc = delegate(ref SpawnCard c) { c.prefab = originalPrefab; }; CharacterReplacements.TryReplaceMasterPrefab(ref card.prefab); } else { resetCardFunc = null; } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedAWUCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedAWUCharacterServer; } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType == BossReplacementType.AlloyWorshipUnit) { handleSpawnedAWUCharacterClient(masterObject); } } private static void handleSpawnedAWUCharacterClient(GameObject masterObject) { masterObject.AddComponent().Initialize(); } private static void handleSpawnedAWUCharacterServer(SpawnResult spawnResult) { //IL_001f: 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) if (IsEnabled && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight && (Object)(object)spawnResult.spawnRequest.spawnCard == (Object)(object)SpawnCardTracker.AlloyWorshipUnitSpawnCard) { spawnResult.spawnedInstance.AddComponent().Initialize(); } } } public static class Aurelionite { private const string MASTER_NAME = "TitanGoldMaster"; private static readonly RunSpecific _aurelioniteMasterReplacementPrefab = new RunSpecific(delegate(out GameObject overridePrefab) { if (IsEnabled) { overridePrefab = CharacterReplacements.GetReplacementMasterPrefab("TitanGoldMaster"); CharacterMaster val = default(CharacterMaster); CharacterBody val2 = default(CharacterBody); if (Object.op_Implicit((Object)(object)overridePrefab) && overridePrefab.TryGetComponent(ref val) && Object.op_Implicit((Object)(object)val.bodyPrefab) && val.bodyPrefab.TryGetComponent(ref val2)) { replaceAurelioniteInItemPickupText(Items.TitanGoldDuringTP, val2.GetDisplayName()); return true; } } overridePrefab = null; return false; }); private static LanguageOverlay _aurelionitePickupOverlay; private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeAurelionite) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static event Action AurelioniteReplacementReceivedClient; private static void replaceAurelioniteInItemPickupText(ItemDef item, string replacementName) { LanguageOverlay aurelionitePickupOverlay = _aurelionitePickupOverlay; if (aurelionitePickupOverlay != null) { aurelionitePickupOverlay.Remove(); } string pickupToken = item.pickupToken; string text = Language.GetString(pickupToken); string oldValue = Language.GetString("TITANGOLD_BODY_NAME"); _aurelionitePickupOverlay = LanguageAPI.AddOverlay(pickupToken, text.Replace(oldValue, replacementName)); } public static bool TryGetAurelioniteMasterReplacementPrefab(out GameObject replacementPrefab) { if (IsEnabled) { replacementPrefab = _aurelioniteMasterReplacementPrefab; return Object.op_Implicit((Object)(object)replacementPrefab); } replacementPrefab = null; return false; } public static bool TryGetAurelioniteMasterReplacementBodyIndex(out BodyIndex replacementIndex) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected I4, but got Unknown CharacterMaster val = default(CharacterMaster); CharacterBody val2 = default(CharacterBody); if (TryGetAurelioniteMasterReplacementPrefab(out var replacementPrefab) && replacementPrefab.TryGetComponent(ref val) && Object.op_Implicit((Object)(object)val.bodyPrefab) && val.bodyPrefab.TryGetComponent(ref val2)) { replacementIndex = (BodyIndex)(int)val2.bodyIndex; return true; } replacementIndex = (BodyIndex)(-1); return false; } public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; Run.onRunDestroyGlobal += runEnd; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; Run.onRunDestroyGlobal -= runEnd; _aurelioniteMasterReplacementPrefab.Dispose(); } private static void runEnd(Run instance) { LanguageOverlay aurelionitePickupOverlay = _aurelionitePickupOverlay; if (aurelionitePickupOverlay != null) { aurelionitePickupOverlay.Remove(); } _aurelionitePickupOverlay = null; } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { if ((Object)(object)card == (Object)(object)SpawnCardTracker.AurelioniteSpawnCard && TryGetAurelioniteMasterReplacementPrefab(out var replacementPrefab)) { GameObject originalPrefab = card.prefab; resetCardFunc = delegate(ref SpawnCard c) { c.prefab = originalPrefab; }; card.prefab = replacementPrefab; } else { resetCardFunc = null; } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedAurelioniteCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedAurelioniteCharacterServer; } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType == BossReplacementType.Aurelionite) { handleSpawnedAurelioniteCharacterClient(masterObject); } } private static void handleSpawnedAurelioniteCharacterClient(GameObject masterObject) { AurelioniteReplacement aurelioniteReplacement = masterObject.AddComponent(); aurelioniteReplacement.Initialize(); Aurelionite.AurelioniteReplacementReceivedClient?.Invoke(aurelioniteReplacement); } private static void handleSpawnedAurelioniteCharacterServer(SpawnResult spawnResult) { //IL_001f: 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) if (IsEnabled && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight && (Object)(object)spawnResult.spawnRequest.spawnCard == (Object)(object)SpawnCardTracker.AurelioniteSpawnCard) { spawnResult.spawnedInstance.AddComponent().Initialize(); } } } public static class FalseSon { private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeFalseSon) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { Log.Info("We are in da fight!!!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\Controllers\\FalseSon.cs", "IsInFight_OnChanged", 48); GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { Log.Info("HAHA Override this ass " + ((Object)card).name, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\Controllers\\FalseSon.cs", "IsInFight_OnChanged", 51); if (SpawnCardTracker.IsAnyFalseSonPhase(card)) { GameObject originalPrefab = card.prefab; resetCardFunc = delegate(ref SpawnCard c) { c.prefab = originalPrefab; }; CharacterReplacements.TryReplaceMasterPrefab(ref card.prefab); } else { resetCardFunc = null; } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedFalseSonCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedFalseSonCharacterServer; } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType - 14 <= BossReplacementType.MithrixHurt) { handleSpawnedFalseSonCharacterClient(masterObject, (uint)(replacementType - 14 + 1)); } } private static void handleSpawnedFalseSonCharacterClient(GameObject masterObject, uint phase) { FalseSonReplacement falseSonReplacement = masterObject.AddComponent(); falseSonReplacement.Phase = phase; falseSonReplacement.Initialize(); } private static void handleSpawnedFalseSonCharacterServer(SpawnResult spawnResult) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight) { FalseSonReplacement falseSonReplacement = spawnResult.spawnedInstance.AddComponent(); falseSonReplacement.Phase = BossTracker.Instance.Phase; falseSonReplacement.Initialize(); } } } public static class HoldoutBoss { private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeTeleporterBosses) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static void Initialize() { SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; } public static void Uninitialize() { SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (replacementType == BossReplacementType.TeleporterBoss) { handleSpawnedTeleporterBossReplacement(masterObject, originalMasterIndex.GetValueOrDefault(MasterIndex.none)); } } public static void TryReplaceDirectorSpawnRequest(DirectorSpawnRequest spawnRequest) { if (IsEnabled) { CharacterReplacements.TryReplaceDirectorSpawnRequest(spawnRequest, handleSpawnedTeleporterBossReplacement); } } private static void handleSpawnedTeleporterBossReplacement(GameObject masterObject, MasterIndex originalMasterIndex) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)masterObject)) { TeleporterBossReplacement teleporterBossReplacement = masterObject.AddComponent(); teleporterBossReplacement.SetOriginalMasterIndex(originalMasterIndex); teleporterBossReplacement.Initialize(); } } } public static class LunarScav { private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeLunarScav) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static event Action LunarScavReplacementReceivedClient; public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { resetCardFunc = null; if ((Object)(object)SpawnCardTracker.LunarScavSpawnCard == (Object)(object)card) { SpawnCard obj = card; MultiCharacterSpawnCard val = (MultiCharacterSpawnCard)(object)((obj is MultiCharacterSpawnCard) ? obj : null); if (val != null) { GameObject[] originalMasterPrefabs = (GameObject[])(object)new GameObject[val.masterPrefabs.Length]; resetCardFunc = delegate(ref SpawnCard c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown MultiCharacterSpawnCard val2 = (MultiCharacterSpawnCard)c; if (originalMasterPrefabs.Length != val2.masterPrefabs.Length) { Log.Warning("original master prefabs and card prefabs have different sizes", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\Controllers\\LunarScav.cs", "IsInFight_OnChanged", 63); } else { Array.Copy(originalMasterPrefabs, val2.masterPrefabs, originalMasterPrefabs.Length); } }; for (int num = 0; num < val.masterPrefabs.Length; num++) { originalMasterPrefabs[num] = val.masterPrefabs[num]; CharacterReplacements.TryReplaceMasterPrefab(ref val.masterPrefabs[num]); } } else { Log.Warning("SpawnCard is not a MultiCharacterSpawnCard", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\Controllers\\LunarScav.cs", "IsInFight_OnChanged", 78); } } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedLunarScavCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedLunarScavCharacterServer; } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType - 8 <= BossReplacementType.MithrixPhase2) { handleSpawnedLunarScavCharacterClient(masterObject, (uint)(replacementType - 8)); } } private static void handleSpawnedLunarScavCharacterClient(GameObject masterObject, uint scavIndex) { LunarScavReplacement lunarScavReplacement = masterObject.AddComponent(); lunarScavReplacement.LunarScavIndex = scavIndex; lunarScavReplacement.Initialize(); LunarScav.LunarScavReplacementReceivedClient?.Invoke(lunarScavReplacement); } private static void handleSpawnedLunarScavCharacterServer(SpawnResult spawnResult) { //IL_0024: 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) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight && (Object)(object)SpawnCardTracker.LunarScavSpawnCard == (Object)(object)spawnResult.spawnRequest.spawnCard) { LunarScavReplacement lunarScavReplacement = spawnResult.spawnedInstance.AddComponent(); int num = Array.IndexOf(SpawnCardTracker.LunarScavSpawnCard.masterPrefabs, spawnResult.spawnRequest.spawnCard.prefab); if (num != -1) { lunarScavReplacement.LunarScavIndex = (uint)num; } lunarScavReplacement.Initialize(); } } } public static class Mithrix { public static readonly SerializableEntityStateType MithrixHurtInitialState = new SerializableEntityStateType(typeof(SpellChannelEnterState)); public static readonly InitializeOnAccess MithrixReturnItemsComponent = new InitializeOnAccess((Func)(() => Caches.MasterPrefabs["BrotherHurtMaster"].bodyPrefab.GetComponent())); public static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.AnyMithrixRandomizerEnabled) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; MithrixPhaseTracker.OnFightVictory += MithrixPhaseTracker_OnFightVictory; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; MithrixPhaseTracker.OnFightVictory -= MithrixPhaseTracker_OnFightVictory; } private static void MithrixPhaseTracker_OnFightVictory(GameObject missionController) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)missionController) && (int)Caches.Scene.OldCommencementSceneIndex != -1 && Object.op_Implicit((Object)(object)SceneCatalog.mostRecentSceneDef) && SceneCatalog.mostRecentSceneDef.sceneDefIndex == Caches.Scene.OldCommencementSceneIndex) { Transform val = missionController.transform.Find("ArenaWalls"); if (Object.op_Implicit((Object)(object)val)) { ((MonoBehaviour)Main.Instance).StartCoroutine(waitThenDisableArenaWalls(((Component)val).gameObject)); } } static IEnumerator waitThenDisableArenaWalls(GameObject arenaWallsObj) { yield return (object)new WaitForSeconds(10f); if (Object.op_Implicit((Object)(object)arenaWallsObj)) { arenaWallsObj.SetActive(false); } } } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { resetCardFunc = null; if ((((bool)ConfigManager.BossRandomizer.RandomizeMithrix || CharacterReplacements.IsAnyForcedCharacterModeEnabled) && ((Object)(object)card == (Object)(object)SpawnCardTracker.MithrixNormalSpawnCard || (Object)(object)card == (Object)(object)SpawnCardTracker.MithrixHurtSpawnCard)) || (((bool)ConfigManager.BossRandomizer.RandomizeMithrixPhase2 || CharacterReplacements.IsAnyForcedCharacterModeEnabled) && SpawnCardTracker.IsPartOfMithrixPhase2(card))) { GameObject originalPrefab = card.prefab; resetCardFunc = delegate(ref SpawnCard c) { c.prefab = originalPrefab; }; CharacterReplacements.TryReplaceMasterPrefab(ref card.prefab); } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedMithrixCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedMithrixCharacterServer; } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType - 1 <= BossReplacementType.MithrixHurt) { handleSpawnedMithrixCharacterClient(masterObject, replacementType, originalMasterIndex); } } private static void handleSpawnedMithrixCharacterClient(GameObject masterObject, BossReplacementType type, MasterIndex? originalMasterIndex) { //IL_000e: 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) BaseMithrixReplacement baseMithrixReplacement; if (type == BossReplacementType.MithrixPhase2) { baseMithrixReplacement = masterObject.AddComponent(); baseMithrixReplacement.SetOriginalMasterIndex(originalMasterIndex.GetValueOrDefault(MasterIndex.none)); } else { bool isHurt; if (!(isHurt = type == BossReplacementType.MithrixHurt) && type != BossReplacementType.MithrixNormal) { Log.Warning($"Invalid mithrix replacement type '{type}'", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\Controllers\\Mithrix.cs", "handleSpawnedMithrixCharacterClient", 150); return; } ((MainMithrixReplacement)(baseMithrixReplacement = masterObject.AddComponent())).IsHurt = isHurt; } baseMithrixReplacement.Initialize(); } private static void handleSpawnedMithrixCharacterServer(SpawnResult spawnResult) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled || BossTracker.Instance == null || !BossTracker.Instance.IsInFight) { return; } BaseMithrixReplacement baseMithrixReplacement = null; bool isHurt; if ((uint)BossTracker.Instance.Phase == 2) { if (((bool)ConfigManager.BossRandomizer.RandomizeMithrixPhase2 || CharacterReplacements.IsAnyForcedCharacterModeEnabled) && SpawnCardTracker.IsPartOfMithrixPhase2(spawnResult.spawnRequest.spawnCard)) { baseMithrixReplacement = spawnResult.spawnedInstance.AddComponent(); } } else if (((bool)ConfigManager.BossRandomizer.RandomizeMithrix || CharacterReplacements.IsAnyForcedCharacterModeEnabled) && ((isHurt = (Object)(object)spawnResult.spawnRequest.spawnCard == (Object)(object)SpawnCardTracker.MithrixHurtSpawnCard) || (Object)(object)spawnResult.spawnRequest.spawnCard == (Object)(object)SpawnCardTracker.MithrixNormalSpawnCard)) { MainMithrixReplacement mainMithrixReplacement = spawnResult.spawnedInstance.AddComponent(); mainMithrixReplacement.IsHurt = isHurt; baseMithrixReplacement = mainMithrixReplacement; } if (Object.op_Implicit((Object)(object)baseMithrixReplacement)) { baseMithrixReplacement.Initialize(); } } public static bool IsReplacedMithrix(GameObject master) { if (Object.op_Implicit((Object)(object)master)) { return Object.op_Implicit((Object)(object)master.GetComponent()); } return false; } public static bool IsReplacedMithrixPhase2Spawn(GameObject master) { if (Object.op_Implicit((Object)(object)master)) { return Object.op_Implicit((Object)(object)master.GetComponent()); } return false; } public static bool IsReplacedPartOfMithrixFight(GameObject master) { if (Object.op_Implicit((Object)(object)master)) { return Object.op_Implicit((Object)(object)master.GetComponent()); } return false; } } public static class SolusWing { private const string MASTER_NAME = "SolusWingMaster"; private static readonly RunSpecific _solusWingMasterReplacementPrefab = new RunSpecific(delegate(out GameObject overridePrefab) { if (IsEnabled) { overridePrefab = CharacterReplacements.GetReplacementMasterPrefab("SolusWingMaster"); if (Object.op_Implicit((Object)(object)overridePrefab)) { return true; } } overridePrefab = null; return false; }); private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeFalseSon) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static bool TryGetSolusWingMasterReplacementPrefab(out GameObject replacementPrefab) { if (IsEnabled) { replacementPrefab = _solusWingMasterReplacementPrefab; return Object.op_Implicit((Object)(object)replacementPrefab); } replacementPrefab = null; return false; } public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; _solusWingMasterReplacementPrefab.Dispose(); } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { if ((Object)(object)card == (Object)(object)SpawnCardTracker.SolusWingSpawnCard && TryGetSolusWingMasterReplacementPrefab(out var replacementPrefab)) { GameObject originalPrefab = card.prefab; resetCardFunc = delegate(ref SpawnCard c) { c.prefab = originalPrefab; }; card.prefab = replacementPrefab; } else { resetCardFunc = null; } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedSolusWingCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedSolusWingCharacterServer; } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType == BossReplacementType.SolusWing) { handleSpawnedSolusWingCharacterClient(masterObject); } } private static void handleSpawnedSolusWingCharacterClient(GameObject masterObject) { masterObject.AddComponent().Initialize(); } private static void handleSpawnedSolusWingCharacterServer(SpawnResult spawnResult) { //IL_001f: 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) if (IsEnabled && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight && (Object)(object)spawnResult.spawnRequest.spawnCard == (Object)(object)SpawnCardTracker.SolusWingSpawnCard) { spawnResult.spawnedInstance.AddComponent().Initialize(); } } } public static class Voidling { public static readonly SerializableEntityStateType EscapeDeathState = new SerializableEntityStateType(typeof(EscapeDeath)); public static readonly SerializableEntityStateType FinalDeathState = new SerializableEntityStateType(typeof(DeathState)); public static readonly InitializeOnAccess FinalDeathStateAnimationDuration = new InitializeOnAccess((Func)delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) SerializableEntityStateType finalDeathState = FinalDeathState; Type deathStateType = ((SerializableEntityStateType)(ref finalDeathState)).stateType; SerializedField val = ContentManager.entityStateConfigurations.Single((EntityStateConfiguration c) => (Type)c.targetType == deathStateType).serializedFieldsCollection.serializedFields.Single((SerializedField f) => f.fieldName.Equals("duration")); return (float)((SerializedValue)(ref val.fieldValue)).GetValue(AccessTools.DeclaredField(typeof(DeathState), "duration")); }); private static bool IsEnabled { get { if (Object.op_Implicit((Object)(object)_instance) && _instance.IsRandomizerEnabled) { if (!ConfigManager.BossRandomizer.RandomizeVoidling) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } public static void Initialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged += IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive += SyncBossReplacementCharacter_OnReceive; SceneCatalog.onMostRecentSceneDefChanged += SceneCatalog_onMostRecentSceneDefChanged; } public static void Uninitialize() { if (BossTracker.Instance != null) { BossTracker.Instance.IsInFight.OnChanged -= IsInFight_OnChanged; } SyncBossReplacementCharacter.OnReceive -= SyncBossReplacementCharacter_OnReceive; SceneCatalog.onMostRecentSceneDefChanged -= SceneCatalog_onMostRecentSceneDefChanged; } private static void IsInFight_OnChanged(bool isInFight) { if (!IsEnabled) { return; } if (isInFight) { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = delegate(ref SpawnCard card, out GenericScriptedSpawnHook.ResetCardDelegate resetCardFunc) { if (SpawnCardTracker.IsAnyVoidlingPhase(card)) { GameObject originalPrefab = card.prefab; resetCardFunc = delegate(ref SpawnCard c) { c.prefab = originalPrefab; }; CharacterReplacements.TryReplaceMasterPrefab(ref card.prefab); } else { resetCardFunc = null; } }; GenericScriptedSpawnHook.OnSpawned += handleSpawnedVoidlingCharacterServer; } else { GenericScriptedSpawnHook.OverrideSpawnPrefabFunc = null; GenericScriptedSpawnHook.OnSpawned -= handleSpawnedVoidlingCharacterServer; } } private static void SceneCatalog_onMostRecentSceneDefChanged(SceneDef newScene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!IsEnabled || (int)Caches.Scene.VoidlingFightSceneIndex == -1 || newScene.sceneDefIndex != Caches.Scene.VoidlingFightSceneIndex) { return; } GameObject val = GameObject.Find("RaidVoid"); if (Object.op_Implicit((Object)(object)val)) { Transform val2 = val.transform.Find("RaidVoidProps/CrabFoam1Prop (14)"); if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.SetActive(false); } } } private static void SyncBossReplacementCharacter_OnReceive(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) { if (replacementType - 4 <= BossReplacementType.MithrixHurt) { handleSpawnedVoidlingCharacterClient(masterObject, (uint)(replacementType - 4 + 1)); } } private static void handleSpawnedVoidlingCharacterClient(GameObject masterObject, uint phase) { VoidlingReplacement voidlingReplacement = masterObject.AddComponent(); voidlingReplacement.Phase = phase; voidlingReplacement.Initialize(); } private static void handleSpawnedVoidlingCharacterServer(SpawnResult spawnResult) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight) { VoidlingReplacement voidlingReplacement = spawnResult.spawnedInstance.AddComponent(); voidlingReplacement.Phase = BossTracker.Instance.Phase; voidlingReplacement.Initialize(); } } } private static BossRandomizerController _instance; public override bool IsRandomizerEnabled { get { if (NetworkServer.active) { if (!ConfigManager.BossRandomizer.Enabled) { return CharacterReplacements.IsAnyForcedCharacterModeEnabled; } return true; } return false; } } protected override bool isNetworked => false; public static bool IsReplacedBossCharacter(GameObject masterObject) { if (Object.op_Implicit((Object)(object)masterObject)) { return Object.op_Implicit((Object)(object)masterObject.GetComponent()); } return false; } protected override void Awake() { base.Awake(); SingletonHelper.Assign(ref _instance, this); Mithrix.Initialize(); FalseSon.Initialize(); SolusWing.Initialize(); Voidling.Initialize(); Aurelionite.Initialize(); LunarScav.Initialize(); AlloyWorshipUnit.Initialize(); HoldoutBoss.Initialize(); } protected override void OnDestroy() { base.OnDestroy(); Mithrix.Uninitialize(); FalseSon.Uninitialize(); Voidling.Uninitialize(); SolusWing.Uninitialize(); Aurelionite.Uninitialize(); LunarScav.Uninitialize(); AlloyWorshipUnit.Uninitialize(); HoldoutBoss.Uninitialize(); SingletonHelper.Unassign(ref _instance, this); } } } namespace RoR2Randomizer.RandomizerControllers.Boss.BossReplacementInfo { public sealed class AlloyWorshipUnitReplacement : BaseBossReplacement { protected override BossReplacementType replacementType => BossReplacementType.AlloyWorshipUnit; protected override CharacterMaster originalMasterPrefab => Caches.MasterPrefabs["SuperRoboBallBossMaster"]; } public sealed class AurelioniteReplacement : BaseBossReplacement { protected override BossReplacementType replacementType => BossReplacementType.Aurelionite; protected override CharacterMaster originalMasterPrefab => Caches.MasterPrefabs["TitanGoldMaster"]; protected override bool replaceBossDropEvenIfExisting => true; } public abstract class BaseBossReplacement : CharacterReplacementInfo { protected abstract BossReplacementType replacementType { get; } protected virtual bool replaceBossDropEvenIfExisting => false; protected override bool isNetworked => true; protected virtual bool sendOriginalCharacterMasterIndex => false; protected override SetSubtitleMode subtitleOverrideMode => SetSubtitleMode.OnlyIfExistingIsNull; protected override void bodyResolved() { base.bodyResolved(); CharacterBody val = base.originalBodyPrefab; if (!Object.op_Implicit((Object)(object)val)) { return; } DeathRewards val2 = default(DeathRewards); if (((Component)val).TryGetComponent(ref val2) && Object.op_Implicit((Object)(object)val2.bossDropTable)) { DeathRewards orAddComponent = ((Component)_body).gameObject.GetOrAddComponent(); if (!Object.op_Implicit((Object)(object)orAddComponent.bossDropTable) || (Object)(object)orAddComponent.bossDropTable == (Object)null || replaceBossDropEvenIfExisting) { orAddComponent.bossDropTable = val2.bossDropTable; } } HealthComponent healthComponent = _body.healthComponent; HealthComponent val3 = default(HealthComponent); if (Object.op_Implicit((Object)(object)healthComponent) && ((Component)val).TryGetComponent(ref val3)) { healthComponent.globalDeathEventChanceCoefficient = val3.globalDeathEventChanceCoefficient; } } protected override IEnumerable getNetMessages() { GameObject gameObject = ((Component)_master).gameObject; BossReplacementType num = replacementType; MasterIndex? originalMasterIndex; if (!sendOriginalCharacterMasterIndex) { originalMasterIndex = null; } else { CharacterMaster obj = originalMasterPrefab; originalMasterIndex = ((obj != null) ? new MasterIndex?(obj.masterIndex) : ((MasterIndex?)null)); } yield return new SyncBossReplacementCharacter(gameObject, num, originalMasterIndex); } } public abstract class BaseMithrixReplacement : BaseBossReplacement { protected override void bodyResolved() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) base.bodyResolved(); if (NetworkServer.active && (((int)Caches.Bodies.VoidlingBaseBodyIndex != -1 && _body.bodyIndex == Caches.Bodies.VoidlingBaseBodyIndex) || ((int)Caches.Bodies.VoidlingPhase1BodyIndex != -1 && _body.bodyIndex == Caches.Bodies.VoidlingPhase1BodyIndex) || ((int)Caches.Bodies.VoidlingPhase2BodyIndex != -1 && _body.bodyIndex == Caches.Bodies.VoidlingPhase2BodyIndex) || ((int)Caches.Bodies.VoidlingPhase3BodyIndex != -1 && _body.bodyIndex == Caches.Bodies.VoidlingPhase3BodyIndex))) { TeleportHelper.TeleportBody(_body, _body.transform.position + new Vector3(0f, 25f, 0f)); } } } public class FalseSonReplacement : BaseBossReplacement { private class FalseSonDialogueFormatOverlayHolder : IDisposable { private bool _disposed; public readonly FalseSonReplacement Owner; public readonly LanguageOverlay Overlay; public FalseSonDialogueFormatOverlayHolder(FalseSonReplacement owner, string replacementToken) { Owner = owner; Overlay = LanguageAPI.AddOverlay("FALSESONBOSS_DIALOGUE_FORMAT", Language.GetString("FALSESONBOSS_DIALOGUE_FORMAT").Replace(Language.GetString("FALSESONBOSS_BODY_NAME"), Language.GetString(replacementToken))); } public void Dispose() { if (!_disposed) { LanguageOverlay overlay = Overlay; if (overlay != null) { overlay.Remove(); } if (Object.op_Implicit((Object)(object)Owner)) { Owner._dialogueOverlayHolder = null; } _disposed = true; } } } private static FalseSonDialogueFormatOverlayHolder _mostRecentDialogueOverlayHolder; private FalseSonDialogueFormatOverlayHolder _dialogueOverlayHolder; public uint Phase; protected override BossReplacementType replacementType { get { if (Phase >= 1 && Phase <= 3) { return (BossReplacementType)(14 + Phase - 1); } return BossReplacementType.Invalid; } } protected override CharacterMaster originalMasterPrefab => (CharacterMaster)(Phase switch { 1u => Caches.MasterPrefabs["FalseSonBoss"], 2u => Caches.MasterPrefabs["FalseSonBossBodyLunarShard"], 3u => Caches.MasterPrefabs["FalseSonBossBodyBrokenLunarShard"], _ => Caches.MasterPrefabs["FalseSonBoss"], }); protected override void bodyResolved() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown base.bodyResolved(); if (Phase == 3) { _master.onBodyDeath.AddListener((UnityAction)delegate { //IL_001f: Unknown result type (might be due to invalid IL or missing references) EntityStateMachine component = ((Component)_body).GetComponent(); if ((Object)(object)component != (Object)null) { EntityState nextState = EntityStateCatalog.InstantiateState(EntityStateCatalog.GetStateIndex(typeof(SkyJumpDeathState))); component.SetNextState(nextState); } }); } _mostRecentDialogueOverlayHolder?.Dispose(); _mostRecentDialogueOverlayHolder = (_dialogueOverlayHolder = new FalseSonDialogueFormatOverlayHolder(this, _body.baseNameToken)); } private void OnDestroy() { _dialogueOverlayHolder?.Dispose(); _dialogueOverlayHolder = null; } } public sealed class LunarScavReplacement : BaseBossReplacement { public uint LunarScavIndex; protected override BossReplacementType replacementType => (BossReplacementType)(8 + LunarScavIndex); protected override CharacterMaster originalMasterPrefab => Caches.MasterPrefabs[$"ScavLunar{LunarScavIndex + 1}Master"]; } public sealed class MainMithrixReplacement : BaseMithrixReplacement { private class MithrixDialogueFormatOverlayHolder : IDisposable { private bool _disposed; public readonly MainMithrixReplacement Owner; public readonly LanguageOverlay Overlay; public MithrixDialogueFormatOverlayHolder(MainMithrixReplacement owner, string replacementToken) { Owner = owner; Overlay = LanguageAPI.AddOverlay("BROTHER_DIALOGUE_FORMAT", Language.GetString("BROTHER_DIALOGUE_FORMAT").Replace(Language.GetString("BROTHER_BODY_NAME"), Language.GetString(replacementToken))); } public void Dispose() { if (!_disposed) { LanguageOverlay overlay = Overlay; if (overlay != null) { overlay.Remove(); } if (Object.op_Implicit((Object)(object)Owner)) { Owner._dialogueOverlayHolder = null; } _disposed = true; } } } private static MithrixDialogueFormatOverlayHolder _mostRecentDialogueOverlayHolder; private MithrixDialogueFormatOverlayHolder _dialogueOverlayHolder; public bool IsHurt; protected override BossReplacementType replacementType { get { if (!IsHurt) { return BossReplacementType.MithrixNormal; } return BossReplacementType.MithrixHurt; } } protected override CharacterMaster originalMasterPrefab => (CharacterMaster)(replacementType switch { BossReplacementType.MithrixNormal => Caches.MasterPrefabs["BrotherMaster"], BossReplacementType.MithrixHurt => Caches.MasterPrefabs["BrotherHurtMaster"], _ => null, }); protected override void bodyResolved() { //IL_0078: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) base.bodyResolved(); if (NetworkServer.active && IsHurt) { _body.AddTimedBuff(Buffs.HiddenInvincibility, SpellChannelEnterState.duration); EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)_body).gameObject, "Body"); if (Object.op_Implicit((Object)(object)val)) { if (val.state != null) { val.SetState(EntityStateCatalog.InstantiateState(EntityStateCatalog.GetStateIndex(((object)BossRandomizerController.Mithrix.MithrixHurtInitialState).GetType()))); } else { val.initialStateType = BossRandomizerController.Mithrix.MithrixHurtInitialState; } } else { Log.Warning("Body entityState for " + _body.GetDisplayName() + " could not be found!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\BossReplacementInfo\\MainMithrixReplacement.cs", "bodyResolved", 87); } if (!Object.op_Implicit((Object)(object)((Component)_body).GetComponent())) { AddReturnStolenItemsOnGettingHit(((Component)_body).gameObject, _body.healthComponent); } } _mostRecentDialogueOverlayHolder?.Dispose(); _mostRecentDialogueOverlayHolder = (_dialogueOverlayHolder = new MithrixDialogueFormatOverlayHolder(this, _body.baseNameToken)); } private void OnDestroy() { _dialogueOverlayHolder?.Dispose(); _dialogueOverlayHolder = null; } public static ReturnStolenItemsOnGettingHit AddReturnStolenItemsOnGettingHit(GameObject bodyObj, HealthComponent healthComponent) { ReturnStolenItemsOnGettingHit val = bodyObj.AddComponent(); val.healthComponent = healthComponent; ReturnStolenItemsOnGettingHit get = BossRandomizerController.Mithrix.MithrixReturnItemsComponent.Get; val.minPercentagePerItem = get.minPercentagePerItem; val.maxPercentagePerItem = get.maxPercentagePerItem; val.initialPercentageToFirstItem = get.initialPercentageToFirstItem; val.Awake(); if (Object.op_Implicit((Object)(object)healthComponent)) { ref IOnTakeDamageServerReceiver[] onTakeDamageReceivers = ref healthComponent.onTakeDamageReceivers; IOnTakeDamageServerReceiver val2 = (IOnTakeDamageServerReceiver)(object)val; ArrayUtils.ArrayAppend(ref onTakeDamageReceivers, ref val2); } return val; } } public sealed class MithrixPhase2EnemiesReplacement : BaseMithrixReplacement { protected override BossReplacementType replacementType => BossReplacementType.MithrixPhase2; } public sealed class SolusWingReplacement : BaseBossReplacement { protected override BossReplacementType replacementType => BossReplacementType.SolusWing; protected override CharacterMaster originalMasterPrefab => Caches.MasterPrefabs["SolusWingMaster"]; } public sealed class TeleporterBossReplacement : BaseBossReplacement { protected override BossReplacementType replacementType => BossReplacementType.TeleporterBoss; protected override SetSubtitleMode subtitleOverrideMode => SetSubtitleMode.DontOverrideIfBothNotNull; } public class VoidlingReplacement : BaseBossReplacement { public uint Phase; protected override BossReplacementType replacementType { get { if (Phase >= 1 && Phase <= VoidlingPhaseTracker.TotalNumPhases) { return (BossReplacementType)(4 + Phase - 1); } return BossReplacementType.Invalid; } } protected override CharacterMaster originalMasterPrefab => Caches.MasterPrefabs[$"MiniVoidRaidCrabMasterPhase{Phase}"]; protected override void bodyResolved() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) base.bodyResolved(); CharacterBody body = _body; body.bodyFlags = (BodyFlags)(body.bodyFlags | 1); CharacterDeathBehavior orAddComponent = ((Component)_body).gameObject.GetOrAddComponent(); if (!Object.op_Implicit((Object)(object)orAddComponent.deathStateMachine)) { EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)_body).gameObject, "Body"); if (Object.op_Implicit((Object)(object)val)) { orAddComponent.deathStateMachine = val; } else { Log.Warning("Body entityState for " + _body.GetDisplayName() + " could not be found!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\BossReplacementInfo\\VoidlingReplacement.cs", "bodyResolved", 50); } } bool flag = Phase == VoidlingPhaseTracker.TotalNumPhases; SerializableEntityStateType val2 = (flag ? BossRandomizerController.Voidling.FinalDeathState : BossRandomizerController.Voidling.EscapeDeathState); Type stateType = ((SerializableEntityStateType)(ref orAddComponent.deathState)).stateType; if (!(stateType == null)) { SerializableEntityStateType escapeDeathState = BossRandomizerController.Voidling.EscapeDeathState; if (!(stateType == ((SerializableEntityStateType)(ref escapeDeathState)).stateType)) { if (stateType != ((SerializableEntityStateType)(ref val2)).stateType) { MultiEntityState.StateMachineSubStatesData stateMachineSubStatesData = ((Component)orAddComponent).gameObject.AddComponent(); stateMachineSubStatesData.StateTypes = (SerializableEntityStateType[])(object)new SerializableEntityStateType[2] { orAddComponent.deathState, val2 }; stateMachineSubStatesData.AlwaysExecuteEnter = true; stateMachineSubStatesData.MinActiveDuration = (flag ? InitializeOnAccess.op_Implicit(BossRandomizerController.Voidling.FinalDeathStateAnimationDuration) : 0.75f); orAddComponent.deathState = MultiEntityState.SerializableStateType; } goto IL_014a; } } orAddComponent.deathState = val2; goto IL_014a; IL_014a: CharacterDeathBehavior val3 = orAddComponent; if (val3.idleStateMachine == null) { val3.idleStateMachine = Array.Empty(); } FogDamageController val4 = default(FogDamageController); BaseZoneBehavior val5 = default(BaseZoneBehavior); if (((Component)base.originalBodyPrefab).TryGetComponent(ref val4) && ((Component)base.originalBodyPrefab).TryGetComponent(ref val5)) { FogDamageController orAddComponent2 = ((Component)_body).gameObject.GetOrAddComponent(); orAddComponent2.teamFilter = ((Component)_body).gameObject.AddComponent(); orAddComponent2.teamFilter.defaultTeam = val4.teamFilter.defaultTeam; orAddComponent2.teamFilter.Awake(); orAddComponent2.invertTeamFilter = val4.invertTeamFilter; orAddComponent2.tickPeriodSeconds = val4.tickPeriodSeconds; orAddComponent2.healthFractionPerSecond = val4.healthFractionPerSecond; orAddComponent2.healthFractionRampCoefficientPerSecond = val4.healthFractionRampCoefficientPerSecond; orAddComponent2.dangerBuffDef = val4.dangerBuffDef; orAddComponent2.dangerBuffDuration = val4.dangerBuffDuration; Type type = ((object)val5).GetType(); BaseZoneBehavior val6 = (BaseZoneBehavior)((Component)_body).gameObject.GetOrAddComponent(type); SphereZone val7 = (SphereZone)(object)((val6 is SphereZone) ? val6 : null); if (val7 != null) { SphereZone val8 = (SphereZone)(object)((val5 is SphereZone) ? val5 : null); val7.radius = val8.radius; val7.rangeIndicator = Object.Instantiate(val8.rangeIndicator, _body.transform); val7.indicatorSmoothTime = val8.indicatorSmoothTime; val7.isInverted = val8.isInverted; } else { Log.Warning("Zone type '" + type.FullName + "' not accounted for!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\RandomizerControllers\\Boss\\BossReplacementInfo\\VoidlingReplacement.cs", "bodyResolved", 109); } orAddComponent2.initialSafeZones = (BaseZoneBehavior[])(object)new BaseZoneBehavior[1] { val6 }; } } } } namespace RoR2Randomizer.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { resourceMan = new ResourceManager("RoR2Randomizer.Properties.Resources", typeof(Resources).Assembly); } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] icon_embed => (byte[])ResourceManager.GetObject("icon_embed", resourceCulture); internal Resources() { } } } namespace RoR2Randomizer.PrefabMarkers { public sealed class NullModelMarker : MonoBehaviour { [SystemInitializer(new Type[] { })] private static void Init() { //IL_0005: 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) GameObject val = Addressables.LoadAssetAsync((object)"RoR2/Base/Core/NullModel.prefab").WaitForCompletion(); if (Object.op_Implicit((Object)(object)val)) { val.AddComponent(); } else { Log.Warning("NullModel asset is null", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\PrefabMarkers\\NullModelMarker.cs", "Init", 27); } } } public class VoidCradleMarker : MonoBehaviour { [SystemInitializer(new Type[] { })] private static void Init() { //IL_0005: 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) AsyncOperationHandle val = Addressables.LoadAssetAsync((object)"RoR2/DLC1/VoidChest/VoidChest.prefab"); val.Completed += delegate(AsyncOperationHandle handle) { GameObject result = handle.Result; if (Object.op_Implicit((Object)(object)result)) { result.AddComponent(); } else { Log.Warning("could not find void cradle prefab", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\PrefabMarkers\\VoidCradleMarker.cs", "Init", 30); } }; } } public class VoidSeedMarker : MonoBehaviour { public enum MarkerType : byte { Monsters_Interactibles, Props_Elites } [SerializeField] private MarkerType _type; public MarkerType Type => _type; [SystemInitializer(new Type[] { })] private static void Init() { //IL_0005: 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) AsyncOperationHandle val = Addressables.LoadAssetAsync((object)"RoR2/DLC1/VoidCamp/VoidCamp.prefab"); val.Completed += delegate(AsyncOperationHandle operationHandle) { Transform voidSeedTransform; if (operationHandle.IsValid() && operationHandle.IsDone) { voidSeedTransform = operationHandle.Result.transform; markCampChild("Camp 1 - Void Monsters & Interactables", MarkerType.Monsters_Interactibles); markCampChild("Camp 2 - Flavor Props & Void Elites", MarkerType.Props_Elites); } void markCampChild(string childName, MarkerType markerType) { Transform val2 = voidSeedTransform.Find(childName); if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.AddComponent()._type = markerType; } else { Log.Warning("unable to find child " + childName, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\PrefabMarkers\\VoidSeedMarker.cs", "Init", 46); } } }; } } } namespace RoR2Randomizer.Patches { [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] internal sealed class PatchClassAttribute : SearchableAttribute { private readonly struct PatchClassInfo { private class EqualityComparer : IEqualityComparer { public bool Equals(PatchClassInfo x, PatchClassInfo y) { return x._type.Equals(y._type); } public int GetHashCode(PatchClassInfo obj) { return obj._type.GetHashCode(); } } private readonly Type _type; private readonly MethodInfo _applyMethod; private readonly MethodInfo _cleanupMethod; public static readonly IEqualityComparer Comparer = new EqualityComparer(); public PatchClassInfo(Type type) { _type = type; _applyMethod = type.GetMethod("Apply", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetMethod("ApplyPatches", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _cleanupMethod = type.GetMethod("Cleanup", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetMethod("CleanupPatches", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (_applyMethod == null) { Log.Error_NoCallerPrefix("Patch class " + type.FullName + " does not have a Apply or ApplyPatches method"); } if (_cleanupMethod == null) { Log.Error_NoCallerPrefix("Patch class " + type.FullName + " does not have a Cleanup or CleanupPatches method"); } } public void Apply() { if (_applyMethod != null) { _applyMethod.Invoke(null, Array.Empty()); } } public void Cleanup() { if (_cleanupMethod != null) { _cleanupMethod.Invoke(null, Array.Empty()); } } public override string ToString() { return _type.FullName + " (Patch)"; } } private static readonly InitializeOnAccess _patchClasses = new InitializeOnAccess((Func)delegate { IEnumerable instances = SearchableAttribute.GetInstances(); return (instances ?? Enumerable.Empty()).Select((SearchableAttribute attr) => new PatchClassInfo((Type)attr.target)).Distinct(PatchClassInfo.Comparer).ToArray(); }); public static void ApplyAllPatches() { SearchableAttribute.GetInstances(); PatchClassInfo[] get = _patchClasses.Get; for (int i = 0; i < get.Length; i++) { PatchClassInfo patchClassInfo = get[i]; try { patchClassInfo.Apply(); } catch (Exception arg) { Log.Error($"Exception while applying {patchClassInfo}: {arg}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\PatchClassAttribute.cs", "ApplyAllPatches", 105); } } } public static void CleanupAllPatches() { PatchClassInfo[] get = _patchClasses.Get; for (int i = 0; i < get.Length; i++) { PatchClassInfo patchClassInfo = get[i]; try { patchClassInfo.Cleanup(); } catch (Exception arg) { Log.Error($"Exception while cleaning up {patchClassInfo}: {arg}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\PatchClassAttribute.cs", "CleanupAllPatches", 124); } } } } } namespace RoR2Randomizer.Patches.SurvivorPodRandomizer { [PatchClass] public static class OverrideIntroAnimation { private static void Apply() { CharacterBody.onBodyAwakeGlobal += CharacterBody_onBodyAwakeGlobal; } private static void Cleanup() { CharacterBody.onBodyAwakeGlobal -= CharacterBody_onBodyAwakeGlobal; } private static void CharacterBody_onBodyAwakeGlobal(CharacterBody body) { if (Object.op_Implicit((Object)(object)Stage.instance) && Stage.instance.usePod && Object.op_Implicit((Object)(object)Run.instance) && Run.instance.spawnWithPod) { SurvivorPodRandomizerController.TryOverrideIntroAnimation(body); } } } } namespace RoR2Randomizer.Patches.StageRandomizer { [PatchClass] public static class ArtifactTrialFixPatch { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__ArtifactTrialMissionController_Awake; public static Manipulator <1>__PortalDialerController_OpenArtifactPortalServer; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__ArtifactTrialMissionController_Awake; if (obj == null) { hook_Awake val = ArtifactTrialMissionController_Awake; <>O.<0>__ArtifactTrialMissionController_Awake = val; obj = (object)val; } ArtifactTrialMissionController.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__PortalDialerController_OpenArtifactPortalServer; if (obj2 == null) { Manipulator val2 = PortalDialerController_OpenArtifactPortalServer; <>O.<1>__PortalDialerController_OpenArtifactPortalServer = val2; obj2 = (object)val2; } PortalDialerController.OpenArtifactPortalServer += (Manipulator)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__ArtifactTrialMissionController_Awake; if (obj == null) { hook_Awake val = ArtifactTrialMissionController_Awake; <>O.<0>__ArtifactTrialMissionController_Awake = val; obj = (object)val; } ArtifactTrialMissionController.Awake -= (hook_Awake)obj; object obj2 = <>O.<1>__PortalDialerController_OpenArtifactPortalServer; if (obj2 == null) { Manipulator val2 = PortalDialerController_OpenArtifactPortalServer; <>O.<1>__PortalDialerController_OpenArtifactPortalServer = val2; obj2 = (object)val2; } PortalDialerController.OpenArtifactPortalServer -= (Manipulator)obj2; } private static void ArtifactTrialMissionController_Awake(orig_Awake orig, ArtifactTrialMissionController self) { if (NetworkServer.active && (bool)ConfigManager.StageRandomizer.Enabled && !Object.op_Implicit((Object)(object)ArtifactTrialMissionController.trialArtifact)) { IEnumerable enumerable = Enumerable.Range(0, ArtifactCatalog.artifactCount); if (Object.op_Implicit((Object)(object)RunArtifactManager.instance)) { IEnumerable enumerable2 = enumerable.Where((int i) => !RunArtifactManager.instance._enabledArtifacts[i]); if (enumerable2.Any()) { enumerable = enumerable2; } } ArtifactTrialMissionController.trialArtifact = ArtifactCatalog.GetArtifactDef((ArtifactIndex)enumerable.GetRandomOrDefault(StageRandomizerController.Instance.RNG, 0)); } orig.Invoke(self); } private static void PortalDialerController_OpenArtifactPortalServer(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStsfld(x, "trialArtifact") })) { val.EmitDelegate>((Func)delegate(ArtifactDef artifactDef) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0022: 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_002d: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && (bool)ConfigManager.StageRandomizer.Enabled) { SceneIndex artifactTrialSceneIndex = Caches.Scene.ArtifactTrialSceneIndex; if ((int)artifactTrialSceneIndex != -1 && StageRandomizerController.TryGetReplacementSceneIndex(artifactTrialSceneIndex, out var replacement) && replacement != artifactTrialSceneIndex) { return (ArtifactDef)null; } } return artifactDef; }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\StageRandomizer\\ArtifactTrialFixPatch.cs", "PortalDialerController_OpenArtifactPortalServer", 73); } } } [PatchClass] public static class InitializeStageReplacementsPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__Run_Start; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__Run_Start; if (obj == null) { Manipulator val = Run_Start; <>O.<0>__Run_Start = val; obj = (object)val; } Run.Start += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__Run_Start; if (obj == null) { Manipulator val = Run_Start; <>O.<0>__Run_Start = val; obj = (object)val; } Run.Start -= (Manipulator)obj; } private static void Run_Start(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, "ServerChangeScene") })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Call, "InitializeStageReplacements"); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\StageRandomizer\\InitializeStageReplacementsPatch.cs", "Run_Start", 31); } } } [PatchClass] public static class OverrideSceneLoadPatch { private static readonly Hook UnityEngine_Networking_NetworkManager_ServerChangeScene_Hook = new Hook((MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((NetworkManager _) => _.ServerChangeScene((string)null))), (Delegate)(Action, NetworkManager, string>)delegate(Action orig, NetworkManager self, string newSceneName) { if (StageRandomizerController.TryGetReplacementSceneName(newSceneName, out var replacement)) { newSceneName = replacement; } orig(self, newSceneName); }); private static void Apply() { Hook unityEngine_Networking_NetworkManager_ServerChangeScene_Hook = UnityEngine_Networking_NetworkManager_ServerChangeScene_Hook; if (unityEngine_Networking_NetworkManager_ServerChangeScene_Hook != null) { unityEngine_Networking_NetworkManager_ServerChangeScene_Hook.Apply(); } } private static void Cleanup() { Hook unityEngine_Networking_NetworkManager_ServerChangeScene_Hook = UnityEngine_Networking_NetworkManager_ServerChangeScene_Hook; if (unityEngine_Networking_NetworkManager_ServerChangeScene_Hook != null) { unityEngine_Networking_NetworkManager_ServerChangeScene_Hook.Undo(); } } } } namespace RoR2Randomizer.Patches.StageEvents { [PatchClass] internal static class OverrideStageEventPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ClassicStageInfo_RebuildCards; public static Func, Run, bool> <1>__Run_get_canFamilyEventTrigger; public static Func <2>__getCardSelectionPrefab; } internal static DirectorCardCategorySelection ForcedCategorySelection; private static Hook[] canFamilyEventTriggerHooks; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ClassicStageInfo_RebuildCards; if (obj == null) { Manipulator val = ClassicStageInfo_RebuildCards; <>O.<0>__ClassicStageInfo_RebuildCards = val; obj = (object)val; } ClassicStageInfo.RebuildCards += (Manipulator)obj; canFamilyEventTriggerHooks = (from type in typeof(Run).Assembly.GetTypes() where typeof(Run).IsAssignableFrom(type) let property = type.GetProperty("canFamilyEventTrigger", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public) where property != null select new Hook((MethodBase)property.GetMethod, (Delegate)new Func, Run, bool>(Run_get_canFamilyEventTrigger))).ToArray(); } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ClassicStageInfo_RebuildCards; if (obj == null) { Manipulator val = ClassicStageInfo_RebuildCards; <>O.<0>__ClassicStageInfo_RebuildCards = val; obj = (object)val; } ClassicStageInfo.RebuildCards -= (Manipulator)obj; if (canFamilyEventTriggerHooks == null) { return; } Hook[] array = canFamilyEventTriggerHooks; foreach (Hook obj2 in array) { if (obj2 != null) { obj2.Undo(); } } } private static bool Run_get_canFamilyEventTrigger(Func orig, Run self) { if (!Object.op_Implicit((Object)(object)ForcedCategorySelection)) { return orig(self); } return true; } private static void ClassicStageInfo_RebuildCards(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "monsterDccsPool"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "GenerateWeightedSelection"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo>((Expression>>)((WeightedSelection _) => _.Evaluate(0f)))) })) { ILCursor obj = array[2]; int index = obj.Index; obj.Index = index + 1; obj.EmitDelegate>((Func)getCardSelectionPrefab); } else { Log.Warning("unable to find patch location (0)", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\StageEvents\\OverrideStageEventPatch.cs", "ClassicStageInfo_RebuildCards", 70); } val.Index = 0; if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "monsterCategories"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Object.Instantiate((DirectorCardCategorySelection)null)))) })) { array[1].EmitDelegate>((Func)getCardSelectionPrefab); } else { Log.Warning("unable to find patch location (1)", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\StageEvents\\OverrideStageEventPatch.cs", "ClassicStageInfo_RebuildCards", 82); } static DirectorCardCategorySelection getCardSelectionPrefab(DirectorCardCategorySelection selected) { if (!Object.op_Implicit((Object)(object)ForcedCategorySelection)) { return selected; } return ForcedCategorySelection; } } } [PatchClass] internal static class SetStageEventOverride { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__ClassicStageInfo_Awake; } private static FamilyDirectorCardCategorySelection _gupFamilySelection; static SetStageEventOverride() { //IL_0005: 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) AsyncOperationHandle val = Addressables.LoadAssetAsync((object)"RoR2/Base/Common/dccsGupFamily.asset"); val.Completed += delegate(AsyncOperationHandle handle) { _gupFamilySelection = handle.Result; }; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ClassicStageInfo_Awake; if (obj == null) { hook_Awake val = ClassicStageInfo_Awake; <>O.<0>__ClassicStageInfo_Awake = val; obj = (object)val; } ClassicStageInfo.Awake += (hook_Awake)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ClassicStageInfo_Awake; if (obj == null) { hook_Awake val = ClassicStageInfo_Awake; <>O.<0>__ClassicStageInfo_Awake = val; obj = (object)val; } ClassicStageInfo.Awake -= (hook_Awake)obj; } private static void ClassicStageInfo_Awake(orig_Awake orig, ClassicStageInfo self) { OverrideStageEventPatch.ForcedCategorySelection = null; if (NetworkServer.active && ConfigManager.Fun.GupModeActive) { if (!Object.op_Implicit((Object)(object)_gupFamilySelection)) { Log.Warning("Gup mode is enabled, but _gupFamilySelection is not loaded!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\StageEvents\\SetStageEventOverride.cs", "ClassicStageInfo_Awake", 47); } else { OverrideStageEventPatch.ForcedCategorySelection = (DirectorCardCategorySelection)(object)_gupFamilySelection; } } orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.SniperWeakPointRandomizer { [PatchClass] internal static class CharacterModel_RandomizeHurtBoxes { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__CharacterModel_Awake; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterModel_Awake; if (obj == null) { hook_Awake val = CharacterModel_Awake; <>O.<0>__CharacterModel_Awake = val; obj = (object)val; } CharacterModel.Awake += (hook_Awake)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterModel_Awake; if (obj == null) { hook_Awake val = CharacterModel_Awake; <>O.<0>__CharacterModel_Awake = val; obj = (object)val; } CharacterModel.Awake -= (hook_Awake)obj; } private static void CharacterModel_Awake(orig_Awake orig, CharacterModel self) { HurtBoxGroup hurtBoxGroup = default(HurtBoxGroup); if (((Component)self).TryGetComponent(ref hurtBoxGroup)) { SniperWeakPointRandomizerController.TryRandomizeSniperTargets(hurtBoxGroup); } orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.Reverse { [HarmonyPatch(typeof(DroneWeaponsBehavior))] public static class DroneWeaponsBehavior { public static void SetNumDroneParts(Inventory inventory, int numParts) { setNumDroneParts(numParts, inventory, (BodyFlags)2, numParts); } [HarmonyPatch("UpdateMinionInventory")] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] private static void setNumDroneParts(int numParts, Inventory inventory, BodyFlags bodyFlags, int newStack) { Manipulator(null); static void Manipulator(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); FieldInfo DroneWeaponsBehavior_stack_FI = AccessTools.DeclaredField(typeof(ItemBehavior), "stack"); while (val.TryGotoNext(new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, DroneWeaponsBehavior_stack_FI) })) { int index = val.Index; val.Index = index + 1; val.Remove(); } } } } [HarmonyPatch(typeof(Run))] public static class Run { [HarmonyPatch("PickNextStageSceneFromCurrentSceneDestinations")] [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] public static void PickNextStageSceneFromSceneDestinations(Run instance, SceneDef scene) { Transpiler(null); static IEnumerable Transpiler(IEnumerable instructions) { MethodInfo SceneCatalog_get_mostRecentSceneDef_MI = AccessTools.PropertyGetter(typeof(SceneCatalog), "mostRecentSceneDef"); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, SceneCatalog_get_mostRecentSceneDef_MI)) { instruction.opcode = OpCodes.Ldarg_1; instruction.operand = null; } yield return instruction; } } } } } namespace RoR2Randomizer.Patches.ProjectileRandomizer { [PatchClass] internal static class HookProjectileImpactFix { [CompilerGenerated] private static class <>O { public static hook_Start <0>__HookProjectileImpact_Start; public static hook_Reel <1>__HookProjectileImpact_Reel; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__HookProjectileImpact_Start; if (obj == null) { hook_Start val = HookProjectileImpact_Start; <>O.<0>__HookProjectileImpact_Start = val; obj = (object)val; } HookProjectileImpact.Start += (hook_Start)obj; object obj2 = <>O.<1>__HookProjectileImpact_Reel; if (obj2 == null) { hook_Reel val2 = HookProjectileImpact_Reel; <>O.<1>__HookProjectileImpact_Reel = val2; obj2 = (object)val2; } HookProjectileImpact.Reel += (hook_Reel)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__HookProjectileImpact_Start; if (obj == null) { hook_Start val = HookProjectileImpact_Start; <>O.<0>__HookProjectileImpact_Start = val; obj = (object)val; } HookProjectileImpact.Start -= (hook_Start)obj; object obj2 = <>O.<1>__HookProjectileImpact_Reel; if (obj2 == null) { hook_Reel val2 = HookProjectileImpact_Reel; <>O.<1>__HookProjectileImpact_Reel = val2; obj2 = (object)val2; } HookProjectileImpact.Reel -= (hook_Reel)obj2; } private static void HookProjectileImpact_Start(orig_Start orig, HookProjectileImpact self) { ProjectileController val = default(ProjectileController); if (((Component)self).TryGetComponent(ref val)) { GameObject owner = val.owner; if (Object.op_Implicit((Object)(object)owner)) { Transform transform = owner.transform; if (Object.op_Implicit((Object)(object)transform)) { ModelLocator component = ((Component)transform).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { Transform modelTransform = component.modelTransform; if (Object.op_Implicit((Object)(object)modelTransform)) { ChildLocator component2 = ((Component)modelTransform).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { CustomChildTransformManager.AutoAddChildTransform(((Component)transform).GetComponent(), component2, self.attachmentString); } } } } } } orig.Invoke(self); } private static bool HookProjectileImpact_Reel(orig_Reel orig, HookProjectileImpact self) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)self.ownerTransform) || !Object.op_Implicit((Object)(object)self.victim)) { self.hookState = (HookState)3; return false; } return orig.Invoke(self); } } [PatchClass] internal static class LightningStakeFix { [CompilerGenerated] private static class <>O { public static Manipulator <0>__GlobalEventManager_OnHitAll; } private static ProjectileTypeIdentifier _lightningStakeProjectileIdentifier; [SystemInitializer(new Type[] { typeof(ProjectileCatalog) })] private static void Init() { _lightningStakeProjectileIdentifier = new ProjectileTypeIdentifier(ProjectileType.OrdinaryProjectile, ProjectileCatalog.FindProjectileIndex("LightningStake")); if (!_lightningStakeProjectileIdentifier.IsValid) { Log.Warning("Unable to find projectile index for LightningStake", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\LightningStakeFix.cs", "Init", 24); } } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GlobalEventManager_OnHitAll; if (obj == null) { Manipulator val = GlobalEventManager_OnHitAll; <>O.<0>__GlobalEventManager_OnHitAll = val; obj = (object)val; } GlobalEventManager.OnHitAll += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GlobalEventManager_OnHitAll; if (obj == null) { Manipulator val = GlobalEventManager_OnHitAll; <>O.<0>__GlobalEventManager_OnHitAll = val; obj = (object)val; } GlobalEventManager.OnHitAll -= (Manipulator)obj; } private static void GlobalEventManager_OnHitAll(ILContext il) { //IL_0001: 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) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "AffixBlue"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((CharacterBody _) => _.HasBuff((BuffDef)null)))) })) { ILCursor obj = array[1]; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Ldarg_1); ProjectileController val = default(ProjectileController); ProjectileParentChainTracker projectileParentChainTracker = default(ProjectileParentChainTracker); obj.EmitDelegate>((Func)((bool hasBuff, DamageInfo damageInfo) => (!hasBuff || !_lightningStakeProjectileIdentifier.IsValid || !ProjectileRandomizerController.IsActive || !ProjectileRandomizerController.TryGetOverrideProjectileIdentifier(in _lightningStakeProjectileIdentifier, out var replacement) || !Object.op_Implicit((Object)(object)damageInfo.inflictor) || !damageInfo.inflictor.TryGetComponent(ref val) || !((Component)val).TryGetComponent(ref projectileParentChainTracker) || (!projectileParentChainTracker.IsChildOf(replacement) && (ProjectileManager_InitializeProjectile_SetOwnerPatch.BulletOwnerNodeOfNextProjectile == null || !ProjectileManager_InitializeProjectile_SetOwnerPatch.BulletOwnerNodeOfNextProjectile.IsChildOf(replacement)))) && hasBuff)); } else { Log.Warning("failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\LightningStakeFix.cs", "GlobalEventManager_OnHitAll", 81); } } } [PatchClass] internal static class ProjectileExplosion_ReplaceChildPrefab { [CompilerGenerated] private static class <>O { public static hook_FireChild <0>__ProjectileExplosion_FireChild; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileExplosion_FireChild; if (obj == null) { hook_FireChild val = ProjectileExplosion_FireChild; <>O.<0>__ProjectileExplosion_FireChild = val; obj = (object)val; } ProjectileExplosion.FireChild += (hook_FireChild)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileExplosion_FireChild; if (obj == null) { hook_FireChild val = ProjectileExplosion_FireChild; <>O.<0>__ProjectileExplosion_FireChild = val; obj = (object)val; } ProjectileExplosion.FireChild -= (hook_FireChild)obj; } private static void ProjectileExplosion_FireChild(orig_FireChild orig, ProjectileExplosion self) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) ref GameObject childrenProjectilePrefab = ref self.childrenProjectilePrefab; ProjectileManager_InitializeProjectile_SetOwnerPatch.OwnerOfNextProjectile = ((Component)self).gameObject; if (ProjectileRandomizerController.TryReplaceProjectileInstantiateFire(ref childrenProjectilePrefab, out var originalPrefab, ((Component)self).transform.position, self.GetRandomDirectionForChild(), self.projectileDamage.damage * self.childrenDamageCoefficient, self.projectileDamage.force, self.projectileDamage.crit, new GenericFireProjectileArgs { Owner = self.projectileController.owner, Weapon = ((Component)self).gameObject, DamageType = DamageTypeCombo.op_Implicit(self.projectileDamage.damageType) })) { orig.Invoke(self); if (Object.op_Implicit((Object)(object)originalPrefab)) { childrenProjectilePrefab = originalPrefab; } } } } [PatchClass] internal static class ProjectileFireChildren_ReplaceChildPrefab { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ProjectileFireChildren_Update_IL; } private static GameObject _originalPrefab; private static readonly FieldInfo _prefab_FI = AccessTools.DeclaredField(typeof(ProjectileFireChildren_ReplaceChildPrefab), "_prefab"); private static GameObject _prefab; private static readonly FieldInfo _position_FI = AccessTools.DeclaredField(typeof(ProjectileFireChildren_ReplaceChildPrefab), "_position"); private static Vector3 _position; private static readonly FieldInfo _rotation_FI = AccessTools.DeclaredField(typeof(ProjectileFireChildren_ReplaceChildPrefab), "_rotation"); private static Quaternion _rotation; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileFireChildren_Update_IL; if (obj == null) { Manipulator val = ProjectileFireChildren_Update_IL; <>O.<0>__ProjectileFireChildren_Update_IL = val; obj = (object)val; } ProjectileFireChildren.Update += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileFireChildren_Update_IL; if (obj == null) { Manipulator val = ProjectileFireChildren_Update_IL; <>O.<0>__ProjectileFireChildren_Update_IL = val; obj = (object)val; } ProjectileFireChildren.Update -= (Manipulator)obj; } private static void ProjectileFireChildren_Update_IL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); ILLabel val3 = default(ILLabel); if (val.TryFindNext(ref array, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "nextSpawnTimer"), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "duration"), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "count"), (Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref val3) || ILPatternMatchingExt.MatchBltUn(x, ref val3) })) { val = array[3]; object operand = val.Next.Operand; ILLabel val2 = (ILLabel)((operand is ILLabel) ? operand : null); if (val2 != null) { if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Object.Instantiate((GameObject)null, default(Vector3), default(Quaternion))))) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(GameObject prefab, Vector3 position, Quaternion rotation, ProjectileFireChildren instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) ProjectileController projectileController = instance.projectileController; ProjectileDamage projectileDamage = instance.projectileDamage; ProjectileManager_InitializeProjectile_SetOwnerPatch.OwnerOfNextProjectile = ((Component)instance).gameObject; if (ProjectileRandomizerController.TryReplaceProjectileInstantiateFire(ref prefab, out _originalPrefab, position, rotation, projectileDamage.damage, projectileDamage.force, projectileDamage.crit, new GenericFireProjectileArgs { Owner = projectileController.owner, Weapon = ((Component)instance).gameObject, DamageType = DamageTypeCombo.op_Implicit(projectileDamage.damageType) })) { _prefab = prefab; _position = position; _rotation = rotation; return true; } return false; }); val.Emit(OpCodes.Brfalse, (object)val2); val.Emit(OpCodes.Ldsfld, _prefab_FI); val.Emit(OpCodes.Ldsfld, _position_FI); val.Emit(OpCodes.Ldsfld, _rotation_FI); } else { Log.Warning("failed (2)", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\ProjectileFireChildren_ReplaceChildPrefab.cs", "ProjectileFireChildren_Update_IL", 85); } ILCursor obj = val.Goto(val2.Target, (MoveType)0, false); obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Action)delegate(ProjectileFireChildren instance) { if (Object.op_Implicit((Object)(object)_originalPrefab)) { instance.childProjectilePrefab = _originalPrefab; } }); } else { Log.Warning("failed (1)", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\ProjectileFireChildren_ReplaceChildPrefab.cs", "ProjectileFireChildren_Update_IL", 100); } } else { Log.Warning("failed (0)", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\ProjectileFireChildren_ReplaceChildPrefab.cs", "ProjectileFireChildren_Update_IL", 105); } } } [PatchClass] internal static class ProjectileGrappleFix { [CompilerGenerated] private static class <>O { public static hook_InitializeProjectile <0>__ProjectileManager_InitializeProjectile; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileManager_InitializeProjectile; if (obj == null) { hook_InitializeProjectile val = ProjectileManager_InitializeProjectile; <>O.<0>__ProjectileManager_InitializeProjectile = val; obj = (object)val; } ProjectileManager.InitializeProjectile += (hook_InitializeProjectile)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileManager_InitializeProjectile; if (obj == null) { hook_InitializeProjectile val = ProjectileManager_InitializeProjectile; <>O.<0>__ProjectileManager_InitializeProjectile = val; obj = (object)val; } ProjectileManager.InitializeProjectile -= (hook_InitializeProjectile)obj; } private static void ProjectileManager_InitializeProjectile(orig_InitializeProjectile orig, ProjectileController projectileController, FireProjectileInfo fireProjectileInfo) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(projectileController, fireProjectileInfo); if (!ProjectileRandomizerController.TryGetOriginalProjectilePrefab(fireProjectileInfo.projectilePrefab, out var originalPrefab) || !Object.op_Implicit((Object)(object)originalPrefab.GetComponent()) || Object.op_Implicit((Object)(object)((Component)projectileController).GetComponent())) { return; } EntityStateMachine val = EntityStateMachine.FindByCustomName(projectileController.owner, "Hook"); if (Object.op_Implicit((Object)(object)val)) { EntityState state = val.state; FireHook val2 = (FireHook)(object)((state is FireHook) ? state : null); if (val2 != null) { val2.SetHookReference(((Component)projectileController).gameObject); } } else { Log.Warning("Tried to initialize grapple projectile, but owner has no 'Hook' state machine", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\ProjectileGrappleFix.cs", "ProjectileManager_InitializeProjectile", 41); } } } [PatchClass] public static class ReplaceFireProjectileServerPrefab { [CompilerGenerated] private static class <>O { public static hook_FireProjectile_FireProjectileInfo <0>__ProjectileManager_FireProjectile_FireProjectileInfo; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileManager_FireProjectile_FireProjectileInfo; if (obj == null) { hook_FireProjectile_FireProjectileInfo val = ProjectileManager_FireProjectile_FireProjectileInfo; <>O.<0>__ProjectileManager_FireProjectile_FireProjectileInfo = val; obj = (object)val; } ProjectileManager.FireProjectile_FireProjectileInfo += (hook_FireProjectile_FireProjectileInfo)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileManager_FireProjectile_FireProjectileInfo; if (obj == null) { hook_FireProjectile_FireProjectileInfo val = ProjectileManager_FireProjectile_FireProjectileInfo; <>O.<0>__ProjectileManager_FireProjectile_FireProjectileInfo = val; obj = (object)val; } ProjectileManager.FireProjectile_FireProjectileInfo -= (hook_FireProjectile_FireProjectileInfo)obj; } private static void ProjectileManager_FireProjectile_FireProjectileInfo(orig_FireProjectile_FireProjectileInfo orig, ProjectileManager self, FireProjectileInfo fireProjectileInfo) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!ProjectileRandomizerController.TryReplaceFire(in fireProjectileInfo, null)) { orig.Invoke(self, fireProjectileInfo); } } } } namespace RoR2Randomizer.Patches.ProjectileRandomizer.SpiteBomb { [PatchClass] internal static class SpiteBomb_SpawnHook { internal static int patchDisabledCount = 0; private static readonly Hook BombArtifactManager_SpawnBomb_Hook = new Hook((MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => BombArtifactManager.SpawnBomb(default(BombRequest), 0f))), (Delegate)(Action, BombRequest, float>)delegate(Action orig, BombRequest bombRequest, float groundY) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (patchDisabledCount > 0 || !ProjectileRandomizerController.TryReplaceFire(in bombRequest)) { orig(bombRequest, groundY); } }, new HookConfig { ManualApply = true }); private static void Apply() { BombArtifactManager_SpawnBomb_Hook.Apply(); } private static void Cleanup() { BombArtifactManager_SpawnBomb_Hook.Undo(); } } } namespace RoR2Randomizer.Patches.ProjectileRandomizer.Orbs { [PatchClass] internal static class LightningOrb_PreventSpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__LightningOrb_OnArrival; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__LightningOrb_OnArrival; if (obj == null) { Manipulator val = LightningOrb_OnArrival; <>O.<0>__LightningOrb_OnArrival = val; obj = (object)val; } LightningOrb.OnArrival += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__LightningOrb_OnArrival; if (obj == null) { Manipulator val = LightningOrb_OnArrival; <>O.<0>__LightningOrb_OnArrival = val; obj = (object)val; } LightningOrb.OnArrival -= (Manipulator)obj; } private static void LightningOrb_OnArrival(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "AddOrb") })) { val.EmitDelegate((Action)delegate { OrbManager_AddOrbHook.PatchDisabledCount++; }); int index = val.Index; val.Index = index + 1; val.EmitDelegate((Action)delegate { OrbManager_AddOrbHook.PatchDisabledCount--; }); num++; } if (num == 0) { Log.Warning("found no patch locations", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\Orbs\\LightningOrb_PreventSpawnHook.cs", "LightningOrb_OnArrival", 45); } } } [PatchClass] internal static class OrbManager_AddOrbHook { [CompilerGenerated] private static class <>O { public static hook_AddOrb <0>__OrbManager_AddOrb; } internal static int PatchDisabledCount; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__OrbManager_AddOrb; if (obj == null) { hook_AddOrb val = OrbManager_AddOrb; <>O.<0>__OrbManager_AddOrb = val; obj = (object)val; } OrbManager.AddOrb += (hook_AddOrb)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__OrbManager_AddOrb; if (obj == null) { hook_AddOrb val = OrbManager_AddOrb; <>O.<0>__OrbManager_AddOrb = val; obj = (object)val; } OrbManager.AddOrb -= (hook_AddOrb)obj; } private static void OrbManager_AddOrb(orig_AddOrb orig, OrbManager self, Orb orb) { if (PatchDisabledCount > 0 || !ProjectileRandomizerController.TryReplaceFire(orb)) { orig.Invoke(self, orb); } } } } namespace RoR2Randomizer.Patches.ProjectileRandomizer.BulletAttacks { [PatchClass] internal static class BulletAttack_FireHook { [CompilerGenerated] private static class <>O { public static hook_FireSingle <0>__BulletAttack_FireSingle; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BulletAttack_FireSingle; if (obj == null) { hook_FireSingle val = BulletAttack_FireSingle; <>O.<0>__BulletAttack_FireSingle = val; obj = (object)val; } BulletAttack.FireSingle += (hook_FireSingle)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BulletAttack_FireSingle; if (obj == null) { hook_FireSingle val = BulletAttack_FireSingle; <>O.<0>__BulletAttack_FireSingle = val; obj = (object)val; } BulletAttack.FireSingle -= (hook_FireSingle)obj; } private static void BulletAttack_FireSingle(orig_FireSingle orig, BulletAttack self, FireSingleArgs args) { //IL_0008: 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) if (!ProjectileRandomizerController.TryReplaceFire(self, ((Ray)(ref args.ray)).direction)) { orig.Invoke(self, args); } } } [PatchClass] internal static class BulletAttack_NetMessageHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__BulletAttack_DefaultHitCallbackImplementation; public static Manipulator <1>__BulletAttack_HandleBulletDamage; } private static NetworkReader _currentReader; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__BulletAttack_DefaultHitCallbackImplementation; if (obj == null) { Manipulator val = BulletAttack_DefaultHitCallbackImplementation; <>O.<0>__BulletAttack_DefaultHitCallbackImplementation = val; obj = (object)val; } BulletAttack.DefaultHitCallbackImplementation += (Manipulator)obj; object obj2 = <>O.<1>__BulletAttack_HandleBulletDamage; if (obj2 == null) { Manipulator val2 = BulletAttack_HandleBulletDamage; <>O.<1>__BulletAttack_HandleBulletDamage = val2; obj2 = (object)val2; } BulletAttack.HandleBulletDamage += (Manipulator)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__BulletAttack_DefaultHitCallbackImplementation; if (obj == null) { Manipulator val = BulletAttack_DefaultHitCallbackImplementation; <>O.<0>__BulletAttack_DefaultHitCallbackImplementation = val; obj = (object)val; } BulletAttack.DefaultHitCallbackImplementation -= (Manipulator)obj; object obj2 = <>O.<1>__BulletAttack_HandleBulletDamage; if (obj2 == null) { Manipulator val2 = BulletAttack_HandleBulletDamage; <>O.<1>__BulletAttack_HandleBulletDamage = val2; obj2 = (object)val2; } BulletAttack.HandleBulletDamage -= (Manipulator)obj2; } private static void BulletAttack_DefaultHitCallbackImplementation(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 53), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "StartMessage"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "FinishMessage") })) { ILCursor obj = array[2]; obj.Emit(OpCodes.Dup); obj.EmitDelegate>((Action)delegate(NetworkWriter messageWriter) { ProjectileParentChainNode projectileParentChainNode = ProjectileManager_InitializeProjectile_SetOwnerPatch.ResolveChainNodeForCurrentOwner(); bool flag = projectileParentChainNode != null; messageWriter.Write(flag); if (flag) { projectileParentChainNode.Serialize(messageWriter); } }); } else { Log.Warning("unable to find hook location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\BulletAttacks\\BulletAttack_NetMessageHook.cs", "BulletAttack_DefaultHitCallbackImplementation", 54); } } private static void BulletAttack_HandleBulletDamage(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "ReadBoolean") })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(NetworkReader reader) { _currentReader = reader; }); int index = val.Index; val.Index = index + 1; val.EmitDelegate((Action)delegate { if (_currentReader.ReadBoolean()) { ProjectileParentChainNode projectileParentChainNode = new ProjectileParentChainNode(); projectileParentChainNode.Deserialize(_currentReader); ProjectileManager_InitializeProjectile_SetOwnerPatch.BulletOwnerNodeOfNextProjectile = projectileParentChainNode; } _currentReader = null; }); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { val.EmitDelegate((Action)delegate { ProjectileManager_InitializeProjectile_SetOwnerPatch.BulletOwnerNodeOfNextProjectile = null; }); } else { Log.Warning("unable to find ret", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\BulletAttacks\\BulletAttack_NetMessageHook.cs", "BulletAttack_HandleBulletDamage", 95); } } else { Log.Warning("unable to find hook location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileRandomizer\\BulletAttacks\\BulletAttack_NetMessageHook.cs", "BulletAttack_HandleBulletDamage", 100); } } } } namespace RoR2Randomizer.Patches.ProjectileParentChainTrackerPatches { [PatchClass] internal static class BulletAttack_Fire_SetBulletsOwner { [CompilerGenerated] private static class <>O { public static hook_Fire <0>__BulletAttack_Fire; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BulletAttack_Fire; if (obj == null) { hook_Fire val = BulletAttack_Fire; <>O.<0>__BulletAttack_Fire = val; obj = (object)val; } BulletAttack.Fire += (hook_Fire)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BulletAttack_Fire; if (obj == null) { hook_Fire val = BulletAttack_Fire; <>O.<0>__BulletAttack_Fire = val; obj = (object)val; } BulletAttack.Fire -= (hook_Fire)obj; } private static void BulletAttack_Fire(orig_Fire orig, BulletAttack self) { BulletAttackIdentifier bulletAttack = BulletAttackCatalog.Instance.GetIdentifier(self); bool isValid = bulletAttack.IsValid; if (isValid) { ProjectileManager_InitializeProjectile_SetOwnerPatch.BulletOwnerNodeOfNextProjectile = new ProjectileParentChainNode(bulletAttack) { Parent = ProjectileManager_InitializeProjectile_SetOwnerPatch.ResolveChainNodeForCurrentOwner() }; } orig.Invoke(self); if (isValid) { ProjectileManager_InitializeProjectile_SetOwnerPatch.BulletOwnerNodeOfNextProjectile = null; } } } [PatchClass] internal static class ProjectileExplosion_FireChild_SetChildOwner { [CompilerGenerated] private static class <>O { public static hook_FireChild <0>__ProjectileExplosion_FireChild; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileExplosion_FireChild; if (obj == null) { hook_FireChild val = ProjectileExplosion_FireChild; <>O.<0>__ProjectileExplosion_FireChild = val; obj = (object)val; } ProjectileExplosion.FireChild += (hook_FireChild)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileExplosion_FireChild; if (obj == null) { hook_FireChild val = ProjectileExplosion_FireChild; <>O.<0>__ProjectileExplosion_FireChild = val; obj = (object)val; } ProjectileExplosion.FireChild -= (hook_FireChild)obj; } private static void ProjectileExplosion_FireChild(orig_FireChild orig, ProjectileExplosion self) { ProjectileManager_InitializeProjectile_SetOwnerPatch.OwnerOfNextProjectile = ((Component)self).gameObject; orig.Invoke(self); ProjectileManager_InitializeProjectile_SetOwnerPatch.OwnerOfNextProjectile = null; } } [PatchClass] internal static class ProjectileFireChildren_Update_SetChildOwner { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ProjectileFireChildren_Update; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileFireChildren_Update; if (obj == null) { Manipulator val = ProjectileFireChildren_Update; <>O.<0>__ProjectileFireChildren_Update = val; obj = (object)val; } ProjectileFireChildren.Update += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileFireChildren_Update; if (obj == null) { Manipulator val = ProjectileFireChildren_Update; <>O.<0>__ProjectileFireChildren_Update = val; obj = (object)val; } ProjectileFireChildren.Update -= (Manipulator)obj; } private static void ProjectileFireChildren_Update(ILContext il) { //IL_0001: 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_0079: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "childProjectilePrefab"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Object.Instantiate((GameObject)null, default(Vector3), default(Quaternion))))) })) { ILCursor obj = array[1]; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Dup); obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Action)delegate(GameObject childProjectile, ProjectileFireChildren instance) { ProjectileParentChainTracker projectileParentChainTracker = default(ProjectileParentChainTracker); if (childProjectile.TryGetComponent(ref projectileParentChainTracker)) { projectileParentChainTracker.TrySetParent(((Component)instance).gameObject); } }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileParentChainTrackerPatches\\ProjectileFireChildren_Update_SetChildOwner.cs", "ProjectileFireChildren_Update", 46); } } } [PatchClass] internal static class ProjectileMageFirewallController_CreateWalkers_SetChildOwner { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ProjectileMageFirewallController_CreateWalkers; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileMageFirewallController_CreateWalkers; if (obj == null) { Manipulator val = ProjectileMageFirewallController_CreateWalkers; <>O.<0>__ProjectileMageFirewallController_CreateWalkers = val; obj = (object)val; } ProjectileMageFirewallController.CreateWalkers += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileMageFirewallController_CreateWalkers; if (obj == null) { Manipulator val = ProjectileMageFirewallController_CreateWalkers; <>O.<0>__ProjectileMageFirewallController_CreateWalkers = val; obj = (object)val; } ProjectileMageFirewallController.CreateWalkers -= (Manipulator)obj; } private static void ProjectileMageFirewallController_CreateWalkers(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = 0; ILCursor[] array = default(ILCursor[]); while (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "walkerPrefab"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((ProjectileManager _) => _.FireProjectile((GameObject)null, default(Vector3), default(Quaternion), (GameObject)null, 0f, 0f, false, (DamageColorIndex)0, (GameObject)null, 0f, (DamageTypeCombo?)null)))) })) { ILCursor obj = array[1]; obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Action)delegate(ProjectileMageFirewallController instance) { ProjectileManager_InitializeProjectile_SetOwnerPatch.OwnerOfNextProjectile = ((Component)instance).gameObject; }); val.Index = array[^1].Index + 1; num++; } if (num == 0) { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileParentChainTrackerPatches\\ProjectileMageFirewallController_CreateWalkers_SetChildOwner.cs", "ProjectileMageFirewallController_CreateWalkers", 46); } } } [PatchClass] internal static class ProjectileMageFirewallWalkerController_FixedUpdate_SetChildOwner { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ProjectileMageFirewallWalkerController_FixedUpdate; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileMageFirewallWalkerController_FixedUpdate; if (obj == null) { Manipulator val = ProjectileMageFirewallWalkerController_FixedUpdate; <>O.<0>__ProjectileMageFirewallWalkerController_FixedUpdate = val; obj = (object)val; } ProjectileMageFirewallWalkerController.FixedUpdate += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileMageFirewallWalkerController_FixedUpdate; if (obj == null) { Manipulator val = ProjectileMageFirewallWalkerController_FixedUpdate; <>O.<0>__ProjectileMageFirewallWalkerController_FixedUpdate = val; obj = (object)val; } ProjectileMageFirewallWalkerController.FixedUpdate -= (Manipulator)obj; } private static void ProjectileMageFirewallWalkerController_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = 0; ILCursor[] array = default(ILCursor[]); while (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "firePillarPrefab"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((ProjectileManager _) => _.FireProjectile((GameObject)null, default(Vector3), default(Quaternion), (GameObject)null, 0f, 0f, false, (DamageColorIndex)0, (GameObject)null, 0f, (DamageTypeCombo?)null)))) })) { ILCursor obj = array[1]; obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Action)delegate(ProjectileMageFirewallWalkerController instance) { ProjectileManager_InitializeProjectile_SetOwnerPatch.OwnerOfNextProjectile = ((Component)instance).gameObject; }); val.Index = array[^1].Index + 1; num++; } if (num == 0) { Log.Warning("found no patch locations", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ProjectileParentChainTrackerPatches\\ProjectileMageFirewallWalkerController_FixedUpdate_SetChildOwner.cs", "ProjectileMageFirewallWalkerController_FixedUpdate", 46); } } } [PatchClass] internal static class ProjectileManager_InitializeProjectile_SetOwnerPatch { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__ProjectileController_Awake; } internal static GameObject OwnerOfNextProjectile; internal static ProjectileParentChainNode BulletOwnerNodeOfNextProjectile; internal static ProjectileParentChainNode ResolveChainNodeForCurrentOwner() { if (BulletOwnerNodeOfNextProjectile != null) { return BulletOwnerNodeOfNextProjectile; } ProjectileParentChainTracker projectileParentChainTracker = default(ProjectileParentChainTracker); if (Object.op_Implicit((Object)(object)OwnerOfNextProjectile) && OwnerOfNextProjectile.TryGetComponent(ref projectileParentChainTracker)) { return projectileParentChainTracker.ChainNode; } return null; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileController_Awake; if (obj == null) { hook_Awake val = ProjectileController_Awake; <>O.<0>__ProjectileController_Awake = val; obj = (object)val; } ProjectileController.Awake += (hook_Awake)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileController_Awake; if (obj == null) { hook_Awake val = ProjectileController_Awake; <>O.<0>__ProjectileController_Awake = val; obj = (object)val; } ProjectileController.Awake -= (hook_Awake)obj; } private static void ProjectileController_Awake(orig_Awake orig, ProjectileController self) { ProjectileParentChainTracker projectileParentChainTracker = ((Component)self).gameObject.AddComponent(); if (Object.op_Implicit((Object)(object)OwnerOfNextProjectile)) { projectileParentChainTracker.TrySetParent(OwnerOfNextProjectile); OwnerOfNextProjectile = null; } else if (BulletOwnerNodeOfNextProjectile != null) { projectileParentChainTracker.SetParent(BulletOwnerNodeOfNextProjectile); } orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.OrbEffectOverrideTarget { [PatchClass] internal static class OrbHurtBoxReferenceObjectOverridePatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__IL_GenericOrb_Begin; } internal static readonly Dictionary overrideOrbTargetPosition = new Dictionary(); private static readonly Hook Orb_get_distanceToTarget = new Hook((MethodBase)AccessTools.DeclaredPropertyGetter(typeof(Orb), "distanceToTarget"), (Delegate)(Func, Orb, float>)delegate(Func orig, Orb self) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) float result = orig(self); if (!Object.op_Implicit((Object)(object)self.target) && overrideOrbTargetPosition.TryGetValue(self, out var value)) { result = Vector3.Distance(self.origin, value); } return result; }, new HookConfig { ManualApply = true }); private static readonly FieldInfo _target_FI = AccessTools.DeclaredField(typeof(OrbHurtBoxReferenceObjectOverridePatch), "_target"); private static HurtBox _target; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__IL_GenericOrb_Begin; if (obj == null) { Manipulator val = IL_GenericOrb_Begin; <>O.<0>__IL_GenericOrb_Begin = val; obj = (object)val; } GenericDamageOrb.Begin += (Manipulator)obj; object obj2 = <>O.<0>__IL_GenericOrb_Begin; if (obj2 == null) { Manipulator val2 = IL_GenericOrb_Begin; <>O.<0>__IL_GenericOrb_Begin = val2; obj2 = (object)val2; } LightningOrb.Begin += (Manipulator)obj2; Orb_get_distanceToTarget.Apply(); } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__IL_GenericOrb_Begin; if (obj == null) { Manipulator val = IL_GenericOrb_Begin; <>O.<0>__IL_GenericOrb_Begin = val; obj = (object)val; } GenericDamageOrb.Begin -= (Manipulator)obj; object obj2 = <>O.<0>__IL_GenericOrb_Begin; if (obj2 == null) { Manipulator val2 = IL_GenericOrb_Begin; <>O.<0>__IL_GenericOrb_Begin = val2; obj2 = (object)val2; } LightningOrb.Begin -= (Manipulator)obj2; Orb_get_distanceToTarget.Undo(); } private static void IL_GenericOrb_Begin(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); int num2 = default(int); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchNewobj(x), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2) })) { int num = default(int); if (ILPatternMatchingExt.MatchStloc(array[1].Next, ref num)) { if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((EffectData _) => _.SetHurtBoxReference((HurtBox)null)))) })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Stsfld, _target_FI); int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Ldloc, num); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(EffectData effectData, Orb instance) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_target) && ProjectileRandomizerController.IsActive && overrideOrbTargetPosition.TryGetValue(instance, out var value)) { OrbTargetDummyObjectMarker marker = OrbTargetDummyObjectMarker.GetMarker(value, instance.duration); if (Object.op_Implicit((Object)(object)marker)) { effectData.SetHurtBoxReference(((Component)marker).gameObject); } } }); } else { Log.Warning("failed to find SetHurtBoxReference call", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\OrbEffectOverrideTarget\\OrbHurtBoxReferenceObjectOverridePatch.cs", "IL_GenericOrb_Begin", 85); } } } else { Log.Warning("failed to find EffectData local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\OrbEffectOverrideTarget\\OrbHurtBoxReferenceObjectOverridePatch.cs", "IL_GenericOrb_Begin", 91); } if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(Orb instance) { overrideOrbTargetPosition.Remove(instance); }); } else { Log.Warning("failed to end of method", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\OrbEffectOverrideTarget\\OrbHurtBoxReferenceObjectOverridePatch.cs", "IL_GenericOrb_Begin", 104); } } } } namespace RoR2Randomizer.Patches.MultiEntityStatePatches { [PatchClass] public static class EntityStateExitOnDestroy { [CompilerGenerated] private static class <>O { public static hook_Destroy <0>__EntityState_Destroy; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EntityState_Destroy; if (obj == null) { hook_Destroy val = EntityState_Destroy; <>O.<0>__EntityState_Destroy = val; obj = (object)val; } EntityState.Destroy += (hook_Destroy)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EntityState_Destroy; if (obj == null) { hook_Destroy val = EntityState_Destroy; <>O.<0>__EntityState_Destroy = val; obj = (object)val; } EntityState.Destroy -= (hook_Destroy)obj; } private static void EntityState_Destroy(orig_Destroy orig, Object obj) { if (Object.op_Implicit(obj)) { GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); EntityStateMachine val2 = default(EntityStateMachine); if (val != null && val.TryGetComponent(ref val2) && val2.state is MultiEntityState multiEntityState) { if (!multiEntityState.IsWaitingForForceExitDestruction) { IEnumerable source = from f in new StackTrace().GetFrames() select f.GetMethod() into m where m != null && m.IsVirtual && typeof(EntityState).IsAssignableFrom(m.DeclaringType) select m; IEnumerable collection = from m in source where m.Name == "OnExit" select m.DeclaringType; IEnumerable collection2 = from m in source where m.Name == "OnEnter" select m.DeclaringType; multiEntityState.forceExit(new HashSet(collection), new HashSet(collection2)); } return; } } orig.Invoke(obj); } } [PatchClass] public static class SetStateOuterPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__setOuterHook; } private static readonly FieldInfo _tempStackField_FI = AccessTools.DeclaredField(typeof(SetStateOuterPatch), "_tempStackField"); private static EntityStateMachine _tempStackField; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown object obj = <>O.<0>__setOuterHook; if (obj == null) { Manipulator val = setOuterHook; <>O.<0>__setOuterHook = val; obj = (object)val; } EntityStateMachine.Awake += (Manipulator)obj; object obj2 = <>O.<0>__setOuterHook; if (obj2 == null) { Manipulator val2 = setOuterHook; <>O.<0>__setOuterHook = val2; obj2 = (object)val2; } EntityStateMachine.SetState += (Manipulator)obj2; object obj3 = <>O.<0>__setOuterHook; if (obj3 == null) { Manipulator val3 = setOuterHook; <>O.<0>__setOuterHook = val3; obj3 = (object)val3; } NetworkStateMachine.HandleSetEntityState += (Manipulator)obj3; object obj4 = <>O.<0>__setOuterHook; if (obj4 == null) { Manipulator val4 = setOuterHook; <>O.<0>__setOuterHook = val4; obj4 = (object)val4; } NetworkStateMachine.OnDeserialize += (Manipulator)obj4; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown object obj = <>O.<0>__setOuterHook; if (obj == null) { Manipulator val = setOuterHook; <>O.<0>__setOuterHook = val; obj = (object)val; } EntityStateMachine.Awake -= (Manipulator)obj; object obj2 = <>O.<0>__setOuterHook; if (obj2 == null) { Manipulator val2 = setOuterHook; <>O.<0>__setOuterHook = val2; obj2 = (object)val2; } EntityStateMachine.SetState -= (Manipulator)obj2; object obj3 = <>O.<0>__setOuterHook; if (obj3 == null) { Manipulator val3 = setOuterHook; <>O.<0>__setOuterHook = val3; obj3 = (object)val3; } NetworkStateMachine.HandleSetEntityState -= (Manipulator)obj3; object obj4 = <>O.<0>__setOuterHook; if (obj4 == null) { Manipulator val4 = setOuterHook; <>O.<0>__setOuterHook = val4; obj4 = (object)val4; } NetworkStateMachine.OnDeserialize -= (Manipulator)obj4; } private static void setOuterHook(ILContext il) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) object obj; if (il == null) { obj = null; } else { MethodDefinition method = il.Method; obj = ((method != null) ? ((MemberReference)method).Name : null); } if (obj == null) { obj = "null"; } string text = "(" + (string?)obj + ") "; ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "outer") })) { val.Emit(OpCodes.Stsfld, _tempStackField_FI); val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldsfld, _tempStackField_FI); int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Action)delegate(EntityState state) { if (state is MultiEntityState multiEntityState) { multiEntityState.OnOuterStateMachineAssigned(); } }); num++; } if (num == 0) { Log.Warning(text + "no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\MultiEntityStatePatches\\SetStateOuterPatch.cs", "setOuterHook", 70); } } } [PatchClass] public static class InitializeMultiStatePatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__CharacterDeathBehavior_OnDeath; public static Action <1>__tryInitializeMultiState; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterDeathBehavior_OnDeath; if (obj == null) { Manipulator val = CharacterDeathBehavior_OnDeath; <>O.<0>__CharacterDeathBehavior_OnDeath = val; obj = (object)val; } CharacterDeathBehavior.OnDeath += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterDeathBehavior_OnDeath; if (obj == null) { Manipulator val = CharacterDeathBehavior_OnDeath; <>O.<0>__CharacterDeathBehavior_OnDeath = val; obj = (object)val; } CharacterDeathBehavior.OnDeath -= (Manipulator)obj; } private static void CharacterDeathBehavior_OnDeath(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => EntityStateCatalog.InstantiateState((EntityStateIndex)0)))) })) { int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)tryInitializeMultiState); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\MultiEntityStatePatches\\SetSubStatesPatch.cs", "CharacterDeathBehavior_OnDeath", 38); } } private static void tryInitializeMultiState(EntityState state, Component subStateDataHolder) { MultiEntityState.StateMachineSubStatesData data = default(MultiEntityState.StateMachineSubStatesData); if (state is MultiEntityState multiEntityState && subStateDataHolder.TryGetComponent(ref data)) { multiEntityState.Initialize(data); } } } } namespace RoR2Randomizer.Patches.ModInfoMessage { [PatchClass] internal static class ShowModInfoMessagePatch { [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__BaseMainMenuScreen_OnEnter; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__3_0; internal void b__3_0() { ConfigManager.Metadata.DisplayModInfoOnStart.Entry.Value = false; _isShowingModInfo = false; } } private static bool _isShowingModInfo; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BaseMainMenuScreen_OnEnter; if (obj == null) { hook_OnEnter val = BaseMainMenuScreen_OnEnter; <>O.<0>__BaseMainMenuScreen_OnEnter = val; obj = (object)val; } BaseMainMenuScreen.OnEnter += (hook_OnEnter)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BaseMainMenuScreen_OnEnter; if (obj == null) { hook_OnEnter val = BaseMainMenuScreen_OnEnter; <>O.<0>__BaseMainMenuScreen_OnEnter = val; obj = (object)val; } BaseMainMenuScreen.OnEnter -= (hook_OnEnter)obj; } private static void BaseMainMenuScreen_OnEnter(orig_OnEnter orig, BaseMainMenuScreen self, MainMenuController mainMenuController) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)mainMenuController) && (Object)(object)self == (Object)(object)mainMenuController.titleMenuScreen && (bool)ConfigManager.Metadata.DisplayModInfoOnStart && !_isShowingModInfo) { _isShowingModInfo = true; SimpleDialogBox obj = SimpleDialogBox.Create((MPEventSystem)null); obj.headerToken = new TokenParamsPair("Gorakh.RoR2Randomizer_MOD_INFO_POPUP_HEADER", Array.Empty()); obj.descriptionToken = new TokenParamsPair("Gorakh.RoR2Randomizer_MOD_INFO_POPUP_DESCRIPTION", Array.Empty()); object obj2 = <>c.<>9__3_0; if (obj2 == null) { UnityAction val = delegate { ConfigManager.Metadata.DisplayModInfoOnStart.Entry.Value = false; _isShowingModInfo = false; }; <>c.<>9__3_0 = val; obj2 = (object)val; } obj.AddActionButton((UnityAction)obj2, "Gorakh.RoR2Randomizer_MOD_INFO_POPUP_DISMISS", true, Array.Empty()); } orig.Invoke(self, mainMenuController); } } } namespace RoR2Randomizer.Patches.Item { [PatchClass] internal static class MonsterUseEquipmentDummyItemHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__AddAutoCastEquipmentItemCount; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__AddAutoCastEquipmentItemCount; if (obj == null) { Manipulator val = AddAutoCastEquipmentItemCount; <>O.<0>__AddAutoCastEquipmentItemCount = val; obj = (object)val; } BaseGoldGatState.FixedUpdate += (Manipulator)obj; object obj2 = <>O.<0>__AddAutoCastEquipmentItemCount; if (obj2 == null) { Manipulator val2 = AddAutoCastEquipmentItemCount; <>O.<0>__AddAutoCastEquipmentItemCount = val2; obj2 = (object)val2; } EquipmentSlot.FixedUpdate += (Manipulator)obj2; object obj3 = <>O.<0>__AddAutoCastEquipmentItemCount; if (obj3 == null) { Manipulator val3 = AddAutoCastEquipmentItemCount; <>O.<0>__AddAutoCastEquipmentItemCount = val3; obj3 = (object)val3; } EquipmentIcon.SetDisplayData += (Manipulator)obj3; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__AddAutoCastEquipmentItemCount; if (obj == null) { Manipulator val = AddAutoCastEquipmentItemCount; <>O.<0>__AddAutoCastEquipmentItemCount = val; obj = (object)val; } BaseGoldGatState.FixedUpdate -= (Manipulator)obj; object obj2 = <>O.<0>__AddAutoCastEquipmentItemCount; if (obj2 == null) { Manipulator val2 = AddAutoCastEquipmentItemCount; <>O.<0>__AddAutoCastEquipmentItemCount = val2; obj2 = (object)val2; } EquipmentSlot.FixedUpdate -= (Manipulator)obj2; object obj3 = <>O.<0>__AddAutoCastEquipmentItemCount; if (obj3 == null) { Manipulator val3 = AddAutoCastEquipmentItemCount; <>O.<0>__AddAutoCastEquipmentItemCount = val3; obj3 = (object)val3; } EquipmentIcon.SetDisplayData -= (Manipulator)obj3; } private static void AddAutoCastEquipmentItemCount(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); while (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "AutoCastEquipment"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GetItemCountEffective((ItemDef)null)))) })) { array[0].Emit(OpCodes.Dup); foreach (ILLabel incomingLabel in array[0].IncomingLabels) { incomingLabel.Target = array[0].Previous; } ILCursor val2 = array[1]; int index = val2.Index; val2.Index = index + 1; val2.EmitDelegate>((Func)((Inventory inventory, int autoCastEquipmentItemCount) => autoCastEquipmentItemCount + inventory.GetItemCountEffective(ContentPackManager.Items.MonsterUseEquipmentDummyItem))); val.Index = val2.Index + 1; } } } } namespace RoR2Randomizer.Patches.ItemRandomizer { [PatchClass] internal static class CaptainDefenseMatrix_GenericPickupPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__CaptainDefenseMatrixController_TryGrantItem; public static Manipulator <1>__CaptainDefenseMatrixController_OnServerMasterSummonGlobal; } private static PickupIndex _defenseMatrixPickupIndex; private static readonly FieldInfo _temporaryInventoryStorage_FI = AccessTools.DeclaredField(typeof(CaptainDefenseMatrix_GenericPickupPatch), "_temporaryInventoryStorage"); private static Inventory _temporaryInventoryStorage; private static readonly MethodInfo getReplacementDefenseMatrixItemDef_MI = AccessTools.DeclaredMethod(typeof(CaptainDefenseMatrix_GenericPickupPatch), "getReplacementDefenseMatrixItemDef", (Type[])null, (Type[])null); private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__CaptainDefenseMatrixController_TryGrantItem; if (obj == null) { Manipulator val = CaptainDefenseMatrixController_TryGrantItem; <>O.<0>__CaptainDefenseMatrixController_TryGrantItem = val; obj = (object)val; } CaptainDefenseMatrixController.TryGrantItem += (Manipulator)obj; object obj2 = <>O.<1>__CaptainDefenseMatrixController_OnServerMasterSummonGlobal; if (obj2 == null) { Manipulator val2 = CaptainDefenseMatrixController_OnServerMasterSummonGlobal; <>O.<1>__CaptainDefenseMatrixController_OnServerMasterSummonGlobal = val2; obj2 = (object)val2; } CaptainDefenseMatrixController.OnServerMasterSummonGlobal += (Manipulator)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__CaptainDefenseMatrixController_TryGrantItem; if (obj == null) { Manipulator val = CaptainDefenseMatrixController_TryGrantItem; <>O.<0>__CaptainDefenseMatrixController_TryGrantItem = val; obj = (object)val; } CaptainDefenseMatrixController.TryGrantItem -= (Manipulator)obj; object obj2 = <>O.<1>__CaptainDefenseMatrixController_OnServerMasterSummonGlobal; if (obj2 == null) { Manipulator val2 = CaptainDefenseMatrixController_OnServerMasterSummonGlobal; <>O.<1>__CaptainDefenseMatrixController_OnServerMasterSummonGlobal = val2; obj2 = (object)val2; } CaptainDefenseMatrixController.OnServerMasterSummonGlobal -= (Manipulator)obj2; } [SystemInitializer(new Type[] { typeof(PickupCatalog), typeof(ItemCatalog) })] private static void InitPickupIndices() { //IL_0005: 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_000f: Unknown result type (might be due to invalid IL or missing references) _defenseMatrixPickupIndex = PickupCatalog.FindPickupIndex(Items.CaptainDefenseMatrix.itemIndex); } private static bool tryGrantReplacementPickup(Inventory inventory, int defaultCount) { if (!Object.op_Implicit((Object)(object)inventory) || !((PickupIndex)(ref _defenseMatrixPickupIndex)).isValid) { return false; } if (!ItemRandomizerController.TryGetReplacementPickupIndex(in _defenseMatrixPickupIndex, out var replacement)) { return false; } PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (pickupDef == null || pickupDef.IsItem()) { return false; } int count = (pickupDef.IsEquipment() ? 1 : defaultCount); bool result = pickupDef.TryGrantTo(inventory, count, forceOverrideEquipment: true); ItemRandomizerController.HandleCharacterGrantedRandomizedEquipment(((Component)inventory).GetComponent()); return result; } private static ItemDef getReplacementDefenseMatrixItemDef(ItemDef defenseMatrixItemDef) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)defenseMatrixItemDef)) { return defenseMatrixItemDef; } PickupIndex original = PickupCatalog.FindPickupIndex(defenseMatrixItemDef.itemIndex); if (!((PickupIndex)(ref original)).isValid) { return defenseMatrixItemDef; } if (!ItemRandomizerController.TryGetReplacementPickupIndex(in original, out var replacement)) { return defenseMatrixItemDef; } PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (!pickupDef.IsItem()) { Log.Warning("TryGrant returned false, but replacement is not an item, using original item", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\CaptainDefenseMatrix_GenericPickupPatch.cs", "getReplacementDefenseMatrixItemDef", 88); return defenseMatrixItemDef; } ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if (Object.op_Implicit((Object)(object)itemDef)) { return itemDef; } return defenseMatrixItemDef; } private static void CaptainDefenseMatrixController_OnServerMasterSummonGlobal(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00e7: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "CaptainDefenseMatrix"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GiveItemPermanent((ItemDef)null, 0)))) })) { ILCursor obj = array[0]; obj.Emit(OpCodes.Stsfld, _temporaryInventoryStorage_FI).Emit(OpCodes.Ldsfld, _temporaryInventoryStorage_FI); obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Func)((Inventory inventory, CaptainDefenseMatrixController instance) => tryGrantReplacementPickup(inventory, instance.defenseMatrixToGrantMechanicalAllies))); ILLabel val = il.DefineLabel(); obj.Emit(OpCodes.Brtrue, (object)val); obj.Emit(OpCodes.Ldsfld, _temporaryInventoryStorage_FI); int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Call, (MethodBase)getReplacementDefenseMatrixItemDef_MI); obj.Index = array[1].Index + 1; obj.MarkLabel(val); } else { Log.Error("Failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\CaptainDefenseMatrix_GenericPickupPatch.cs", "CaptainDefenseMatrixController_OnServerMasterSummonGlobal", 139); } } private static void CaptainDefenseMatrixController_TryGrantItem(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "CaptainDefenseMatrix"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GetItemCountEffective((ItemDef)null)))) })) { ILCursor val2 = array[0]; val2.Emit(OpCodes.Stsfld, _temporaryInventoryStorage_FI).Emit(OpCodes.Ldsfld, _temporaryInventoryStorage_FI); val2 = array[1]; ILCursor obj = val2; int index = obj.Index; obj.Index = index + 1; val2.Emit(OpCodes.Ldsfld, _temporaryInventoryStorage_FI); val2.EmitDelegate>((Func)delegate(int defenseMatrixItemCount, Inventory inventory) { if (!Object.op_Implicit((Object)(object)inventory) || !((PickupIndex)(ref _defenseMatrixPickupIndex)).isValid) { return defenseMatrixItemCount; } PickupIndex replacement; return (!ItemRandomizerController.TryGetReplacementPickupIndex(in _defenseMatrixPickupIndex, out replacement)) ? defenseMatrixItemCount : inventory.GetPickupCount(((PickupIndex)(ref replacement)).pickupDef); }); val.Index = val2.Index + 1; } else { Log.Error("Failed to find GetItemCount patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\CaptainDefenseMatrix_GenericPickupPatch.cs", "CaptainDefenseMatrixController_TryGrantItem", 178); } if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "CaptainDefenseMatrix"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GiveItemPermanent((ItemDef)null, 0)))) })) { ILCursor obj2 = array[0]; obj2.Emit(OpCodes.Stsfld, _temporaryInventoryStorage_FI).Emit(OpCodes.Ldsfld, _temporaryInventoryStorage_FI); obj2.Emit(OpCodes.Ldarg_0); obj2.EmitDelegate>((Func)((Inventory inventory, CaptainDefenseMatrixController instance) => tryGrantReplacementPickup(inventory, instance.defenseMatrixToGrantPlayer))); ILLabel val3 = il.DefineLabel(); obj2.Emit(OpCodes.Brtrue, (object)val3); obj2.Emit(OpCodes.Ldsfld, _temporaryInventoryStorage_FI); int index = obj2.Index; obj2.Index = index + 1; obj2.Emit(OpCodes.Call, (MethodBase)getReplacementDefenseMatrixItemDef_MI); ILCursor obj3 = array[1]; index = obj3.Index; obj3.Index = index + 1; obj3.MarkLabel(val3); } else { Log.Error("Failed to find GiveItem patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\CaptainDefenseMatrix_GenericPickupPatch.cs", "CaptainDefenseMatrixController_TryGrantItem", 212); } } } [PatchClass] internal static class EvolutionArtifactGenericPickupFix { [CompilerGenerated] private static class <>O { public static Manipulator <0>__MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem; public static hook_OnServerCardSpawnedGlobal <1>__MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem; if (obj == null) { Manipulator val = MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem; <>O.<0>__MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem = val; obj = (object)val; } MonsterTeamGainsItemsArtifactManager.GrantMonsterTeamItem += (Manipulator)obj; object obj2 = <>O.<1>__MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal; if (obj2 == null) { hook_OnServerCardSpawnedGlobal val2 = MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal; <>O.<1>__MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal = val2; obj2 = (object)val2; } MonsterTeamGainsItemsArtifactManager.OnServerCardSpawnedGlobal += (hook_OnServerCardSpawnedGlobal)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem; if (obj == null) { Manipulator val = MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem; <>O.<0>__MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem = val; obj = (object)val; } MonsterTeamGainsItemsArtifactManager.GrantMonsterTeamItem -= (Manipulator)obj; object obj2 = <>O.<1>__MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal; if (obj2 == null) { hook_OnServerCardSpawnedGlobal val2 = MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal; <>O.<1>__MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal = val2; obj2 = (object)val2; } MonsterTeamGainsItemsArtifactManager.OnServerCardSpawnedGlobal -= (hook_OnServerCardSpawnedGlobal)obj2; } private static void MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int pickupDefLocalIndex = -1; ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => PickupCatalog.GetPickupDef(default(PickupIndex))))), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref pickupDefLocalIndex) })) { ILLabel skipGiveItemLabel = null; if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, pickupDefLocalIndex), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref skipGiveItemLabel) })) { ILCursor obj = array[1]; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Ldloc, pickupDefLocalIndex); obj.EmitDelegate>((Func)((PickupDef pickup) => pickup != null && !pickup.IsItem() && pickup.TryGrantTo(MonsterTeamGainsItemsArtifactManager.monsterTeamInventory, 1, forceOverrideEquipment: true))); obj.Emit(OpCodes.Brtrue, (object)skipGiveItemLabel); } } else { Log.Error("Unable to find pickupDef local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\EvolutionArtifactGenericPickupFix.cs", "MonsterTeamGainsItemsArtifactManager_GrantMonsterTeamItem", 66); } } private static void MonsterTeamGainsItemsArtifactManager_OnServerCardSpawnedGlobal(orig_OnServerCardSpawnedGlobal orig, SpawnResult spawnResult) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 orig.Invoke(spawnResult); CharacterMaster val = default(CharacterMaster); if (Object.op_Implicit((Object)(object)spawnResult.spawnedInstance) && spawnResult.spawnedInstance.TryGetComponent(ref val) && (int)val.teamIndex == 2) { val.inventory.CopyEquipmentFrom(MonsterTeamGainsItemsArtifactManager.monsterTeamInventory); ItemRandomizerController.HandleCharacterGrantedRandomizedEquipment(val); } } } [PatchClass] internal static class FuelArrayItemCostPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__FuelArrayCostType_IsAffordable_IL; public static Func, object, CostTypeDef, IsAffordableContext, bool> <1>__FuelArrayCostType_IsAffordable_On; public static Action, PayCostContext, PayCostResults> <2>__FuelArrayCostType_PayCost; } private static CostTypeDef _fuelArrayCostType; private static Hook _fuelArrayPayCost_OnHook; private static Hook _fuelArrayIsAffordable_OnHook; private static ILHook _fuelArrayIsAffordable_ILHook; private static PickupIndex _fuelArrayPickupIndex; private static bool _patchActive; [SystemInitializer(new Type[] { typeof(CostTypeCatalog) })] private static void InitCostTypeHooks() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_007c: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown _fuelArrayCostType = CostTypeCatalog.GetCostTypeDef((CostTypeIndex)8); MethodInfo method = ((Delegate)(object)_fuelArrayCostType.isAffordable).Method; object obj = <>O.<0>__FuelArrayCostType_IsAffordable_IL; if (obj == null) { Manipulator val = FuelArrayCostType_IsAffordable_IL; <>O.<0>__FuelArrayCostType_IsAffordable_IL = val; obj = (object)val; } _fuelArrayIsAffordable_ILHook = new ILHook((MethodBase)method, (Manipulator)obj, new ILHookConfig { ManualApply = true }); _fuelArrayIsAffordable_OnHook = new Hook((MethodBase)((Delegate)(object)_fuelArrayCostType.isAffordable).Method, (Delegate)new Func, object, CostTypeDef, IsAffordableContext, bool>(FuelArrayCostType_IsAffordable_On), new HookConfig { ManualApply = true }); _fuelArrayPayCost_OnHook = new Hook((MethodBase)((Delegate)(object)_fuelArrayCostType.payCost).Method, (Delegate)new Action, PayCostContext, PayCostResults>(FuelArrayCostType_PayCost), new HookConfig { ManualApply = true }); if (_patchActive) { _fuelArrayIsAffordable_OnHook.Apply(); _fuelArrayIsAffordable_ILHook.Apply(); _fuelArrayPayCost_OnHook.Apply(); } } [SystemInitializer(new Type[] { typeof(PickupCatalog), typeof(EquipmentCatalog) })] private static void InitFuelArrayPickupIndex() { //IL_0005: 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_000f: Unknown result type (might be due to invalid IL or missing references) _fuelArrayPickupIndex = PickupCatalog.FindPickupIndex(Equipment.QuestVolatileBattery.equipmentIndex); } private static void Apply() { ILHook fuelArrayIsAffordable_ILHook = _fuelArrayIsAffordable_ILHook; if (fuelArrayIsAffordable_ILHook != null) { fuelArrayIsAffordable_ILHook.Apply(); } Hook fuelArrayIsAffordable_OnHook = _fuelArrayIsAffordable_OnHook; if (fuelArrayIsAffordable_OnHook != null) { fuelArrayIsAffordable_OnHook.Apply(); } Hook fuelArrayPayCost_OnHook = _fuelArrayPayCost_OnHook; if (fuelArrayPayCost_OnHook != null) { fuelArrayPayCost_OnHook.Apply(); } _patchActive = true; } private static void Cleanup() { ILHook fuelArrayIsAffordable_ILHook = _fuelArrayIsAffordable_ILHook; if (fuelArrayIsAffordable_ILHook != null) { fuelArrayIsAffordable_ILHook.Undo(); } Hook fuelArrayIsAffordable_OnHook = _fuelArrayIsAffordable_OnHook; if (fuelArrayIsAffordable_OnHook != null) { fuelArrayIsAffordable_OnHook.Undo(); } Hook fuelArrayPayCost_OnHook = _fuelArrayPayCost_OnHook; if (fuelArrayPayCost_OnHook != null) { fuelArrayPayCost_OnHook.Undo(); } _patchActive = false; } private static void FuelArrayCostType_PayCost(Action orig, PayCostContext context, PayCostResults result) { if (((PickupIndex)(ref _fuelArrayPickupIndex)).isValid && ItemRandomizerController.TryGetReplacementPickupIndex(in _fuelArrayPickupIndex, out var replacement)) { PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (pickupDef != null && !pickupDef.IsEquipment()) { CharacterMaster activatorMaster = context.activatorMaster; if (Object.op_Implicit((Object)(object)activatorMaster)) { pickupDef.TryDeductFrom(activatorMaster); MultiShopCardUtils.OnNonMoneyPurchase(context); } return; } } orig(context, result); } private static bool FuelArrayCostType_IsAffordable_On(Func orig, object self, CostTypeDef costTypeDef, IsAffordableContext context) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if (((PickupIndex)(ref _fuelArrayPickupIndex)).isValid && ItemRandomizerController.TryGetReplacementPickupIndex(in _fuelArrayPickupIndex, out var replacement)) { PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (pickupDef != null && !pickupDef.IsEquipment()) { CharacterBody component = ((Component)context.activator).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { return component.inventory.GetPickupCount(pickupDef) >= context.cost; } } } return orig(self, costTypeDef, context); } private static void FuelArrayCostType_IsAffordable_IL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Equipment), "QuestVolatileBattery"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EquipmentDef), "equipmentIndex")) })) { ILCursor obj = array[1]; int index = obj.Index; obj.Index = index + 1; obj.EmitDelegate>((Func)delegate(EquipmentIndex fuelArrayEquipmentIndex) { //IL_000c: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!((PickupIndex)(ref _fuelArrayPickupIndex)).isValid) { return fuelArrayEquipmentIndex; } if (!ItemRandomizerController.TryGetReplacementPickupIndex(in _fuelArrayPickupIndex, out var replacement)) { return fuelArrayEquipmentIndex; } PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (pickupDef.IsEquipment()) { return pickupDef.equipmentIndex; } Log.Warning("IL Hook ran, but replacement pickup is not an equipment, using default equipment index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\FuelArrayItemCostPatch.cs", "FuelArrayCostType_IsAffordable_IL", 141); return fuelArrayEquipmentIndex; }); } else { Log.Error("Failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\FuelArrayItemCostPatch.cs", "FuelArrayCostType_IsAffordable_IL", 148); } } } [PatchClass] internal static class InfiniteTower_GenericPickupFix { [CompilerGenerated] private static class <>O { public static Manipulator <0>__InfiniteTowerRun_AdvanceWave; public static hook_OnCombatSquadMemberDiscovered <1>__InfiniteTowerWaveController_OnCombatSquadMemberDiscovered; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__InfiniteTowerRun_AdvanceWave; if (obj == null) { Manipulator val = InfiniteTowerRun_AdvanceWave; <>O.<0>__InfiniteTowerRun_AdvanceWave = val; obj = (object)val; } InfiniteTowerRun.AdvanceWave += (Manipulator)obj; object obj2 = <>O.<1>__InfiniteTowerWaveController_OnCombatSquadMemberDiscovered; if (obj2 == null) { hook_OnCombatSquadMemberDiscovered val2 = InfiniteTowerWaveController_OnCombatSquadMemberDiscovered; <>O.<1>__InfiniteTowerWaveController_OnCombatSquadMemberDiscovered = val2; obj2 = (object)val2; } InfiniteTowerWaveController.OnCombatSquadMemberDiscovered += (hook_OnCombatSquadMemberDiscovered)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__InfiniteTowerRun_AdvanceWave; if (obj == null) { Manipulator val = InfiniteTowerRun_AdvanceWave; <>O.<0>__InfiniteTowerRun_AdvanceWave = val; obj = (object)val; } InfiniteTowerRun.AdvanceWave -= (Manipulator)obj; object obj2 = <>O.<1>__InfiniteTowerWaveController_OnCombatSquadMemberDiscovered; if (obj2 == null) { hook_OnCombatSquadMemberDiscovered val2 = InfiniteTowerWaveController_OnCombatSquadMemberDiscovered; <>O.<1>__InfiniteTowerWaveController_OnCombatSquadMemberDiscovered = val2; obj2 = (object)val2; } InfiniteTowerWaveController.OnCombatSquadMemberDiscovered -= (hook_OnCombatSquadMemberDiscovered)obj2; } private static void InfiniteTowerWaveController_OnCombatSquadMemberDiscovered(orig_OnCombatSquadMemberDiscovered orig, InfiniteTowerWaveController self, CharacterMaster master) { orig.Invoke(self, master); if (NetworkServer.active) { master.inventory.CopyEquipmentFrom(self.enemyInventory); ItemRandomizerController.HandleCharacterGrantedRandomizedEquipment(master); } } private static void InfiniteTowerRun_AdvanceWave(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int enemyItemEntryLocalIndex = -1; ILCursor[] array = default(ILCursor[]); if (!val.TryFindNext(ref array, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "enemyItemPattern"), (Instruction x) => ILPatternMatchingExt.MatchLdelemAny(x), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref enemyItemEntryLocalIndex) })) { Log.Error("Failed to find enemyItemEntry local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\InfiniteTower_GenericPickupFix.cs", "InfiniteTowerRun_AdvanceWave", 57); return; } int pickupDefLocalIndex = -1; ILLabel val4 = default(ILLabel); if (!val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => PickupCatalog.GetPickupDef(default(PickupIndex))))), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref pickupDefLocalIndex) })) { Log.Error("Failed to find pickupDef local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\InfiniteTower_GenericPickupFix.cs", "InfiniteTowerRun_AdvanceWave", 72); } else if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, pickupDefLocalIndex), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val4) })) { ILCursor val2 = array[1]; int index = val2.Index; val2.Index = index + 1; val2.Emit(OpCodes.Ldloc, enemyItemEntryLocalIndex); val2.Emit(OpCodes.Ldloc, pickupDefLocalIndex); val2.Emit(OpCodes.Ldarg_0); val2.EmitDelegate>((Func)((EnemyItemEntry itemEntry, PickupDef pickup, InfiniteTowerRun instance) => pickup != null && !pickup.IsItem() && PickupExtensions.TryGrantTo(count: pickup.IsEquipment() ? 1 : itemEntry.stacks, pickupDef: pickup, inventory: instance.enemyInventory, forceOverrideEquipment: true))); ILLabel val3 = il.DefineLabel(); val2.Emit(OpCodes.Brtrue, (object)val3); if (val2.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GiveItemPermanent((ItemIndex)0, 0)))) })) { val2.MarkLabel(val3); } else { Log.Error($"Failed to find {val3} target", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\InfiniteTower_GenericPickupFix.cs", "InfiniteTowerRun_AdvanceWave", 118); } } else { Log.Error("Failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\InfiniteTower_GenericPickupFix.cs", "InfiniteTowerRun_AdvanceWave", 124); } } } [PatchClass] internal static class NonPlayerEquipmentSlotRNGPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__EquipmentSlot_Start; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EquipmentSlot_Start; if (obj == null) { Manipulator val = EquipmentSlot_Start; <>O.<0>__EquipmentSlot_Start = val; obj = (object)val; } EquipmentSlot.Start += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EquipmentSlot_Start; if (obj == null) { Manipulator val = EquipmentSlot_Start; <>O.<0>__EquipmentSlot_Start = val; obj = (object)val; } EquipmentSlot.Start -= (Manipulator)obj; } private static void EquipmentSlot_Start(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchNewobj(x) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(ulong seed, EquipmentSlot instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) CharacterBody characterBody = instance.characterBody; if (Object.op_Implicit((Object)(object)characterBody) && !characterBody.isPlayerControlled) { ulong num = seed; NetworkInstanceId netId = ((NetworkBehaviour)instance).netId; seed = num ^ ((NetworkInstanceId)(ref netId)).Value; } return seed; }); } else { Log.Error("Failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\NonPlayerEquipmentSlotRNGPatch.cs", "EquipmentSlot_Start", 43); } } } [PatchClass] internal static class ObsoleteChestRoll_ItemHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ChestBehavior_PickFromList; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ChestBehavior_PickFromList; if (obj == null) { Manipulator val = ChestBehavior_PickFromList; <>O.<0>__ChestBehavior_PickFromList = val; obj = (object)val; } ChestBehavior.PickFromList += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ChestBehavior_PickFromList; if (obj == null) { Manipulator val = ChestBehavior_PickFromList; <>O.<0>__ChestBehavior_PickFromList = val; obj = (object)val; } ChestBehavior.PickFromList -= (Manipulator)obj; } private static void ChestBehavior_PickFromList(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ILCursor val = new ILCursor(il); MethodInfo currentPickupSetter = AccessTools.DeclaredPropertySetter(typeof(ChestBehavior), "currentPickup"); while (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)currentPickupSetter) })) { val.EmitDelegate>((Func)delegate(UniquePickup pickup) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!((PickupIndex)(ref pickup.pickupIndex)).isValid) { return pickup; } UniquePickup result = default(UniquePickup); ((UniquePickup)(ref result))..ctor(ItemRandomizerController.GetReplacementPickupIndex(pickup.pickupIndex)); result.decayValue = pickup.decayValue; return result; }); int index = val.Index; val.Index = index + 1; } } } [PatchClass] internal static class PickupDropletController_PickupRandomizeHook { [CompilerGenerated] private static class <>O { public static hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 <0>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3; } private static readonly FieldInfo _patchEnabled_FI = AccessTools.DeclaredField(typeof(PickupDropletController_PickupRandomizeHook), "_patchEnabled"); private static bool _patchEnabled = false; private static readonly MethodInfo PickupDropletController_CreatePickupDroplet_PickupIndex_MI = SymbolExtensions.GetMethodInfo((Expression)(() => PickupDropletController.CreatePickupDroplet(default(PickupIndex), default(Vector3), default(Vector3)))); private static readonly MethodInfo PickupDropletController_CreatePickupDroplet_CreatePickupInfo_MI = SymbolExtensions.GetMethodInfo((Expression)(() => PickupDropletController.CreatePickupDroplet(default(CreatePickupInfo), default(Vector3), default(Vector3)))); internal static readonly Manipulator GenericEnablePatchHook = (Manipulator)delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)PickupDropletController_CreatePickupDroplet_PickupIndex_MI) || ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)PickupDropletController_CreatePickupDroplet_CreatePickupInfo_MI) })) { val.Emit(OpCodes.Ldc_I4_1); val.Emit(OpCodes.Stsfld, _patchEnabled_FI); int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Stsfld, _patchEnabled_FI); } }; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3; if (obj == null) { hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val = PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3; <>O.<0>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 = val; obj = (object)val; } PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3; if (obj == null) { hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val = PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3; <>O.<0>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 = val; obj = (object)val; } PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 -= (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj; } private static void PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_000e: 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) if (_patchEnabled && ItemRandomizerController.TryGetReplacementPickupIndex(((CreatePickupInfo)(ref pickupInfo)).pickupIndex, out var replacement)) { ((CreatePickupInfo)(ref pickupInfo)).pickupIndex = replacement; } orig.Invoke(pickupInfo, position, velocity); } } [PatchClass] internal static class PickupDropTable_PickupIndexHook { [CompilerGenerated] private static class <>O { public static hook_GenerateDrop <0>__PickupDropTable_GenerateDrop; public static hook_GeneratePickup <1>__PickupDropTable_GeneratePickup; public static hook_GenerateUniqueDrops <2>__PickupDropTable_GenerateUniqueDrops; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__PickupDropTable_GenerateDrop; if (obj == null) { hook_GenerateDrop val = PickupDropTable_GenerateDrop; <>O.<0>__PickupDropTable_GenerateDrop = val; obj = (object)val; } PickupDropTable.GenerateDrop += (hook_GenerateDrop)obj; object obj2 = <>O.<1>__PickupDropTable_GeneratePickup; if (obj2 == null) { hook_GeneratePickup val2 = PickupDropTable_GeneratePickup; <>O.<1>__PickupDropTable_GeneratePickup = val2; obj2 = (object)val2; } PickupDropTable.GeneratePickup += (hook_GeneratePickup)obj2; object obj3 = <>O.<2>__PickupDropTable_GenerateUniqueDrops; if (obj3 == null) { hook_GenerateUniqueDrops val3 = PickupDropTable_GenerateUniqueDrops; <>O.<2>__PickupDropTable_GenerateUniqueDrops = val3; obj3 = (object)val3; } PickupDropTable.GenerateUniqueDrops += (hook_GenerateUniqueDrops)obj3; } private static UniquePickup PickupDropTable_GeneratePickup(orig_GeneratePickup orig, PickupDropTable self, Xoroshiro128Plus rng) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) UniquePickup val = orig.Invoke(self, rng); return new UniquePickup(ItemRandomizerController.GetReplacementPickupIndex(val.pickupIndex)); } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__PickupDropTable_GenerateDrop; if (obj == null) { hook_GenerateDrop val = PickupDropTable_GenerateDrop; <>O.<0>__PickupDropTable_GenerateDrop = val; obj = (object)val; } PickupDropTable.GenerateDrop -= (hook_GenerateDrop)obj; object obj2 = <>O.<1>__PickupDropTable_GeneratePickup; if (obj2 == null) { hook_GeneratePickup val2 = PickupDropTable_GeneratePickup; <>O.<1>__PickupDropTable_GeneratePickup = val2; obj2 = (object)val2; } PickupDropTable.GeneratePickup -= (hook_GeneratePickup)obj2; object obj3 = <>O.<2>__PickupDropTable_GenerateUniqueDrops; if (obj3 == null) { hook_GenerateUniqueDrops val3 = PickupDropTable_GenerateUniqueDrops; <>O.<2>__PickupDropTable_GenerateUniqueDrops = val3; obj3 = (object)val3; } PickupDropTable.GenerateUniqueDrops -= (hook_GenerateUniqueDrops)obj3; } private static PickupIndex PickupDropTable_GenerateDrop(orig_GenerateDrop orig, PickupDropTable self, Xoroshiro128Plus rng) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return ItemRandomizerController.GetReplacementPickupIndex(orig.Invoke(self, rng)); } private static PickupIndex[] PickupDropTable_GenerateUniqueDrops(orig_GenerateUniqueDrops orig, PickupDropTable self, int maxDrops, Xoroshiro128Plus rng) { //IL_0012: 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_001c: Unknown result type (might be due to invalid IL or missing references) PickupIndex[] array = orig.Invoke(self, maxDrops, rng); for (int i = 0; i < array.Length; i++) { array[i] = ItemRandomizerController.GetReplacementPickupIndex(array[i]); } return array; } } [PatchClass] internal static class RandomizeGenericCreatePickupHook { private static void Apply() { ScrappingToIdle.OnEnter += PickupDropletController_PickupRandomizeHook.GenericEnablePatchHook; GlobalEventManager.OnCharacterDeath += PickupDropletController_PickupRandomizeHook.GenericEnablePatchHook; } private static void Cleanup() { ScrappingToIdle.OnEnter -= PickupDropletController_PickupRandomizeHook.GenericEnablePatchHook; GlobalEventManager.OnCharacterDeath -= PickupDropletController_PickupRandomizeHook.GenericEnablePatchHook; } } [PatchClass] internal static class RandomizeGivePickupsOnStart { [CompilerGenerated] private static class <>O { public static hook_Start <0>__GivePickupsOnStart_Start; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GivePickupsOnStart_Start; if (obj == null) { hook_Start val = GivePickupsOnStart_Start; <>O.<0>__GivePickupsOnStart_Start = val; obj = (object)val; } GivePickupsOnStart.Start += (hook_Start)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GivePickupsOnStart_Start; if (obj == null) { hook_Start val = GivePickupsOnStart_Start; <>O.<0>__GivePickupsOnStart_Start = val; obj = (object)val; } GivePickupsOnStart.Start -= (hook_Start)obj; } private static void GivePickupsOnStart_Start(orig_Start orig, GivePickupsOnStart self) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Invalid comparison between Unknown and I4 //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) if (ItemRandomizerController.IsEnabled) { if (!Object.op_Implicit((Object)(object)self.equipmentDef) && !string.IsNullOrEmpty(self.equipmentString)) { EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(self.equipmentString); if ((int)val != -1) { self.equipmentDef = EquipmentCatalog.GetEquipmentDef(val); } else { Log.Warning("Unable to find equipment index with name \"" + self.equipmentString + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\RandomizeGivePickupsOnStart.cs", "GivePickupsOnStart_Start", 37); } } if (self.itemInfos.Length != 0) { List list = new List(self.itemInfos.Length); ItemInfo[] itemInfos = self.itemInfos; foreach (ItemInfo val2 in itemInfos) { ItemIndex val3 = ItemCatalog.FindItemIndex(val2.itemString); if ((int)val3 == -1) { Log.Warning("Unable to find item index with name \"" + val2.itemString + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\RandomizeGivePickupsOnStart.cs", "GivePickupsOnStart_Start", 50); continue; } list.Add(new ItemDefInfo { itemDef = ItemCatalog.GetItemDef(val3), count = val2.count, dontExceedCount = false }); } MiscUtils.AddItems(ref self.itemDefInfos, list); self.itemInfos = Array.Empty(); } int num = (Object.op_Implicit((Object)(object)self.equipmentDef) ? 1 : 0); PickupIndex[] array = (PickupIndex[])(object)new PickupIndex[num + self.itemDefInfos.Length]; if (Object.op_Implicit((Object)(object)self.equipmentDef)) { array[0] = ItemRandomizerController.GetReplacementPickupIndex(PickupCatalog.FindPickupIndex(self.equipmentDef.equipmentIndex)); } for (int j = 0; j < self.itemDefInfos.Length; j++) { array[num + j] = ItemRandomizerController.GetReplacementPickupIndex(PickupCatalog.FindPickupIndex(self.itemDefInfos[j].itemDef.itemIndex)); } self.equipmentDef = null; List list2 = new List(array.Length); for (int k = 0; k < array.Length; k++) { if (((PickupIndex)(ref array[k])).isValid) { PickupDef pickupDef = ((PickupIndex)(ref array[k])).pickupDef; if (pickupDef.IsItem()) { ItemDefInfo item = (ItemDefInfo)((!ArrayUtils.IsInBounds(self.itemDefInfos, k - num)) ? new ItemDefInfo { count = 1, dontExceedCount = false } : self.itemDefInfos[k - num]); item.itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); list2.Add(item); } else if (pickupDef.IsEquipment()) { self.equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); } else { Log.Warning($"Unimplemented pickup {pickupDef.pickupIndex}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\RandomizeGivePickupsOnStart.cs", "GivePickupsOnStart_Start", 116); } } } self.itemDefInfos = list2.ToArray(); } orig.Invoke(self); } } [PatchClass] internal static class ScavItemHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__IL_FindItem_OnEnter; public static hook_OnEnter <1>__On_FindItem_OnEnter; public static Manipulator <2>__GrantItem_GrantPickupServer; public static Manipulator <3>__ScavengerItemGranter_Start; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown object obj = <>O.<0>__IL_FindItem_OnEnter; if (obj == null) { Manipulator val = IL_FindItem_OnEnter; <>O.<0>__IL_FindItem_OnEnter = val; obj = (object)val; } FindItem.OnEnter += (Manipulator)obj; object obj2 = <>O.<1>__On_FindItem_OnEnter; if (obj2 == null) { hook_OnEnter val2 = On_FindItem_OnEnter; <>O.<1>__On_FindItem_OnEnter = val2; obj2 = (object)val2; } FindItem.OnEnter += (hook_OnEnter)obj2; object obj3 = <>O.<2>__GrantItem_GrantPickupServer; if (obj3 == null) { Manipulator val3 = GrantItem_GrantPickupServer; <>O.<2>__GrantItem_GrantPickupServer = val3; obj3 = (object)val3; } GrantItem.GrantPickupServer += (Manipulator)obj3; object obj4 = <>O.<3>__ScavengerItemGranter_Start; if (obj4 == null) { Manipulator val4 = ScavengerItemGranter_Start; <>O.<3>__ScavengerItemGranter_Start = val4; obj4 = (object)val4; } ScavengerItemGranter.Start += (Manipulator)obj4; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown object obj = <>O.<0>__IL_FindItem_OnEnter; if (obj == null) { Manipulator val = IL_FindItem_OnEnter; <>O.<0>__IL_FindItem_OnEnter = val; obj = (object)val; } FindItem.OnEnter -= (Manipulator)obj; object obj2 = <>O.<1>__On_FindItem_OnEnter; if (obj2 == null) { hook_OnEnter val2 = On_FindItem_OnEnter; <>O.<1>__On_FindItem_OnEnter = val2; obj2 = (object)val2; } FindItem.OnEnter -= (hook_OnEnter)obj2; object obj3 = <>O.<2>__GrantItem_GrantPickupServer; if (obj3 == null) { Manipulator val3 = GrantItem_GrantPickupServer; <>O.<2>__GrantItem_GrantPickupServer = val3; obj3 = (object)val3; } GrantItem.GrantPickupServer -= (Manipulator)obj3; object obj4 = <>O.<3>__ScavengerItemGranter_Start; if (obj4 == null) { Manipulator val4 = ScavengerItemGranter_Start; <>O.<3>__ScavengerItemGranter_Start = val4; obj4 = (object)val4; } ScavengerItemGranter.Start -= (Manipulator)obj4; } private static void On_FindItem_OnEnter(orig_OnEnter orig, FindItem self) { orig.Invoke(self); if (((PickupIndex)(ref self.dropPickup)).isValid && ((PickupIndex)(ref self.dropPickup)).pickupDef.IsEquipment()) { self.itemsToGrant = 1; } } private static void IL_FindItem_OnEnter(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "pickupDisplay"), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "dropPickup"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "SetPickupIndex") })) { ILCursor obj = array[2]; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Func)((PickupIndex dropPickup, FindItem instance) => (instance != null && ((EntityState)instance).isAuthority) ? (instance.dropPickup = ItemRandomizerController.GetReplacementPickupIndex(dropPickup)) : dropPickup)); } } private static void GrantItem_GrantPickupServer(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int pickupDefLocalIndex = -1; int itemIndexLocalIndex = -1; ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref pickupDefLocalIndex), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "itemIndex"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref itemIndexLocalIndex), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, itemIndexLocalIndex) })) { ILCursor val2 = array[3]; val2.Emit(OpCodes.Ldarg_0); val2.Emit(OpCodes.Ldloc, pickupDefLocalIndex); val2.Emit(OpCodes.Ldarg_2); val2.EmitDelegate>((Func)delegate(GrantItem instance, PickupDef pickupDef, int countToGrant) { if (instance == null || pickupDef == null) { return false; } if (pickupDef.IsItem()) { return false; } CharacterBody characterBody = ((EntityState)instance).characterBody; if (!Object.op_Implicit((Object)(object)characterBody)) { return false; } CharacterMaster master = characterBody.master; return Object.op_Implicit((Object)(object)master) && pickupDef.TryGrantTo(master, countToGrant); }); ILLabel val3 = val.DefineLabel(); val2.Emit(OpCodes.Brtrue, (object)val3); if (val2.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GiveItemPermanent((ItemIndex)0, 0)))) })) { val2.MarkLabel(val3); } else { Log.Warning("Failed to find skipGiveItemLabel location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ScavItemHook.cs", "GrantItem_GrantPickupServer", 118); } } else { Log.Warning("Failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ScavItemHook.cs", "GrantItem_GrantPickupServer", 123); } } private static void ScavengerItemGranter_Start(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int stackRollDataLocalIndex = -1; ILCursor[] array = default(ILCursor[]); int num = default(int); if (!val.TryFindNext(ref array, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdelemAny(x), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref stackRollDataLocalIndex) })) { Log.Error("Failed to find stackRollData local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ScavItemHook.cs", "ScavengerItemGranter_Start", 146); return; } int rolledItemPickupDefLocalIndex = -1; if (val.TryFindNext(ref array, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "GenerateDrop"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => PickupCatalog.GetPickupDef(default(PickupIndex))))), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref rolledItemPickupDefLocalIndex) })) { ILCursor val2 = array[2]; int index = val2.Index; val2.Index = index + 1; val2.Emit(OpCodes.Ldarg_0); val2.Emit(OpCodes.Ldloc, rolledItemPickupDefLocalIndex); val2.Emit(OpCodes.Ldloc, stackRollDataLocalIndex); val2.EmitDelegate>((Func)((ScavengerItemGranter instance, PickupDef pickupDef, StackRollData stackRollData) => pickupDef != null && !pickupDef.IsItem() && PickupExtensions.TryGrantTo(count: pickupDef.IsEquipment() ? 1 : stackRollData.stacks, pickupDef: pickupDef, inventory: ((Component)instance).GetComponent()))); ILLabel val3 = il.DefineLabel(); val2.Emit(OpCodes.Brtrue, (object)val3); if (val2.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GiveItemPermanent((ItemIndex)0, 0)))) })) { val2.MarkLabel(val3); } else { Log.Error("Unable to find afterGiveItem label location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ScavItemHook.cs", "ScavengerItemGranter_Start", 197); } } else { Log.Error("Failed to find PickupDef local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ScavItemHook.cs", "ScavengerItemGranter_Start", 202); } } } [PatchClass] internal static class VoidFieldsPickupPatch { [CompilerGenerated] private static class <>O { public static hook_ModifySpawnedMasters <0>__ArenaMissionController_ModifySpawnedMasters_CopyEquipment; public static Manipulator <1>__ArenaMissionController_AddItemStack_GenericPickupPatch; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__ArenaMissionController_ModifySpawnedMasters_CopyEquipment; if (obj == null) { hook_ModifySpawnedMasters val = ArenaMissionController_ModifySpawnedMasters_CopyEquipment; <>O.<0>__ArenaMissionController_ModifySpawnedMasters_CopyEquipment = val; obj = (object)val; } ArenaMissionController.ModifySpawnedMasters += (hook_ModifySpawnedMasters)obj; object obj2 = <>O.<1>__ArenaMissionController_AddItemStack_GenericPickupPatch; if (obj2 == null) { Manipulator val2 = ArenaMissionController_AddItemStack_GenericPickupPatch; <>O.<1>__ArenaMissionController_AddItemStack_GenericPickupPatch = val2; obj2 = (object)val2; } ArenaMissionController.AddItemStack += (Manipulator)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__ArenaMissionController_ModifySpawnedMasters_CopyEquipment; if (obj == null) { hook_ModifySpawnedMasters val = ArenaMissionController_ModifySpawnedMasters_CopyEquipment; <>O.<0>__ArenaMissionController_ModifySpawnedMasters_CopyEquipment = val; obj = (object)val; } ArenaMissionController.ModifySpawnedMasters -= (hook_ModifySpawnedMasters)obj; object obj2 = <>O.<1>__ArenaMissionController_AddItemStack_GenericPickupPatch; if (obj2 == null) { Manipulator val2 = ArenaMissionController_AddItemStack_GenericPickupPatch; <>O.<1>__ArenaMissionController_AddItemStack_GenericPickupPatch = val2; obj2 = (object)val2; } ArenaMissionController.AddItemStack -= (Manipulator)obj2; } private static void ArenaMissionController_ModifySpawnedMasters_CopyEquipment(orig_ModifySpawnedMasters orig, ArenaMissionController self, GameObject targetGameObject) { orig.Invoke(self, targetGameObject); CharacterMaster val = default(CharacterMaster); if (NetworkServer.active && Object.op_Implicit((Object)(object)targetGameObject) && targetGameObject.TryGetComponent(ref val)) { val.inventory.CopyEquipmentFrom(self.inventory); ItemRandomizerController.HandleCharacterGrantedRandomizedEquipment(val); } } private static void ArenaMissionController_AddItemStack_GenericPickupPatch(ILContext il) { //IL_0007: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int pickupDefLocalIndex = -1; ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => PickupCatalog.GetPickupDef(default(PickupIndex))))), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref pickupDefLocalIndex) })) { ILCursor val2 = array[1]; int index = val2.Index; val2.Index = index + 1; val2.Emit(OpCodes.Ldarg_0); val2.Emit(OpCodes.Ldloc, pickupDefLocalIndex); val2.EmitDelegate>((Func)delegate(ArenaMissionController instance, PickupDef pickupDef) { if (pickupDef == null || pickupDef.IsItem()) { return false; } if (!Object.op_Implicit((Object)(object)instance)) { return false; } Inventory inventory = instance.inventory; if (!Object.op_Implicit((Object)(object)inventory)) { return false; } int count = (pickupDef.IsEquipment() ? 1 : instance.monsterItemStackOrder[instance.nextItemStackIndex].stacks); return pickupDef.TryGrantTo(inventory, count, forceOverrideEquipment: true); }); ILLabel val3 = il.DefineLabel(); val2.Emit(OpCodes.Brtrue, (object)val3); if (val2.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Inventory _) => _.GiveItemPermanent((ItemIndex)0, 0)))) })) { val2.MarkLabel(val3); } else { Log.Error("Unable to find afterGiveItemLabel location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\VoidFieldsPickupPatch.cs", "ArenaMissionController_AddItemStack_GenericPickupPatch", 96); } } else { Log.Error("Unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\VoidFieldsPickupPatch.cs", "ArenaMissionController_AddItemStack_GenericPickupPatch", 101); } } } [PatchClass] internal static class WorldPlacedItemPickupHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__GenericPickupController_SetPickupIndexFromString; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GenericPickupController_SetPickupIndexFromString; if (obj == null) { Manipulator val = GenericPickupController_SetPickupIndexFromString; <>O.<0>__GenericPickupController_SetPickupIndexFromString = val; obj = (object)val; } GenericPickupController.SetPickupIndexFromString += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GenericPickupController_SetPickupIndexFromString; if (obj == null) { Manipulator val = GenericPickupController_SetPickupIndexFromString; <>O.<0>__GenericPickupController_SetPickupIndexFromString = val; obj = (object)val; } GenericPickupController.SetPickupIndexFromString -= (Manipulator)obj; } private static void GenericPickupController_SetPickupIndexFromString(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.DeclaredPropertySetter(typeof(GenericPickupController), "Network_pickupState")) })) { val.EmitDelegate>((Func)((PickupIndex pickupIndex) => ItemRandomizerController.GetReplacementPickupIndex(pickupIndex))); } } } } namespace RoR2Randomizer.Patches.ItemRandomizer.ArtifactKey { [PatchClass] internal static class ArtifactKeyCostTypePatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ArtifactKeyCostType_IsAffordable_IL; public static Func, object, CostTypeDef, IsAffordableContext, bool> <1>__ArtifactKeyCostType_IsAffordable_On; public static Action, object, PayCostContext, PayCostResults> <2>__ArtifactKeyCostType_PayCost; } private static bool _patchActive; private static ILHook _artifactKeyIsAffordableILHook; private static Hook _artifactKeyIsAffordableOnHook; private static Hook _artifactKeyPayCostHook; [SystemInitializer(new Type[] { typeof(CostTypeCatalog) })] private static void Init() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0031: 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) //IL_003c: Expected O, but got Unknown //IL_00d5: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0084: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown CostTypeDef costTypeDef = CostTypeCatalog.GetCostTypeDef((CostTypeIndex)11); if (costTypeDef == null) { return; } IsAffordableDelegate isAffordable = costTypeDef.isAffordable; if (isAffordable != null) { MethodInfo method = ((Delegate)(object)isAffordable).Method; object obj = <>O.<0>__ArtifactKeyCostType_IsAffordable_IL; if (obj == null) { Manipulator val = ArtifactKeyCostType_IsAffordable_IL; <>O.<0>__ArtifactKeyCostType_IsAffordable_IL = val; obj = (object)val; } _artifactKeyIsAffordableILHook = new ILHook((MethodBase)method, (Manipulator)obj, new ILHookConfig { ManualApply = true }); applyHookIfPatchClassActive((IDetour)(object)_artifactKeyIsAffordableILHook); _artifactKeyIsAffordableOnHook = new Hook((MethodBase)((Delegate)(object)isAffordable).Method, (Delegate)new Func, object, CostTypeDef, IsAffordableContext, bool>(ArtifactKeyCostType_IsAffordable_On), new HookConfig { ManualApply = true }); applyHookIfPatchClassActive((IDetour)(object)_artifactKeyIsAffordableOnHook); } PayCostDelegate payCost = costTypeDef.payCost; if (payCost != null) { _artifactKeyPayCostHook = new Hook((MethodBase)((Delegate)(object)payCost).Method, (Delegate)new Action, object, PayCostContext, PayCostResults>(ArtifactKeyCostType_PayCost), new HookConfig { ManualApply = true }); applyHookIfPatchClassActive((IDetour)(object)_artifactKeyPayCostHook); } static void applyHookIfPatchClassActive(IDetour hook) { if (_patchActive) { hook.Apply(); } } } private static void Apply() { ILHook artifactKeyIsAffordableILHook = _artifactKeyIsAffordableILHook; if (artifactKeyIsAffordableILHook != null) { artifactKeyIsAffordableILHook.Apply(); } Hook artifactKeyIsAffordableOnHook = _artifactKeyIsAffordableOnHook; if (artifactKeyIsAffordableOnHook != null) { artifactKeyIsAffordableOnHook.Apply(); } Hook artifactKeyPayCostHook = _artifactKeyPayCostHook; if (artifactKeyPayCostHook != null) { artifactKeyPayCostHook.Apply(); } _patchActive = true; } private static void Cleanup() { ILHook artifactKeyIsAffordableILHook = _artifactKeyIsAffordableILHook; if (artifactKeyIsAffordableILHook != null) { artifactKeyIsAffordableILHook.Undo(); } Hook artifactKeyIsAffordableOnHook = _artifactKeyIsAffordableOnHook; if (artifactKeyIsAffordableOnHook != null) { artifactKeyIsAffordableOnHook.Undo(); } Hook artifactKeyPayCostHook = _artifactKeyPayCostHook; if (artifactKeyPayCostHook != null) { artifactKeyPayCostHook.Undo(); } _patchActive = false; } private static bool ArtifactKeyCostType_IsAffordable_On(Func orig, object self, CostTypeDef costTypeDef, IsAffordableContext context) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0016: 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_0041: 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) if (ItemRandomizerController.IsEnabled && ItemRandomizerController.TryGetReplacementPickupIndex(PickupCatalog.FindPickupIndex(Items.ArtifactKey.itemIndex), out var replacement)) { PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (!pickupDef.IsItem()) { if (!Object.op_Implicit((Object)(object)context.activator)) { return false; } CharacterBody val = default(CharacterBody); if (!((Component)context.activator).TryGetComponent(ref val)) { return false; } CharacterMaster master = val.master; if (!Object.op_Implicit((Object)(object)master)) { return false; } return master.GetPickupCount(pickupDef) >= context.cost; } } return orig(self, costTypeDef, context); } private static void ArtifactKeyCostType_IsAffordable_IL(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "ArtifactKey") })) { int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)((ItemDef artifactKey) => ItemRandomizerController.TryGetReplacementPickupIndex(PickupCatalog.FindPickupIndex(artifactKey.itemIndex), out var replacement) ? ItemCatalog.GetItemDef(((PickupIndex)(ref replacement)).pickupDef.itemIndex) : artifactKey)); } } private static void ArtifactKeyCostType_PayCost(Action orig, object self, PayCostContext context, PayCostResults result) { //IL_000c: 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_0016: Unknown result type (might be due to invalid IL or missing references) if (ItemRandomizerController.IsEnabled && ItemRandomizerController.TryGetReplacementPickupIndex(PickupCatalog.FindPickupIndex(Items.ArtifactKey.itemIndex), out var replacement)) { PickupDef pickupDef = ((PickupIndex)(ref replacement)).pickupDef; if (!pickupDef.IsItem()) { pickupDef.TryDeductFrom(context.activatorMaster, context.cost); MultiShopCardUtils.OnNonMoneyPurchase(context); return; } } orig(self, context, result); } } [PatchClass] internal static class ReplaceArtifactKeyPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__hookFindPickupIndex_ItemIndex; public static Manipulator <1>__ArtifactTrialMissionController_RemoveAllMissionKeys; public static Func <2>__matchCallFindPickupIndex_ItemIndex; public static Func <3>__GetReplacementPickupIndex; } private static readonly MethodInfo PickupCatalog_FindPickupIndex_ItemIndex_MI = SymbolExtensions.GetMethodInfo((Expression)(() => PickupCatalog.FindPickupIndex((ItemIndex)0))); private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__hookFindPickupIndex_ItemIndex; if (obj == null) { Manipulator val = hookFindPickupIndex_ItemIndex; <>O.<0>__hookFindPickupIndex_ItemIndex = val; obj = (object)val; } SetupState.FixedUpdate += (Manipulator)obj; object obj2 = <>O.<0>__hookFindPickupIndex_ItemIndex; if (obj2 == null) { Manipulator val2 = hookFindPickupIndex_ItemIndex; <>O.<0>__hookFindPickupIndex_ItemIndex = val2; obj2 = (object)val2; } ArtifactTrialMissionController.RemoveAllMissionKeys += (Manipulator)obj2; object obj3 = <>O.<1>__ArtifactTrialMissionController_RemoveAllMissionKeys; if (obj3 == null) { Manipulator val3 = ArtifactTrialMissionController_RemoveAllMissionKeys; <>O.<1>__ArtifactTrialMissionController_RemoveAllMissionKeys = val3; obj3 = (object)val3; } ArtifactTrialMissionController.RemoveAllMissionKeys += (Manipulator)obj3; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__hookFindPickupIndex_ItemIndex; if (obj == null) { Manipulator val = hookFindPickupIndex_ItemIndex; <>O.<0>__hookFindPickupIndex_ItemIndex = val; obj = (object)val; } SetupState.FixedUpdate -= (Manipulator)obj; object obj2 = <>O.<0>__hookFindPickupIndex_ItemIndex; if (obj2 == null) { Manipulator val2 = hookFindPickupIndex_ItemIndex; <>O.<0>__hookFindPickupIndex_ItemIndex = val2; obj2 = (object)val2; } ArtifactTrialMissionController.RemoveAllMissionKeys -= (Manipulator)obj2; object obj3 = <>O.<1>__ArtifactTrialMissionController_RemoveAllMissionKeys; if (obj3 == null) { Manipulator val3 = ArtifactTrialMissionController_RemoveAllMissionKeys; <>O.<1>__ArtifactTrialMissionController_RemoveAllMissionKeys = val3; obj3 = (object)val3; } ArtifactTrialMissionController.RemoveAllMissionKeys -= (Manipulator)obj3; } private static void hookFindPickupIndex_ItemIndex(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); while (val.TryGotoNext((MoveType)2, new Func[1] { matchCallFindPickupIndex_ItemIndex })) { val.EmitDelegate>((Func)ItemRandomizerController.GetReplacementPickupIndex); } } private static void ArtifactTrialMissionController_RemoveAllMissionKeys(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int pickupIndexLocalIndex = -1; ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { matchCallFindPickupIndex_ItemIndex, (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref pickupIndexLocalIndex) })) { ILLabel moveNextLbl = null; int characterMasterLocalIndex = -1; if (val.TryFindNext(ref array, new Func[5] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.DeclaredPropertyGetter(typeof(CharacterMaster), "readOnlyInstancesList")), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo>((Expression>>)((ReadOnlyCollection _) => _.GetEnumerator()))), (Instruction x) => ILPatternMatchingExt.MatchBr(x, ref moveNextLbl), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.DeclaredPropertyGetter(typeof(IEnumerator), "Current")), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref characterMasterLocalIndex) })) { ILCursor obj = array[4]; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Ldloc, characterMasterLocalIndex); obj.Emit(OpCodes.Ldloc, pickupIndexLocalIndex); obj.EmitDelegate>((Func)delegate(CharacterMaster characterMaster, PickupIndex pickupIndex) { PickupDef pickupDef = ((PickupIndex)(ref pickupIndex)).pickupDef; if (pickupDef != null && !pickupDef.IsItem()) { pickupDef.TryDeductFrom(characterMaster, int.MaxValue); return true; } return false; }); obj.Emit(OpCodes.Brtrue, (object)moveNextLbl); } else { Log.Warning("unable to find CharacterMaster.readOnlyInstancesList foreach", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ArtifactKey\\ReplaceArtifactKeyPatch.cs", "ArtifactTrialMissionController_RemoveAllMissionKeys", 88); } } else { Log.Warning("unable to find pickup index local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ItemRandomizer\\ArtifactKey\\ReplaceArtifactKeyPatch.cs", "ArtifactTrialMissionController_RemoveAllMissionKeys", 93); } } private static bool matchCallFindPickupIndex_ItemIndex(Instruction instr) { return ILPatternMatchingExt.MatchCallOrCallvirt(instr, (MethodBase)PickupCatalog_FindPickupIndex_ItemIndex_MI); } } } namespace RoR2Randomizer.Patches.Fixes { [PatchClass] internal static class Loadout_BodyLoadoutManager_GetSkillVariant_IndexOutOfRangeFix { [CompilerGenerated] private static class <>O { public static Manipulator <0>__BodyLoadoutManager_GetSkillVariant; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BodyLoadoutManager_GetSkillVariant; if (obj == null) { Manipulator val = BodyLoadoutManager_GetSkillVariant; <>O.<0>__BodyLoadoutManager_GetSkillVariant = val; obj = (object)val; } BodyLoadoutManager.GetSkillVariant += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BodyLoadoutManager_GetSkillVariant; if (obj == null) { Manipulator val = BodyLoadoutManager_GetSkillVariant; <>O.<0>__BodyLoadoutManager_GetSkillVariant = val; obj = (object)val; } BodyLoadoutManager.GetSkillVariant -= (Manipulator)obj; } private static void BodyLoadoutManager_GetSkillVariant(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdelemU4(x) })) { val.Remove(); val.Emit(OpCodes.Call, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => ArrayUtils.GetSafe((uint[])null, 0)))); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\Loadout_BodyLoadoutManager_GetSkillVariant_IndexOutOfRangeFix.cs", "BodyLoadoutManager_GetSkillVariant", 34); } } } [PatchClass] internal static class PlayerCharacterBody_AuthorityFix { private static readonly Hook NetworkIdentity_get_localPlayerAuthority_Hook = new Hook((MethodBase)AccessTools.DeclaredPropertyGetter(typeof(NetworkIdentity), "localPlayerAuthority"), (Delegate)(Func, NetworkIdentity, bool>)((Func orig, NetworkIdentity self) => NetworkIdentity_get_localPlayerAuthority(orig(self), self)), new HookConfig { ManualApply = true }); private static readonly ILHook NetworkIdentity_OnStartServer_ILHook = new ILHook((MethodBase)AccessTools.DeclaredMethod(typeof(NetworkIdentity), "OnStartServer", (Type[])null, (Type[])null), (Manipulator)delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000c: 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) ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "localPlayerAuthority") })) { val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Call, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => NetworkIdentity_get_localPlayerAuthority(localPlayerAuthority: false, null)))); num++; } if (num == 0) { Log.Warning("no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\PlayerCharacterBody_AuthorityFix.cs", "NetworkIdentity_OnStartServer_ILHook", 40); } }, new ILHookConfig { ManualApply = true }); private static void Apply() { NetworkIdentity_get_localPlayerAuthority_Hook.Apply(); } private static void Cleanup() { NetworkIdentity_get_localPlayerAuthority_Hook.Undo(); } private static bool NetworkIdentity_get_localPlayerAuthority(bool localPlayerAuthority, NetworkIdentity self) { CharacterBody val = default(CharacterBody); if (!localPlayerAuthority && ExplicitSpawnRandomizerController.IsActive && ((Component)self).TryGetComponent(ref val)) { GameObject masterObject = val.masterObject; if (Object.op_Implicit((Object)(object)masterObject) && Object.op_Implicit((Object)(object)masterObject.GetComponent())) { self.localPlayerAuthority = true; return true; } } return localPlayerAuthority; } } [PatchClass] internal static class ProjectileParentTether_NullRefFix { [CompilerGenerated] private static class <>O { public static hook_FixedUpdate <0>__ProjectileParentTether_FixedUpdate; public static hook_UpdateTetherGraphic <1>__ProjectileParentTether_UpdateTetherGraphic; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileParentTether_FixedUpdate; if (obj == null) { hook_FixedUpdate val = ProjectileParentTether_FixedUpdate; <>O.<0>__ProjectileParentTether_FixedUpdate = val; obj = (object)val; } ProjectileParentTether.FixedUpdate += (hook_FixedUpdate)obj; object obj2 = <>O.<1>__ProjectileParentTether_UpdateTetherGraphic; if (obj2 == null) { hook_UpdateTetherGraphic val2 = ProjectileParentTether_UpdateTetherGraphic; <>O.<1>__ProjectileParentTether_UpdateTetherGraphic = val2; obj2 = (object)val2; } ProjectileParentTether.UpdateTetherGraphic += (hook_UpdateTetherGraphic)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileParentTether_FixedUpdate; if (obj == null) { hook_FixedUpdate val = ProjectileParentTether_FixedUpdate; <>O.<0>__ProjectileParentTether_FixedUpdate = val; obj = (object)val; } ProjectileParentTether.FixedUpdate -= (hook_FixedUpdate)obj; object obj2 = <>O.<1>__ProjectileParentTether_UpdateTetherGraphic; if (obj2 == null) { hook_UpdateTetherGraphic val2 = ProjectileParentTether_UpdateTetherGraphic; <>O.<1>__ProjectileParentTether_UpdateTetherGraphic = val2; obj2 = (object)val2; } ProjectileParentTether.UpdateTetherGraphic -= (hook_UpdateTetherGraphic)obj2; } private static void ProjectileParentTether_FixedUpdate(orig_FixedUpdate orig, ProjectileParentTether self) { if (Object.op_Implicit((Object)(object)self.projectileController) && Object.op_Implicit((Object)(object)self.projectileController.owner)) { orig.Invoke(self); } } private static void ProjectileParentTether_UpdateTetherGraphic(orig_UpdateTetherGraphic orig, ProjectileParentTether self) { if (Object.op_Implicit((Object)(object)self.projectileController) && Object.op_Implicit((Object)(object)self.projectileController.owner)) { orig.Invoke(self); } } } public static class Shared { private static readonly string[] _skillFieldNames = new string[4] { "primary", "secondary", "utility", "special" }; public static void Physics_Raycast_LayerMaskDistanceFix_ILPatch(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); while (val.TryGotoNext(new Func[3] { (Instruction x) => x.MatchImplicitConversion(), (Instruction x) => ILPatternMatchingExt.MatchConvR4(x), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)StaticReflectionCache.Physics_Raycast_Ray_outRaycastHit_float_MI) })) { int index = val.Index; val.Index = index + 1; val.RemoveRange(2); val.EmitDelegate<<>F{00000010}>((<>F{00000010})delegate(Ray ray, out RaycastHit hit, int layerMask) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Physics.Raycast(ray, ref hit, float.PositiveInfinity, layerMask); }); } } public static void HookAnimator_GetFloat(ILContext il, string name, T hook) where T : Delegate { HookAnimator_GetValue(il, name, StaticReflectionCache.Animator_GetFloat_name_MI, hook); } public static void HookAnimator_GetValue(ILContext il, string name, MethodInfo targetMethod, T hook) where T : Delegate { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, name), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)targetMethod) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate(hook); } } public static void EntityState_SkillSlotResolver(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); FieldReference val2 = default(FieldReference); while (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)StaticReflectionCache.EntityState_get_skillLocator), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val2) && Array.IndexOf(_skillFieldNames, ((MemberReference)val2).Name) != -1 })) { val.Index += 2; val.Remove(); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(SkillLocator locator, EntityState entityState) { GenericSkill owner = EntityStateOwnerTracker.GetOwner(entityState); if (Object.op_Implicit((Object)(object)owner)) { return owner; } if (Object.op_Implicit((Object)(object)locator)) { Log.Warning("EntityState_SkillSlotResolver: No state owner found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\Shared.cs", "EntityState_SkillSlotResolver", 79); return locator.primary; } throw new NullReferenceException("SkillLocator is null"); }); } } public static void TryAddTemporaryComponentIfMissing(CharacterBody body, ref T cachedComponent) where T : MonoBehaviour { if (Object.op_Implicit((Object)(object)body) && !Object.op_Implicit((Object)(object)cachedComponent)) { cachedComponent = TempComponentsTracker.AddTempComponent((MonoBehaviour)(object)body); } } public static void Try_get_gameObject(ILCursor c) { c.ReplaceCall>((Component comp) => (!Object.op_Implicit((Object)(object)comp)) ? null : comp.gameObject); } public static void ReplaceCall(this ILCursor c, T del) where T : Delegate { c.Remove(); c.EmitDelegate(del); } } } namespace RoR2Randomizer.Patches.Fixes.Skills.EntityStates.VoidRaidCrab { [PatchClass] public static class DeathState { [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__DeathState_OnEnter; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DeathState_OnEnter; if (obj == null) { hook_OnEnter val = DeathState_OnEnter; <>O.<0>__DeathState_OnEnter = val; obj = (object)val; } DeathState.OnEnter += (hook_OnEnter)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DeathState_OnEnter; if (obj == null) { hook_OnEnter val = DeathState_OnEnter; <>O.<0>__DeathState_OnEnter = val; obj = (object)val; } DeathState.OnEnter -= (hook_OnEnter)obj; } private static void DeathState_OnEnter(orig_OnEnter orig, DeathState self) { CustomChildTransformManager.AutoAddChildTransform((EntityState)(object)self, self.initialEffectMuzzle); orig.Invoke(self); } } [PatchClass] public static class EscapeDeath { [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__EscapeDeath_OnEnter; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EscapeDeath_OnEnter; if (obj == null) { hook_OnEnter val = EscapeDeath_OnEnter; <>O.<0>__EscapeDeath_OnEnter = val; obj = (object)val; } EscapeDeath.OnEnter += (hook_OnEnter)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EscapeDeath_OnEnter; if (obj == null) { hook_OnEnter val = EscapeDeath_OnEnter; <>O.<0>__EscapeDeath_OnEnter = val; obj = (object)val; } EscapeDeath.OnEnter -= (hook_OnEnter)obj; } private static void EscapeDeath_OnEnter(orig_OnEnter orig, EscapeDeath self) { CustomChildTransformManager.AutoAddChildTransform((EntityState)(object)self, self.gauntletEntranceChildName); orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.Fixes.Skills.EntityStates.NewtMonster { [PatchClass] public static class KickFromShop { [CompilerGenerated] private static class <>O { public static Manipulator <0>__KickFromShop_FixedUpdate; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__KickFromShop_FixedUpdate; if (obj == null) { Manipulator val = KickFromShop_FixedUpdate; <>O.<0>__KickFromShop_FixedUpdate = val; obj = (object)val; } KickFromShop.FixedUpdate += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__KickFromShop_FixedUpdate; if (obj == null) { Manipulator val = KickFromShop_FixedUpdate; <>O.<0>__KickFromShop_FixedUpdate = val; obj = (object)val; } KickFromShop.FixedUpdate -= (Manipulator)obj; } private static void KickFromShop_FixedUpdate(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "KickOutOfShop"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, "Find"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Component), "gameObject")) })) { val.Index += 2; Shared.Try_get_gameObject(val); } else { Log.Warning("unable to find KickOutOfShop NullRefFix patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\Skills\\EntityStates\\NewtMonster\\KickFromShop.cs", "KickFromShop_FixedUpdate", 39); } int localIndex = -1; int num = default(int); if (val.TryGotoNext(new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Component _) => _.GetComponent()))), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref localIndex), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num) && num == localIndex, (Instruction x) => x.MatchImplicitConversion() })) { val.Index += 4; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(KickFromShop instance) { CharacterBody characterBody = ((EntityState)instance).characterBody; if (Object.op_Implicit((Object)(object)characterBody)) { GameObject masterObject = characterBody.masterObject; if (Object.op_Implicit((Object)(object)masterObject)) { return !BossRandomizerController.IsReplacedBossCharacter(masterObject); } } return true; }); val.Emit(OpCodes.And); } else { Log.Warning("unable to find patch location for disabling invulnerability for boss replacement", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\Skills\\EntityStates\\NewtMonster\\KickFromShop.cs", "KickFromShop_FixedUpdate", 71); } } } } namespace RoR2Randomizer.Patches.Fixes.Skills.EntityStates.BrotherMonster { [PatchClass] public static class SpellBaseState { [CompilerGenerated] private static class <>O { public static Manipulator <0>__SpellBaseState_OnEnter; public static Manipulator <1>__SpellBaseState_InitItemStealer; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__SpellBaseState_OnEnter; if (obj == null) { Manipulator val = SpellBaseState_OnEnter; <>O.<0>__SpellBaseState_OnEnter = val; obj = (object)val; } SpellBaseState.OnEnter += (Manipulator)obj; object obj2 = <>O.<1>__SpellBaseState_InitItemStealer; if (obj2 == null) { Manipulator val2 = SpellBaseState_InitItemStealer; <>O.<1>__SpellBaseState_InitItemStealer = val2; obj2 = (object)val2; } SpellBaseState.InitItemStealer += (Manipulator)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__SpellBaseState_OnEnter; if (obj == null) { Manipulator val = SpellBaseState_OnEnter; <>O.<0>__SpellBaseState_OnEnter = val; obj = (object)val; } SpellBaseState.OnEnter -= (Manipulator)obj; object obj2 = <>O.<1>__SpellBaseState_InitItemStealer; if (obj2 == null) { Manipulator val2 = SpellBaseState_InitItemStealer; <>O.<1>__SpellBaseState_InitItemStealer = val2; obj2 = (object)val2; } SpellBaseState.InitItemStealer -= (Manipulator)obj2; } private static void SpellBaseState_OnEnter(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "HammerRenderer"), (Instruction x) => ILPatternMatchingExt.MatchCall(x, "FindModelChild"), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Component), "gameObject")) })) { val.Index += 2; Shared.Try_get_gameObject(val); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\Skills\\EntityStates\\BrotherMonster\\SpellBaseState.cs", "SpellBaseState_OnEnter", 42); } } private static void SpellBaseState_InitItemStealer(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((GameObject _) => _.GetComponent()))) })) { int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(ReturnStolenItemsOnGettingHit returnItems, SpellBaseState instance) { if (ConfigManager.BossRandomizer.AnyMithrixRandomizerEnabled && !Object.op_Implicit((Object)(object)returnItems) && instance != null) { GameObject gameObject = ((EntityState)instance).gameObject; if (Object.op_Implicit((Object)(object)gameObject) && BossRandomizerController.Mithrix.IsReplacedPartOfMithrixFight(((EntityState)instance).characterBody.masterObject)) { returnItems = MainMithrixReplacement.AddReturnStolenItemsOnGettingHit(gameObject, ((EntityState)instance).healthComponent); } } return returnItems; }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\Fixes\\Skills\\EntityStates\\BrotherMonster\\SpellBaseState.cs", "SpellBaseState_InitItemStealer", 72); } } } [PatchClass] public static class SpellChannelState { [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__SpellChannelState_OnEnter; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SpellChannelState_OnEnter; if (obj == null) { hook_OnEnter val = SpellChannelState_OnEnter; <>O.<0>__SpellChannelState_OnEnter = val; obj = (object)val; } SpellChannelState.OnEnter += (hook_OnEnter)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SpellChannelState_OnEnter; if (obj == null) { hook_OnEnter val = SpellChannelState_OnEnter; <>O.<0>__SpellChannelState_OnEnter = val; obj = (object)val; } SpellChannelState.OnEnter -= (hook_OnEnter)obj; } private static void SpellChannelState_OnEnter(orig_OnEnter orig, SpellChannelState self) { CustomChildTransformManager.AutoAddChildTransform((EntityState)(object)self, "SpellChannel"); orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.ExplicitSpawnRandomizer { internal static class AqueductRingEvent_SpawnHook { private static void Apply() { SceneCatalog.onMostRecentSceneDefChanged += onSceneLoaded; } private static void Cleanup() { SceneCatalog.onMostRecentSceneDefChanged -= onSceneLoaded; } private static void onSceneLoaded(SceneDef scene) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeAbandonedAqueductRingEvent && (int)Caches.Scene.AbandonedAqueductSceneIndex != -1 && scene.sceneDefIndex == Caches.Scene.AbandonedAqueductSceneIndex) { ((MonoBehaviour)Main.Instance).StartCoroutine(waitThenReplaceRingEventEnemies()); } } private static IEnumerator waitThenReplaceRingEventEnemies() { yield return (object)new WaitForSeconds(0.25f); GameObject val = GameObject.Find("HOLDER: Secret Ring Area Content"); if (!Object.op_Implicit((Object)(object)val)) { yield break; } Transform val2 = val.transform.Find("ApproxCenter/RingEventController"); if (!Object.op_Implicit((Object)(object)val2)) { yield break; } CharacterMaster[] componentsInChildren = ((Component)val2).GetComponentsInChildren(); foreach (CharacterMaster val3 in componentsInChildren) { if (!val3.hasBody) { CharacterMaster summonReplacement = ExplicitSpawnRandomizerController.GetSummonReplacement(val3); if (Object.op_Implicit((Object)(object)summonReplacement)) { val3.bodyPrefab = summonReplacement.bodyPrefab; } } } } } [PatchClass] internal static class BeetleQueenSummonEggs_SpawnHook { private static readonly Manipulator _replaceBeetleQueenGuardsManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeBeetleQueenSummonGuards); private static void Apply() { SummonEggs.SummonEgg += _replaceBeetleQueenGuardsManipulator; } private static void Cleanup() { SummonEggs.SummonEgg -= _replaceBeetleQueenGuardsManipulator; } } [PatchClass] internal static class ColDroneman_SpawnHook { private static readonly Manipulator _replaceColDronemanSpawnManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones); private static void Apply() { DroneWeaponsBehavior.TrySpawnDrone += _replaceColDronemanSpawnManipulator; } private static void Cleanup() { DroneWeaponsBehavior.TrySpawnDrone -= _replaceColDronemanSpawnManipulator; } } [PatchClass] internal static class DeployableMinionSpawner_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__DeployableMinionSpawner_SpawnMinion; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DeployableMinionSpawner_SpawnMinion; if (obj == null) { Manipulator val = DeployableMinionSpawner_SpawnMinion; <>O.<0>__DeployableMinionSpawner_SpawnMinion = val; obj = (object)val; } DeployableMinionSpawner.SpawnMinion += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DeployableMinionSpawner_SpawnMinion; if (obj == null) { Manipulator val = DeployableMinionSpawner_SpawnMinion; <>O.<0>__DeployableMinionSpawner_SpawnMinion = val; obj = (object)val; } DeployableMinionSpawner.SpawnMinion -= (Manipulator)obj; } private static void DeployableMinionSpawner_SpawnMinion(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TrySpawnObject") })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(DirectorSpawnRequest spawnRequest, DeployableMinionSpawner instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000c: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) DeployableSlot deployableSlot = instance.deployableSlot; if (deployableSlot - 12 <= 1) { if (!ConfigManager.ExplicitSpawnRandomizer.RandomizeRoboBallBuddies) { return; } } else { Log.Warning($"unhandled deployable slot {instance.deployableSlot}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\DeployableMinionSpawner_SpawnHook.cs", "DeployableMinionSpawner_SpawnMinion", 41); } ExplicitSpawnRandomizerController.TryReplaceDirectorSpawnRequest(spawnRequest); }); } else { Log.Warning("Failed to find the patch location for TrySpawnObject", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\DeployableMinionSpawner_SpawnHook.cs", "DeployableMinionSpawner_SpawnMinion", 50); } } } [PatchClass] internal static class DirectorCore_TrySpawnObject { public delegate void PostfixDelegate(ref GameObject result, DirectorSpawnRequest directorSpawnRequest); [CompilerGenerated] private static class <>O { public static hook_TrySpawnObject <0>__DirectorCore_TrySpawnObject_EventsHook; } public static event PostfixDelegate Postfix; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DirectorCore_TrySpawnObject_EventsHook; if (obj == null) { hook_TrySpawnObject val = DirectorCore_TrySpawnObject_EventsHook; <>O.<0>__DirectorCore_TrySpawnObject_EventsHook = val; obj = (object)val; } DirectorCore.TrySpawnObject += (hook_TrySpawnObject)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DirectorCore_TrySpawnObject_EventsHook; if (obj == null) { hook_TrySpawnObject val = DirectorCore_TrySpawnObject_EventsHook; <>O.<0>__DirectorCore_TrySpawnObject_EventsHook = val; obj = (object)val; } DirectorCore.TrySpawnObject -= (hook_TrySpawnObject)obj; } private static GameObject DirectorCore_TrySpawnObject_EventsHook(orig_TrySpawnObject orig, DirectorCore self, DirectorSpawnRequest directorSpawnRequest) { GameObject result = orig.Invoke(self, directorSpawnRequest); DirectorCore_TrySpawnObject.Postfix?.Invoke(ref result, directorSpawnRequest); return result; } } [PatchClass] internal static class Doppelganger_SpawnHook { private static readonly Manipulator _replaceDoppelgangerSpawnManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeDoppelgangers); private static void Apply() { DoppelgangerInvasionManager.CreateDoppelganger += _replaceDoppelgangerSpawnManipulator; } private static void Cleanup() { DoppelgangerInvasionManager.CreateDoppelganger -= _replaceDoppelgangerSpawnManipulator; } } [PatchClass] internal static class DroneBoy_SpawnHook { private static readonly Manipulator _replaceDroneboySpawnManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones); private static void Apply() { DronesDropDynamiteBehaviour.TrySpawnDrone += _replaceDroneboySpawnManipulator; } private static void Cleanup() { DronesDropDynamiteBehaviour.TrySpawnDrone -= _replaceDroneboySpawnManipulator; } } [PatchClass] internal static class EngineerTurret_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__PlaceTurret_FixedUpdate; public static Manipulator <1>__CharacterBody_HandleConstructTurret; public static Manipulator <2>__PlaceTurret_GetPlacementInfo; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__PlaceTurret_FixedUpdate; if (obj == null) { Manipulator val = PlaceTurret_FixedUpdate; <>O.<0>__PlaceTurret_FixedUpdate = val; obj = (object)val; } PlaceTurret.FixedUpdate += (Manipulator)obj; object obj2 = <>O.<1>__CharacterBody_HandleConstructTurret; if (obj2 == null) { Manipulator val2 = CharacterBody_HandleConstructTurret; <>O.<1>__CharacterBody_HandleConstructTurret = val2; obj2 = (object)val2; } CharacterBody.HandleConstructTurret += (Manipulator)obj2; object obj3 = <>O.<2>__PlaceTurret_GetPlacementInfo; if (obj3 == null) { Manipulator val3 = PlaceTurret_GetPlacementInfo; <>O.<2>__PlaceTurret_GetPlacementInfo = val3; obj3 = (object)val3; } PlaceTurret.GetPlacementInfo += (Manipulator)obj3; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__PlaceTurret_FixedUpdate; if (obj == null) { Manipulator val = PlaceTurret_FixedUpdate; <>O.<0>__PlaceTurret_FixedUpdate = val; obj = (object)val; } PlaceTurret.FixedUpdate -= (Manipulator)obj; object obj2 = <>O.<1>__CharacterBody_HandleConstructTurret; if (obj2 == null) { Manipulator val2 = CharacterBody_HandleConstructTurret; <>O.<1>__CharacterBody_HandleConstructTurret = val2; obj2 = (object)val2; } CharacterBody.HandleConstructTurret -= (Manipulator)obj2; object obj3 = <>O.<2>__PlaceTurret_GetPlacementInfo; if (obj3 == null) { Manipulator val3 = PlaceTurret_GetPlacementInfo; <>O.<2>__PlaceTurret_GetPlacementInfo = val3; obj3 = (object)val3; } PlaceTurret.GetPlacementInfo -= (Manipulator)obj3; } private static void PlaceTurret_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext((MoveType)2, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "turretMasterPrefab"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => MasterCatalog.FindMasterIndex((GameObject)null)))) })) { num++; val.EmitDelegate>((Func)delegate(MasterIndex original) { //IL_0013: 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_0019: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!ConfigManager.ExplicitSpawnRandomizer.RandomizeEngiTurrets) { return original; } MasterIndex summonReplacement = ExplicitSpawnRandomizerController.GetSummonReplacement(original); return (!((MasterIndex)(ref summonReplacement)).isValid) ? original : summonReplacement; }); } if (num == 0) { Log.Warning("Failed to patch any locations for FixedUpdate", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\EngineerTurret_SpawnHook.cs", "PlaceTurret_FixedUpdate", 55); } } private static void CharacterBody_HandleConstructTurret(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "Perform") })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(CharacterMaster summoned) { if (NetworkServer.active && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeEngiTurrets) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(((Component)summoned).gameObject); } }); } else { Log.Warning("Failed to find patch the location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\EngineerTurret_SpawnHook.cs", "CharacterBody_HandleConstructTurret", 82); } } private static void PlaceTurret_GetPlacementInfo(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 2f) })) { num++; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)delegate(float originalDistance, PlaceTurret instance) { if ((bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeEngiTurrets) { GameObject summonReplacement = ExplicitSpawnRandomizerController.GetSummonReplacement(instance.turretMasterPrefab); CharacterMaster val2 = default(CharacterMaster); float num2 = default(float); if (Object.op_Implicit((Object)(object)summonReplacement) && summonReplacement.TryGetComponent(ref val2) && Object.op_Implicit((Object)(object)val2.bodyPrefab) && Caches.CharacterBodyRadius.TryGetValue(val2.bodyPrefab, ref num2)) { float num3 = num2 + 1.5f; return Mathf.Max(originalDistance, num3); } } return originalDistance; }); } if (num == 0) { Log.Warning("Failed to patch any locations for radius override in GetPlacementInfo", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\EngineerTurret_SpawnHook.cs", "PlaceTurret_GetPlacementInfo", 123); } val.Index = 0; num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchRet(x) })) { num++; val.EmitDelegate>((Func)delegate(PlacementInfo result) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeEngiTurrets) { ref Quaternion rotation = ref result.rotation; rotation *= Quaternion.Euler(0f, 180f, 0f); } return result; }); int index = val.Index; val.Index = index + 1; } if (num == 0) { Log.Warning("Failed to patch any locations for turret rotation in GetPlacementInfo", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\EngineerTurret_SpawnHook.cs", "PlaceTurret_GetPlacementInfo", 154); } } } [PatchClass] internal static class EquipmentSlot_FireDroneBackup_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__EquipmentSlot_FireDroneBackup; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EquipmentSlot_FireDroneBackup; if (obj == null) { Manipulator val = EquipmentSlot_FireDroneBackup; <>O.<0>__EquipmentSlot_FireDroneBackup = val; obj = (object)val; } EquipmentSlot.FireDroneBackup += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EquipmentSlot_FireDroneBackup; if (obj == null) { Manipulator val = EquipmentSlot_FireDroneBackup; <>O.<0>__EquipmentSlot_FireDroneBackup = val; obj = (object)val; } EquipmentSlot.FireDroneBackup -= (Manipulator)obj; } private static void EquipmentSlot_FireDroneBackup(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Prefabs/CharacterMasters/DroneBackupMaster"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Resources.Load((string)null)))) })) { ILCursor val = array[^1]; int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)((GameObject strikeDronePrefab) => ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones ? ExplicitSpawnRandomizerController.GetSummonReplacement(strikeDronePrefab) : strikeDronePrefab)); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "SummonMaster") })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(CharacterMaster summoned) { if (Object.op_Implicit((Object)(object)summoned) && NetworkServer.active && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(((Component)summoned).gameObject); } }); } else { Log.Warning("Failed to patch the summoning of the drone", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\EquipmentSlot_FireDroneBackup_SpawnHook.cs", "EquipmentSlot_FireDroneBackup", 62); } } else { Log.Warning("Failed to patch the loading of the drone prefab", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\EquipmentSlot_FireDroneBackup_SpawnHook.cs", "EquipmentSlot_FireDroneBackup", 67); } } } [PatchClass] internal static class GlobalOnDeath_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__GlobalEventManager_OnCharacterDeath; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GlobalEventManager_OnCharacterDeath; if (obj == null) { Manipulator val = GlobalEventManager_OnCharacterDeath; <>O.<0>__GlobalEventManager_OnCharacterDeath = val; obj = (object)val; } GlobalEventManager.OnCharacterDeath += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GlobalEventManager_OnCharacterDeath; if (obj == null) { Manipulator val = GlobalEventManager_OnCharacterDeath; <>O.<0>__GlobalEventManager_OnCharacterDeath = val; obj = (object)val; } GlobalEventManager.OnCharacterDeath -= (Manipulator)obj; } private unsafe static void GlobalEventManager_OnCharacterDeath(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Prefabs/CharacterMasters/UrchinTurretMaster"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Resources.Load((string)null)))) })) { ILCursor obj = array[^1]; int index = obj.Index; obj.Index = index + 1; obj.EmitDelegate>((Func)((GameObject urchinPrefab) => ConfigManager.ExplicitSpawnRandomizer.RandomizeMalachiteUrchins ? ExplicitSpawnRandomizerController.GetSummonReplacement(urchinPrefab) : urchinPrefab)); } else { Log.Warning("unable to find Malachite Urchin spawn patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\GlobalOnDeath_SpawnHook.cs", "GlobalEventManager_OnCharacterDeath", 58); } val.Index = 0; int num = 0; while (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(CommonAssets), "wispSoulMasterPrefabMasterComponent") })) { val.EmitDelegate>((Func)((CharacterMaster soulWispOriginalMasterPrefab) => ((bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeSoulWisps && ExplicitSpawnRandomizerController.TryGetReplacementMaster(soulWispOriginalMasterPrefab, out var replacementPrefab)) ? replacementPrefab : soulWispOriginalMasterPrefab)); num++; } if (num <= 0) { Log.Warning("unable to find Soul Wisp spawn patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\GlobalOnDeath_SpawnHook.cs", "GlobalEventManager_OnCharacterDeath", 90); } val.Index = 0; num = 0; while (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(CommonAssets), "eliteEarthHealerMaster") })) { val.EmitDelegate>((Func)((GameObject healingCoreMasterPrefab) => ConfigManager.ExplicitSpawnRandomizer.RandomizeHealingCores ? ExplicitSpawnRandomizerController.GetSummonReplacement(healingCoreMasterPrefab) : healingCoreMasterPrefab)); num++; } if (num <= 0) { Log.Warning("unable to find Healing Core spawn patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\GlobalOnDeath_SpawnHook.cs", "GlobalEventManager_OnCharacterDeath", 121); } val.Index = 0; if (val.TryFindNext(ref array, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "RoR2/DLC1/EliteVoid/VoidInfestorMaster.prefab"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Addressables.LoadAssetAsync((object)null)))), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo>((Expression>>)((AsyncOperationHandle _) => ((AsyncOperationHandle*)_)->WaitForCompletion()))) })) { ILCursor obj2 = array[^1]; int index = obj2.Index; obj2.Index = index + 1; obj2.EmitDelegate>((Func)((GameObject voidInfestorMasterPrefab) => ConfigManager.ExplicitSpawnRandomizer.RandomizeVoidInfestors ? ExplicitSpawnRandomizerController.GetSummonReplacement(voidInfestorMasterPrefab) : voidInfestorMasterPrefab)); } else { Log.Warning("unable to find Void Infestor spawn patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\GlobalOnDeath_SpawnHook.cs", "GlobalEventManager_OnCharacterDeath", 148); } val.Index = 0; num = 0; while (val.TryGotoNext((MoveType)0, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => NetworkServer.Spawn((GameObject)null)))) })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(GameObject instantiated) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) CharacterMaster val2 = default(CharacterMaster); MasterIndex prefabMasterIndex; if (NetworkServer.active && Object.op_Implicit((Object)(object)instantiated) && instantiated.TryGetComponent(ref val2)) { prefabMasterIndex = val2.masterIndex; if (((MasterIndex)(ref prefabMasterIndex)).isValid) { if (isMasterIndex(Caches.Masters.MalachiteUrchin)) { if (!ConfigManager.ExplicitSpawnRandomizer.RandomizeMalachiteUrchins) { return; } } else if (isMasterIndex(Caches.Masters.VoidInfestor) && !ConfigManager.ExplicitSpawnRandomizer.RandomizeVoidInfestors) { return; } ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(instantiated); } } bool isMasterIndex(MasterIndex masterIndex) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (((MasterIndex)(ref masterIndex)).isValid) { return prefabMasterIndex == masterIndex; } return false; } }); int index = val.Index; val.Index = index + 1; num++; } if (num <= 0) { Log.Warning("unable to find patch location for NetworkServer.Spawn register replacement hook", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\GlobalOnDeath_SpawnHook.cs", "GlobalEventManager_OnCharacterDeath", 200); } val.Index = 0; num = 0; while (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "Perform") })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(CharacterMaster master) { //IL_0012: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) MasterIndex spawnedMasterIndex; if (NetworkServer.active && Object.op_Implicit((Object)(object)master)) { spawnedMasterIndex = master.masterIndex; if (((MasterIndex)(ref spawnedMasterIndex)).isValid) { if (isMasterIndex(Caches.Masters.SoulWisp)) { if (!ConfigManager.ExplicitSpawnRandomizer.RandomizeSoulWisps) { return; } } else if (isMasterIndex(Caches.Masters.HealingCore) && !ConfigManager.ExplicitSpawnRandomizer.RandomizeHealingCores) { return; } ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(((Component)master).gameObject); } } bool isMasterIndex(MasterIndex masterIndex) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (((MasterIndex)(ref masterIndex)).isValid) { return spawnedMasterIndex == masterIndex; } return false; } }); num++; } if (num <= 0) { Log.Warning("unable to find patch location for MasterSummon.Perform register replacement hook", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\GlobalOnDeath_SpawnHook.cs", "GlobalEventManager_OnCharacterDeath", 251); } } } [PatchClass] internal static class MinePod_SpawnHook { private static readonly Manipulator _replaceMinePodSpawnManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones); private static void Apply() { MinePlant.SpawnMine += _replaceMinePodSpawnManipulator; } private static void Cleanup() { MinePlant.SpawnMine -= _replaceMinePodSpawnManipulator; } } [PatchClass] internal static class OrphanedCore_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__PhysicsProjectileBehavior_OnMasterSpawned; } private static readonly Manipulator _replaceBestBuddySpawnManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones); private static void Apply() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown PhysicsProjectileBehavior.TrySpawnDrone += _replaceBestBuddySpawnManipulator; object obj = <>O.<0>__PhysicsProjectileBehavior_OnMasterSpawned; if (obj == null) { Manipulator val = PhysicsProjectileBehavior_OnMasterSpawned; <>O.<0>__PhysicsProjectileBehavior_OnMasterSpawned = val; obj = (object)val; } PhysicsProjectileBehavior.OnMasterSpawned += (Manipulator)obj; } private static void Cleanup() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown PhysicsProjectileBehavior.TrySpawnDrone -= _replaceBestBuddySpawnManipulator; object obj = <>O.<0>__PhysicsProjectileBehavior_OnMasterSpawned; if (obj == null) { Manipulator val = PhysicsProjectileBehavior_OnMasterSpawned; <>O.<0>__PhysicsProjectileBehavior_OnMasterSpawned = val; obj = (object)val; } PhysicsProjectileBehavior.OnMasterSpawned -= (Manipulator)obj; } private static void PhysicsProjectileBehavior_OnMasterSpawned(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldarg_1); val.EmitDelegate>((Action)delegate(SpawnResult spawnResult) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones && spawnResult.success && Object.op_Implicit((Object)(object)spawnResult.spawnedInstance)) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(spawnResult.spawnedInstance); } }); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Component _) => _.GetComponent()))) })) { num++; val.Emit(OpCodes.Dup); int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)delegate(Component component, Deployable deployable) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)deployable) && ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones) { deployable = component.gameObject.AddComponent(); deployable.onUndeploy = new UnityEvent(); } return deployable; }); } if (num == 0) { Log.Warning("failed to find any patch locations in PhysicsProjectileBehavior.OnMasterSpawned", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\OrphanedCore_SpawnHook.cs", "PhysicsProjectileBehavior_OnMasterSpawned", 68); } } } [PatchClass] internal static class ParentEgg_HatchSpawnHook { private static readonly Manipulator Hatch_DoHatch = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeAncestralPods); private static void Apply() { Hatch.DoHatch += Hatch_DoHatch; } private static void Cleanup() { Hatch.DoHatch -= Hatch_DoHatch; } } [PatchClass] internal static class ProjectileSpawnMaster_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ProjectileSpawnMaster_SpawnMaster; } private static CharacterSpawnCard _cscMinorConstructOnKill; [SystemInitializer(new Type[] { })] private static void Init() { //IL_0005: 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) AsyncOperationHandle val = Addressables.LoadAssetAsync((object)"RoR2/DLC1/MajorAndMinorConstruct/cscMinorConstructOnKill.asset"); val.Completed += delegate(AsyncOperationHandle handle) { _cscMinorConstructOnKill = handle.Result; }; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileSpawnMaster_SpawnMaster; if (obj == null) { Manipulator val = ProjectileSpawnMaster_SpawnMaster; <>O.<0>__ProjectileSpawnMaster_SpawnMaster = val; obj = (object)val; } ProjectileSpawnMaster.SpawnMaster += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ProjectileSpawnMaster_SpawnMaster; if (obj == null) { Manipulator val = ProjectileSpawnMaster_SpawnMaster; <>O.<0>__ProjectileSpawnMaster_SpawnMaster = val; obj = (object)val; } ProjectileSpawnMaster.SpawnMaster += (Manipulator)obj; } private static void ProjectileSpawnMaster_SpawnMaster(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TrySpawnObject") })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(DirectorSpawnRequest spawnRequest, ProjectileSpawnMaster instance) { if (Object.op_Implicit((Object)(object)instance.spawnCard)) { if ((Object)(object)instance.spawnCard == (Object)(object)_cscMinorConstructOnKill) { if (!ConfigManager.ExplicitSpawnRandomizer.RandomizeDefenseNucleusAlphaConstruct) { return; } } else { Log.Warning($"unhandled spawncard {instance.spawnCard}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\ProjectileSpawnMaster_SpawnHook.cs", "ProjectileSpawnMaster_SpawnMaster", 67); } } ExplicitSpawnRandomizerController.TryReplaceDirectorSpawnRequest(spawnRequest); }); } else { Log.Warning("failed to find any patch locations", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\ProjectileSpawnMaster_SpawnHook.cs", "ProjectileSpawnMaster_SpawnMaster", 75); } } } [PatchClass] internal static class QueenGlandBeetleGuards_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__BeetleGlandBodyBehavior_FixedUpdate; public static Manipulator <1>__BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned; } private static ILHook BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BeetleGlandBodyBehavior_FixedUpdate; if (obj == null) { Manipulator val = BeetleGlandBodyBehavior_FixedUpdate; <>O.<0>__BeetleGlandBodyBehavior_FixedUpdate = val; obj = (object)val; } BeetleGlandBodyBehavior.FixedUpdate += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__BeetleGlandBodyBehavior_FixedUpdate; if (obj == null) { Manipulator val = BeetleGlandBodyBehavior_FixedUpdate; <>O.<0>__BeetleGlandBodyBehavior_FixedUpdate = val; obj = (object)val; } BeetleGlandBodyBehavior.FixedUpdate -= (Manipulator)obj; ILHook beetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook = BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook; if (beetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook != null) { beetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook.Undo(); } } private static void BeetleGlandBodyBehavior_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TrySpawnObject") })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(DirectorSpawnRequest directorSpawnRequest) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown if ((bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeQueensGlandBeetleGuards) { ExplicitSpawnRandomizerController.TryReplaceDirectorSpawnRequest(directorSpawnRequest); if (ExplicitSpawnRandomizerController.IsActive && BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook == null && directorSpawnRequest.onSpawnedServer != null) { Delegate[] invocationList = directorSpawnRequest.onSpawnedServer.GetInvocationList(); if (invocationList.Length != 0) { MethodInfo method = invocationList[0].Method; object obj = <>O.<1>__BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned; if (obj == null) { Manipulator val2 = BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned; <>O.<1>__BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned = val2; obj = (object)val2; } BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned_ILHook = new ILHook((MethodBase)method, (Manipulator)obj); } } } }); } else { Log.Warning("failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\QueenGlandBeetleGuards_SpawnHook.cs", "BeetleGlandBodyBehavior_FixedUpdate", 68); } } private static void BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldarg_1); val.EmitDelegate>((Action)delegate(SpawnResult spawnResult) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeQueensGlandBeetleGuards && spawnResult.success && Object.op_Implicit((Object)(object)spawnResult.spawnedInstance)) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(spawnResult.spawnedInstance); } }); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((Component _) => _.GetComponent()))) })) { num++; val.Emit(OpCodes.Dup); int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)delegate(Component component, Deployable deployable) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)deployable) && ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeQueensGlandBeetleGuards) { deployable = component.gameObject.AddComponent(); deployable.onUndeploy = new UnityEvent(); } return deployable; }); } if (num == 0) { Log.Warning("failed to find any patch locations in BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\QueenGlandBeetleGuards_SpawnHook.cs", "BeetleGlandBodyBehavior_FixedUpdate_OnGuardMasterSpawned", 109); } } } [PatchClass] internal static class RoboBallBossDeployMinion_SpawnHook { private static readonly Manipulator _replaceMinionsManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeRoboBallBossMinions); private static void Apply() { DeployMinions.SummonMinion += _replaceMinionsManipulator; } private static void Cleanup() { DeployMinions.SummonMinion -= _replaceMinionsManipulator; } } [PatchClass] internal static class Shopkeeper_SpawnHook { private static void Apply() { SceneCatalog.onMostRecentSceneDefChanged += onSceneLoaded; } private static void Cleanup() { SceneCatalog.onMostRecentSceneDefChanged -= onSceneLoaded; } private static void onSceneLoaded(SceneDef scene) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || (int)Caches.Scene.NewtShopSceneIndex == -1 || scene.sceneDefIndex != Caches.Scene.NewtShopSceneIndex) { return; } MasterIndex shopkeeperNewt = Caches.Masters.ShopkeeperNewt; if (!((MasterIndex)(ref shopkeeperNewt)).isValid || !ExplicitSpawnRandomizerController.IsActive || !ConfigManager.ExplicitSpawnRandomizer.RandomizeShopkeeperNewt) { return; } MasterIndex summonReplacement = ExplicitSpawnRandomizerController.GetSummonReplacement(Caches.Masters.ShopkeeperNewt); if (!((MasterIndex)(ref summonReplacement)).isValid) { return; } GameObject masterPrefab = MasterCatalog.GetMasterPrefab(summonReplacement); CharacterMaster val = default(CharacterMaster); if (!Object.op_Implicit((Object)(object)masterPrefab) || !masterPrefab.TryGetComponent(ref val) || !Object.op_Implicit((Object)(object)val.bodyPrefab)) { return; } GameObject val2 = GameObject.Find("HOLDER: Store"); if (!Object.op_Implicit((Object)(object)val2)) { Log.Warning("could not find HOLDER: Store", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\Shopkeeper_SpawnHook.cs", "onSceneLoaded", 52); return; } Transform val3 = val2.transform.Find("HOLDER: Store Platforms/ShopkeeperPosition/ShopkeeperMaster"); CharacterMaster val4 = default(CharacterMaster); if (Object.op_Implicit((Object)(object)val3) && ((Component)val3).TryGetComponent(ref val4)) { val4.bodyPrefab = val.bodyPrefab; ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(((Component)val4).gameObject, Caches.Masters.ShopkeeperNewt); } } } [PatchClass] internal static class SquidTurret_SpawnHook { private static readonly Manipulator GlobalEventManager_OnInteractionBegin = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeSquidTurrets); private static void Apply() { GlobalEventManager.OnInteractionBegin += GlobalEventManager_OnInteractionBegin; } private static void Cleanup() { GlobalEventManager.OnInteractionBegin -= GlobalEventManager_OnInteractionBegin; } } [PatchClass] internal static class SummonMasterPrefab_SpawnHook { [CompilerGenerated] private static class <>O { public static hook_OpenSummonReturnMaster <0>__SummonMasterBehavior_OpenSummonReturnMaster; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SummonMasterBehavior_OpenSummonReturnMaster; if (obj == null) { hook_OpenSummonReturnMaster val = SummonMasterBehavior_OpenSummonReturnMaster; <>O.<0>__SummonMasterBehavior_OpenSummonReturnMaster = val; obj = (object)val; } SummonMasterBehavior.OpenSummonReturnMaster += (hook_OpenSummonReturnMaster)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SummonMasterBehavior_OpenSummonReturnMaster; if (obj == null) { hook_OpenSummonReturnMaster val = SummonMasterBehavior_OpenSummonReturnMaster; <>O.<0>__SummonMasterBehavior_OpenSummonReturnMaster = val; obj = (object)val; } SummonMasterBehavior.OpenSummonReturnMaster -= (hook_OpenSummonReturnMaster)obj; } private static CharacterMaster SummonMasterBehavior_OpenSummonReturnMaster(orig_OpenSummonReturnMaster orig, SummonMasterBehavior self, Interactor activator) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!ConfigManager.ExplicitSpawnRandomizer.RandomizeDrones) { return orig.Invoke(self, activator); } GameObject originalPrefab; bool num = ExplicitSpawnRandomizerController.TryReplaceSummon(ref self.masterPrefab, out originalPrefab); CharacterMaster val = orig.Invoke(self, activator); if (num) { self.masterPrefab = originalPrefab; CharacterMaster val2 = default(CharacterMaster); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)originalPrefab) && originalPrefab.TryGetComponent(ref val2)) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(((Component)val).gameObject, val2.masterIndex); } } return val; } } [PatchClass] internal static class VoidCradleInfestors_SpawnHook { [CompilerGenerated] private static class <>O { public static hook_Spawn <0>__ScriptedCombatEncounter_Spawn; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ScriptedCombatEncounter_Spawn; if (obj == null) { hook_Spawn val = ScriptedCombatEncounter_Spawn; <>O.<0>__ScriptedCombatEncounter_Spawn = val; obj = (object)val; } ScriptedCombatEncounter.Spawn += (hook_Spawn)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ScriptedCombatEncounter_Spawn; if (obj == null) { hook_Spawn val = ScriptedCombatEncounter_Spawn; <>O.<0>__ScriptedCombatEncounter_Spawn = val; obj = (object)val; } ScriptedCombatEncounter.Spawn -= (hook_Spawn)obj; } private static void ScriptedCombatEncounter_Spawn(orig_Spawn orig, ScriptedCombatEncounter self, ref SpawnInfo spawnInfo) { GameObject originalPrefab; SpawnCard card; if (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeVoidInfestors && Object.op_Implicit((Object)(object)((Component)self).GetComponent())) { if (ExplicitSpawnRandomizerController.TryReplaceSummon(ref spawnInfo.spawnCard.prefab, out originalPrefab)) { card = spawnInfo.spawnCard; GenericScriptedSpawnHook.OnSpawned += onSpawned; } } orig.Invoke(self, ref spawnInfo); void onSpawned(SpawnResult result) { //IL_0000: 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_0023: 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_0052: 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_0082: Unknown result type (might be due to invalid IL or missing references) if (result.spawnRequest != null && (Object)(object)result.spawnRequest.spawnCard == (Object)(object)card) { result.spawnRequest.spawnCard.prefab = originalPrefab; GenericScriptedSpawnHook.OnSpawned -= onSpawned; CharacterMaster val = default(CharacterMaster); if (result.success && Object.op_Implicit((Object)(object)result.spawnedInstance) && Object.op_Implicit((Object)(object)originalPrefab) && originalPrefab.TryGetComponent(ref val)) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(result.spawnedInstance, val.masterIndex); } } } } } [PatchClass] internal static class VoidMegaCrabItemBehavior_SpawnHook { private static readonly Manipulator _replaceVoidAlliesManipulator = ExplicitSpawnRandomizerController.GetSimpleDirectorSpawnRequestHook(ConfigManager.ExplicitSpawnRandomizer.RandomizeZoeaVoidAllies); private static void Apply() { VoidMegaCrabItemBehavior.FixedUpdate += _replaceVoidAlliesManipulator; } private static void Cleanup() { VoidMegaCrabItemBehavior.FixedUpdate -= _replaceVoidAlliesManipulator; } } } namespace RoR2Randomizer.Patches.ExplicitSpawnRandomizer.Heretic { [PatchClass] internal static class Heretic_ConditionalSkillOverrideFix { [CompilerGenerated] private static class <>O { public static hook_SetSkillOverride <0>__GenericSkill_SetSkillOverride; public static hook_UnsetSkillOverride <1>__GenericSkill_UnsetSkillOverride; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__GenericSkill_SetSkillOverride; if (obj == null) { hook_SetSkillOverride val = GenericSkill_SetSkillOverride; <>O.<0>__GenericSkill_SetSkillOverride = val; obj = (object)val; } GenericSkill.SetSkillOverride += (hook_SetSkillOverride)obj; object obj2 = <>O.<1>__GenericSkill_UnsetSkillOverride; if (obj2 == null) { hook_UnsetSkillOverride val2 = GenericSkill_UnsetSkillOverride; <>O.<1>__GenericSkill_UnsetSkillOverride = val2; obj2 = (object)val2; } GenericSkill.UnsetSkillOverride += (hook_UnsetSkillOverride)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__GenericSkill_SetSkillOverride; if (obj == null) { hook_SetSkillOverride val = GenericSkill_SetSkillOverride; <>O.<0>__GenericSkill_SetSkillOverride = val; obj = (object)val; } GenericSkill.SetSkillOverride -= (hook_SetSkillOverride)obj; object obj2 = <>O.<1>__GenericSkill_UnsetSkillOverride; if (obj2 == null) { hook_UnsetSkillOverride val2 = GenericSkill_UnsetSkillOverride; <>O.<1>__GenericSkill_UnsetSkillOverride = val2; obj2 = (object)val2; } GenericSkill.UnsetSkillOverride -= (hook_UnsetSkillOverride)obj2; } private static bool isSkillOwnedByRandomizedHeretic(GenericSkill skill) { //IL_0031: 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) if (Object.op_Implicit((Object)(object)skill)) { CharacterBody characterBody = skill.characterBody; if (Object.op_Implicit((Object)(object)characterBody)) { GameObject masterObject = characterBody.masterObject; ExplicitSpawnReplacementInfo explicitSpawnReplacementInfo = default(ExplicitSpawnReplacementInfo); if (Object.op_Implicit((Object)(object)masterObject) && masterObject.TryGetComponent(ref explicitSpawnReplacementInfo) && explicitSpawnReplacementInfo.OriginalMasterIndex == Caches.Masters.Heretic) { return true; } } } return false; } private static void GenericSkill_UnsetSkillOverride(orig_UnsetSkillOverride orig, GenericSkill self, object source, SkillDef skillDef, SkillOverridePriority priority) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((int)priority != 4 || !isSkillOwnedByRandomizedHeretic(self)) { orig.Invoke(self, source, skillDef, priority); } } private static void GenericSkill_SetSkillOverride(orig_SetSkillOverride orig, GenericSkill self, object source, SkillDef skillDef, SkillOverridePriority priority) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((int)priority != 4 || !isSkillOwnedByRandomizedHeretic(self)) { orig.Invoke(self, source, skillDef, priority); } } } [PatchClass] internal static class Heretic_MULT_Fix { [CompilerGenerated] private static class <>O { public static hook_SetPrimarySkill <0>__ToolbotStanceBase_SetPrimarySkill; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ToolbotStanceBase_SetPrimarySkill; if (obj == null) { hook_SetPrimarySkill val = ToolbotStanceBase_SetPrimarySkill; <>O.<0>__ToolbotStanceBase_SetPrimarySkill = val; obj = (object)val; } ToolbotStanceBase.SetPrimarySkill += (hook_SetPrimarySkill)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ToolbotStanceBase_SetPrimarySkill; if (obj == null) { hook_SetPrimarySkill val = ToolbotStanceBase_SetPrimarySkill; <>O.<0>__ToolbotStanceBase_SetPrimarySkill = val; obj = (object)val; } ToolbotStanceBase.SetPrimarySkill -= (hook_SetPrimarySkill)obj; } private static void ToolbotStanceBase_SetPrimarySkill(orig_SetPrimarySkill orig, ToolbotStanceBase self) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (self != null) { EntityStateMachine outer = ((EntityState)self).outer; CharacterBody val = default(CharacterBody); if (Object.op_Implicit((Object)(object)outer) && ((Component)outer).TryGetComponent(ref val)) { GameObject masterObject = val.masterObject; ExplicitSpawnReplacementInfo explicitSpawnReplacementInfo = default(ExplicitSpawnReplacementInfo); if (Object.op_Implicit((Object)(object)masterObject) && masterObject.TryGetComponent(ref explicitSpawnReplacementInfo) && explicitSpawnReplacementInfo.OriginalMasterIndex == Caches.Masters.Heretic) { return; } } } orig.Invoke(self); } } [PatchClass] internal static class Heretic_TransformBodyHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__CharacterMaster_OnInventoryChanged; public static hook_TransformBody_string <1>__CharacterMaster_TransformBody_string; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__CharacterMaster_OnInventoryChanged; if (obj == null) { Manipulator val = CharacterMaster_OnInventoryChanged; <>O.<0>__CharacterMaster_OnInventoryChanged = val; obj = (object)val; } CharacterMaster.OnInventoryChanged += (Manipulator)obj; object obj2 = <>O.<1>__CharacterMaster_TransformBody_string; if (obj2 == null) { hook_TransformBody_string val2 = CharacterMaster_TransformBody_string; <>O.<1>__CharacterMaster_TransformBody_string = val2; obj2 = (object)val2; } CharacterMaster.TransformBody_string += (hook_TransformBody_string)obj2; } private static void CharacterMaster_TransformBody_string(orig_TransformBody_string orig, CharacterMaster self, string bodyName) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeHeretic && !Object.op_Implicit((Object)(object)((Component)self).GetComponent()) && (CharacterReplacements.IsAnyForcedCharacterModeEnabled || (ExplicitSpawnRandomizerController.TryGetOriginalBodyName(bodyName, out var originalName) && originalName == "HereticBody"))) { ExplicitSpawnRandomizerController.RegisterSpawnedReplacement(((Component)self).gameObject, Caches.Masters.Heretic); } orig.Invoke(self, bodyName); } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__CharacterMaster_OnInventoryChanged; if (obj == null) { Manipulator val = CharacterMaster_OnInventoryChanged; <>O.<0>__CharacterMaster_OnInventoryChanged = val; obj = (object)val; } CharacterMaster.OnInventoryChanged -= (Manipulator)obj; object obj2 = <>O.<1>__CharacterMaster_TransformBody_string; if (obj2 == null) { hook_TransformBody_string val2 = CharacterMaster_TransformBody_string; <>O.<1>__CharacterMaster_TransformBody_string = val2; obj2 = (object)val2; } CharacterMaster.TransformBody_string -= (hook_TransformBody_string)obj2; } private static void CharacterMaster_OnInventoryChanged(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_015f: 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) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "HereticBody"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TransformBody") })) { array[1].EmitDelegate>((Func)((string bodyName) => (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeHeretic && ExplicitSpawnRandomizerController.TryGetReplacementBodyName(bodyName, out var replacementName)) ? replacementName : bodyName)); } else { Log.Warning("failed to find the patch location for TransformBody", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\Heretic\\Heretic_TransformBodyHook.cs", "CharacterMaster_OnInventoryChanged", 66); } val.Index = 0; ILLabel val3 = default(ILLabel); if (val.TryFindNext(ref array, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "bodyIndex"), (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "HereticBody"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => BodyCatalog.FindBodyIndex((string)null)))), (Instruction x) => ILPatternMatchingExt.MatchBeq(x, ref val3) })) { ILCursor obj = array[3]; ILLabel val2 = (ILLabel)obj.Next.Operand; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Func)delegate(CharacterMaster instance) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeHeretic) { MasterIndex heretic = Caches.Masters.Heretic; if (((MasterIndex)(ref heretic)).isValid) { ExplicitSpawnReplacementInfo explicitSpawnReplacementInfo = default(ExplicitSpawnReplacementInfo); if (((Component)instance).TryGetComponent(ref explicitSpawnReplacementInfo)) { return explicitSpawnReplacementInfo.OriginalMasterIndex == Caches.Masters.Heretic; } return false; } } return false; }); obj.Emit(OpCodes.Brtrue, (object)val2); } else { Log.Warning("failed to find the patch location for FindBodyIndex", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\Heretic\\Heretic_TransformBodyHook.cs", "CharacterMaster_OnInventoryChanged", 100); } } } } namespace RoR2Randomizer.Patches.ExplicitSpawnRandomizer.Director { [PatchClass] internal static class ArenaMissionController_ReplaceMonsterDisplay { [CompilerGenerated] private static class <>O { public static Manipulator <0>__ArenaMissionController_AddMonsterType; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ArenaMissionController_AddMonsterType; if (obj == null) { Manipulator val = ArenaMissionController_AddMonsterType; <>O.<0>__ArenaMissionController_AddMonsterType = val; obj = (object)val; } ArenaMissionController.AddMonsterType += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ArenaMissionController_AddMonsterType; if (obj == null) { Manipulator val = ArenaMissionController_AddMonsterType; <>O.<0>__ArenaMissionController_AddMonsterType = val; obj = (object)val; } ArenaMissionController.AddMonsterType -= (Manipulator)obj; } private static void ArenaMissionController_AddMonsterType(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); int num = 0; int num2 = default(int); while (val.TryGotoNext((MoveType)2, new Func[4] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "spawnCard"), (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "prefab"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((GameObject _) => _.GetComponent()))) })) { val.EmitDelegate>((Func)((CharacterMaster masterPrefab) => (ExplicitSpawnRandomizerController.IsActive && (bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeDirectorSpawns) ? ExplicitSpawnRandomizerController.GetSummonReplacement(masterPrefab) : masterPrefab)); num++; } if (num == 0) { Log.Warning("no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\Director\\ArenaMissionController_ReplaceMonsterDisplay.cs", "ArenaMissionController_AddMonsterType", 52); } } } [PatchClass] internal static class CombatDirector_SpawnHook { [CompilerGenerated] private static class <>O { public static Manipulator <0>__CombatDirector_Spawn; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CombatDirector_Spawn; if (obj == null) { Manipulator val = CombatDirector_Spawn; <>O.<0>__CombatDirector_Spawn = val; obj = (object)val; } CombatDirector.Spawn += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CombatDirector_Spawn; if (obj == null) { Manipulator val = CombatDirector_Spawn; <>O.<0>__CombatDirector_Spawn = val; obj = (object)val; } CombatDirector.Spawn -= (Manipulator)obj; } private static void CombatDirector_Spawn(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TrySpawnObject") })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(DirectorSpawnRequest spawnRequest, CombatDirector combatDirector) { if (Object.op_Implicit((Object)(object)((Component)combatDirector).GetComponent()) && string.Equals(combatDirector.customName, "Boss", StringComparison.OrdinalIgnoreCase)) { BossRandomizerController.HoldoutBoss.TryReplaceDirectorSpawnRequest(spawnRequest); } else if (shouldRandomizeAsExplicitSpawn()) { ExplicitSpawnRandomizerController.TryReplaceDirectorSpawnRequest(spawnRequest); } bool shouldRandomizeAsExplicitSpawn() { if ((bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeDirectorSpawns) { return true; } VoidSeedMarker voidSeedMarker = default(VoidSeedMarker); if ((bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeVoidSeedMonsters && ((Component)combatDirector).TryGetComponent(ref voidSeedMarker) && voidSeedMarker.Type == VoidSeedMarker.MarkerType.Monsters_Interactibles) { return true; } return false; } }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\ExplicitSpawnRandomizer\\Director\\CombatDirector_SpawnHook.cs", "CombatDirector_Spawn", 80); } } } } namespace RoR2Randomizer.Patches.EnemyInfoPanelEquipmentDisplay { [PatchClass] internal static class AddEquipmentDisplayControllerPatch { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__EnemyInfoPanel_Awake; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EnemyInfoPanel_Awake; if (obj == null) { hook_Awake val = EnemyInfoPanel_Awake; <>O.<0>__EnemyInfoPanel_Awake = val; obj = (object)val; } EnemyInfoPanel.Awake += (hook_Awake)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EnemyInfoPanel_Awake; if (obj == null) { hook_Awake val = EnemyInfoPanel_Awake; <>O.<0>__EnemyInfoPanel_Awake = val; obj = (object)val; } EnemyInfoPanel.Awake -= (hook_Awake)obj; } private static void EnemyInfoPanel_Awake(orig_Awake orig, EnemyInfoPanel self) { orig.Invoke(self); ((Component)self).gameObject.AddComponent(); } } [PatchClass] internal static class ShouldDisplayPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__EnemyInfoPanel_SetDisplayDataForViewer; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer; if (obj == null) { Manipulator val = EnemyInfoPanel_SetDisplayDataForViewer; <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer = val; obj = (object)val; } EnemyInfoPanel.SetDisplayDataForViewer += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer; if (obj == null) { Manipulator val = EnemyInfoPanel_SetDisplayDataForViewer; <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer = val; obj = (object)val; } EnemyInfoPanel.SetDisplayDataForViewer -= (Manipulator)obj; } private static void EnemyInfoPanel_SetDisplayDataForViewer(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, 0) })) { val.Emit(OpCodes.Ldloc, 0); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)((bool shouldDisplay, HUD hud) => shouldDisplay || TrySetEquipmentsPatch.GetAllInventoryProviderEquipments(hud.targetMaster.teamIndex).Any())); val.Emit(OpCodes.Stloc, 0); } else { Log.Error("Failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\EnemyInfoPanelEquipmentDisplay\\ShouldDisplayPatch.cs", "EnemyInfoPanel_SetDisplayDataForViewer", 40); } } } [PatchClass] internal static class TrySetEquipmentsPatch { [CompilerGenerated] private static class <>O { public static Manipulator <0>__EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments; if (obj == null) { Manipulator val = EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments; <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments = val; obj = (object)val; } EnemyInfoPanel.SetDisplayDataForViewer += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments; if (obj == null) { Manipulator val = EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments; <>O.<0>__EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments = val; obj = (object)val; } EnemyInfoPanel.SetDisplayDataForViewer -= (Manipulator)obj; } internal static IEnumerable GetAllInventoryProviderEquipments(TeamIndex viewerTeam) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return InstanceTracker.GetInstancesList().SelectMany(delegate(EnemyInfoPanelInventoryProvider inventoryProvider) { //IL_000c: 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) if (inventoryProvider.teamFilter.teamIndex == viewerTeam) { return Enumerable.Empty(); } Inventory inventory = inventoryProvider.inventory; return from i in Enumerable.Range(0, inventory.GetEquipmentSlotCount()) select inventory.GetEquipment((uint)i).equipmentIndex into ei where (int)ei != -1 select ei; }).Distinct(); } private static void EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int enemyInfoPanelLocalIndex = -1; ILCursor[] array = default(ILCursor[]); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => EnemyInfoPanel.SetDisplayingOnHud((HUD)null, false)))), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref enemyInfoPanelLocalIndex) })) { if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((EnemyInfoPanel _) => _.TrySetItems((ItemIndex[])null, 0, (int[])null)))) })) { val.Emit(OpCodes.Ldloc, enemyInfoPanelLocalIndex); val.EmitDelegate>((Action)delegate(EnemyInfoPanel enemyInfoPanel) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) EnemyInfoPanelEquipmentDisplayController enemyInfoPanelEquipmentDisplayController = default(EnemyInfoPanelEquipmentDisplayController); if (((Component)enemyInfoPanel).TryGetComponent(ref enemyInfoPanelEquipmentDisplayController)) { TeamIndex teamIndex = enemyInfoPanel.hud.targetMaster.teamIndex; enemyInfoPanelEquipmentDisplayController.TrySetEquipments(GetAllInventoryProviderEquipments(teamIndex).ToArray()); } }); } else { Log.Error("Failed to find TrySetItems call", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\EnemyInfoPanelEquipmentDisplay\\TrySetEquipmentsPatch.cs", "EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments", 70); } } else { Log.Error("Failed to find enemyInfoPanel local index", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\EnemyInfoPanelEquipmentDisplay\\TrySetEquipmentsPatch.cs", "EnemyInfoPanel_SetDisplayDataForViewer_TrySetEqipments", 75); } } } } namespace RoR2Randomizer.Patches.EffectRandomizer { [PatchClass] internal static class SpawnEffectHook { [CompilerGenerated] private static class <>O { public static hook_SpawnEffect_EffectIndex_EffectData_bool <0>__EffectManager_SpawnEffect; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EffectManager_SpawnEffect; if (obj == null) { hook_SpawnEffect_EffectIndex_EffectData_bool val = EffectManager_SpawnEffect; <>O.<0>__EffectManager_SpawnEffect = val; obj = (object)val; } EffectManager.SpawnEffect_EffectIndex_EffectData_bool += (hook_SpawnEffect_EffectIndex_EffectData_bool)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__EffectManager_SpawnEffect; if (obj == null) { hook_SpawnEffect_EffectIndex_EffectData_bool val = EffectManager_SpawnEffect; <>O.<0>__EffectManager_SpawnEffect = val; obj = (object)val; } EffectManager.SpawnEffect_EffectIndex_EffectData_bool -= (hook_SpawnEffect_EffectIndex_EffectData_bool)obj; } private static void EffectManager_SpawnEffect(orig_SpawnEffect_EffectIndex_EffectData_bool orig, EffectIndex effectIndex, EffectData effectData, bool transmit) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (!transmit) { EffectRandomizerController.TryReplaceEffectIndex(ref effectIndex); } orig.Invoke(effectIndex, effectData, transmit); } } } namespace RoR2Randomizer.Patches.CharacterLimiting { [PatchClass] internal static class EngiAsTurret { [CompilerGenerated] private static class <>O { public static Manipulator <0>__CharacterBody_HandleConstructTurret; } private static MasterIndex _engiMasterIndex; [SystemInitializer(new Type[] { typeof(MasterCatalog) })] private static void Init() { //IL_0005: 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) _engiMasterIndex = MasterCatalog.FindMasterIndex("EngiMonsterMaster"); } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_HandleConstructTurret; if (obj == null) { Manipulator val = CharacterBody_HandleConstructTurret; <>O.<0>__CharacterBody_HandleConstructTurret = val; obj = (object)val; } CharacterBody.HandleConstructTurret += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_HandleConstructTurret; if (obj == null) { Manipulator val = CharacterBody_HandleConstructTurret; <>O.<0>__CharacterBody_HandleConstructTurret = val; obj = (object)val; } CharacterBody.HandleConstructTurret -= (Manipulator)obj; } private static void CharacterBody_HandleConstructTurret(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "Perform") })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(CharacterMaster summoned, CharacterBody owner) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active && ((MasterIndex)(ref _engiMasterIndex)).isValid && Object.op_Implicit((Object)(object)summoned) && summoned.masterIndex == _engiMasterIndex) { GameObject owner2; if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)owner.master)) { owner2 = ((Component)owner.master).gameObject; if (owner.master.masterIndex != _engiMasterIndex) { return; } } else { owner2 = null; } LimitedCharacterData.AddGeneration(((Component)summoned).gameObject, owner2, LimitedCharacterType.EngiAsTurret); } }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\CharacterLimiting\\EngiAsTurret.cs", "CharacterBody_HandleConstructTurret", 65); } } } [PatchClass] internal static class GetDeployableSameSlotLimitPatch { [CompilerGenerated] private static class <>O { public static hook_GetDeployableSameSlotLimit <0>__CharacterMaster_GetDeployableSameSlotLimit; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterMaster_GetDeployableSameSlotLimit; if (obj == null) { hook_GetDeployableSameSlotLimit val = CharacterMaster_GetDeployableSameSlotLimit; <>O.<0>__CharacterMaster_GetDeployableSameSlotLimit = val; obj = (object)val; } CharacterMaster.GetDeployableSameSlotLimit += (hook_GetDeployableSameSlotLimit)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterMaster_GetDeployableSameSlotLimit; if (obj == null) { hook_GetDeployableSameSlotLimit val = CharacterMaster_GetDeployableSameSlotLimit; <>O.<0>__CharacterMaster_GetDeployableSameSlotLimit = val; obj = (object)val; } CharacterMaster.GetDeployableSameSlotLimit -= (hook_GetDeployableSameSlotLimit)obj; } private static int CharacterMaster_GetDeployableSameSlotLimit(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_002d: 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) int num = orig.Invoke(self, slot); CharacterLimitMode characterLimitMode = ConfigManager.Performance.SpawnLimitMode; LimitedCharacterData limitedCharacterData = default(LimitedCharacterData); if (characterLimitMode > CharacterLimitMode.Off && (int)slot != 35 && ((Component)self).TryGetComponent(ref limitedCharacterData) && limitedCharacterData.DeployableType == slot) { int generation = limitedCharacterData.Generation; if (generation > 0) { switch (characterLimitMode) { case CharacterLimitMode.DecreaseByOneForEveryGeneration: num -= generation; break; case CharacterLimitMode.HalveForEveryGeneration: num = Mathf.FloorToInt((float)num * Mathf.Pow(0.5f, (float)generation)); break; case CharacterLimitMode.DisableMinionSummon: num = 0; break; } } } return Mathf.Max(num, 0); } } [PatchClass] internal static class Goobo { [CompilerGenerated] private static class <>O { public static Manipulator <0>__GummyCloneProjectile_SpawnGummyClone; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GummyCloneProjectile_SpawnGummyClone; if (obj == null) { Manipulator val = GummyCloneProjectile_SpawnGummyClone; <>O.<0>__GummyCloneProjectile_SpawnGummyClone = val; obj = (object)val; } GummyCloneProjectile.SpawnGummyClone += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GummyCloneProjectile_SpawnGummyClone; if (obj == null) { Manipulator val = GummyCloneProjectile_SpawnGummyClone; <>O.<0>__GummyCloneProjectile_SpawnGummyClone = val; obj = (object)val; } GummyCloneProjectile.SpawnGummyClone -= (Manipulator)obj; } private static void GummyCloneProjectile_SpawnGummyClone(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "TrySpawnObject") })) { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(DirectorSpawnRequest gooboSpawnRequest, GummyCloneProjectile instance) { if (gooboSpawnRequest != null) { ProjectileController val2 = default(ProjectileController); CharacterBody val3 = default(CharacterBody); GameObject owner; if (Object.op_Implicit((Object)(object)instance) && ((Component)instance).TryGetComponent(ref val2) && Object.op_Implicit((Object)(object)val2.owner) && val2.owner.TryGetComponent(ref val3)) { owner = val3.masterObject; } else { owner = null; } MiscUtils.AppendDelegate(ref gooboSpawnRequest.onSpawnedServer, delegate(SpawnResult result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (result.success && Object.op_Implicit((Object)(object)result.spawnedInstance)) { LimitedCharacterData.AddGeneration(result.spawnedInstance, owner, LimitedCharacterType.Goobo); } }); } }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\CharacterLimiting\\Goobo.cs", "GummyCloneProjectile_SpawnGummyClone", 59); } } } } namespace RoR2Randomizer.Patches.CharacterAnimationMirroring { [PatchClass] internal static class Animator_ReplaceWithMirror_Hook { internal static int PatchDisabledCount; private static readonly ILHook[] _animatorILHooks; static Animator_ReplaceWithMirror_Hook() { //IL_0002: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown ILHookConfig val = new ILHookConfig { ManualApply = true }; MethodInfo[] array = (from m in typeof(Animator).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where MethodBaseExtensions.HasMethodBody((MethodBase)m) && !m.IsGenericMethod select m).ToArray(); int num = array.Length; _animatorILHooks = (ILHook[])(object)new ILHook[num]; for (int num2 = 0; num2 < num; num2++) { _animatorILHooks[num2] = new ILHook((MethodBase)array[num2], (Manipulator)delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val2 = new ILCursor(il); val2.Emit(OpCodes.Ldarg_0); val2.EmitDelegate>((Func)delegate(Object instance) { if (PatchDisabledCount <= 0) { Animator val3 = (Animator)(object)((instance is Animator) ? instance : null); if (val3 != null) { return (Object)(object)CharacterAnimationMirrorOwner.GetMirrorTargetAnimatorOrOriginal(val3); } } return instance; }); val2.Emit(OpCodes.Starg, 0); }, ref val); } } private static void Apply() { if (_animatorILHooks != null) { ILHook[] animatorILHooks = _animatorILHooks; for (int i = 0; i < animatorILHooks.Length; i++) { animatorILHooks[i].Apply(); } } } private static void Cleanup() { if (_animatorILHooks != null) { ILHook[] animatorILHooks = _animatorILHooks; for (int i = 0; i < animatorILHooks.Length; i++) { animatorILHooks[i].Undo(); } } } private static Animator EntityState_GetModelAnimator(orig_GetModelAnimator orig, EntityState self) { Animator val = orig.Invoke(self); if (PatchDisabledCount <= 0) { val = CharacterAnimationMirrorOwner.GetMirrorTargetAnimatorOrOriginal(val); } return val; } } } namespace RoR2Randomizer.Patches.BuffRandomizer { [PatchClass] public static class BuffIndexPatch { [CompilerGenerated] private static class <>O { public static hook_SetBuffCount <0>__CharacterBody_SetBuffCount; public static Manipulator <1>__IL_CharacterBody_AddTimedBuff_BuffDef_float; public static hook_AddTimedBuff_BuffDef_float <2>__On_CharacterBody_AddTimedBuff_BuffDef_float; public static Manipulator <3>__replaceReadBuffCountFromArray; public static Func <4>__simpleReplaceBuffIndex; } public static uint SkipPatchCount; private static ILHook[] CharacterBody_AddTimedBuff_BuffDef_float_localFunctionPatches; private static float? _currentAddTimedBuffDuration; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_SetBuffCount; if (obj == null) { hook_SetBuffCount val = CharacterBody_SetBuffCount; <>O.<0>__CharacterBody_SetBuffCount = val; obj = (object)val; } CharacterBody.SetBuffCount += (hook_SetBuffCount)obj; object obj2 = <>O.<1>__IL_CharacterBody_AddTimedBuff_BuffDef_float; if (obj2 == null) { Manipulator val2 = IL_CharacterBody_AddTimedBuff_BuffDef_float; <>O.<1>__IL_CharacterBody_AddTimedBuff_BuffDef_float = val2; obj2 = (object)val2; } CharacterBody.AddTimedBuff_BuffDef_float += (Manipulator)obj2; object obj3 = <>O.<2>__On_CharacterBody_AddTimedBuff_BuffDef_float; if (obj3 == null) { hook_AddTimedBuff_BuffDef_float val3 = On_CharacterBody_AddTimedBuff_BuffDef_float; <>O.<2>__On_CharacterBody_AddTimedBuff_BuffDef_float = val3; obj3 = (object)val3; } CharacterBody.AddTimedBuff_BuffDef_float += (hook_AddTimedBuff_BuffDef_float)obj3; object obj4 = <>O.<3>__replaceReadBuffCountFromArray; if (obj4 == null) { Manipulator val4 = replaceReadBuffCountFromArray; <>O.<3>__replaceReadBuffCountFromArray = val4; obj4 = (object)val4; } CharacterBody.AddBuff_BuffIndex += (Manipulator)obj4; object obj5 = <>O.<3>__replaceReadBuffCountFromArray; if (obj5 == null) { Manipulator val5 = replaceReadBuffCountFromArray; <>O.<3>__replaceReadBuffCountFromArray = val5; obj5 = (object)val5; } CharacterBody.RemoveBuff_BuffIndex += (Manipulator)obj5; } private static void On_CharacterBody_AddTimedBuff_BuffDef_float(orig_AddTimedBuff_BuffDef_float orig, CharacterBody self, BuffDef buffDef, float duration) { _currentAddTimedBuffDuration = duration; orig.Invoke(self, buffDef, duration); _currentAddTimedBuffDuration = null; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_SetBuffCount; if (obj == null) { hook_SetBuffCount val = CharacterBody_SetBuffCount; <>O.<0>__CharacterBody_SetBuffCount = val; obj = (object)val; } CharacterBody.SetBuffCount -= (hook_SetBuffCount)obj; object obj2 = <>O.<1>__IL_CharacterBody_AddTimedBuff_BuffDef_float; if (obj2 == null) { Manipulator val2 = IL_CharacterBody_AddTimedBuff_BuffDef_float; <>O.<1>__IL_CharacterBody_AddTimedBuff_BuffDef_float = val2; obj2 = (object)val2; } CharacterBody.AddTimedBuff_BuffDef_float -= (Manipulator)obj2; object obj3 = <>O.<2>__On_CharacterBody_AddTimedBuff_BuffDef_float; if (obj3 == null) { hook_AddTimedBuff_BuffDef_float val3 = On_CharacterBody_AddTimedBuff_BuffDef_float; <>O.<2>__On_CharacterBody_AddTimedBuff_BuffDef_float = val3; obj3 = (object)val3; } CharacterBody.AddTimedBuff_BuffDef_float -= (hook_AddTimedBuff_BuffDef_float)obj3; object obj4 = <>O.<3>__replaceReadBuffCountFromArray; if (obj4 == null) { Manipulator val4 = replaceReadBuffCountFromArray; <>O.<3>__replaceReadBuffCountFromArray = val4; obj4 = (object)val4; } CharacterBody.AddBuff_BuffIndex -= (Manipulator)obj4; object obj5 = <>O.<3>__replaceReadBuffCountFromArray; if (obj5 == null) { Manipulator val5 = replaceReadBuffCountFromArray; <>O.<3>__replaceReadBuffCountFromArray = val5; obj5 = (object)val5; } CharacterBody.RemoveBuff_BuffIndex -= (Manipulator)obj5; if (CharacterBody_AddTimedBuff_BuffDef_float_localFunctionPatches == null) { return; } ILHook[] characterBody_AddTimedBuff_BuffDef_float_localFunctionPatches = CharacterBody_AddTimedBuff_BuffDef_float_localFunctionPatches; foreach (ILHook obj6 in characterBody_AddTimedBuff_BuffDef_float_localFunctionPatches) { if (obj6 != null) { obj6.Undo(); } } } private static void IL_CharacterBody_AddTimedBuff_BuffDef_float(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "buffIndex") })) { val.EmitDelegate>((Func)simpleReplaceBuffIndex); int index = val.Index; val.Index = index + 1; num++; } if (num == 0) { Log.Warning("buffIndex stfld: no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\BuffIndexPatch.cs", "IL_CharacterBody_AddTimedBuff_BuffDef_float", 85); } val.Index = 0; num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "buffIndex") })) { int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)simpleReplaceBuffIndex); num++; } if (num == 0) { Log.Warning("buffIndex ldfld: no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\BuffIndexPatch.cs", "IL_CharacterBody_AddTimedBuff_BuffDef_float", 106); } HashSet hashSet = new HashSet(); val.Index = 0; ILCursor val4 = default(ILCursor); while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val4) && ((MemberReference)val4).Name.StartsWith("g__") })) { MethodReference val2 = (MethodReference)val.Next.Operand; MethodInfo method = typeof(CharacterBody).GetMethod(((MemberReference)val2).Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); if (method != null) { hashSet.Add(method); } else { Log.Warning("unable to find method " + ((MemberReference)val2).Name, "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\BuffIndexPatch.cs", "IL_CharacterBody_AddTimedBuff_BuffDef_float", 127); } } if (hashSet.Count == 0) { Log.Warning("could not find any local functions to hook", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\BuffIndexPatch.cs", "IL_CharacterBody_AddTimedBuff_BuffDef_float", 133); } if (CharacterBody_AddTimedBuff_BuffDef_float_localFunctionPatches != null) { return; } CharacterBody_AddTimedBuff_BuffDef_float_localFunctionPatches = (ILHook[])(object)new ILHook[hashSet.Count]; ILHookConfig val3 = new ILHookConfig { ManualApply = false }; int num2 = 0; foreach (MethodInfo localFunctions in hashSet) { CharacterBody_AddTimedBuff_BuffDef_float_localFunctionPatches[num2] = new ILHook((MethodBase)localFunctions, (Manipulator)delegate(ILContext val5) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown val4 = new ILCursor(val5); int num3 = 0; while (val4.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "buffIndex") })) { val4.EmitDelegate>((Func)simpleReplaceBuffIndex); int index2 = val4.Index; val4.Index = index2 + 1; num3++; } if (num3 == 0) { Log.Warning(GeneralExtensions.FullDescription((MethodBase)localFunctions) + " buffIndex stfld: no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\BuffIndexPatch.cs", "IL_CharacterBody_AddTimedBuff_BuffDef_float", 167); } val4.Index = 0; num3 = 0; while (val4.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "buffIndex") })) { int index2 = val4.Index; val4.Index = index2 + 1; val4.EmitDelegate>((Func)simpleReplaceBuffIndex); num3++; } if (num3 == 0) { Log.Warning(GeneralExtensions.FullDescription((MethodBase)localFunctions) + " buffIndex ldfld: no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\BuffIndexPatch.cs", "IL_CharacterBody_AddTimedBuff_BuffDef_float", 188); } }, val3); } static BuffIndex simpleReplaceBuffIndex(BuffIndex original) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (SkipPatchCount == 0 && BuffRandomizerController.IsActive) { BuffRandomizerController.TryReplaceBuffIndex(ref original); } return original; } } private static void CharacterBody_SetBuffCount(orig_SetBuffCount orig, CharacterBody self, BuffIndex buffType, int newCount) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if (SkipPatchCount == 0 && BuffRandomizerController.IsActive && BuffRandomizerController.TryReplaceBuffIndex(ref buffType) && BuffRandomizerController.TryGetDotIndex(buffType, out var dot)) { int num = newCount - self.buffs[buffType]; if (num > 0) { GameObject val = ((Component)self).gameObject; HealthComponent healthComponent = self.healthComponent; if (Object.op_Implicit((Object)(object)healthComponent)) { GameObject lastHitAttacker = healthComponent.lastHitAttacker; if (Object.op_Implicit((Object)(object)lastHitAttacker)) { val = lastHitAttacker; } } DotRandomizerPatch.SkipApplyBuffCount++; float num2 = _currentAddTimedBuffDuration ?? float.PositiveInfinity; for (int i = 0; i < num; i++) { DotController.InflictDot(((Component)self).gameObject, val, dot, num2, 0f, (uint?)1u); } DotRandomizerPatch.SkipApplyBuffCount--; return; } if (num < 0) { DotController val2 = DotController.FindDotController(((Component)self).gameObject); if (Object.op_Implicit((Object)(object)val2)) { int num3 = 0; List dotStackList = val2.dotStackList; int num4 = dotStackList.Count - 1; while (num4 >= 0 && num3 < -num) { DotStack val3 = dotStackList[num4]; if (val3 != null && val3.dotIndex == dot) { DotDef dotDef = val3.dotDef; if (dotDef != null) { BuffDef associatedBuff = dotDef.associatedBuff; if (Object.op_Implicit((Object)(object)associatedBuff) && associatedBuff.buffIndex == buffType) { num3++; SkipPatchCount++; val2.RemoveDotStackAtServer(num4); SkipPatchCount--; } } } num4--; } if (num3 == -num) { return; } } } } orig.Invoke(self, buffType, newCount); } private static void replaceReadBuffCountFromArray(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); while (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "buffs"), (Instruction x) => ILPatternMatchingExt.MatchLdelemI4(x) })) { ILCursor val2 = array[^1]; val2.EmitDelegate>((Func)delegate(int buffIndex) { if (SkipPatchCount == 0 && BuffRandomizerController.IsActive) { BuffRandomizerController.TryReplaceBuffIndex(ref buffIndex); } return buffIndex; }); val.Index = val2.Index + 1; } } } [PatchClass] internal static class DotRandomizerPatch { [CompilerGenerated] private static class <>O { public static hook_InflictDot_refInflictDotInfo <0>__DotController_InflictDot_refInflictDotInfo; public static hook_OnDotStackRemovedServer <1>__DotController_OnDotStackRemovedServer; } public static uint SkipApplyBuffCount; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__DotController_InflictDot_refInflictDotInfo; if (obj == null) { hook_InflictDot_refInflictDotInfo val = DotController_InflictDot_refInflictDotInfo; <>O.<0>__DotController_InflictDot_refInflictDotInfo = val; obj = (object)val; } DotController.InflictDot_refInflictDotInfo += (hook_InflictDot_refInflictDotInfo)obj; object obj2 = <>O.<1>__DotController_OnDotStackRemovedServer; if (obj2 == null) { hook_OnDotStackRemovedServer val2 = DotController_OnDotStackRemovedServer; <>O.<1>__DotController_OnDotStackRemovedServer = val2; obj2 = (object)val2; } DotController.OnDotStackRemovedServer += (hook_OnDotStackRemovedServer)obj2; } private static void DotController_OnDotStackRemovedServer(orig_OnDotStackRemovedServer orig, DotController self, DotStack dotStack) { BuffIndexPatch.SkipPatchCount++; orig.Invoke(self, dotStack); BuffIndexPatch.SkipPatchCount--; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__DotController_InflictDot_refInflictDotInfo; if (obj == null) { hook_InflictDot_refInflictDotInfo val = DotController_InflictDot_refInflictDotInfo; <>O.<0>__DotController_InflictDot_refInflictDotInfo = val; obj = (object)val; } DotController.InflictDot_refInflictDotInfo -= (hook_InflictDot_refInflictDotInfo)obj; object obj2 = <>O.<1>__DotController_OnDotStackRemovedServer; if (obj2 == null) { hook_OnDotStackRemovedServer val2 = DotController_OnDotStackRemovedServer; <>O.<1>__DotController_OnDotStackRemovedServer = val2; obj2 = (object)val2; } DotController.OnDotStackRemovedServer -= (hook_OnDotStackRemovedServer)obj2; } private static void DotController_InflictDot_refInflictDotInfo(orig_InflictDot_refInflictDotInfo orig, ref InflictDotInfo inflictDotInfo) { //IL_0015: 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_003d: 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_00ac: Unknown result type (might be due to invalid IL or missing references) if (BuffRandomizerController.IsActive && SkipApplyBuffCount == 0 && BuffRandomizerController.TryGetBuffIndex(inflictDotInfo.dotIndex, out var buff) && BuffRandomizerController.TryReplaceBuffIndex(ref buff)) { if (!BuffRandomizerController.TryGetDotIndex(buff, out var dot)) { HealthComponent val = default(HealthComponent); if (Object.op_Implicit((Object)(object)inflictDotInfo.victimObject) && inflictDotInfo.victimObject.TryGetComponent(ref val)) { if (!val.alive) { return; } if (Object.op_Implicit((Object)(object)val.body)) { BuffIndexPatch.SkipPatchCount++; GetBuffIndex_BuffIndex_ReplacePatch.ForceDisable = true; float num = inflictDotInfo.duration; if (num <= 0f) { num = 8f; } val.body.AddTimedBuff(buff, num); GetBuffIndex_BuffIndex_ReplacePatch.ForceDisable = false; BuffIndexPatch.SkipPatchCount--; } else { Log.Warning("victim object has no body ({inflictDotInfo.victimObject})", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\DotRandomizerPatch.cs", "DotController_InflictDot_refInflictDotInfo", 73); } } else { Log.Warning("victim object has no health component ({inflictDotInfo.victimObject})", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\DotRandomizerPatch.cs", "DotController_InflictDot_refInflictDotInfo", 79); } return; } inflictDotInfo.dotIndex = dot; } BuffIndexPatch.SkipPatchCount++; orig.Invoke(ref inflictDotInfo); BuffIndexPatch.SkipPatchCount--; } } [PatchClass] internal static class GetBuffIndex_BuffIndex_ReplacePatch { [PatchClass] private static class GenericOptIn { private static readonly MethodInfo CharacterBody_GetBuffCount_BuffIndex_MI = SymbolExtensions.GetMethodInfo((Expression>)((CharacterBody _) => _.GetBuffCount((BuffIndex)0))); private static readonly Manipulator CharacterBody_GetBuffCount_BuffIndex_Manipulator = getGenericManipulator(CharacterBody_GetBuffCount_BuffIndex_MI); private static readonly MethodInfo CharacterBody_GetBuffCount_BuffDef_MI = SymbolExtensions.GetMethodInfo((Expression>)((CharacterBody _) => _.GetBuffCount((BuffDef)null))); private static readonly Manipulator CharacterBody_GetBuffCount_BuffDef_Manipulator = getGenericManipulator(CharacterBody_GetBuffCount_BuffDef_MI); private static readonly MethodInfo CharacterBody_HasBuff_BuffDef_MI = SymbolExtensions.GetMethodInfo((Expression>)((CharacterBody _) => _.HasBuff((BuffDef)null))); private static readonly Manipulator CharacterBody_HasBuff_BuffDef_Manipulator = getGenericManipulator(CharacterBody_HasBuff_BuffDef_MI); private static readonly Manipulator CharacterBody_GetBuffCount_BuffDef_CharacterBody_GetBuffCount_BuffDef_Manipulator = getGenericManipulator(CharacterBody_GetBuffCount_BuffDef_MI, CharacterBody_HasBuff_BuffDef_MI); private static readonly ILHook RoR2_Items_ShockNearbyBodyBehavior_OnDisable = new ILHook((MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((ShockNearbyBodyBehavior _) => _.OnDisable())), CharacterBody_HasBuff_BuffDef_Manipulator, new ILHookConfig { ManualApply = true }); private static readonly ILHook RoR2_VoidSurvivorController_get_isCorrupted = new ILHook((MethodBase)AccessTools.DeclaredPropertyGetter(typeof(VoidSurvivorController), "isCorrupted"), CharacterBody_HasBuff_BuffDef_Manipulator, new ILHookConfig { ManualApply = true }); private static Manipulator getGenericManipulator(params MethodBase[] patchMethods) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return (Manipulator)delegate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MethodBase[] array = patchMethods; foreach (MethodBase method in array) { int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, method) })) { val.Emit(OpCodes.Call, (MethodBase)enablePatch_MI); int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Call, (MethodBase)disablePatch_MI); num++; } if (num == 0) { Log.Warning("(" + ((MemberReference)il.Method).FullName + ") no match found for " + GeneralExtensions.FullDescription(method), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\GetBuffCount\\GenericOptIn.cs", "getGenericManipulator", 35); } val.Index = 0; } }; } private static void Apply() { PlatingBuffMainState.GetInteractability += CharacterBody_GetBuffCount_BuffIndex_Manipulator; PlatingBuffMainState.OnInteractionBegin += CharacterBody_GetBuffCount_BuffIndex_Manipulator; CharacterBody.AddTimedBuff_BuffDef_float_int += CharacterBody_GetBuffCount_BuffDef_Manipulator; MushroomVoidBehavior.OnEnable += CharacterBody_GetBuffCount_BuffDef_Manipulator; PrimarySkillShurikenBehavior.FixedUpdate += CharacterBody_GetBuffCount_BuffDef_Manipulator; PrimarySkillShurikenBehavior.OnDisable += CharacterBody_HasBuff_BuffDef_Manipulator; CastSmokescreen.OnExit += CharacterBody_HasBuff_BuffDef_Manipulator; CastSmokescreenNoDelay.OnExit += CharacterBody_HasBuff_BuffDef_Manipulator; Capture.TargetIsTethered += CharacterBody_HasBuff_BuffDef_Manipulator; Capture.UpdateTethers += CharacterBody_HasBuff_BuffDef_Manipulator; FireFinalStand.OnEnter += CharacterBody_HasBuff_BuffDef_Manipulator; FireWardWipe.OnEnter += CharacterBody_HasBuff_BuffDef_Manipulator; AffixVoidBehavior.FixedUpdate += CharacterBody_HasBuff_BuffDef_Manipulator; AffixVoidBehavior.OnDisable += CharacterBody_HasBuff_BuffDef_Manipulator; AncientWispFireController.Update += CharacterBody_HasBuff_BuffDef_Manipulator; BearVoidBehavior.FixedUpdate += CharacterBody_HasBuff_BuffDef_Manipulator; BearVoidBehavior.OnDisable += CharacterBody_HasBuff_BuffDef_Manipulator; CharacterBody.AddTimedBuff_BuffDef_float += CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingsBehavior.FixedUpdate += CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingsBehavior.OnDisable += CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingVoidBehavior.FixedUpdate += CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingVoidBehavior.OnDisable += CharacterBody_HasBuff_BuffDef_Manipulator; ImmuneToDebuffBehavior.FixedUpdate += CharacterBody_HasBuff_BuffDef_Manipulator; ImmuneToDebuffBehavior.OnDisable += CharacterBody_GetBuffCount_BuffDef_CharacterBody_GetBuffCount_BuffDef_Manipulator; RoR2_Items_ShockNearbyBodyBehavior_OnDisable.Apply(); RoR2_VoidSurvivorController_get_isCorrupted.Apply(); } private static void Cleanup() { PlatingBuffMainState.GetInteractability -= CharacterBody_GetBuffCount_BuffIndex_Manipulator; PlatingBuffMainState.OnInteractionBegin -= CharacterBody_GetBuffCount_BuffIndex_Manipulator; CharacterBody.AddTimedBuff_BuffDef_float_int -= CharacterBody_GetBuffCount_BuffDef_Manipulator; MushroomVoidBehavior.OnEnable -= CharacterBody_GetBuffCount_BuffDef_Manipulator; PrimarySkillShurikenBehavior.FixedUpdate -= CharacterBody_GetBuffCount_BuffDef_Manipulator; PrimarySkillShurikenBehavior.OnDisable -= CharacterBody_HasBuff_BuffDef_Manipulator; CastSmokescreen.OnExit -= CharacterBody_HasBuff_BuffDef_Manipulator; CastSmokescreenNoDelay.OnExit -= CharacterBody_HasBuff_BuffDef_Manipulator; Capture.TargetIsTethered -= CharacterBody_HasBuff_BuffDef_Manipulator; Capture.UpdateTethers -= CharacterBody_HasBuff_BuffDef_Manipulator; FireFinalStand.OnEnter -= CharacterBody_HasBuff_BuffDef_Manipulator; FireWardWipe.OnEnter -= CharacterBody_HasBuff_BuffDef_Manipulator; AffixVoidBehavior.FixedUpdate -= CharacterBody_HasBuff_BuffDef_Manipulator; AffixVoidBehavior.OnDisable -= CharacterBody_HasBuff_BuffDef_Manipulator; AncientWispFireController.Update -= CharacterBody_HasBuff_BuffDef_Manipulator; BearVoidBehavior.FixedUpdate -= CharacterBody_HasBuff_BuffDef_Manipulator; BearVoidBehavior.OnDisable -= CharacterBody_HasBuff_BuffDef_Manipulator; CharacterBody.AddTimedBuff_BuffDef_float -= CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingsBehavior.FixedUpdate -= CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingsBehavior.OnDisable -= CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingVoidBehavior.FixedUpdate -= CharacterBody_HasBuff_BuffDef_Manipulator; ElementalRingVoidBehavior.OnDisable -= CharacterBody_HasBuff_BuffDef_Manipulator; ImmuneToDebuffBehavior.FixedUpdate -= CharacterBody_HasBuff_BuffDef_Manipulator; ImmuneToDebuffBehavior.OnDisable -= CharacterBody_GetBuffCount_BuffDef_CharacterBody_GetBuffCount_BuffDef_Manipulator; RoR2_Items_ShockNearbyBodyBehavior_OnDisable.Undo(); RoR2_VoidSurvivorController_get_isCorrupted.Undo(); } } [PatchClass] private static class VoidFiendOptInFix { [CompilerGenerated] private static class <>O { public static Manipulator <0>__VoidSurvivorController_FixedUpdate; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__VoidSurvivorController_FixedUpdate; if (obj == null) { Manipulator val = VoidSurvivorController_FixedUpdate; <>O.<0>__VoidSurvivorController_FixedUpdate = val; obj = (object)val; } VoidSurvivorController.FixedUpdate += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__VoidSurvivorController_FixedUpdate; if (obj == null) { Manipulator val = VoidSurvivorController_FixedUpdate; <>O.<0>__VoidSurvivorController_FixedUpdate = val; obj = (object)val; } VoidSurvivorController.FixedUpdate -= (Manipulator)obj; } private static void VoidSurvivorController_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000e: 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) ILCursor val = new ILCursor(il); int num = 0; ILCursor[] array = default(ILCursor[]); while (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, "corruptedBuffDef"), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression>)((CharacterBody _) => _.HasBuff((BuffDef)null)))) })) { array[1].Emit(OpCodes.Call, (MethodBase)enablePatch_MI); ILCursor val2 = array[^1]; int index = val2.Index; val2.Index = index + 1; val2.Emit(OpCodes.Call, (MethodBase)disablePatch_MI); val.Index = val2.Index; num++; } if (num == 0) { Log.Warning("no patch locations found", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\GetBuffCount\\VoidFiendOptInFix.cs", "VoidSurvivorController_FixedUpdate", 47); } } } [CompilerGenerated] private static class <>O { public static hook_GetBuffCount_BuffIndex <0>__CharacterBody_GetBuffCount_BuffIndex; } public static bool ForceDisable = false; private static bool _patchEnabled = false; private static readonly MethodInfo enablePatch_MI = SymbolExtensions.GetMethodInfo((Expression)(() => enablePatch())); private static readonly MethodInfo disablePatch_MI = SymbolExtensions.GetMethodInfo((Expression)(() => decrementEnabledCount())); private static void enablePatch() { if (_patchEnabled) { Log.Warning("Already enabled!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\GetBuffCount\\GetBuffIndex_BuffIndex_ReplacePatch.cs", "enablePatch", 19); } _patchEnabled = true; } private static void decrementEnabledCount() { if (!_patchEnabled) { Log.Warning("Already disabled!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\GetBuffCount\\GetBuffIndex_BuffIndex_ReplacePatch.cs", "decrementEnabledCount", 30); } _patchEnabled = false; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_GetBuffCount_BuffIndex; if (obj == null) { hook_GetBuffCount_BuffIndex val = CharacterBody_GetBuffCount_BuffIndex; <>O.<0>__CharacterBody_GetBuffCount_BuffIndex = val; obj = (object)val; } CharacterBody.GetBuffCount_BuffIndex += (hook_GetBuffCount_BuffIndex)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_GetBuffCount_BuffIndex; if (obj == null) { hook_GetBuffCount_BuffIndex val = CharacterBody_GetBuffCount_BuffIndex; <>O.<0>__CharacterBody_GetBuffCount_BuffIndex = val; obj = (object)val; } CharacterBody.GetBuffCount_BuffIndex -= (hook_GetBuffCount_BuffIndex)obj; } private static int CharacterBody_GetBuffCount_BuffIndex(orig_GetBuffCount_BuffIndex orig, CharacterBody self, BuffIndex buffType) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_patchEnabled && !ForceDisable) { BuffRandomizerController.TryReplaceBuffIndex(ref buffType); } return orig.Invoke(self, buffType); } } [PatchClass] internal static class TimedBuffFixPatch { [CompilerGenerated] private static class <>O { public static hook_UpdateBuffs <0>__CharacterBody_UpdateBuffs; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_UpdateBuffs; if (obj == null) { hook_UpdateBuffs val = CharacterBody_UpdateBuffs; <>O.<0>__CharacterBody_UpdateBuffs = val; obj = (object)val; } CharacterBody.UpdateBuffs += (hook_UpdateBuffs)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CharacterBody_UpdateBuffs; if (obj == null) { hook_UpdateBuffs val = CharacterBody_UpdateBuffs; <>O.<0>__CharacterBody_UpdateBuffs = val; obj = (object)val; } CharacterBody.UpdateBuffs -= (hook_UpdateBuffs)obj; } private static void CharacterBody_UpdateBuffs(orig_UpdateBuffs orig, CharacterBody self, float deltaTime) { BuffIndexPatch.SkipPatchCount++; GetBuffIndex_BuffIndex_ReplacePatch.ForceDisable = true; orig.Invoke(self, deltaTime); GetBuffIndex_BuffIndex_ReplacePatch.ForceDisable = false; BuffIndexPatch.SkipPatchCount--; } } [PatchClass] internal static class VoidFiendCleanseCorruptFix { [CompilerGenerated] private static class <>O { public static Manipulator <0>__DotController_RemoveAllDots; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DotController_RemoveAllDots; if (obj == null) { Manipulator val = DotController_RemoveAllDots; <>O.<0>__DotController_RemoveAllDots = val; obj = (object)val; } DotController.RemoveAllDots += (Manipulator)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DotController_RemoveAllDots; if (obj == null) { Manipulator val = DotController_RemoveAllDots; <>O.<0>__DotController_RemoveAllDots = val; obj = (object)val; } DotController.RemoveAllDots -= (Manipulator)obj; } private static void DotController_RemoveAllDots(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //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_00f6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILCursor[] array = default(ILCursor[]); DotStack val4 = default(DotStack); if (val.TryFindNext(ref array, new Func[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)SymbolExtensions.GetMethodInfo>((Expression>>)((Dictionary _) => _.TryGetValue(0, out Discard.Value)))), (Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val4) })) { int dotControllerLocIndex = 0; array[0].GotoPrev(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref dotControllerLocIndex) }); ILCursor val2 = array[1]; object operand = val2.Next.Operand; ILLabel val3 = (ILLabel)((operand is ILLabel) ? operand : null); if (val3 != null) { val.Index = val2.Index + 1; val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc, dotControllerLocIndex); val.EmitDelegate>((Func)delegate(GameObject victimObject, DotController controller) { if (Object.op_Implicit((Object)(object)victimObject) && Object.op_Implicit((Object)(object)controller) && BuffRandomizerController.IsActive && Object.op_Implicit((Object)(object)victimObject.GetComponent()) && containsCorruptModeDOT(out var corruptModeDOTIndex)) { for (int num = controller.dotStackList.Count - 1; num >= 0; num--) { if (num != corruptModeDOTIndex) { controller.RemoveDotStackAtServer(num); } } return true; } return false; bool containsCorruptModeDOT(out int reference) { //IL_0005: 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 (BuffRandomizerController.TryGetReplacementBuffIndex(Buffs.VoidSurvivorCorruptMode.buffIndex, out var replacement)) { for (int i = 0; i < controller.dotStackList.Count; i++) { val4 = controller.dotStackList[i]; if (val4 != null && val4.dotDef != null && Object.op_Implicit((Object)(object)val4.dotDef.associatedBuff) && val4.dotDef.associatedBuff.buffIndex == replacement) { reference = i; return true; } } } reference = -1; return false; } }); val.Emit(OpCodes.Brtrue, (object)val3); } else { Log.Warning("Brfalse operand is not ILLabel", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\VoidSurvivorCleanseCorruptFix.cs", "DotController_RemoveAllDots", 92); } } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BuffRandomizer\\VoidSurvivorCleanseCorruptFix.cs", "DotController_RemoveAllDots", 97); } } } } namespace RoR2Randomizer.Patches.BossRandomizer { public class BossPhaseTracker : BossTracker where T : BossPhaseTracker { public TrackedValue Phase; } public class BossTracker where T : BossTracker { public TrackedValue IsInFight; public static T Instance { get; private set; } protected BossTracker() { Instance = (T)this; } protected virtual void applyPatches() { SceneCatalog.onMostRecentSceneDefChanged += onSceneLoaded; } protected virtual void cleanupPatches() { SceneCatalog.onMostRecentSceneDefChanged -= onSceneLoaded; } protected virtual void onSceneLoaded(SceneDef scene) { IsInFight.Value = false; } } [PatchClass] public static class GenericScriptedSpawnHook { public delegate void ResetCardDelegate(ref SpawnCard card); public delegate void OverrideSpawnPrefabDelegate(ref SpawnCard card, out ResetCardDelegate resetCardFunc); [HarmonyPatch] private static class ScriptedCombatEncounter_Spawn_HandleSpawn_Patch { private static MethodBase TargetMethod() { return typeof(ScriptedCombatEncounter).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).SingleOrDefault((MethodInfo m) => m.GetCustomAttribute(typeof(CompilerGeneratedAttribute)) != null && m.Name.StartsWith("g__HandleSpawn|")); } private static void Postfix(ref SpawnResult spawnResult) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (spawnResult.success && Object.op_Implicit((Object)(object)spawnResult.spawnedInstance) && spawnResult.spawnRequest != null && Object.op_Implicit((Object)(object)spawnResult.spawnRequest.spawnCard)) { GenericScriptedSpawnHook.OnSpawned?.Invoke(spawnResult); } } } [CompilerGenerated] private static class <>O { public static hook_Spawn <0>__ScriptedCombatEncounter_Spawn; } private static OverrideSpawnPrefabDelegate _overrideSpawnPrefabFunc; public static OverrideSpawnPrefabDelegate OverrideSpawnPrefabFunc { get { return _overrideSpawnPrefabFunc; } set { if (_overrideSpawnPrefabFunc != null && value != null) { Log.Warning("Assignined while there is an existing hook, existing will be removed", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\GenericScriptedSpawnHook.cs", "OverrideSpawnPrefabFunc", 28); } _overrideSpawnPrefabFunc = value; } } public static event Action OnSpawned; private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ScriptedCombatEncounter_Spawn; if (obj == null) { hook_Spawn val = ScriptedCombatEncounter_Spawn; <>O.<0>__ScriptedCombatEncounter_Spawn = val; obj = (object)val; } ScriptedCombatEncounter.Spawn += (hook_Spawn)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ScriptedCombatEncounter_Spawn; if (obj == null) { hook_Spawn val = ScriptedCombatEncounter_Spawn; <>O.<0>__ScriptedCombatEncounter_Spawn = val; obj = (object)val; } ScriptedCombatEncounter.Spawn -= (hook_Spawn)obj; } private static void ScriptedCombatEncounter_Spawn(orig_Spawn orig, ScriptedCombatEncounter self, ref SpawnInfo spawnInfo) { ResetCardDelegate resetCardFunc = null; if (NetworkServer.active) { _overrideSpawnPrefabFunc?.Invoke(ref spawnInfo.spawnCard, out resetCardFunc); } orig.Invoke(self, ref spawnInfo); if (NetworkServer.active) { resetCardFunc?.Invoke(ref spawnInfo.spawnCard); } } } } namespace RoR2Randomizer.Patches.BossRandomizer.Voidling { [PatchClass] public sealed class VoidlingPhaseTracker : BossPhaseTracker { private class PhaseEncounterData : MonoBehaviour { public uint Phase; public ScriptedCombatEncounter ScriptedEncounter; public void Initialize() { if (SpawnCardTracker.VoidlingPhasesSpawnCards == null) { SpawnCardTracker.VoidlingPhasesSpawnCards = (SpawnCard[])(object)new SpawnCard[TotalNumPhases]; } if (!Object.op_Implicit((Object)(object)SpawnCardTracker.VoidlingPhasesSpawnCards[Phase - 1])) { SpawnCardTracker.VoidlingPhasesSpawnCards[Phase - 1] = ScriptedEncounter.spawns[0].spawnCard; } } } [CompilerGenerated] private static class <>O { public static hook_Start <0>__VoidRaidGauntletController_Start; } private static uint? _totalNumPhases; public static uint TotalNumPhases => _totalNumPhases.Value; private static void ApplyPatches() { new VoidlingPhaseTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown base.applyPatches(); object obj = <>O.<0>__VoidRaidGauntletController_Start; if (obj == null) { hook_Start val = VoidRaidGauntletController_Start; <>O.<0>__VoidRaidGauntletController_Start = val; obj = (object)val; } VoidRaidGauntletController.Start += (hook_Start)obj; ScriptedCombatEncounter.BeginEncounter += new hook_BeginEncounter(ScriptedCombatEncounter_BeginEncounter); DeathState.OnEnter += new hook_OnEnter(DeathState_OnEnter); } protected override void cleanupPatches() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown base.cleanupPatches(); object obj = <>O.<0>__VoidRaidGauntletController_Start; if (obj == null) { hook_Start val = VoidRaidGauntletController_Start; <>O.<0>__VoidRaidGauntletController_Start = val; obj = (object)val; } VoidRaidGauntletController.Start -= (hook_Start)obj; ScriptedCombatEncounter.BeginEncounter -= new hook_BeginEncounter(ScriptedCombatEncounter_BeginEncounter); DeathState.OnEnter -= new hook_OnEnter(DeathState_OnEnter); } private static void VoidRaidGauntletController_Start(orig_Start orig, VoidRaidGauntletController self) { orig.Invoke(self); if (!_totalNumPhases.HasValue) { _totalNumPhases = (uint)self.phaseEncounters.Length; } for (uint num = 0u; num < TotalNumPhases; num++) { ScriptedCombatEncounter val = self.phaseEncounters[num]; PhaseEncounterData phaseEncounterData = ((Component)val).gameObject.AddComponent(); phaseEncounterData.ScriptedEncounter = val; phaseEncounterData.Phase = num + 1; phaseEncounterData.Initialize(); } } private void ScriptedCombatEncounter_BeginEncounter(orig_BeginEncounter orig, ScriptedCombatEncounter self) { PhaseEncounterData phaseEncounterData = default(PhaseEncounterData); if (((Component)self).TryGetComponent(ref phaseEncounterData)) { IsInFight.Value = true; Phase.Value = phaseEncounterData.Phase; } orig.Invoke(self); } private void DeathState_OnEnter(orig_OnEnter orig, DeathState self) { orig.Invoke(self); IsInFight.Value = false; } } } namespace RoR2Randomizer.Patches.BossRandomizer.SolusWing { [PatchClass] public class SolusWingTracker : BossTracker { private static void ApplyPatches() { new SolusWingTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown base.applyPatches(); Mission2Fight.OnEnter += new hook_OnEnter(Mission2Fight_OnEnter); Mission5Death.OnEnter += new hook_OnEnter(Mission5Death_OnEnter); } private void Mission5Death_OnEnter(orig_OnEnter orig, Mission5Death self) { IsInFight.Value = false; orig.Invoke(self); } private void Mission2Fight_OnEnter(orig_OnEnter orig, Mission2Fight self) { SpawnCardTracker.SolusWingSpawnCard = ((SolusWing2BaseMissionState)self).solutionalHauntReferences.solusWingScriptedCombatEncounter.spawns[0].spawnCard; IsInFight.Value = true; orig.Invoke(self); } protected override void cleanupPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown base.cleanupPatches(); Mission2Fight.OnEnter -= new hook_OnEnter(Mission2Fight_OnEnter); Mission5Death.OnEnter -= new hook_OnEnter(Mission5Death_OnEnter); } } } namespace RoR2Randomizer.Patches.BossRandomizer.Mithrix { [PatchClass] internal static class BrotherSpeechDriver_ReplaceAurelionite { [CompilerGenerated] private static class <>O { public static Manipulator <0>__replaceAurelioniteIndexPatch; } private static readonly FieldInfo BrotherSpeechDriver_titanGoldBodyIndex_FI = AccessTools.DeclaredField(typeof(BrotherSpeechDriver), "titanGoldBodyIndex"); private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__replaceAurelioniteIndexPatch; if (obj == null) { Manipulator val = replaceAurelioniteIndexPatch; <>O.<0>__replaceAurelioniteIndexPatch = val; obj = (object)val; } BrotherSpeechDriver.DoInitialSightResponse += (Manipulator)obj; object obj2 = <>O.<0>__replaceAurelioniteIndexPatch; if (obj2 == null) { Manipulator val2 = replaceAurelioniteIndexPatch; <>O.<0>__replaceAurelioniteIndexPatch = val2; obj2 = (object)val2; } BrotherSpeechDriver.OnBodyKill += (Manipulator)obj2; object obj3 = <>O.<0>__replaceAurelioniteIndexPatch; if (obj3 == null) { Manipulator val3 = replaceAurelioniteIndexPatch; <>O.<0>__replaceAurelioniteIndexPatch = val3; obj3 = (object)val3; } BrotherSpeechDriver.OnCharacterBodyStartGlobal += (Manipulator)obj3; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__replaceAurelioniteIndexPatch; if (obj == null) { Manipulator val = replaceAurelioniteIndexPatch; <>O.<0>__replaceAurelioniteIndexPatch = val; obj = (object)val; } BrotherSpeechDriver.DoInitialSightResponse -= (Manipulator)obj; object obj2 = <>O.<0>__replaceAurelioniteIndexPatch; if (obj2 == null) { Manipulator val2 = replaceAurelioniteIndexPatch; <>O.<0>__replaceAurelioniteIndexPatch = val2; obj2 = (object)val2; } BrotherSpeechDriver.OnBodyKill -= (Manipulator)obj2; object obj3 = <>O.<0>__replaceAurelioniteIndexPatch; if (obj3 == null) { Manipulator val3 = replaceAurelioniteIndexPatch; <>O.<0>__replaceAurelioniteIndexPatch = val3; obj3 = (object)val3; } BrotherSpeechDriver.OnCharacterBodyStartGlobal -= (Manipulator)obj3; } private static void replaceAurelioniteIndexPatch(ILContext il) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown object obj; if (il == null) { obj = null; } else { MethodDefinition method = il.Method; obj = ((method != null) ? ((MemberReference)method).FullName : null); } if (obj == null) { obj = "null"; } string text = "(" + (string?)obj + ") "; ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, BrotherSpeechDriver_titanGoldBodyIndex_FI) })) { int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)((BodyIndex val2) => BossRandomizerController.Aurelionite.TryGetAurelioniteMasterReplacementBodyIndex(out var replacementIndex) ? replacementIndex : val2)); num++; } if (num <= 0) { Log.Warning(text + "patched 0 locations", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\Mithrix\\BrotherSpeechDriver_ReplaceAurelionite.cs", "replaceAurelioniteIndexPatch", 62); } } } [PatchClass] internal static class BrotherSpeechDriver_ReplaceHeretic { [CompilerGenerated] private static class <>O { public static Manipulator <0>__replaceHereticIndexPatch; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__replaceHereticIndexPatch; if (obj == null) { Manipulator val = replaceHereticIndexPatch; <>O.<0>__replaceHereticIndexPatch = val; obj = (object)val; } BrotherSpeechDriver.DoInitialSightResponse += (Manipulator)obj; object obj2 = <>O.<0>__replaceHereticIndexPatch; if (obj2 == null) { Manipulator val2 = replaceHereticIndexPatch; <>O.<0>__replaceHereticIndexPatch = val2; obj2 = (object)val2; } BrotherSpeechDriver.OnBodyKill += (Manipulator)obj2; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__replaceHereticIndexPatch; if (obj == null) { Manipulator val = replaceHereticIndexPatch; <>O.<0>__replaceHereticIndexPatch = val; obj = (object)val; } BrotherSpeechDriver.DoInitialSightResponse -= (Manipulator)obj; object obj2 = <>O.<0>__replaceHereticIndexPatch; if (obj2 == null) { Manipulator val2 = replaceHereticIndexPatch; <>O.<0>__replaceHereticIndexPatch = val2; obj2 = (object)val2; } BrotherSpeechDriver.OnBodyKill -= (Manipulator)obj2; } private static void replaceHereticIndexPatch(ILContext il) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown object obj; if (il == null) { obj = null; } else { MethodDefinition method = il.Method; obj = ((method != null) ? ((MemberReference)method).FullName : null); } if (obj == null) { obj = "null"; } _ = "(" + (string?)obj + ") "; ILCursor val = new ILCursor(il); int num = 0; while (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "hereticBodyIndex") })) { int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)((BodyIndex val2) => ((bool)ConfigManager.ExplicitSpawnRandomizer.RandomizeHeretic && ExplicitSpawnRandomizerController.TryGetReplacementBodyIndex(val2, out var replacement)) ? replacement : val2)); num++; } if (num <= 0) { Log.Warning("patched 0 locations", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\Mithrix\\BrotherSpeechDriver_ReplaceHeretic.cs", "replaceHereticIndexPatch", 57); } } } [PatchClass] public sealed class MithrixPhaseTracker : BossPhaseTracker { public delegate void OnFightVictoryDelegate(GameObject missionController); public static event OnFightVictoryDelegate OnFightVictory; private static void ApplyPatches() { new MithrixPhaseTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown base.applyPatches(); BrotherEncounterPhaseBaseState.OnEnter += new Manipulator(BrotherEncounterPhaseBaseState_OnEnter); PreEncounter.OnEnter += new hook_OnEnter(PreEncounter_OnEnter); EncounterFinished.OnEnter += new hook_OnEnter(EncounterFinished_OnEnter); } protected override void cleanupPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown base.cleanupPatches(); BrotherEncounterPhaseBaseState.OnEnter -= new Manipulator(BrotherEncounterPhaseBaseState_OnEnter); PreEncounter.OnEnter -= new hook_OnEnter(PreEncounter_OnEnter); EncounterFinished.OnEnter -= new hook_OnEnter(EncounterFinished_OnEnter); } private void EncounterFinished_OnEnter(orig_OnEnter orig, EncounterFinished self) { orig.Invoke(self); IsInFight.Value = false; if (self != null) { EntityStateMachine outer = ((EntityState)self).outer; if (Object.op_Implicit((Object)(object)outer)) { MithrixPhaseTracker.OnFightVictory?.Invoke(((Component)outer).gameObject); } } } private void PreEncounter_OnEnter(orig_OnEnter orig, PreEncounter self) { orig.Invoke(self); IsInFight.Value = true; Phase.Value = 0u; } private void BrotherEncounterPhaseBaseState_OnEnter(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, "GoToNextPhase") })) { val.Emit(OpCodes.Dup); int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Action)delegate(PhaseCounter instance) { Phase.Value = (uint)instance.phase; }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\Mithrix\\MithrixPhaseTracker.cs", "BrotherEncounterPhaseBaseState_OnEnter", 83); } } } [PatchClass] public static class MithrixSpawnCardTracker { [CompilerGenerated] private static class <>O { public static hook_OnEnter <0>__Phase1_OnEnter; public static hook_OnEnter <1>__Phase2_OnEnter; public static Manipulator <2>__Phase4_OnEnter; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__Phase1_OnEnter; if (obj == null) { hook_OnEnter val = Phase1_OnEnter; <>O.<0>__Phase1_OnEnter = val; obj = (object)val; } Phase1.OnEnter += (hook_OnEnter)obj; object obj2 = <>O.<1>__Phase2_OnEnter; if (obj2 == null) { hook_OnEnter val2 = Phase2_OnEnter; <>O.<1>__Phase2_OnEnter = val2; obj2 = (object)val2; } Phase2.OnEnter += (hook_OnEnter)obj2; object obj3 = <>O.<2>__Phase4_OnEnter; if (obj3 == null) { Manipulator val3 = Phase4_OnEnter; <>O.<2>__Phase4_OnEnter = val3; obj3 = (object)val3; } Phase4.OnEnter += (Manipulator)obj3; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__Phase1_OnEnter; if (obj == null) { hook_OnEnter val = Phase1_OnEnter; <>O.<0>__Phase1_OnEnter = val; obj = (object)val; } Phase1.OnEnter -= (hook_OnEnter)obj; object obj2 = <>O.<1>__Phase2_OnEnter; if (obj2 == null) { hook_OnEnter val2 = Phase2_OnEnter; <>O.<1>__Phase2_OnEnter = val2; obj2 = (object)val2; } Phase2.OnEnter -= (hook_OnEnter)obj2; object obj3 = <>O.<2>__Phase4_OnEnter; if (obj3 == null) { Manipulator val3 = Phase4_OnEnter; <>O.<2>__Phase4_OnEnter = val3; obj3 = (object)val3; } Phase4.OnEnter -= (Manipulator)obj3; } private static void Phase1_OnEnter(orig_OnEnter orig, Phase1 self) { orig.Invoke(self); if (!Object.op_Implicit((Object)(object)SpawnCardTracker.MithrixNormalSpawnCard)) { SpawnCardTracker.MithrixNormalSpawnCard = ((BrotherEncounterPhaseBaseState)self).phaseScriptedCombatEncounter.spawns[0].spawnCard; } } private static void Phase2_OnEnter(orig_OnEnter orig, Phase2 self) { orig.Invoke(self); if (SpawnCardTracker.MithrixPhase2SpawnCards == null) { SpawnCardTracker.MithrixPhase2SpawnCards = ((BrotherEncounterPhaseBaseState)self).phaseScriptedCombatEncounter.spawns.Select((SpawnInfo s) => s.spawnCard).Distinct().ToArray(); } } private static void Phase4_OnEnter(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCall(x, "BeginEncounter") })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)delegate(Phase4 __instance) { if (!Object.op_Implicit((Object)(object)SpawnCardTracker.MithrixHurtSpawnCard)) { SpawnCardTracker.MithrixHurtSpawnCard = ((BrotherEncounterPhaseBaseState)__instance).phaseScriptedCombatEncounter.spawns[0].spawnCard; } }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\Mithrix\\MithrixSpawnCardTracker.cs", "Phase4_OnEnter", 59); } } } } namespace RoR2Randomizer.Patches.BossRandomizer.LunarScav { [PatchClass] public sealed class LunarScavFightTracker : BossTracker { private static void ApplyPatches() { new LunarScavFightTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown base.applyPatches(); BossRandomizerController.LunarScav.LunarScavReplacementReceivedClient += LunarScavReplacementReceivedClient; FadeOut.OnEnter += new hook_OnEnter(FadeOut_OnEnter); } protected override void cleanupPatches() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown base.cleanupPatches(); BossRandomizerController.LunarScav.LunarScavReplacementReceivedClient -= LunarScavReplacementReceivedClient; FadeOut.OnEnter -= new hook_OnEnter(FadeOut_OnEnter); } private void FadeOut_OnEnter(orig_OnEnter orig, FadeOut self) { IsInFight.Value = false; orig.Invoke(self); } private void LunarScavReplacementReceivedClient(LunarScavReplacement replacement) { IsInFight.Value = true; } protected override void onSceneLoaded(SceneDef scene) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) base.onSceneLoaded(scene); if ((int)Caches.Scene.LunarScavFightSceneIndex != -1 && scene.sceneDefIndex == Caches.Scene.LunarScavFightSceneIndex) { IsInFight.Value = true; } } } [PatchClass] internal static class LunarScavSpawnCardTracker { [CompilerGenerated] private static class <>O { public static hook_BeginEncounter <0>__ScriptedCombatEncounter_BeginEncounter; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ScriptedCombatEncounter_BeginEncounter; if (obj == null) { hook_BeginEncounter val = ScriptedCombatEncounter_BeginEncounter; <>O.<0>__ScriptedCombatEncounter_BeginEncounter = val; obj = (object)val; } ScriptedCombatEncounter.BeginEncounter += (hook_BeginEncounter)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__ScriptedCombatEncounter_BeginEncounter; if (obj == null) { hook_BeginEncounter val = ScriptedCombatEncounter_BeginEncounter; <>O.<0>__ScriptedCombatEncounter_BeginEncounter = val; obj = (object)val; } ScriptedCombatEncounter.BeginEncounter -= (hook_BeginEncounter)obj; } private static void ScriptedCombatEncounter_BeginEncounter(orig_BeginEncounter orig, ScriptedCombatEncounter self) { if (!Object.op_Implicit((Object)(object)SpawnCardTracker.LunarScavSpawnCard) && BossTracker.Instance != null && (bool)BossTracker.Instance.IsInFight && ((Object)self).name == "ScavLunarEncounter") { SpawnCard spawnCard = self.spawns[0].spawnCard; SpawnCardTracker.LunarScavSpawnCard = (MultiCharacterSpawnCard)(object)((spawnCard is MultiCharacterSpawnCard) ? spawnCard : null); } orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.BossRandomizer.FalseSon { [PatchClass] public sealed class FalseSonPhaseTracker : BossPhaseTracker { public const uint TotalNumPhases = 3u; private static void ApplyPatches() { new FalseSonPhaseTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown base.applyPatches(); ScriptedCombatEncounter.BeginEncounter += new hook_BeginEncounter(ScriptedCombatEncounter_BeginEncounter); MeridianEventStart.OnEnter += new hook_OnEnter(MeridianEventStart_OnEnter); Phase1.OnEnter += new hook_OnEnter(Phase1_OnEnter); Phase2.OnEnter += new hook_OnEnter(Phase2_OnEnter); Phase3.OnEnter += new hook_OnEnter(Phase3_OnEnter); MeridianEventCleared.OnEnter += new hook_OnEnter(MeridianEventCleared_OnEnter); } protected override void cleanupPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown base.cleanupPatches(); ScriptedCombatEncounter.BeginEncounter -= new hook_BeginEncounter(ScriptedCombatEncounter_BeginEncounter); MeridianEventStart.OnEnter -= new hook_OnEnter(MeridianEventStart_OnEnter); Phase1.OnEnter -= new hook_OnEnter(Phase1_OnEnter); Phase2.OnEnter -= new hook_OnEnter(Phase2_OnEnter); Phase3.OnEnter -= new hook_OnEnter(Phase3_OnEnter); MeridianEventCleared.OnEnter -= new hook_OnEnter(MeridianEventCleared_OnEnter); } private void ScriptedCombatEncounter_BeginEncounter(orig_BeginEncounter orig, ScriptedCombatEncounter self) { MeridianEventTriggerInteraction instance = MeridianEventTriggerInteraction.instance; if (Object.op_Implicit((Object)(object)instance) && (Object)(object)self == (Object)(object)instance.falseSonBossEncounter && self.spawns.Length != 0) { SpawnCard[] falseSonPhasesSpawnCards = SpawnCardTracker.FalseSonPhasesSpawnCards; uint num = (uint)Phase - 1; if (falseSonPhasesSpawnCards[num] == null) { falseSonPhasesSpawnCards[num] = self.spawns[0].spawnCard; } } orig.Invoke(self); } private void MeridianEventStart_OnEnter(orig_OnEnter orig, MeridianEventStart self) { IsInFight.Value = true; orig.Invoke(self); } private void Phase1_OnEnter(orig_OnEnter orig, Phase1 self) { Phase.Value = 1u; orig.Invoke(self); } private void Phase2_OnEnter(orig_OnEnter orig, Phase2 self) { Phase.Value = 2u; orig.Invoke(self); } private void Phase3_OnEnter(orig_OnEnter orig, Phase3 self) { Phase.Value = 3u; orig.Invoke(self); } private void MeridianEventCleared_OnEnter(orig_OnEnter orig, MeridianEventCleared self) { IsInFight.Value = false; orig.Invoke(self); } } } namespace RoR2Randomizer.Patches.BossRandomizer.Aurelionite { [PatchClass] public class AurelioniteFightTracker : BossTracker { private static void ApplyPatches() { new AurelioniteFightTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown base.applyPatches(); BossRandomizerController.Aurelionite.AurelioniteReplacementReceivedClient += AurelioniteReplacementReceivedClient; GoldshoresBossfight.SpawnBoss += new Manipulator(GoldshoresBossfight_SpawnBoss); Exit.OnEnter += new hook_OnEnter(Exit_OnEnter); } protected override void cleanupPatches() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown base.cleanupPatches(); BossRandomizerController.Aurelionite.AurelioniteReplacementReceivedClient -= AurelioniteReplacementReceivedClient; GoldshoresBossfight.SpawnBoss -= new Manipulator(GoldshoresBossfight_SpawnBoss); Exit.OnEnter -= new hook_OnEnter(Exit_OnEnter); } private void GoldshoresBossfight_SpawnBoss(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) ILCursor[] array = default(ILCursor[]); if (new ILCursor(il).TryFindNext(ref array, new Func[3] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "combatEncounterPrefab"), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)SymbolExtensions.GetMethodInfo((Expression)(() => Object.Instantiate((GameObject)null)))), (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "scriptedCombatEncounter") })) { ILCursor obj = array[^1]; int index = obj.Index; obj.Index = index + 1; obj.Emit(OpCodes.Ldarg_0); obj.EmitDelegate>((Action)delegate(GoldshoresBossfight instance) { if (Object.op_Implicit((Object)(object)instance.scriptedCombatEncounter) && !Object.op_Implicit((Object)(object)SpawnCardTracker.AurelioniteSpawnCard)) { SpawnCardTracker.AurelioniteSpawnCard = instance.scriptedCombatEncounter.spawns[0].spawnCard; } IsInFight.Value = true; }); } else { Log.Warning("failed to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\Aurelionite\\AurelioniteFightTracker.cs", "GoldshoresBossfight_SpawnBoss", 74); } } private void AurelioniteReplacementReceivedClient(AurelioniteReplacement replacement) { IsInFight.Value = true; } private void Exit_OnEnter(orig_OnEnter orig, Exit self) { IsInFight.Value = false; orig.Invoke(self); } } [PatchClass] internal static class MithrixSpawnFixPatch { private static readonly Manipulator _replaceMithrixHurtReference = CharacterReplacements.FixMasterIndexReferences(() => BossRandomizerController.Mithrix.IsEnabled, "brotherHurtMasterIndex"); private static void Apply() { GoldTitanManager.OnBossGroupStartServer += _replaceMithrixHurtReference; } private static void Cleanup() { GoldTitanManager.OnBossGroupStartServer -= _replaceMithrixHurtReference; } } [PatchClass] internal static class OverrideTPEventSpawnPatch { [CompilerGenerated] private static class <>O { public static hook_TryStartChannelingTitansServer <0>__GoldTitanManager_TryStartChannelingTitansServer; } private static void Apply() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GoldTitanManager_TryStartChannelingTitansServer; if (obj == null) { hook_TryStartChannelingTitansServer val = GoldTitanManager_TryStartChannelingTitansServer; <>O.<0>__GoldTitanManager_TryStartChannelingTitansServer = val; obj = (object)val; } GoldTitanManager.TryStartChannelingTitansServer += (hook_TryStartChannelingTitansServer)obj; } private static void Cleanup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__GoldTitanManager_TryStartChannelingTitansServer; if (obj == null) { hook_TryStartChannelingTitansServer val = GoldTitanManager_TryStartChannelingTitansServer; <>O.<0>__GoldTitanManager_TryStartChannelingTitansServer = val; obj = (object)val; } GoldTitanManager.TryStartChannelingTitansServer -= (hook_TryStartChannelingTitansServer)obj; } private static bool GoldTitanManager_TryStartChannelingTitansServer(orig_TryStartChannelingTitansServer orig, object channeler, Vector3 approximatePosition, Vector3? lookAtPosition, Action channelEndCallback) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = null; bool flag; if (flag = BossRandomizerController.Aurelionite.TryGetAurelioniteMasterReplacementPrefab(out var replacementPrefab)) { prefab = ((SpawnCard)GoldTitanManager.goldTitanSpawnCard).prefab; ((SpawnCard)GoldTitanManager.goldTitanSpawnCard).prefab = replacementPrefab; } bool result = orig.Invoke(channeler, approximatePosition, lookAtPosition, channelEndCallback); if (flag) { ((SpawnCard)GoldTitanManager.goldTitanSpawnCard).prefab = prefab; } return result; } } } namespace RoR2Randomizer.Patches.BossRandomizer.AlloyWorshipUnit { [PatchClass] public sealed class AlloyWorshipUnitFightTracker : BossTracker { private static void ApplyPatches() { new AlloyWorshipUnitFightTracker().applyPatches(); } private static void CleanupPatches() { BossTracker.Instance?.cleanupPatches(); } protected override void applyPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown base.applyPatches(); Listening.FixedUpdate += new Manipulator(Listening_FixedUpdate); } protected override void cleanupPatches() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown base.cleanupPatches(); Listening.FixedUpdate -= new Manipulator(Listening_FixedUpdate); } private void Listening_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "BeginEncounter") })) { val.Emit(OpCodes.Dup); val.EmitDelegate>((Action)delegate(ScriptedCombatEncounter encounter) { if (!Object.op_Implicit((Object)(object)SpawnCardTracker.AlloyWorshipUnitSpawnCard)) { SpawnCardTracker.AlloyWorshipUnitSpawnCard = encounter.spawns[0].spawnCard; } IsInFight.Value = true; CombatSquad squad = encounter.combatSquad; squad.onDefeatedServer += onDefeatedServer; void onDefeatedServer() { IsInFight.Value = false; if (Object.op_Implicit((Object)(object)squad)) { squad.onDefeatedServer -= onDefeatedServer; } } }); } else { Log.Warning("unable to find patch location", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Patches\\BossRandomizer\\AlloyWorshipUnit\\AlloyWorshipUnitFightTracker.cs", "Listening_FixedUpdate", 66); } } } } namespace RoR2Randomizer.Networking { public static class CustomNetworkMessageManager { public static void RegisterMessages() { NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); } } public interface INetMessageProvider { bool SendMessages { get; } IEnumerable GetNetMessages(); } [Flags] public enum MessageProviderFlags : byte { None = 0, Persistent = 1 } public static class NetworkingManager { private readonly struct MessageProviderInfo { private class InstanceEqualityComparer : IEqualityComparer { public bool Equals(MessageProviderInfo x, MessageProviderInfo y) { return x.Equals(y); } public int GetHashCode(MessageProviderInfo obj) { return obj.GetHashCode(); } } public readonly INetMessageProvider Provider; public readonly MessageProviderFlags Flags; public static readonly IEqualityComparer EqualityComparer = new InstanceEqualityComparer(); public MessageProviderInfo(INetMessageProvider provider, MessageProviderFlags flags) { Provider = provider; Flags = flags; } public override bool Equals(object obj) { if (obj is MessageProviderInfo messageProviderInfo) { return EqualityComparer.Default.Equals(Provider, messageProviderInfo.Provider); } return false; } public override int GetHashCode() { return Provider.GetHashCode(); } } [CompilerGenerated] private static class <>O { public static Action <0>__runStart; public static NetworkUserGenericDelegate <1>__NetworkUser_onPostNetworkUserStart; } private static readonly HashSet _messageProviders = new HashSet(MessageProviderInfo.EqualityComparer); private static ulong? _runCallbacksHandle; public static void RegisterMessageProvider(INetMessageProvider provider, MessageProviderFlags flags = MessageProviderFlags.None) { if (!_messageProviders.Add(new MessageProviderInfo(provider, flags))) { Log.Warning($"Message provider {provider} already registered", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\NetworkingManager.cs", "RegisterMessageProvider", 58); } } public static void UnregisterMessageProvider(INetMessageProvider provider) { _messageProviders.RemoveWhere((MessageProviderInfo i) => i.Provider == provider); } [SystemInitializer(new Type[] { })] private static void Init() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown _runCallbacksHandle = RunSpecificCallbacksManager.AddEntry(runStart, delegate { _messageProviders.RemoveWhere((MessageProviderInfo i) => (i.Flags & MessageProviderFlags.Persistent) == 0); }, -1); object obj = <>O.<1>__NetworkUser_onPostNetworkUserStart; if (obj == null) { NetworkUserGenericDelegate val = NetworkUser_onPostNetworkUserStart; <>O.<1>__NetworkUser_onPostNetworkUserStart = val; obj = (object)val; } NetworkUser.onPostNetworkUserStart += (NetworkUserGenericDelegate)obj; } internal static void Uninitialize() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown if (_runCallbacksHandle.HasValue) { RunSpecificCallbacksManager.RemoveEntry(_runCallbacksHandle.Value); } object obj = <>O.<1>__NetworkUser_onPostNetworkUserStart; if (obj == null) { NetworkUserGenericDelegate val = NetworkUser_onPostNetworkUserStart; <>O.<1>__NetworkUser_onPostNetworkUserStart = val; obj = (object)val; } NetworkUser.onPostNetworkUserStart -= (NetworkUserGenericDelegate)obj; } private static void NetworkUser_onPostNetworkUserStart(NetworkUser networkUser) { if (!NetworkServer.active || NetworkServer.dontListen || !Object.op_Implicit((Object)(object)Run.instance)) { return; } foreach (NetworkMessageBase item in collectAllMessages(requirePersistent: false)) { item.SendTo(((NetworkBehaviour)networkUser).connectionToClient); } } private static IEnumerable collectAllMessages(bool requirePersistent) { foreach (MessageProviderInfo messageProvider in _messageProviders) { if (!messageProvider.Provider.SendMessages || (requirePersistent && (messageProvider.Flags & MessageProviderFlags.Persistent) == 0)) { continue; } foreach (NetworkMessageBase netMessage in messageProvider.Provider.GetNetMessages()) { yield return netMessage; } } } private static void runStart(Run _) { if (!NetworkServer.active || NetworkServer.dontListen) { return; } foreach (NetworkMessageBase item in collectAllMessages(requirePersistent: true)) { item.SendTo((NetworkDestination)1); } } public static void TrySendAll(this INetMessageProvider provider, NetworkDestination destination) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (!provider.SendMessages) { return; } foreach (NetworkMessageBase netMessage in provider.GetNetMessages()) { netMessage.SendTo(destination); } } } } namespace RoR2Randomizer.Networking.SurvivorPodRandomizer { public sealed class SyncSurvivorPodReplacements : ChunkedNetworkMessage { public delegate void OnReceiveDelegate(Dictionary overrideSpawnPods); private Dictionary _overrideSpawnPods; public static event OnReceiveDelegate OnReceive; public SyncSurvivorPodReplacements() { } public SyncSurvivorPodReplacements(Dictionary overrideSpawnPods) { _overrideSpawnPods = overrideSpawnPods; } public override void Serialize(NetworkWriter writer) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) writer.WritePackedUInt32((uint)_overrideSpawnPods.Count); foreach (KeyValuePair overrideSpawnPod in _overrideSpawnPods) { NetworkExtensions.WriteBodyIndex(writer, overrideSpawnPod.Key); overrideSpawnPod.Value.Serialize(writer); } } public override void Deserialize(NetworkReader reader) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) uint num = reader.ReadPackedUInt32(); _overrideSpawnPods = new Dictionary(); for (uint num2 = 0u; num2 < num; num2++) { _overrideSpawnPods.Add(NetworkExtensions.ReadBodyIndex(reader), new SpawnPodPrefabData(reader)); } } public override void OnReceived() { SyncSurvivorPodReplacements.OnReceive?.Invoke(_overrideSpawnPods); } } } namespace RoR2Randomizer.Networking.SniperWeakPointRandomizer { public sealed class SyncSniperWeakPointReplacements : SyncGameObjectReference { private readonly struct HurtBoxData { public readonly byte IndexPlusOne; public readonly bool OverrideIsSniperTarget; public HurtBoxData(HurtBox hurtBox) : this((byte)(hurtBox.indexInGroup + 1), hurtBox.isSniperTarget) { } private HurtBoxData(byte indexPlusOne, bool overrideIsSniperTarget) { IndexPlusOne = indexPlusOne; OverrideIsSniperTarget = overrideIsSniperTarget; } public void Serialize(NetworkWriter writer) { writer.Write(IndexPlusOne); writer.Write(OverrideIsSniperTarget); } public static HurtBoxData Deserialize(NetworkReader reader) { return new HurtBoxData(reader.ReadByte(), reader.ReadBoolean()); } } private int _totalLength; private HurtBoxData[] _hurtBoxDatas; protected override bool shouldHandleEvent { get { if (!NetworkServer.active) { return NetworkClient.active; } return false; } } public SyncSniperWeakPointReplacements() { } public SyncSniperWeakPointReplacements(CharacterBody ownerBody, IEnumerable hurtBoxes, int totalLength) : base(((Component)ownerBody).gameObject) { _totalLength = totalLength; _hurtBoxDatas = (from h in hurtBoxes where h.indexInGroup >= 0 select new HurtBoxData(h)).ToArray(); } public override void SendTo(NetworkDestination destination) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (_hurtBoxDatas.Length != 0) { base.SendTo(destination); } } public override void SendTo(NetworkConnection target) { if (_hurtBoxDatas.Length != 0) { base.SendTo(target); } } public override void Serialize(NetworkWriter writer) { base.Serialize(writer); writer.WritePackedUInt32((uint)_totalLength); writer.WritePackedUInt32((uint)_hurtBoxDatas.Length); HurtBoxData[] hurtBoxDatas = _hurtBoxDatas; foreach (HurtBoxData hurtBoxData in hurtBoxDatas) { hurtBoxData.Serialize(writer); } } public override void Deserialize(NetworkReader reader) { base.Deserialize(reader); _totalLength = (int)reader.ReadPackedUInt32(); uint num = reader.ReadPackedUInt32(); _hurtBoxDatas = new HurtBoxData[num]; for (uint num2 = 0u; num2 < num; num2++) { _hurtBoxDatas[num2] = HurtBoxData.Deserialize(reader); } } protected override void onReceivedObjectResolved(GameObject obj) { ModelLocator val = default(ModelLocator); if (obj.TryGetComponent(ref val)) { Transform modelTransform = val.modelTransform; HurtBoxGroup val2 = default(HurtBoxGroup); if (Object.op_Implicit((Object)(object)modelTransform) && ((Component)modelTransform).TryGetComponent(ref val2) && val2.hurtBoxes != null) { ((Component)val2).gameObject.AddComponent().Initialize(getOriginalIsSniperTargetValues(val2), getOverrideIsSniperTargetValues()); } } } private bool[] getOriginalIsSniperTargetValues(HurtBoxGroup hurtBoxGroup) { bool[] array = new bool[_totalLength]; for (int i = 0; i < _totalLength; i++) { HurtBox safe = ArrayUtils.GetSafe(hurtBoxGroup.hurtBoxes, i); if (Object.op_Implicit((Object)(object)safe)) { array[i] = safe.isSniperTarget; } } return array; } private bool?[] getOverrideIsSniperTargetValues() { bool?[] array = new bool?[_totalLength]; HurtBoxData[] hurtBoxDatas = _hurtBoxDatas; for (int i = 0; i < hurtBoxDatas.Length; i++) { HurtBoxData hurtBoxData = hurtBoxDatas[i]; int num = hurtBoxData.IndexPlusOne - 1; if (ArrayUtils.IsInBounds(array, num)) { array[num] = hurtBoxData.OverrideIsSniperTarget; } } return array; } } } namespace RoR2Randomizer.Networking.ProjectileRandomizer { public sealed class SyncProjectileReplacements : ChunkedNetworkMessage { public delegate void OnReceiveDelegate(ReplacementDictionary projectileReplacements, bool isAppendedReplacements); private static uint _currentAppendedServerVersion; private static uint? _latestAppendedServerVersionReceived; private bool _isAppendedReplacements; private uint _appendedServerVersion; private ReplacementDictionary _projectileReplacements; public static event OnReceiveDelegate OnReceive; static SyncProjectileReplacements() { Run.onRunDestroyGlobal += delegate { _currentAppendedServerVersion = 0u; _latestAppendedServerVersionReceived = null; }; } public SyncProjectileReplacements() { } public SyncProjectileReplacements(ReplacementDictionary projectileReplacements, bool isAppendedReplacements) { if (isAppendedReplacements) { _appendedServerVersion = _currentAppendedServerVersion++; } _isAppendedReplacements = isAppendedReplacements; _projectileReplacements = projectileReplacements; } public override void Serialize(NetworkWriter writer) { writer.Write(_isAppendedReplacements); if (_isAppendedReplacements) { writer.WritePackedUInt32(_appendedServerVersion); } writer.WritePackedUInt32((uint)_projectileReplacements.Count); foreach (KeyValuePair projectileReplacement in _projectileReplacements) { projectileReplacement.Key.Serialize(writer); projectileReplacement.Value.Serialize(writer); } } public override void Deserialize(NetworkReader reader) { _isAppendedReplacements = reader.ReadBoolean(); if (_isAppendedReplacements) { _appendedServerVersion = reader.ReadPackedUInt32(); } uint num = reader.ReadPackedUInt32(); Dictionary dictionary = new Dictionary(); for (uint num2 = 0u; num2 < num; num2++) { dictionary.Add(new ProjectileTypeIdentifier(reader), new ProjectileTypeIdentifier(reader)); } _projectileReplacements = new ReplacementDictionary(dictionary); } public override void OnReceived() { if (NetworkServer.active) { return; } if (_isAppendedReplacements) { if (_latestAppendedServerVersionReceived.HasValue && _appendedServerVersion <= _latestAppendedServerVersionReceived.Value) { return; } _latestAppendedServerVersionReceived = _appendedServerVersion; } SyncProjectileReplacements.OnReceive?.Invoke(_projectileReplacements, _isAppendedReplacements); } } } namespace RoR2Randomizer.Networking.ProjectileRandomizer.SpiteBomb { public sealed class SpawnRandomizedSpiteBombMessage : NetworkMessageBase { private float _damage; private Vector3 _spawnPosition; private GenericFireProjectileArgs _genericArgs; public SpawnRandomizedSpiteBombMessage() { } public SpawnRandomizedSpiteBombMessage(float damage, Vector3 spawnPosition, GenericFireProjectileArgs genericArgs) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) _damage = damage; _spawnPosition = spawnPosition; _genericArgs = genericArgs; } public override void Serialize(NetworkWriter writer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) writer.Write(_damage); writer.Write(_spawnPosition); SerializableObjectExtensions.Write(writer, _genericArgs); } public override void Deserialize(NetworkReader reader) { //IL_000e: 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) _damage = reader.ReadSingle(); _spawnPosition = reader.ReadVector3(); _genericArgs = SerializableObjectExtensions.Read(reader); } public override void OnReceived() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00ca: 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_00ec: 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) if (NetworkServer.active) { BombRequest val = new BombRequest { spawnPosition = _spawnPosition, raycastOrigin = _spawnPosition + Random.insideUnitSphere * (BombArtifactManager.bombSpawnBaseRadius * BombArtifactManager.bombSpawnRadiusCoefficient), bombBaseDamage = _damage, attacker = _genericArgs.Owner, teamIndex = _genericArgs.OwnerTeam, velocityY = Random.Range(5f, 25f) }; Ray val2 = new Ray(val.raycastOrigin + new Vector3(0f, BombArtifactManager.maxBombStepUpDistance, 0f), Vector3.down); float num = BombArtifactManager.maxBombStepUpDistance + BombArtifactManager.maxBombFallDistance; LayerIndex world = LayerIndex.world; RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, ref val3, num, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1)) { SpiteBomb_SpawnHook.patchDisabledCount++; BombArtifactManager.SpawnBomb(val, ((RaycastHit)(ref val3)).point.y); SpiteBomb_SpawnHook.patchDisabledCount--; } } } } } namespace RoR2Randomizer.Networking.ProjectileRandomizer.Orbs { public sealed class SpawnRandomizedOrbMessage : NetworkMessageBase { private const float MAX_TARGET_DISTANCE = 200f; private static readonly BullseyeSearch _orbTargetSearch = new BullseyeSearch { minAngleFilter = 0f, maxAngleFilter = 7.5f, filterByLoS = true, minDistanceFilter = 0f, maxDistanceFilter = 200f, sortMode = (SortMode)1 }; private ProjectileTypeIdentifier _orbIdentifier; private Vector3 _origin; private float _damage; private float _force; private bool _isCrit; private GenericFireProjectileArgs _genericArgs; private Vector3? _overrideTargetPosition; public SpawnRandomizedOrbMessage() { } public SpawnRandomizedOrbMessage(ProjectileTypeIdentifier orbIdentifier, Vector3 origin, Quaternion rotation, float damage, float force, bool isCrit, GenericFireProjectileArgs genericArgs) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00c8: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) _orbIdentifier = orbIdentifier; _origin = origin; _damage = damage; _force = force; _isCrit = isCrit; _genericArgs = genericArgs; if (Object.op_Implicit((Object)(object)_genericArgs.Target)) { return; } float num = ((!(genericArgs.MaxDistance >= 0f)) ? 200f : genericArgs.MaxDistance); Vector3 val = rotation * Vector3.forward; _orbTargetSearch.searchOrigin = _origin; _orbTargetSearch.searchDirection = val; _orbTargetSearch.maxDistanceFilter = num; CharacterBody ownerBody = _genericArgs.OwnerBody; if (Object.op_Implicit((Object)(object)ownerBody)) { _orbTargetSearch.viewer = ownerBody; _orbTargetSearch.teamMaskFilter = TeamMask.GetUnprotectedTeams(_genericArgs.OwnerTeam); } else { _orbTargetSearch.viewer = null; _orbTargetSearch.teamMaskFilter = TeamMask.all; } _orbTargetSearch.RefreshCandidates(); HurtBox val2 = _orbTargetSearch.GetResults().FirstOrDefault(); if (Object.op_Implicit((Object)(object)val2)) { _genericArgs.Target = val2; return; } Ray val3 = default(Ray); ((Ray)(ref val3))..ctor(_origin, val); Ray val4 = val3; LayerIndex world = LayerIndex.world; RaycastHit val5 = default(RaycastHit); if (Physics.Raycast(val4, ref val5, num, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask))) { _overrideTargetPosition = ((RaycastHit)(ref val5)).point; } else { _overrideTargetPosition = ((Ray)(ref val3)).GetPoint(num); } } public override void Serialize(NetworkWriter writer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) _orbIdentifier.Serialize(writer); writer.Write(_origin); writer.Write(_damage); writer.Write(_force); writer.Write(_isCrit); SerializableObjectExtensions.Write(writer, _genericArgs); writer.WriteNullableVector3(_overrideTargetPosition); } public override void Deserialize(NetworkReader reader) { //IL_000e: 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) _orbIdentifier = new ProjectileTypeIdentifier(reader); _origin = reader.ReadVector3(); _damage = reader.ReadSingle(); _force = reader.ReadSingle(); _isCrit = reader.ReadBoolean(); _genericArgs = SerializableObjectExtensions.Read(reader); _overrideTargetPosition = reader.ReadNullableVector3(); } public override void OnReceived() { if (!NetworkServer.active) { Log.Warning("called on client", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\ProjectileRandomizer\\Orbs\\SpawnRandomizedOrbMessage.cs", "OnReceived", 138); } else { spawnOrb(); } } public void SpawnOrSendMessage() { if (NetworkServer.active || !Object.op_Implicit((Object)(object)_genericArgs.Target)) { spawnOrb(); } else if (NetworkClient.active) { SendTo((NetworkDestination)2); } } private void spawnOrb() { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) Orb val; switch (_orbIdentifier.Type) { case ProjectileType.DamageOrb: { DamageOrbIdentifier identifier2 = DamageOrbCatalog.Instance.GetIdentifier(_orbIdentifier.Index); if (!identifier2.IsValid) { Log.Warning($"invalid damage orb at index {_orbIdentifier.Index}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\ProjectileRandomizer\\Orbs\\SpawnRandomizedOrbMessage.cs", "spawnOrb", 166); return; } GenericDamageOrb val2 = identifier2.CreateInstance(); if (val2 == null) { Log.Warning(string.Format("null {0} instance returned from {1}", "GenericDamageOrb", identifier2), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\ProjectileRandomizer\\Orbs\\SpawnRandomizedOrbMessage.cs", "spawnOrb", 173); return; } val2.damageValue = _damage; val2.attacker = _genericArgs.Owner; val2.isCrit = _isCrit; val2.teamIndex = _genericArgs.OwnerTeam; val = (Orb)(object)val2; break; } case ProjectileType.LightningOrb: { LightningOrbIdentifier identifier = LightningOrbCatalog.Instance.GetIdentifier(_orbIdentifier.Index); if (!identifier.IsValid) { Log.Warning($"invalid lightning orb at index {_orbIdentifier.Index}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\ProjectileRandomizer\\Orbs\\SpawnRandomizedOrbMessage.cs", "spawnOrb", 191); return; } LightningOrb obj = identifier.CreateInstance(); obj.damageValue = _damage; obj.attacker = _genericArgs.Owner; obj.inflictor = _genericArgs.Weapon; obj.teamIndex = _genericArgs.OwnerTeam; obj.isCrit = _isCrit; val = (Orb)(object)obj; break; } default: Log.Warning($"unhandled orb type {_orbIdentifier.Type}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\ProjectileRandomizer\\Orbs\\SpawnRandomizedOrbMessage.cs", "spawnOrb", 206); return; } val.origin = _origin; SquidOrb val3 = (SquidOrb)(object)((val is SquidOrb) ? val : null); if (val3 != null) { val3.forceScalar = _force; } if (Object.op_Implicit((Object)(object)_genericArgs.Target)) { val.target = _genericArgs.Target; } else if (!_overrideTargetPosition.HasValue) { Log.Warning("both _genericArgs.Target and _overrideTargetPosition null", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\ProjectileRandomizer\\Orbs\\SpawnRandomizedOrbMessage.cs", "spawnOrb", 225); } else { Vector3 value = _overrideTargetPosition.Value; OrbHurtBoxReferenceObjectOverridePatch.overrideOrbTargetPosition[val] = value; LightningStrikeOrb val4 = (LightningStrikeOrb)(object)((val is LightningStrikeOrb) ? val : null); if (val4 != null) { val4.lastKnownTargetPosition = value; } else { SimpleLightningStrikeOrb val5 = (SimpleLightningStrikeOrb)(object)((val is SimpleLightningStrikeOrb) ? val : null); if (val5 != null) { val5.lastKnownTargetPosition = value; } } } OrbManager_AddOrbHook.PatchDisabledCount++; OrbManager.instance.AddOrb(val); OrbManager_AddOrbHook.PatchDisabledCount--; } } } namespace RoR2Randomizer.Networking.ProjectileRandomizer.Orbs.Lightning { public sealed class SyncLightningOrbCatalog : NetworkMessageBase { public delegate void OnReceiveDelegate(LightningOrbIdentifier[] identifiers, int identifiersCount); private int _identifiersCount; private LightningOrbIdentifier[] _identifiers; public static event OnReceiveDelegate OnReceive; public SyncLightningOrbCatalog() { } public SyncLightningOrbCatalog(LightningOrbIdentifier[] identifiers, int identifiersCount) { _identifiers = identifiers; _identifiersCount = identifiersCount; } public override void Serialize(NetworkWriter writer) { writer.WritePackedUInt32((uint)_identifiersCount); for (int i = 0; i < _identifiersCount; i++) { _identifiers[i].Serialize(writer); } } public override void Deserialize(NetworkReader reader) { _identifiersCount = (int)reader.ReadPackedUInt32(); _identifiers = new LightningOrbIdentifier[_identifiersCount]; for (uint num = 0u; num < _identifiersCount; num++) { _identifiers[num] = new LightningOrbIdentifier(reader); } } public override void OnReceived() { SyncLightningOrbCatalog.OnReceive?.Invoke(_identifiers, _identifiersCount); } } public sealed class SyncLightningOrbIndexNeeded : NetworkMessageBase { public delegate void OnReceiveDelegate(LightningOrbIdentifier identifier); private LightningOrbIdentifier _identifier; public static event OnReceiveDelegate OnReceive; public SyncLightningOrbIndexNeeded() { } public SyncLightningOrbIndexNeeded(LightningOrbIdentifier identifier) { _identifier = identifier; } public override void Serialize(NetworkWriter writer) { _identifier.Serialize(writer); } public override void Deserialize(NetworkReader reader) { _identifier = new LightningOrbIdentifier(reader); } public override void OnReceived() { SyncLightningOrbIndexNeeded.OnReceive?.Invoke(_identifier); } } } namespace RoR2Randomizer.Networking.ProjectileRandomizer.Orbs.GenericDamage { public sealed class SyncDamageOrbCatalog : NetworkMessageBase { public delegate void OnReceiveDelegate(DamageOrbIdentifier[] identifiers, int identifiersCount); private DamageOrbIdentifier[] _identifiers; private int _identifiersCount; public static event OnReceiveDelegate OnReceive; public SyncDamageOrbCatalog() { } public SyncDamageOrbCatalog(DamageOrbIdentifier[] identifiers, int identifiersCount) { _identifiers = identifiers; _identifiersCount = identifiersCount; } public override void Serialize(NetworkWriter writer) { writer.WritePackedUInt32((uint)_identifiersCount); for (int i = 0; i < _identifiersCount; i++) { _identifiers[i].Serialize(writer); } } public override void Deserialize(NetworkReader reader) { int num = (int)reader.ReadPackedUInt32(); _identifiers = new DamageOrbIdentifier[_identifiersCount = num]; for (int i = 0; i < num; i++) { _identifiers[i] = new DamageOrbIdentifier(reader); } } public override void OnReceived() { if (!NetworkServer.active && NetworkClient.active) { SyncDamageOrbCatalog.OnReceive?.Invoke(_identifiers, _identifiersCount); } } } public sealed class SyncDamageOrbIndexNeeded : NetworkMessageBase { public delegate void OnReceiveDelegate(DamageOrbIdentifier required); private DamageOrbIdentifier _required; public static event OnReceiveDelegate OnReceive; public SyncDamageOrbIndexNeeded() { } public SyncDamageOrbIndexNeeded(in DamageOrbIdentifier required) { _required = required; } public override void Serialize(NetworkWriter writer) { _required.Serialize(writer); } public override void Deserialize(NetworkReader reader) { _required = new DamageOrbIdentifier(reader); } public override void OnReceived() { if (NetworkServer.active) { SyncDamageOrbIndexNeeded.OnReceive?.Invoke(_required); } } } } namespace RoR2Randomizer.Networking.ProjectileRandomizer.Bullet { public sealed class SyncBulletAttackCatalog : NetworkMessageBase { public delegate void OnReceiveDelegate(BulletAttackIdentifier[] identifiers, int identifiersCount); private BulletAttackIdentifier[] _identifiers; private int _identifiersCount; public static event OnReceiveDelegate OnReceive; public SyncBulletAttackCatalog() { } public SyncBulletAttackCatalog(BulletAttackIdentifier[] identifiers, int identifiersCount) { _identifiers = identifiers; _identifiersCount = identifiersCount; } public override void Serialize(NetworkWriter writer) { writer.WritePackedUInt32((uint)_identifiersCount); for (int i = 0; i < _identifiersCount; i++) { _identifiers[i].Serialize(writer); } } public override void Deserialize(NetworkReader reader) { int num = (int)reader.ReadPackedUInt32(); _identifiers = new BulletAttackIdentifier[_identifiersCount = num]; for (int i = 0; i < num; i++) { _identifiers[i] = new BulletAttackIdentifier(reader); } } public override void OnReceived() { if (!NetworkServer.active && NetworkClient.active) { SyncBulletAttackCatalog.OnReceive?.Invoke(_identifiers, _identifiersCount); } } } public sealed class SyncBulletAttackIndexNeeded : NetworkMessageBase { public delegate void OnReceiveDelegate(BulletAttackIdentifier required); private BulletAttackIdentifier _required; public static event OnReceiveDelegate OnReceive; public SyncBulletAttackIndexNeeded() { } public SyncBulletAttackIndexNeeded(in BulletAttackIdentifier required) { _required = required; } public override void Serialize(NetworkWriter writer) { _required.Serialize(writer); } public override void Deserialize(NetworkReader reader) { _required = new BulletAttackIdentifier(reader); } public override void OnReceived() { if (NetworkServer.active) { SyncBulletAttackIndexNeeded.OnReceive?.Invoke(_required); } } } } namespace RoR2Randomizer.Networking.ItemTierRandomizer { public sealed class SyncItemTierReplacements : ChunkedNetworkMessage { public delegate void OnReceiveDelegate(ItemTier?[] itemTierOverrides); private ItemTier?[] _itemTierOverrides; public static event OnReceiveDelegate OnReceive; public SyncItemTierReplacements(ItemTier?[] itemTierOverrides) { _itemTierOverrides = itemTierOverrides; } public SyncItemTierReplacements() { } public unsafe override void Serialize(NetworkWriter writer) { //IL_0006: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected I4, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) List> list = new List>(); GenericStaticEnumerable allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; ItemTier? val = _itemTierOverrides[current]; if (val.HasValue) { list.Add(new KeyValuePair(current, val.Value)); } } } finally { ((IDisposable)(*(AllItemsEnumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } writer.WritePackedUInt32((uint)list.Count); foreach (KeyValuePair item in list) { writer.WritePackedUInt32((uint)(int)item.Key); writer.Write((byte)item.Value); } } public override void Deserialize(NetworkReader reader) { //IL_0023: 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) _itemTierOverrides = ItemCatalog.GetPerItemBuffer(); uint num = reader.ReadPackedUInt32(); for (int i = 0; i < num; i++) { uint num2 = reader.ReadPackedUInt32(); ItemTier value = (ItemTier)reader.ReadByte(); _itemTierOverrides[num2] = value; } } public override void OnReceived() { if (!NetworkServer.active) { SyncItemTierReplacements.OnReceive?.Invoke(_itemTierOverrides); } } } } namespace RoR2Randomizer.Networking.ItemRandomizer { public class SyncItemReplacements : ChunkedNetworkMessage { public delegate void OnReceiveDelegate(in IndexReplacementsCollection itemIndexReplacements); private IndexReplacementsCollection _itemIndexReplacements; public static event OnReceiveDelegate OnReceive; public SyncItemReplacements(IndexReplacementsCollection itemIndexReplacements) { _itemIndexReplacements = itemIndexReplacements; } public SyncItemReplacements() { } public override void Serialize(NetworkWriter writer) { _itemIndexReplacements.Serialize(writer); } public override void Deserialize(NetworkReader reader) { _itemIndexReplacements = IndexReplacementsCollection.Deserialize(reader); } public override void OnReceived() { if (!NetworkServer.active) { SyncItemReplacements.OnReceive?.Invoke(in _itemIndexReplacements); } } } } namespace RoR2Randomizer.Networking.Generic { public abstract class NetworkMessageBase : INetMessage, ISerializableObject { public virtual void SendTo(NetworkDestination destination) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) NetMessageExtensions.Send((INetMessage)(object)this, destination); } public virtual void SendTo(NetworkConnection connection) { NetMessageExtensions.Send((INetMessage)(object)this, connection); } public abstract void Serialize(NetworkWriter writer); public abstract void Deserialize(NetworkReader reader); public abstract void OnReceived(); } public abstract class SyncGameObjectReference : NetworkMessageBase { private const float OBJECT_WAIT_TIMEOUT = 2f; private readonly GameObject _obj; private NetworkInstanceId _objectId; protected virtual bool shouldHandleEvent => true; public SyncGameObjectReference() { } protected SyncGameObjectReference(GameObject obj) { _obj = obj; } private static IEnumerator waitForNetIdInitialized(GameObject obj, CoroutineOut netId) { return baseTask(obj, netId).AddTimeout(2f); static IEnumerator baseTask(GameObject val, CoroutineOut val2) { while (Object.op_Implicit((Object)(object)val) && !val.activeInHierarchy) { yield return 0; } if (Object.op_Implicit((Object)(object)val)) { NetworkIdentity netIdentity = null; while (Object.op_Implicit((Object)(object)val)) { NetworkIdentity component; netIdentity = (component = val.GetComponent()); if (Object.op_Implicit((Object)(object)component)) { break; } yield return 0; } if (Object.op_Implicit((Object)(object)val)) { while (Object.op_Implicit((Object)(object)netIdentity)) { NetworkInstanceId netId2 = netIdentity.netId; if (!((NetworkInstanceId)(ref netId2)).IsEmpty()) { break; } yield return 0; } if (Object.op_Implicit((Object)(object)netIdentity)) { val2.Result = netIdentity.netId; } } } } } private static IEnumerator waitForNetIdThenSend(SyncGameObjectReference message, Action sendMessageFunc) { CoroutineOut netId = new CoroutineOut(); yield return waitForNetIdInitialized(message._obj, netId); if (netId.Result.HasValue) { message._objectId = netId.Result.Value; sendMessageFunc(); } } public override void SendTo(NetworkDestination destination) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)Main.Instance).StartCoroutine(waitForNetIdThenSend(this, delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) base.SendTo(destination); })); } public override void SendTo(NetworkConnection target) { ((MonoBehaviour)Main.Instance).StartCoroutine(waitForNetIdThenSend(this, delegate { base.SendTo(target); })); } public override void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(_objectId); } public override void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _objectId = reader.ReadNetworkId(); } public static IEnumerator WaitForObjectResolved(NetworkInstanceId objectId, float? timeout, CoroutineOut resolvedObject) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) IEnumerator enumerator = baseTask(objectId, resolvedObject); if (timeout.HasValue) { enumerator = enumerator.AddTimeout(timeout.Value); } return enumerator; static IEnumerator baseTask(NetworkInstanceId val2, CoroutineOut val) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) while (!Object.op_Implicit((Object)(object)(val.Result = (NetworkServer.active ? NetworkServer.FindLocalObject(val2) : ClientScene.FindLocalObject(val2))))) { yield return 0; } } } private IEnumerator waitForObjectResolved() { CoroutineOut resolvedObject = new CoroutineOut(); yield return WaitForObjectResolved(_objectId, 2f, resolvedObject); if (Object.op_Implicit((Object)(object)resolvedObject.Result)) { onReceivedObjectResolved(resolvedObject.Result); } } public override void OnReceived() { if (shouldHandleEvent) { if (((NetworkInstanceId)(ref _objectId)).IsEmpty()) { Log.Warning("recieved empty object id, aborting", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\Generic\\SyncGameObjectReference.cs", "OnReceived", 160); } else { ((MonoBehaviour)Main.Instance).StartCoroutine(waitForObjectResolved()); } } } protected abstract void onReceivedObjectResolved(GameObject obj); } } namespace RoR2Randomizer.Networking.Generic.Chunking { public abstract class ChunkedNetworkMessage : NetworkMessageBase { private class ConstructingMessage { public readonly Guid MessageID; private byte[][] _collectedMessageData; private SerializableSystemType? _messageType; public ConstructingMessage(Guid messageID) { MessageID = messageID; } public void HandleHeader(ChunkedMessageHeader header) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (_collectedMessageData == null) { _collectedMessageData = new byte[header.MessageCount][]; } else { Array.Resize(ref _collectedMessageData, header.MessageCount); } _messageType = header.CompleteMessageType; refreshMessages(); } public void CollectChunk(MessageChunk chunk) { if (_collectedMessageData == null) { _collectedMessageData = new byte[chunk.Header.ChunkIndex + 1][]; } else { ArrayUtils.EnsureCapacity(ref _collectedMessageData, chunk.Header.ChunkIndex + 1); } _collectedMessageData[chunk.Header.ChunkIndex] = chunk.Data; refreshMessages(); } private void refreshMessages() { if (_messageType.HasValue && _collectedMessageData.All((byte[] m) => m != null)) { onFullMessageReceived(); } } private void onFullMessageReceived() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) object obj; try { obj = Activator.CreateInstance((Type)_messageType.Value); } catch (Exception arg) { Log.Warning($"exception while creating message instance: {arg}", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\Generic\\Chunking\\ChunkedNetworkMessage.cs", "onFullMessageReceived", 110); obj = null; } if (obj != null) { receiveMessage(obj); } _constructingMessages.Remove(MessageID); } private void receiveMessage(object message) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown INetMessage val = (INetMessage)((message is INetMessage) ? message : null); if (val != null) { byte[] array = new byte[_collectedMessageData.Sum((byte[] m) => m.Length)]; int num = 0; byte[][] collectedMessageData = _collectedMessageData; foreach (byte[] array2 in collectedMessageData) { Array.Copy(array2, 0, array, num, array2.Length); num += array2.Length; } NetworkReader val2 = new NetworkReader(array); ((ISerializableObject)val).Deserialize(val2); val.OnReceived(); } else { Log.Warning(string.Format("message is not {0} ({1})", "INetMessage", message), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\Generic\\Chunking\\ChunkedNetworkMessage.cs", "receiveMessage", 149); } } } internal class ChunkedMessageHeader : NetworkMessageBase { internal Guid ID { get; private set; } internal byte MessageCount { get; private set; } internal SerializableSystemType CompleteMessageType { get; private set; } public ChunkedMessageHeader() { } public ChunkedMessageHeader(Guid id, byte messageCount, SerializableSystemType completeMessageType) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ID = id; MessageCount = messageCount; CompleteMessageType = completeMessageType; } public override void Serialize(NetworkWriter writer) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) Guid iD = ID; NetworkExtensions.WriteGuid(writer, ref iD); writer.Write(MessageCount); writer.WriteSerializableType(CompleteMessageType); } public override void Deserialize(NetworkReader reader) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) ID = NetworkExtensions.ReadGuid(reader); MessageCount = reader.ReadByte(); CompleteMessageType = reader.ReadSerializableType(); } public override void OnReceived() { handleReceiveChunkHeader(this); } } internal class MessageChunk : NetworkMessageBase { internal MessageChunkHeader Header { get; private set; } internal byte[] Data { get; private set; } public MessageChunk() { } public MessageChunk(MessageChunkHeader header, byte[] data, uint startIndex, uint count) { Header = header; int num = Mathf.Min((int)count, data.Length - (int)startIndex); Data = new byte[num]; Array.Copy(data, startIndex, Data, 0L, num); } public override void Serialize(NetworkWriter writer) { Header.Serialize(writer); writer.WritePackedUInt32((uint)Data.Length); writer.Write(Data, Data.Length); } public override void Deserialize(NetworkReader reader) { Header = new MessageChunkHeader(reader); uint num = reader.ReadPackedUInt32(); Data = reader.ReadBytes((int)num); } public override void OnReceived() { handleReceiveChunk(this); } } public const uint MAX_PACKET_SIZE = 1024u; private static readonly Dictionary _constructingMessages; private static ConstructingMessage getOrCreateConstructingMessage(Guid messageID) { if (!_constructingMessages.TryGetValue(messageID, out var value)) { value = new ConstructingMessage(messageID); _constructingMessages.Add(messageID, value); } return value; } private static void handleReceiveChunkHeader(ChunkedMessageHeader header) { getOrCreateConstructingMessage(header.ID).HandleHeader(header); } private static void handleReceiveChunk(MessageChunk chunk) { getOrCreateConstructingMessage(chunk.Header.MessageID).CollectChunk(chunk); } static ChunkedNetworkMessage() { _constructingMessages = new Dictionary(); Run.onRunDestroyGlobal += delegate { _constructingMessages.Clear(); }; } private bool trySendChunked(Action sendMessageFunc) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) NetworkWriter val = new NetworkWriter(); Serialize(val); byte[] array = val.AsArray(); int num = array.Length; if ((long)num >= 1024L) { byte b = (byte)Mathf.CeilToInt((float)num / 1041f); Guid guid = Guid.NewGuid(); ChunkedMessageHeader obj = new ChunkedMessageHeader(guid, b, (SerializableSystemType)GetType()); sendMessageFunc(obj); for (byte b2 = 0; b2 < b; b2++) { MessageChunk obj2 = new MessageChunk(new MessageChunkHeader(guid, b2), array, (uint)(b2 * 1024), 1024u); sendMessageFunc(obj2); } return true; } return false; } public override void SendTo(NetworkConnection connection) { if (!trySendChunked(delegate(NetworkMessageBase m) { m.SendTo(connection); })) { base.SendTo(connection); } } public override void SendTo(NetworkDestination destination) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (!trySendChunked(delegate(NetworkMessageBase m) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) m.SendTo(destination); })) { base.SendTo(destination); } } } public readonly struct MessageChunkHeader { public const int SIZE = 17; public readonly Guid MessageID; public readonly byte ChunkIndex; public MessageChunkHeader(Guid messageID, byte chunkIndex) { MessageID = messageID; ChunkIndex = chunkIndex; } public MessageChunkHeader(NetworkReader reader) : this(NetworkExtensions.ReadGuid(reader), reader.ReadByte()) { } public void Serialize(NetworkWriter writer) { NetworkExtensions.WriteGuid(writer, ref MessageID); writer.Write(ChunkIndex); } } } namespace RoR2Randomizer.Networking.ExplicitSpawnRandomizer { public sealed class SyncExplicitSpawnRandomizerEnabled : NetworkMessageBase { public delegate void OnReceiveDelegate(bool isEnabled, bool randomizeHeretic); private bool _isEnabled; private bool _randomizeHeretic; public static event OnReceiveDelegate OnReceive; public SyncExplicitSpawnRandomizerEnabled() { } public SyncExplicitSpawnRandomizerEnabled(bool isEnabled, bool randomizeHeretic) { _isEnabled = isEnabled; _randomizeHeretic = randomizeHeretic; } public override void Serialize(NetworkWriter writer) { writer.WriteBits(_isEnabled, _randomizeHeretic); } public override void Deserialize(NetworkReader reader) { reader.ReadBits(out _isEnabled, out _randomizeHeretic); } public override void OnReceived() { if (!NetworkServer.active && NetworkClient.active) { SyncExplicitSpawnRandomizerEnabled.OnReceive?.Invoke(_isEnabled, _randomizeHeretic); } } } public sealed class SyncExplicitSpawnReplacement : SyncGameObjectReference { public delegate void OnReceivedDelegate(GameObject masterObject, MasterIndex originalMasterIndex); private MasterIndex _originalMasterIndex; protected override bool shouldHandleEvent { get { if (!NetworkServer.active) { return NetworkClient.active; } return false; } } public static event OnReceivedDelegate OnReceive; public SyncExplicitSpawnReplacement() { } public SyncExplicitSpawnReplacement(GameObject obj, MasterIndex originalMasterIndex) : base(obj) { //IL_0008: 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) _originalMasterIndex = originalMasterIndex; } public override void Serialize(NetworkWriter writer) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) base.Serialize(writer); GeneratedNetworkCode._WriteNetworkMasterIndex_MasterCatalog(writer, NetworkMasterIndex.op_Implicit(_originalMasterIndex)); } public override void Deserialize(NetworkReader reader) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) base.Deserialize(reader); _originalMasterIndex = NetworkMasterIndex.op_Implicit(GeneratedNetworkCode._ReadNetworkMasterIndex_MasterCatalog(reader)); } protected override void onReceivedObjectResolved(GameObject obj) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) SyncExplicitSpawnReplacement.OnReceive?.Invoke(obj, _originalMasterIndex); } } } namespace RoR2Randomizer.Networking.EffectRandomizer { public sealed class SyncEffectReplacements : ChunkedNetworkMessage { public delegate void OnReceiveDelegate(in IndexReplacementsCollection effectReplacements); private IndexReplacementsCollection _effectReplacements; public static event OnReceiveDelegate OnReceive; public SyncEffectReplacements() { } public SyncEffectReplacements(in IndexReplacementsCollection effectReplacements) { _effectReplacements = effectReplacements; } public override void Serialize(NetworkWriter writer) { _effectReplacements.Serialize(writer); } public override void Deserialize(NetworkReader reader) { _effectReplacements = IndexReplacementsCollection.Deserialize(reader); } public override void OnReceived() { SyncEffectReplacements.OnReceive?.Invoke(in _effectReplacements); } } } namespace RoR2Randomizer.Networking.DamageOrbTargetDummy { public sealed class ClientRequestOrbTargetMarkerObjects : NetworkMessageBase { public sealed class Reply : NetworkMessageBase { public delegate void OnReceiveDelegate(OrbTargetDummyObjectMarker[] newTargetObjects); private NetworkInstanceId[] _objectIDs; public static event OnReceiveDelegate OnReceive; public Reply() { _objectIDs = Array.Empty(); } public Reply(GameObject[] objects) { _objectIDs = Array.ConvertAll(objects, (GameObject o) => o.GetComponent().netId); } public override void Serialize(NetworkWriter writer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) writer.WritePackedUInt32((uint)_objectIDs.Length); NetworkInstanceId[] objectIDs = _objectIDs; foreach (NetworkInstanceId val in objectIDs) { writer.Write(val); } } public override void Deserialize(NetworkReader reader) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) uint num = reader.ReadPackedUInt32(); _objectIDs = (NetworkInstanceId[])(object)new NetworkInstanceId[num]; for (uint num2 = 0u; num2 < num; num2++) { _objectIDs[num2] = reader.ReadNetworkId(); } } private static IEnumerator waitForAllObjectsResolvedAndInvokeEvent(NetworkInstanceId[] objectIDs) { CoroutineOut resolvedObject = new CoroutineOut(); OrbTargetDummyObjectMarker[] resolvedTargetObjects = new OrbTargetDummyObjectMarker[objectIDs.Length]; for (int i = 0; i < resolvedTargetObjects.Length; i++) { yield return SyncGameObjectReference.WaitForObjectResolved(objectIDs[i], null, resolvedObject); if (Object.op_Implicit((Object)(object)resolvedObject.Result)) { Object.DontDestroyOnLoad((Object)(object)resolvedObject.Result); OrbTargetDummyObjectMarker component = resolvedObject.Result.GetComponent(); component.IsAvailableToLocalPlayer = true; resolvedTargetObjects[i] = component; } } Reply.OnReceive?.Invoke(resolvedTargetObjects); } public override void OnReceived() { ((MonoBehaviour)Main.Instance).StartCoroutine(waitForAllObjectsResolvedAndInvokeEvent(_objectIDs)); } } private uint _newObjectCount; private NetworkUserId _requesterID; public ClientRequestOrbTargetMarkerObjects() { } public ClientRequestOrbTargetMarkerObjects(uint amount, NetworkUserId requesterID) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) _newObjectCount = amount; _requesterID = requesterID; } public override void Serialize(NetworkWriter writer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) writer.WritePackedUInt32(_newObjectCount); GeneratedNetworkCode._WriteNetworkUserId_None(writer, _requesterID); } public override void Deserialize(NetworkReader reader) { //IL_000e: 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) _newObjectCount = reader.ReadPackedUInt32(); _requesterID = GeneratedNetworkCode._ReadNetworkUserId_None(reader); } public override void OnReceived() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { Log.Error("called on client", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\DamageOrbTargetDummy\\ClientRequestOrbTargetMarkerObjects.cs", "OnReceived", 45); return; } NetworkConnection requesterConnection = null; if (((NetworkUserId)(ref _requesterID)).HasValidValue()) { NetworkUser val = ((IEnumerable)NetworkUser.readOnlyInstancesList).SingleOrDefault((Func)((NetworkUser user) => user.id.value == _requesterID.value)); if (Object.op_Implicit((Object)(object)val)) { requesterConnection = ((NetworkBehaviour)val).connectionToClient; } else { Log.Warning(string.Format("could not find {0} with id {1}", "NetworkUser", _requesterID), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\DamageOrbTargetDummy\\ClientRequestOrbTargetMarkerObjects.cs", "OnReceived", 59); } } else { Log.Warning("no valid requester ID", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\DamageOrbTargetDummy\\ClientRequestOrbTargetMarkerObjects.cs", "OnReceived", 64); } if (requesterConnection == null) { Log.Warning("unable to find requester connection", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\DamageOrbTargetDummy\\ClientRequestOrbTargetMarkerObjects.cs", "OnReceived", 69); } else { ((MonoBehaviour)Main.Instance).StartCoroutine(waitForConnectionReadyAndCreateObjects()); } IEnumerator waitForConnectionReadyAndCreateObjects() { while (requesterConnection != null && !requesterConnection.isReady) { yield return 0; } if (requesterConnection != null) { GameObject[] array = (GameObject[])(object)new GameObject[_newObjectCount]; for (int i = 0; i < _newObjectCount; i++) { OrbTargetDummyObjectMarker orbTargetDummyObjectMarker = OrbTargetDummyObjectMarker.InstantiateNew(); array[i] = ((Component)orbTargetDummyObjectMarker).gameObject; NetworkServer.SpawnWithClientAuthority(((Component)orbTargetDummyObjectMarker).gameObject, requesterConnection); } new Reply(array).SendTo(requesterConnection); } } } } } namespace RoR2Randomizer.Networking.CharacterReplacements { public sealed class SyncCharacterMasterReplacementMode : NetworkMessageBase { public delegate void OnReceiveDelegate(CharacterReplacementMode mode); private CharacterReplacementMode _mode; public static event OnReceiveDelegate OnReceive; public SyncCharacterMasterReplacementMode() { } public SyncCharacterMasterReplacementMode(CharacterReplacementMode mode) { _mode = mode; } public override void Serialize(NetworkWriter writer) { NetworkExtensions.WritePackedIndex32(writer, (int)_mode); } public override void Deserialize(NetworkReader reader) { _mode = (CharacterReplacementMode)NetworkExtensions.ReadPackedIndex32(reader); } public override void OnReceived() { if (!NetworkServer.active && NetworkClient.active) { SyncCharacterMasterReplacementMode.OnReceive?.Invoke(_mode); } } } public sealed class SyncCharacterMasterReplacements : ChunkedNetworkMessage { public delegate void OnReceivedDelegate(in IndexReplacementsCollection masterReplacements); private IndexReplacementsCollection _masterReplacements; public static event OnReceivedDelegate OnReceive; public SyncCharacterMasterReplacements() { } public SyncCharacterMasterReplacements(in IndexReplacementsCollection masterReplacements) { _masterReplacements = masterReplacements; } public override void Serialize(NetworkWriter writer) { _masterReplacements.Serialize(writer); } public override void Deserialize(NetworkReader reader) { _masterReplacements = IndexReplacementsCollection.Deserialize(reader); } public override void OnReceived() { if (!NetworkServer.active && NetworkClient.active) { SyncCharacterMasterReplacements.OnReceive?.Invoke(in _masterReplacements); } } } } namespace RoR2Randomizer.Networking.BossRandomizer { public enum BossReplacementType : uint { Invalid, MithrixNormal, MithrixHurt, MithrixPhase2, VoidlingPhase1, VoidlingPhase2, VoidlingPhase3, Aurelionite, LunarScav1, LunarScav2, LunarScav3, LunarScav4, AlloyWorshipUnit, TeleporterBoss, FalseSonBoss, FalseSonLunar, FalseSonBroken, SolusWing, Count } public class SyncBossReplacementCharacter : SyncGameObjectReference { public delegate void OnReceivedDelegate(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex); private BossReplacementType _replacementType; private MasterIndex? _originalMasterIndex; protected override bool shouldHandleEvent { get { if (!NetworkServer.active) { return NetworkClient.active; } return false; } } public static event OnReceivedDelegate OnReceive; public SyncBossReplacementCharacter() { } public SyncBossReplacementCharacter(GameObject masterObject, BossReplacementType replacementType, MasterIndex? originalMasterIndex) : base(masterObject) { _replacementType = replacementType; if (!replacementType.IsValid()) { Log.Warning(string.Format("about to sync a boss replacement with an invalid boss type of {0}! {1}={2}", replacementType, "masterObject", masterObject), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Networking\\BossRandomizer\\SyncBossReplacementCharacter.cs", ".ctor", 26); } _originalMasterIndex = originalMasterIndex; } public override void Serialize(NetworkWriter writer) { //IL_0031: 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) base.Serialize(writer); writer.WritePackedUInt32((uint)_replacementType); MasterIndex? originalMasterIndex = _originalMasterIndex; writer.WriteNullableNetworkMasterIndex(originalMasterIndex.HasValue ? new NetworkMasterIndex?(NetworkMasterIndex.op_Implicit(originalMasterIndex.GetValueOrDefault())) : ((NetworkMasterIndex?)null)); } public override void Deserialize(NetworkReader reader) { //IL_0031: 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) base.Deserialize(reader); _replacementType = (BossReplacementType)reader.ReadPackedUInt32(); NetworkMasterIndex? val = reader.ReadNullableNetworkMasterIndex(); _originalMasterIndex = (val.HasValue ? new MasterIndex?(NetworkMasterIndex.op_Implicit(val.GetValueOrDefault())) : ((MasterIndex?)null)); } protected override void onReceivedObjectResolved(GameObject obj) { SyncBossReplacementCharacter.OnReceive?.Invoke(obj, _replacementType, _originalMasterIndex); } } } namespace RoR2Randomizer.ModCompatibility { public static class RiskOfOptionsCompat { public static readonly InitializeOnAccess IsEnabled = new InitializeOnAccess((Func)(() => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))); private static readonly InitializeOnAccess _iconSprite = new InitializeOnAccess((Func)delegate { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, Resources.icon_embed)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero); } Log.Warning("LoadImage failed", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\ModCompatibility\\RiskOfOptionsCompat.cs", "_iconSprite", 23); return (Sprite)null; }); public static void Setup() { ModSettingsManager.SetModDescription("A Remade Risk of Rain 2 randomizer mod.\n\nMost of the settings will only take effect when the next run is started."); Sprite val = InitializeOnAccess.op_Implicit(_iconSprite); if (Object.op_Implicit((Object)(object)val)) { ModSettingsManager.SetModIcon(val); } } } } namespace RoR2Randomizer.Extensions { public static class CollectionExtensions { public static T GetRandomOrDefault(this IEnumerable enumerable, Xoroshiro128Plus rng, T fallback = default(T)) { if (enumerable == null) { throw new ArgumentNullException("enumerable"); } if (rng == null) { throw new ArgumentNullException("rng"); } if (enumerable is T[] array) { int num = array.Length; if (num > 0) { return rng.NextElementUniform(array); } } else if (enumerable is IList { Count: var count } list) { if (count > 0) { return rng.NextElementUniform(list); } } else { int num = enumerable.Count(); if (num > 0) { return enumerable.ElementAt(rng.RangeInt(0, num)); } } return fallback; } public static T PickWeighted(this IEnumerable enumerable, Xoroshiro128Plus rng, Func weightSelector) { if (enumerable == null) { throw new ArgumentNullException("enumerable"); } if (rng == null) { throw new ArgumentNullException("rng"); } if (weightSelector == null) { throw new ArgumentNullException("weightSelector"); } int num = ((!(enumerable is T[] array)) ? enumerable.Count() : array.Length); WeightedSelection val = new WeightedSelection(num); foreach (T item in enumerable) { val.AddChoice(item, weightSelector(item)); } return val.Evaluate(rng.nextNormalizedFloat); } public static TValue GetOrAddNew(this IDictionary dict, TKey key) where TValue : new() { if (dict == null) { throw new ArgumentNullException("dict"); } if (!dict.TryGetValue(key, out var value)) { value = new TValue(); dict.Add(key, value); } return value; } public static T GetAndRemoveAt(this IList list, int index) { if (list == null) { throw new ArgumentNullException("list"); } T result = list[index]; list.RemoveAt(index); return result; } public static T GetAndRemoveRandom(this IList list, Xoroshiro128Plus rng) { return list.GetAndRemoveAt(rng.RangeInt(0, list.Count)); } } public static class CoroutineExtensions { public static IEnumerator AddTimeout(this IEnumerator baseRoutine, float timeout, CoroutineOut result = null) { float timeStarted = Time.unscaledTime; while (baseRoutine.MoveNext()) { float num = Time.unscaledTime - timeStarted; if (num >= timeout) { if (result != null) { result.Result = new TimeoutActionResult(num, TimeoutActionResultState.TimedOut); } yield break; } yield return baseRoutine.Current; } if (result != null) { result.Result = new TimeoutActionResult(Time.unscaledTime - timeStarted, TimeoutActionResultState.Finished); } } } public static class DelegateExtensions { public static TryConvertDelegate AddNullCheck(this Func converter) where T : class { return delegate(T input, out T output) { output = converter(input); return output != null; }; } public static TryConvertToNextValue ToConvertToNextValue(this TryConvertDelegate tryConvert) { return delegate(ref T value) { return tryConvert(value, out value); }; } } public static class IndexReplacementsCollectionExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasReplacement(this in IndexReplacementsCollection instance, in T original) where T : Enum { return instance.HasReplacement((int)(object)original); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryGetReplacement(this in IndexReplacementsCollection instance, in T original, out T replacement) where T : Enum { int replacement2; bool result = instance.TryGetReplacement((int)(object)original, out replacement2); replacement = (T)(object)replacement2; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasOriginal(this in IndexReplacementsCollection instance, in T replacement) where T : Enum { return instance.HasOriginal((int)(object)replacement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryGetOriginal(this in IndexReplacementsCollection instance, in T replacement, out T original) where T : Enum { int original2; bool result = instance.TryGetOriginal((int)(object)replacement, out original2); original = (T)(object)original2; return result; } } public static class InventoryExtensions { public static bool HasItems(this GivePickupsOnStart givePickupsOnStart, ItemIndex item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) int count; return givePickupsOnStart.HasItems(item, out count); } public static bool HasItems(this GivePickupsOnStart givePickupsOnStart, ItemIndex item, out int count) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 if ((int)item == -1) { return (count = givePickupsOnStart.itemDefInfos.Length + givePickupsOnStart.itemInfos.Length) > 0; } return (count = givePickupsOnStart.itemDefInfos.Count((ItemDefInfo i) => i.itemDef.itemIndex == item) + givePickupsOnStart.itemInfos.Count((ItemInfo i) => ItemCatalog.FindItemIndex(i.itemString) == item)) > 0; } public static bool HasAnyItems(this GivePickupsOnStart givePickupsOnStart) { if (givePickupsOnStart.itemDefInfos.Length == 0) { return givePickupsOnStart.itemInfos.Length != 0; } return true; } public static bool HasEquipment(this GivePickupsOnStart givePickupsOnStart, EquipmentIndex equipment) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!Object.op_Implicit((Object)(object)givePickupsOnStart.equipmentDef) || givePickupsOnStart.equipmentDef.equipmentIndex != equipment) { if (!string.IsNullOrEmpty(givePickupsOnStart.equipmentString)) { return EquipmentCatalog.FindEquipmentIndex(givePickupsOnStart.equipmentString) == equipment; } return false; } return true; } public static bool HasAnyEquipment(this GivePickupsOnStart givePickupsOnStart) { if (!Object.op_Implicit((Object)(object)givePickupsOnStart.equipmentDef)) { return !string.IsNullOrEmpty(givePickupsOnStart.equipmentString); } return true; } public static void GiveItemIfMissing(this Inventory inventory, ItemDef item, int count = 1) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) inventory.GiveItemIfMissing(item.itemIndex, count); } public static void GiveItemIfMissing(this Inventory inventory, ItemIndex item, int count = 1) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) int itemCountEffective = inventory.GetItemCountEffective(item); if (itemCountEffective < count) { inventory.GiveItemPermanent(item, count - itemCountEffective); } } } public static class MiscExtensions { public static string ToLogString(this Variant variant) { //IL_0011: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) return "[" + Language.GetString(variant.skillDef.skillNameToken) + " (" + variant.skillDef.skillName + ", " + ((Object)variant.skillDef).name + "), (acticationState.stateType: " + (((SerializableEntityStateType)(ref variant.skillDef.activationState)).stateType?.FullName ?? "null") + ")]"; } public static bool IsValid(this BossReplacementType value) { if (value != BossReplacementType.Invalid) { return value < BossReplacementType.Count; } return false; } public static bool IsNothing(this SerializableEntityStateType state) { Type stateType = ((SerializableEntityStateType)(ref state)).stateType; if (!(stateType == null)) { return stateType == typeof(Uninitialized); } return true; } } public static class NetworkBitExtensions { private static bool[] _sharedBitsArray = Array.Empty(); private static void readBitsIntoArray(NetworkReader reader, int amount) { ArrayUtils.EnsureCapacity(ref _sharedBitsArray, amount); NetworkExtensions.ReadBitArray(reader, _sharedBitsArray, amount); } public static void WriteBits(this NetworkWriter writer, params bool[] bits) { NetworkExtensions.WriteBitArray(writer, bits); } public static void ReadBits(this NetworkReader reader, out bool bit) { readBitsIntoArray(reader, 1); bit = _sharedBitsArray[0]; } public static void ReadBits(this NetworkReader reader, out bool bit1, out bool bit2) { readBitsIntoArray(reader, 2); bit1 = _sharedBitsArray[0]; bit2 = _sharedBitsArray[1]; } public static void ReadBits(this NetworkReader reader, out bool bit1, out bool bit2, out bool bit3) { readBitsIntoArray(reader, 3); bit1 = _sharedBitsArray[0]; bit2 = _sharedBitsArray[1]; bit3 = _sharedBitsArray[2]; } } public static class NetworkingExtensions { public static SerializableSystemType ReadSerializableType(this NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return new SerializableSystemType { assemblyQualifiedName = reader.ReadString() }; } public static void WriteSerializableType(this NetworkWriter writer, SerializableSystemType serializableSystemType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) writer.Write(serializableSystemType.assemblyQualifiedName); } private static T? readNullable(this NetworkReader reader, Func readFunc) where T : struct { return reader.readNullable(() => readFunc(reader)); } private static T? readNullable(this NetworkReader reader, Func readFunc) where T : struct { if (!reader.ReadBoolean()) { return null; } return readFunc(); } private static void writeNullable(this NetworkWriter writer, T? value, Action writeFunc) where T : struct { writer.writeNullable(value, delegate(T t) { writeFunc(writer, t); }); } private static void writeNullable(this NetworkWriter writer, T? value, Action writeFunc) where T : struct { if (value.HasValue) { writer.Write(true); writeFunc(value.Value); } else { writer.Write(false); } } public static DamageType? ReadNullableDamageType(this NetworkReader reader) { return reader.readNullable((Func)((NetworkReader r) => (DamageType)r.ReadInt32())); } public static void WriteNullableDamageType(this NetworkWriter writer, DamageType? damageType) { writeNullable(writer, damageType, (Action)delegate(NetworkWriter w, DamageType v) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown w.Write((int)v); }); } public static Vector3? ReadNullableVector3(this NetworkReader reader) { return reader.readNullable((Func)reader.ReadVector3); } public static void WriteNullableVector3(this NetworkWriter writer, Vector3? vector3) { writeNullable(writer, vector3, (Action)writer.Write); } public static NetworkMasterIndex? ReadNullableNetworkMasterIndex(this NetworkReader reader) { return reader.readNullable((Func)GeneratedNetworkCode._ReadNetworkMasterIndex_MasterCatalog); } public static void WriteNullableNetworkMasterIndex(this NetworkWriter writer, NetworkMasterIndex? masterIndex) { writeNullable(writer, masterIndex, (Action)GeneratedNetworkCode._WriteNetworkMasterIndex_MasterCatalog); } } public static class PatchingExtensions { public static bool MatchImplicitConversion(this Instruction instruction) { return instruction.MatchImplicitConversion(typeof(TFrom), typeof(TTo)); } public static bool MatchImplicitConversion(this Instruction instruction, Type from, Type to) { return ILPatternMatchingExt.MatchCall(instruction, (MethodBase)ReflectionUtils.FindImplicitConversion(from, to)); } public static bool MatchGetMemberValue(this Instruction instruction, out MemberReference member) { MethodReference val = default(MethodReference); if (ILPatternMatchingExt.MatchCallOrCallvirt(instruction, ref val)) { member = (MemberReference)(object)val; return true; } FieldReference val2 = default(FieldReference); if (ILPatternMatchingExt.MatchLdfld(instruction, ref val2) || ILPatternMatchingExt.MatchLdflda(instruction, ref val2) || ILPatternMatchingExt.MatchLdsfld(instruction, ref val2) || ILPatternMatchingExt.MatchLdsflda(instruction, ref val2)) { member = (MemberReference)(object)val2; return true; } member = null; return false; } } public static class PickupExtensions { private static bool tryGrantTo(this PickupDef pickupDef, Inventory inventory, int count, bool forceOverrideEquipment, out bool notify) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (pickupDef == null || !Object.op_Implicit((Object)(object)inventory) || count <= 0) { notify = false; return false; } uint slotCount; if (pickupDef.IsItem()) { if (Object.op_Implicit((Object)(object)inventory)) { inventory.GiveItemPermanent(pickupDef.itemIndex, count); notify = true; } else { notify = false; } } else { if (!pickupDef.IsEquipment()) { Log.Warning($"pickup {pickupDef} not implemented", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Extensions\\PickupExtensions.cs", "tryGrantTo", 82); notify = false; return false; } if (Object.op_Implicit((Object)(object)inventory)) { if (forceOverrideEquipment) { for (uint num = 0u; num < count; num++) { inventory.SetEquipmentIndexForSlot(pickupDef.equipmentIndex, num); } } else { slotCount = (uint)inventory.GetEquipmentSlotCount(); if (!giveEquipments(requireEmpty: true)) { giveEquipments(requireEmpty: false); } } notify = true; } else { notify = false; } } return true; bool giveEquipments(bool requireEmpty) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0058: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0078: Unknown result type (might be due to invalid IL or missing references) if (count <= 0) { return false; } for (uint num2 = 0u; num2 < slotCount; num2++) { EquipmentState equipment = inventory.GetEquipment(num2); if (Object.op_Implicit((Object)(object)equipment.equipmentDef) && (requireEmpty ? ((int)equipment.equipmentDef.equipmentIndex == -1) : (equipment.equipmentDef.equipmentIndex != pickupDef.equipmentIndex))) { count--; inventory.SetEquipmentIndexForSlot(pickupDef.equipmentIndex, num2); if (count <= 0) { return true; } } } return false; } } public static bool TryGrantTo(this PickupDef pickupDef, Inventory inventory, int count = 1, bool forceOverrideEquipment = false) { bool notify; return pickupDef.tryGrantTo(inventory, count, forceOverrideEquipment, out notify); } public static bool TryGrantTo(this PickupDef pickupDef, CharacterMaster master, int count = 1, bool forceOverrideEquipment = false) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)master) && pickupDef.tryGrantTo(master.inventory, count, forceOverrideEquipment, out var notify)) { if (notify && Object.op_Implicit((Object)(object)master.playerCharacterMasterController)) { GenericPickupController.SendPickupMessage(master, new UniquePickup(pickupDef.pickupIndex)); } return true; } return false; } public static int GetPickupCount(this CharacterMaster master, PickupDef pickupDef) { if (pickupDef == null || !Object.op_Implicit((Object)(object)master)) { return 0; } return master.inventory.GetPickupCount(pickupDef); } public static int GetPickupCount(this Inventory inventory, PickupDef pickupDef) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) if (pickupDef == null || !Object.op_Implicit((Object)(object)inventory)) { return 0; } if (pickupDef.IsItem()) { if (Object.op_Implicit((Object)(object)inventory)) { return inventory.GetItemCountEffective(pickupDef.itemIndex); } } else if (pickupDef.IsEquipment() && Object.op_Implicit((Object)(object)inventory)) { int num = 0; int equipmentSlotCount = inventory.GetEquipmentSlotCount(); for (uint num2 = 0u; num2 < equipmentSlotCount; num2++) { EquipmentDef equipmentDef = inventory.GetEquipment(num2).equipmentDef; if (Object.op_Implicit((Object)(object)equipmentDef) && equipmentDef.equipmentIndex == pickupDef.equipmentIndex) { num++; } } return num; } return 0; } public static void TryDeductFrom(this PickupDef pickupDef, CharacterMaster master, int count = 1) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected I4, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) if (pickupDef == null || !Object.op_Implicit((Object)(object)master) || count <= 0) { return; } Inventory inventory = master.inventory; if (pickupDef.IsItem()) { if (Object.op_Implicit((Object)(object)inventory)) { count = Mathf.Min(count, inventory.GetItemCountPermanent(pickupDef.itemIndex)); if (count > 0) { inventory.RemoveItemPermanent(pickupDef.itemIndex, count); } } } else if (pickupDef.IsEquipment()) { if (!Object.op_Implicit((Object)(object)inventory)) { return; } int equipmentSlotCount = inventory.GetEquipmentSlotCount(); for (uint num = 0u; num < equipmentSlotCount; num++) { EquipmentState equipment = inventory.GetEquipment(num); if (Object.op_Implicit((Object)(object)equipment.equipmentDef) && equipment.equipmentDef.equipmentIndex == pickupDef.equipmentIndex) { count--; inventory.SetEquipmentIndexForSlot((EquipmentIndex)(-1), num); if (count <= 0) { break; } } } } else if ((int)pickupDef.miscPickupIndex != -1) { IReadOnlyList miscPickupDefs = MiscPickupCatalog.miscPickupDefs; if (miscPickupDefs == null) { return; } int num2 = (int)pickupDef.miscPickupIndex; if (num2 < 0 || num2 >= miscPickupDefs.Count) { return; } MiscPickupDef val = miscPickupDefs[num2]; uint coinValue = val.coinValue; if (val is LunarCoinDef) { NetworkUser val2 = Util.LookUpBodyNetworkUser(master.GetBody()); if (Object.op_Implicit((Object)(object)val2)) { val2.DeductLunarCoins(coinValue); } } else if (val is VoidCoinDef) { master.voidCoins -= coinValue; } else { Log.Warning(string.Format("{0} {1} is not implemented", "MiscPickupDef", val), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Extensions\\PickupExtensions.cs", "TryDeductFrom", 214); } } else { Log.Warning($"pickup {pickupDef} not implemented", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Extensions\\PickupExtensions.cs", "TryDeductFrom", 221); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsItem(this PickupDef pickupDef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)pickupDef.itemIndex != -1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsEquipment(this PickupDef pickupDef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 return (int)pickupDef.equipmentIndex != -1; } } public static class StringExtensions { private static readonly StringBuilder _stringBuilder = new StringBuilder(); public static string Repeat(this string str, uint count) { _stringBuilder.Clear(); for (uint num = 0u; num < count; num++) { _stringBuilder.Append(str); } return _stringBuilder.ToString(); } } public static class UnityObjectExtensions { public static Component GetOrAddComponent(this GameObject obj, Type componentType) { Component result = default(Component); if (obj.TryGetComponent(componentType, ref result)) { return result; } return obj.AddComponent(componentType); } public static T GetOrAddComponent(this GameObject obj) where T : Component { return (T)(object)obj.GetOrAddComponent(typeof(T)); } public static bool TryFindChild(this ChildLocator locator, string name, out Transform child) { return Object.op_Implicit((Object)(object)(child = locator.FindChild(name))); } public static bool TryGetModelBounds(this CharacterModel root, out Bounds bounds) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)root.mainSkinnedMeshRenderer)) { bounds = ((Renderer)root.mainSkinnedMeshRenderer).bounds; return true; } return ((Component)root).transform.TryGetModelBounds(out bounds); } public static bool TryGetModelBounds(this Transform root, out Bounds bounds) { //IL_0089: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Bounds? val = null; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(); foreach (Renderer val2 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val2) && val2.enabled && !(val2 is ParticleSystemRenderer)) { if (val.HasValue) { Bounds value = val.Value; ((Bounds)(ref value)).Encapsulate(val2.bounds); val = value; } else { val = val2.bounds; } } } if (val.HasValue) { bounds = val.Value; return true; } bounds = default(Bounds); return false; } public static string GetScenePath(this Transform transform) { return string.Join("/", from t in MiscUtils.CreateReverseLinkedListFromLinks(transform, (Transform t) => t.parent) select ((Object)t).name); } } } namespace RoR2Randomizer.CustomContent { public class ContentPackManager : IContentPackProvider { public static class Items { public static readonly ItemDef MonsterUseEquipmentDummyItem; static Items() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) MonsterUseEquipmentDummyItem = ScriptableObject.CreateInstance(); ((Object)MonsterUseEquipmentDummyItem).name = "MonsterUseEquipmentDummyItem"; MonsterUseEquipmentDummyItem.deprecatedTier = (ItemTier)5; MonsterUseEquipmentDummyItem.hidden = true; MonsterUseEquipmentDummyItem.canRemove = false; MonsterUseEquipmentDummyItem.AutoPopulateTokens(); } } private readonly ContentPack _contentPack = new ContentPack(); public string identifier => "Gorakh.RoR2Randomizer"; public void Init() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { _contentPack.identifier = identifier; _contentPack.entityStateTypes.Add(new Type[1] { typeof(MultiEntityState) }); _contentPack.itemDefs.Add((ItemDef[])(object)new ItemDef[1] { Items.MonsterUseEquipmentDummyItem }); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(_contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } public sealed class MultiEntityState : EntityState { public class StateMachineSubStatesData : MonoBehaviour { public SerializableEntityStateType[] StateTypes = Array.Empty(); public bool AlwaysExecuteEnter; public float MinActiveDuration; } private readonly struct SubState { public readonly EntityState EntityState; public readonly Type CachedStateType; public SubState(EntityState state) { EntityState = state; CachedStateType = ((object)state).GetType(); } private SubState(EntityStateIndex index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) EntityState = EntityStateCatalog.InstantiateState(CachedStateType = EntityStateCatalog.GetStateType(index)); } public SubState(NetworkReader reader) : this(NetworkExtensions.ReadEntityStateIndex(reader)) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) EntityState.OnDeserialize(reader); } public void Serialize(NetworkWriter writer) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) NetworkExtensions.Write(writer, EntityStateCatalog.GetStateIndex(CachedStateType)); EntityState.OnSerialize(writer); } } public static readonly SerializableEntityStateType SerializableStateType = new SerializableEntityStateType(typeof(MultiEntityState)); private SubState[] _subStates = Array.Empty(); private float _minActiveDuration; private float _enterExecuteTime = -1f; private bool _alwaysExecuteEnter; private bool _isWaitingForForceExitDestruction; public bool IsWaitingForForceExitDestruction => _isWaitingForForceExitDestruction; public void Initialize(StateMachineSubStatesData data) { _subStates = (from type in data.StateTypes select EntityStateCatalog.InstantiateState(((object)data).GetType()) into state select new SubState(state)).ToArray(); _alwaysExecuteEnter = data.AlwaysExecuteEnter; _minActiveDuration = data.MinActiveDuration; } public void OnOuterStateMachineAssigned() { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { SubState subState = subStates[i]; subState.EntityState.outer = base.outer; if (subState.EntityState is MultiEntityState multiEntityState) { multiEntityState.OnOuterStateMachineAssigned(); } } } public override void OnSerialize(NetworkWriter writer) { writer.WritePackedUInt32((uint)_subStates.Length); SubState[] subStates = _subStates; foreach (SubState subState in subStates) { subState.Serialize(writer); } writer.Write(_minActiveDuration); writer.WriteBits(_alwaysExecuteEnter, _isWaitingForForceExitDestruction); } public override void OnDeserialize(NetworkReader reader) { uint num = reader.ReadPackedUInt32(); _subStates = new SubState[num]; for (uint num2 = 0u; num2 < num; num2++) { _subStates[num2] = new SubState(reader); } _minActiveDuration = reader.ReadSingle(); reader.ReadBits(out _alwaysExecuteEnter, out _isWaitingForForceExitDestruction); } public override void OnEnter() { onEnter(null); } private void onEnter(HashSet exclude) { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { SubState subState = subStates[i]; if (exclude == null || !exclude.Contains(subState.CachedStateType)) { subState.EntityState.OnEnter(); } } _enterExecuteTime = Time.time; } internal void forceExit(HashSet excludeExitTypes, HashSet excludeEnterTypes) { if (_subStates == null) { return; } if (_alwaysExecuteEnter && _enterExecuteTime < 0f) { onEnter(excludeEnterTypes); } SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { SubState subState = subStates[i]; if (subState.EntityState != null && (excludeExitTypes == null || !excludeExitTypes.Contains(subState.CachedStateType))) { try { subState.EntityState.OnExit(); } catch (Exception arg) { Log.Warning(string.Format("Caught exception when exiting {0} due to state machine destroyed: {1}", "MultiEntityState", arg), "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\CustomContent\\MultiEntityState.cs", "forceExit", 160); } } } IEnumerator enumerator = waitThenDestroyFromForceExit(); if (Object.op_Implicit((Object)(object)base.outer)) { ((MonoBehaviour)base.outer).StartCoroutine(enumerator); } else { ((MonoBehaviour)Main.Instance).StartCoroutine(enumerator); } } private IEnumerator waitThenDestroyFromForceExit() { _isWaitingForForceExitDestruction = true; float num = Time.time - _enterExecuteTime; if (num < _minActiveDuration) { yield return (object)new WaitForSeconds(_minActiveDuration - num); } _isWaitingForForceExitDestruction = false; Object.Destroy((Object)(object)((Component)base.outer).gameObject); } public override void OnExit() { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { subStates[i].EntityState.OnExit(); } } public override void ModifyNextState(EntityState nextState) { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { subStates[i].EntityState.ModifyNextState(nextState); } } public override void Update() { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { subStates[i].EntityState.Update(); } } public override void FixedUpdate() { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { subStates[i].EntityState.FixedUpdate(); } } public override InterruptPriority GetMinimumInterruptPriority() { return (InterruptPriority)_subStates.Select((SubState subState) => (int)subState.EntityState.GetMinimumInterruptPriority()).Max(); } public override void PlayAnimation(string layerName, string animationStateName) { SubState[] subStates = _subStates; for (int i = 0; i < subStates.Length; i++) { subStates[i].EntityState.PlayAnimation(layerName, animationStateName); } } } } namespace RoR2Randomizer.Configuration { public abstract class BaseRandomizerConfig : ConfigCategory { private const string RANDOMIZER_NAME_POSTFIX = " Randomizer"; public readonly BoolConfigValue Enabled; public override ModCompatibilityFlags CompatibilityFlags => base.CompatibilityFlags | ModCompatibilityFlags.RiskOfOptions; protected BaseRandomizerConfig(string randomizerType, ConfigFile file, bool EnabledByDefault = true) : base(randomizerType + " Randomizer", file) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown Enabled = new BoolConfigValue(getEntry("Enabled", new ConfigDescription("If the " + randomizerType + " Randomizer should be enabled", (AcceptableValueBase)null, Array.Empty()), EnabledByDefault)); } } public class ConfigCategory { private static readonly InitializeOnAccessDictionary _configFields = new InitializeOnAccessDictionary((Func)((Type type) => ReflectionUtils.GetTypeHierarchyList(type).SelectMany((Type t) => (t == type) ? (from f in t.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where Array.IndexOf(f.FieldType.GetInterfaces(), typeof(IConfigModCompatibility)) != -1 select f) : _configFields[t]).ToArray())); public readonly string CategoryName; protected readonly ConfigFile _file; public virtual ModCompatibilityFlags CompatibilityFlags => ModCompatibilityFlags.None; public ConfigCategory(string categoryName, ConfigFile file) { CategoryName = categoryName; _file = file; } public void RunModCompatibilities() { if ((CompatibilityFlags & ModCompatibilityFlags.RiskOfOptions) != ModCompatibilityFlags.None && InitializeOnAccess.op_Implicit(RiskOfOptionsCompat.IsEnabled)) { riskOfOptionsCompatibility(); } } private void riskOfOptionsCompatibility() { FieldInfo[] array = _configFields[GetType()]; for (int i = 0; i < array.Length; i++) { ((IConfigModCompatibility)array[i].GetValue(this))?.CreateRiskOfOptionsEntry(); } } protected ConfigEntry getEntry(string key, T defaultValue) { return getEntry(key, ConfigDescription.Empty, defaultValue); } protected ConfigEntry getEntry(string key, string description, T defaultValue) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return getEntry(key, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty()), defaultValue); } protected ConfigEntry getEntry(string key, ConfigDescription description, T defaultValue) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown return _file.Bind(new ConfigDefinition(CategoryName, key), defaultValue, description); } } public static class ConfigManager { private static readonly List _allCategories = new List(); internal static MetadataConfig Metadata; public static BuffRandomizerConfig BuffRandomizer; public static BossRandomizerConfig BossRandomizer; public static StageRandomizerConfig StageRandomizer; public static ProjectileRandomizerConfig ProjectileRandomizer; public static ExplicitSpawnRandomizerConfig ExplicitSpawnRandomizer; public static ItemRandomizerConfig ItemRandomizer; public static ItemTierRandomizerConfig ItemTierRandomizer; public static PerformanceConfig Performance; public static FunConfig Fun; public static MiscConfig Misc; public static void Initialize(ConfigFile file) { _allCategories.Add(BuffRandomizer = new BuffRandomizerConfig(file)); _allCategories.Add(StageRandomizer = new StageRandomizerConfig(file)); _allCategories.Add(BossRandomizer = new BossRandomizerConfig(file)); _allCategories.Add(ProjectileRandomizer = new ProjectileRandomizerConfig(file)); _allCategories.Add(ExplicitSpawnRandomizer = new ExplicitSpawnRandomizerConfig(file)); _allCategories.Add(ItemRandomizer = new ItemRandomizerConfig(file)); _allCategories.Add(ItemTierRandomizer = new ItemTierRandomizerConfig(file)); _allCategories.Sort((ConfigCategory a, ConfigCategory b) => a.CategoryName.CompareTo(b.CategoryName)); _allCategories.Add(Performance = new PerformanceConfig(file)); _allCategories.Add(Fun = new FunConfig(file)); _allCategories.Add(Misc = new MiscConfig(file)); _allCategories.Insert(0, Metadata = new MetadataConfig(file)); foreach (ConfigCategory allCategory in _allCategories) { allCategory.RunModCompatibilities(); } } } public sealed class FunConfig : ConfigCategory { private readonly BoolConfigValue _gupMode; public override ModCompatibilityFlags CompatibilityFlags => base.CompatibilityFlags | ModCompatibilityFlags.RiskOfOptions; public bool GupModeActive { get { if ((bool)_gupMode && Object.op_Implicit((Object)(object)Caches.DLC.SOTV)) { return ((BaseUserEntitlementTracker)(object)EntitlementManager.localUserEntitlementTracker).AnyUserHasEntitlement(Caches.DLC.SOTV.requiredEntitlement); } return false; } } public FunConfig(ConfigFile file) : base("Fun", file) { _gupMode = new BoolConfigValue(getEntry("Gup Mode", "GUP ".Repeat(2500u), defaultValue: false)); } } internal sealed class MetadataConfig : ConfigCategory { public readonly BoolConfigValue DisplayModInfoOnStart; public MetadataConfig(ConfigFile file) : base("Metadata (These settings are not intended for users to modify)", file) { DisplayModInfoOnStart = new BoolConfigValue(getEntry("SHOW_MOD_INFO_MESSAGE", defaultValue: true)); } } public class MiscConfig : ConfigCategory { public readonly BoolConfigValue SurvivorPodRandomizerEnabled; public readonly BoolConfigValue EffectRandomizerEnabled; public readonly BoolConfigValue SniperWeakPointRandomizerEnabled; public override ModCompatibilityFlags CompatibilityFlags => base.CompatibilityFlags | ModCompatibilityFlags.RiskOfOptions; public MiscConfig(ConfigFile file) : base("Miscellaneous", file) { SurvivorPodRandomizerEnabled = new BoolConfigValue(getEntry("Survivor Spawn Pod Randomizer", "Randomizes the intro animation of all survivors.", defaultValue: true)); EffectRandomizerEnabled = new BoolConfigValue(getEntry("Effect Randomizer", "Randomizes various visual effects. (Potential Epilepsy Warning)", defaultValue: false)); SniperWeakPointRandomizerEnabled = new BoolConfigValue(getEntry("Weak Point Randomizer", "Randomizes which hitboxes are considered weak points for railgunner's scoped shot. The number of weak points on a character does not change.", defaultValue: true)); } } [Flags] public enum ModCompatibilityFlags : byte { None = 0, RiskOfOptions = 1 } public sealed class PerformanceConfig : ConfigCategory { public readonly EnumConfigValue SpawnLimitMode; public override ModCompatibilityFlags CompatibilityFlags => base.CompatibilityFlags | ModCompatibilityFlags.RiskOfOptions; public PerformanceConfig(ConfigFile file) : base("Performance", file) { SpawnLimitMode = new EnumConfigValue(getEntry("Spawn Limit Mode", "Limits the ability for characters to infinitely duplicate themselves.\n\nOff: No limit is applied, characters can duplicate infinitely.\n\nDecreaseByOneForEveryGeneration: Each summon has 1 less slot for summons than it's owner (A player spawned Goobo will have 2 Goobo slots, it's Goobo's will have 1 slot, and those Goobo's spawns will have no slots)\n\nHalveForEveryGeneration: Each minion will have half as many spawns slots as it's owner.\n\nDisableMinionSummon: Characters considered minions cannot spawn themselves at all. (Limits everything to 1 \"generation\")", CharacterLimitMode.DecreaseByOneForEveryGeneration)); } } } namespace RoR2Randomizer.Configuration.ConfigValue { public sealed class BoolConfigValue : GenericConfigValue { public BoolConfigValue(ConfigEntry entry) : base(entry) { } public override void CreateRiskOfOptionsEntry() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Entry)); } } public sealed class EnumConfigValue : GenericConfigValue where T : Enum { public EnumConfigValue(ConfigEntry entry) : base(entry) { } public override void CreateRiskOfOptionsEntry() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)Entry)); } } public sealed class EnumStringConfigValue : ParsedStringConfigValue where T : struct { private readonly bool _ignoreCase; public EnumStringConfigValue(ConfigEntry entry, T fallback, bool ignoreCase) : base(entry, fallback) { _ignoreCase = ignoreCase; } protected override bool tryParse(string str, out T value) { return Enum.TryParse(str, _ignoreCase, out value); } } public abstract class GenericConfigValue : IConfigModCompatibility { public readonly ConfigEntry Entry; public event Action OnChange; protected GenericConfigValue(ConfigEntry entry) { Entry = entry; Entry.SettingChanged += Entry_SettingChanged; } ~GenericConfigValue() { if (Entry != null) { Entry.SettingChanged -= Entry_SettingChanged; } } private void Entry_SettingChanged(object sender, EventArgs e) { this.OnChange?.Invoke(); } public string GetSettingPath() { ConfigDefinition definition = ((ConfigEntryBase)Entry).Definition; return definition.Section + "->" + definition.Key; } public abstract void CreateRiskOfOptionsEntry(); public static implicit operator T(GenericConfigValue config) { return config.Entry.Value; } } public interface IConfigModCompatibility { void CreateRiskOfOptionsEntry(); } public sealed class IntStringConfigValue : ParsedStringConfigValue { public IntStringConfigValue(ConfigEntry entry, int fallback) : base(entry, fallback) { } protected override bool tryParse(string str, out int value) { return int.TryParse(str, out value); } } public abstract class ParsedStringConfigValue : StringConfigValue { protected readonly T _fallback; public T Parsed { get { if (tryParse(Entry.Value, out var value)) { return value; } Log.Warning("Setting " + GetSettingPath() + " does not have a valid value", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedStringConfigValue.cs", "Parsed", 24); return _fallback; } } protected ParsedStringConfigValue(ConfigEntry entry, T fallback) : base(entry) { _fallback = fallback; } protected abstract bool tryParse(string str, out T value); } public class SliderConfigValue : GenericConfigValue { private readonly SliderType _type; private readonly float _min; private readonly float _max; private readonly string _format; private readonly float _increment; public SliderConfigValue(ConfigEntry entry, SliderType type, float min, float max, string format, float increment) : base(entry) { _type = type; _min = min; _max = max; _format = (string.IsNullOrEmpty(format) ? "{0}" : ("{0:" + format + "}")); _increment = increment; } public SliderConfigValue(ConfigEntry entry, SliderType type, float min, float max, string format) : this(entry, type, min, max, format, 1f) { } public SliderConfigValue(ConfigEntry entry, SliderType type, float min, float max) : this(entry, type, min, max, "F1") { } public override void CreateRiskOfOptionsEntry() { //IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0068: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown BaseOption val; switch (_type) { case SliderType.Slider: val = (BaseOption)new SliderOption((ConfigEntry)(object)Entry, new SliderConfig { min = _min, max = _max, formatString = _format }); break; case SliderType.IntSlider: val = (BaseOption)new IntSliderOption((ConfigEntry)(object)Entry, new IntSliderConfig { min = (int)_min, max = (int)_max, formatString = _format }); break; case SliderType.StepSlider: val = (BaseOption)new StepSliderOption((ConfigEntry)(object)Entry, new StepSliderConfig { min = _min, max = _max, formatString = _format, increment = _increment }); break; default: Log.Warning($"({typeof(T).Name}) Slider type {_type} is not implemented!", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\SliderConfigValue.cs", "CreateRiskOfOptionsEntry", 45); return; } ModSettingsManager.AddOption(val); } } public enum SliderType : byte { Slider, IntSlider, StepSlider } public class StringConfigValue : GenericConfigValue { public StringConfigValue(ConfigEntry entry) : base(entry) { } public override void CreateRiskOfOptionsEntry() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(Entry)); } } } namespace RoR2Randomizer.Configuration.ConfigValue.ParsedList { public class ParsedBuffIndexListConfigValue : ParsedListConfigValue { private static readonly List _instancesWaitingForCatalogInit = new List(); [SystemInitializer(new Type[] { typeof(BuffCatalog) })] private static void InitInstancesWaitingForCatalog() { foreach (ParsedBuffIndexListConfigValue item in _instancesWaitingForCatalogInit) { item.tryParseToList(); } _instancesWaitingForCatalogInit.Clear(); } public ParsedBuffIndexListConfigValue(ConfigEntry entry) : base(entry) { if (BuffCatalog.buffDefs == null) { _instancesWaitingForCatalogInit.Add(this); } } protected override IEnumerable parse(string[] values) { if (BuffCatalog.buffDefs == null) { return Enumerable.Empty(); } return from i in (from i in values.Select(delegate(string buffName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) buffName = buffName.Trim(); BuffIndex val = findBuffIndexCaseInsensitive(buffName); if ((int)val == -1) { if (!buffName.StartsWith("bd")) { val = findBuffIndexCaseInsensitive("bd" + buffName); } if ((int)val == -1) { Log.Warning("Could not find buff with name \"" + buffName + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedList\\ParsedBuffIndexListConfigValue.cs", "parse", 56); } } return val; }) where (int)i != -1 select i).Distinct() orderby i select i; static BuffIndex findBuffIndexCaseInsensitive(string buffName) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) BuffDef? obj = ((IEnumerable)BuffCatalog.buffDefs).FirstOrDefault((Func)((BuffDef bd) => string.Equals(((Object)bd).name, buffName, StringComparison.OrdinalIgnoreCase))); if (obj == null) { return (BuffIndex)(-1); } return obj.buffIndex; } } } public class ParsedEquipmentIndexListConfigValue : ParsedListConfigValue { public ParsedEquipmentIndexListConfigValue(ConfigEntry entry) : base(entry) { if (!((ResourceAvailability)(ref EquipmentCatalog.availability)).available) { ((ResourceAvailability)(ref EquipmentCatalog.availability)).CallWhenAvailable((Action)delegate { tryParseToList(); }); } } public static EquipmentIndex FindEquipmentIndexCaseInsensitive(string equipmentName) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) EquipmentDef? obj = ((IEnumerable)EquipmentCatalog.equipmentDefs).FirstOrDefault((Func)((EquipmentDef ed) => string.Equals(((Object)ed).name, equipmentName, StringComparison.OrdinalIgnoreCase))); if (obj == null) { return (EquipmentIndex)(-1); } return obj.equipmentIndex; } protected override IEnumerable parse(string[] values) { if (!((ResourceAvailability)(ref EquipmentCatalog.availability)).available) { return Enumerable.Empty(); } return from i in (from i in values.Select(delegate(string equipmentName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 equipmentName = equipmentName.Trim(); EquipmentIndex val = FindEquipmentIndexCaseInsensitive(equipmentName); if ((int)val == -1) { Log.Warning("Could not find equipment with name \"" + equipmentName + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedList\\ParsedEquipmentIndexListConfigValue.cs", "parse", 37); } return val; }) where (int)i != -1 select i).Distinct() orderby i select i; } } public class ParsedItemIndexListConfigValue : ParsedListConfigValue { public ParsedItemIndexListConfigValue(ConfigEntry entry) : base(entry) { if (!((ResourceAvailability)(ref ItemCatalog.availability)).available) { ((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)delegate { tryParseToList(); }); } } public static ItemIndex FindItemIndexCaseInsensitive(string itemName) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ItemDef? obj = ((IEnumerable)ItemCatalog.itemDefs).FirstOrDefault((Func)((ItemDef item) => string.Equals(((Object)item).name, itemName, StringComparison.OrdinalIgnoreCase))); if (obj == null) { return (ItemIndex)(-1); } return obj.itemIndex; } protected override IEnumerable parse(string[] values) { if (!((ResourceAvailability)(ref ItemCatalog.availability)).available) { return Enumerable.Empty(); } return from i in (from i in values.Select(delegate(string itemName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 itemName = itemName.Trim(); ItemIndex val = FindItemIndexCaseInsensitive(itemName); if ((int)val == -1) { Log.Warning("Could not find item with name \"" + itemName + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedList\\ParsedItemIndexListConfigValue.cs", "parse", 37); } return val; }) where (int)i != -1 select i).Distinct() orderby i select i; } } public abstract class ParsedListConfigValue : StringConfigValue, IEnumerable, IEnumerable { private T[] _parsedArray; public ReadOnlyArray ParsedArray { get; private set; } public ParsedListConfigValue(ConfigEntry entry) : base(entry) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) _parsedArray = Array.Empty(); ParsedArray = ReadOnlyArray.op_Implicit(_parsedArray); base.OnChange += tryParseToList; tryParseToList(); } protected void tryParseToList() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) string value = Entry.Value; if (!string.IsNullOrWhiteSpace(value)) { string[] array = value.Split(','); if (array.Length != 0) { _parsedArray = parse(array).ToArray(); ParsedArray = ReadOnlyArray.op_Implicit(_parsedArray); } } } protected abstract IEnumerable parse(string[] values); public int BinarySearch(T value, IComparer comparer = null) { if (comparer != null) { return Array.BinarySearch(_parsedArray, value, comparer); } return Array.BinarySearch(_parsedArray, value); } public IEnumerator GetEnumerator() { return ((IEnumerable)_parsedArray).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return _parsedArray.GetEnumerator(); } } public class ParsedMasterIndexListConfigValue : ParsedListConfigValue { private static readonly List _instancesWaitingForCatalogInit = new List(); [SystemInitializer(new Type[] { typeof(MasterCatalog) })] private static void InitInstancesWaitingForCatalog() { foreach (ParsedMasterIndexListConfigValue item in _instancesWaitingForCatalogInit) { item.tryParseToList(); } _instancesWaitingForCatalogInit.Clear(); } public ParsedMasterIndexListConfigValue(ConfigEntry entry) : base(entry) { if (MasterCatalog.allMasters == null) { _instancesWaitingForCatalogInit.Add(this); } } protected override IEnumerable parse(string[] values) { if (MasterCatalog.allMasters == null) { return Enumerable.Empty(); } return (from i in values.Select(delegate(string masterName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) masterName = masterName.Trim(); MasterIndex result = findMasterIndexCaseInsensitive(masterName); if (!((MasterIndex)(ref result)).isValid) { if (!masterName.EndsWith("Master")) { result = findMasterIndexCaseInsensitive(masterName + "Master"); } if (!((MasterIndex)(ref result)).isValid && !masterName.EndsWith("MonsterMaster")) { result = findMasterIndexCaseInsensitive(masterName + "MonsterMaster"); } if (!((MasterIndex)(ref result)).isValid) { Log.Warning("Could not find master index with name \"" + masterName + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedList\\ParsedMasterIndexListConfigValue.cs", "parse", 72); } } return result; }) where ((MasterIndex)(ref i)).isValid select i).Distinct().OrderBy((MasterIndex i) => i, MasterIndexComparer.Instance); static MasterIndex findMasterIndexCaseInsensitive(string masterName) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) CharacterMaster val = MasterCatalog.allMasters.FirstOrDefault((Func)((CharacterMaster m) => string.Equals(((Object)m).name, masterName, StringComparison.OrdinalIgnoreCase))); if (!Object.op_Implicit((Object)(object)val) || !CharacterReplacements.ShouldRandomizeMaster(val)) { return MasterIndex.none; } return val.masterIndex; } } } public class ParsedPickupIndexListConfigValue : ParsedListConfigValue { private static readonly List _instancesWaitingForCatalogInit = new List(); [SystemInitializer(new Type[] { typeof(PickupCatalog) })] private static void InitInstancesWaitingForCatalog() { foreach (ParsedPickupIndexListConfigValue item in _instancesWaitingForCatalogInit) { item.tryParseToList(); } _instancesWaitingForCatalogInit.Clear(); } public ParsedPickupIndexListConfigValue(ConfigEntry entry) : base(entry) { if (PickupCatalog.pickupCount == 0) { _instancesWaitingForCatalogInit.Add(this); } } public static PickupIndex FindPickupIndexCaseInsensitive(string pickupName) { //IL_002d: 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) PickupDef? obj = PickupCatalog.allPickups.FirstOrDefault((Func)((PickupDef pd) => string.Equals(pd.internalName, pickupName, StringComparison.OrdinalIgnoreCase))); if (obj == null) { return PickupIndex.none; } return obj.pickupIndex; } protected override IEnumerable parse(string[] values) { if (PickupCatalog.pickupCount == 0) { return Enumerable.Empty(); } return (from i in ((IEnumerable)values).Select((Func)delegate(string pickupName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0035: Invalid comparison between Unknown and I4 //IL_0025: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) pickupName = pickupName.Trim(); PickupIndex result = FindPickupIndexCaseInsensitive(pickupName); if (((PickupIndex)(ref result)).isValid) { return result; } ItemIndex val = ParsedItemIndexListConfigValue.FindItemIndexCaseInsensitive(pickupName); if ((int)val != -1) { return PickupCatalog.FindPickupIndex(val); } EquipmentIndex val2 = ParsedEquipmentIndexListConfigValue.FindEquipmentIndexCaseInsensitive(pickupName); if ((int)val2 != -1) { return PickupCatalog.FindPickupIndex(val2); } Log.Warning("Could not find pickup with name \"" + pickupName + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedList\\ParsedPickupIndexListConfigValue.cs", "parse", 59); return PickupIndex.none; }) where ((PickupIndex)(ref i)).isValid select i).Distinct().OrderBy((PickupIndex i) => i, PickupIndexComparer.Instance); } } public class ParsedSceneIndexListConfigValue : ParsedListConfigValue { public ParsedSceneIndexListConfigValue(ConfigEntry entry) : base(entry) { if (!((ResourceAvailability)(ref SceneCatalog.availability)).available) { ((ResourceAvailability)(ref SceneCatalog.availability)).CallWhenAvailable((Action)delegate { tryParseToList(); }); } } public static SceneIndex FindSceneIndexCaseInsensitive(string sceneName) { //IL_000d: 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) SceneDef? obj = ((IEnumerable)(object)SceneCatalog.allSceneDefs).FirstOrDefault((Func)((SceneDef sd) => string.Equals(sd.cachedName, sceneName, StringComparison.OrdinalIgnoreCase))); if (obj == null) { return (SceneIndex)(-1); } return obj.sceneDefIndex; } protected override IEnumerable parse(string[] values) { if (!((ResourceAvailability)(ref SceneCatalog.availability)).available) { return Enumerable.Empty(); } return from i in (from i in values.Select(delegate(string sceneName) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 sceneName = sceneName.Trim(); SceneIndex val = FindSceneIndexCaseInsensitive(sceneName); if ((int)val == -1) { Log.Warning("Could not find scene index with name \"" + sceneName + "\"", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\Configuration\\ConfigValue\\ParsedList\\ParsedSceneIndexListConfigValue.cs", "parse", 38); } return val; }) where (int)i != -1 select i).Distinct() orderby i select i; } } } namespace RoR2Randomizer.ChildTransformAdditions { public static class CustomChildTransformManager { [Flags] public enum ChildFlags : byte { None = 0, ForceNewObject = 1 } public static void AutoAddChildTransform(EntityState state, string name, ChildFlags flags = ChildFlags.None) { if (state != null) { AutoAddChildTransform(state.characterBody, state.GetModelChildLocator(), name, flags); } } public static void AutoAddChildTransform(CharacterBody body, ChildLocator locator, string name, ChildFlags flags = ChildFlags.None) { //IL_0029: 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) if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)locator) && !Object.op_Implicit((Object)(object)locator.FindChild(name))) { ref NameTransformPair[] transformPairs = ref locator.transformPairs; NameTransformPair customChildTransformPair = getCustomChildTransformPair(body, locator, name, flags); ArrayUtils.ArrayAppend(ref transformPairs, ref customChildTransformPair); } } public static void AutoAddChildTransforms(EntityState state, params string[] names) { if (state != null) { AutoAddChildTransforms(state.characterBody, state.GetModelChildLocator(), names); } } public static void AutoAddChildTransforms(CharacterBody body, ChildLocator locator, params string[] names) { if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)locator) && names.Length != 0) { MiscUtils.AddItems(ref locator.transformPairs, from n in names where !Object.op_Implicit((Object)(object)locator.FindChild(n)) select getCustomChildTransformPair(body, locator, n, ChildFlags.None)); } } private static NameTransformPair getCustomChildTransformPair(CharacterBody body, ChildLocator locator, string name, ChildFlags flags) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Transform val = getCustomChildTransform(body, locator, name, flags); if ((flags & ChildFlags.ForceNewObject) != ChildFlags.None) { Transform transform = new GameObject(name).transform; transform.parent = val; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; val = transform; } return new NameTransformPair { transform = val, name = name }; } private static Transform getCustomChildTransform(CharacterBody body, ChildLocator locator, string name, ChildFlags flags) { Transform result = default(Transform); switch (name) { case "MuzzleLeft": if (locator.TryFindChild("HandL", ref result)) { break; } goto default; case "MuzzleRight": if (locator.TryFindChild("HandR", ref result)) { break; } goto default; case "BodyCenter": if (Object.op_Implicit((Object)(object)(result = body.coreTransform))) { break; } goto default; default: if (!Object.op_Implicit((Object)(object)(result = body.aimOriginTransform))) { result = body.transform; } break; } return result; } } } namespace RoR2Randomizer.CharacterLimiter { public enum CharacterLimitMode { Off, DecreaseByOneForEveryGeneration, HalveForEveryGeneration, DisableMinionSummon } public class LimitedCharacterData : MonoBehaviour { public DeployableSlot DeployableType = (DeployableSlot)35; public LimitedCharacterType Type; public int Generation; public static LimitedCharacterData AddGeneration(GameObject master, GameObject owner, LimitedCharacterType type) { LimitedCharacterData limitedCharacterData = master.AddComponent(); limitedCharacterData.Generation = GetGeneration(owner) + 1; limitedCharacterData.Type = type; return limitedCharacterData; } public static int GetGeneration(GameObject master) { LimitedCharacterData limitedCharacterData = default(LimitedCharacterData); if (!Object.op_Implicit((Object)(object)master) || !master.TryGetComponent(ref limitedCharacterData)) { return 0; } return limitedCharacterData.Generation; } private void Start() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Deployable val = default(Deployable); if (!((Component)this).TryGetComponent(ref val) || !Object.op_Implicit((Object)(object)val.ownerMaster)) { return; } foreach (DeployableInfo deployables in val.ownerMaster.deployablesList) { if ((Object)(object)deployables.deployable == (Object)(object)val) { DeployableType = deployables.slot; break; } } } } public enum LimitedCharacterType { Goobo, EngiAsTurret, Count } } namespace RoR2Randomizer.BodyAnimationMirroring { [Serializable] public readonly struct BoneIdentifier : IEquatable { [SerializeField] private readonly bool _isID; [SerializeField] private readonly HumanBodyBones _boneID; [SerializeField] private readonly string _boneName; public BoneIdentifier(HumanBodyBones boneID) : this(isID: true, boneID, null) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) public BoneIdentifier(string boneName) : this(isID: false, (HumanBodyBones)(-1), boneName) { } private BoneIdentifier(bool isID, HumanBodyBones boneID, string boneName) { //IL_0008: 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) _isID = isID; _boneID = boneID; _boneName = boneName; } public override bool Equals(object obj) { if (obj is BoneIdentifier other) { return Equals(other); } return false; } public bool Equals(BoneIdentifier other) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (_isID != other._isID) { return false; } if (_isID) { return _boneID == other._boneID; } return string.Equals(_boneName, other._boneName, StringComparison.OrdinalIgnoreCase); } public override int GetHashCode() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) int num = -813282265; num = num * -1521134295 + _isID.GetHashCode(); if (_isID) { return num * -1521134295 + ((object)_boneID/*cast due to .constrained prefix*/).GetHashCode(); } return num * -1521134295 + _boneName.GetHashCode(); } public static bool operator ==(in BoneIdentifier left, in BoneIdentifier right) { return left.Equals(right); } public static bool operator !=(in BoneIdentifier left, in BoneIdentifier right) { return !(left == right); } public static implicit operator BoneIdentifier(HumanBodyBones boneID) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new BoneIdentifier(boneID); } public static implicit operator BoneIdentifier(string boneName) { return new BoneIdentifier(boneName); } } public class BoneMarker : MonoBehaviour { public BoneIdentifier Identifier; private SyncToTransform _transformSync; public bool HasForcedTargetTransform { get { if (Object.op_Implicit((Object)(object)_transformSync)) { return Object.op_Implicit((Object)(object)_transformSync.Target); } return false; } } public void SetForceTargetBone(BoneMarker target) { if (!Object.op_Implicit((Object)(object)_transformSync)) { _transformSync = ((Component)this).gameObject.AddComponent(); } _transformSync.Target = ((Component)target).transform; } public void ReturnToOriginalTransform(float tweenDuration) { if (HasForcedTargetTransform) { _transformSync.ResetToOriginalTransform(tweenDuration); } } private void OnDestroy() { if (HasForcedTargetTransform) { Object.Destroy((Object)(object)_transformSync); } } } public abstract class CharacterAnimationMirrorBase : MonoBehaviour { protected readonly List _boneMarkers = new List(); public Animator Animator { get; private set; } protected IEnumerable<(BoneMarker originalBone, BoneMarker matchingBone)> findAllMatchingBones(CharacterAnimationMirrorBase other) { foreach (BoneMarker originalBone in _boneMarkers) { foreach (BoneMarker boneMarker in other._boneMarkers) { if (originalBone.Identifier == boneMarker.Identifier) { yield return (originalBone: originalBone, matchingBone: boneMarker); } } } } protected virtual void Awake() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Animator = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)Animator)) { for (HumanBodyBones val = (HumanBodyBones)0; (int)val < 55; val = (HumanBodyBones)(val + 1)) { Transform boneTransform = Animator.GetBoneTransform(val); if (Object.op_Implicit((Object)(object)boneTransform)) { BoneMarker boneMarker = ((Component)boneTransform).gameObject.AddComponent(); boneMarker.Identifier = val; _boneMarkers.Add(boneMarker); } } } CharacterModel characterModel = default(CharacterModel); if (((Component)this).TryGetComponent(ref characterModel)) { setupBones(characterModel); } } private void setupBones(CharacterModel characterModel) { if (characterModel.baseRendererInfos == null) { Log.Error("baseRendererInfos is null", "C:\\Users\\michi\\source\\repos\\RoR2Randomizer\\RoR2Randomizer\\RoR2Randomizer\\BodyAnimationMirroring\\CharacterAnimationMirrorBase.cs", "setupBones", 64); return; } foreach (SkinnedMeshRenderer item in characterModel.baseRendererInfos.Where((RendererInfo ri) => Object.op_Implicit((Object)(object)ri.renderer) && ri.renderer is SkinnedMeshRenderer).Select((Func)((RendererInfo ri) => (SkinnedMeshRenderer)ri.renderer))) { Transform[] bones = item.bones; foreach (Transform val in bones) { if (Object.op_Implicit((Object)(object)val)) { setupBone(val); } } } } private void setupBone(Transform bone) { BoneMarker boneMarker = ((Component)bone).gameObject.AddComponent(); boneMarker.Identifier = ((Object)bone).name; _boneMarkers.Add(boneMarker); } protected virtual void OnDestroy() { foreach (BoneMarker boneMarker in _boneMarkers) { if (Object.op_Implicit((Object)(object)boneMarker)) { Object.Destroy((Object)(object)boneMarker); } } } } public class CharacterAnimationMirrorOwner : CharacterAnimationMirrorBase { private CharacterAnimationMirrorTarget _mirrorModel; private bool _isWaitingToDestroy; public CharacterAnimationMirrorTarget MirrorModel { get { return _mirrorModel; } set { _mirrorModel = value; foreach (BoneMarker boneMarker in _boneMarkers) { boneMarker.ReturnToOriginalTransform(0f); } foreach (var item in findAllMatchingBones(value)) { item.originalBone.SetForceTargetBone(item.matchingBone); } } } public Animator MirrorAnimator { get { if (Object.op_Implicit((Object)(object)MirrorModel)) { return MirrorModel.Animator; } return null; } } public bool IsValid => !_isWaitingToDestroy; protected override void OnDestroy() { base.OnDestroy(); if (Object.op_Implicit((Object)(object)MirrorModel)) { MirrorModel.CleanupSelf(); } } public static Animator GetMirrorTargetAnimatorOrOriginal(Animator original) { CharacterAnimationMirrorOwner characterAnimationMirrorOwner = default(CharacterAnimationMirrorOwner); if (Object.op_Implicit((Object)(object)original) && ((Component)original).TryGetComponent(ref characterAnimationMirrorOwner) && characterAnimationMirrorOwner.IsValid) { Animator mirrorAnimator = characterAnimationMirrorOwner.MirrorAnimator; if (Object.op_Implicit((Object)(object)mirrorAnimator)) { return mirrorAnimator; } } return original; } public static CharacterAnimationMirrorOwner SetupForModelTransform(Transform modelTransform, BodyIndex mirrorBodyIndex) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) CharacterAnimationMirrorOwner characterAnimationMirrorOwner = ((Component)modelTransform).gameObject.AddComponent(); characterAnimationMirrorOwner.setupMirrorBody(mirrorBodyIndex); return characterAnimationMirrorOwner; } private void setupMirrorBody(BodyIndex mirrorBodyIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if ((int)mirrorBodyIndex == -1) { return; } CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(mirrorBodyIndex); if (!Object.op_Implicit((Object)(object)bodyPrefabBodyComponent)) { return; } ModelLocator component = ((Component)bodyPrefabBodyComponent).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { Transform modelTransform = component.modelTransform; if (Object.op_Implicit((Object)(object)modelTransform)) { CharacterAnimationMirrorTarget characterAnimationMirrorTarget = ((Component)Object.Instantiate(modelTransform, ((Component)this).transform.position, ((Component)this).transform.rotation)).gameObject.AddComponent(); characterAnimationMirrorTarget.Owner = this; MirrorModel = characterAnimationMirrorTarget; } } } public void StopMirroring(float tweenDuration) { if (_isWaitingToDestroy) { return; } if (tweenDuration <= 0f) { Object.Destroy((Object)(object)this); return; } foreach (BoneMarker boneMarker in _boneMarkers) { if (Object.op_Implicit((Object)(object)boneMarker)) { if (boneMarker.HasForcedTargetTransform) { boneMarker.ReturnToOriginalTransform(tweenDuration); } else { Object.Destroy((Object)(object)boneMarker); } } } ((MonoBehaviour)this).StartCoroutine(waitThenDestroy(tweenDuration)); } private IEnumerator waitThenDestroy(float waitTime) { _isWaitingToDestroy = true; yield return (object)new WaitForSeconds(waitTime); Object.Destroy((Object)(object)this); } } public class CharacterAnimationMirrorTarget : CharacterAnimationMirrorBase { public CharacterAnimationMirrorOwner Owner; private Transform transform; protected override void Awake() { base.Awake(); transform = ((Component)this).transform; if (Object.op_Implicit((Object)(object)base.Animator)) { base.Animator.cullingMode = (AnimatorCullingMode)0; } Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } HurtBoxGroup component = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { HurtBox[] hurtBoxes = component.hurtBoxes; for (int i = 0; i < hurtBoxes.Length; i++) { Object.Destroy((Object)(object)hurtBoxes[i]); } Object.Destroy((Object)(object)component); } else { HurtBox[] hurtBoxes = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < hurtBoxes.Length; i++) { Object.Destroy((Object)(object)hurtBoxes[i]); } } Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } CharacterModel component2 = ((Component)this).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { ((Behaviour)component2).enabled = false; } } private void Update() { //IL_002e: 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) if (Object.op_Implicit((Object)(object)Owner) && Object.op_Implicit((Object)(object)transform)) { Transform val = ((Component)Owner).transform; transform.position = val.position; transform.rotation = val.rotation; } } public void CleanupSelf() { Object.Destroy((Object)(object)((Component)this).gameObject); } } public class SyncToTransform : MonoBehaviour { public Transform Target; private Transform transform; private Vector3 _originalLocalPosition; private Quaternion _originalLocalRotation; private bool _isAnimated; private Vector3 _localPositionLastFrame; private Quaternion _localRotationLastFrame; private bool _isResetting; private float _resetDuration; private float _resetTimer; public void ResetToOriginalTransform(float tweenTime) { if (tweenTime <= 0f) { Object.Destroy((Object)(object)this); } _isResetting = true; _resetDuration = tweenTime; _resetTimer = 0f; } private void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //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_003b: Unknown result type (might be due to invalid IL or missing references) transform = ((Component)this).transform; _localPositionLastFrame = (_originalLocalPosition = transform.localPosition); _localRotationLastFrame = (_originalLocalRotation = transform.localRotation); } private void LateUpdate() { //IL_0022: 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_003a: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Target)) { if (_isResetting) { Object.Destroy((Object)(object)this); } return; } if (transform.localPosition != _localPositionLastFrame || transform.localRotation != _localRotationLastFrame) { _isAnimated = true; } else { _isAnimated = false; } if (_isResetting) { float num = _resetTimer / _resetDuration; Vector3 val; Quaternion val2; if (_isAnimated) { val = transform.position; val2 = transform.rotation; } else { val = transform.TransformPoint(_originalLocalPosition); Transform parent = transform.parent; val2 = (Object.op_Implicit((Object)(object)parent) ? parent.rotation : Quaternion.identity) * _originalLocalRotation; } transform.position = Vector3.Lerp(Target.position, val, num); transform.rotation = Quaternion.Lerp(Target.rotation, val2, num); if (num >= 1f) { Object.Destroy((Object)(object)this); } } else { transform.position = Target.position; transform.rotation = Target.rotation; } } private void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (_isResetting) { _resetTimer += Time.deltaTime; } _localPositionLastFrame = transform.localPosition; _localRotationLastFrame = transform.localRotation; } private void OnDestroy() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)transform)) { transform.localPosition = _originalLocalPosition; transform.localRotation = _originalLocalRotation; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }