Example #1
0
 private void Update()
 {
     if (this.Items > 0)
     {
         this.TakeIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Take"))
         {
             LocalPlayer.Inventory.SendMessage("PlayWhoosh");
             if (LocalPlayer.Inventory.AddItem(this._itemid, 1, false, false, null))
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Raise(GlobalTargets.OnlyServer);
                     itemHolderTakeItem.Target = base.entity;
                     itemHolderTakeItem.Send();
                 }
                 else
                 {
                     this.ItemsRender[this.Items - 1].SetActive(false);
                     this.Items--;
                 }
             }
         }
     }
     else if (this.TakeIcon.activeSelf)
     {
         this.TakeIcon.SetActive(false);
     }
     if (this.Items < this.ItemsRender.Length && LocalPlayer.Inventory.Owns(this._itemid, true))
     {
         this.AddIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Craft"))
         {
             if (base.GetComponent <AudioSource>())
             {
                 base.GetComponent <AudioSource>().Play();
             }
             else
             {
                 LocalPlayer.Sfx.PlayWhoosh();
             }
             if (LocalPlayer.Inventory.RemoveItem(this._itemid, 1, false, true))
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Raise(GlobalTargets.OnlyServer);
                     itemHolderAddItem.Target = base.entity;
                     itemHolderAddItem.Send();
                 }
                 else
                 {
                     this.Items++;
                     this.ItemsRender[this.Items - 1].SetActive(true);
                 }
             }
         }
     }
     else
     {
         this.AddIcon.SetActive(false);
     }
 }