private void OnButtonClicked() { bool hasItem = _item != null; bool isOnPickup = _pickUp != null; if (hasItem && isOnPickup) { SwapItem(); } else if (hasItem && !isOnPickup) { // drop item DropItem(); } else if (!hasItem && isOnPickup) { _pickUp.PickUp(_inventory); } }
public void OnEnterPickup(PickUpBehaviour pickUpBehaviour) { if (!pickUpBehaviour.PickUpNeedApproval) { pickUpBehaviour.PickUp(_inventory); return; } bool hasItem = _item != null; if (hasItem) { _ui.ChangeState(ItemSlotUiController.State.Swap); } else { _ui.ChangeState(ItemSlotUiController.State.PickUp); } _pickUp = pickUpBehaviour; }