using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CookBook; using HG; using Microsoft.CodeAnalysis; using R2API.Networking; using R2API.Networking.Interfaces; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2BepInExPack.GameAssetPathsBetter; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RandomRecipes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a458f03d09eef4bd40f79287eaaaea62efc6feb8")] [assembly: AssemblyProduct("RandomRecipes")] [assembly: AssemblyTitle("RandomRecipes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RandomRecipes { public class Assets { public static AssetBundle assetBundle; public static void Init() { GetAssetBundle(); } private static void GetAssetBundle() { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RandomRecipes.mwmwrandomrecipes"); if (stream != null) { assetBundle = AssetBundle.LoadFromStream(stream); } } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } public static class Networking { public static int holdNumRandomCraftables = 0; public static List holdRandomRecipeTypes = new List(); public static List holdIngredient1s = new List(); public static List holdIngredient2s = new List(); public static List holdResults = new List(); } public class SyncSendRecipes : INetMessage, ISerializableObject { private List randomRecipeTypeList; private List ingredient1List; private List ingredient2List; private List resultList; public SyncSendRecipes() { } public SyncSendRecipes(List randomRecipeTypeList, List ingredient1List, List ingredient2List, List resultList) { this.randomRecipeTypeList = randomRecipeTypeList; this.ingredient1List = ingredient1List; this.ingredient2List = ingredient2List; this.resultList = resultList; } public void Serialize(NetworkWriter writer) { writer.Write(randomRecipeTypeList.Count); for (int i = 0; i < randomRecipeTypeList.Count; i++) { writer.Write(randomRecipeTypeList[i]); writer.Write(ingredient1List[i]); writer.Write(ingredient2List[i]); writer.Write(resultList[i]); } } public void Deserialize(NetworkReader reader) { int num = reader.ReadInt32(); randomRecipeTypeList = new List(); ingredient1List = new List(); ingredient2List = new List(); resultList = new List(); for (int i = 0; i < num; i++) { randomRecipeTypeList.Add(reader.ReadInt32()); ingredient1List.Add(reader.ReadInt32()); ingredient2List.Add(reader.ReadInt32()); resultList.Add(reader.ReadInt32()); } } public void OnReceived() { Log.Info($"Received {randomRecipeTypeList.Count} recipes"); Networking.holdNumRandomCraftables += randomRecipeTypeList.Count; Networking.holdRandomRecipeTypes.AddRange(randomRecipeTypeList); Networking.holdIngredient1s.AddRange(ingredient1List); Networking.holdIngredient2s.AddRange(ingredient2List); Networking.holdResults.AddRange(resultList); } } public class SyncFinishedSendingRecipes : INetMessage, ISerializableObject { public void Serialize(NetworkWriter writer) { } public void Deserialize(NetworkReader reader) { } public void OnReceived() { Log.Info("Finished receiving recipes, attemping to add to catalog"); RandomCraftableManager.ClientRandomizeCraftables(Networking.holdNumRandomCraftables, Networking.holdRandomRecipeTypes, Networking.holdIngredient1s, Networking.holdIngredient2s, Networking.holdResults); Networking.holdNumRandomCraftables = 0; Networking.holdRandomRecipeTypes = new List(); Networking.holdIngredient1s = new List(); Networking.holdIngredient2s = new List(); Networking.holdResults = new List(); } } public class Options { private static bool? _rooEnabled; public static bool rooEnabled { get { if (!_rooEnabled.HasValue) { _rooEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); } return _rooEnabled.Value; } } public static ConfigEntry noRandomRecipes { get; set; } public static ConfigEntry whitesToGreenWeight { get; set; } public static ConfigEntry greensToRedWeight { get; set; } public static ConfigEntry greensToYellowWeight { get; set; } public static ConfigEntry lessersToOrangeWeight { get; set; } public static ConfigEntry greenAndWhiteToGreenWeight { get; set; } public static ConfigEntry greensToGreenWeight { get; set; } public static ConfigEntry scrapAndGreenTo2WhiteWeight { get; set; } public static ConfigEntry scrapAndRedTo4WhiteWeight { get; set; } public static ConfigEntry orangeAndLesserToRedWeight { get; set; } public static ConfigEntry orangeAndLesserToYellowWeight { get; set; } public static ConfigEntry logRecipes { get; set; } private static void OnSettingChanged() { RandomCraftableManager.numRandomCraftables = noRandomRecipes.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.WhitesToGreen] = whitesToGreenWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.GreensToRed] = greensToRedWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.GreensToYellow] = greensToYellowWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.LessersToOrange] = lessersToOrangeWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.GreenAndWhiteToGreen] = greenAndWhiteToGreenWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.GreensToGreen] = greensToGreenWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.ScrapAndGreenTo2White] = scrapAndGreenTo2WhiteWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.ScrapAndRedTo4White] = scrapAndRedTo4WhiteWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.OrangeAndLesserToRed] = orangeAndLesserToRedWeight.Value; RandomCraftableManager.recipeTypeWeights[RandomCraftableManager.RecipeType.OrangeAndLesserToYellow] = orangeAndLesserToYellowWeight.Value; } public static void Init() { noRandomRecipes = RandomRecipes.config.Bind("Recipes", "Number of Recipes", 40, "The number of additional random recipes. Generated at the start of each run."); noRandomRecipes.SettingChanged += delegate { OnSettingChanged(); }; whitesToGreenWeight = RandomRecipes.config.Bind("Recipes", "WhitesToGreen Weight", 5f, "The weighted probability of a random recipe being WhitesToGreen."); whitesToGreenWeight.SettingChanged += delegate { OnSettingChanged(); }; greensToRedWeight = RandomRecipes.config.Bind("Recipes", "GreensToRed Weight", 2f, "The weighted probability of a random recipe being GreensToRed."); greensToRedWeight.SettingChanged += delegate { OnSettingChanged(); }; greensToYellowWeight = RandomRecipes.config.Bind("Recipes", "GreensToYellow Weight", 1f, "The weighted probability of a random recipe being GreensToYellow."); greensToYellowWeight.SettingChanged += delegate { OnSettingChanged(); }; lessersToOrangeWeight = RandomRecipes.config.Bind("Recipes", "LessersToOrange Weight", 1f, "The weighted probability of a random recipe being LessersToOrange."); lessersToOrangeWeight.SettingChanged += delegate { OnSettingChanged(); }; greensToGreenWeight = RandomRecipes.config.Bind("Recipes", "GreensToGreen Weight", 1f, "The weighted probability of a random recipe being GreensToGreen."); greensToGreenWeight.SettingChanged += delegate { OnSettingChanged(); }; greenAndWhiteToGreenWeight = RandomRecipes.config.Bind("Recipes", "GreenAndWhiteToGreen Weight", 1f, "The weighted probability of a random recipe being GreenAndWhiteToGreen."); greenAndWhiteToGreenWeight.SettingChanged += delegate { OnSettingChanged(); }; scrapAndGreenTo2WhiteWeight = RandomRecipes.config.Bind("Recipes", "ScrapAndGreenTo2White Weight", 1.5f, "The weighted probability of a random recipe being ScrapAndGreenTo2White."); scrapAndGreenTo2WhiteWeight.SettingChanged += delegate { OnSettingChanged(); }; scrapAndRedTo4WhiteWeight = RandomRecipes.config.Bind("Recipes", "ScrapAndRedTo4White Weight", 1.2f, "The weighted probability of a random recipe being ScrapAndRedTo4White."); scrapAndRedTo4WhiteWeight.SettingChanged += delegate { OnSettingChanged(); }; orangeAndLesserToRedWeight = RandomRecipes.config.Bind("Recipes", "OrangeAndLesserToRed Weight", 0.8f, "The weighted probability of a random recipe being OrangeAndLesserToRed."); orangeAndLesserToRedWeight.SettingChanged += delegate { OnSettingChanged(); }; orangeAndLesserToYellowWeight = RandomRecipes.config.Bind("Recipes", "OrangeAndLesserToYellow Weight", 0.8f, "The weighted probability of a random recipe being OrangeAndLesserToYellow."); orangeAndLesserToYellowWeight.SettingChanged += delegate { OnSettingChanged(); }; logRecipes = RandomRecipes.config.Bind("Debug", "Log Recipes", false, "Whether or not to output generated recipes to the console."); if (rooEnabled) { RoOInit(); } } public static void OnLoadFinished() { OnSettingChanged(); } private static void RoOInit() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_0166: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(noRandomRecipes, new IntSliderConfig { min = 0, max = 5000 })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(whitesToGreenWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(greensToRedWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(greensToYellowWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(lessersToOrangeWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(greenAndWhiteToGreenWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(greensToGreenWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(scrapAndGreenTo2WhiteWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(scrapAndRedTo4WhiteWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(orangeAndLesserToRedWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(orangeAndLesserToYellowWeight, new StepSliderConfig { min = 0f, max = 10f, increment = 0.1f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(logRecipes, new CheckBoxConfig())); ModSettingsManager.SetModDescription("Config options for RandomRecipes."); ModSettingsManager.SetModIcon(Assets.assetBundle.LoadAsset("icon")); } } public static class RandomCraftableManager { public enum RecipeType { WhitesToGreen, GreensToRed, GreensToYellow, LessersToOrange, GreensToGreen, GreenAndWhiteToGreen, ScrapAndGreenTo2White, ScrapAndRedTo4White, OrangeAndLesserToRed, OrangeAndLesserToYellow } public static Dictionary recipeTypeWeights = new Dictionary { { RecipeType.WhitesToGreen, 5f }, { RecipeType.GreensToRed, 2f }, { RecipeType.GreensToYellow, 1f }, { RecipeType.LessersToOrange, 1f }, { RecipeType.GreensToGreen, 1f }, { RecipeType.GreenAndWhiteToGreen, 1f }, { RecipeType.ScrapAndGreenTo2White, 1.5f }, { RecipeType.ScrapAndRedTo4White, 1.2f }, { RecipeType.OrangeAndLesserToRed, 0.8f }, { RecipeType.OrangeAndLesserToYellow, 0.8f } }; public static CraftableDef[] craftableDefs; public static int numRandomCraftables = 40; public static void RandomizeAndRefresh() { if (NetworkServer.active) { ServerRandomizeCraftables(); } } private static void UpdateCraftableContent() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) ContentManager._craftableDefs = ContentManager._craftableDefs.Concat(craftableDefs).ToArray(); CraftableCatalog.availability = default(ResourceAvailability); CraftableCatalog.pickupToIngredientSearchTable = new Dictionary>(); CraftableCatalog.resultToRecipeSearchTable = new Dictionary>(); Utils.UnpatchedSetCraftableDefs(ContentManager.craftableDefs); Log.Info("Tried to update CraftableCatalog"); if (SoftDeps.cookbookEnabled) { SoftDeps.RefreshCookBook(); } } private static void ServerRandomizeCraftables() { List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); PickupIndex[] array = PickupTransmutationManager.itemTier1Group.Concat(PickupTransmutationManager.itemTier2Group).ToArray(); float num = recipeTypeWeights.Values.Sum(); for (int i = 0; i < numRandomCraftables; i++) { RecipeType recipeType = RecipeType.WhitesToGreen; float num2 = Random.value * num; foreach (KeyValuePair recipeTypeWeight in recipeTypeWeights) { num2 -= recipeTypeWeight.Value; if (num2 <= 0f) { recipeType = recipeTypeWeight.Key; list.Add((int)recipeType); break; } } switch (recipeType) { case RecipeType.WhitesToGreen: list2.Add(PickupTransmutationManager.itemTier1Group.GetRandomIndex()); list3.Add(PickupTransmutationManager.itemTier1Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); break; case RecipeType.GreensToRed: list2.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list3.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier3Group.GetRandomIndex()); break; case RecipeType.GreensToYellow: list2.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list3.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTierBossGroup.GetRandomIndex()); break; case RecipeType.LessersToOrange: list2.Add(array.GetRandomIndex()); list3.Add(array.GetRandomIndex()); list4.Add(PickupTransmutationManager.equipmentNormalGroup.GetRandomIndex()); break; case RecipeType.GreensToGreen: list2.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list3.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); break; case RecipeType.GreenAndWhiteToGreen: list2.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list3.Add(PickupTransmutationManager.itemTier1Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); break; case RecipeType.ScrapAndGreenTo2White: list2.Add(0); list3.Add(PickupTransmutationManager.itemTier2Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier1Group.GetRandomIndex()); break; case RecipeType.ScrapAndRedTo4White: list2.Add(0); list3.Add(PickupTransmutationManager.itemTier3Group.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier1Group.GetRandomIndex()); break; case RecipeType.OrangeAndLesserToRed: list2.Add(PickupTransmutationManager.equipmentNormalGroup.GetRandomIndex()); list3.Add(array.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTier3Group.GetRandomIndex()); break; case RecipeType.OrangeAndLesserToYellow: list2.Add(PickupTransmutationManager.equipmentNormalGroup.GetRandomIndex()); list3.Add(array.GetRandomIndex()); list4.Add(PickupTransmutationManager.itemTierBossGroup.GetRandomIndex()); break; } } ((MonoBehaviour)RandomRecipes.instance).StartCoroutine(SendRecipesCoroutine(list, list2, list3, list4)); } private static IEnumerator SendRecipesCoroutine(List randomRecipeTypeList, List ingredient1List, List ingredient2List, List resultList) { int i = 0; int limit = randomRecipeTypeList.Count; while (i < randomRecipeTypeList.Count) { int cutoff = limit - i; NetMessageExtensions.Send((INetMessage)(object)new SyncSendRecipes(randomRecipeTypeList.GetRange(i, Math.Min(50, cutoff)), ingredient1List.GetRange(i, Math.Min(50, cutoff)), ingredient2List.GetRange(i, Math.Min(50, cutoff)), resultList.GetRange(i, Math.Min(50, cutoff))), (NetworkDestination)1); i += 50; yield return null; } NetMessageExtensions.Send((INetMessage)(object)new SyncFinishedSendingRecipes(), (NetworkDestination)1); } private static void ClearOldCraftableDefs() { if (craftableDefs != null) { List list = ContentManager.craftableDefs.ToList(); CraftableDef[] array = craftableDefs; foreach (CraftableDef item in array) { list.Remove(item); } ContentManager._craftableDefs = list.ToArray(); } } public static void ClientRandomizeCraftables(int num, List randomRecipeTypeList, List ingredient1List, List ingredient2List, List resultList) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) ClearOldCraftableDefs(); craftableDefs = (CraftableDef[])(object)new CraftableDef[num]; PickupIndex[] array = PickupTransmutationManager.itemTier1Group.Concat(PickupTransmutationManager.itemTier2Group).ToArray(); for (int i = 0; i < randomRecipeTypeList.Count; i++) { switch ((RecipeType)randomRecipeTypeList[i]) { case RecipeType.WhitesToGreen: BuildCraftableDef(PickupTransmutationManager.itemTier1Group[ingredient1List[i]], PickupTransmutationManager.itemTier1Group[ingredient2List[i]], PickupTransmutationManager.itemTier2Group[resultList[i]], 1, i); break; case RecipeType.GreensToRed: BuildCraftableDef(PickupTransmutationManager.itemTier2Group[ingredient1List[i]], PickupTransmutationManager.itemTier2Group[ingredient2List[i]], PickupTransmutationManager.itemTier3Group[resultList[i]], 1, i); break; case RecipeType.GreensToYellow: BuildCraftableDef(PickupTransmutationManager.itemTier2Group[ingredient1List[i]], PickupTransmutationManager.itemTier2Group[ingredient2List[i]], PickupTransmutationManager.itemTierBossGroup[resultList[i]], 1, i); break; case RecipeType.LessersToOrange: BuildCraftableDef(array[ingredient1List[i]], array[ingredient2List[i]], PickupTransmutationManager.equipmentNormalGroup[resultList[i]], 1, i); break; case RecipeType.GreensToGreen: BuildCraftableDef(PickupTransmutationManager.itemTier2Group[ingredient1List[i]], PickupTransmutationManager.itemTier2Group[ingredient2List[i]], PickupTransmutationManager.itemTier2Group[resultList[i]], 1, i); break; case RecipeType.GreenAndWhiteToGreen: BuildCraftableDef(PickupTransmutationManager.itemTier2Group[ingredient1List[i]], PickupTransmutationManager.itemTier1Group[ingredient2List[i]], PickupTransmutationManager.itemTier2Group[resultList[i]], 1, i); break; case RecipeType.ScrapAndGreenTo2White: BuildCraftableDef(PickupCatalog.FindPickupIndex(Addressables.LoadAssetAsync((object)RoR2_Base_Scrap.ScrapWhite_asset).WaitForCompletion().itemIndex), PickupTransmutationManager.itemTier2Group[ingredient2List[i]], PickupTransmutationManager.itemTier1Group[resultList[i]], 2, i); break; case RecipeType.ScrapAndRedTo4White: BuildCraftableDef(PickupCatalog.FindPickupIndex(Addressables.LoadAssetAsync((object)RoR2_Base_Scrap.ScrapWhite_asset).WaitForCompletion().itemIndex), PickupTransmutationManager.itemTier3Group[ingredient2List[i]], PickupTransmutationManager.itemTier1Group[resultList[i]], 4, i); break; case RecipeType.OrangeAndLesserToRed: BuildCraftableDef(PickupTransmutationManager.equipmentNormalGroup[ingredient1List[i]], array[ingredient2List[i]], PickupTransmutationManager.itemTier3Group[resultList[i]], 1, i); break; case RecipeType.OrangeAndLesserToYellow: BuildCraftableDef(PickupTransmutationManager.equipmentNormalGroup[ingredient1List[i]], array[ingredient2List[i]], PickupTransmutationManager.itemTierBossGroup[resultList[i]], 1, i); break; } } UpdateCraftableContent(); } private static void BuildCraftableDef(PickupIndex ingredient1Index, PickupIndex ingredient2Index, PickupIndex resultIndex, int dropNum, int index) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (Options.logRecipes.Value) { Log.Info($"Adding recipe for {PickupCatalog.GetPickupDef(ingredient1Index).internalName} and {PickupCatalog.GetPickupDef(ingredient2Index).internalName} into {dropNum} {PickupCatalog.GetPickupDef(resultIndex).internalName}"); } Object downcastedDef = GetDowncastedDef(ingredient1Index); Object downcastedDef2 = GetDowncastedDef(ingredient2Index); Object downcastedDef3 = GetDowncastedDef(resultIndex); CraftableDef val = ScriptableObject.CreateInstance(); val.pickup = downcastedDef3; Recipe val2 = new Recipe(); val2.amountToDrop = dropNum; RecipeIngredient val3 = new RecipeIngredient(); val3.pickup = downcastedDef; RecipeIngredient val4 = new RecipeIngredient(); val4.pickup = downcastedDef2; val2.ingredients = (RecipeIngredient[])(object)new RecipeIngredient[2] { val3, val4 }; val2.craftableDef = val; val.recipes = (Recipe[])(object)new Recipe[1] { val2 }; craftableDefs[index] = val; } private static Object GetDowncastedDef(PickupIndex pickup) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) return (Object)(((int)((PickupIndex)(ref pickup)).pickupDef.equipmentIndex == -1) ? ((object)ItemCatalog.GetItemDef(((PickupIndex)(ref pickup)).pickupDef.itemIndex)) : ((object)EquipmentCatalog.GetEquipmentDef(((PickupIndex)(ref pickup)).pickupDef.equipmentIndex))); } public static int GetRandomIndex(this T[] array) { return Random.Range(0, array.Length); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("mwmw.RandomRecipes", "RandomRecipes", "1.0.1")] public class RandomRecipes : BaseUnityPlugin { public const string PluginGUID = "mwmw.RandomRecipes"; public const string PluginAuthor = "mwmw"; public const string PluginName = "RandomRecipes"; public const string PluginVersion = "1.0.1"; public static ConfigFile config; public static BaseUnityPlugin instance; public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); instance = (BaseUnityPlugin)(object)this; config = ((BaseUnityPlugin)this).Config; RegisterNetMessages(); Assets.Init(); Options.Init(); Run.onRunStartGlobal += delegate { RandomCraftableManager.RandomizeAndRefresh(); }; RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(OnLoadFinished)); } private void OnLoadFinished() { Options.OnLoadFinished(); } private void RegisterNetMessages() { NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); } } public static class SoftDeps { private static bool? _cookbookEnabled; public static bool cookbookEnabled { get { if (!_cookbookEnabled.HasValue) { _cookbookEnabled = Chainloader.PluginInfos.ContainsKey("rainorshine.CookBook"); } return _cookbookEnabled.Value; } } public static void RefreshCookBook() { RecipeProvider.Rebuild(); } } public static class Utils { public static void UnpatchedSetCraftableDefs(CraftableDef[] newCraftableDefs) { //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Invalid comparison between Unknown and I4 //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_02bf: Unknown result type (might be due to invalid IL or missing references) ArrayUtils.CloneTo(newCraftableDefs, ref CraftableCatalog.craftableDefs); CraftableCatalog.allRecipes = new List(); for (int i = 0; i < ContentManager._craftableDefs.Length; i++) { CraftableDef val = ContentManager._craftableDefs[i]; for (int j = 0; j < val.recipes.Length; j++) { Recipe val2 = val.recipes[j]; val2.craftableDef = val; val2.indexInCraftableDef = j; RecipeIngredient[] ingredients = val2.ingredients; RecipeIngredient[] array = ingredients; foreach (RecipeIngredient val3 in array) { val3.pickupIndex = PickupIndex.none; if (val3.IsDefinedPickup()) { Object pickup = val3.pickup; ItemDef val4 = (ItemDef)(object)((pickup is ItemDef) ? pickup : null); Object pickup2 = val3.pickup; EquipmentDef val5 = (EquipmentDef)(object)((pickup2 is EquipmentDef) ? pickup2 : null); if ((Object)(object)val4 != (Object)null && (int)val4.itemIndex != -1) { val3.pickupIndex = PickupCatalog.FindPickupIndex(val4.itemIndex); } else if ((Object)(object)val5 != (Object)null && (int)val5.equipmentIndex != -1) { val3.pickupIndex = PickupCatalog.FindPickupIndex(val5.equipmentIndex); } } } CraftableCatalog.allRecipes.Add(new RecipeEntry { recipe = val2, result = val.GetPickupDefFromResult().pickupIndex, amountToDrop = val2.amountToDrop, possibleIngredients = null }); } } IEnumerable allPickups = PickupCatalog.allPickups; foreach (RecipeEntry allRecipe in CraftableCatalog.allRecipes) { if (!CraftableCatalog.resultToRecipeSearchTable.ContainsKey(allRecipe.result)) { CraftableCatalog.resultToRecipeSearchTable.Add(allRecipe.result, new List()); } CraftableCatalog.resultToRecipeSearchTable[allRecipe.result].Add(allRecipe); List list = new List(); allRecipe.possibleIngredients = (IngredientSlotEntry[])(object)new IngredientSlotEntry[allRecipe.recipe.ingredients.Length]; for (int l = 0; l < allRecipe.recipe.ingredients.Length; l++) { IngredientSlotEntry val6 = new IngredientSlotEntry(l); val6.type = allRecipe.recipe.ingredients[l].type; list = new List(); RecipeIngredient val7 = allRecipe.recipe.ingredients[l]; foreach (PickupDef item in allPickups) { if (val7.Validate(item.pickupIndex)) { list.Add(item.pickupIndex); if (!CraftableCatalog.pickupToIngredientSearchTable.ContainsKey(item.pickupIndex)) { CraftableCatalog.pickupToIngredientSearchTable.Add(item.pickupIndex, new List()); } CraftableCatalog.pickupToIngredientSearchTable[item.pickupIndex].Add(allRecipe); val6.pickups = list.ToArray(); } } val6.slotIndex = l; allRecipe.possibleIngredients[l] = val6; } } } } }