Example #1
0
        /// Transfert items from this to an other
        public void TransfertTo(InventoryTilable to, int qty)
        {
            if ((to.def == null || to.def == this.def) && !to.full)
            {
                if (to.def == null)
                {
                    to.InitInventory(this.def);
                }
                int added = 0;
                while (this.list.Count != 0 && added < qty && !this.full)
                {
                      {
                        to.list.Enqueue(this.list.Dequeue());
                        added++;
                    }
                }

                if (this.list.Count == 0)
                {
                    if (this._parent == null)
                    {
                        this._def = null;
                    }
                    else
                    {
                        this._parent.Destroy();
                    }
                }
            }
        }
Example #2
0
        public Stackable(Vector2Int position, TilableDef def, int count)
        {
            this.position    = position;
            this.def         = def;
            this.inventory   = new InventoryTilable(this, count);
            this.position    = position;
            this.def         = def;
            this.mainGraphic = GraphicInstance.GetNew(this.def.graphics);

            Loki.stackableLabelController.AddLabel(this);
        }