public virtual bool AddItem(ISkillArgs args, FreeItem item, bool useMove) { bool existed = (GetExisted(item) != null); if (existed) { if (item.IsUnique()) { if (inventoryUI != null) { inventoryUI.Error(args, this, "已存在唯一物品'" + item.GetName() + "'"); } return(false); } } ItemPosition old = GetNotFullExisted(item); if (old != null) { int addCount = item.GetCount(); old.SetKey(item); int removed = Math.Min(item.GetItemStack() - old.GetCount(), item.GetCount()); old.SetCount(old.GetCount() + removed); if (inventoryUI != null && args != null) { inventoryUI.UpdateItem(args, this, old); } if (removed < addCount) { FreeItem clone = item.Clone(); clone.SetCount(addCount - removed); AddNewItem(args, clone, false); } args.TempUsePara(new StringPara("inventory", name)); item.Added(args); if (inventoryUI != null && inventoryUI.MoveAction != null && useMove) { args.TempUsePara(new StringPara("to", this.name)); inventoryUI.MoveAction.Act(args); args.ResumePara("to"); } args.ResumePara("inventory"); return(true); } else { return(AddNewItem(args, item, useMove)); } }
public ItemPosition(FreeItem key, int x, int y) : base() { this.key = key; this.x = x; this.y = y; this.count = key.GetCount(); this.keyFields = new ObjectFields(key); }