| | |
| | | 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;
|
| | | }
|
| | |
| | | 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);
|
| | |
| | | {
|
| | | 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);
|
| | | }
|