public void UpdateStackSize(InventoryItem eventSourceItem)
    {
        // Do stacking
        var otherSize = CurrentItemData.StackWith(eventSourceItem.CurrentItemData);

        UpdateDisplayedData();
        if (otherSize == 0)
        {
            // Destroy other if stack is reduced to 0
            eventSourceItem.OnSelfDestruction();
        }
        else
        {
            eventSourceItem.UpdateDisplayedData();
        }
    }
示例#2
0
        /// <summary>
        /// For items, apply a new value to the current item.
        /// </summary>
        public static void ItemApplyValue(string key, object value, bool mandatory)
        {
            if (!mandatory &&
                (value.Equals("") ||
                 value == null ||
                 (value is object[] && ((object[])value).Length == 0)))
            {
                if (CurrentItemData.ContainsKey(key))
                {
                    CurrentItemData.Remove(key);
                }
            }
            else if (!CurrentItemData.ContainsKey(key) || value != CurrentItemData[key])
            {
                CurrentItemData[key] = value;
                unsavedChanges       = true;
            }

            openItems[currentFileIndex][currentItemIndex].NotifyKeyChanged(key);
        }
 public bool CanStackWith(InventoryItem eventSourceItem)
 {
     return(CurrentItemData.IsStackableWith(eventSourceItem.CurrentItemData));
 }