コード例 #1
0
    /// <summary>
    /// General function to try to equip the item in the active hand
    /// </summary>
    public void Equip()
    {
        // Is the player allowed to interact? (not a ghost)
        if (!isValidPlayer())
        {
            return;
        }

        // Is there an item to equip?
        if (!CurrentSlot.IsFull)
        {
            return;
        }

        //This checks which UI slot the item can be equiped to and swaps it there
        UI_ItemSlot itemSlot = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);

        if (itemSlot != null)
        {
            // If we couldn't equip item into pocket, let's try the other pocket!
            if (!SwapItem(itemSlot) && itemSlot.eventName == "storage02")
            {
                SwapItem(InventorySlotCache.GetSlotByEvent("storage01"));
            }
        }
        else
        {
            Logger.LogError("No slot type was found for this object for auto equip", Category.UI);
        }
    }
コード例 #2
0
    /// <summary>
    /// General function to try to equip the item in the active hand
    /// </summary>
    public void Equip()
    {
        // Is the player allowed to interact? (not a ghost)
        if (!isValidPlayer())
        {
            return;
        }

        // Is there an item to equip?
        if (!CurrentSlot.IsFull)
        {
            return;
        }

        //This checks which UI slot the item can be equiped to and swaps it there
        ItemType    type       = Slots.GetItemType(CurrentSlot.Item);
        SpriteType  masterType = Slots.GetItemMasterType(CurrentSlot.Item);
        UI_ItemSlot itemSlot   = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);

        if (itemSlot != null)
        {
            SwapItem(itemSlot);
        }
        else
        {
            Logger.LogError("No slot type was found for this object for auto equip", Category.UI);
        }
    }
コード例 #3
0
ファイル: Hands.cs プロジェクト: DiaAWAY/unitystation
    public void Use()
    {
        if (PlayerManager.LocalPlayerScript != null)
        {
            if (!PlayerManager.LocalPlayerScript.playerMove.allowInput ||
                PlayerManager.LocalPlayerScript.playerMove.isGhost)
            {
                return;
            }
        }

        if (!CurrentSlot.IsFull)
        {
            return;
        }

        //Is the item edible?
        if (CheckEdible())
        {
            return;
        }

        //This checks which UI slot the item can be equiped too and swaps it there
        ItemType   type       = Slots.GetItemType(CurrentSlot.Item);
        SpriteType masterType = Slots.GetItemMasterType(CurrentSlot.Item);

        switch (masterType)
        {
        case SpriteType.Clothing:
            UI_ItemSlot slot = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);
            SwapItem(slot);
            break;

        case SpriteType.Items:
            UI_ItemSlot itemSlot = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);
            SwapItem(itemSlot);
            break;

        case SpriteType.Guns:
            break;
        }
    }
コード例 #4
0
    /// <summary>
    /// General function to try to equip the item in the active hand
    /// </summary>
    public void Equip()
    {
        // Is the player allowed to interact? (not a ghost)
        if (!isValidPlayer())
        {
            return;
        }

        // Is there an item to equip?
        if (CurrentSlot.Item == null)
        {
            Logger.Log("!CurrentSlot.IsFull");
            return;
        }

        //This checks which UI slot the item can be equiped to and swaps it there
        UI_ItemSlot itemSlot = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);

        if (itemSlot != null)
        {
            //Try to equip the item into the appropriate slot
            if (!SwapItem(itemSlot))
            {
                //If we couldn't equip the item into it's primary slot, try the pockets!
                if (!SwapItem(InventorySlotCache.GetSlotByEvent(EquipSlot.storage01)))
                {
                    //We couldn't equip the item in pocket 1. Try pocket2!
                    //This swap fails if both pockets are full, do nothing if fail
                    SwapItem(InventorySlotCache.GetSlotByEvent(EquipSlot.storage02));
                }
            }
        }

        else
        {
            Logger.LogError("No slot type was found for this object for auto equip", Category.UI);
        }
    }
コード例 #5
0
ファイル: Hands.cs プロジェクト: svensis/unitystation
    public void Use()
    {
        if (PlayerManager.LocalPlayerScript != null)
        {
            if (!PlayerManager.LocalPlayerScript.playerMove.allowInput ||
                PlayerManager.LocalPlayerScript.playerMove.isGhost)
            {
                return;
            }
        }

        if (!CurrentSlot.IsFull)
        {
            return;
        }

        //Is the item edible?
        if (CheckEdible())
        {
            return;
        }

        //This checks which UI slot the item can be equiped too and swaps it there
        ItemType    type       = Slots.GetItemType(CurrentSlot.Item);
        SpriteType  masterType = Slots.GetItemMasterType(CurrentSlot.Item);
        UI_ItemSlot itemSlot   = InventorySlotCache.GetSlotByItemType(CurrentSlot.Item);

        if (itemSlot != null)
        {
            SwapItem(itemSlot);
        }
        else
        {
            Logger.LogError("No slot type was found for this object for auto equip", Category.UI);
        }
    }