Ejemplo n.º 1
0
        private bool DropItem(Transform charTransform, Inventory inventory, PickupIndex pickupIndex)
        {
            _pickups[inventory] = new PickupRecord(Time.time, ItemIndex.None);

            //if (!inventory.hasAuthority)
            //    return false;

            var pickupDef = PickupCatalog.GetPickupDef(pickupIndex);

            if (pickupDef.equipmentIndex != EquipmentIndex.None)
            {
                if (inventory.GetEquipmentIndex() != pickupDef.equipmentIndex)
                {
                    return(false);
                }

                inventory.SetEquipmentIndex(EquipmentIndex.None);
            }
            else
            {
                if (inventory.GetItemCount(pickupDef.itemIndex) <= 0)
                {
                    return(false);
                }

                inventory.RemoveItem(pickupDef.itemIndex, 1);
            }

            PickupDropletController.CreatePickupDroplet(pickupIndex,
                                                        charTransform.position, Vector3.up * 20f + charTransform.forward * 10f);
            return(true);
        }
Ejemplo n.º 2
0
 private void GenericPickupControllerGrantItem(On.RoR2.GenericPickupController.orig_GrantItem orig, RoR2.GenericPickupController self, CharacterBody body, Inventory inventory)
 {
     orig(self, body, inventory);
     _pickups[inventory] = new PickupRecord(Time.time, PickupCatalog.GetPickupDef(self.pickupIndex).itemIndex);
 }