예제 #1
0
        private void PlaceNonEquipment()
        {
            int num = this._itemWhiteList.FirstOrDefault((int wli) => LocalPlayer.Inventory._possessedItems.Any((InventoryItem pi) => pi._itemId == wli));

            if (num > 0 && LocalPlayer.Inventory.RemoveItem(num, 1, false, true))
            {
                if (BoltNetwork.isRunning)
                {
                    RackAdd rackAdd = RackAdd.Create(GlobalTargets.OnlyServer);
                    rackAdd.Slot   = base.GetComponentInParent <CoopRack>().GetSlotIndex(this);
                    rackAdd.Rack   = base.GetComponentInParent <BoltEntity>();
                    rackAdd.ItemId = num;
                    rackAdd.Send();
                }
                else
                {
                    this._storedItemId = num;
                    this.SpawnItemView();
                }
                LocalPlayer.Sfx.PlayPutDown(base.gameObject);
                this._addIcon.gameObject.SetActive(false);
                if (!this._offsetIcons)
                {
                    this._addIcon.transform.parent.position = base.transform.position;
                }
                else
                {
                    this._takeIcon.transform.parent.position = base.transform.position + this.IconsOffset;
                }
            }
        }
예제 #2
0
        private void PlaceEquipment()
        {
            Item item = null;

            if (!this._billboardRotate)
            {
                InventoryItemView inventoryItemView = LocalPlayer.Inventory.IsRightHandEmpty() ? null : LocalPlayer.Inventory.RightHand;
                if (inventoryItemView != null)
                {
                    item = inventoryItemView.ItemCache;
                }
            }
            else
            {
                item = ItemDatabase.Items[this._currentAddItem];
            }
            if (item != null && this.IsValidItem(item))
            {
                if (LocalPlayer.Inventory.IsRightHandEmpty() || LocalPlayer.Inventory.RightHand._itemId != item._id || LocalPlayer.Inventory.IsSlotLocked(Item.EquipmentSlot.RightHand))
                {
                    if (!LocalPlayer.Inventory.RemoveItem(item._id, 1, false, true))
                    {
                        return;
                    }
                }
                else if (!LocalPlayer.Inventory.ShuffleRemoveRightHandItem())
                {
                    return;
                }
                if (BoltNetwork.isRunning && !this.hellDoorSlot)
                {
                    RackAdd rackAdd = RackAdd.Create(GlobalTargets.OnlyServer);
                    rackAdd.Slot   = base.GetComponentInParent <CoopRack>().GetSlotIndex(this);
                    rackAdd.Rack   = base.GetComponentInParent <BoltEntity>();
                    rackAdd.ItemId = item._id;
                    rackAdd.Send();
                }
                else
                {
                    if (this.hellDoorSlot)
                    {
                        this.Removed = false;
                        this.Added   = true;
                    }
                    this._storedItemId = item._id;
                    this.SpawnItemView();
                }
                Sfx.Play(SfxInfo.SfxTypes.AddItem, base.transform, true);
                this._addIcon.gameObject.SetActive(false);
                if (!this._offsetIcons)
                {
                    this._addIcon.transform.parent.position = base.transform.position;
                }
                else
                {
                    this._takeIcon.transform.parent.position = base.transform.position + this.IconsOffset;
                }
            }
        }
예제 #3
0
        private IEnumerator OnDeserialized()
        {
            while (!GlobalDataSaver.Ready)
            {
                yield return(null);
            }
            yield return(null);

            if (this._storedItemId > 0)
            {
                while (!LocalPlayer.Inventory)
                {
                    yield return(null);
                }
                yield return(null);

                if (BoltNetwork.isRunning)
                {
                    if (BoltNetwork.isServer)
                    {
                        BoltEntity be = base.GetComponentInParent <BoltEntity>();
                        while (!be.isAttached)
                        {
                            yield return(null);
                        }
                        RackAdd add = RackAdd.Create(GlobalTargets.OnlyServer);
                        add.Slot           = base.GetComponentInParent <CoopRack>().GetSlotIndex(this);
                        add.Rack           = be;
                        add.ItemId         = this._storedItemId;
                        this._storedItemId = 0;
                        add.Send();
                    }
                }
                else
                {
                    this.SpawnItemView();
                }
            }
            yield break;
        }