Exemplo n.º 1
0
                public GuiItem(Item item)
                {
                    icon            = item.Icon;
                    id              = item.Id;
                    identifier      = item.Identifier;
                    name            = item.Name;
                    quickAccessSlot = item.QuickAccessIndex;
                    quantity        = 1.0f;
                    isVolumetric    = false;

                    VolumeItem volumeItem = item as VolumeItem;

                    if (volumeItem != null)
                    {
                        isVolumetric = true;
                        quantity     = volumeItem.Volume;
                    }

                    DiscreteItem discreteItem = item as DiscreteItem;

                    if (discreteItem != null)
                    {
                        quantity = discreteItem.StackSize;
                    }
                }
Exemplo n.º 2
0
        /// <summary>
        /// Helper for implementing TryMerge for discrete items
        /// </summary>
        protected bool Merge(DiscreteItem item, bool subtract, bool force, bool dryrun)
        {
            if (subtract)
            {
                if (!force && StackSize < item.StackSize)
                {
                    return(false);
                }

                if (!dryrun)
                {
                    StackSize -= item.StackSize;
                }
            }
            else
            {
                if (!dryrun)
                {
                    StackSize += item.StackSize;
                }
            }

            return(true);
        }