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 RandomRecipes v1.0.0
RandomRecipes.dll
Decompiled 4 months agousing 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 Microsoft.CodeAnalysis; using R2API.Networking; using R2API.Networking.Interfaces; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ContentManagement; using RoR2BepInExPack.GameAssetPaths.Version_1_35_0; 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+3dd2bd53fd3bfb1d9398e4f710cfc3bf8d2ac5b5")] [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] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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<int> holdRandomRecipeTypes = new List<int>(); public static List<int> holdIngredient1s = new List<int>(); public static List<int> holdIngredient2s = new List<int>(); public static List<int> holdResults = new List<int>(); } public class SyncSendRecipes : INetMessage, ISerializableObject { private List<int> randomRecipeTypeList; private List<int> ingredient1List; private List<int> ingredient2List; private List<int> resultList; public SyncSendRecipes() { } public SyncSendRecipes(List<int> randomRecipeTypeList, List<int> ingredient1List, List<int> ingredient2List, List<int> 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<int>(); ingredient1List = new List<int>(); ingredient2List = new List<int>(); resultList = new List<int>(); 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<int>(); Networking.holdIngredient1s = new List<int>(); Networking.holdIngredient2s = new List<int>(); Networking.holdResults = new List<int>(); } } 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<int> noRandomRecipes { get; set; } public static ConfigEntry<float> whitesToGreenWeight { get; set; } public static ConfigEntry<float> greensToRedWeight { get; set; } public static ConfigEntry<float> greensToYellowWeight { get; set; } public static ConfigEntry<float> lessersToOrangeWeight { get; set; } public static ConfigEntry<float> greenAndWhiteToGreenWeight { get; set; } public static ConfigEntry<float> greensToGreenWeight { get; set; } public static ConfigEntry<float> scrapAndGreenTo2WhiteWeight { get; set; } public static ConfigEntry<float> scrapAndRedTo4WhiteWeight { get; set; } public static ConfigEntry<float> orangeAndLesserToRedWeight { get; set; } public static ConfigEntry<float> orangeAndLesserToYellowWeight { get; set; } public static ConfigEntry<bool> 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<int>("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<float>("Recipes", "WhitesToGreen Weight", 5f, "The weighted probability of a random recipe being WhitesToGreen."); whitesToGreenWeight.SettingChanged += delegate { OnSettingChanged(); }; greensToRedWeight = RandomRecipes.config.Bind<float>("Recipes", "GreensToRed Weight", 2f, "The weighted probability of a random recipe being GreensToRed."); greensToRedWeight.SettingChanged += delegate { OnSettingChanged(); }; greensToYellowWeight = RandomRecipes.config.Bind<float>("Recipes", "GreensToYellow Weight", 1f, "The weighted probability of a random recipe being GreensToYellow."); greensToYellowWeight.SettingChanged += delegate { OnSettingChanged(); }; lessersToOrangeWeight = RandomRecipes.config.Bind<float>("Recipes", "LessersToOrange Weight", 1f, "The weighted probability of a random recipe being LessersToOrange."); lessersToOrangeWeight.SettingChanged += delegate { OnSettingChanged(); }; greensToGreenWeight = RandomRecipes.config.Bind<float>("Recipes", "GreensToGreen Weight", 1f, "The weighted probability of a random recipe being GreensToGreen."); greensToGreenWeight.SettingChanged += delegate { OnSettingChanged(); }; greenAndWhiteToGreenWeight = RandomRecipes.config.Bind<float>("Recipes", "GreenAndWhiteToGreen Weight", 1f, "The weighted probability of a random recipe being GreenAndWhiteToGreen."); greenAndWhiteToGreenWeight.SettingChanged += delegate { OnSettingChanged(); }; scrapAndGreenTo2WhiteWeight = RandomRecipes.config.Bind<float>("Recipes", "ScrapAndGreenTo2White Weight", 1.5f, "The weighted probability of a random recipe being ScrapAndGreenTo2White."); scrapAndGreenTo2WhiteWeight.SettingChanged += delegate { OnSettingChanged(); }; scrapAndRedTo4WhiteWeight = RandomRecipes.config.Bind<float>("Recipes", "ScrapAndRedTo4White Weight", 1.2f, "The weighted probability of a random recipe being ScrapAndRedTo4White."); scrapAndRedTo4WhiteWeight.SettingChanged += delegate { OnSettingChanged(); }; orangeAndLesserToRedWeight = RandomRecipes.config.Bind<float>("Recipes", "OrangeAndLesserToRed Weight", 0.8f, "The weighted probability of a random recipe being OrangeAndLesserToRed."); orangeAndLesserToRedWeight.SettingChanged += delegate { OnSettingChanged(); }; orangeAndLesserToYellowWeight = RandomRecipes.config.Bind<float>("Recipes", "OrangeAndLesserToYellow Weight", 0.8f, "The weighted probability of a random recipe being OrangeAndLesserToYellow."); orangeAndLesserToYellowWeight.SettingChanged += delegate { OnSettingChanged(); }; logRecipes = RandomRecipes.config.Bind<bool>("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<Sprite>("icon")); } } public static class RandomCraftableManager { public enum RecipeType { WhitesToGreen, GreensToRed, GreensToYellow, LessersToOrange, GreensToGreen, GreenAndWhiteToGreen, ScrapAndGreenTo2White, ScrapAndRedTo4White, OrangeAndLesserToRed, OrangeAndLesserToYellow } [CompilerGenerated] private sealed class <SendRecipesCoroutine>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public List<int> randomRecipeTypeList; public List<int> ingredient1List; public List<int> ingredient2List; public List<int> resultList; private int <i>5__1; private int <limit>5__2; private int <cutoff>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SendRecipesCoroutine>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <i>5__1 = 0; <limit>5__2 = randomRecipeTypeList.Count; break; case 1: <>1__state = -1; break; } if (<i>5__1 < randomRecipeTypeList.Count) { <cutoff>5__3 = <limit>5__2 - <i>5__1; NetMessageExtensions.Send((INetMessage)(object)new SyncSendRecipes(randomRecipeTypeList.GetRange(<i>5__1, Math.Min(50, <cutoff>5__3)), ingredient1List.GetRange(<i>5__1, Math.Min(50, <cutoff>5__3)), ingredient2List.GetRange(<i>5__1, Math.Min(50, <cutoff>5__3)), resultList.GetRange(<i>5__1, Math.Min(50, <cutoff>5__3))), (NetworkDestination)1); <i>5__1 += 50; <>2__current = null; <>1__state = 1; return true; } NetMessageExtensions.Send((INetMessage)(object)new SyncFinishedSendingRecipes(), (NetworkDestination)1); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static Dictionary<RecipeType, float> recipeTypeWeights = new Dictionary<RecipeType, float> { { 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<PickupIndex, List<RecipeEntry>>(); CraftableCatalog.resultToRecipeSearchTable = new Dictionary<PickupIndex, List<RecipeEntry>>(); CraftableCatalog.Init(); Log.Info("Tried to update CraftableCatalog"); if (SoftDeps.cookbookEnabled) { SoftDeps.RefreshCookBook(); } } private static void ServerRandomizeCraftables() { List<int> list = new List<int>(); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); List<int> list4 = new List<int>(); 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<RecipeType, float> 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)); } [IteratorStateMachine(typeof(<SendRecipesCoroutine>d__7))] private static IEnumerator SendRecipesCoroutine(List<int> randomRecipeTypeList, List<int> ingredient1List, List<int> ingredient2List, List<int> resultList) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SendRecipesCoroutine>d__7(0) { randomRecipeTypeList = randomRecipeTypeList, ingredient1List = ingredient1List, ingredient2List = ingredient2List, resultList = resultList }; } private static void ClearOldCraftableDefs() { if (craftableDefs != null) { List<CraftableDef> 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<int> randomRecipeTypeList, List<int> ingredient1List, List<int> ingredient2List, List<int> 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<ItemDef>((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<ItemDef>((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<CraftableDef>(); 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<T>(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.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("mwmw.RandomRecipes", "RandomRecipes", "1.0.0")] 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.0"; 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<SyncSendRecipes>(); NetworkingAPI.RegisterMessageType<SyncFinishedSendingRecipes>(); } } 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(); } } }