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 SaleStarMultishop v1.0.0
SaleStarMultishop.dll
Decompiled 6 hours agousing System; using System.Collections.Generic; using System.Diagnostics; 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 HarmonyLib; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RoR2; using UnityEngine; using UnityEngine.Networking; [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("SaleStarMultishop")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SaleStarMultishop")] [assembly: AssemblyTitle("SaleStarMultishop")] [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 SaleStarMultishop { [BepInPlugin("com.iaguito.salestarmultishop", "SaleStarMultishop", "1.0.0")] public class SaleStarMultishopPlugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Manipulator <0>__Patch_PurchaseInteraction_OnInteractionBegin; } public const string PluginGUID = "com.iaguito.salestarmultishop"; public const string PluginName = "SaleStarMultishop"; public const string PluginVersion = "1.0.0"; private static readonly FieldRef<MultiShopController, GameObject[]> TerminalGameObjectsRef = AccessTools.FieldRefAccess<MultiShopController, GameObject[]>("terminalGameObjects"); private static readonly FieldRef<ShopTerminalBehavior, Xoroshiro128Plus> ShopRngRef = AccessTools.FieldRefAccess<ShopTerminalBehavior, Xoroshiro128Plus>("rng"); private static GameObject _lastInteractedTerminal; private static Interactor _currentActivator; private static int _preInteractionSaleStars; private static bool _saleStarConsumedOnInteraction; private static int _lastBonusRoll; private Harmony _harmony; private ILHook _ilHookOnInteractionBegin; public static SaleStarMultishopPlugin Instance { get; private set; } public static ManualLogSource ModLogger { get; private set; } public static ConfigEntry<bool> ChestStyleBonusDrops { get; private set; } public static ConfigEntry<bool> AffectEquipmentMultishops { get; private set; } public void Awake() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown Instance = this; ModLogger = ((BaseUnityPlugin)this).Logger; ChestStyleBonusDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "ChestStyleBonusDrops", false, "If true, Sale Star bonus drops behave like a regular chest: dropping additional items of random rarity based on the terminal's rarity chances (including Shipping Request Form scaling, etc.). If false, additional drops duplicate the selected item, just like with Adaptative Chests."); AffectEquipmentMultishops = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "AffectEquipmentMultishops", true, "If true, Sale Star will also work on Equipment Multishop Terminals."); ItemQualitiesCompat.Init(); _harmony = new Harmony("com.iaguito.salestarmultishop"); _harmony.PatchAll(typeof(SaleStarMultishopPlugin)); try { MethodInfo method = typeof(PurchaseInteraction).GetMethod("OnInteractionBegin", BindingFlags.Instance | BindingFlags.Public); if (method != null) { object obj = <>O.<0>__Patch_PurchaseInteraction_OnInteractionBegin; if (obj == null) { Manipulator val = Patch_PurchaseInteraction_OnInteractionBegin; <>O.<0>__Patch_PurchaseInteraction_OnInteractionBegin = val; obj = (object)val; } _ilHookOnInteractionBegin = new ILHook((MethodBase)method, (Manipulator)obj); ModLogger.LogInfo((object)"Successfully applied ILHook to PurchaseInteraction.OnInteractionBegin."); } else { ModLogger.LogError((object)"Failed to locate PurchaseInteraction.OnInteractionBegin method!"); } } catch (Exception arg) { ModLogger.LogError((object)$"Error initializing ILHook: {arg}"); } ModLogger.LogInfo((object)"SaleStarMultishop v1.0.0 initialized!"); } public void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } ILHook ilHookOnInteractionBegin = _ilHookOnInteractionBegin; if (ilHookOnInteractionBegin != null) { ilHookOnInteractionBegin.Dispose(); } } public static int GetTotalSaleStarCount(Inventory inventory) { if (!Object.op_Implicit((Object)(object)inventory)) { return 0; } int num = 0; if ((Object)(object)Items.LowerPricedChests != (Object)null) { num += inventory.GetItemCountEffective(Items.LowerPricedChests); } if (ItemQualitiesCompat.IsLoaded) { num += ItemQualitiesCompat.GetQualitySaleStarCount(inventory); } return num; } public static bool IsMultiShopTerminal(ShopTerminalBehavior stb) { if (!Object.op_Implicit((Object)(object)stb)) { return false; } if ((Object)(object)stb.serverMultiShopController != (Object)null) { return true; } if ((Object)(object)((Component)stb).GetComponentInParent<MultiShopController>() != (Object)null) { return true; } if ((Object)(object)((Component)stb).transform.parent != (Object)null && (Object)(object)((Component)((Component)stb).transform.parent).GetComponentInParent<MultiShopController>() != (Object)null) { return true; } return false; } private static bool ShouldMakeCompatible(MultiShopController msc) { if (!Object.op_Implicit((Object)(object)msc)) { return true; } if (msc.doEquipmentInstead && !AffectEquipmentMultishops.Value) { return false; } return true; } private static void ApplySaleStarCompatibility(GameObject terminalObject) { if (Object.op_Implicit((Object)(object)terminalObject)) { PurchaseInteraction component = terminalObject.GetComponent<PurchaseInteraction>(); if ((Object)(object)component != (Object)null) { component.saleStarCompatible = true; } } } [HarmonyPostfix] [HarmonyPatch(typeof(MultiShopController), "Start")] private static void MultiShopController_Start_Postfix(MultiShopController __instance) { if (!ShouldMakeCompatible(__instance)) { return; } GameObject[] array = TerminalGameObjectsRef.Invoke(__instance); if (array != null) { GameObject[] array2 = array; for (int i = 0; i < array2.Length; i++) { ApplySaleStarCompatibility(array2[i]); } } } [HarmonyPostfix] [HarmonyPatch(typeof(PurchaseInteraction), "Awake")] private static void PurchaseInteraction_Awake_Postfix(PurchaseInteraction __instance) { ShopTerminalBehavior component = ((Component)__instance).GetComponent<ShopTerminalBehavior>(); if ((Object)(object)component != (Object)null && ShouldMakeCompatible(component.serverMultiShopController ?? ((Component)component).GetComponentInParent<MultiShopController>())) { __instance.saleStarCompatible = true; } } [HarmonyPostfix] [HarmonyPatch(typeof(ShopTerminalBehavior), "SetPickup")] private static void ShopTerminalBehavior_SetPickup_Postfix(ShopTerminalBehavior __instance) { if (ShouldMakeCompatible(__instance.serverMultiShopController ?? ((Component)__instance).GetComponentInParent<MultiShopController>())) { PurchaseInteraction component = ((Component)__instance).GetComponent<PurchaseInteraction>(); if ((Object)(object)component != (Object)null) { component.saleStarCompatible = true; } } } [HarmonyPostfix] [HarmonyPatch(typeof(PurchaseInteraction), "CanBeAffordedByInteractor")] private static void PurchaseInteraction_CanBeAffordedByInteractor_Postfix(PurchaseInteraction __instance, Interactor activator, ref bool __result) { if (!__instance.saleStarCompatible) { return; } ShopTerminalBehavior component = ((Component)__instance).GetComponent<ShopTerminalBehavior>(); if (Object.op_Implicit((Object)(object)component) && IsMultiShopTerminal(component)) { CharacterBody val = (Object.op_Implicit((Object)(object)activator) ? ((Component)activator).GetComponent<CharacterBody>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.inventory) && GetTotalSaleStarCount(val.inventory) > 0) { __instance.saleStarCompatible = true; } } } [HarmonyPostfix] [HarmonyPatch(typeof(Inventory), "GetItemCountEffective", new Type[] { typeof(ItemDef) })] private static void Inventory_GetItemCountEffective_Postfix(Inventory __instance, ItemDef itemDef, ref int __result) { if ((Object)(object)itemDef == (Object)(object)Items.LowerPricedChests && ItemQualitiesCompat.IsLoaded) { int qualitySaleStarCount = ItemQualitiesCompat.GetQualitySaleStarCount(__instance); if (qualitySaleStarCount > 0) { __result += qualitySaleStarCount; } } } [HarmonyPrefix] [HarmonyPatch(typeof(PurchaseInteraction), "OnInteractionBegin")] private static void PurchaseInteraction_OnInteractionBegin_Prefix(PurchaseInteraction __instance, Interactor activator) { if (!NetworkServer.active || !__instance.saleStarCompatible) { return; } ShopTerminalBehavior component = ((Component)__instance).GetComponent<ShopTerminalBehavior>(); if (Object.op_Implicit((Object)(object)component) && IsMultiShopTerminal(component)) { _lastInteractedTerminal = ((Component)__instance).gameObject; _currentActivator = activator; _saleStarConsumedOnInteraction = false; _lastBonusRoll = 0; CharacterBody val = (Object.op_Implicit((Object)(object)activator) ? ((Component)activator).GetComponent<CharacterBody>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.inventory)) { _preInteractionSaleStars = GetTotalSaleStarCount(val.inventory); } else { _preInteractionSaleStars = 0; } } } private static void Patch_PurchaseInteraction_OnInteractionBegin(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0251: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Play_item_proc_lowerPricedChest") })) { int num = -1; ILCursor val2 = new ILCursor(il); val2.Goto(val.Index, (MoveType)0, false); int num3 = default(int); while (val2.TryGotoPrev(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num3) })) { if (val2.Next.OpCode == OpCodes.Stloc || val2.Next.OpCode == OpCodes.Stloc_S || val2.Next.OpCode == OpCodes.Stloc_0 || val2.Next.OpCode == OpCodes.Stloc_1 || val2.Next.OpCode == OpCodes.Stloc_2 || val2.Next.OpCode == OpCodes.Stloc_3) { object operand = val2.Next.Operand; VariableDefinition val3 = (VariableDefinition)((operand is VariableDefinition) ? operand : null); if (val3 != null) { num = ((VariableReference)val3).Index; } else if (operand is int num2) { num = num2; } else if (val2.Next.OpCode == OpCodes.Stloc_0) { num = 0; } else if (val2.Next.OpCode == OpCodes.Stloc_1) { num = 1; } else if (val2.Next.OpCode == OpCodes.Stloc_2) { num = 2; } else if (val2.Next.OpCode == OpCodes.Stloc_3) { num = 3; } if (num >= 0 && num < il.Body.Variables.Count && ((MemberReference)((VariableReference)il.Body.Variables[num]).VariableType).FullName == typeof(int).FullName) { ModLogger.LogInfo((object)$"Dynamically located bonus drop count variable at index {num}."); break; } } } if (num < 0) { num = 16; ModLogger.LogWarning((object)$"Could not dynamically find bonus drop count variable; falling back to index {num}."); } val.MoveAfterLabels(); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc, il.Body.Variables[num]); val.EmitDelegate<Action<PurchaseInteraction, int>>((Action<PurchaseInteraction, int>)delegate(PurchaseInteraction purchaseInteraction, int bonusDrops) { OnSaleStarTriggered(purchaseInteraction, bonusDrops); }); ModLogger.LogInfo((object)"Successfully injected Sale Star Multishop handler into PurchaseInteraction.OnInteractionBegin!"); } else { ModLogger.LogError((object)"Failed to find 'Play_item_proc_lowerPricedChest' instruction in PurchaseInteraction.OnInteractionBegin!"); } } private static void OnSaleStarTriggered(PurchaseInteraction pi, int bonusDrops) { if (Object.op_Implicit((Object)(object)pi)) { _saleStarConsumedOnInteraction = true; _lastBonusRoll = bonusDrops; ShopTerminalBehavior component = ((Component)pi).GetComponent<ShopTerminalBehavior>(); if (Object.op_Implicit((Object)(object)component) && IsMultiShopTerminal(component)) { component.dropAmount = 2 + bonusDrops; ModLogger.LogInfo((object)$"[SaleStarMultishop] Sale Star triggered on terminal {((Object)component).name}! dropAmount set to {component.dropAmount}."); } } } public static UniquePickup RollRandomBonusPickup(ShopTerminalBehavior stb, Xoroshiro128Plus rng) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Invalid comparison between Unknown and I4 //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ab: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Invalid comparison between Unknown and I4 //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Invalid comparison between Unknown and I4 //IL_00ed: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Invalid comparison between Unknown and I4 //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Invalid comparison between Unknown and I4 //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Invalid comparison between Unknown and I4 //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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Invalid comparison between Unknown and I4 //IL_0155: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Invalid comparison between Unknown and I4 //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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) if (Object.op_Implicit((Object)(object)stb.dropTable)) { return stb.dropTable.GeneratePickup(rng); } MultiShopController val = stb.serverMultiShopController ?? ((Component)stb).GetComponentInParent<MultiShopController>(); if (Object.op_Implicit((Object)(object)val) && val.doEquipmentInstead) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableEquipmentDropList)); } PickupDef pickupDef = PickupCatalog.GetPickupDef(stb.CurrentPickup().pickupIndex); if (pickupDef == null || (int)pickupDef.equipmentIndex != -1) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableEquipmentDropList)); } ItemTier itemTier = stb.itemTier; if (Object.op_Implicit((Object)(object)val) && (int)itemTier == 1000) { itemTier = val.itemTier; } if ((int)itemTier == 1) { List<PickupIndex> list = ((rng.nextNormalizedFloat < 0.2f) ? Run.instance.availableTier3DropList : Run.instance.availableTier2DropList); return new UniquePickup(rng.NextElementUniform<PickupIndex>(list)); } if ((int)itemTier == 2) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableTier3DropList)); } if ((int)itemTier == 3) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableLunarCombinedDropList)); } if ((int)itemTier == 6) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableVoidTier1DropList)); } if ((int)itemTier == 7) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableVoidTier2DropList)); } if ((int)itemTier == 8) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableVoidTier3DropList)); } if ((int)itemTier == 9) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableVoidBossDropList)); } if ((int)itemTier == 4) { return new UniquePickup(rng.NextElementUniform<PickupIndex>(Run.instance.availableBossDropList)); } float nextNormalizedFloat = rng.nextNormalizedFloat; List<PickupIndex> list2 = ((nextNormalizedFloat < 0.0099f) ? Run.instance.availableTier3DropList : ((!(nextNormalizedFloat < 0.2079f)) ? Run.instance.availableTier1DropList : Run.instance.availableTier2DropList)); return new UniquePickup(rng.NextElementUniform<PickupIndex>(list2)); } [HarmonyPrefix] [HarmonyPatch(typeof(ShopTerminalBehavior), "DropPickup", new Type[] { typeof(bool) })] private static bool ShopTerminalBehavior_DropPickup_Prefix(ShopTerminalBehavior __instance, bool isDuplicated) { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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_0207: Invalid comparison between Unknown and I4 //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } if (!IsMultiShopTerminal(__instance)) { return true; } bool flag = false; int num = __instance.dropAmount; if (num > 1) { flag = true; } else if ((Object)(object)_lastInteractedTerminal == (Object)(object)((Component)__instance).gameObject && _saleStarConsumedOnInteraction) { flag = true; num = 2 + _lastBonusRoll; } else if ((Object)(object)_lastInteractedTerminal == (Object)(object)((Component)__instance).gameObject && (Object)(object)_currentActivator != (Object)null && _preInteractionSaleStars > 0) { CharacterBody component = ((Component)_currentActivator).GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory) && GetTotalSaleStarCount(component.inventory) < _preInteractionSaleStars) { flag = true; num = 2 + _lastBonusRoll; ModLogger.LogInfo((object)"[SaleStarMultishop] Detected Sale Star consumption via inventory delta!"); } } if (!flag || num <= 1) { return true; } ModLogger.LogInfo((object)$"[SaleStarMultishop] Spawning {num} item droplets for terminal {((Object)__instance).name}!"); if (__instance.debt <= 0) { __instance.debt = 1; } __instance.SetHasBeenPurchased(true); UniquePickup val = __instance.CurrentPickup(); if ((int)__instance.storageType == 3) { val.isRental = true; } Vector3 position = (Object.op_Implicit((Object)(object)__instance.dropTransform) ? __instance.dropTransform : ((Component)__instance).transform).position; Vector3 val2 = ((Component)__instance).transform.TransformVector(__instance.dropVelocity); Xoroshiro128Plus rng = (Xoroshiro128Plus)(ShopRngRef.Invoke(__instance) ?? ((object)(Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.stageRng : null)) ?? ((object)new Xoroshiro128Plus(0uL))); object obj = null; int index = 0; if (ItemQualitiesCompat.IsLoaded) { obj = ItemQualitiesCompat.GenerateQualityDropTiers(((Component)__instance).gameObject, num, rng); if (obj != null) { ModLogger.LogInfo((object)"[SaleStarMultishop] Generated ItemQualities upgrade tiers for extra drops!"); } } float num2 = 20f; float num3 = 0f - (float)(num - 1) * num2 * 0.5f; MultiShopController val3 = __instance.serverMultiShopController ?? ((Component)__instance).GetComponentInParent<MultiShopController>(); int num4; if (!Object.op_Implicit((Object)(object)val3) || !val3.doEquipmentInstead) { PickupDef pickupDef = PickupCatalog.GetPickupDef(val.pickupIndex); num4 = ((pickupDef == null || (int)pickupDef.equipmentIndex != -1) ? 1 : 0); } else { num4 = 1; } bool flag2 = (byte)num4 != 0; for (int i = 0; i < __instance.debt; i++) { for (int j = 0; j < num; j++) { UniquePickup val4 = ((j == 0 || (!ChestStyleBonusDrops.Value && !flag2)) ? val : RollRandomBonusPickup(__instance, rng)); if (obj != null) { val4 = ItemQualitiesCompat.TryUpgradePickupQuality(val4, obj, ref index); } Vector3 val5 = Quaternion.AngleAxis(num3 + (float)j * num2, Vector3.up) * val2; PickupDropletController.CreatePickupDroplet(val4, position, val5, isDuplicated); } } __instance.debt = 0; __instance.dropAmount = 1; return false; } } public static class ItemQualitiesCompat { private static bool _initialized; private static MethodInfo _generateQualityDropTiersMethod; private static MethodInfo _tryUpgradePickupQualityMethod; private static FieldInfo _qualitySaleStarGroupField; private static MethodInfo _getItemCountsEffectiveMethod; private static PropertyInfo _totalCountProperty; public static bool IsLoaded { get; private set; } public static void Init() { if (_initialized) { return; } _initialized = true; try { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (assembly2.GetName().Name == "ItemQualities") { assembly = assembly2; break; } } if (!(assembly == null)) { Type type = assembly.GetType("ItemQualities.Patches.Items.LowerPricedChests"); if (type != null) { _generateQualityDropTiersMethod = type.GetMethod("generateQualityDropTiersFromSaleStars", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _tryUpgradePickupQualityMethod = type.GetMethod("tryUpgradePickupQualityFromSaleStars", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } Type type2 = assembly.GetType("ItemQualities.ItemQualitiesContent+ItemQualityGroups"); if (type2 != null) { _qualitySaleStarGroupField = type2.GetField("LowerPricedChests", BindingFlags.Static | BindingFlags.Public); } Type type3 = assembly.GetType("ItemQualities.ItemQualityGroup"); if (type3 != null) { _getItemCountsEffectiveMethod = type3.GetMethod("GetItemCountsEffective", new Type[1] { typeof(Inventory) }); } Type type4 = assembly.GetType("ItemQualities.ItemQualityCounts"); if (type4 != null) { _totalCountProperty = type4.GetProperty("TotalCount"); } IsLoaded = _generateQualityDropTiersMethod != null && _tryUpgradePickupQualityMethod != null; if (IsLoaded) { SaleStarMultishopPlugin.ModLogger.LogInfo((object)"ItemQualities mod detected and compatibility enabled!"); } } } catch (Exception arg) { SaleStarMultishopPlugin.ModLogger.LogWarning((object)$"Failed to initialize ItemQualities compatibility: {arg}"); } } public static int GetQualitySaleStarCount(Inventory inventory) { if (!_initialized) { Init(); } if (_qualitySaleStarGroupField == null || _getItemCountsEffectiveMethod == null || !Object.op_Implicit((Object)(object)inventory)) { return 0; } try { object value = _qualitySaleStarGroupField.GetValue(null); if (value == null) { return 0; } object obj = _getItemCountsEffectiveMethod.Invoke(value, new object[1] { inventory }); if (obj == null) { return 0; } if (_totalCountProperty != null) { return (int)_totalCountProperty.GetValue(obj); } } catch { } return 0; } public static object GenerateQualityDropTiers(GameObject purchasedObject, int dropCount, Xoroshiro128Plus rng) { if (!IsLoaded || _generateQualityDropTiersMethod == null) { return null; } try { return _generateQualityDropTiersMethod.Invoke(null, new object[4] { purchasedObject, dropCount, false, rng }); } catch (Exception arg) { SaleStarMultishopPlugin.ModLogger.LogError((object)$"Error calling generateQualityDropTiersFromSaleStars: {arg}"); return null; } } public static UniquePickup TryUpgradePickupQuality(UniquePickup pickup, object qualityTiers, ref int index) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!IsLoaded || _tryUpgradePickupQualityMethod == null || qualityTiers == null) { return pickup; } try { object[] array = new object[3] { pickup, qualityTiers, index }; object? obj = _tryUpgradePickupQualityMethod.Invoke(null, array); index = (int)array[2]; return (UniquePickup)obj; } catch (Exception arg) { SaleStarMultishopPlugin.ModLogger.LogError((object)$"Error calling tryUpgradePickupQualityFromSaleStars: {arg}"); return pickup; } } } }