using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using On.RoR2.Artifacts; using RoR2; using RoR2.Artifacts; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PlannedEvolution")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3e57e8001a30fe3c7ee6338a541a2be342576ac6")] [assembly: AssemblyProduct("PlannedEvolution")] [assembly: AssemblyTitle("PlannedEvolution")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace PlannedEvolution { [BepInPlugin("com.FortressForce.PlannedEvolution", "Planned Evolution", "2.3.4")] public class PlannedEvolutionPlugin : BaseUnityPlugin { private class EvolutionStep { public string ItemIdentifier = string.Empty; public int Count; } private ConfigEntry? ModEnabled; private ConfigEntry[] StageConfigs = new ConfigEntry[20]; private static ConfigEntry? BlacklistWhite; private static ConfigEntry? BlacklistGreen; private static ConfigEntry? BlacklistRed; private List BannedItemIndices = new List(); private bool isCacheBuilt; private static Inventory? MonsterInventory { get { object? obj = typeof(MonsterTeamGainsItemsArtifactManager).GetField("monsterTeamInventory", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null); return (Inventory?)((obj is Inventory) ? obj : null); } } public void Awake() { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown ModEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Set to false to disable the mod."); for (int i = 0; i < 20; i++) { int num = i + 1; string text = ((num <= 5) ? "AnyWhite, 1" : ((num <= 10) ? "AnyGreen, 1" : "AnyRed, 1")); StageConfigs[i] = ((BaseUnityPlugin)this).Config.Bind("Evolution Schedule", $"Stage {num}", text, "Use semicolons to add multiple items per stage, for example: anywhite,1; Armorplate,1"); } BlacklistWhite = ((BaseUnityPlugin)this).Config.Bind("Blacklists", "Banned Whites", "RollOfPennies", "Banned White items."); BlacklistGreen = ((BaseUnityPlugin)this).Config.Bind("Blacklists", "Banned Greens", "SquidPolyp", "Banned Green items."); BlacklistRed = ((BaseUnityPlugin)this).Config.Bind("Blacklists", "Banned Reds", "ShockNearby", "Banned Red items."); ConfigEntry? modEnabled = ModEnabled; if (modEnabled == null || modEnabled.Value) { MonsterTeamGainsItemsArtifactManager.GrantMonsterTeamItem += new hook_GrantMonsterTeamItem(OverrideEvolution); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PlannedEvolution 2.3.4: Config usability improvements."); } } private void OverrideEvolution(orig_GrantMonsterTeamItem orig) { //IL_0139: 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_0169: Expected O, but got Unknown orig.Invoke(); try { if (!isCacheBuilt) { BuildBlacklistCache(); } if ((Object)(object)Run.instance == (Object)null) { return; } Inventory monsterInventory = MonsterInventory; if (!((Object)(object)monsterInventory != (Object)null)) { return; } monsterInventory.CleanInventory(); int num = Run.instance.stageClearCount + 1; List list = new List(); for (int i = 0; i < num && i < StageConfigs.Length; i++) { string text = StageConfigs[i]?.Value; if (string.IsNullOrEmpty(text)) { continue; } foreach (EvolutionStep item in ParseStageConfig(text)) { string text2 = ApplyEvolutionStep(item, monsterInventory); if (i + 1 == num && !string.IsNullOrEmpty(text2)) { list.Add($"{item.Count}x {text2}"); } } } ArtifactDef val = ArtifactCatalog.FindArtifactDef("Evolution"); if ((Object)(object)RunArtifactManager.instance != (Object)null && (Object)(object)val != (Object)null && RunArtifactManager.instance.IsArtifactEnabled(val) && list.Count > 0) { Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage { baseToken = $"[Planned Evolution] Stage {num}: " + string.Join(", ", list) }); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Error in OverrideEvolution: {arg}"); } } private List ParseStageConfig(string rawText) { List list = new List(); string[] array = rawText.Split(';'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Trim().Split(','); if (array2.Length == 2 && int.TryParse(array2[1].Trim(), out var result)) { list.Add(new EvolutionStep { ItemIdentifier = array2[0].Trim(), Count = result }); } } return list; } private string? ApplyEvolutionStep(EvolutionStep step, Inventory inventory) { //IL_0028: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) ItemIndex val = (step.ItemIdentifier.StartsWith("Any", StringComparison.OrdinalIgnoreCase) ? PickRandomItem(step.ItemIdentifier) : FindItemIndexBetter(step.ItemIdentifier)); if ((int)val != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(val); if ((Object)(object)itemDef == (Object)null) { return null; } if (step.Count > 0) { inventory.GiveItemPermanent(val, step.Count); } else if (step.Count < 0) { inventory.RemoveItemPermanent(val, Math.Abs(step.Count)); } return Language.GetString(itemDef.nameToken); } return null; } private void BuildBlacklistCache() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Invalid comparison between Unknown and I4 //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (isCacheBuilt || !((ResourceAvailability)(ref ItemCatalog.availability)).available) { return; } BannedItemIndices.Clear(); string[] array = (BlacklistWhite?.Value + "," + BlacklistGreen?.Value + "," + BlacklistRed?.Value).Split(','); foreach (string text in array) { ItemIndex val = FindItemIndexBetter(text.Trim()); if ((int)val != -1) { BannedItemIndices.Add(val); } } isCacheBuilt = true; } private ItemIndex FindItemIndexBetter(string identifier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_007c: Unknown result type (might be due to invalid IL or missing references) ItemIndex val = ItemCatalog.FindItemIndex(identifier); if ((int)val != -1) { return val; } GenericStaticEnumerable allItems = ItemCatalog.allItems; AllItemsEnumerator enumerator = allItems.GetEnumerator(); try { while (((AllItemsEnumerator)(ref enumerator)).MoveNext()) { ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current; ItemDef itemDef = ItemCatalog.GetItemDef(current); if (!((Object)(object)itemDef == (Object)null) && (((Object)itemDef).name.Equals(identifier, StringComparison.OrdinalIgnoreCase) || Language.GetString(itemDef.nameToken).Equals(identifier, StringComparison.OrdinalIgnoreCase))) { return current; } } } finally { ((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose(); } return (ItemIndex)(-1); } private ItemIndex PickRandomItem(string keyword) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Run.instance == (Object)null) { return (ItemIndex)(-1); } List list = keyword.Trim().ToLowerInvariant() switch { "anywhite" => Run.instance.availableTier1DropList, "anygreen" => Run.instance.availableTier2DropList, "anyred" => Run.instance.availableTier3DropList, "anyvoid" => Run.instance.availableVoidTier1DropList, _ => null, }; if (list == null || list.Count == 0) { return (ItemIndex)(-1); } List list2 = list.Where(delegate(PickupIndex p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(p); ItemIndex val = (ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex)); return (int)val != -1 && !BannedItemIndices.Contains(val); }).ToList(); if (list2.Count == 0) { return (ItemIndex)(-1); } return (ItemIndex)(((??)PickupCatalog.GetPickupDef(Run.instance.treasureRng.NextElementUniform(list2))?.itemIndex) ?? (-1)); } } }