hch
2025-07-23 64f046bdca87c2dcf8427cd2a2154fe9c4fc9249
Main/System/KnapSack/PackManager.cs
@@ -161,12 +161,17 @@
    }
    public event Action<PackType> refrechPackEvent; //刷新整个背包数据
    public event Action<PackType, string, bool> ChangeItemEvent; //物品刷新,可能批量创建注意效率; bool:true代表创建 false 刷新
    public event Action<PackType, string> DeleteItemEvent; //删除物品,可能批量删除注意效率
    public event Action<PackType, int, int> refreshItemCountEvent; // 慎用会卡(单个)最新物品数量刷新(旧的弃用)在得到新物品、物品数量的改变,清理该物品时均会触发 int 位置索引 int物品id
    public event Action<PackType> gridRefreshEvent; //背包空格刷新
    public event Action<PackType, int, int> itemCntAddEvent; //物品数量增加 int 位置索引 int物品id
    public event Action<PackType, int, int> itemCntReduceEvent; //物品数量减少的改变 int 位置索引 int物品id
    //物品(创建)刷新,可能批量创建注意效率; bool:true代表创建 false 刷新; 注意0707物品数量刷新不包含在此事件
    public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建
    //删除物品,可能批量删除注意效率
    public event Action<PackType, string> DeleteItemEvent; // 背包类型,GUID
    // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但0725整个背包刷新不触发,如果有需要单独数量刷新事件另外处理
    // 触发比较频繁,界面使用时可以做个汇总后延迟刷新
    public event Action<PackType, int, int> RefreshItemEvent; //背包类型,位置索引,物品id
    public event Action<PackType> gridRefreshEvent; //背包可用格子数刷新
    public event Action<int, int> useItemSuccessEvent; //物品使用成功 int 位置索引 int物品id
    public event Action<int> refreshItemDayUseCountEvent;  //刷新物品每日使用数量
@@ -196,7 +201,7 @@
        {
            var itemInfo = new ItemInfo(packInfo.ItemInfo[i]);
            var item = playerPackDict[packType].UpdateItem(itemInfo);
            AddItemGUIDDict(item, false);
            AddItemGUIDDict(item, true);
            if (isPlayBetterEquipEffect)
            {
@@ -240,15 +245,11 @@
        var item = playerPackDict[type].UpdateItem(itemInfo);
        AddItemGUIDDict(item, showNewItem);
        if (refreshItemCountEvent != null)
        if (RefreshItemEvent != null)
        {
            refreshItemCountEvent(type, itemInfo.index, itemInfo.itemId);
            RefreshItemEvent(type, itemInfo.index, itemInfo.itemId);
        }
        if (itemCntAddEvent != null)
        {
            itemCntAddEvent(type, itemInfo.index, itemInfo.itemId);
        }
        // if (type == PackType.Equip)
        // {
@@ -297,32 +298,12 @@
            ItemModel itemModel = singlePack.GetItemByIndex(refresh.ItemIndex);
            if (itemModel != null)
            {
                bool isAddItemCount = false;
                if (refresh.ItemCount > itemModel.count)
                {
                    isAddItemCount = true;
                }
                itemModel.RefreshCount((int)refresh.ItemCount);
                if (isAddItemCount)
                if (RefreshItemEvent != null)
                {
                    if (itemCntAddEvent != null)
                    {
                        itemCntAddEvent(type, itemModel.gridIndex, itemModel.itemId);
                    }
                    ItemLogicUtility.Instance.RefreshPickItem(type, itemModel.itemId.ToString());
                }
                else
                {
                    if (itemCntReduceEvent != null)
                    {
                        itemCntReduceEvent(type, itemModel.gridIndex, itemModel.itemId);
                    }
                }
                if (refreshItemCountEvent != null)
                {
                    refreshItemCountEvent(type, itemModel.gridIndex, itemModel.itemId);
                    RefreshItemEvent(type, itemModel.gridIndex, itemModel.itemId);
                }
            }
@@ -348,8 +329,6 @@
                DeleteItemDictByGUID(type, guid);
            }
        }
    }
    public void RemoveItem(H0709_tagClearItem clearItem)
@@ -375,15 +354,11 @@
            DeleteItemDictByGUID(type, itemModel.guid);
            singlePack.RemoveItem(clearItem.ItemIndex);
            if (refreshItemCountEvent != null)
            if (RefreshItemEvent != null)
            {
                refreshItemCountEvent(type, clearItem.ItemIndex, itemId);
                RefreshItemEvent(type, clearItem.ItemIndex, itemId);
            }
            if (itemCntReduceEvent != null)
            {
                itemCntReduceEvent(type, clearItem.ItemIndex, itemId);
            }
        }
        UpdatePackRedpoint(type);