/// <summary> /// Checks if this ItemEntity can be stacked with another ItemEntity. To stack, both items must contain the same /// stat modifiers, name, description, value, and graphic index. /// </summary> /// <param name="source">Item to check if can stack on this ItemEntity.</param> /// <returns>True if the two items can stack on each other, else false.</returns> public bool CanStack(ItemEntity source) { // Check for equal reference if (ReferenceEquals(this, source)) { // Although it makes sense for an ItemEntity to be able to stack onto itself, // there is no reason this should ever happen intentionally const string errmsg = "Trying to stack an ItemEntity `{0}` onto itself. Although this is not an error, " + "it makes no sense why it would be attempted."; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, this); } Debug.Fail(string.Format(errmsg, this)); return(true); } // Check for non-equal values if (Value != source.Value || GraphicIndex != source.GraphicIndex || Type != source.Type || Name != source.Name || Description != source.Description || Range != source.Range || WeaponType != source.WeaponType) { return(false); } // Check for non-equal stats if (!BaseStats.HasSameValues(source.BaseStats) || !ReqStats.HasSameValues(source.ReqStats)) { return(false); } // Everything important is equal, so they can be stacked return(true); }