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 RecyclerDarkAlchemySwitcheroo v1.0.0
RecyclerDarkAlchemySwitcheroo.dll
Decompiled 7 hours agousing System; 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.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.CursedBook.Spells; using HG.Reflection; using Microsoft.CodeAnalysis; using On.EntityStates.CursedBook.Spells; using On.RoR2; using On.RoR2.Items; using RoR2; using RoR2.AsyncManagement; using RoR2.Items; using RoR2BepInExPack.GameAssetPathsBetter; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RecyclerDarkAlchemySwitcheroo")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RecyclerDarkAlchemySwitcheroo")] [assembly: AssemblyTitle("RecyclerDarkAlchemySwitcheroo")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] 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 RDAS { 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); } } [BepInPlugin("Xaidee.RecyclerDarkAlchemySwitcheroo", "RecyclerDarkAlchemySwitcheroo", "1.0.0")] public class ModPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Action <0>__ChangeDefs; public static hook_UpdateTargets <1>__EquipmentSlotUpdateTargets; public static hook_UpdateTargets <2>__CursedBookBodyBehaviorUpdateTargets; public static hook_FireRecycle <3>__FireRecycle; public static hook_OnEnter <4>__UpgradeItemOnEnter; } private static ConfigEntry<bool> _enableRecyclingHexes; private static readonly GameObject RecyclerBadIndicatorPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Recycle.RecyclerBadIndicator_prefab).WaitForCompletion(); private static readonly GameObject RecyclerIndicatorPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Recycle.RecyclerIndicator_prefab).WaitForCompletion(); private static readonly GameObject OmniRecycleEffectPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Recycle.OmniRecycleEffect_prefab).WaitForCompletion(); public void Awake() { //IL_00a4: 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_00af: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); _enableRecyclingHexes = ((BaseUnityPlugin)this).Config.Bind<bool>("Recycler Dark Alchemy Switcheroo", "EnableRecyclingHexes", false, "Allows Recyclers to recycle Hexes into white items like base game's Dark Alchemy does."); string rootPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (Directory.Exists(Path.Combine(rootPath, "languages"))) { Language.collectLanguageRootFolders += delegate(List<string> list) { list.Add(Path.Combine(rootPath, "languages")); }; } ((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)ChangeDefs); object obj = <>O.<1>__EquipmentSlotUpdateTargets; if (obj == null) { hook_UpdateTargets val = EquipmentSlotUpdateTargets; <>O.<1>__EquipmentSlotUpdateTargets = val; obj = (object)val; } EquipmentSlot.UpdateTargets += (hook_UpdateTargets)obj; object obj2 = <>O.<2>__CursedBookBodyBehaviorUpdateTargets; if (obj2 == null) { hook_UpdateTargets val2 = CursedBookBodyBehaviorUpdateTargets; <>O.<2>__CursedBookBodyBehaviorUpdateTargets = val2; obj2 = (object)val2; } CursedBookBodyBehavior.UpdateTargets += (hook_UpdateTargets)obj2; object obj3 = <>O.<3>__FireRecycle; if (obj3 == null) { hook_FireRecycle val3 = FireRecycle; <>O.<3>__FireRecycle = val3; obj3 = (object)val3; } EquipmentSlot.FireRecycle += (hook_FireRecycle)obj3; object obj4 = <>O.<4>__UpgradeItemOnEnter; if (obj4 == null) { hook_OnEnter val4 = UpgradeItemOnEnter; <>O.<4>__UpgradeItemOnEnter = val4; obj4 = (object)val4; } UpgradeItem.OnEnter += (hook_OnEnter)obj4; } private static void ChangeDefs() { EquipmentDef recycle = Equipment.Recycle; ItemDef pageUpgradeItem = Items.PageUpgradeItem; recycle.pickupToken = "EQUIPMENT_RDAS_RECYCLER_PICKUP"; recycle.descriptionToken = "EQUIPMENT_RDAS_RECYCLER_DESC"; pageUpgradeItem.pickupToken = "CURSEDBOOK_SPELL_RDAS_DARKALCHEMY_PICKUP"; pageUpgradeItem.descriptionToken = "CURSEDBOOK_SPELL_RDAS_DARKALCHEMY_DESC"; } private static void EquipmentSlotUpdateTargets(orig_UpdateTargets orig, EquipmentSlot self, EquipmentIndex targetingEquipmentIndex, bool userShouldAnticipateTarget) { //IL_001c: 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_0013: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (self.remoteClientTargetOverride.HasValue || targetingEquipmentIndex != Equipment.Recycle.equipmentIndex) { orig.Invoke(self, targetingEquipmentIndex, userShouldAnticipateTarget); return; } self.currentTarget = new UserTargetInfo(self.FindPickupController(self.GetAimRay(), 10f, 30f, true, false)); Transform transformToIndicateAt = self.currentTarget.transformToIndicateAt; GenericPickupController pickupController = self.currentTarget.pickupController; if (Object.op_Implicit((Object)(object)transformToIndicateAt)) { self.targetIndicator.visualizerPrefab = ((!CanRecyclePickup(pickupController)) ? RecyclerBadIndicatorPrefab : ((self.stock <= 0) ? CommonAssets.recyclerCooldownIndicatorPrefab : RecyclerIndicatorPrefab)); } self.targetIndicator.active = Object.op_Implicit((Object)(object)transformToIndicateAt); self.targetIndicator.targetTransform = (Object.op_Implicit((Object)(object)transformToIndicateAt) ? self.currentTarget.transformToIndicateAt : null); } private static bool FireRecycle(orig_FireRecycle orig, EquipmentSlot self) { //IL_0006: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) self.UpdateTargets(Equipment.Recycle.equipmentIndex, false); GenericPickupController pickupController = self.currentTarget.pickupController; if (!Object.op_Implicit((Object)(object)pickupController) || !CanRecyclePickup(pickupController) || !AttemptRecycle(pickupController.pickup, out var result)) { return false; } self.subcooldownTimer = 0.2f; pickupController.pickup = result; EffectManager.SimpleEffect(OmniRecycleEffectPrefab, ((Component)pickupController.pickupDisplay).transform.position, Quaternion.identity, true); pickupController.ForcePickupDisplayUpdate(); CreatePickupInfo val = default(CreatePickupInfo); ((CreatePickupInfo)(ref val)).pickup = result; val.position = ((Component)pickupController).transform.position; CreatePickupInfo val2 = val; GenericPickupController.CreatePickup(ref val2); self.InvalidateCurrentTarget(); return true; } private static void CursedBookBodyBehaviorUpdateTargets(orig_UpdateTargets orig, CursedBookBodyBehavior self) { //IL_0006: 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_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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) if (!self.IsCurrentSpell(CursedBookSpells.UpgradeItem.spellIndex)) { orig.Invoke(self); return; } self.currentTarget = new PickupTargetInfo(self.FindPickupController(((BaseKeyItemBodyBehavior)self).body.inputBank.GetAimRay(), 10f, 30f, true, true)); bool flag = Object.op_Implicit((Object)(object)self.currentTarget.pickupController) && self.currentTarget.pickupDef != null && !self.currentTarget.pickupController.Recycled; self.indicator.visualizerPrefab = (flag ? CursedBookBodyBehavior.upgradeItemIndicatorPrefab : CursedBookBodyBehavior.upgradeItemCannotUpgradeIndicatorPrefab); self.indicator.active = true; self.indicator.targetTransform = self.currentTarget.transformToIndicateAt; } private static void UpgradeItemOnEnter(orig_OnEnter orig, UpgradeItem self) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) ((BaseCursedBookSpellState)self).bodyAttachment = ((EntityState)self).GetComponent<NetworkedBodyAttachment>(); ((BaseCursedBookSpellState)self).ownerBody = ((BaseCursedBookSpellState)self).bodyAttachment.attachedBody; ((BaseCursedBookSpellState)self).bodyBehavior = ((Component)((BaseCursedBookSpellState)self).ownerBody).GetComponent<CursedBookBodyBehavior>(); ((BaseCursedBookSpellState)self).overrideConsumeOnExit = ((BaseCursedBookSpellState)self).consumeCursedBookOnExit; if (((EntityState)self).isAuthority) { self.targetObject = ((BaseCursedBookSpellState)self).bodyBehavior.currentTarget.rootObject; } bool flag = false; GenericPickupController val = default(GenericPickupController); if (Object.op_Implicit((Object)(object)self.targetObject) && self.targetObject.TryGetComponent<GenericPickupController>(ref val) && !val.Recycled) { if (NetworkServer.active) { UniquePickup initialPickupState = val.pickup; PickupIndex[] array = (PickupTransmutationManager.GetAvailableGroupFromPickupIndex(val.pickup.pickupIndex) ?? Array.Empty<PickupIndex>()).Where((PickupIndex pickupIndex) => pickupIndex != initialPickupState.pickupIndex).ToArray(); if (array.Length != 0) { GenericPickupController obj = val; UniquePickup pickup = val.pickup; obj.pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(Run.instance.treasureRng.NextElementUniform<PickupIndex>(array)); EffectManager.SimpleEffect(EntityStateGameObject.op_Implicit(UpgradeItem.transmutationEffectPrefab), ((Component)val.pickupDisplay).transform.position, Quaternion.identity, true); } } flag = true; val.NetworkRecycled = true; val.ForcePickupDisplayUpdate(); } if (flag) { ((BaseCursedBookSpellState)self).bodyBehavior.InvalidateCurrentTarget(); } ((BaseCursedBookSpellState)self).overrideConsumeOnExit = flag; } private static bool CanRecyclePickup(GenericPickupController genericPickup) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(genericPickup.pickup.pickupIndex); if (pickupDef == null || (int)pickupDef.itemIndex == -1 || genericPickup.pickup.isRental) { return false; } if (!_enableRecyclingHexes.Value && (int)pickupDef.itemTier == 13) { return false; } ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if (!Object.op_Implicit((Object)(object)itemDef)) { return false; } if (((IEnumerable<ItemTag>)CursedBookBodyBehavior.bannedTagsForUpgrade).Any((Func<ItemTag, bool>)itemDef.ContainsTag)) { return false; } ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier); if (Object.op_Implicit((Object)(object)itemTierDef) && (Object)(object)itemTierDef.previousTier != (Object)null && Run.instance.allAvailableTierDroplists.TryGetValue(itemTierDef.previousTier.tier, out var value)) { return value.Count > 0; } return false; } private static bool AttemptRecycle(UniquePickup source, out UniquePickup result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_00e6: Unknown result type (might be due to invalid IL or missing references) result = source; PickupDef pickupDef = PickupCatalog.GetPickupDef(source.pickupIndex); if (pickupDef == null) { return result != source; } ItemIndex itemIndex = pickupDef.itemIndex; ItemTier itemTier = pickupDef.itemTier; ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemTier); if (!Object.op_Implicit((Object)(object)itemDef) || !Object.op_Implicit((Object)(object)itemTierDef) || (Object)(object)itemTierDef.previousTier == (Object)null) { return result != source; } List<PickupIndex> list = Run.instance.allAvailableTierDroplists[itemTierDef.previousTier.tier]; WeightedSelection<PickupIndex> val = new WeightedSelection<PickupIndex>(8); foreach (PickupIndex item in list) { float num = 1f; PickupDef pickupDef2 = PickupCatalog.GetPickupDef(item); if (pickupDef2 == null) { continue; } ItemDef itemDef2 = ItemCatalog.GetItemDef(pickupDef2.itemIndex); if (Object.op_Implicit((Object)(object)itemDef2)) { ItemTag[] tags = itemDef2.tags; foreach (ItemTag val2 in tags) { num = ((!itemDef.ContainsTag(val2)) ? (num * 0.5f) : (num * 10f)); } } val.AddChoice(item, num); } if (val.Count > 0) { result = ((UniquePickup)(ref source)).WithPickupIndex(val.Evaluate(Run.instance.treasureRng.nextNormalizedFloat)); } return result != source; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }