Exemplo n.º 1
0
        private void RockContentUpdate(ref MultiHolder.ContentTypes showAddIcon)
        {
            bool flag = !BoltNetwork.isRunning || (base.transform.position - LocalPlayer.GameObject.transform.position).magnitude < 5f;

            if ((!BoltNetwork.isRunning && this._contentActual > 0 && LocalPlayer.Inventory.AmountOf(this.RockItemId, true) < 5) || (BoltNetwork.isRunning && this._contentActual > 0 && LocalPlayer.Inventory.AmountOf(this.RockItemId, true) < 5 && flag))
            {
                this.TakeRockIcon.SetActive(true);
                if (TheForest.Utils.Input.GetButtonDown("Take"))
                {
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.ContentType = (int)this._contentTypeActual;
                        itemHolderTakeItem.Target      = this.entity;
                        itemHolderTakeItem.Player      = LocalPlayer.Entity;
                        itemHolderTakeItem.Send();
                    }
                    else if (LocalPlayer.Inventory.AddItem(this.RockItemId, 1, false, false, (WeaponStatUpgrade.Types)(-2)))
                    {
                        this.RockRender[this._contentActual - 1].SetActive(false);
                        this._contentActual--;
                        if (this._contentActual == 0)
                        {
                            this._contentTypeActual = MultiHolder.ContentTypes.None;
                        }
                        this.RefreshMassAndDrag();
                    }
                }
            }
            else
            {
                this.TakeRockIcon.SetActive(false);
            }
            if (this._contentActual < this.RockRender.Length && LocalPlayer.Inventory.Owns(this.RockItemId) && flag && (this._content == MultiHolder.ContentTypes.Rock || (!LocalPlayer.Inventory.Logs.HasLogs && !LocalPlayer.AnimControl.carry)))
            {
                showAddIcon = MultiHolder.ContentTypes.Rock;
                if (TheForest.Utils.Input.GetButtonDown("Craft"))
                {
                    LocalPlayer.Inventory.RemoveItem(this.RockItemId, 1, false);
                    this._emitter.Play();
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                        itemHolderAddItem.ContentType = 3;
                        itemHolderAddItem.Target      = this.entity;
                        itemHolderAddItem.Send();
                    }
                    else
                    {
                        this._contentTypeActual = MultiHolder.ContentTypes.Rock;
                        this._contentActual++;
                        this.RockRender[this._contentActual - 1].SetActive(true);
                        this.RefreshMassAndDrag();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void LogContentUpdate(ref MultiHolder.ContentTypes showAddIcon)
        {
            bool flag = !BoltNetwork.isRunning || (base.transform.position - LocalPlayer.GameObject.transform.position).magnitude < 5f;

            if ((!BoltNetwork.isRunning && this._contentActual > 0 && LocalPlayer.Inventory.Logs.Amount < 2 && !LocalPlayer.AnimControl.carry) || (BoltNetwork.isRunning && this._contentActual > 0 && LocalPlayer.Inventory.Logs.Amount < 2 && !LocalPlayer.AnimControl.carry && flag))
            {
                this.TakeIcon.SetActive(true);
                if (TheForest.Utils.Input.GetButtonDown("Take"))
                {
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.ContentType = (int)this._contentTypeActual;
                        itemHolderTakeItem.Target      = this.entity;
                        itemHolderTakeItem.Player      = LocalPlayer.Entity;
                        itemHolderTakeItem.Send();
                    }
                    else if (LocalPlayer.Inventory.Logs.Lift())
                    {
                        this.LogRender[this._contentActual - 1].SetActive(false);
                        this._contentActual--;
                        if (this._contentActual == 0)
                        {
                            this._contentTypeActual = MultiHolder.ContentTypes.None;
                        }
                        this.RefreshMassAndDrag();
                    }
                }
            }
            else
            {
                this.TakeIcon.SetActive(false);
            }
            if (this._contentActual < this.LogRender.Length && LocalPlayer.Inventory.Logs.Amount > 0 && flag)
            {
                showAddIcon = MultiHolder.ContentTypes.Log;
                if (TheForest.Utils.Input.GetButtonDown("Craft"))
                {
                    this._contentTypeActual = MultiHolder.ContentTypes.Log;
                    this._emitter.Play();
                    LocalPlayer.Inventory.Logs.PutDown(false, false, true);
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                        itemHolderAddItem.ContentType = 1;
                        itemHolderAddItem.Target      = this.entity;
                        itemHolderAddItem.Send();
                    }
                    else
                    {
                        this._contentActual++;
                        this.LogRender[this._contentActual - 1].SetActive(true);
                        this.RefreshMassAndDrag();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void StickContentUpdate(ref MultiHolder.ContentTypes showAddIcon)
        {
            bool flag     = true;
            bool takeIcon = false;

            if ((!BoltNetwork.isRunning && this._contentActual > 0) || (BoltNetwork.isRunning && this._contentActual > 0 && flag))
            {
                takeIcon = true;
                if (TheForest.Utils.Input.GetButtonDown("Take"))
                {
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.ContentType = (int)this._contentTypeActual;
                        itemHolderTakeItem.Target      = base.entity;
                        itemHolderTakeItem.Player      = LocalPlayer.Entity;
                        itemHolderTakeItem.Send();
                    }
                    else if (LocalPlayer.Inventory.AddItem(this.StickItemId, 1, false, false, null) || LocalPlayer.Inventory.FakeDrop(this.StickItemId, null))
                    {
                        this.StickRender[this._contentActual - 1].SetActive(false);
                        this._contentActual--;
                        if (this._contentActual == 0)
                        {
                            takeIcon = false;
                            this._contentTypeActual = MultiHolder.ContentTypes.None;
                        }
                        this.RefreshMassAndDrag();
                    }
                }
            }
            if (this._contentActual < this.StickRender.Length && LocalPlayer.Inventory.Owns(this.StickItemId, true) && flag && (this._content == MultiHolder.ContentTypes.Stick || this._addingContentType == MultiHolder.ContentTypes.Stick))
            {
                showAddIcon = MultiHolder.ContentTypes.Stick;
                if (TheForest.Utils.Input.GetButtonDown("Craft"))
                {
                    LocalPlayer.Inventory.RemoveItem(this.StickItemId, 1, false, true);
                    Sfx.Play(SfxInfo.SfxTypes.AddLog, this.StickRender[this._contentActual].transform, true);
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                        itemHolderAddItem.ContentType = 4;
                        itemHolderAddItem.Target      = base.entity;
                        itemHolderAddItem.Send();
                    }
                    else
                    {
                        this._contentTypeActual = MultiHolder.ContentTypes.Stick;
                        this._contentActual++;
                        this.StickRender[this._contentActual - 1].SetActive(true);
                        this.RefreshMassAndDrag();
                    }
                }
            }
            Scene.HudGui.HolderWidgets[0].Show(takeIcon, this._contentTypeActual == MultiHolder.ContentTypes.Stick && showAddIcon == MultiHolder.ContentTypes.Stick, this.TakeIcon.transform);
        }
Exemplo n.º 4
0
 private void Update()
 {
     if (this.Logs > 0 && LocalPlayer.Inventory.Logs.Amount < 2 && (!BoltNetwork.isRunning || this.entity.isAttached))
     {
         this.TakeIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Take"))
         {
             if (!BoltNetwork.isRunning)
             {
                 if (LocalPlayer.Inventory.Logs.Lift())
                 {
                     this.LogRender[this.Logs - 1].SetActive(false);
                     this.Logs--;
                     this.RefreshMassAndDrag();
                 }
             }
             else
             {
                 ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                 itemHolderTakeItem.Target = this.entity;
                 itemHolderTakeItem.Player = LocalPlayer.Entity;
                 itemHolderTakeItem.Send();
             }
         }
     }
     else
     {
         this.TakeIcon.SetActive(false);
     }
     if (this.Logs < 7 && LocalPlayer.Inventory.Logs.Amount > 0 && (!BoltNetwork.isRunning || this.entity.isAttached))
     {
         this.AddIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Craft"))
         {
             LocalPlayer.Inventory.Logs.PutDown(false, false, true);
             if (BoltNetwork.isRunning)
             {
                 ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                 itemHolderAddItem.Target = this.entity;
                 itemHolderAddItem.Send();
             }
             else
             {
                 this.Logs++;
                 this.LogRender[this.Logs - 1].SetActive(true);
                 this.RefreshMassAndDrag();
             }
             this.emitter.Play();
         }
     }
     else
     {
         this.AddIcon.SetActive(false);
     }
 }
Exemplo n.º 5
0
 public override void OnEvent(ItemHolderAddItem evnt)
 {
     if (evnt.Target)
     {
         Component[] componentsInChildren = evnt.Target.GetComponentsInChildren(typeof(MultiHolder), true);
         if (componentsInChildren.Length > 0)
         {
             (componentsInChildren[0] as MultiHolder).AddItemMP((MultiHolder.ContentTypes)evnt.ContentType, evnt.RaisedBy);
         }
     }
 }
Exemplo n.º 6
0
    private void Update()
    {
        bool flag = this.Logs > 0 && LocalPlayer.Inventory.Logs.Amount < 2 && (!BoltNetwork.isRunning || base.entity.isAttached);

        if (flag && TheForest.Utils.Input.GetButtonDown("Take"))
        {
            if (!BoltNetwork.isRunning)
            {
                if (LocalPlayer.Inventory.Logs.Lift())
                {
                    this.LogRender[this.Logs - 1].SetActive(false);
                    this.Logs--;
                    this.RefreshMassAndDrag();
                }
            }
            else
            {
                ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                itemHolderTakeItem.Target = base.entity;
                itemHolderTakeItem.Player = LocalPlayer.Entity;
                itemHolderTakeItem.Send();
            }
        }
        bool flag2 = this.Logs < 7 && LocalPlayer.Inventory.Logs.Amount > 0 && (!BoltNetwork.isRunning || base.entity.isAttached);

        if (flag2 && TheForest.Utils.Input.GetButtonDown("Craft"))
        {
            LocalPlayer.Inventory.Logs.PutDown(false, false, true, null);
            if (BoltNetwork.isRunning)
            {
                ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                itemHolderAddItem.Target = base.entity;
                itemHolderAddItem.Send();
            }
            else
            {
                this.Logs++;
                this.LogRender[this.Logs - 1].SetActive(true);
                this.RefreshMassAndDrag();
            }
            this.emitter.Play();
        }
        Scene.HudGui.HolderWidgets[2].Show(flag, flag2, this.TakeIcon.transform);
    }
Exemplo n.º 7
0
 public override void OnEvent(ItemHolderAddItem evnt)
 {
     if (evnt.Target)
     {
         rockThrowerItemHolder componentInChildren = evnt.Target.GetComponentInChildren <rockThrowerItemHolder>();
         if (componentInChildren)
         {
             componentInChildren.AddItemMP(evnt.ContentType);
             return;
         }
         MultiThrowerItemHolder componentInChildren2 = evnt.Target.GetComponentInChildren <MultiThrowerItemHolder>();
         if (componentInChildren2)
         {
             componentInChildren2.AddItemMP(evnt.ContentType);
             return;
         }
         LogHolder componentInChildren3 = evnt.Target.GetComponentInChildren <LogHolder>();
         if (componentInChildren3)
         {
             componentInChildren3.AddItemMP(evnt.RaisedBy);
         }
         else
         {
             ItemHolder componentInChildren4 = evnt.Target.GetComponentInChildren <ItemHolder>();
             if (componentInChildren4)
             {
                 componentInChildren4.AddItemMP();
             }
             else
             {
                 MultiHolder[] componentsInChildren = evnt.Target.GetComponentsInChildren <MultiHolder>(true);
                 if (componentsInChildren.Length > 0)
                 {
                     componentsInChildren[0].AddItemMP((MultiHolder.ContentTypes)evnt.ContentType, evnt.RaisedBy);
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 private void Update()
 {
     if (BoltNetwork.isServer)
     {
     }
     if (BoltNetwork.isClient)
     {
     }
     if (this.CurrentItemAmount > 0 && LocalPlayer.Inventory.HasRoomFor(this.CurrentItemId, 1))
     {
         this.CurrentTakeIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Take") && LocalPlayer.Inventory.AddItem(this.CurrentItemId, 1, false, false, null))
         {
             LocalPlayer.Sfx.PlayItemCustomSfx(this.CurrentItemId, true);
             if (BoltNetwork.isRunning)
             {
                 ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                 itemHolderTakeItem.Target      = base.entity;
                 itemHolderTakeItem.Player      = LocalPlayer.Entity;
                 itemHolderTakeItem.ContentType = this.Current;
                 itemHolderTakeItem.Send();
             }
             else
             {
                 this.CurrentItemAmount--;
                 this.UpdateRenderers();
             }
         }
     }
     else if (this.CurrentTakeIcon.activeSelf)
     {
         this.CurrentTakeIcon.SetActive(false);
     }
     if (this.CurrentItemAmount < this.CurrentItemMaxCapacity && LocalPlayer.Inventory.Owns(this.CurrentItemId, true))
     {
         this.CurrentAddIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Craft"))
         {
             if (this._addItemEvent.Length > 0)
             {
                 FMODCommon.PlayOneshot(this._addItemEvent, base.transform);
             }
             else
             {
                 LocalPlayer.Sfx.PlayPutDown(base.gameObject);
             }
             if (LocalPlayer.Inventory.RemoveItem(this.CurrentItemId, 1, false, true))
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                     itemHolderAddItem.Target      = base.entity;
                     itemHolderAddItem.ContentType = this.Current;
                     itemHolderAddItem.Send();
                 }
                 else
                 {
                     this.CurrentItemAmount++;
                     this.UpdateRenderers();
                 }
             }
         }
     }
     else
     {
         this.CurrentAddIcon.SetActive(false);
     }
 }
Exemplo n.º 9
0
 private void Update()
 {
     if (BoltNetwork.isServer)
     {
         base.state.ItemCount   = this.Items;
         base.state.ammoCount   = this.ammoLoaded;
         base.state.leverRotate = this.lever.localRotation.y;
     }
     if (BoltNetwork.isClient)
     {
         this.Items      = base.state.ItemCount;
         this.ammoLoaded = base.state.ammoCount;
         if (this.ammoLoaded > 0)
         {
             for (int i = 0; i < this.ammoLoaded; i++)
             {
                 this.am.rockAmmo[i].SetActive(true);
             }
         }
         else
         {
             foreach (GameObject gameObject in this.am.rockAmmo)
             {
                 gameObject.SetActive(false);
             }
         }
     }
     if (!LocalPlayer.AnimControl.onRockThrower && BoltNetwork.isRunning)
     {
         Vector3 localEulerAngles = this.lever.localEulerAngles;
         localEulerAngles.y          = base.state.leverRotate;
         this.lever.localEulerAngles = localEulerAngles;
     }
     if (this.Items > 0)
     {
         this.TakeIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Take"))
         {
             int  contentType = 0;
             bool flag        = false;
             if (LocalPlayer.Inventory.AddItem(this._itemid, 1, false, false, null))
             {
                 flag = true;
             }
             if (flag)
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                     itemHolderTakeItem.Target      = base.entity;
                     itemHolderTakeItem.ContentType = contentType;
                     itemHolderTakeItem.Player      = LocalPlayer.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 (this.addItemEvent.Length > 0)
             {
                 FMODCommon.PlayOneshot(this.addItemEvent, base.transform);
             }
             else
             {
                 LocalPlayer.Sfx.PlayPutDown(base.gameObject);
             }
             int  num   = 0;
             bool flag2 = false;
             if (LocalPlayer.Inventory.RemoveItem(this._itemid, 1, false, true))
             {
                 flag2 = true;
             }
             if (flag2)
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                     itemHolderAddItem.ContentType = num;
                     itemHolderAddItem.Target      = base.entity;
                     itemHolderAddItem.Send();
                 }
                 else
                 {
                     this.Items++;
                     this.ItemsRender[this.Items - 1].SetActive(true);
                     this.ItemsRender[this.Items - 1].SendMessage("setupAmmoType", num);
                 }
             }
         }
     }
     else
     {
         this.AddIcon.SetActive(false);
     }
 }
Exemplo n.º 10
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);
     }
 }
Exemplo n.º 11
0
 private void Update()
 {
     if (BoltNetwork.isRunning)
     {
         this.UpdateMP();
     }
     if (this._nextItemIndex > 0)
     {
         Scene.HudGui.MultiThrowerTakeWidget.ShowSingle(this._items[this._nextItemIndex - 1], this._takeIcon.transform, SideIcons.Take);
         if (TheForest.Utils.Input.GetButtonDown("Take"))
         {
             this.TakeItem();
         }
     }
     else
     {
         Scene.HudGui.MultiThrowerTakeWidget.Shutdown();
     }
     if (this._nextItemIndex < this._renderSlots.Length)
     {
         bool flag = this.CanToggleNextAddItem();
         if (flag && TheForest.Utils.Input.GetButtonDown("Rotate"))
         {
             LocalPlayer.Sfx.PlayWhoosh();
             this.ToggleNextAddItem();
         }
         if (this._currentAddItem >= 0 && this._currentAddItem < ItemDatabase.Items.Length)
         {
             int  id    = ItemDatabase.Items[this._currentAddItem]._id;
             bool flag2 = !LocalPlayer.Inventory.IsRightHandEmpty() && LocalPlayer.Inventory.RightHand._itemId == id;
             if (LocalPlayer.Inventory.Owns(id, true))
             {
                 Scene.HudGui.MultiThrowerAddWidget.ShowList(ItemDatabase.Items[this._currentAddItem]._id, this._addIcon.transform, SideIcons.Craft);
                 if (TheForest.Utils.Input.GetButtonDown("Craft") && ((flag2 && LocalPlayer.Inventory.ShuffleRemoveRightHandItem()) || (!flag2 && LocalPlayer.Inventory.RemoveItem(id, 1, false, true))))
                 {
                     if (this._addItemEvent.Length > 0)
                     {
                         FMODCommon.PlayOneshot(this._addItemEvent, base.transform);
                     }
                     else
                     {
                         LocalPlayer.Sfx.PlayPutDown(base.gameObject);
                     }
                     if (BoltNetwork.isRunning)
                     {
                         ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                         itemHolderAddItem.ContentType = id;
                         itemHolderAddItem.Target      = base.entity;
                         itemHolderAddItem.Send();
                     }
                     else
                     {
                         this.SpawnEquipmentItemView(this._renderSlots[this._nextItemIndex], id);
                         this._items[this._nextItemIndex] = id;
                         this._nextItemIndex++;
                     }
                 }
                 return;
             }
         }
         if (flag)
         {
             this.ToggleNextAddItem();
         }
         Scene.HudGui.MultiThrowerAddWidget.Shutdown();
     }
     else
     {
         Scene.HudGui.MultiThrowerAddWidget.Shutdown();
     }
 }
Exemplo n.º 12
0
 private void Update()
 {
     if (BoltNetwork.isRunning)
     {
         this.UpdateMP();
     }
     if (this._nextItemIndex > 0)
     {
         if (!this._takeIcon.activeSelf)
         {
             this._takeIcon.SetActive(true);
         }
         if (TheForest.Utils.Input.GetButtonDown("Take") && LocalPlayer.Inventory.AddItem(this._items[this._nextItemIndex - 1], 1, false, false, (WeaponStatUpgrade.Types)(-2)))
         {
             if (BoltNetwork.isRunning)
             {
                 ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                 itemHolderTakeItem.Target      = this.entity;
                 itemHolderTakeItem.ContentType = this._items[this._nextItemIndex - 1];
                 itemHolderTakeItem.Player      = LocalPlayer.Entity;
                 itemHolderTakeItem.Send();
             }
             else
             {
                 this._nextItemIndex--;
                 UnityEngine.Object.Destroy(this._renderSlots[this._nextItemIndex].GetChild(0).gameObject);
                 this._renderSlots[this._nextItemIndex].gameObject.SetActive(false);
                 this._items[this._nextItemIndex] = -1;
             }
             if (DecayingInventoryItemView.LastUsed)
             {
                 DecayingInventoryItemView.LastUsed.SetDecayState(DecayingInventoryItemView.DecayStates.Spoilt);
             }
         }
     }
     else if (this._takeIcon.activeSelf)
     {
         this._takeIcon.SetActive(false);
     }
     if (this._nextItemIndex < this._renderSlots.Length && !LocalPlayer.Inventory.IsRightHandEmpty() && !LocalPlayer.Inventory.RightHand.ItemCache.MatchType(Item.Types.Story) && !this.IsBlackListed(LocalPlayer.Inventory.RightHand._itemId))
     {
         if (!this._addIcon.activeSelf)
         {
             this._addIcon.SetActive(true);
         }
         if (TheForest.Utils.Input.GetButtonDown("Craft"))
         {
             if (this._addItemEvent.Length > 0)
             {
                 FMODCommon.PlayOneshot(this._addItemEvent, base.transform);
             }
             else
             {
                 LocalPlayer.Sfx.PlayPutDown(base.gameObject);
             }
             int itemId = LocalPlayer.Inventory.RightHand._itemId;
             LocalPlayer.Inventory.ShuffleRemoveRightHandItem();
             if (BoltNetwork.isRunning)
             {
                 ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                 itemHolderAddItem.ContentType = itemId;
                 itemHolderAddItem.Target      = this.entity;
                 itemHolderAddItem.Send();
             }
             else
             {
                 this.SpawnEquipmentItemView(this._renderSlots[this._nextItemIndex], itemId);
                 this._items[this._nextItemIndex] = itemId;
                 this._nextItemIndex++;
             }
         }
     }
     else if (this._addIcon.activeSelf)
     {
         this._addIcon.SetActive(false);
     }
 }
Exemplo n.º 13
0
        protected override void StickContentUpdate(ref ContentTypes showAddIcon)
        {
            bool takeIcon = false;

            if (_contentActual > 0)
            {
                takeIcon = true;
                if (TheForest.Utils.Input.GetButtonDown("Take") || (TheForest.Utils.Input.GetButton("Take") && _nextAddItem < Time.time))
                {
                    if (TheForest.Utils.Input.GetButtonDown("Take"))
                    {
                        _nextAddItem = Time.time + 0.25f;
                    }
                    else
                    {
                        _nextAddItem = Time.time + 0.05f;
                    }
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.ContentType = (int)_contentTypeActual;
                        itemHolderTakeItem.Target      = entity;
                        itemHolderTakeItem.Player      = LocalPlayer.Entity;
                        itemHolderTakeItem.Send();
                    }
                    else if (LocalPlayer.Inventory.AddItem(StickItemId) || LocalPlayer.Inventory.FakeDrop(StickItemId))
                    {
                        StickRender[_contentActual - 1].SetActive(false);
                        _contentActual--;
                        if (_contentActual == 0)
                        {
                            takeIcon           = false;
                            _contentTypeActual = ContentTypes.None;
                        }
                        RefreshMassAndDrag();
                    }
                }
            }
            if (_contentActual < StickRender.Length && LocalPlayer.Inventory.Owns(StickItemId) && (_content == ContentTypes.Stick || _addingContentType == ContentTypes.Stick))
            {
                showAddIcon = ContentTypes.Stick;
                if (TheForest.Utils.Input.GetButtonDown("Craft") || (TheForest.Utils.Input.GetButton("Craft") && _nextAddItem < Time.time))
                {
                    if (TheForest.Utils.Input.GetButtonDown("Craft"))
                    {
                        _nextAddItem = Time.time + 0.25f;
                    }
                    else
                    {
                        _nextAddItem = Time.time + 0.05f;
                    }
                    LocalPlayer.Inventory.RemoveItem(StickItemId);
                    Sfx.Play(SfxInfo.SfxTypes.AddLog, StickRender[_contentActual].transform);
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                        itemHolderAddItem.ContentType = 4;
                        itemHolderAddItem.Target      = entity;
                        itemHolderAddItem.Send();
                    }
                    else
                    {
                        _contentTypeActual = ContentTypes.Stick;
                        _contentActual++;
                        StickRender[_contentActual - 1].SetActive(true);
                        RefreshMassAndDrag();
                    }
                }
            }
            Scene.HudGui.HolderWidgets[0].Show(takeIcon, _contentTypeActual == ContentTypes.Stick && showAddIcon == ContentTypes.Stick, TakeIcon.transform);
        }
Exemplo n.º 14
0
 protected override void Update()
 {
     if (CurrentItemAmount > 0 && TheForest.Utils.LocalPlayer.Inventory.HasRoomFor(CurrentItemId))
     {
         CurrentTakeIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Take") || (TheForest.Utils.Input.GetButton("Take") && _nextAddItem < Time.time))
         {
             if (TheForest.Utils.Input.GetButtonDown("Take"))
             {
                 _nextAddItem = Time.time + 0.25f;
             }
             else
             {
                 _nextAddItem = Time.time + 0.05f;
             }
             if (TheForest.Utils.LocalPlayer.Inventory.AddItem(CurrentItemId))
             {
                 TheForest.Utils.LocalPlayer.Sfx.PlayItemCustomSfx(CurrentItemId);
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                     itemHolderTakeItem.Target      = entity;
                     itemHolderTakeItem.Player      = TheForest.Utils.LocalPlayer.Entity;
                     itemHolderTakeItem.ContentType = Current;
                     itemHolderTakeItem.Send();
                 }
                 else
                 {
                     CurrentItemAmount--;
                     UpdateRenderers();
                 }
             }
         }
     }
     else if (CurrentTakeIcon.activeSelf)
     {
         CurrentTakeIcon.SetActive(false);
     }
     if (CurrentItemAmount < CurrentItemMaxCapacity && TheForest.Utils.LocalPlayer.Inventory.Owns(CurrentItemId))
     {
         CurrentAddIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Craft") || (TheForest.Utils.Input.GetButton("Craft") && _nextAddItem < Time.time))
         {
             if (TheForest.Utils.Input.GetButtonDown("Craft"))
             {
                 _nextAddItem = Time.time + 0.25f;
             }
             else
             {
                 _nextAddItem = Time.time + 0.05f;
             }
             if (_addItemEvent.Length > 0)
             {
                 FMODCommon.PlayOneshot(_addItemEvent, transform);
             }
             else
             {
                 TheForest.Utils.LocalPlayer.Sfx.PlayPutDown(gameObject);
             }
             if (TheForest.Utils.LocalPlayer.Inventory.RemoveItem(CurrentItemId))
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                     itemHolderAddItem.Target      = entity;
                     itemHolderAddItem.ContentType = Current;
                     itemHolderAddItem.Send();
                 }
                 else
                 {
                     CurrentItemAmount++;
                     UpdateRenderers();
                 }
             }
         }
     }
     else
     {
         CurrentAddIcon.SetActive(false);
     }
 }
Exemplo n.º 15
0
 public override void OnEvent(ItemHolderAddItem evnt)
 {
     if (evnt.Target)
     {
         Component[] componentsInChildren = evnt.Target.GetComponentsInChildren(typeof(MultiHolder), true);
         if (componentsInChildren.Length > 0)
         {
             (componentsInChildren[0] as MultiHolder).AddItemMP((MultiHolder.ContentTypes)evnt.ContentType, evnt.RaisedBy);
         }
     }
 }
Exemplo n.º 16
0
        private void Update()
        {
            if (this.IsSlotOccupied)
            {
                Scene.HudGui.RackWidgets[(int)this._type].ShowSingle(this._currentTakeItem, this.CurrentTakeItemId, this._slots[this.CurrentSlot]._slotTr, SideIcons.Take);
                if (TheForest.Utils.Input.GetButtonDown("Take") && (LocalPlayer.Inventory.AddItem(this.CurrentTakeItemId, 1, false, false, null) || LocalPlayer.Inventory.FakeDrop(this.CurrentTakeItemId, null)))
                {
                    LocalPlayer.Sfx.PlayItemCustomSfx(this.CurrentTakeItemId, true);
                    this.CurrentTakeIcon.SetActive(false);
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.Target       = base.entity;
                        itemHolderTakeItem.Player       = LocalPlayer.Entity;
                        itemHolderTakeItem.ContentType  = this.CurrentSlot;
                        itemHolderTakeItem.ContentValue = this.CurrentTakeItemId;
                        itemHolderTakeItem.Send();
                        if (BoltNetwork.isClient)
                        {
                            this.CurrentTakeItemId = 0;
                        }
                    }
                    else
                    {
                        this.CurrentTakeItemId = 0;
                        this.UpdateRenderers();
                    }
                }
            }
            int num = LocalPlayer.Inventory.OwnsWhich(this.CurrentAddItemId, this._allowFallback);

            if (!this.IsSlotOccupied && num > -1)
            {
                if (this._slots[this.CurrentSlot]._items.Length > 1)
                {
                    Scene.HudGui.RackWidgets[(int)this._type].ShowList(this.CurrentAddItemId, num, this._slots[this.CurrentSlot]._slotTr, SideIcons.Craft);
                }
                else
                {
                    Scene.HudGui.RackWidgets[(int)this._type].ShowSingle(this.CurrentAddItemId, num, this._slots[this.CurrentSlot]._slotTr, SideIcons.Craft);
                }
                if (TheForest.Utils.Input.GetButtonDown("Craft"))
                {
                    Sfx.Play(SfxInfo.SfxTypes.AddItem, this.CurrentAddIcon.transform, true);
                    if (LocalPlayer.Inventory.RemoveItem(num, 1, false, true))
                    {
                        this.CurrentTakeItemId = num;
                        this._currentTakeItem  = this.CurrentAddItemId;
                        if (BoltNetwork.isRunning)
                        {
                            ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                            itemHolderAddItem.Target      = base.entity;
                            itemHolderAddItem.ContentType = this.CurrentSlot;
                            itemHolderAddItem.ContentInfo = num;
                            itemHolderAddItem.Send();
                        }
                        else
                        {
                            this.UpdateRenderers();
                        }
                    }
                }
            }
            bool flag = this.CanToggleNextAddItem();

            if (flag && (TheForest.Utils.Input.GetButtonDown("Rotate") || num == -1))
            {
                LocalPlayer.Sfx.PlayWhoosh();
                this.ToggleNextAddItem();
            }
        }
Exemplo n.º 17
0
 public void AddItemMP(MultiHolder.ContentTypes type, BoltConnection source)
 {
     if ((this._contentTypeActual == MultiHolder.ContentTypes.Log || this._contentTypeActual == MultiHolder.ContentTypes.None) && type == MultiHolder.ContentTypes.Log)
     {
         if (type == MultiHolder.ContentTypes.None)
         {
             this._contentActual = 0;
         }
         if (base.entity.isOwner)
         {
             this._contentTypeActual = MultiHolder.ContentTypes.Log;
             if (this._contentActual < this.LogRender.Length)
             {
                 this._contentActual = Mathf.Min(this._contentActual + 1, this.LogRender.Length);
             }
             else
             {
                 PlayerAddItem playerAddItem = PlayerAddItem.Create(source);
                 playerAddItem.ItemId = this.LogItemId;
                 playerAddItem.Send();
             }
             this.RefreshMassAndDrag();
         }
         else
         {
             ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(base.entity.source);
             itemHolderAddItem.Target      = base.entity;
             itemHolderAddItem.ContentType = 1;
             itemHolderAddItem.Send();
         }
     }
     if ((this._contentTypeActual == MultiHolder.ContentTypes.Rock || this._contentTypeActual == MultiHolder.ContentTypes.None) && type == MultiHolder.ContentTypes.Rock)
     {
         if (type == MultiHolder.ContentTypes.None)
         {
             this._contentActual = 0;
         }
         if (base.entity.isOwner)
         {
             this._contentTypeActual = MultiHolder.ContentTypes.Rock;
             if (this._contentActual < this.RockRender.Length)
             {
                 this._contentActual = Mathf.Min(this._contentActual + 1, this.RockRender.Length);
             }
             else
             {
                 PlayerAddItem playerAddItem2 = PlayerAddItem.Create(source);
                 playerAddItem2.ItemId = this.RockItemId;
                 playerAddItem2.Send();
             }
             this.RefreshMassAndDrag();
         }
         else
         {
             ItemHolderAddItem itemHolderAddItem2 = ItemHolderAddItem.Create(base.entity.source);
             itemHolderAddItem2.ContentType = 3;
             itemHolderAddItem2.Target      = base.entity;
             itemHolderAddItem2.Send();
         }
     }
     if ((this._contentTypeActual == MultiHolder.ContentTypes.Stick || this._contentTypeActual == MultiHolder.ContentTypes.None) && type == MultiHolder.ContentTypes.Stick)
     {
         if (type == MultiHolder.ContentTypes.None)
         {
             this._contentActual = 0;
         }
         if (base.entity.isOwner)
         {
             this._contentTypeActual = MultiHolder.ContentTypes.Stick;
             if (this._contentActual < this.StickRender.Length)
             {
                 this._contentActual = Mathf.Min(this._contentActual + 1, this.StickRender.Length);
             }
             else
             {
                 PlayerAddItem playerAddItem3 = PlayerAddItem.Create(source);
                 playerAddItem3.ItemId = this.StickItemId;
                 playerAddItem3.Send();
             }
             this.RefreshMassAndDrag();
         }
         else
         {
             ItemHolderAddItem itemHolderAddItem3 = ItemHolderAddItem.Create(base.entity.source);
             itemHolderAddItem3.ContentType = 4;
             itemHolderAddItem3.Target      = base.entity;
             itemHolderAddItem3.Send();
         }
     }
 }
Exemplo n.º 18
0
        protected override void Update()
        {
            if (BoltNetwork.isServer)
            {
                state.ItemCount = Items;
            }
            else if (BoltNetwork.isClient)
            {
                Items = state.ItemCount;
            }
            bool takeIcon = Items > 0;

            if (TheForest.Utils.Input.GetButtonDown("Take") ||
                (TheForest.Utils.Input.GetButton("Take") && _nextAddItem < Time.time))
            {
                if (TheForest.Utils.Input.GetButtonDown("Take"))
                {
                    _nextAddItem = Time.time + 0.25f;
                }
                else
                {
                    _nextAddItem = Time.time + 0.05f;
                }
                if (Items > 0 && TheForest.Utils.LocalPlayer.Inventory.AddItem(_itemid, 1, false, false,
                                                                               (!_bonusManager)
                            ? TheForest.Items.Inventory.ItemProperties.Any
                            : _bonusManager.GetItemProperties(Items - 1)))
                {
                    TheForest.Utils.LocalPlayer.Sfx.PlayItemCustomSfx(_itemid);
                    if (BoltNetwork.isRunning)
                    {
                        ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                        itemHolderTakeItem.Target = entity;
                        itemHolderTakeItem.Player = TheForest.Utils.LocalPlayer.Entity;
                        itemHolderTakeItem.Send();
                    }
                    else
                    {
                        Items--;
                        ItemsRender[Items].SetActive(false);
                        if (_bonusManager)
                        {
                            _bonusManager.UnsetItemProperties(Items);
                        }
                    }
                }
            }
            bool flag = Items < ItemsRender.Length && TheForest.Utils.LocalPlayer.Inventory.Owns(_itemid);

            if (flag)
            {
                if (TheForest.Utils.Input.GetButtonDown("Craft") ||
                    (TheForest.Utils.Input.GetButton("Craft") && _nextAddItem < Time.time))
                {
                    if (TheForest.Utils.Input.GetButtonDown("Craft"))
                    {
                        _nextAddItem = Time.time + 0.25f;
                    }
                    else
                    {
                        _nextAddItem = Time.time + 0.05f;
                    }
                    if (addItemEvent.Length > 0)
                    {
                        FMODCommon.PlayOneshot(addItemEvent, transform);
                    }
                    else
                    {
                        TheForest.Utils.LocalPlayer.Sfx.PlayPutDown(gameObject);
                    }
                    if (TheForest.Utils.LocalPlayer.Inventory.RemoveItem(_itemid))
                    {
                        if (BoltNetwork.isRunning)
                        {
                            ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                            itemHolderAddItem.Target = entity;
                            itemHolderAddItem.Send();
                        }
                        else
                        {
                            Items++;
                            ItemsRender[Items - 1].SetActive(true);
                            if (_bonusManager)
                            {
                                int index = TheForest.Utils.LocalPlayer.Inventory.AmountOf(_itemid);
                                _bonusManager.SetItemProperties(Items - 1, _itemid,
                                                                TheForest.Utils.LocalPlayer.Inventory.InventoryItemViewsCache[_itemid][index]
                                                                .Properties);
                            }
                        }
                    }
                }
            }
            TheForest.Utils.Scene.HudGui.HolderWidgets[(int)_type].Show(takeIcon, flag, TakeIcon.transform);
        }
Exemplo n.º 19
0
 private void Update()
 {
     if (BoltNetwork.isServer)
     {
         base.state.ItemCount = this.Items;
     }
     if (BoltNetwork.isClient)
     {
         this.Items = base.state.ItemCount;
     }
     if (this.Items > 0)
     {
         this.TakeIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Take") && LocalPlayer.Inventory.AddItem(this._itemid, 1, false, false, (WeaponStatUpgrade.Types)(-2)))
         {
             LocalPlayer.Sfx.PlayWhoosh();
             if (BoltNetwork.isRunning)
             {
                 ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                 itemHolderTakeItem.Target = this.entity;
                 itemHolderTakeItem.Player = LocalPlayer.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))
     {
         this.AddIcon.SetActive(true);
         if (TheForest.Utils.Input.GetButtonDown("Craft"))
         {
             if (this.addItemEvent.Length > 0)
             {
                 FMODCommon.PlayOneshot(this.addItemEvent, base.transform);
             }
             else
             {
                 LocalPlayer.Sfx.PlayPutDown(base.gameObject);
             }
             if (LocalPlayer.Inventory.RemoveItem(this._itemid, 1, false))
             {
                 if (BoltNetwork.isRunning)
                 {
                     ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                     itemHolderAddItem.Target = this.entity;
                     itemHolderAddItem.Send();
                 }
                 else
                 {
                     this.Items++;
                     this.ItemsRender[this.Items - 1].SetActive(true);
                 }
             }
         }
     }
     else
     {
         this.AddIcon.SetActive(false);
     }
 }
Exemplo n.º 20
0
        protected override void Update()
        {
            if (IsSlotOccupied)
            {
                TheForest.Utils.Scene.HudGui.RackWidgets[(int)_type].ShowSingle(_currentTakeItem, CurrentTakeItemId, _slots[CurrentSlot]._slotTr, TheForest.UI.SideIcons.Take);
                if (TheForest.Utils.Input.GetButtonDown("Take") || (TheForest.Utils.Input.GetButton("Take") && _nextAddItem < Time.time))
                {
                    if (TheForest.Utils.Input.GetButtonDown("Take"))
                    {
                        _nextAddItem = Time.time + 0.25f;
                    }
                    else
                    {
                        _nextAddItem = Time.time + 0.05f;
                    }
                    if ((TheForest.Utils.LocalPlayer.Inventory.AddItem(CurrentTakeItemId) || TheForest.Utils.LocalPlayer.Inventory.FakeDrop(CurrentTakeItemId)))
                    {
                        TheForest.Utils.LocalPlayer.Sfx.PlayItemCustomSfx(CurrentTakeItemId);
                        CurrentTakeIcon.SetActive(false);
                        if (BoltNetwork.isRunning)
                        {
                            ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                            itemHolderTakeItem.Target       = entity;
                            itemHolderTakeItem.Player       = TheForest.Utils.LocalPlayer.Entity;
                            itemHolderTakeItem.ContentType  = CurrentSlot;
                            itemHolderTakeItem.ContentValue = CurrentTakeItemId;
                            itemHolderTakeItem.Send();
                            if (BoltNetwork.isClient)
                            {
                                CurrentTakeItemId = 0;
                            }
                        }
                        else
                        {
                            CurrentTakeItemId = 0;
                            UpdateRenderers();
                        }
                    }
                }
            }
            int num = TheForest.Utils.LocalPlayer.Inventory.OwnsWhich(CurrentAddItemId, _allowFallback);

            if (!IsSlotOccupied && num > -1)
            {
                if (_slots[CurrentSlot]._items.Length > 1)
                {
                    TheForest.Utils.Scene.HudGui.RackWidgets[(int)_type].ShowList(CurrentAddItemId, num, _slots[CurrentSlot]._slotTr, TheForest.UI.SideIcons.Craft);
                }
                else
                {
                    TheForest.Utils.Scene.HudGui.RackWidgets[(int)_type].ShowSingle(CurrentAddItemId, num, _slots[CurrentSlot]._slotTr, TheForest.UI.SideIcons.Craft);
                }
                if (TheForest.Utils.Input.GetButtonDown("Craft") || (TheForest.Utils.Input.GetButton("Craft") && _nextAddItem < Time.time))
                {
                    if (TheForest.Utils.Input.GetButtonDown("Craft"))
                    {
                        _nextAddItem = Time.time + 0.25f;
                    }
                    else
                    {
                        _nextAddItem = Time.time + 0.05f;
                    }
                    TheForest.Audio.Sfx.Play(TheForest.Audio.SfxInfo.SfxTypes.AddItem, CurrentAddIcon.transform);
                    if (TheForest.Utils.LocalPlayer.Inventory.RemoveItem(num))
                    {
                        CurrentTakeItemId = num;
                        _currentTakeItem  = CurrentAddItemId;
                        if (BoltNetwork.isRunning)
                        {
                            ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                            itemHolderAddItem.Target      = entity;
                            itemHolderAddItem.ContentType = CurrentSlot;
                            itemHolderAddItem.ContentInfo = num;
                            itemHolderAddItem.Send();
                        }
                        else
                        {
                            UpdateRenderers();
                        }
                    }
                }
            }
            bool flag = CanToggleNextAddItem();

            if (flag && (TheForest.Utils.Input.GetButtonDown("Rotate") || num == -1))
            {
                TheForest.Utils.LocalPlayer.Sfx.PlayWhoosh();
                ToggleNextAddItem();
            }
        }
Exemplo n.º 21
0
 public override void OnEvent(ItemHolderAddItem evnt)
 {
     if (evnt.Target)
     {
         rockThrowerItemHolder componentInChildren = evnt.Target.GetComponentInChildren<rockThrowerItemHolder>();
         if (componentInChildren)
         {
             componentInChildren.AddItemMP(evnt.ContentType);
             return;
         }
         MultiThrowerItemHolder componentInChildren2 = evnt.Target.GetComponentInChildren<MultiThrowerItemHolder>();
         if (componentInChildren2)
         {
             componentInChildren2.AddItemMP(evnt.ContentType);
             return;
         }
         LogHolder componentInChildren3 = evnt.Target.GetComponentInChildren<LogHolder>();
         if (componentInChildren3)
         {
             componentInChildren3.AddItemMP(evnt.RaisedBy);
         }
         else
         {
             ItemHolder componentInChildren4 = evnt.Target.GetComponentInChildren<ItemHolder>();
             if (componentInChildren4)
             {
                 componentInChildren4.AddItemMP();
             }
             else
             {
                 MultiHolder[] componentsInChildren = evnt.Target.GetComponentsInChildren<MultiHolder>(true);
                 if (componentsInChildren.Length > 0)
                 {
                     componentsInChildren[0].AddItemMP((MultiHolder.ContentTypes)evnt.ContentType, evnt.RaisedBy);
                 }
             }
         }
     }
 }
Exemplo n.º 22
0
    private void Update()
    {
        if (BoltNetwork.isServer)
        {
            base.state.ItemCount = this.Items;
        }
        else if (BoltNetwork.isClient)
        {
            this.Items = base.state.ItemCount;
        }
        bool takeIcon = this.Items > 0;

        if (this.Items > 0 && TheForest.Utils.Input.GetButtonDown("Take") && LocalPlayer.Inventory.AddItem(this._itemid, 1, false, false, (!this._bonusManager) ? ItemProperties.Any : this._bonusManager.GetItemProperties(this.Items - 1)))
        {
            LocalPlayer.Sfx.PlayItemCustomSfx(this._itemid, true);
            if (BoltNetwork.isRunning)
            {
                ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer);
                itemHolderTakeItem.Target = base.entity;
                itemHolderTakeItem.Player = LocalPlayer.Entity;
                itemHolderTakeItem.Send();
            }
            else
            {
                this.Items--;
                this.ItemsRender[this.Items].SetActive(false);
                if (this._bonusManager)
                {
                    this._bonusManager.UnsetItemProperties(this.Items);
                }
            }
        }
        bool flag = this.Items < this.ItemsRender.Length && LocalPlayer.Inventory.Owns(this._itemid, true);

        if (flag && TheForest.Utils.Input.GetButtonDown("Craft"))
        {
            if (this.addItemEvent.Length > 0)
            {
                FMODCommon.PlayOneshot(this.addItemEvent, base.transform);
            }
            else
            {
                LocalPlayer.Sfx.PlayPutDown(base.gameObject);
            }
            if (LocalPlayer.Inventory.RemoveItem(this._itemid, 1, false, true))
            {
                if (BoltNetwork.isRunning)
                {
                    ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                    itemHolderAddItem.Target = base.entity;
                    itemHolderAddItem.Send();
                }
                else
                {
                    this.Items++;
                    this.ItemsRender[this.Items - 1].SetActive(true);
                    if (this._bonusManager)
                    {
                        int index = LocalPlayer.Inventory.AmountOf(this._itemid, true);
                        this._bonusManager.SetItemProperties(this.Items - 1, this._itemid, LocalPlayer.Inventory.InventoryItemViewsCache[this._itemid][index].Properties);
                    }
                }
            }
        }
        Scene.HudGui.HolderWidgets[(int)this._type].Show(takeIcon, flag, this.TakeIcon.transform);
    }
 protected override void Update()
 {
     if (BoltNetwork.isRunning)
     {
         UpdateMP();
     }
     if (_nextItemIndex > 0)
     {
         TheForest.Utils.Scene.HudGui.MultiThrowerTakeWidget.ShowSingle(_items[_nextItemIndex - 1],
                                                                        _takeIcon.transform, TheForest.UI.SideIcons.Take);
         if (TheForest.Utils.Input.GetButtonDown("Take") ||
             (TheForest.Utils.Input.GetButton("Take") && _nextAddItem < Time.time))
         {
             if (TheForest.Utils.Input.GetButtonDown("Take"))
             {
                 _nextAddItem = Time.time + 0.25f;
             }
             else
             {
                 _nextAddItem = Time.time + 0.05f;
             }
             TakeItem();
         }
     }
     else
     {
         TheForest.Utils.Scene.HudGui.MultiThrowerTakeWidget.Shutdown();
     }
     if (_nextItemIndex < _renderSlots.Length)
     {
         bool flag = CanToggleNextAddItem();
         if (flag && TheForest.Utils.Input.GetButtonDown("Rotate"))
         {
             TheForest.Utils.LocalPlayer.Sfx.PlayWhoosh();
             ToggleNextAddItem();
         }
         if (_currentAddItem >= 0 && _currentAddItem < TheForest.Items.ItemDatabase.Items.Length)
         {
             int  id    = TheForest.Items.ItemDatabase.Items[_currentAddItem]._id;
             bool flag2 = !TheForest.Utils.LocalPlayer.Inventory.IsRightHandEmpty() &&
                          TheForest.Utils.LocalPlayer.Inventory.RightHand._itemId == id;
             if (TheForest.Utils.LocalPlayer.Inventory.Owns(id))
             {
                 TheForest.Utils.Scene.HudGui.MultiThrowerAddWidget.ShowList(TheForest.Items.ItemDatabase.Items[_currentAddItem]._id, _addIcon.transform, TheForest.UI.SideIcons.Craft);
                 if (TheForest.Utils.Input.GetButtonDown("Craft") || (TheForest.Utils.Input.GetButton("Craft") && _nextAddItem < Time.time))
                 {
                     if (TheForest.Utils.Input.GetButtonDown("Craft"))
                     {
                         _nextAddItem = Time.time + 0.25f;
                     }
                     else
                     {
                         _nextAddItem = Time.time + 0.05f;
                     }
                     if (flag2 && TheForest.Utils.LocalPlayer.Inventory.ShuffleRemoveRightHandItem() || !flag2 && TheForest.Utils.LocalPlayer.Inventory.RemoveItem(id))
                     {
                         if (_addItemEvent.Length > 0)
                         {
                             FMODCommon.PlayOneshot(_addItemEvent, transform);
                         }
                         else
                         {
                             TheForest.Utils.LocalPlayer.Sfx.PlayPutDown(gameObject);
                         }
                         if (BoltNetwork.isRunning)
                         {
                             ItemHolderAddItem itemHolderAddItem = ItemHolderAddItem.Create(GlobalTargets.OnlyServer);
                             itemHolderAddItem.ContentType = id;
                             itemHolderAddItem.Target      = entity;
                             itemHolderAddItem.Send();
                         }
                         else
                         {
                             SpawnEquipmentItemView(_renderSlots[_nextItemIndex], id);
                             _items[_nextItemIndex] = id;
                             _nextItemIndex++;
                         }
                     }
                 }
                 return;
             }
         }
         if (flag)
         {
             ToggleNextAddItem();
         }
         TheForest.Utils.Scene.HudGui.MultiThrowerAddWidget.Shutdown();
     }
     else
     {
         TheForest.Utils.Scene.HudGui.MultiThrowerAddWidget.Shutdown();
     }
 }