From 674bce8f052e8633008cc0d03a7eb9197037bc73 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期三, 19 十二月 2018 17:24:39 +0800
Subject: [PATCH] 【1.4】聚魂功能

---
 System/GatheringSoul/VirtualPackModel.cs |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/System/GatheringSoul/VirtualPackModel.cs b/System/GatheringSoul/VirtualPackModel.cs
index cde74ad..1b4769f 100644
--- a/System/GatheringSoul/VirtualPackModel.cs
+++ b/System/GatheringSoul/VirtualPackModel.cs
@@ -78,20 +78,20 @@
             return false;
         }
 
-        public bool TryGetItem<T>(PackType packType, int index, out T item) where T : VirtualPackItem
+        public bool TryGetItem<T>(PackType packType, int packIndex, out T item) where T : VirtualPackItem
         {
             item = default(T);
             if (virtualPackItems.ContainsKey(packType))
             {
                 var _index = virtualPackItems[packType].FindIndex((x) =>
                  {
-                     return x.index == index;
+                     return x.index == packIndex;
                  });
-                if (index != -1)
+                if (_index != -1)
                 {
                     item = virtualPackItems[packType][_index] as T;
                 }
-                return index != -1;
+                return _index != -1;
             }
             return false;
         }
@@ -107,11 +107,7 @@
                     return;
             }
             List<VirtualPackItem> list;
-            if (virtualPackItems.TryGetValue(packType, out list))
-            {
-                list.Clear();
-            }
-            else
+            if (!virtualPackItems.TryGetValue(packType, out list))
             {
                 list = new List<VirtualPackItem>();
                 virtualPackItems.Add(packType, list);
@@ -147,7 +143,16 @@
         {
             for (int i = 0; i < items.Length; i++)
             {
-                var item = VirtualPackItem.Get(packType);
+                var item = list.Find((x) =>
+                {
+                    return x.index == items[i].ItemPlace;
+                });
+                if (item != null)
+                {
+                    list.Remove(item);
+                    item = null;
+                }
+                item = VirtualPackItem.Get(packType);
                 list.Add(item);
                 item.ParsePackItem(items[i].ItemPlace, items[i].ItemData);
             }

--
Gitblit v1.8.0