コード例 #1
0
    private HolsterResult DoHolsterMainHand()
    {
        if (in_hands == null || in_hands.IsHolstered())
        {
            return(HolsterResult.Invalid);
        }
        switch (in_hands.GetItemSize())
        {
        case ItemSize.Small:
            Debug.Log("Stash to inventory: " + in_hands.gameObject.name);
            // Item is holstered and hidden
            in_hands.SetHolstered(true);
            in_hands.SetVisible(false);
            // Item is selected
            active_item = in_hands;
            AttachToRightHand(in_hands);
            // Hand is empty now, but do not detach
            in_hands = null;
            return(HolsterResult.Success);

        case ItemSize.Large:
            if (on_back == null)
            {
                Debug.Log("Holster to back: " + in_hands.gameObject.name);
                // Item is holstered, but visible
                in_hands.SetHolstered(true);
                in_hands.SetVisible(true);
                // Item is on back
                on_back = in_hands;
                AttachToBack(in_hands);
                // Hand is empty now, but do not detach
                in_hands = null;
                return(HolsterResult.Success);
            }
            else
            {
                // Do not holster, but also do not do anything else
                return(HolsterResult.Blocked);
            }

        case ItemSize.Bulky:
        case ItemSize.Case:
            // Do not holster, but also do not do anything else
            return(HolsterResult.Blocked);

        default:
            Debug.Log("Unsupported");
            break;
        }
        return(HolsterResult.Invalid);
    }
コード例 #2
0
    public void Pickup(PickupInteraction item)
    {
        /*
         * if (item == in_hands
         ||  item == suitcase
         ||  item == on_back
         ||  item == active_item
         ||  HasI)*/
        if (item == null)
        {
            return;
        }
        if (HasItem(item))
        {
            return;
        }

        switch (item.GetItemSize())
        {
        case ItemSize.Bulky:
            PickupCarryOnly(item);
            return;

        case ItemSize.Small:
        case ItemSize.Large:
            PickupHolsterable(item);
            return;

        default:
            Debug.Log("This should be impossible");
            break;
        }
    }
コード例 #3
0
    private void PickupHolsterable(PickupInteraction item)
    {
        DoButtonCooldown();

        // Picking up a large item, while carrying a suitcase?
        if (suitcase != null && item.GetItemSize() == ItemSize.Large)
        {
            // Store to back if the slot is free?
            if (on_back == null)
            {
                AddToBack(item);
                return;
            }
            // TODO: No idea whether suit and bulky item will be dropped...
            // Cancel for now
            return;
        }

        // Already holding something?
        if (in_hands != null)
        {
            if (in_hands.GetItemSize() == ItemSize.Large || in_hands.GetItemSize() == ItemSize.Bulky)
            {
                switch (item.GetItemSize())
                {
                case ItemSize.Large:
                    if (on_back == null)
                    {
                        AddToBack(item);
                    }
                    else
                    {
                        PickupSwap(item, on_back);
                    }
                    break;

                case ItemSize.Bulky:
                    PickupSwap(item, in_hands);
                    break;

                case ItemSize.Small:
                    AddToInventory(item);
                    break;

                default:
                    Debug.Log("This code should not be reached");
                    break;
                }
                return;
            }
            else if (in_hands.GetItemSize() == ItemSize.Small)
            {
                DoHolsterMainHand();
            }
        }

        // Hand is free, pick it up
        if (in_hands == null)
        {
            AddToHand(item);
            return;
        }
    }