Beispiel #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;
                    }
                }
Beispiel #2
0
        /// <summary>
        /// Helper for implementing TryMerge for discrete items
        /// </summary>
        protected bool Merge(VolumeItem item, bool subtract, bool force, bool dryrun)
        {
            if (subtract)
            {
                if (!force && Volume + .0001f < item.Volume)
                {
                    return(false);
                }

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

            return(true);
        }