Exemplo n.º 1
0
    private void CleanCache()
    {
        int num = this.m_cardCache.Count - 60;

        if (num > 0)
        {
            CollectionDeck currentlyOpenDeck = null;
            if (CollectionManager.Get() != null)
            {
                currentlyOpenDeck = CollectionManager.Get().GetTaggedDeck(CollectionManager.DeckTag.Editing);
            }
            List <string> deckHelperCardChoices = (DeckHelper.Get() != null) ? DeckHelper.Get().GetCardIDChoices() : null;
            List <string> names = new List <string>();
            int           index = 0;
            while (index < this.m_cardCache.Count)
            {
                CardCacheItem item = this.m_cardCache[index];
                if (!this.CanClearItem(item, currentlyOpenDeck, deckHelperCardChoices))
                {
                    index++;
                }
                else
                {
                    names.Add(item.m_cardId);
                    this.m_cardCache.RemoveAt(index);
                    DefLoader.Get().ClearCardDef(item.m_cardId);
                    if (names.Count == num)
                    {
                        break;
                    }
                }
            }
            AssetCache.ClearCardPrefabs(names);
        }
    }
Exemplo n.º 2
0
 private bool CanClearItem(CardCacheItem item, CollectionDeck currentlyOpenDeck, List <string> deckHelperCardChoices)
 {
     if ((currentlyOpenDeck != null) && (currentlyOpenDeck.GetCardIdCount(item.m_cardId) > 0))
     {
         return(false);
     }
     if ((deckHelperCardChoices != null) && deckHelperCardChoices.Contains(item.m_cardId))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
 public CardDef GetCardDef(string cardId)
 {
     for (int i = 0; i < this.m_cardCache.Count; i++)
     {
         CardCacheItem item = this.m_cardCache[i];
         if (item.m_cardId.Equals(cardId))
         {
             item.m_lastRequestTimestamp = TimeUtils.BinaryStamp();
             this.m_cardCache.RemoveAt(i);
             this.m_cardCache.Add(item);
             return(item.m_cardDef);
         }
     }
     return(null);
 }
Exemplo n.º 4
0
 private void AddCard(string cardID, CardDef card)
 {
     if (this.GetCardDef(cardID) != null)
     {
         Log.Rachelle.Print(string.Format("CollectionCardCache.AddCard(): somehow the card def for {0} was already in the cache...", cardID), new object[0]);
     }
     else
     {
         CardCacheItem item = new CardCacheItem {
             m_cardId  = cardID,
             m_cardDef = card
         };
         item.m_lastRequestTimestamp = TimeUtils.BinaryStamp();
         this.m_cardCache.Add(item);
         this.CleanCache();
     }
 }