Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of VarianceAPI v2.3.1
plugins/VarianceAPI.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DebugToolkit; using EntityStates; using EntityStates.Gup; using HG; using HG.Coroutines; using HG.Reflection; using IL.EntityStates.Gup; using KinematicCharacterController; using MSU; using MSU.Config; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using On.RoR2.UI; using R2API; using R2API.AddressReferencedAssets; using R2API.ScriptableObjects; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RoR2; using RoR2.CharacterAI; using RoR2.ConVar; using RoR2.ContentManagement; using RoR2.ExpansionManagement; using RoR2.Skills; using RoR2.UI; using RoR2BepInExPack.GameAssetPaths.Version_1_39_0; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.Serialization; using UnityEngine.UI; using VAPI.Components; using VAPI.Modules; using VAPI.RuleSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: InternalsVisibleTo("VarianceAPI.Editor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace EntityStates { public class EmptyState : BaseState { public override void FixedUpdate() { ((EntityState)this).FixedUpdate(); ((EntityState)this).outer.SetNextStateToMain(); } } } namespace VAPI { internal static class Commands { [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCvapi_ListBodies(ConCommandArgs args) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); list.Add("Modified Bodies:"); list.Add("----------------"); foreach (BodyVariantDefProvider instance in BodyVariantDefProvider.instances) { GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(instance.tiedIndex); list.Add($"{((Object)bodyPrefab).name} (VariantDef count: {instance.totalVariantCount})"); } Debug.Log((object)string.Join("\n", list)); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCvapi_ListVariants(ConCommandArgs args) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0036: 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 (((ConCommandArgs)(ref args)).Count == 0) { Debug.Log((object)"No arguments given."); return; } BodyIndex bodyFromPartial = StringFinder.Instance.GetBodyFromPartial(((ConCommandArgs)(ref args))[0]); if ((int)bodyFromPartial == -1) { Debug.Log((object)"No body could be found with that name. To get a list of bodies that have variants, use \"vapi_list_bodies\"."); return; } BodyVariantDefProvider bodyVariantDefProvider = BodyVariantDefProvider.FindProvider(bodyFromPartial); if (bodyVariantDefProvider == null) { Debug.Log((object)"The body provided does not have a BodyVariantDefProvider. To get a list of bodies that have variants, use \"vapi_list_bodies\"."); return; } List<string> list = new List<string>(); list.Add($"{bodyFromPartial}'s Variants"); list.Add("-----------------------"); for (int i = 0; i < bodyVariantDefProvider.totalVariantCount; i++) { VariantDef variantDef = bodyVariantDefProvider.GetVariantDef(i); list.Add($"{i} - {((Object)variantDef).name}"); } Debug.Log((object)string.Join("\n", list)); } [ConCommand(/*Could not decode attribute arguments.*/)] public static void SpawnVariant(ConCommandArgs args) { //IL_0000: 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_0040: 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_0058: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)args.sender == (Object)null) { Debug.Log((object)"Sender does not exist"); return; } if (((ConCommandArgs)(ref args)).Count == 0) { Debug.Log((object)"No Arguments Given."); return; } MasterIndex aiFromPartial = StringFinder.Instance.GetAiFromPartial(((ConCommandArgs)(ref args))[0]); if (aiFromPartial == MasterIndex.none) { Debug.Log((object)"Could not find master."); return; } GameObject masterPrefab = MasterCatalog.GetMasterPrefab(aiFromPartial); string[] array = Array.Empty<string>(); for (int i = 1; i < ((ConCommandArgs)(ref args)).Count; i++) { string text = ((ConCommandArgs)(ref args))[i]; ArrayUtils.ArrayAppend<string>(ref array, ref text); } List<VariantDef> list = new List<VariantDef>(); VariantDef[] allVariants = BodyVariantDefProvider.FindProvider(aiFromPartial).GetAllVariants(filtered: false); string[] array2 = array; foreach (string text2 in array2) { foreach (VariantDef variantDef in allVariants) { if (((Object)variantDef).name.ToLowerInvariant().Contains(text2.ToLowerInvariant())) { list.Add(variantDef); break; } } } Vector3 position = args.sender.master.GetBody().transform.position; VariantSummon variantSummon = new VariantSummon(); variantSummon.variantDefs = list.ToArray(); ((MasterSummon)variantSummon).ignoreTeamMemberLimit = true; ((MasterSummon)variantSummon).useAmbientLevel = false; ((MasterSummon)variantSummon).masterPrefab = masterPrefab; ((MasterSummon)variantSummon).position = position; ((MasterSummon)variantSummon).rotation = Quaternion.identity; ((MasterSummon)variantSummon).summonerBodyObject = null; ((MasterSummon)variantSummon).teamIndexOverride = masterPrefab.GetComponent<CharacterMaster>().teamIndex; variantSummon.PerformSummon(); List<string> list2 = new List<string>(); list2.Add("Spawned a " + ((Object)masterPrefab).name + " with the following VariantDefs"); for (int l = 0; l < list.Count; l++) { list2.Add($"{l} - {((Object)list[l]).name}"); } Debug.Log((object)string.Join("\n", list2)); } [ConCommand(/*Could not decode attribute arguments.*/)] public static void SpawnAsVariant(ConCommandArgs args) { //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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 //IL_0036: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_0168: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) if (((ConCommandArgs)(ref args)).Count == 0) { Debug.Log((object)"No Arguments Given"); return; } BodyIndex bodyFromPartial = StringFinder.Instance.GetBodyFromPartial(((ConCommandArgs)(ref args))[0]); if ((int)bodyFromPartial == -1) { Debug.Log((object)"No body could be found with that name"); return; } GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(bodyFromPartial); if ((Object)(object)args.sender == (Object)null) { Debug.Log((object)"Sender does not exist"); return; } CharacterMaster senderMaster = ((ConCommandArgs)(ref args)).senderMaster; if (!Object.op_Implicit((Object)(object)senderMaster.GetBody())) { Debug.Log((object)"Master has no body"); return; } string[] array = Array.Empty<string>(); for (int i = 1; i < ((ConCommandArgs)(ref args)).Count; i++) { string text = ((ConCommandArgs)(ref args))[i]; ArrayUtils.ArrayAppend<string>(ref array, ref text); } List<VariantDef> list = new List<VariantDef>(); VariantDef[] allVariants = BodyVariantDefProvider.FindProvider(bodyFromPartial).GetAllVariants(filtered: false); string[] array2 = array; foreach (string text2 in array2) { foreach (VariantDef variantDef in allVariants) { if (((Object)variantDef).name.ToLowerInvariant().Contains(text2.ToLowerInvariant())) { list.Add(variantDef); break; } } } senderMaster.bodyPrefab = bodyPrefab; List<string> list2 = new List<string>(); list2.Add($"{args.sender.userName} is spawning as {bodyFromPartial} with the following VariantDefs:"); BoolConVar val = (BoolConVar)Reflection.GetFieldCached(typeof(Stage), "stage1PodConVar").GetValue(null); bool value = val.value; val.SetBool(false); CharacterBody val2 = senderMaster.Respawn(senderMaster.GetBody().footPosition, senderMaster.GetBody().transform.rotation, false); if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.AddComponent<DoNotTurnIntoVariant>(); BodyVariantManager component = ((Component)val2).GetComponent<BodyVariantManager>(); BodyVariantReward component2 = ((Component)val2).GetComponent<BodyVariantReward>(); if (Object.op_Implicit((Object)(object)component)) { component.AddVariants(list); } if (Object.op_Implicit((Object)(object)component2)) { component2.AddVariants(list); } } for (int l = 0; l < list.Count; l++) { list2.Add($"{l} - {((Object)list[l]).name}"); } Debug.Log((object)string.Join("\n", list2)); val.SetBool(value); } } public enum VariantIndex { None = -1 } public enum VariantTierIndex { None = -1, Common, Uncommon, Rare, Legendary, AssignedAtRuntime } public enum VariantPackIndex { None = -1 } public enum ComponentAttachmentType { Body, Master, Model } public enum OverrideNameType { Prefix, Suffix, Complete } [Flags] public enum BasicAIModifier { Default = 0, Unstable = 1, ForceSprint = 2 } public enum MeshType { Default, Beetle, BeetleGuard, MiniMushrum, MagmaWorm, OverloadingWorm } public class VariantDefIndexComparer : IEqualityComparer<VariantDef> { public bool Equals(VariantDef x, VariantDef y) { VariantIndex num = (Object.op_Implicit((Object)(object)x) ? x.variantIndex : VariantIndex.None); VariantIndex variantIndex = (Object.op_Implicit((Object)(object)y) ? y.variantIndex : VariantIndex.None); return num == variantIndex; } public int GetHashCode(VariantDef obj) { if (!Object.op_Implicit((Object)(object)obj)) { return -1; } return obj.variantIndex.GetHashCode(); } } public static class GupVariantHelper { private static List<VariantDef> _blacklistedVariants = new List<VariantDef>(); private static Dictionary<VariantDef, VariantDef> _gupToGeep = new Dictionary<VariantDef, VariantDef>(new VariantDefIndexComparer()); private static Dictionary<VariantDef, VariantDef> _geepToGip = new Dictionary<VariantDef, VariantDef>(new VariantDefIndexComparer()); public static void AddToBlacklist(VariantDef variantToBlacklist) { _blacklistedVariants.Add(variantToBlacklist); } public static void AddGupProgression(VariantDef gupVariant, VariantDef geepVariant, VariantDef gipVariant) { ((ResourceAvailability)(ref VariantCatalog.availability)).CallWhenAvailable((Action)delegate { _gupToGeep.Add(gupVariant, geepVariant); _geepToGip.Add(geepVariant, gipVariant); }); } internal static void HandleDeathState(ILContext context) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00c1: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown ILCursor val = new ILCursor(context); if (!val.TryGotoNext(new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchDup(x), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<BaseSplitDeath>(x, "moneyMultiplier"), (Instruction x) => ILPatternMatchingExt.MatchStfld<BodySplitter>(x, "moneyMultiplier") })) { VAPILog.Fatal("Failed to reach specific destination for handling Gup's death states!", 45, "HandleDeathState"); BaseSplitDeath.FixedUpdate -= new Manipulator(HandleDeathState); } else { val.Emit(OpCodes.Dup); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<BodySplitter, BaseSplitDeath>>((Action<BodySplitter, BaseSplitDeath>)HandleDeath); } static void HandleDeath(BodySplitter splitter, BaseSplitDeath baseSplitDeath) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)((EntityState)baseSplitDeath).characterBody)) { MasterSummon masterSummon = splitter.masterSummon; VariantSummon variantSummon = (VariantSummon)(object)(splitter.masterSummon = (MasterSummon)(object)new VariantSummon { masterPrefab = masterSummon.masterPrefab, ignoreTeamMemberLimit = false, useAmbientLevel = null, teamIndexOverride = null }); BodyVariantManager bodyVariantManager = default(BodyVariantManager); if (((Component)((EntityState)baseSplitDeath).characterBody).TryGetComponent<BodyVariantManager>(ref bodyVariantManager)) { variantSummon.variantDefs = FilterVariants(bodyVariantManager.variantsInBody, splitter.masterSummon.masterPrefab, ((EntityState)baseSplitDeath).characterBody.bodyIndex); } } } } private static VariantDef[] FilterVariants(ReadOnlyCollection<VariantDef> variantDefs, GameObject masterSummonPrefb, BodyIndex dyingBodyIndex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) List<VariantDef> list = new List<VariantDef>(); BodyIndex val = (BodyIndex)(-1); CharacterMaster val2 = default(CharacterMaster); CharacterBody val3 = default(CharacterBody); if (masterSummonPrefb.TryGetComponent<CharacterMaster>(ref val2) && val2.bodyPrefab.TryGetComponent<CharacterBody>(ref val3)) { val = val3.bodyIndex; } foreach (VariantDef variantDef in variantDefs) { if (!_blacklistedVariants.Contains(variantDef)) { VariantDef value; if (val == dyingBodyIndex) { list.Add(variantDef); } else if (_gupToGeep.TryGetValue(variantDef, out value)) { list.Add(value); } else if (_geepToGip.TryGetValue(variantDef, out value)) { list.Add(value); } } } return list.ToArray(); } } public static class VAPIAssets { private const string ASSET_BUNDLE_NAME = "vapiassets"; private const string ASSET_BUNDLE_FOLDER_NAME = "assetbundles"; public static ResourceAvailability assetsAvailability; internal static SkillDef _emptySkillDef; private static AssetBundle _assetBundle; private static string assetBundleFolderPath => Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)VAPIMain.instance).Info.Location), "assetbundles"); public static TAsset LoadAsset<TAsset>(string name) where TAsset : Object { return _assetBundle.LoadAsset<TAsset>(name); } public static VAPIAssetRequest<TAsset> LoadAssetAsync<TAsset>(string name) where TAsset : Object { return new VAPIAssetRequest<TAsset>(_assetBundle.LoadAssetAsync(name)); } public static TAsset[] LoadAssets<TAsset>() where TAsset : Object { return _assetBundle.LoadAllAssets<TAsset>(); } public static VAPIAssetRequest<TAsset> LoadAssetsAsync<TAsset>() where TAsset : Object { return new VAPIAssetRequest<TAsset>(_assetBundle.LoadAllAssetsAsync<TAsset>()); } internal static IEnumerator Initialize() { if (!((ResourceAvailability)(ref assetsAvailability)).available) { VAPILog.Info("Initializing Assets...", 50, "Initialize"); IEnumerator loadRoutine = LoadAssetBundle(); while (!MSUtil.IsDone(loadRoutine)) { yield return null; } ParallelCoroutine coroutine = new ParallelCoroutine(); coroutine.Add(SwapShaders()); coroutine.Add(SwapAddressableShaders()); while (!coroutine.isDone) { yield return null; } ((ResourceAvailability)(ref assetsAvailability)).MakeAvailable(); } } private static IEnumerator LoadAssetBundle() { AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(Path.Combine(assetBundleFolderPath, "vapiassets")); while (!((AsyncOperation)request).isDone) { yield return null; } _assetBundle = request.assetBundle; } private static IEnumerator SwapShaders() { return ShaderUtil.SwapStubbedShadersAsync(_assetBundle); } private static IEnumerator SwapAddressableShaders() { return ShaderUtil.LoadAddressableMaterialShadersAsync(_assetBundle); } } public class VAPIAssetRequest<TAsset> : IEnumerator where TAsset : Object { private AssetBundleRequest _request; public TAsset asset => (TAsset)(object)_request.asset; public TAsset[] assets => _request.allAssets.OfType<TAsset>().ToArray(); public bool isDone => ((AsyncOperation)_request).isDone; public float progress => ((AsyncOperation)_request).progress; object IEnumerator.Current => _request.asset; internal VAPIAssetRequest(AssetBundleRequest request) { _request = request; } bool IEnumerator.MoveNext() { return !((AsyncOperation)_request).isDone; } void IEnumerator.Reset() { throw new NotSupportedException(); } } public class VAPIConfig { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static OnConfigChangedDelegate<bool> <>9__26_0; public static OnConfigChangedDelegate<bool> <>9__26_1; public static IsDisabledDelegate <>9__26_2; public static IsDisabledDelegate <>9__26_3; public static IsDisabledDelegate <>9__26_4; internal void <SetConfigs>b__26_0(bool b) { RuleDef varianceArtifactRuleDef = RuleBookExtras._varianceArtifactRuleDef; varianceArtifactRuleDef.FindChoice("On").excludeByDefault = !b; varianceArtifactRuleDef.FindChoice("Off").excludeByDefault = !b; InfiniteTower.AddOrRemoveWave(b); if (Object.op_Implicit((Object)(object)PreGameController.instance) && NetworkServer.active) { PreGameController.instance.RecalculateModifierAvailability(); } } internal void <SetConfigs>b__26_1(bool b) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (b) { BaseSplitDeath.FixedUpdate -= new Manipulator(GupVariantHelper.HandleDeathState); BaseSplitDeath.FixedUpdate += new Manipulator(GupVariantHelper.HandleDeathState); } else { BaseSplitDeath.FixedUpdate -= new Manipulator(GupVariantHelper.HandleDeathState); } } internal bool <SetConfigs>b__26_2() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)_enableRewards); } internal bool <SetConfigs>b__26_3() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)_enableRewards); } internal bool <SetConfigs>b__26_4() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)_enableRewards); } } public const string PREFIX = "VAPI."; public const string GENERAL = "VAPI.General"; public const string REWARDS = "VAPI.Rewards"; [AutoConfig] internal static ConfiguredBool _showVariantRuleCategory; [AutoConfig] internal static ConfiguredBool _enableArtifactOfVariance; [AutoConfig] internal static ConfiguredBool _activateMeshReplacementSystem; [AutoConfig] internal static ConfiguredBool _sendArrivalMesssages; [AutoConfig] internal static ConfiguredBool _modifyGupDeathStates; [AutoConfig] internal static ConfiguredColor _variantHealthBarColor; [AutoConfig] internal static ConfiguredBool _enableRewards; [AutoConfig] internal static ConfiguredBool _luckAffectsItemRewards; [AutoConfig] internal static ConfiguredBool _itemRewardsSpawnOnPlayer; [AutoConfig] internal static ConfiguredFloat _hiddenRealmsItemRollChance; internal static ConfigFactory configFactory { get; private set; } public static ConfigFile generalConfig { get; private set; } public static ConfigFile rewardsConfig { get; private set; } internal VAPIConfig(BaseUnityPlugin plugin) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown configFactory = new ConfigFactory(plugin); generalConfig = configFactory.CreateConfigFile("VAPI.General", false); rewardsConfig = configFactory.CreateConfigFile("VAPI.Rewards", false); SetConfigs(); } private void SetConfigs() { //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_0011: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //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_0048: 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_005e: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c9: Expected O, but got Unknown //IL_00ca: 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_00da: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0101: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_01f4: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_025b: Expected O, but got Unknown //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Expected O, but got Unknown //IL_02bd: Expected O, but got Unknown //IL_02c2: Expected O, but got Unknown //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_034a: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Expected O, but got Unknown _showVariantRuleCategory = new ConfiguredBool(false) { section = "General", key = "Show Variant Rule Category", description = "Uncovers the Variant rule category, allowing you to enable or disable variant spawning from the lobby.", configFile = generalConfig }; _enableArtifactOfVariance = new ConfiguredBool(true) { section = "General", key = "Enable Artifact of Variance", description = "Wether the artifact of Variance is enabled", configFile = generalConfig }.WithConfigChange((OnConfigChangedDelegate<bool>)delegate(bool b) { RuleDef varianceArtifactRuleDef = RuleBookExtras._varianceArtifactRuleDef; varianceArtifactRuleDef.FindChoice("On").excludeByDefault = !b; varianceArtifactRuleDef.FindChoice("Off").excludeByDefault = !b; InfiniteTower.AddOrRemoveWave(b); if (Object.op_Implicit((Object)(object)PreGameController.instance) && NetworkServer.active) { PreGameController.instance.RecalculateModifierAvailability(); } }); _activateMeshReplacementSystem = new ConfiguredBool(true) { section = "General", key = "Activate Mesh Replacecment Systems", description = "Activates the Mesh Replacement System, allowing for some Variants to have different meshes.\nExtremely jank, may not work at all, and could tank performance.", configFile = generalConfig }; _sendArrivalMesssages = new ConfiguredBool(true) { section = "General", key = "Send Arrival Messages", description = "Wether variants which tier's send messages on arrival send said messages.", configFile = generalConfig }; _modifyGupDeathStates = new ConfiguredBool(true) { section = "General", key = "Modify Gup/Geep Death States", description = "Modifies the Death state of Gup and Geep so that the split enemies retain some variant logic. For example, A Variant gup will spleet into Geeps that only have the parent's variant defs. And a variant geep will not spawn from a normal gup.", configFile = generalConfig }.WithConfigChange((OnConfigChangedDelegate<bool>)delegate(bool b) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (b) { BaseSplitDeath.FixedUpdate -= new Manipulator(GupVariantHelper.HandleDeathState); BaseSplitDeath.FixedUpdate += new Manipulator(GupVariantHelper.HandleDeathState); } else { BaseSplitDeath.FixedUpdate -= new Manipulator(GupVariantHelper.HandleDeathState); } }); _variantHealthBarColor = new ConfiguredColor(Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)144, byte.MaxValue))) { section = "General", key = "Variant Healthbar Color", description = "The Healthbar Colour for Variants", configFile = generalConfig }; _enableRewards = new ConfiguredBool(true) { section = "Rewards", key = "Activate Rewards Systems", description = "Activates the Rewards Systems, when enabled, variants drop extra gold and experiencee, alongside a chance for an item.", configFile = rewardsConfig, checkBoxConfig = new CheckBoxConfig { restartRequired = true } }; ConfiguredBool val = new ConfiguredBool(false) { section = "Rewards", key = "Luck affects item rewards", description = "If true, the Luck stat will influence the chance for an Item Reward", configFile = rewardsConfig }; CheckBoxConfig val2 = new CheckBoxConfig(); object obj = <>c.<>9__26_2; if (obj == null) { IsDisabledDelegate val3 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)_enableRewards); <>c.<>9__26_2 = val3; obj = (object)val3; } ((BaseOptionConfig)val2).checkIfDisabled = (IsDisabledDelegate)obj; val.checkBoxConfig = val2; _luckAffectsItemRewards = val; ConfiguredBool val4 = new ConfiguredBool(false) { section = "Rewards", key = "Item Rewards Spawn on Player", description = "Setting this to true makes item rewards spawn on the player that dealt the killing blow to a variant, instead of the variant's position.", configFile = rewardsConfig }; CheckBoxConfig val5 = new CheckBoxConfig(); object obj2 = <>c.<>9__26_3; if (obj2 == null) { IsDisabledDelegate val6 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)_enableRewards); <>c.<>9__26_3 = val6; obj2 = (object)val6; } ((BaseOptionConfig)val5).checkIfDisabled = (IsDisabledDelegate)obj2; val4.checkBoxConfig = val5; _itemRewardsSpawnOnPlayer = val4; ConfiguredFloat val7 = new ConfiguredFloat(100f) { section = "Rewards", key = "Chance for ItemDrops in Hidden Realms", description = "The chance for an Item drop in a hidden realm, this check must pass before the variant even has a chance to drop an item.\nSet this to 0 for no item drops in hidden realms.", configFile = rewardsConfig, sliderType = (SliderTypeEnum)1 }; SliderConfig val8 = new SliderConfig(); object obj3 = <>c.<>9__26_4; if (obj3 == null) { IsDisabledDelegate val9 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)_enableRewards); <>c.<>9__26_4 = val9; obj3 = (object)val9; } ((BaseOptionConfig)val8).checkIfDisabled = (IsDisabledDelegate)obj3; val8.min = 0f; val8.max = 100f; val7.sliderConfig = val8; _hiddenRealmsItemRollChance = val7; } } public class VAPIContent : IContentPackProvider { public static class VariantTiers { public static VariantTierDef Common => Load("Common"); public static VariantTierDef Uncommon => Load("Uncommon"); public static VariantTierDef Rare => Load("Rare"); public static VariantTierDef Legendary => Load("Legendary"); private static VariantTierDef Load(string name) { if (!((ResourceAvailability)(ref VAPIAssets.assetsAvailability)).available) { throw new InvalidOperationException("Cannot load tier " + name + " without VAPIAssets initialized."); } return VAPIAssets.LoadAsset<VariantTierDef>(name); } } public static class Artifacts { public static ArtifactDef Variance; } public static class Buffs { public static BuffDef bdVariant; } public static class Items { public static ItemDef ExtraPrimary; public static ItemDef ExtraSecondary; public static ItemDef ExtraSpecial; public static ItemDef ExtraUtility; public static ItemDef GlobalCDR; public static ItemDef GreenHealthbar; public static ItemDef Plus1Crit; public static ItemDef PrimaryCDR; public static ItemDef SecondaryCDR; public static ItemDef SpecialCDR; public static ItemDef UtilityCDR; } internal static ParallelCoroutine _parallelPreLoadDispatchers; private static Func<IEnumerator>[] _loadDispatchers; internal static ParallelCoroutine _parallelPostLoadDispatchers; private static Action[] _fieldAssignDispatchers; public string identifier => "com.Nebby.VAPI"; public static ReadOnlyContentPack readOnlyContentPack => new ReadOnlyContentPack(contentPack); internal static ContentPack contentPack { get; } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { IEnumerator enumerator2 = VAPIAssets.Initialize(); while (!MSUtil.IsDone(enumerator2)) { yield return null; } while (!MSUtil.IsDone((IEnumerator)_parallelPreLoadDispatchers)) { yield return null; } for (int i = 0; i < _loadDispatchers.Length; i++) { args.ReportProgress(Util.Remap((float)(i + 1), 0f, (float)_loadDispatchers.Length, 0.1f, 0.2f)); enumerator2 = _loadDispatchers[i](); while (enumerator2?.MoveNext() ?? false) { yield return null; } } while (!MSUtil.IsDone((IEnumerator)_parallelPostLoadDispatchers)) { yield return null; } for (int j = 0; j < _fieldAssignDispatchers.Length; j++) { args.ReportProgress(Util.Remap((float)(j + 1), 0f, (float)_fieldAssignDispatchers.Length, 0.95f, 0.99f)); _fieldAssignDispatchers[j](); } } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield return null; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } private static IEnumerator AddBaseVariantPack() { VAPILog.Info("Adding base VariantPack", 78, "AddBaseVariantPack"); VAPIAssetRequest<VariantPackDef> request = VAPIAssets.LoadAssetAsync<VariantPackDef>("BaseVariantPack"); while (!request.isDone) { yield return null; } VariantPackCatalog.AddVariantPack(request.asset, VAPIConfig.rewardsConfig); } private static void LoadFromAssetBundles() { _parallelPreLoadDispatchers.Add(PopulateWithAssetCollectionContentPack()); _parallelPostLoadDispatchers.Add(LoadEmptySkillDef()); _parallelPostLoadDispatchers.Add(LoadLockedIconAndAssignToExpansionDef()); static IEnumerator LoadEmptySkillDef() { VAPIAssetRequest<SkillDef> request2 = VAPIAssets.LoadAssetAsync<SkillDef>("EmptySkillDef"); while (!request2.isDone) { yield return null; } VAPIAssets._emptySkillDef = request2.asset; } static IEnumerator LoadLockedIconAndAssignToExpansionDef() { VAPIAssetRequest<ExpansionDef> request = VAPIAssets.LoadAssetAsync<ExpansionDef>("VarianceExpansion"); AsyncOperationHandle<Sprite> iconRequest = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common_MiscIcons.texUnlockIcon_png); ParallelCoroutine coroutine = new ParallelCoroutine(); coroutine.Add((IEnumerator)request); coroutine.Add((IEnumerator)(object)iconRequest); while (!MSUtil.IsDone((IEnumerator)coroutine)) { yield return null; } request.asset.disabledIconSprite = iconRequest.Result; } static IEnumerator PopulateWithAssetCollectionContentPack() { VAPIAssetRequest<AssetCollection> request3 = VAPIAssets.LoadAssetAsync<AssetCollection>("acContentPack"); while (!request3.isDone) { yield return null; } ContentUtil.AddContentFromAssetCollection(contentPack, request3.asset); } } private void AddSelf(AddContentPackProviderDelegate addContentPackProviderDelegate) { addContentPackProviderDelegate.Invoke((IContentPackProvider)(object)this); } internal VAPIContent() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddSelf); ((ResourceAvailability)(ref VAPIAssets.assetsAvailability)).CallWhenAvailable((Action)delegate { _parallelPreLoadDispatchers.Add(LanguageFileLoader.AddLanguageFilesFromModAsync((BaseUnityPlugin)(object)VAPIMain.instance, "languages")); LoadFromAssetBundles(); }); } static VAPIContent() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown contentPack = new ContentPack(); _parallelPreLoadDispatchers = new ParallelCoroutine(); _parallelPostLoadDispatchers = new ParallelCoroutine(); VAPIMain main = VAPIMain.instance; _loadDispatchers = new Func<IEnumerator>[4] { delegate { VAPILog.Info("Initializing Items...", 150, ".cctor"); ItemModule.AddProvider((BaseUnityPlugin)(object)main, ContentUtil.CreateGenericContentPieceProvider<ItemDef>((BaseUnityPlugin)(object)main, contentPack)); return ItemModule.InitializeItems((BaseUnityPlugin)(object)main); }, delegate { VAPILog.Info("Initializing Artifacts...", 156, ".cctor"); ArtifactModule.AddProvider((BaseUnityPlugin)(object)main, ContentUtil.CreateGenericContentPieceProvider<ArtifactDef>((BaseUnityPlugin)(object)main, contentPack)); return ArtifactModule.InitializeArtifacts((BaseUnityPlugin)(object)main); }, AddBaseVariantPack, InfiniteTower.Init }; _fieldAssignDispatchers = new Action[3] { delegate { ContentUtil.PopulateTypeFields<ArtifactDef>(typeof(Artifacts), contentPack.artifactDefs); }, delegate { ContentUtil.PopulateTypeFields<BuffDef>(typeof(Buffs), contentPack.buffDefs); }, delegate { ContentUtil.PopulateTypeFields<ItemDef>(typeof(Items), contentPack.itemDefs); } }; } } internal class VAPILog { private static ManualLogSource logger; public static void Fatal(object data, [CallerLineNumber] int i = 0, [CallerMemberName] string member = "") { Log((LogLevel)1, data, i, member); } public static void Error(object data, [CallerLineNumber] int i = 0, [CallerMemberName] string member = "") { Log((LogLevel)2, data, i, member); } public static void Warning(object data, [CallerLineNumber] int i = 0, [CallerMemberName] string member = "") { Log((LogLevel)4, data, i, member); } public static void Message(object data, [CallerLineNumber] int i = 0, [CallerMemberName] string member = "") { Log((LogLevel)8, data, i, member); } public static void Info(object data, [CallerLineNumber] int i = 0, [CallerMemberName] string member = "") { Log((LogLevel)16, data, i, member); } public static void Debug(object data, [CallerLineNumber] int i = 0, [CallerMemberName] string member = "") { Log((LogLevel)32, data, i, member); } private static void Log(LogLevel level, object data, int i, string member) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) LogRuntime(level, data, i, member); } private static void LogEditor(LogLevel level, object data, int i, string member) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0004: 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_0008: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if ((int)level <= 4) { if (level - 1 > 1) { if ((int)level == 4) { Debug.LogWarning((object)Format(data, i, member)); } } else { Debug.LogError((object)Format(data, i, member)); } } else if ((int)level == 8 || (int)level == 16 || (int)level == 32) { Debug.Log((object)Format(data, i, member)); } } private static void LogRuntime(LogLevel level, object data, int i, string member) { //IL_0000: 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_004a: 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) object obj = ((((Enum)level).HasFlag((Enum)(object)(LogLevel)4) || ((Enum)level).HasFlag((Enum)(object)(LogLevel)2) || ((Enum)level).HasFlag((Enum)(object)(LogLevel)1)) ? Format(data, i, member) : data); logger.Log(level, obj); } public static string Format(object data, int i, string member) { return $"{data} | Line={i} : Member={member}"; } internal VAPILog(ManualLogSource logger_) { logger = logger_; } } public class BodyVariantDefProvider { internal static List<BodyVariantDefProvider> instances = new List<BodyVariantDefProvider>(); private VariantDef[] variantsForBody = Array.Empty<VariantDef>(); private VariantDef[] filteredUniques = Array.Empty<VariantDef>(); private VariantDef[] filteredNonUniques = Array.Empty<VariantDef>(); public BodyIndex tiedIndex { get; internal set; } public int totalVariantCount => variantsForBody.Length; [SystemInitializer(new Type[] { })] private static void SystemInitializer() { Stage.onStageStartGlobal += delegate { OnStageStartGlobal(SceneInfo.instance, Run.instance); }; } public static void FilterVariants(SceneInfo sceneInfo, Run run) { OnStageStartGlobal(sceneInfo, run); } private static void OnStageStartGlobal(SceneInfo info, Run run) { //IL_0069: 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_009f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)info) || !Object.op_Implicit((Object)(object)run)) { VAPILog.Error("A Stage (" + Stage.instance.sceneDef.baseSceneNameOverride + ") has started, but there is no Run And/Or SceneInfo instances! Variants will not be filtered." + $"\n(Run: {run}, SceneInfo: {info}", 39, "OnStageStartGlobal"); return; } StageInfo stageInfo = StageInfo.ParseInternalStageName(info.sceneDef.baseSceneName); ExpansionDef[] runExpansions = ExpansionCatalog._expansionDefs.Where((ExpansionDef ed) => run.IsExpansionEnabled(ed)).ToArray(); foreach (BodyVariantDefProvider instance in instances) { instance.FilterVariants(stageInfo, runExpansions, run.ruleBook); } } public static BodyVariantDefProvider FindProvider(string masterOrCharacterName) { //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_0008: 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_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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0021: Unknown result type (might be due to invalid IL or missing references) MasterIndex val = MasterCatalog.FindMasterIndex(masterOrCharacterName); if (val == MasterIndex.none) { BodyIndex val2 = BodyCatalog.FindBodyIndex(masterOrCharacterName); if ((int)val2 == -1) { return null; } return FindProvider(val2); } return FindProvider(val); } public static BodyVariantDefProvider FindProvider(GameObject prefab) { CharacterMaster component = prefab.GetComponent<CharacterMaster>(); CharacterBody component2 = prefab.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { return FindProvider(component); } if (!Object.op_Implicit((Object)(object)component2)) { return null; } return FindProvider(component2); } public static BodyVariantDefProvider FindProvider(MasterIndex masterIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return FindProvider(MasterCatalog.GetMasterPrefab(masterIndex).GetComponent<CharacterMaster>()); } public static BodyVariantDefProvider FindProvider(CharacterMaster master) { if (master.hasBody) { return FindProvider(master.bodyInstanceObject.GetComponent<CharacterBody>()); } if (!Object.op_Implicit((Object)(object)master.bodyPrefab)) { return null; } return FindProvider(master.bodyPrefab.GetComponent<CharacterBody>()); } public static BodyVariantDefProvider FindProvider(CharacterBody body) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) VariantCatalog.ThrowIfNotInitialized(); return VariantCatalog.GetBodyVariantDefProvider(body.bodyIndex); } public static BodyVariantDefProvider FindProvider(BodyIndex index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) VariantCatalog.ThrowIfNotInitialized(); return VariantCatalog.GetBodyVariantDefProvider(index); } private void FilterVariants(StageInfo stageInfo, ExpansionDef[] runExpansions, RuleBook runRulebook) { //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_00b0: Unknown result type (might be due to invalid IL or missing references) try { filteredUniques = (from vd in variantsForBody where vd.isUnique where vd.IsAvailable(stageInfo, runExpansions, runRulebook) select vd).ToArray(); filteredNonUniques = (from vd in variantsForBody where !vd.isUnique where vd.IsAvailable(stageInfo, runExpansions, runRulebook) select vd).ToArray(); } catch (Exception arg) { VAPILog.Error($"Could not filter variants for body {BodyCatalog.GetBodyName(tiedIndex)}: {arg}", 155, "FilterVariants"); } } public VariantDef[] GetUniqueVariants(bool filtered) { if (!filtered) { return variantsForBody.Where((VariantDef vd) => vd.isUnique).ToArray(); } return filteredUniques; } public VariantDef[] GetVariants(bool filtered) { if (!filtered) { return variantsForBody.Where((VariantDef vd) => !vd.isUnique).ToArray(); } return filteredNonUniques; } public VariantDef[] GetAllVariants(bool filtered) { if (!filtered) { return variantsForBody; } return filteredUniques.Concat(filteredNonUniques).ToArray(); } public string GetBodyName() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(tiedIndex); if (!Object.op_Implicit((Object)(object)bodyPrefab)) { return null; } return ((Object)bodyPrefab).name; } public VariantDef GetVariantDef(int index) { return ArrayUtils.GetSafe<VariantDef>(variantsForBody, index); } public BodyVariantDefProvider(VariantDef[] variantsForBody, BodyIndex tiedIndex) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) this.variantsForBody = variantsForBody; this.tiedIndex = tiedIndex; instances.Add(this); } } public static class VariantCatalog { public static ResourceAvailability availability = default(ResourceAvailability); internal static VariantDef[] _registeredVariants = Array.Empty<VariantDef>(); private static readonly Dictionary<string, VariantIndex> _nameToIndex = new Dictionary<string, VariantIndex>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<BodyIndex, BodyVariantDefProvider> _bodyIndexToDefProvider = new Dictionary<BodyIndex, BodyVariantDefProvider>(); public static int variantCount => _registeredVariants.Length; public static VariantDef GetVariantDef(VariantIndex variantIndex) { ThrowIfNotInitialized(); return ArrayUtils.GetSafe<VariantDef>(_registeredVariants, (int)variantIndex); } public static VariantIndex FindVariantIndex(string variantName) { ThrowIfNotInitialized(); if (_nameToIndex.TryGetValue(variantName, out var value)) { return value; } return VariantIndex.None; } internal static BodyVariantDefProvider GetBodyVariantDefProvider(BodyIndex index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (_bodyIndexToDefProvider.TryGetValue(index, out var value)) { return value; } return null; } [SystemInitializer(new Type[] { typeof(BodyCatalog), typeof(VariantTierCatalog) })] private static void SystemInitializer() { _nameToIndex.Clear(); _registeredVariants = RegisterVariantsFromPacks(VariantPackCatalog._registeredPacks).ToArray(); PopulateBodyIndexToVariants(); VAPILog.Info("Variant Catalog Initialized", 77, "SystemInitializer"); ((ResourceAvailability)(ref availability)).MakeAvailable(); } private static VariantDef[] RegisterVariantsFromPacks(VariantPackDef[] packs) { VAPILog.Info($"Registering VariantDefs from {VariantPackCatalog.variantPackCount} VariantPacks", 83, "RegisterVariantsFromPacks"); List<VariantDef> list = new List<VariantDef>(); foreach (VariantPackDef obj in packs) { ConfigFile variantConfiguration = obj.variantConfiguration; BepInPlugin bepInPlugin = obj.bepInPlugin; VariantDef[] variants = obj.variants; if (variants.Length != 0) { variants = variants.Where(ValidateVariant).ToArray(); if (variantConfiguration != null) { ConfigureVariantsThatPassedFilter(variantConfiguration, bepInPlugin, variants); } list.AddRange(variants); } } list = list.OrderBy((VariantDef vd) => vd.bodyName + "." + ((Object)vd).name).ToList(); int num = list.ToArray().Length; for (VariantIndex variantIndex = (VariantIndex)0; (int)variantIndex < num; variantIndex++) { RegisterVariant(list[(int)variantIndex], variantIndex); } return list.ToArray(); } private static bool ValidateVariant(VariantDef variant) { try { if (string.IsNullOrEmpty(((Object)variant).name) || string.IsNullOrWhiteSpace(((Object)variant).name)) { VAPILog.Error($"Variant {variant} has no object name!", 122, "ValidateVariant"); return false; } if (!BodyCatalog.bodyNames.Contains(variant.bodyName)) { return false; } return true; } catch (Exception arg) { VAPILog.Error($"Could not validate variant {variant}: {arg}", 137, "ValidateVariant"); return false; } } private static void ConfigureVariantsThatPassedFilter(ConfigFile configFile, BepInPlugin plugin, IEnumerable<VariantDef> variants) { //IL_002f: 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_004f: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b0: 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_00b6: 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_00d1: Expected O, but got Unknown //IL_00d6: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_015e: 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_0171: Unknown result type (might be due to invalid IL or missing references) foreach (VariantDef variant in variants) { try { variant._spawnRateConfig = new ConfiguredFloat(variant.spawnRate) { section = variant.bodyName + " Variants", key = ((Object)variant).name + " Spawn Rate", description = "Chance for the " + ((Object)variant).name + " variant to spawn\n(Percentage, 0-100)", configFile = configFile, modGUID = plugin.GUID, modName = plugin.Name, sliderType = (SliderTypeEnum)1, sliderConfig = new SliderConfig { min = 0f, max = 100f } }; ((ConfiguredVariable<float>)(object)variant._spawnRateConfig).onConfigChanged += delegate(float f) { variant.spawnRate = f; }; variant._isUniqueConfig = new ConfiguredBool(variant.isUnique) { section = variant.bodyName + " Variants", key = ((Object)variant).name + " Uniqueness", description = "Wether or not " + ((Object)variant).name + " is Unique", configFile = configFile, modGUID = plugin.GUID, modName = plugin.Name }.WithConfigChange((OnConfigChangedDelegate<bool>)delegate(bool b) { variant.isUnique = b; }).DoConfigure(); } catch (Exception ex) { VAPILog.Error($"Error Configuring Variant {variant}: {ex}\n(ConfigFile: {configFile}, Variant: {variant})", 178, "ConfigureVariantsThatPassedFilter"); } } } private static void RegisterVariant(VariantDef variant, VariantIndex index) { try { variant.variantIndex = index; _nameToIndex.Add(((Object)variant).name, index); _ = variant.variantTierDef; } catch (Exception arg) { VAPILog.Error($"Could not register variant {variant}: {arg}", 196, "RegisterVariant"); } } private static void PopulateBodyIndexToVariants() { //IL_008f: 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) VAPILog.Info("Creating BodyVariantDefProviders for registered variants", 202, "PopulateBodyIndexToVariants"); foreach (CharacterBody body in BodyCatalog.allBodyPrefabBodyBodyComponents) { VariantDef[] array = _registeredVariants.Where((VariantDef vd) => vd.bodyName.Equals(((Object)body).name, StringComparison.OrdinalIgnoreCase)).ToArray(); if (array.Length != 0) { ((Component)body).gameObject.AddComponent<BodyVariantManager>(); if (ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards)) { ((Component)body).gameObject.AddComponent<BodyVariantReward>(); } _bodyIndexToDefProvider.Add(body.bodyIndex, new BodyVariantDefProvider(array, body.bodyIndex)); } } } internal static void ThrowIfNotInitialized() { if (!((ResourceAvailability)(ref availability)).available) { throw new InvalidOperationException("VariantCatalog not initialized"); } } } public static class VariantPackCatalog { private readonly struct ConfigPair { public readonly ConfigFile tierConfig; public readonly ConfigFile variantConfig; public ConfigPair(ConfigFile configFile) { variantConfig = configFile; tierConfig = configFile; } public ConfigPair(ConfigFile tierFile, ConfigFile variantFile) { tierConfig = tierFile; variantConfig = variantFile; } public override bool Equals(object obj) { if (obj is ConfigPair other) { return Equals(other); } return false; } public bool Equals(ConfigPair other) { if (tierConfig == other.tierConfig) { return variantConfig == other.variantConfig; } return false; } public override int GetHashCode() { return base.GetHashCode(); } public static bool operator ==(ConfigPair lhs, ConfigPair rhs) { return lhs.Equals(rhs); } public static bool operator !=(ConfigPair lhs, ConfigPair rhs) { return !(lhs == rhs); } } public static ResourceAvailability availability = default(ResourceAvailability); private static Dictionary<ConfigPair, List<(VariantPackDef, BepInPlugin)>> _unregisteredPacks = new Dictionary<ConfigPair, List<(VariantPackDef, BepInPlugin)>>(); internal static VariantPackDef[] _registeredPacks = Array.Empty<VariantPackDef>(); private static readonly Dictionary<string, VariantPackIndex> nameToIndex = new Dictionary<string, VariantPackIndex>(StringComparer.OrdinalIgnoreCase); public static int variantPackCount => _registeredPacks.Length; public static VariantPackDef GetVariantPackDef(VariantPackIndex variantPackIndex) { ThrowIfNotInitialized(); return ArrayUtils.GetSafe<VariantPackDef>(_registeredPacks, (int)variantPackIndex); } public static VariantPackIndex FindVariantPackIndex(string packName) { ThrowIfNotInitialized(); if (nameToIndex.TryGetValue(packName, out var value)) { return value; } return VariantPackIndex.None; } public static VariantPackDef FindVariantPackDef(VariantDef variant) { ThrowIfNotInitialized(); VariantPackDef[] registeredPacks = _registeredPacks; foreach (VariantPackDef variantPackDef in registeredPacks) { if (variantPackDef.variants.Contains(variant)) { return variantPackDef; } } return null; } public static VariantPackDef FindVariantPackDef(VariantTierDef variantTier) { ThrowIfNotInitialized(); VariantPackDef[] registeredPacks = _registeredPacks; foreach (VariantPackDef variantPackDef in registeredPacks) { if (variantPackDef.variantTiers.Contains(variantTier)) { return variantPackDef; } } return null; } public static void AddVariantPacks(AssetBundle assetBundle) { ThrowIfInitialized(); ConfigPair configPair = default(ConfigPair); BepInPlugin bepInPlugin = GetBepInPlugin(Assembly.GetCallingAssembly()); VariantPackDef[] array = assetBundle.LoadAllAssets<VariantPackDef>(); for (int i = 0; i < array.Length; i++) { AddPackInternal(array[i], configPair, bepInPlugin); } } public static void AddVariantPacks(AssetBundle assetBundle, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); ConfigPair configPair = default(ConfigPair); BepInPlugin metadata = ownerPlugin.Info.Metadata; VariantPackDef[] array = assetBundle.LoadAllAssets<VariantPackDef>(); for (int i = 0; i < array.Length; i++) { AddPackInternal(array[i], configPair, metadata); } } public static void AddVariantPacks(AssetBundle assetBundle, ConfigFile configFile) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(configFile); BepInPlugin bepInPlugin = GetBepInPlugin(Assembly.GetCallingAssembly()); VariantPackDef[] array = assetBundle.LoadAllAssets<VariantPackDef>(); for (int i = 0; i < array.Length; i++) { AddPackInternal(array[i], configPair, bepInPlugin); } } public static void AddVariantPacks(AssetBundle assetBundle, ConfigFile configFile, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(configFile); BepInPlugin metadata = ownerPlugin.Info.Metadata; VariantPackDef[] array = assetBundle.LoadAllAssets<VariantPackDef>(); for (int i = 0; i < array.Length; i++) { AddPackInternal(array[i], configPair, metadata); } } public static void AddVariantPacks(AssetBundle assetBundle, ConfigFile tierConfig, ConfigFile variantConfig) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(tierConfig, variantConfig); BepInPlugin bepInPlugin = GetBepInPlugin(Assembly.GetCallingAssembly()); VariantPackDef[] array = assetBundle.LoadAllAssets<VariantPackDef>(); for (int i = 0; i < array.Length; i++) { AddPackInternal(array[i], configPair, bepInPlugin); } } public static void AddVariantPacks(AssetBundle assetBundle, ConfigFile tierConfig, ConfigFile variantConfig, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(tierConfig, variantConfig); BepInPlugin metadata = ownerPlugin.Info.Metadata; VariantPackDef[] array = assetBundle.LoadAllAssets<VariantPackDef>(); for (int i = 0; i < array.Length; i++) { AddPackInternal(array[i], configPair, metadata); } } public static void AddVariantPacks(IEnumerable<VariantPackDef> variantPacks) { ThrowIfInitialized(); BepInPlugin bepInPlugin = GetBepInPlugin(Assembly.GetCallingAssembly()); foreach (VariantPackDef variantPack in variantPacks) { AddPackInternal(variantPack, default(ConfigPair), bepInPlugin); } } public static void AddVariantPacks(IEnumerable<VariantPackDef> variantPacks, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); BepInPlugin metadata = ownerPlugin.Info.Metadata; foreach (VariantPackDef variantPack in variantPacks) { AddPackInternal(variantPack, default(ConfigPair), metadata); } } public static void AddVariantPacks(IEnumerable<VariantPackDef> variantPacks, ConfigFile configFile) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(configFile); BepInPlugin bepInPlugin = GetBepInPlugin(Assembly.GetCallingAssembly()); foreach (VariantPackDef variantPack in variantPacks) { AddPackInternal(variantPack, configPair, bepInPlugin); } } public static void AddVariantPacks(IEnumerable<VariantPackDef> variantPacks, ConfigFile configFile, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(configFile); BepInPlugin metadata = ownerPlugin.Info.Metadata; foreach (VariantPackDef variantPack in variantPacks) { AddPackInternal(variantPack, configPair, metadata); } } public static void AddVariantPacks(IEnumerable<VariantPackDef> variantPacks, ConfigFile tierConfig, ConfigFile variantConfig) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(tierConfig, variantConfig); BepInPlugin bepInPlugin = GetBepInPlugin(Assembly.GetCallingAssembly()); foreach (VariantPackDef variantPack in variantPacks) { AddPackInternal(variantPack, configPair, bepInPlugin); } } public static void AddVariantPacks(IEnumerable<VariantPackDef> variantPacks, ConfigFile tierConfig, ConfigFile variantConfig, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); ConfigPair configPair = new ConfigPair(tierConfig, variantConfig); BepInPlugin metadata = ownerPlugin.Info.Metadata; foreach (VariantPackDef variantPack in variantPacks) { AddPackInternal(variantPack, configPair, metadata); } } public static void AddVariantPack(VariantPackDef packDef) { ThrowIfInitialized(); AddPackInternal(packDef, default(ConfigPair), GetBepInPlugin(Assembly.GetCallingAssembly())); } public static void AddVariantPack(VariantPackDef packDef, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); AddPackInternal(packDef, default(ConfigPair), ownerPlugin.Info.Metadata); } public static void AddVariantPack(VariantPackDef packDef, ConfigFile configFile) { ThrowIfInitialized(); AddPackInternal(packDef, new ConfigPair(configFile), GetBepInPlugin(Assembly.GetCallingAssembly())); } public static void AddVariantPack(VariantPackDef packDef, ConfigFile configFile, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); AddPackInternal(packDef, new ConfigPair(configFile), ownerPlugin.Info.Metadata); } public static void AddVariantPack(VariantPackDef packDef, ConfigFile tierConfig, ConfigFile variantConfig) { ThrowIfInitialized(); AddPackInternal(packDef, new ConfigPair(tierConfig, variantConfig), GetBepInPlugin(Assembly.GetCallingAssembly())); } public static void AddVariantPack(VariantPackDef packDef, ConfigFile tierConfig, ConfigFile variantConfig, BaseUnityPlugin ownerPlugin) { ThrowIfInitialized(); AddPackInternal(packDef, new ConfigPair(tierConfig, variantConfig), ownerPlugin.Info.Metadata); } private static BepInPlugin GetBepInPlugin(Assembly assembly) { Type[] source = default(Type[]); Reflection.GetTypesSafe(assembly, ref source); return (from t in source where ((MemberInfo)t).GetCustomAttribute<BepInPlugin>() != null select ((MemberInfo)t).GetCustomAttribute<BepInPlugin>()).FirstOrDefault(); } private static void AddPackInternal(VariantPackDef packDef, ConfigPair configPair, BepInPlugin plugin) { if (!_unregisteredPacks.ContainsKey(configPair)) { _unregisteredPacks[configPair] = new List<(VariantPackDef, BepInPlugin)>(); } _unregisteredPacks[configPair].Add((packDef, plugin)); } [SystemInitializer(new Type[] { })] private static void SystemInit() { nameToIndex.Clear(); _registeredPacks = RegisterPacks(); _unregisteredPacks = null; VAPILog.Info("VariantPack Catalog Initialized", 423, "SystemInit"); ((ResourceAvailability)(ref availability)).MakeAvailable(); } private static VariantPackDef[] RegisterPacks() { List<(VariantPackDef, ConfigPair, BepInPlugin)> list = new List<(VariantPackDef, ConfigPair, BepInPlugin)>(); foreach (KeyValuePair<ConfigPair, List<(VariantPackDef, BepInPlugin)>> unregisteredPack in _unregisteredPacks) { unregisteredPack.Deconstruct(out var key, out var value); ConfigPair configPair = key; List<(VariantPackDef, BepInPlugin)> source = value; List<(VariantPackDef, BepInPlugin)> list2 = new List<(VariantPackDef, BepInPlugin)>(); list2 = source.Where(ValidatePack).ToList(); list.AddRange(list2.Select(((VariantPackDef, BepInPlugin) x) => (x.Item1, configPair, x.Item2))); } list = list.OrderBy(((VariantPackDef, ConfigPair, BepInPlugin) vpd) => ((Object)vpd.Item1).name).ToList(); int num = list.ToArray().Length; for (VariantPackIndex variantPackIndex = (VariantPackIndex)0; (int)variantPackIndex < num; variantPackIndex++) { RegisterPack(list[(int)variantPackIndex], variantPackIndex); } return list.Select(((VariantPackDef, ConfigPair, BepInPlugin) x) => x.Item1).ToArray(); } private static bool ValidatePack((VariantPackDef packDef, BepInPlugin plugin) tuple) { try { return true; } catch (Exception arg) { VAPILog.Error($"Could not validate pack {tuple.packDef}: {arg}", 460, "ValidatePack"); return false; } } private static void RegisterPack((VariantPackDef packDef, ConfigPair pair, BepInPlugin plugin) variantPack, VariantPackIndex index) { try { VariantPackDef item = variantPack.packDef; item.tierConfiguration = variantPack.pair.tierConfig; item.variantConfiguration = variantPack.pair.variantConfig; item.bepInPlugin = variantPack.plugin; ModSettingsManager.SetModIcon(item.packEnabledIcon, item.bepInPlugin.GUID, item.bepInPlugin.Name); ModSettingsManager.SetModDescriptionToken(item.descriptionToken, item.bepInPlugin.GUID, item.bepInPlugin.Name); item.variantPackIndex = index; nameToIndex.Add(((Object)item).name, index); } catch (Exception arg) { VAPILog.Error($"Could not register pack {variantPack}: {arg}", 483, "RegisterPack"); } } private static void ThrowIfNotInitialized() { if (!((ResourceAvailability)(ref availability)).available) { throw new InvalidOperationException("VariantPackCatalog not initialized"); } } private static void ThrowIfInitialized() { if (((ResourceAvailability)(ref availability)).available) { throw new InvalidOperationException("VariantPackCatalog already initialized"); } } } public static class VariantTierCatalog { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<VariantTierDef, string> <>9__8_0; public static IsDisabledDelegate <>9__10_6; public static IsDisabledDelegate <>9__10_7; public static IsDisabledDelegate <>9__10_8; public static IsDisabledDelegate <>9__10_9; public static IsDisabledDelegate <>9__10_10; internal string <RegisterTiersFromPacks>b__8_0(VariantTierDef vtd) { return ((Object)vtd).name; } internal bool <ConfigureTiersThatPassedFilter>b__10_6() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); } internal bool <ConfigureTiersThatPassedFilter>b__10_7() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); } internal bool <ConfigureTiersThatPassedFilter>b__10_8() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); } internal bool <ConfigureTiersThatPassedFilter>b__10_9() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); } internal bool <ConfigureTiersThatPassedFilter>b__10_10() { return !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); } } public static ResourceAvailability availability = default(ResourceAvailability); private static VariantTierDef[] _registeredTiers; private static readonly Dictionary<VariantTierIndex, VariantTierDef> _tierToDef = new Dictionary<VariantTierIndex, VariantTierDef>(); public static int variantTierCount => _registeredTiers.Length; public static VariantTierDef GetVariantTierDef(VariantTierIndex variantTier) { ThrowIfNotInitialized(); if (_tierToDef.TryGetValue(variantTier, out var value)) { return value; } return null; } public static VariantTierDef FindVariantTierDef(string tierName) { ThrowIfNotInitialized(); VariantTierDef[] registeredTiers = _registeredTiers; foreach (VariantTierDef variantTierDef in registeredTiers) { if (((Object)variantTierDef).name == tierName) { return variantTierDef; } } return null; } [SystemInitializer(new Type[] { typeof(VariantPackCatalog) })] private static void SystemInit() { _tierToDef.Clear(); _registeredTiers = RegisterTiersFromPacks(VariantPackCatalog._registeredPacks); VAPILog.Info("VariantTierCatalog Initialized", 71, "SystemInit"); ((ResourceAvailability)(ref availability)).MakeAvailable(); } private static VariantTierDef[] RegisterTiersFromPacks(VariantPackDef[] packs) { VAPILog.Info($"Registering VariantTierDefs from {VariantPackCatalog.variantPackCount} VariantPacks.", 77, "RegisterTiersFromPacks"); List<VariantTierDef> list = new List<VariantTierDef>(); foreach (VariantPackDef obj in packs) { ConfigFile tierConfiguration = obj.tierConfiguration; BepInPlugin bepInPlugin = obj.bepInPlugin; VariantTierDef[] variantTiers = obj.variantTiers; if (variantTiers.Length != 0) { variantTiers = variantTiers.Where(ValidateTier).ToArray(); if (tierConfiguration != null) { ConfigureTiersThatPassedFilter(tierConfiguration, bepInPlugin, variantTiers); } list.AddRange(variantTiers); } } list = list.OrderBy((VariantTierDef vtd) => ((Object)vtd).name).ToList(); int num = 0; foreach (VariantTierDef item in list) { if (item.tier == VariantTierIndex.AssignedAtRuntime) { item.tier = (VariantTierIndex)(++num + 10); } if (_tierToDef.ContainsKey(item.tier)) { VAPILog.Error($"Duplicate TierDef for tier {item.tier}", 110, "RegisterTiersFromPacks"); } else { _tierToDef.Add(item.tier, item); } } return list.ToArray(); } private static bool ValidateTier(VariantTierDef tierDef) { try { return true; } catch (Exception arg) { VAPILog.Error($"Could not validate tier {tierDef}: {arg}", 128, "ValidateTier"); return false; } } private static void ConfigureTiersThatPassedFilter(ConfigFile configFile, BepInPlugin plugin, IEnumerable<VariantTierDef> tierDefs) { //IL_002f: 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_004f: 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_0065: 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_0078: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_010d: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) //IL_00d2: Expected O, but got Unknown //IL_01ba: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_0247: 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_024d: 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) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_028d: Expected O, but got Unknown //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown //IL_0360: Expected O, but got Unknown //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Expected O, but got Unknown //IL_0433: Expected O, but got Unknown //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Expected O, but got Unknown //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Expected O, but got Unknown foreach (VariantTierDef tierDef in tierDefs) { try { VariantTierDef variantTierDef = tierDef; ConfiguredFloat val = new ConfiguredFloat(tierDef.goldMultiplier) { section = ((Object)tierDef).name + " Tier", key = "Gold Multiplier", description = "The Gold Multiplier for this tier", configFile = configFile, modName = plugin.Name, modGUID = plugin.GUID, sliderType = (SliderTypeEnum)1 }; SliderConfig val2 = new SliderConfig { FormatString = "{0:0.0}", min = 0f, max = 100f }; object obj = <>c.<>9__10_6; if (obj == null) { IsDisabledDelegate val3 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); <>c.<>9__10_6 = val3; obj = (object)val3; } ((BaseOptionConfig)val2).checkIfDisabled = (IsDisabledDelegate)obj; val.sliderConfig = val2; variantTierDef.goldMultiplier = ConfiguredVariable<float>.op_Implicit((ConfiguredVariable<float>)(object)val.WithConfigChange((OnConfigChangedDelegate<float>)delegate(float f) { tierDef.goldMultiplier = f; }).DoConfigure()); VariantTierDef variantTierDef2 = tierDef; ConfiguredFloat val4 = new ConfiguredFloat(tierDef.experienceMultiplier) { section = ((Object)tierDef).name + " Tier", key = "Experience Multiplier", description = "The Experience Multiplier for this tier", configFile = configFile, modName = plugin.Name, modGUID = plugin.GUID, sliderType = (SliderTypeEnum)1 }; SliderConfig val5 = new SliderConfig { FormatString = "{0:0.0}", min = 0f, max = 100f }; object obj2 = <>c.<>9__10_7; if (obj2 == null) { IsDisabledDelegate val6 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); <>c.<>9__10_7 = val6; obj2 = (object)val6; } ((BaseOptionConfig)val5).checkIfDisabled = (IsDisabledDelegate)obj2; val4.sliderConfig = val5; variantTierDef2.experienceMultiplier = ConfiguredVariable<float>.op_Implicit((ConfiguredVariable<float>)(object)val4.WithConfigChange((OnConfigChangedDelegate<float>)delegate(float f) { tierDef.experienceMultiplier = f; }).DoConfigure()); VariantTierDef variantTierDef3 = tierDef; ConfiguredFloat val7 = new ConfiguredFloat(tierDef.whiteItemDropChance) { section = ((Object)tierDef).name + " Tier", key = "White Item Drop Chance", description = "The Chance for variants of this tier to drop a White Item", configFile = configFile, modName = plugin.Name, modGUID = plugin.GUID, sliderType = (SliderTypeEnum)1 }; SliderConfig val8 = new SliderConfig { min = 0f, max = 100f }; object obj3 = <>c.<>9__10_8; if (obj3 == null) { IsDisabledDelegate val9 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); <>c.<>9__10_8 = val9; obj3 = (object)val9; } ((BaseOptionConfig)val8).checkIfDisabled = (IsDisabledDelegate)obj3; val7.sliderConfig = val8; variantTierDef3.whiteItemDropChance = ConfiguredVariable<float>.op_Implicit((ConfiguredVariable<float>)(object)val7.WithConfigChange((OnConfigChangedDelegate<float>)delegate(float f) { tierDef.whiteItemDropChance = f; }).DoConfigure()); VariantTierDef variantTierDef4 = tierDef; ConfiguredFloat val10 = new ConfiguredFloat(tierDef.greenItemDropChance) { section = ((Object)tierDef).name + " Tier", key = "Green Item Drop Chance", description = "The Chance for variants of this tier to drop a Green Item", configFile = configFile, modName = plugin.Name, modGUID = plugin.GUID, sliderType = (SliderTypeEnum)1 }; SliderConfig val11 = new SliderConfig { min = 0f, max = 100f }; object obj4 = <>c.<>9__10_9; if (obj4 == null) { IsDisabledDelegate val12 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); <>c.<>9__10_9 = val12; obj4 = (object)val12; } ((BaseOptionConfig)val11).checkIfDisabled = (IsDisabledDelegate)obj4; val10.sliderConfig = val11; variantTierDef4.greenItemDropChance = ConfiguredVariable<float>.op_Implicit((ConfiguredVariable<float>)(object)val10.WithConfigChange((OnConfigChangedDelegate<float>)delegate(float f) { tierDef.greenItemDropChance = f; }).DoConfigure()); VariantTierDef variantTierDef5 = tierDef; ConfiguredFloat val13 = new ConfiguredFloat(tierDef.redItemDropChance) { section = ((Object)tierDef).name + " Tier", key = "Red Item Drop Chance", description = "The Chance for variants of this tier to drop a Red Item", configFile = configFile, modName = plugin.Name, modGUID = plugin.GUID, sliderType = (SliderTypeEnum)1 }; SliderConfig val14 = new SliderConfig { min = 0f, max = 100f }; object obj5 = <>c.<>9__10_10; if (obj5 == null) { IsDisabledDelegate val15 = () => !ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._enableRewards); <>c.<>9__10_10 = val15; obj5 = (object)val15; } ((BaseOptionConfig)val14).checkIfDisabled = (IsDisabledDelegate)obj5; val13.sliderConfig = val14; variantTierDef5.redItemDropChance = ConfiguredVariable<float>.op_Implicit((ConfiguredVariable<float>)(object)val13.WithConfigChange((OnConfigChangedDelegate<float>)delegate(float f) { tierDef.redItemDropChance = f; }).DoConfigure()); tierDef.armorBonus = ConfiguredVariable<float>.op_Implicit((ConfiguredVariable<float>)(object)new ConfiguredFloat(tierDef.armorBonus) { section = ((Object)tierDef).name + " Tier", key = "Tier Armor Bonus", description = "Armor bonus applied to variants with this tier, this value stacks if the variant has multiple VariantDefs applied.", configFile = configFile, modName = plugin.Name, modGUID = plugin.GUID, sliderType = (SliderTypeEnum)1, sliderConfig = new SliderConfig { min = 0f, max = 100f } }.WithConfigChange((OnConfigChangedDelegate<float>)delegate(float f) { tierDef.armorBonus = f; }).DoConfigure()); } catch (Exception ex) { VAPILog.Error($"Error configuring tier {tierDef}: {ex}\n(ConfigFile: {configFile}, Tier: {tierDef}", 262, "ConfigureTiersThatPassedFilter"); } } } private static void ThrowIfNotInitialized() { if (!((ResourceAvailability)(ref availability)).available) { throw new InvalidOperationException("VariantCatalog not initialized"); } } } public class VariantDirectorSpawnRequest : DirectorSpawnRequest { public VariantDef[] variantDefs = Array.Empty<VariantDef>(); public bool applyOnStart; public DeathRewards deathRewardsBase; public float deathRewardsCoefficient; public bool supressRewards; public VariantDirectorSpawnRequest(SpawnCard spawnCard, DirectorPlacementRule placementRule, Xoroshiro128Plus rng) : base(spawnCard, placementRule, rng) { } [SystemInitializer(new Type[] { })] private static void SystemInit() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown DirectorCore.TrySpawnObject += new hook_TrySpawnObject(HandleCustomRequest); } private static GameObject HandleCustomRequest(orig_TrySpawnObject orig, DirectorCore self, DirectorSpawnRequest directorSpawnRequest) { GameObject val = orig.Invoke(self, directorSpawnRequest); try { if (directorSpawnRequest is VariantDirectorSpawnRequest variantDirectorSpawnRequest && Object.op_Implicit((Object)(object)val)) { GameObject bodyInstanceObject = val.GetComponent<CharacterMaster>().bodyInstanceObject; if (Object.op_Implicit((Object)(object)bodyInstanceObject)) { DeathRewards component = bodyInstanceObject.GetComponent<DeathRewards>(); if (Object.op_Implicit((Object)(object)variantDirectorSpawnRequest.deathRewardsBase) && Object.op_Implicit((Object)(object)component) && !variantDirectorSpawnRequest.supressRewards) { component.expReward = (uint)((float)variantDirectorSpawnRequest.deathRewardsBase.expReward * variantDirectorSpawnRequest.deathRewardsCoefficient); component.goldReward = (uint)((float)variantDirectorSpawnRequest.deathRewardsBase.goldReward * variantDirectorSpawnRequest.deathRewardsCoefficient); } bodyInstanceObject.AddComponent<DoNotTurnIntoVariant>(); BodyVariantManager component2 = bodyInstanceObject.GetComponent<BodyVariantManager>(); BodyVariantReward component3 = bodyInstanceObject.GetComponent<BodyVariantReward>(); if (Object.op_Implicit((Object)(object)component2) && NetworkServer.active) { component2.AddVariants(variantDirectorSpawnRequest.variantDefs); component2.applyOnStart = variantDirectorSpawnRequest.applyOnStart; } if (Object.op_Implicit((Object)(object)component3)) { if (variantDirectorSpawnRequest.supressRewards) { component3.AddVariants(variantDirectorSpawnRequest.variantDefs); } component3.applyOnStart = variantDirectorSpawnRequest.applyOnStart; } } } } catch (Exception arg) { VAPILog.Error($"Exception on DirectorCore.TrySpawnObject hook for VariantDirectorSpawnRequest: {arg}", 90, "HandleCustomRequest"); } return val; } } public class VariantRewardInfo { public float goldMultiplier; public float experienceMultiplier; public float whiteChance; public float greenChance; public float redChance; protected List<PickupIndex> whiteItems; protected List<PickupIndex> greenItems; protected List<PickupIndex> redItems; protected int nextRedItem; protected int nextGreenItem; protected int nextWhiteItem; public virtual void SetIndicesAndNextItems(Run runInstance) { whiteItems = Run.instance.availableTier1DropList; greenItems = Run.instance.availableTier2DropList; redItems = Run.instance.availableTier3DropList; nextWhiteItem = Run.instance.treasureRng.RangeInt(0, whiteItems.Count); nextGreenItem = Run.instance.treasureRng.RangeInt(0, greenItems.Count); nextRedItem = Run.instance.treasureRng.RangeInt(0, redItems.Count); } public virtual void SetFromAverageOfTiers(IEnumerable<VariantTierDef> tiers, Run runInstance) { List<VariantTierDef> list = tiers.ToList(); if (list.Count == 0) { goldMultiplier = 1f; experienceMultiplier = 1f; whiteChance = 0f; greenChance = 0f; redChance = 0f; return; } goldMultiplier = 0f; experienceMultiplier = 0f; whiteChance = 0f; greenChance = 0f; redChance = 0f; if (list.Count == 1) { VariantTierDef variantTierDef = list.FirstOrDefault(); goldMultiplier = variantTierDef.goldMultiplier; experienceMultiplier = variantTierDef.experienceMultiplier; whiteChance = variantTierDef.whiteItemDropChance; greenChance = variantTierDef.greenItemDropChance; redChance = variantTierDef.redItemDropChance; } else { goldMultiplier = 1f; experienceMultiplier = 1f; whiteChance = 0f; greenChance = 0f; redChance = 0f; foreach (VariantTierDef item in list) { goldMultiplier += item.goldMultiplierMinus1; experienceMultiplier += item.experienceMultiplierMinus1; whiteChance += item.whiteItemDropChance; greenChance += item.greenItemDropChance; redChance += item.redItemDropChance; } int count = list.Count; whiteChance /= count; greenChance /= count; redChance /= count; } SetIndicesAndNextItems(runInstance); } public virtual void TrySpawnDroplet(DamageReport damageReport, CharacterMaster master = null) { //IL_0049: 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_00d6: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { VAPILog.Warning("TrySpawnDroplet called on client.", 123, "TrySpawnDroplet"); } else if (Util.CheckRoll(redChance, Object.op_Implicit((Object)(object)master) ? master.luck : 0f, (CharacterMaster)null)) { CreateDroplet(redItems[nextRedItem], damageReport); } else if (Util.CheckRoll(redChance + greenChance, Object.op_Implicit((Object)(object)master) ? master.luck : 0f, (CharacterMaster)null)) { CreateDroplet(greenItems[nextGreenItem], damageReport); } else if (Util.CheckRoll(redChance + greenChance + whiteChance, Object.op_Implicit((Object)(object)master) ? master.luck : 0f, (CharacterMaster)null)) { CreateDroplet(whiteItems[nextWhiteItem], damageReport); } } protected virtual void CreateDroplet(PickupIndex dropletIndex, DamageReport report) { //IL_0000: 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_0018: 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_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_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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) PickupDropletController.CreatePickupDroplet(dropletIndex, ConfiguredVariable<bool>.op_Implicit((ConfiguredVariable<bool>)(object)VAPIConfig._itemRewardsSpawnOnPlayer) ? report.attacker.transform.position : ((Component)report.victim).transform.position, Vector3.up * 20f + (Vector3.right * (float)Random.Range(1, 5) + Vector3.forward * (float)Random.Range(1, 5))); } public VariantRewardInfo(float goldMultiplier, float experienceMultiplier, float whiteChance, float greenChance, float redChance) { this.goldMultiplier = goldMultiplier; this.experienceMultiplier = experienceMultiplier; this.whiteChance = whiteChance; this.greenChance = greenChance; this.redChance = redChance; } public VariantRewardInfo() { } } public class VariantSummon : MasterSummon { public struct VariantSummonReport { public CharacterMaster summonMasterInstance; public VariantDef[] summonInstanceVariants; public CharacterMaster leaderMasterInstance; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Perform <>9__15_0; internal CharacterMaster <SystemInit>b__15_0(orig_Perform orig, MasterSummon self) { CharacterMaster val = orig.Invoke(self); if (self is VariantSummon variantSummon) { variantSummon.ModifySpawnedInstance(val);