Пример #1
0
 public override void UI_InteractOtherSlot(GameObject originator, GameObject item)
 {
     if (item != null)
     {
         //Put item in back without opening it
         //Check if it is a storage obj:
         if (storageObj.NextSpareSlot() != null)
         {
             UIManager.TryUpdateSlot(new UISlotObject(storageObj.NextSpareSlot().UUID, item,
                                                      InventorySlotCache.GetSlotByItem(item)?.inventorySlot.UUID));
             SoundManager.PlayAtPosition("Rustle0" + UnityEngine.Random.Range(1, 6).ToString(), PlayerManager.LocalPlayer.transform.position);
         }
     }
     else
     {
         if (UIManager.StorageHandler.storageCache != storageObj)
         {
             UIManager.StorageHandler.OpenStorageUI(storageObj);
         }
         else
         {
             UIManager.StorageHandler.CloseStorageUI();
         }
     }
 }
Пример #2
0
    public bool Interact(InventoryApply interaction)
    {
        if (interaction.TargetObject != gameObject)
        {
            //backpack can't be "applied" to something else in inventory
            return(false);
        }
        if (interaction.HandObject != null)
        {
            //Put item in back without opening it
            //Check if it is a storage obj:
            if (storageObj.NextSpareSlot() != null)
            {
                UIManager.TryUpdateSlot(new UISlotObject(storageObj.NextSpareSlot().UUID, interaction.HandObject,
                                                         InventorySlotCache.GetSlotByItem(interaction.HandObject)?.inventorySlot.UUID));
                SoundManager.PlayAtPosition("Rustle0" + UnityEngine.Random.Range(1, 6).ToString(), PlayerManager.LocalPlayer.transform.position);
                ObjectBehaviour itemObj = interaction.HandObject.GetComponent <ObjectBehaviour>();
                itemObj.parentContainer = objectBehaviour;
            }
        }
        else
        {
            //nothing in hand, just open / close the backpack (note that this means backpack can only be moved in inventory
            //by dragging and dropping)
            return(Interact(HandActivate.ByLocalPlayer()));
        }


        return(false);
    }
Пример #3
0
    /// <summary> This is clientside </summary>
    public void StoreItem(GameObject Performer, EquipSlot equipSlot, GameObject item)
    {
        InventorySlot storageInvSlot = storageObj.NextSpareSlot();

        if (storageInvSlot != null && item != gameObject)
        {
            var playerInvSlot = InventoryManager.GetSlotFromOriginatorHand(Performer, equipSlot);
            StoreItemMessage.Send(gameObject, Performer, playerInvSlot.equipSlot, true);
            SoundManager.PlayAtPosition("Rustle0" + Random.Range(1, 6).ToString(), PlayerManager.LocalPlayer.transform.position);
            ObjectBehaviour itemObj = item.GetComponent <ObjectBehaviour>();
            itemObj.parentContainer = objectBehaviour;
        }
    }
Пример #4
0
 public override void UI_InteractOtherSlot(GameObject originator, GameObject item)
 {
     if (item != null)
     {
         //Put item in back without opening it
         //Check if it is a storage obj:
         if (storageObj.NextSpareSlot() != null)
         {
             UIManager.TryUpdateSlot(new UISlotObject(storageObj.NextSpareSlot().UUID, item,
                                                      InventorySlotCache.GetSlotByItem(item)?.inventorySlot.UUID));
         }
     }
     else
     {
         if (UIManager.StorageHandler.storageCache != storageObj)
         {
             UIManager.StorageHandler.OpenStorageUI(storageObj);
         }
         else
         {
             UIManager.StorageHandler.CloseStorageUI();
         }
     }
 }