private void TakeItem() { int num = this._items[this._nextItemIndex - 1]; bool flag = LocalPlayer.Inventory.AddItem(num, 1, false, false, null); if (!flag) { flag = LocalPlayer.Inventory.FakeDrop(num, null); } if (!flag) { return; } if (BoltNetwork.isRunning) { ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(GlobalTargets.OnlyServer); itemHolderTakeItem.Target = base.entity; itemHolderTakeItem.ContentType = num; 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); } }
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(); } } } }
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(); } } } }
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); }
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); } }
public override void OnEvent(ItemHolderTakeItem evnt) { if (evnt.Target) { Component[] componentsInChildren = evnt.Target.GetComponentsInChildren(typeof(MultiHolder), true); if (componentsInChildren.Length > 0) { (componentsInChildren[0] as MultiHolder).TakeItemMP(null, (MultiHolder.ContentTypes)evnt.ContentType); } } }
public void TakeItemMP(BoltEntity targetPlayer, MultiHolder.ContentTypes type) { if (type != this._contentTypeActual) { return; } if (this._contentActual > 0) { if (BoltNetwork.isServer) { PlayerAddItem playerAddItem; if (targetPlayer.isOwner) { playerAddItem = PlayerAddItem.Create(GlobalTargets.OnlySelf); } else { playerAddItem = PlayerAddItem.Create(targetPlayer.source); } if (this._contentTypeActual == MultiHolder.ContentTypes.Rock) { playerAddItem.ItemId = this.RockItemId; } else if (this._contentTypeActual == MultiHolder.ContentTypes.Stick) { playerAddItem.ItemId = this.StickItemId; } else { playerAddItem.ItemId = this.LogItemId; } playerAddItem.Send(); } if (base.entity.isOwner) { this._contentActual = Mathf.Max(this._contentActual - 1, 0); if (this._contentActual == 0) { this._contentTypeActual = MultiHolder.ContentTypes.None; } this.RefreshMassAndDrag(); } else { ItemHolderTakeItem itemHolderTakeItem = ItemHolderTakeItem.Create(base.entity.source); itemHolderTakeItem.Target = base.entity; itemHolderTakeItem.ContentType = (int)this._contentTypeActual; itemHolderTakeItem.Send(); } return; } }
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); }
public override void OnEvent(ItemHolderTakeItem evnt) { if (evnt.Target) { rockThrowerItemHolder componentInChildren = evnt.Target.GetComponentInChildren <rockThrowerItemHolder>(); if (componentInChildren) { componentInChildren.TakeItemMP(evnt.Player, evnt.ContentType); return; } MultiThrowerItemHolder componentInChildren2 = evnt.Target.GetComponentInChildren <MultiThrowerItemHolder>(); if (componentInChildren2) { componentInChildren2.TakeItemMP(evnt.Player, evnt.ContentType); return; } LogHolder componentInChildren3 = evnt.Target.GetComponentInChildren <LogHolder>(); if (componentInChildren3) { componentInChildren3.TakeItemMP(evnt.Player); return; } ItemHolder componentInChildren4 = evnt.Target.GetComponentInChildren <ItemHolder>(); if (componentInChildren4) { componentInChildren4.TakeItemMP(evnt.Player); return; } MultiHolder[] componentsInChildren = evnt.Target.GetComponentsInChildren <MultiHolder>(true); if (componentsInChildren.Length > 0) { componentsInChildren[0].TakeItemMP(evnt.Player, (MultiHolder.ContentTypes)evnt.ContentType); return; } } }
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); } }
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); } }
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); } }
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); } }
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); }
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); } }
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); } }
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(); } }
public override void OnEvent(ItemHolderTakeItem evnt) { if (evnt.Target) { Component[] componentsInChildren = evnt.Target.GetComponentsInChildren(typeof(MultiHolder), true); if (componentsInChildren.Length > 0) { (componentsInChildren[0] as MultiHolder).TakeItemMP(null, (MultiHolder.ContentTypes)evnt.ContentType); } } }
public override void OnEvent(ItemHolderTakeItem evnt) { if (evnt.Target) { rockThrowerItemHolder componentInChildren = evnt.Target.GetComponentInChildren<rockThrowerItemHolder>(); if (componentInChildren) { componentInChildren.TakeItemMP(evnt.Player, evnt.ContentType); return; } MultiThrowerItemHolder componentInChildren2 = evnt.Target.GetComponentInChildren<MultiThrowerItemHolder>(); if (componentInChildren2) { componentInChildren2.TakeItemMP(evnt.Player, evnt.ContentType); return; } LogHolder componentInChildren3 = evnt.Target.GetComponentInChildren<LogHolder>(); if (componentInChildren3) { componentInChildren3.TakeItemMP(evnt.Player); return; } ItemHolder componentInChildren4 = evnt.Target.GetComponentInChildren<ItemHolder>(); if (componentInChildren4) { componentInChildren4.TakeItemMP(evnt.Player); return; } MultiHolder[] componentsInChildren = evnt.Target.GetComponentsInChildren<MultiHolder>(true); if (componentsInChildren.Length > 0) { componentsInChildren[0].TakeItemMP(evnt.Player, (MultiHolder.ContentTypes)evnt.ContentType); return; } } }
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); }
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); }
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(); } }