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 ShareItemsWithMoreFun v0.2.0
ShareItemsWithMoreFun.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using EntityStates; using EntityStates.CaptainSupplyDrop; using HG; using On.EntityStates.CaptainSupplyDrop; using On.RoR2; using On.RoR2.Quests.CompulsionQuests; using R2API.Networking; using R2API.Networking.Interfaces; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Artifacts; using RoR2.Orbs; using RoR2.Quests; using RoR2.Quests.CompulsionQuests; using RoR2.UI; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceLocations; [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("ShareItemsWithMoreFun")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+2fc2a1b209c708c592447b9a71b731f3901c9a9f")] [assembly: AssemblyProduct("ShareItemsWithMoreFun")] [assembly: AssemblyTitle("ShareItemsWithMoreFun")] [assembly: AssemblyVersion("0.2.0.0")] namespace ShareItemsWithMoreFun; internal static class ChestHooks { private const float DropDelaySeconds = 0.85f; public static void Install() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown ChestBehavior.Start += new hook_Start(ChestBehavior_Start); OptionChestBehavior.Start += new hook_Start(OptionChestBehavior_Start); PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin); PurchaseInteraction.SetAvailable += new hook_SetAvailable(PurchaseInteraction_SetAvailable); PurchaseInteraction.GetInteractability += new hook_GetInteractability(PurchaseInteraction_GetInteractability); PurchaseInteraction.onPurchaseGlobalServer += OnPurchaseGlobalServer; ChestBehavior.Open += new hook_Open(ChestBehavior_Open); ChestBehavior.OpenAndGrantViaOrb += new hook_OpenAndGrantViaOrb(ChestBehavior_OpenAndGrantViaOrb); ChestBehavior.ItemDrop += new hook_ItemDrop(ChestBehavior_ItemDrop); OptionChestBehavior.Open += new hook_Open(OptionChestBehavior_Open); OptionChestBehavior.ItemDrop += new hook_ItemDrop(OptionChestBehavior_ItemDrop); } private static void ChestBehavior_Start(orig_Start orig, ChestBehavior self) { orig.Invoke(self); if (CanManage(((Component)self).gameObject) && !self.isCommandChest) { ManagedChest managedChest = Setup(((Component)self).gameObject, ModConfig.InstancedChests.Value); if (Object.op_Implicit((Object)(object)managedChest)) { managedChest.chest = self; managedChest.baseDropCount = Math.Max(1, self.dropCount); } } } private static void OptionChestBehavior_Start(orig_Start orig, OptionChestBehavior self) { orig.Invoke(self); if (ModConfig.InstancedChests.Value && CanManage(((Component)self).gameObject)) { ManagedChest managedChest = Setup(((Component)self).gameObject, instanced: true); if (Object.op_Implicit((Object)(object)managedChest)) { managedChest.optionChest = self; } } } private static bool CanManage(GameObject chestObject) { if (NetworkServer.active && ModConfig.Enabled.Value && !DelusionChestController.isDelusionEnable && Object.op_Implicit((Object)(object)Run.instance)) { return ModConfig.IsManagedChestName(((Object)chestObject).name); } return false; } private static ManagedChest Setup(GameObject chestObject, bool instanced) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown PurchaseInteraction component = chestObject.GetComponent<PurchaseInteraction>(); if (!Object.op_Implicit((Object)(object)component)) { return null; } ManagedChest orAdd = ManagedChest.GetOrAdd(chestObject); orAdd.serverManaged = true; orAdd.instanced = instanced; orAdd.remoteOpAllowed = instanced && ModConfig.RemoteOpCanOpenChests.Value; orAdd.purchase = component; orAdd.rng = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong); Plugin.Debug($"Coffre géré : {((Object)chestObject).name} (instancié : {instanced})"); if (instanced) { ChestManagedMessage chestManagedMessage = ChestManagedMessage.For(orAdd); if (chestManagedMessage != null) { NetMessageExtensions.Send((INetMessage)(object)chestManagedMessage, (NetworkDestination)1); } } return orAdd; } private static bool TryGetServerInstanced(Component component, out ManagedChest managed) { managed = (NetworkServer.active ? component.GetComponent<ManagedChest>() : null); if (Object.op_Implicit((Object)(object)managed) && managed.serverManaged && managed.instanced) { return !managed.globallyOpened; } return false; } private static void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (!TryGetServerInstanced((Component)(object)self, out var managed)) { orig.Invoke(self, activator); return; } CharacterMaster val = PlayerResolver.FromInteractor(activator); if (!Object.op_Implicit((Object)(object)val) || managed.HasOpened(((NetworkBehaviour)val).netId)) { return; } if (Object.op_Implicit((Object)(object)managed.chest)) { managed.chest.dropCount = managed.baseDropCount; } managed.purchaseInProgress = true; managed.purchaseSucceeded = false; try { orig.Invoke(self, activator); } finally { managed.purchaseInProgress = false; } if (managed.purchaseSucceeded) { int num = ((!Object.op_Implicit((Object)(object)managed.chest)) ? 1 : Math.Max(1, managed.chest.dropCount)); if (Object.op_Implicit((Object)(object)managed.chest)) { managed.chest.dropCount = managed.baseDropCount; } managed.MarkOpened(((NetworkBehaviour)val).netId); Plugin.Debug($"{((Object)val).name} a ouvert {((Object)self).name} ({num} drop(s))"); NetMessageExtensions.Send((INetMessage)(object)new ChestOpenedMessage(((NetworkBehaviour)self).netId, ((NetworkBehaviour)val).netId, ChestVisual.PlayOpening), (NetworkDestination)1); ((MonoBehaviour)managed).StartCoroutine(DropAfterDelay(managed, val, num)); } } private static void OnPurchaseGlobalServer(PayCostContext context, PayCostResults results) { PurchaseInteraction val = context?.purchaseInteraction; ManagedChest managedChest = default(ManagedChest); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<ManagedChest>(ref managedChest) && managedChest.purchaseInProgress) { managedChest.purchaseSucceeded = true; } } private static IEnumerator DropAfterDelay(ManagedChest managed, CharacterMaster owner, int dropCount) { yield return (object)new WaitForSeconds(0.85f); if (!Object.op_Implicit((Object)(object)managed) || !NetworkServer.active) { yield break; } DropContext dropContext = null; UniquePickup currentPickup; try { if (Object.op_Implicit((Object)(object)managed.chest)) { ChestBehavior chest = managed.chest; currentPickup = chest.currentPickup; if (!((UniquePickup)(ref currentPickup)).isValid) { chest.Roll(); } chest.dropCount = dropCount; managed.allowItemDrop = true; using (dropContext = DropContext.Begin(owner, convertToChoices: true, managed.rng)) { chest.ItemDrop(); yield break; } } if (Object.op_Implicit((Object)(object)managed.optionChest)) { managed.optionChest.Roll(); managed.allowItemDrop = true; using (dropContext = DropContext.Begin(owner, convertToChoices: false, managed.rng)) { managed.optionChest.ItemDrop(); yield break; } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Échec du drop de {((Object)managed).name} : {arg}"); int num = dropContext?.dropletsCreated ?? 0; DropPlainItemsAfterFailure(managed, owner, Object.op_Implicit((Object)(object)managed.chest) ? (dropCount - num) : (1 - num)); } finally { managed.allowItemDrop = false; if (Object.op_Implicit((Object)(object)managed.chest)) { managed.chest.dropCount = managed.baseDropCount; managed.chest.NetworkisChestOpened = false; currentPickup = managed.chest.currentPickup; if (!((UniquePickup)(ref currentPickup)).isValid) { managed.chest.Roll(); } } } } private static void DropPlainItemsAfterFailure(ManagedChest managed, CharacterMaster owner, int missing) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0099: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (missing <= 0) { return; } try { if (Object.op_Implicit((Object)(object)managed.optionChest)) { managed.allowItemDrop = true; using (DropContext.Begin(owner, convertToChoices: false, null)) { managed.optionChest.ItemDrop(); return; } } ChestBehavior chest = managed.chest; if (!Object.op_Implicit((Object)(object)chest) || !Object.op_Implicit((Object)(object)chest.dropTransform)) { return; } Vector3 val = chest.dropTransform.position + Vector3.up * 1.5f; Vector3 val2 = Vector3.up * chest.dropUpVelocityStrength + chest.dropTransform.forward * chest.dropForwardVelocityStrength; Quaternion val3 = Quaternion.AngleAxis(360f / (float)missing, Vector3.up); using (DropContext.Begin(owner, convertToChoices: false, null)) { for (int i = 0; i < missing; i++) { UniquePickup currentPickup = chest.currentPickup; if (!((UniquePickup)(ref currentPickup)).isValid) { chest.Roll(); } currentPickup = chest.currentPickup; if (!((UniquePickup)(ref currentPickup)).isValid) { break; } PickupDropletController.CreatePickupDroplet(chest.currentPickup, val, val2, false); val2 = val3 * val2; chest.Roll(); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"Le drop de secours a aussi échoué : {arg}"); } } private static void PurchaseInteraction_SetAvailable(orig_SetAvailable orig, PurchaseInteraction self, bool newAvailable) { if (newAvailable || !TryGetServerInstanced((Component)(object)self, out var managed) || !managed.purchaseInProgress) { orig.Invoke(self, newAvailable); } } private static void ChestBehavior_Open(orig_Open orig, ChestBehavior self) { if (TryGetServerInstanced((Component)(object)self, out var managed)) { if (managed.purchaseInProgress) { return; } managed.globallyOpened = true; Plugin.Debug(((Object)self).name + " ouvert hors achat : retour au comportement vanilla"); } orig.Invoke(self); } private static void ChestBehavior_OpenAndGrantViaOrb(orig_OpenAndGrantViaOrb orig, ChestBehavior self, Interactor interactor) { if (TryGetServerInstanced((Component)(object)self, out var managed)) { if (managed.purchaseInProgress) { return; } managed.globallyOpened = true; } orig.Invoke(self, interactor); } private static void OptionChestBehavior_Open(orig_Open orig, OptionChestBehavior self) { if (TryGetServerInstanced((Component)(object)self, out var managed)) { if (managed.purchaseInProgress) { return; } managed.globallyOpened = true; } orig.Invoke(self); } private static void ChestBehavior_ItemDrop(orig_ItemDrop orig, ChestBehavior self) { ManagedChest managedChest = (NetworkServer.active ? ((Component)self).GetComponent<ManagedChest>() : null); if (!Object.op_Implicit((Object)(object)managedChest) || !managedChest.serverManaged || managedChest.globallyOpened) { orig.Invoke(self); return; } if (managedChest.instanced) { if (managedChest.allowItemDrop) { managedChest.allowItemDrop = false; orig.Invoke(self); } return; } using (DropContext.Begin(PlayerResolver.FromInteractor(Object.op_Implicit((Object)(object)managedChest.purchase) ? managedChest.purchase.lastActivator : null), convertToChoices: true, managedChest.rng)) { orig.Invoke(self); } } private static void OptionChestBehavior_ItemDrop(orig_ItemDrop orig, OptionChestBehavior self) { ManagedChest managedChest = (NetworkServer.active ? ((Component)self).GetComponent<ManagedChest>() : null); if (Object.op_Implicit((Object)(object)managedChest) && managedChest.serverManaged && managedChest.instanced && !managedChest.globallyOpened) { if (managedChest.allowItemDrop) { managedChest.allowItemDrop = false; orig.Invoke(self); } } else { orig.Invoke(self); } } private static Interactability PurchaseInteraction_GetInteractability(orig_GetInteractability orig, PurchaseInteraction self, Interactor activator) { //IL_0003: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0020: 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_0045: Unknown result type (might be due to invalid IL or missing references) Interactability val = orig.Invoke(self, activator); ManagedChest component = ((Component)self).GetComponent<ManagedChest>(); if ((int)val == 0 && RemoteOperation.CanOpenChest(self, component, activator)) { val = RemoteOperation.EvaluateAsAllowed(self, activator, orig); } if ((int)val == 0) { return val; } bool alreadyOpened = default(bool); if (Object.op_Implicit((Object)(object)component) && component.IsInstancedFor(activator, out alreadyOpened) && alreadyOpened) { return (Interactability)0; } return val; } } internal static class ChoiceBuilder { public static bool TryConvert(ref CreatePickupInfo info, Xoroshiro128Plus rng) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_006c: 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_00b6: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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) UniquePickup pickup = ((CreatePickupInfo)(ref info)).pickup; PickupDef def = (((UniquePickup)(ref pickup)).isValid ? PickupCatalog.GetPickupDef(pickup.pickupIndex) : null); string text = QualityKey(def); if (text == null || !Object.op_Implicit((Object)(object)Run.instance)) { return false; } if (rng == null) { rng = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong); } PickupDropTable table = (Object.op_Implicit((Object)(object)info.chest) ? info.chest.dropTable : null); List<PickupIndex> list = CollectCandidates(pickup, text, table, onlyTableLists: true); if (list.Count == 0) { list = CollectCandidates(pickup, text, table, onlyTableLists: false); } int num = Math.Min(ModConfig.ChoiceCount.Value - 1, list.Count); if (num < 1) { return false; } List<UniquePickup> list2 = new List<UniquePickup>(num + 1) { pickup }; for (int i = 0; i < num; i++) { int num2 = rng.RangeInt(i, list.Count); List<PickupIndex> list3 = list; int index = i; List<PickupIndex> list4 = list; int index2 = num2; PickupIndex value = list[num2]; PickupIndex value2 = list[i]; list3[index] = value; list4[index2] = value2; list2.Add(((UniquePickup)(ref pickup)).WithPickupIndex(list[i])); } for (int num3 = list2.Count - 1; num3 > 0; num3--) { int num4 = rng.RangeInt(0, num3 + 1); List<UniquePickup> list5 = list2; int index2 = num3; int index = num4; UniquePickup value3 = list2[num4]; UniquePickup value4 = list2[num3]; list5[index2] = value3; list2[index] = value4; } GameObject val = OptionPickupPrefab.Get(); if (!Object.op_Implicit((Object)(object)val)) { return false; } info.pickerOptions = PickupPickerController.GenerateOptionsFromList<List<UniquePickup>>(list2); info.maxOptionCount = 1; info.prefabOverride = val; ((CreatePickupInfo)(ref info)).pickup = DisplayPickup(pickup, def); Plugin.Debug($"Orbe : {list2.Count} choix de qualité {text}"); return true; } private static string QualityKey(PickupDef def) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_002b: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected I4, but got Unknown if (def == null) { return null; } if ((int)def.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(def.itemIndex); if (!Object.op_Implicit((Object)(object)itemDef)) { return null; } if ((int)itemDef.tier != 3) { return "item:" + (int)itemDef.tier; } return "lunar"; } if ((int)def.equipmentIndex != -1) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(def.equipmentIndex); if (!Object.op_Implicit((Object)(object)equipmentDef)) { return null; } if (equipmentDef.isLunar) { return "lunar"; } if (!equipmentDef.isBoss) { return "equipment"; } return "equipment:boss"; } return null; } private static List<PickupIndex> CollectCandidates(UniquePickup rolled, string quality, PickupDropTable table, bool onlyTableLists) { //IL_000c: 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_0087: 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_008f: 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_00bf: 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_00c8: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = new List<PickupIndex>(); HashSet<PickupIndex> hashSet = new HashSet<PickupIndex> { rolled.pickupIndex }; BasicPickupDropTable val = (BasicPickupDropTable)(object)((table is BasicPickupDropTable) ? table : null); bool flag = Object.op_Implicit((Object)(object)val) && val.IsFilterRequired(); foreach (var (list2, num) in DropLists(Run.instance, val)) { if (list2 == null || (onlyTableLists && Object.op_Implicit((Object)(object)val) && num <= 0f)) { continue; } foreach (PickupIndex item in list2) { if (hashSet.Add(item)) { PickupDef pickupDef = PickupCatalog.GetPickupDef(item); if (!(QualityKey(pickupDef) != quality) && (!flag || val.PassesFilter(item)) && AllowsStorageFlags(pickupDef, rolled)) { list.Add(item); } } } } return list; } private static IEnumerable<(List<PickupIndex>, float)> DropLists(Run run, BasicPickupDropTable t) { bool b = Object.op_Implicit((Object)(object)t); yield return (run.availableTier1DropList, b ? t.tier1Weight : 1f); yield return (run.availableTier2DropList, b ? t.tier2Weight : 1f); yield return (run.availableTier3DropList, b ? t.tier3Weight : 1f); yield return (run.availableBossDropList, b ? t.bossWeight : 1f); yield return (run.availableLunarItemDropList, b ? t.lunarItemWeight : 1f); yield return (run.availableLunarEquipmentDropList, b ? t.lunarEquipmentWeight : 1f); yield return (run.availableLunarCombinedDropList, b ? t.lunarCombinedWeight : 1f); yield return (run.availableEquipmentDropList, b ? t.equipmentWeight : 1f); yield return (run.availableVoidTier1DropList, b ? t.voidTier1Weight : 1f); yield return (run.availableVoidTier2DropList, b ? t.voidTier2Weight : 1f); yield return (run.availableVoidTier3DropList, b ? t.voidTier3Weight : 1f); yield return (run.availableVoidBossDropList, b ? t.voidBossWeight : 1f); yield return (run.availableFoodTierDropList, b ? t.foodTierWeight : 1f); yield return (run.availablePowerShapeItemsDropList, b ? t.powerShapesWeight : 1f); yield return (run.availableCursedTierDropList, b ? t.cursedWeight : 1f); yield return (run.availableHexTierDropList, b ? t.hexWeight : 1f); yield return (run.availablePageTierDropList, b ? t.pageWeight : 1f); } private static bool AllowsStorageFlags(PickupDef def, UniquePickup rolled) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) if ((int)def.itemIndex == -1) { if (!((UniquePickup)(ref rolled)).isTempItem) { return !rolled.isRental; } return false; } ItemDef itemDef = ItemCatalog.GetItemDef(def.itemIndex); if (((UniquePickup)(ref rolled)).isTempItem && !itemDef.ContainsTag((ItemTag)31)) { return false; } if (rolled.isRental && !itemDef.ContainsTag((ItemTag)40)) { return false; } return true; } private static UniquePickup DisplayPickup(UniquePickup rolled, PickupDef def) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0051: 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_004d: Unknown result type (might be due to invalid IL or missing references) ItemTier val; if ((int)def.itemIndex != -1) { val = ItemCatalog.GetItemDef(def.itemIndex).tier; } else { if ((int)def.equipmentIndex == -1 || !EquipmentCatalog.GetEquipmentDef(def.equipmentIndex).isLunar) { return rolled; } val = (ItemTier)3; } PickupIndex val2 = PickupCatalog.FindPickupIndex(val); if (!((PickupIndex)(ref val2)).isValid) { return rolled; } return ((UniquePickup)(ref rolled)).WithPickupIndex(val2); } } internal static class ClientHooks { public static void Install() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown PurchaseInteraction.ShouldDisplayHologram += new hook_ShouldDisplayHologram(PurchaseInteraction_ShouldDisplayHologram); PurchaseInteraction.ShouldShowOnScanner += new hook_ShouldShowOnScanner(PurchaseInteraction_ShouldShowOnScanner); PurchaseInteraction.ShouldProximityHighlight += new hook_ShouldProximityHighlight(PurchaseInteraction_ShouldProximityHighlight); PickupPickerController.ShouldShowOnScanner += new hook_ShouldShowOnScanner(PickupPickerController_ShouldShowOnScanner); GenericPickupController.ShouldShowOnScanner += new hook_ShouldShowOnScanner(GenericPickupController_ShouldShowOnScanner); } private static bool PurchaseInteraction_ShouldDisplayHologram(orig_ShouldDisplayHologram orig, PurchaseInteraction self, GameObject viewer) { if (orig.Invoke(self, viewer)) { return !OpenedForLocalView(self, viewer); } return false; } private static bool PurchaseInteraction_ShouldShowOnScanner(orig_ShouldShowOnScanner orig, PurchaseInteraction self) { if (orig.Invoke(self)) { return !OpenedForLocalView(self, null); } return false; } private static bool PurchaseInteraction_ShouldProximityHighlight(orig_ShouldProximityHighlight orig, PurchaseInteraction self) { if (orig.Invoke(self)) { return !OpenedForLocalView(self, null); } return false; } private static bool PickupPickerController_ShouldShowOnScanner(orig_ShouldShowOnScanner orig, PickupPickerController self) { if (orig.Invoke(self)) { return !HiddenLocally((Component)(object)self); } return false; } private static bool GenericPickupController_ShouldShowOnScanner(orig_ShouldShowOnScanner orig, GenericPickupController self) { if (orig.Invoke(self)) { return !HiddenLocally((Component)(object)self); } return false; } private static bool HiddenLocally(Component component) { OwnedObject component2 = component.GetComponent<OwnedObject>(); if (Object.op_Implicit((Object)(object)component2)) { return component2.ShouldHideLocally(); } return false; } private static bool OpenedForLocalView(PurchaseInteraction purchase, GameObject viewer) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) ManagedChest component = ((Component)purchase).GetComponent<ManagedChest>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } CharacterMaster val = (Object.op_Implicit((Object)(object)viewer) ? PlayerResolver.FromBody(viewer.GetComponent<CharacterBody>()) : null); if (Object.op_Implicit((Object)(object)val) && PlayerResolver.IsLocalPlayer(((NetworkBehaviour)val).netId)) { if (component.instanced && !component.globallyOpened) { return component.HasOpened(((NetworkBehaviour)val).netId); } return false; } return component.OpenedByAnyLocalPlayer(); } } internal static class ClientVisuals { private sealed class AnimatorBridge : EntityState { public static bool Play(Animator animator, string layer, string state, string playbackRateParam, float duration) { if (!HasState(animator, layer, state)) { return false; } EntityState.PlayAnimationOnAnimator(animator, layer, state, playbackRateParam, duration, 0f); return true; } public static bool Play(Animator animator, string layer, string state) { if (!HasState(animator, layer, state)) { return false; } EntityState.PlayAnimationOnAnimator(animator, layer, state); return true; } private static bool HasState(Animator animator, string layer, string state) { int layerIndex = animator.GetLayerIndex(layer); if (layerIndex >= 0) { return animator.HasState(layerIndex, Animator.StringToHash(state)); } return false; } } private const float OpeningSeconds = 1f; public static void PlayLocalOpening(GameObject chestObject) { ManagedChest component = chestObject.GetComponent<ManagedChest>(); if (Object.op_Implicit((Object)(object)component)) { component.localOpenedShown = true; } Animator val = FindAnimator(chestObject); if (Object.op_Implicit((Object)(object)val) && AnimatorBridge.Play(val, "Body", "Opening", "Opening.playbackRate", 1f) && Object.op_Implicit((Object)(object)component)) { ((MonoBehaviour)component).StartCoroutine(FinishOpening(val)); } SfxLocator component2 = chestObject.GetComponent<SfxLocator>(); if (Object.op_Implicit((Object)(object)component2) && !string.IsNullOrEmpty(component2.openSound)) { Util.PlaySound(component2.openSound, chestObject); } } public static void ShowOpened(GameObject chestObject) { ManagedChest component = chestObject.GetComponent<ManagedChest>(); if (Object.op_Implicit((Object)(object)component)) { component.localOpenedShown = true; } Animator val = FindAnimator(chestObject); if (Object.op_Implicit((Object)(object)val)) { AnimatorBridge.Play(val, "Body", "Opened"); } } private static Animator FindAnimator(GameObject chestObject) { ModelLocator component = chestObject.GetComponent<ModelLocator>(); Transform val = (Object.op_Implicit((Object)(object)component) ? component.modelTransform : null); if (!Object.op_Implicit((Object)(object)val)) { return null; } return ((Component)val).GetComponent<Animator>(); } private static IEnumerator FinishOpening(Animator animator) { yield return (object)new WaitForSeconds(1f); if (Object.op_Implicit((Object)(object)animator)) { AnimatorBridge.Play(animator, "Body", "Opened"); } } } internal static class CompatHooks { private sealed class BeaconScope : IDisposable { private readonly bool previousActive; private readonly CharacterMaster previousOwner; private readonly Interactor previousInteractor; public BeaconScope(CharacterMaster owner, Interactor interactor) { previousActive = beaconContextActive; previousOwner = beaconOwner; previousInteractor = beaconInteractor; beaconContextActive = true; beaconOwner = owner; beaconInteractor = interactor; } public void Dispose() { beaconContextActive = previousActive; beaconOwner = previousOwner; beaconInteractor = previousInteractor; } } private static bool beaconContextActive; private static CharacterMaster beaconOwner; private static Interactor beaconInteractor; public static void Install() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown UnlockTargetState.OnEnter += new hook_OnEnter(UnlockTargetState_OnEnter); HackingMainState.FixedUpdate += new hook_FixedUpdate(HackingMainState_FixedUpdate); HackingInProgressState.FixedUpdate += new hook_FixedUpdate(HackingInProgressState_FixedUpdate); HackingMainState.PurchaseInteractionIsValidTarget += new hook_PurchaseInteractionIsValidTarget(PurchaseInteractionIsValidTarget); CompulsionQuestCloakedChest.EnsureCloakedChestExists += new hook_EnsureCloakedChestExists(EnsureCloakedChestExists); } private static bool IsServerInstanced(Component component, out ManagedChest managed) { managed = (Object.op_Implicit((Object)(object)component) ? component.GetComponent<ManagedChest>() : null); if (NetworkServer.active && Object.op_Implicit((Object)(object)managed) && managed.serverManaged && managed.instanced) { return !managed.globallyOpened; } return false; } private static void UnlockTargetState_OnEnter(orig_OnEnter orig, UnlockTargetState self) { PurchaseInteraction target = self.target; int num = (Object.op_Implicit((Object)(object)target) ? target.cost : 0); orig.Invoke(self); if (num > 0 && Object.op_Implicit((Object)(object)target) && target.cost == 0 && IsServerInstanced((Component)(object)target, out var _)) { target.Networkcost = num; } } private static void HackingMainState_FixedUpdate(orig_FixedUpdate orig, HackingMainState self) { using (BeaconContext((EntityState)(object)self)) { orig.Invoke(self); } } private static void HackingInProgressState_FixedUpdate(orig_FixedUpdate orig, HackingInProgressState self) { using (BeaconContext((EntityState)(object)self)) { orig.Invoke(self); } } private static bool PurchaseInteractionIsValidTarget(orig_PurchaseInteractionIsValidTarget orig, PurchaseInteraction purchaseInteraction) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 bool flag = orig.Invoke(purchaseInteraction); if (flag && beaconContextActive && IsServerInstanced((Component)(object)purchaseInteraction, out var _)) { if (Object.op_Implicit((Object)(object)beaconOwner) && Object.op_Implicit((Object)(object)beaconInteractor)) { return (int)purchaseInteraction.GetInteractability(beaconInteractor) > 0; } return false; } return flag; } private static IDisposable BeaconContext(EntityState state) { GameObject val = (Object.op_Implicit((Object)(object)state.outer) ? ((Component)state.outer).gameObject : null); GenericOwnership val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<GenericOwnership>() : null); GameObject val3 = (Object.op_Implicit((Object)(object)val2) ? val2.ownerObject : null); CharacterMaster owner = PlayerResolver.FromBody(Object.op_Implicit((Object)(object)val3) ? val3.GetComponent<CharacterBody>() : null); Interactor interactor = (Object.op_Implicit((Object)(object)val3) ? val3.GetComponent<Interactor>() : null); return new BeaconScope(owner, interactor); } private static void EnsureCloakedChestExists(orig_EnsureCloakedChestExists orig, CompulsionQuestCloakedChest self) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_0036: 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_0096: Unknown result type (might be due to invalid IL or missing references) CompulsionQuestTracker val = (Object.op_Implicit((Object)(object)((BaseQuest)self).runner) ? ((Component)((BaseQuest)self).runner).GetComponent<CompulsionQuestTracker>() : null); TeamIndex team = (TeamIndex)((!Object.op_Implicit((Object)(object)val) || (int)val.participatingTeamIndex == -1) ? 1 : ((int)val.participatingTeamIndex)); CharacterMaster questOwner = (Object.op_Implicit((Object)(object)val) ? PlayerResolver.FromBody(val.questOwnerCharacterBody) : null); List<ChestBehavior> list = new List<ChestBehavior>(); foreach (ChestBehavior instances in InstanceTracker.GetInstancesList<ChestBehavior>()) { if (Object.op_Implicit((Object)(object)instances) && ((Object)instances).name.IndexOf("Stealthed", StringComparison.OrdinalIgnoreCase) >= 0 && IsServerInstanced((Component)(object)instances, out var managed) && !AnyPlayerCanStillOpen(managed, team, questOwner)) { list.Add(instances); } } List<ChestBehavior> list2 = new List<ChestBehavior>(); try { foreach (ChestBehavior item in list) { InstanceTracker.Remove<ChestBehavior>(item); list2.Add(item); } orig.Invoke(self); } finally { foreach (ChestBehavior item2 in list2) { if (Object.op_Implicit((Object)(object)item2)) { InstanceTracker.Add<ChestBehavior>(item2); } } } } private static bool AnyPlayerCanStillOpen(ManagedChest managed, TeamIndex team, CharacterMaster questOwner) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0098: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)questOwner) && managed.HasOpened(((NetworkBehaviour)questOwner).netId)) { return false; } foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (Object.op_Implicit((Object)(object)instance) && instance.isConnected) { CharacterMaster master = instance.master; CharacterBody val = (Object.op_Implicit((Object)(object)master) ? master.GetBody() : null); bool flag = Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive; if (Object.op_Implicit((Object)(object)master) && master.teamIndex == team && flag && !managed.HasOpened(((NetworkBehaviour)master).netId)) { return true; } } } return false; } } internal static class Conflicts { private static readonly string[] KnownConflicts = new string[8] { "ThreeChoiceChests", "ItemShare", "ShareSuite", "InstancedLoot", "ArtifactOfPotential", "Artifact of Potential", "Equilibrium", "CatchupLoot" }; public static void WarnAboutKnownConflicts() { List<string> list = new List<string>(); foreach (PluginInfo value2 in Chainloader.PluginInfos.Values) { string text = value2.Metadata.GUID ?? string.Empty; string text2 = value2.Metadata.Name ?? string.Empty; if (text == "com.shareitemswithmorefun") { continue; } string[] knownConflicts = KnownConflicts; foreach (string value in knownConflicts) { if (text2.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(text2 + " (" + text + ")"); break; } } } if (list.Count > 0) { Plugin.Log.LogWarning((object)("Mods qui modifient aussi les coffres ou le partage du butin : " + string.Join(", ", list) + ". Butin en double ou comportements étranges possibles : désactivez-les avec ShareItemsWithMoreFun.")); } } } internal static class DifficultyFreeze { private static GameObject freezeObject; public static bool IsFrozen => Object.op_Implicit((Object)(object)freezeObject); public static float FrozenStopwatch { get; private set; } public static int FrozenStageClearCount { get; private set; } public static void FreezeServer() { if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance) && !IsFrozen && Apply(Run.instance.GetRunStopwatch(), Run.instance.stageClearCount)) { NetMessageExtensions.Send((INetMessage)(object)new DifficultyFreezeMessage(frozen: true, FrozenStopwatch, FrozenStageClearCount), (NetworkDestination)1); Plugin.Debug($"Téléporteur chargé : difficulté figée à {FrozenStopwatch:0} s"); } } public static void ReleaseServer() { if (NetworkServer.active && IsFrozen) { Release(); NetMessageExtensions.Send((INetMessage)(object)new DifficultyFreezeMessage(frozen: false, 0f, 0), (NetworkDestination)1); Plugin.Debug("Difficulté relâchée"); } } public static bool Apply(float stopwatch, int stageClearCount) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Release(); if (InstanceTracker.GetInstancesList<OverrideDifficultyArgs>().Count > 0) { return false; } FrozenStopwatch = stopwatch; FrozenStageClearCount = stageClearCount; freezeObject = new GameObject("ShareItemsWithMoreFun_DifficultyFreeze"); freezeObject.SetActive(false); OverrideDifficultyArgs obj = freezeObject.AddComponent<OverrideDifficultyArgs>(); obj.timeOverrideValue = Mathf.Max(0f, stopwatch); obj.stageClearCountOverrideValue = Mathf.Max(0, stageClearCount); freezeObject.SetActive(true); return true; } public static void Release() { if (Object.op_Implicit((Object)(object)freezeObject)) { freezeObject.SetActive(false); Object.Destroy((Object)(object)freezeObject); } freezeObject = null; } } internal class DifficultyFreezeMessage : INetMessage, ISerializableObject { private bool frozen; private float stopwatch; private int stageClearCount; public DifficultyFreezeMessage() { } public DifficultyFreezeMessage(bool frozen, float stopwatch, int stageClearCount) { this.frozen = frozen; this.stopwatch = stopwatch; this.stageClearCount = stageClearCount; } public void Serialize(NetworkWriter writer) { writer.Write(frozen); writer.Write(stopwatch); writer.Write(stageClearCount); } public void Deserialize(NetworkReader reader) { frozen = reader.ReadBoolean(); stopwatch = reader.ReadSingle(); stageClearCount = reader.ReadInt32(); } public void OnReceived() { if (!NetworkServer.active) { if (frozen) { DifficultyFreeze.Apply(stopwatch, stageClearCount); } else { DifficultyFreeze.Release(); } } } } internal sealed class DropContext : IDisposable { public readonly CharacterMaster owner; public readonly bool convertToChoices; public readonly Xoroshiro128Plus rng; public int dropletsCreated; private readonly DropContext previous; private readonly List<GameObject> tagged = new List<GameObject>(); public static DropContext Current { get; private set; } private DropContext(CharacterMaster owner, bool convertToChoices, Xoroshiro128Plus rng, DropContext previous) { this.owner = owner; this.convertToChoices = convertToChoices; this.rng = rng; this.previous = previous; } public static DropContext Begin(CharacterMaster owner, bool convertToChoices, Xoroshiro128Plus rng) { Current = new DropContext(owner, convertToChoices, rng, Current); return Current; } public void Tag(GameObject gameObject) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)gameObject)) { OwnedObject.GetOrAdd(gameObject).SetOwnerServer(((NetworkBehaviour)owner).netId, ModConfig.ReserveOrbs.Value, ModConfig.HideOtherPlayersOrbs.Value, ModConfig.RemoteOpCanOpenChests.Value); tagged.Add(gameObject); } } public void Dispose() { Current = previous; foreach (GameObject item in tagged) { if (Object.op_Implicit((Object)(object)item)) { try { OwnerMessage.Broadcast(item); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } tagged.Clear(); } } internal static class Grant { private static readonly FieldInfo PickupConsumedField = typeof(GenericPickupController).GetField("onPickupConsumed", BindingFlags.Static | BindingFlags.NonPublic); public static bool ToMaster(CharacterMaster master, UniquePickup pickup, Vector3 origin) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Invalid comparison between Unknown and I4 //IL_0078: 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_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) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01e1: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); CharacterBody val = (Object.op_Implicit((Object)(object)master) ? master.GetBody() : null); if (pickupDef == null || pickupDef.attemptGrant == null || !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)master.inventory)) { return false; } bool flag = (int)pickupDef.itemIndex != -1; bool flag2 = (int)pickupDef.equipmentIndex != -1; if (!flag && !flag2) { return false; } if (flag2 && val.isRemoteOp) { PendingEquipment.Add(master, pickup); return true; } GrantContext val2 = new GrantContext { body = val, controller = null }; ((GrantContext)(ref val2)).pickup = pickup; val2.position = origin; val2.rotation = Quaternion.identity; GrantContext val3 = val2; pickupDef.attemptGrant.Invoke(ref val3); val.OnPickup((PickupClass)(((UniquePickup)(ref pickup)).isTempItem ? 2 : 3)); if (val3.shouldNotify) { GenericPickupController.SendPickupMessage(master, pickup); } if (val3.shouldDestroy) { RaisePickupConsumed(val, pickup); } if (flag) { DispatchArgs val4 = new DispatchArgs { inventoryToGrantTo = master.inventory, itemIndex = pickupDef.itemIndex, origin = origin, permanentCount = 0, temporaryCount = 0f, rentalCount = 0, travelDuration = 1f, isPickup = false, onArrivalBehavior = delegate { } }; NetworkIdentity networkIdentity = val.networkIdentity; val4.orbDestinationOverride = Either<NetworkIdentity, HurtBox>.op_Implicit(ref networkIdentity); ItemTransferOrb.DispatchItemTransferOrb(val4); } else if (!val3.shouldDestroy) { UniquePickup pickup2 = ((GrantContext)(ref val3)).pickup; if (((UniquePickup)(ref pickup2)).isValid) { UniquePickup pickup3 = ((GrantContext)(ref val3)).pickup; pickup3.ignoreArtifactBasedPickupReplacements = true; using (DropContext.Begin(master, convertToChoices: false, null)) { PickupDropletController.CreatePickupDroplet(pickup3, origin + Vector3.up, Vector3.up * 15f, false); } } } return true; } private static void RaisePickupConsumed(CharacterBody body, UniquePickup pickup) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) try { (PickupConsumedField?.GetValue(null) as Action<CharacterBody, UniquePickup>)?.Invoke(body, pickup); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class LateJoinSync { public static void Install() { NetworkUser.onNetworkUserLoadedSceneServer += OnNetworkUserLoadedScene; } private static void OnNetworkUserLoadedScene(NetworkUser networkUser) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) if (!NetworkServer.active || !Object.op_Implicit((Object)(object)networkUser) || ((NetworkBehaviour)networkUser).isLocalPlayer) { return; } NetworkConnection connectionToClient = ((NetworkBehaviour)networkUser).connectionToClient; if (connectionToClient == null || NetworkServer.localConnections.Contains(connectionToClient)) { return; } int num = 0; if (DifficultyFreeze.IsFrozen) { NetMessageExtensions.Send((INetMessage)(object)new DifficultyFreezeMessage(frozen: true, DifficultyFreeze.FrozenStopwatch, DifficultyFreeze.FrozenStageClearCount), connectionToClient); num++; } foreach (ManagedChest item in new List<ManagedChest>(ManagedChest.Instances)) { if (!Object.op_Implicit((Object)(object)item) || !item.serverManaged || !item.instanced || item.globallyOpened || !Object.op_Implicit((Object)(object)item.purchase)) { continue; } ChestManagedMessage chestManagedMessage = ChestManagedMessage.For(item); if (chestManagedMessage != null) { NetMessageExtensions.Send((INetMessage)(object)chestManagedMessage, connectionToClient); num++; } foreach (NetworkInstanceId item2 in item.OpenedBy) { NetMessageExtensions.Send((INetMessage)(object)new ChestOpenedMessage(((NetworkBehaviour)item.purchase).netId, item2, ChestVisual.ShowOpened), connectionToClient); num++; } } foreach (OwnedObject item3 in new List<OwnedObject>(OwnedObject.Instances)) { OwnerMessage ownerMessage = (Object.op_Implicit((Object)(object)item3) ? OwnerMessage.For(((Component)item3).gameObject) : null); if (ownerMessage != null) { NetMessageExtensions.Send((INetMessage)(object)ownerMessage, connectionToClient); num++; } } Plugin.Debug($"État envoyé à {networkUser.userName} ({num} message(s))"); } } internal class ManagedChest : MonoBehaviour { public static readonly HashSet<ManagedChest> Instances = new HashSet<ManagedChest>(); public bool instanced; public bool serverManaged; public bool globallyOpened; public bool remoteOpAllowed; public ChestBehavior chest; public OptionChestBehavior optionChest; public PurchaseInteraction purchase; public int baseDropCount = 1; public Xoroshiro128Plus rng; public bool purchaseInProgress; public bool purchaseSucceeded; public bool allowItemDrop; public bool localOpenedShown; private readonly HashSet<NetworkInstanceId> openedBy = new HashSet<NetworkInstanceId>(); public IEnumerable<NetworkInstanceId> OpenedBy => openedBy; public bool IsInstancedFor(Interactor activator, out bool alreadyOpened) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) alreadyOpened = false; if (!instanced || globallyOpened) { return false; } CharacterMaster val = PlayerResolver.FromInteractor(activator); alreadyOpened = !Object.op_Implicit((Object)(object)val) || openedBy.Contains(((NetworkBehaviour)val).netId); return true; } public bool HasOpened(NetworkInstanceId masterId) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return openedBy.Contains(masterId); } public void MarkOpened(NetworkInstanceId masterId) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) openedBy.Add(masterId); } public bool OpenedByAnyLocalPlayer() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!instanced || globallyOpened) { return false; } foreach (NetworkInstanceId item in openedBy) { if (PlayerResolver.IsLocalPlayer(item)) { return true; } } return false; } public static ManagedChest GetOrAdd(GameObject chestObject) { ManagedChest component = chestObject.GetComponent<ManagedChest>(); if (!Object.op_Implicit((Object)(object)component)) { return chestObject.AddComponent<ManagedChest>(); } return component; } private void OnEnable() { Instances.Add(this); } private void OnDisable() { Instances.Remove(this); } } internal enum ChestVisual : byte { None, PlayOpening, ShowOpened } internal class ChestManagedMessage : INetMessage, ISerializableObject { private NetworkInstanceId chestId; private bool remoteOpAllowed; public static ChestManagedMessage For(ManagedChest managed) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_003d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)managed) && Object.op_Implicit((Object)(object)managed.purchase)) { NetworkInstanceId netId = ((NetworkBehaviour)managed.purchase).netId; if (!((NetworkInstanceId)(ref netId)).IsEmpty()) { return new ChestManagedMessage { chestId = ((NetworkBehaviour)managed.purchase).netId, remoteOpAllowed = managed.remoteOpAllowed }; } } return null; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(chestId); writer.Write(remoteOpAllowed); } public void Deserialize(NetworkReader reader) { //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) chestId = reader.ReadNetworkId(); remoteOpAllowed = reader.ReadBoolean(); } public void OnReceived() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { bool allowed = remoteOpAllowed; NetworkLookups.WhenFound(chestId, delegate(GameObject chestObject) { ManagedChest orAdd = ManagedChest.GetOrAdd(chestObject); orAdd.instanced = true; orAdd.remoteOpAllowed = allowed; }); } } } internal class ChestOpenedMessage : INetMessage, ISerializableObject { private NetworkInstanceId chestId; private NetworkInstanceId playerId; private ChestVisual visual; public ChestOpenedMessage() { } public ChestOpenedMessage(NetworkInstanceId chestId, NetworkInstanceId playerId, ChestVisual visual) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) this.chestId = chestId; this.playerId = playerId; this.visual = visual; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) writer.Write(chestId); writer.Write(playerId); writer.Write((byte)visual); } public void Deserialize(NetworkReader reader) { //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_000e: 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) chestId = reader.ReadNetworkId(); playerId = reader.ReadNetworkId(); visual = (ChestVisual)reader.ReadByte(); } public void OnReceived() { //IL_0008: 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_001f: Unknown result type (might be due to invalid IL or missing references) NetworkInstanceId player = playerId; ChestVisual chestVisual = visual; NetworkLookups.WhenFound(chestId, delegate(GameObject chestObject) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) ManagedChest orAdd = ManagedChest.GetOrAdd(chestObject); orAdd.instanced = true; bool flag = !orAdd.HasOpened(player); orAdd.MarkOpened(player); if (PlayerResolver.IsLocalPlayer(player)) { if (chestVisual == ChestVisual.PlayOpening) { ClientVisuals.PlayLocalOpening(chestObject); } else if (chestVisual == ChestVisual.ShowOpened && (flag || !orAdd.localOpenedShown)) { ClientVisuals.ShowOpened(chestObject); } } }); } } internal class OwnerMessage : INetMessage, ISerializableObject { private NetworkInstanceId objectId; private NetworkInstanceId ownerId; private bool reserve; private bool hide; private bool remoteOpAllowed; public OwnerMessage() { } private OwnerMessage(NetworkInstanceId objectId, OwnedObject owned) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) this.objectId = objectId; ownerId = owned.ownerId; reserve = owned.reserve; hide = owned.hide; remoteOpAllowed = owned.remoteOpAllowed; } public static OwnerMessage For(GameObject gameObject) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) NetworkIdentity val = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<NetworkIdentity>() : null); OwnedObject ownedObject = (Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<OwnedObject>() : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)ownedObject)) { NetworkInstanceId netId = val.netId; if (!((NetworkInstanceId)(ref netId)).IsEmpty()) { return new OwnerMessage(val.netId, ownedObject); } } return null; } public static void Broadcast(GameObject gameObject) { if (NetworkServer.active) { OwnerMessage ownerMessage = For(gameObject); if (ownerMessage != null) { NetMessageExtensions.Send((INetMessage)(object)ownerMessage, (NetworkDestination)1); } } } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) writer.Write(objectId); writer.Write(ownerId); writer.Write(reserve); writer.Write(hide); writer.Write(remoteOpAllowed); } public void Deserialize(NetworkReader reader) { //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_000e: 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) objectId = reader.ReadNetworkId(); ownerId = reader.ReadNetworkId(); reserve = reader.ReadBoolean(); hide = reader.ReadBoolean(); remoteOpAllowed = reader.ReadBoolean(); } public void OnReceived() { //IL_0008: 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_0037: Unknown result type (might be due to invalid IL or missing references) NetworkInstanceId owner = ownerId; bool reserveForOwner = reserve; bool hideFromOthers = hide; bool droneAllowed = remoteOpAllowed; NetworkLookups.WhenFound(objectId, delegate(GameObject gameObject) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) OwnedObject.GetOrAdd(gameObject).Apply(owner, reserveForOwner, hideFromOthers, droneAllowed); }); } } internal static class ModConfig { private const string DefaultChestNames = "Chest1, Chest2, GoldChest, Chest1StealthedVariant, CategoryChestDamage, CategoryChestHealing, CategoryChestUtility, CategoryChest2Damage Variant, CategoryChest2Healing Variant, CategoryChest2Utility Variant, Lockbox, EquipmentBarrel, LunarChest, VoidChest, VoidTriple, LockboxVoid"; public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> InstancedChests; public static ConfigEntry<bool> RemoteOpCanOpenChests; public static ConfigEntry<bool> FreezeDifficultyAfterTeleporter; public static ConfigEntry<bool> ReviveDeadPlayersAfterTeleporter; public static ConfigEntry<int> ChoiceCount; public static ConfigEntry<bool> ReserveOrbs; public static ConfigEntry<bool> HideOtherPlayersOrbs; public static ConfigEntry<bool> GrantToInventory; public static ConfigEntry<float> DisconnectGraceSeconds; public static ConfigEntry<string> ChestNames; public static ConfigEntry<bool> VerboseLogging; private static HashSet<string> chestNameSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static void Init(ConfigFile config) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown Enabled = config.Bind<bool>("General", "Enabled", true, "Master switch. When off, chests behave exactly like vanilla. Host setting."); InstancedChests = config.Bind<bool>("General", "InstancedChests", true, "Each player can open every chest once, on their side. The chest stays closed for the others. Host setting."); RemoteOpCanOpenChests = config.Bind<bool>("Chests", "RemoteOpCanOpenChests", true, "A dead player piloting a drone (Alloyed Collective remote operation) can open the mod's chests on their side, with their own money, and open their orbs. Vanilla drones cannot open chests. Host setting."); FreezeDifficultyAfterTeleporter = config.Bind<bool>("Stage", "FreezeDifficultyAfterTeleporter", true, "Once the stage's teleporter is charged, the difficulty stops rising until the next stage (the run timer itself keeps going). Host setting."); ReviveDeadPlayersAfterTeleporter = config.Bind<bool>("Stage", "ReviveDeadPlayersAfterTeleporter", true, "Once the stage's teleporter is charged, dead players (including those piloting a drone) come back near the teleporter. Host setting."); ChoiceCount = config.Bind<int>("Orbs", "ChoiceCount", 3, new ConfigDescription("Number of items offered by each orb (same rarity as the rolled item). Host setting.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 6), Array.Empty<object>())); ReserveOrbs = config.Bind<bool>("Orbs", "ReserveForOpener", true, "Only the player who opened the chest can open its orb. Host setting."); HideOtherPlayersOrbs = config.Bind<bool>("Orbs", "HideOtherPlayersOrbs", true, "Orbs belonging to another player are invisible. Host setting."); GrantToInventory = config.Bind<bool>("Orbs", "GrantToInventory", true, "The chosen item goes straight into the owner's inventory instead of dropping on the ground. Host setting."); DisconnectGraceSeconds = config.Bind<float>("Orbs", "DisconnectGraceSeconds", 180f, "When an orb's owner disconnects, it stays reserved this many seconds (time to relaunch and rejoin), then becomes free for everyone. 0 = stays reserved until the end of the stage. Host setting."); ChestNames = config.Bind<string>("Chests", "ChestNames", "Chest1, Chest2, GoldChest, Chest1StealthedVariant, CategoryChestDamage, CategoryChestHealing, CategoryChestUtility, CategoryChest2Damage Variant, CategoryChest2Healing Variant, CategoryChest2Utility Variant, Lockbox, EquipmentBarrel, LunarChest, VoidChest, VoidTriple, LockboxVoid", "Comma-separated prefab names of the chests handled by the mod. Host setting."); VerboseLogging = config.Bind<bool>("Debug", "VerboseLogging", false, "Writes every chest and orb decision to the BepInEx log."); RebuildChestNames(); ChestNames.SettingChanged += delegate { RebuildChestNames(); }; } public static bool IsManagedChestName(string objectName) { return chestNameSet.Contains(NormalizeName(objectName)); } public static string NormalizeName(string objectName) { if (string.IsNullOrEmpty(objectName)) { return string.Empty; } string text = objectName.Trim(); while (text.EndsWith("(Clone)", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - "(Clone)".Length).TrimEnd(); } return text; } private static void RebuildChestNames() { HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); string[] array = (ChestNames.Value ?? string.Empty).Split(','); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { hashSet.Add(text); } } chestNameSet = hashSet; } } internal static class NetworkLookups { private struct Pending { public NetworkInstanceId id; public Action<GameObject> action; public float expiresAt; } private const float TimeoutSeconds = 10f; private static readonly List<Pending> pending = new List<Pending>(); public static void WhenFound(NetworkInstanceId id, Action<GameObject> action) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(id); if (Object.op_Implicit((Object)(object)val) && !pending.Exists((Pending p) => p.id == id)) { Run(action, val); return; } pending.Add(new Pending { id = id, action = action, expiresAt = Time.unscaledTime + 10f }); } public static void Tick() { //IL_0077: 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) if (NetworkLookups.pending.Count == 0) { return; } if (NetworkClient.active && !ClientScene.ready) { for (int i = 0; i < NetworkLookups.pending.Count; i++) { Pending value = NetworkLookups.pending[i]; value.expiresAt = Time.unscaledTime + 10f; NetworkLookups.pending[i] = value; } return; } List<KeyValuePair<Pending, GameObject>> list = null; int num = 0; for (int j = 0; j < NetworkLookups.pending.Count; j++) { Pending pending = NetworkLookups.pending[j]; GameObject val = Util.FindNetworkObject(pending.id); if (Object.op_Implicit((Object)(object)val)) { (list ?? (list = new List<KeyValuePair<Pending, GameObject>>())).Add(new KeyValuePair<Pending, GameObject>(pending, val)); } else if (Time.unscaledTime >= pending.expiresAt) { Plugin.Debug($"Objet réseau {pending.id} jamais trouvé, message ignoré"); } else { NetworkLookups.pending[num++] = pending; } } NetworkLookups.pending.RemoveRange(num, NetworkLookups.pending.Count - num); if (list == null) { return; } foreach (KeyValuePair<Pending, GameObject> item in list) { Run(item.Key.action, item.Value); } } private static void Run(Action<GameObject> action, GameObject target) { try { action(target); } catch (Exception ex) { Plugin.Log.LogError((object)ex); } } } internal static class OptionPickupPrefab { private static readonly string[] Keys = new string[3] { "f8e3413a378bd7c44aa09bed0020eaf5", "RoR2/DLC1/Interactables/OptionPickup/OptionPickup.prefab", "RoR2/DLC1/OptionPickup/OptionPickup.prefab" }; private static GameObject prefab; private static bool warned; public static void Load() { TryKey(0); } private static void TryKey(int index) { //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 (index >= Keys.Length) { Plugin.Log.LogWarning((object)"Prefab OptionPickup introuvable : l'orbe de l'Artefact du Commandement sera utilisée à la place."); return; } string key = Keys[index]; AsyncOperationHandle<IList<IResourceLocation>> val = Addressables.LoadResourceLocationsAsync((object)key, typeof(GameObject)); val.Completed += delegate(AsyncOperationHandle<IList<IResourceLocation>> locations) { //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) if (locations.Result == null || locations.Result.Count == 0) { TryKey(index + 1); } else { AsyncOperationHandle<GameObject> val2 = Addressables.LoadAssetAsync<GameObject>((object)key); val2.Completed += delegate(AsyncOperationHandle<GameObject> handle) { if (Object.op_Implicit((Object)(object)handle.Result)) { prefab = handle.Result; Plugin.Debug("Prefab OptionPickup chargé (" + key + ")"); } else { TryKey(index + 1); } }; } }; } public static GameObject Get() { if (Object.op_Implicit((Object)(object)prefab)) { return prefab; } if (!warned) { warned = true; Plugin.Log.LogWarning((object)"Prefab OptionPickup pas encore disponible, repli sur l'orbe de commandement."); } return CommandArtifactManager.commandCubePrefab; } } internal static class OrbHooks { public static void Install() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += new hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(CreatePickupDroplet); PickupDropletController.OnEnable += new hook_OnEnable(PickupDropletController_OnEnable); PickupDropletController.CreatePickup += new hook_CreatePickup(PickupDropletController_CreatePickup); PickupPickerController.Awake += new hook_Awake(PickupPickerController_Awake); GenericPickupController.Awake += new hook_Awake(GenericPickupController_Awake); PickupPickerController.GetInteractability += new hook_GetInteractability(PickupPickerController_GetInteractability); PickupPickerController.HandlePickupSelected += new hook_HandlePickupSelected(PickupPickerController_HandlePickupSelected); GenericPickupController.GetInteractability += new hook_GetInteractability(GenericPickupController_GetInteractability); GenericPickupController.OnTriggerStay += new hook_OnTriggerStay(GenericPickupController_OnTriggerStay); } private static void CreatePickupDroplet(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity) { //IL_0056: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0028: 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_0039: Unknown result type (might be due to invalid IL or missing references) DropContext current = DropContext.Current; if (current != null && current.convertToChoices && NetworkServer.active && pickupInfo.pickerOptions == null && !CommandArtifactManager.IsCommandArtifactEnabled) { CreatePickupInfo info = pickupInfo; try { if (ChoiceBuilder.TryConvert(ref info, current.rng)) { pickupInfo = info; } } catch (Exception arg) { Plugin.Log.LogError((object)$"Conversion en orbe impossible, item simple à la place : {arg}"); } } orig.Invoke(pickupInfo, position, velocity); if (current != null) { current.dropletsCreated++; } } private static void PickupDropletController_OnEnable(orig_OnEnable orig, PickupDropletController self) { orig.Invoke(self); if (NetworkServer.active) { DropContext.Current?.Tag(((Component)self).gameObject); } } private static void PickupDropletController_CreatePickup(orig_CreatePickup orig, PickupDropletController self) { OwnedObject ownedObject = (NetworkServer.active ? ((Component)self).GetComponent<OwnedObject>() : null); if (!Object.op_Implicit((Object)(object)ownedObject) || !ownedObject.HasOwner) { orig.Invoke(self); return; } using (DropContext.Begin(ownedObject.OwnerMaster, convertToChoices: false, null)) { orig.Invoke(self); } } private static void PickupPickerController_Awake(orig_Awake orig, PickupPickerController self) { orig.Invoke(self); if (NetworkServer.active) { DropContext.Current?.Tag(((Component)self).gameObject); } } private static void GenericPickupController_Awake(orig_Awake orig, GenericPickupController self) { orig.Invoke(self); if (NetworkServer.active) { DropContext.Current?.Tag(((Component)self).gameObject); } } private static Interactability PickupPickerController_GetInteractability(orig_GetInteractability orig, PickupPickerController self, Interactor activator) { //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) Interactability val = orig.Invoke(self, activator); if ((int)val == 0 && RemoteOperation.CanOpenOrb(self, activator)) { val = RemoteOperation.EvaluateAsAllowed(self, activator, orig); } if ((int)val != 0 && !OwnedObject.Allows(((Component)self).gameObject, PlayerResolver.FromInteractor(activator))) { return (Interactability)0; } return val; } private static Interactability GenericPickupController_GetInteractability(orig_GetInteractability orig, GenericPickupController self, Interactor activator) { //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Interactability val = orig.Invoke(self, activator); if ((int)val != 0 && !OwnedObject.Allows(((Component)self).gameObject, PlayerResolver.FromInteractor(activator))) { return (Interactability)0; } return val; } private static void GenericPickupController_OnTriggerStay(orig_OnTriggerStay orig, GenericPickupController self, Collider other) { if (!NetworkServer.active || !Object.op_Implicit((Object)(object)other) || OwnedObject.Allows(((Component)self).gameObject, PlayerResolver.FromBody(((Component)other).GetComponent<CharacterBody>()))) { orig.Invoke(self, other); } } private static void PickupPickerController_HandlePickupSelected(orig_HandlePickupSelected orig, PickupPickerController self, int choiceIndex) { //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) OwnedObject ownedObject = (NetworkServer.active ? ((Component)self).GetComponent<OwnedObject>() : null); if (!Object.op_Implicit((Object)(object)ownedObject) || !ownedObject.HasOwner) { orig.Invoke(self, choiceIndex); return; } NetworkUIPromptController component = ((Component)self).GetComponent<NetworkUIPromptController>(); CharacterMaster val = (Object.op_Implicit((Object)(object)component) ? component.currentParticipantMaster : null); CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetBody() : null); if (!ModConfig.GrantToInventory.Value && (!Object.op_Implicit((Object)(object)val2) || !val2.isRemoteOp)) { OrigWithOwner(orig, self, choiceIndex, ownedObject.OwnerMaster); } else { if ((uint)choiceIndex >= (uint)self.options.Length) { return; } Option val3 = self.options[choiceIndex]; if (val3.available && Object.op_Implicit((Object)(object)val) && OwnedObject.Allows(((Component)self).gameObject, PlayerResolver.FromMaster(val))) { if (!Grant.ToMaster(val, val3.pickup, ((Component)self).transform.position)) { OrigWithOwner(orig, self, choiceIndex, val); return; } Plugin.Debug($"{((Object)val).name} choisit {val3.pickup.pickupIndex}"); component.SetParticipantMaster((CharacterMaster)null); NetworkServer.Destroy(((Component)self).gameObject); } } } private static void OrigWithOwner(orig_HandlePickupSelected orig, PickupPickerController self, int choiceIndex, CharacterMaster owner) { using (DropContext.Begin(owner, convertToChoices: false, null)) { orig.Invoke(self, choiceIndex); } } } internal class OwnedObject : MonoBehaviour { public static readonly HashSet<OwnedObject> Instances = new HashSet<OwnedObject>(); private const float HideRefreshSeconds = 0.25f; private const float FastHideSeconds = 3f; private const float OwnerCheckSeconds = 1f; public NetworkInstanceId ownerId = NetworkInstanceId.Invalid; public bool reserve; public bool hide; public bool remoteOpAllowed; private CharacterMaster cachedOwner; private readonly List<Renderer> hiddenRenderers = new List<Renderer>(); private readonly List<Light> hiddenLights = new List<Light>(); private Highlight hiddenHighlight; private float nextHideRefresh; private float fastHideUntil; private float nextOwnerCheck; private float ownerMissingSince = -1f; public bool HasOwner => ownerId != NetworkInstanceId.Invalid; public CharacterMaster OwnerMaster { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)cachedOwner) && HasOwner) { GameObject val = Util.FindNetworkObject(ownerId); cachedOwner = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterMaster>() : null); } return cachedOwner; } } public static OwnedObject GetOrAdd(GameObject gameObject) { OwnedObject component = gameObject.GetComponent<OwnedObject>(); if (!Object.op_Implicit((Object)(object)component)) { return gameObject.AddComponent<OwnedObject>(); } return component; } public static bool Allows(GameObject gameObject, CharacterMaster player) { //IL_002a: 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) OwnedObject component = gameObject.GetComponent<OwnedObject>(); if (!Object.op_Implicit((Object)(object)component) || !component.HasOwner || !component.reserve) { return true; } if (Object.op_Implicit((Object)(object)player)) { return ((NetworkBehaviour)player).netId == component.ownerId; } return false; } public void SetOwnerServer(NetworkInstanceId owner, bool reserveForOwner, bool hideFromOthers, bool droneAllowed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Apply(owner, reserveForOwner, hideFromOthers, droneAllowed); } public void Apply(NetworkInstanceId owner, bool reserveForOwner, bool hideFromOthers, bool droneAllowed) { //IL_0000: 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_0016: 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) if (owner != ownerId) { cachedOwner = null; } ownerId = owner; reserve = HasOwner && reserveForOwner; hide = HasOwner && hideFromOthers; remoteOpAllowed = HasOwner && droneAllowed; nextHideRefresh = 0f; fastHideUntil = Time.unscaledTime + 3f; ownerMissingSince = -1f; if (ShouldHideLocally()) { HideNow(); } else { ShowAgain(); } } public bool ShouldHideLocally() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (hide && HasOwner && LocalUserManager.readOnlyLocalUsersList.Count > 0) { return !PlayerResolver.IsLocalPlayer(ownerId); } return false; } private void OnEnable() { Instances.Add(this); } private void OnDisable() { Instances.Remove(this); } private void Update() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active || !HasOwner || !(Time.unscaledTime >= nextOwnerCheck)) { return; } nextOwnerCheck = Time.unscaledTime + 1f; CharacterMaster ownerMaster = OwnerMaster; PlayerCharacterMasterController val = (Object.op_Implicit((Object)(object)ownerMaster) ? ownerMaster.playerCharacterMasterController : null); bool flag = !Object.op_Implicit((Object)(object)ownerMaster); bool flag2 = Object.op_Implicit((Object)(object)val) && !val.isConnected; if (!flag && !flag2) { ownerMissingSince = -1f; return; } if (ownerMissingSince < 0f) { ownerMissingSince = Time.unscaledTime; } float value = ModConfig.DisconnectGraceSeconds.Value; if (flag || (value > 0f && Time.unscaledTime - ownerMissingSince >= value)) { Plugin.Debug(((Object)this).name + " libéré : propriétaire absent"); Apply(NetworkInstanceId.Invalid, reserveForOwner: false, hideFromOthers: false, droneAllowed: false); OwnerMessage.Broadcast(((Component)this).gameObject); } } private void LateUpdate() { float unscaledTime = Time.unscaledTime; if ((!(unscaledTime < nextHideRefresh) || !(unscaledTime >= fastHideUntil)) && ShouldHideLocally()) { nextHideRefresh = unscaledTime + 0.25f; HideNow(); } } private void HideNow() { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (val.enabled) { val.enabled = false; hiddenRenderers.Add(val); } } Light[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Light>(true); foreach (Light val2 in componentsInChildren2) { if (((Behaviour)val2).enabled) { ((Behaviour)val2).enabled = false; hiddenLights.Add(val2); } } Highlight component = ((Component)this).GetComponent<Highlight>(); if (Object.op_Implicit((Object)(object)component) && ((Behaviour)component).enabled) { ((Behaviour)component).enabled = false; hiddenHighlight = component; } } private void ShowAgain() { foreach (Renderer hiddenRenderer in hiddenRenderers) { if (Object.op_Implicit((Object)(object)hiddenRenderer)) { hiddenRenderer.enabled = true; } } foreach (Light hiddenLight in hiddenLights) { if (Object.op_Implicit((Object)(object)hiddenLight)) { ((Behaviour)hiddenLight).enabled = true; } } if (Object.op_Implicit((Object)(object)hiddenHighlight)) { ((Behaviour)hiddenHighlight).enabled = true; } hiddenRenderers.Clear(); hiddenLights.Clear(); hiddenHighlight = null; } } internal static class PendingEquipment { private static readonly Dictionary<CharacterMaster, List<UniquePickup>> pending = new Dictionary<CharacterMaster, List<UniquePickup>>(); public static void Install() { CharacterBody.onBodyStartGlobal += OnBodyStart; Run.onRunDestroyGlobal += delegate { pending.Clear(); }; } public static void Add(CharacterMaster master, UniquePickup pickup) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!pending.TryGetValue(master, out var value)) { value = new List<UniquePickup>(); pending[master] = value; } value.Add(pickup); Plugin.Debug($"Équipement mis de côté pour {((Object)master).name} jusqu'à son retour : {pickup.pickupIndex}"); } private static void OnBodyStart(CharacterBody body) { //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) //IL_0055: 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) if (!NetworkServer.active || !Object.op_Implicit((Object)(object)body) || body.isRemoteOp) { return; } CharacterMaster master = body.master; if (!Object.op_Implicit((Object)(object)master) || !pending.TryGetValue(master, out var value)) { return; } pending.Remove(master); foreach (UniquePickup item in value) { Grant.ToMaster(master, item, body.corePosition); } } } internal static class PlayerResolver { public static CharacterMaster FromInteractor(Interactor interactor) { if (!Object.op_Implicit((Object)(object)interactor)) { return null; } return FromBody(((Component)interactor).GetComponent<CharacterBody>()); } public static CharacterMaster FromBody(CharacterBody body) { if (!Object.op_Implicit((Object)(object)body)) { return null; } return FromMaster(body.master); } public static CharacterMaster FromMaster(CharacterMaster master) { int num = 0; while (Object.op_Implicit((Object)(object)master) && num < 4) { if (Object.op_Implicit((Object)(object)master.playerCharacterMasterController)) { return master; } CharacterMaster val = (Object.op_Implicit((Object)(object)master.minionOwnership) ? master.minionOwnership.ownerMaster : null); if ((Object)(object)val == (Object)(object)master) { break; } master = val; num++; } return null; } public static bool IsLocalPlayer(NetworkInstanceId masterId) { //IL_0022: 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) foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { CharacterMaster cachedMaster = readOnlyLocalUsers.cachedMaster; if (Object.op_Implicit((Object)(object)cachedMaster) && ((NetworkBehaviour)cachedMaster).netId == masterId) { return true; } } return false; } } [BepInPlugin("com.shareitemswithmorefun", "ShareItemsWithMoreFun", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.shareitemswithmorefun"; public const string PluginName = "ShareItemsWithMoreFun"; public const string PluginVersion = "0.2.0"; internal static ManualLogSource Log; internal static Plugin Instance; private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; ModConfig.Init(((BaseUnityPlugin)this).Config); OptionPickupPrefab.Load(); NetworkingAPI.RegisterMessageType<ChestManagedMessage>(); NetworkingAPI.RegisterMessageType<ChestOpenedMessage>(); NetworkingAPI.RegisterMessageType<OwnerMessage>(); NetworkingAPI.RegisterMessageType<DifficultyFreezeMessage>(); ChestHooks.Install(); OrbHooks.Install(); ClientHooks.Install(); LateJoinSync.Install(); CompatHooks.Install(); PendingEquipment.Install(); StageEndHooks.Install(); if (RiskOfOptionsCompat.Enabled) { RiskOfOptionsCompat.Register(); } } private void Start() { Conflicts.WarnAboutKnownConflicts(); } private void Update() { NetworkLookups.Tick(); } internal static void Debug(string message) { if (ModConfig.VerboseLogging.Value) { Log.LogInfo((object)message); } } } internal static class RemoteOperation { public static bool CanOpenChest(PurchaseInteraction purchase, ManagedChest managed, Interactor activator) { if (!Object.op_Implicit((Object)(object)activator) || !activator.isRemoteOp || purchase.allowRemoteOpInteraction) { return false; } if (!Object.op_Implicit((Object)(object)managed) || !managed.instanced || managed.globallyOpened || !managed.remoteOpAllowed) { return false; } if (NetworkServer.active) { return managed.serverManaged; } return true; } public static Interactability EvaluateAsAllowed(PurchaseInteraction purchase, Interactor activator, orig_GetInteractability orig) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) purchase.allowRemoteOpInteraction = true; try { return orig.Invoke(purchase, activator); } finally { purchase.allowRemoteOpInteraction = false; } } public static bool CanOpenOrb(PickupPickerController picker, Interactor activator) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)activator) || !activator.isRemoteOp || picker.allowRemoteOpInteraction) { return false; } OwnedObject component = ((Component)picker).GetComponent<OwnedObject>(); CharacterMaster val = PlayerResolver.FromInteractor(activator); if (Object.op_Implicit((Object)(object)component) && component.HasOwner && component.remoteOpAllowed && Object.op_Implicit((Object)(object)val)) { return ((NetworkBehaviour)val).netId == component.ownerId; } return false; } public static Interactability EvaluateAsAllowed(PickupPickerController picker, Interactor activator, orig_GetInteractability orig) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) picker.allowRemoteOpInteraction = true; try { return orig.Invoke(picker, activator); } finally { picker.allowRemoteOpInteraction = false; } } } internal static class RiskOfOptionsCompat { public const string Guid = "com.rune580.riskofoptions"; public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Register() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0072: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown ModSettingsManag