Exemplo n.º 1
0
 private void ChestBehavior_PickFromList(On.RoR2.ChestBehavior.orig_PickFromList orig, ChestBehavior self, List <PickupIndex> dropList)
 {
     if (NetworkServer.active)
     {
         if (isCurrentStageBazaar())
         {
             foreach (BazaarItem bazaarItem in bazaar.GetBazaarItems())
             {
                 if (bazaarItem.chestBehavior == self)
                 {
                     List <PickupIndex> newList = new List <PickupIndex> {
                         bazaarItem.pickupIndex
                     };
                     orig(self, newList);
                     return;
                 }
             }
             if (bazaar.IsMoneyLunarPod(self.gameObject))
             {
                 List <PickupIndex> newList = new List <PickupIndex> {
                     PickupIndex.none
                 };
                 orig(self, newList);
                 return;
             }
         }
     }
     orig(self, dropList);
 }
Exemplo n.º 2
0
        private void SaveAndSyncChestPickup(On.RoR2.ChestBehavior.orig_PickFromList orig, ChestBehavior self, List <PickupIndex> dropList)
        {
            orig(self, dropList);

            if (ShouldIgnoreChestBehaviour(self))
            {
                return;
            }

            var dropPickup = self.GetFieldValue <PickupIndex>("dropPickup");

            if (dropPickup == null || dropPickup == PickupIndex.none)
            {
                Debug.LogWarning($"Failed to get pickupIndex of Chest {self.netId}");
                return;
            }

            if (NetworkServer.active)
            {
                if (!NetworkChestSync.instance)
                {
                    var instance = Instantiate(chestSyncPrefab);
                    NetworkServer.Spawn(instance);
                }

                StartCoroutine(SyncChestPickup(self.netId, PickupCatalog.GetPickupDef(dropPickup).internalName, syncInterval));
            }
        }