예제 #1
0
        private void ImportanceUpdateCycle_DoOnce()
        {
            TaleNewsDatabase database = DesynchronizedMain.TaleNewsDatabaseSystem;

            // Establish a counter of all *non-perm-forgot* tale-news
            Dictionary <TaleNews, int> remembranceCounter = new Dictionary <TaleNews, int>();

            foreach (TaleNews news in database.GetAllValidNonPermForgottenNews())
            {
                remembranceCounter.Add(news, 0);
            }

            // Update the importance scores of all *non-forgotten* news,
            // see if any of them are to be forgotten.
            foreach (Pawn_NewsKnowledgeTracker tracker in DesynchronizedMain.TaleNewsDatabaseSystem.KnowledgeTrackerMasterList)
            {
                foreach (TaleNewsReference reference in tracker.GetAllValidNonForgottenNewsReferences())
                {
                    reference.UpdateNewsImportance();
                    if (!reference.NewsIsLocallyForgotten)
                    {
                        remembranceCounter[reference.ReferencedTaleNews]++;
                    }
                }
            }

            // Purge all forgotten news
            foreach (KeyValuePair <TaleNews, int> kvPair in remembranceCounter)
            {
                if (kvPair.Key.UniqueID == TaleNews.DefaultTaleNews.UniqueID)
                {
                    continue;
                }
                if (kvPair.Value == 0)
                {
                    kvPair.Key.Signal_NewsIsPermanentlyForgotten();
                }
            }
        }
예제 #2
0
        private void TaleNewsDebugSystem()
        {
            // DEBUG
            TaleNewsDatabase tndbs = this;

            FileLog.Log("System time is " + DateTime.Now.ToShortTimeString() + "; beginning log.");
            FileLog.Log("To optimize performance, all logs will now temporarily be buffered.");
            foreach (PawnKnowledgeCard card in tndbs.KnowledgeMappings)
            {
                FileLog.LogBuffered("Loading new card...");
                if (card == null)
                {
                    FileLog.LogBuffered("Loaded card is null.");
                }
                else
                {
                    FileLog.LogBuffered("Loaded card exists.");
                    Pawn pawn = card.Subject;
                    if (pawn == null)
                    {
                        FileLog.LogBuffered("Subject of card is null.");
                    }
                    else
                    {
                        FileLog.LogBuffered("Subject of card exists; name: " + pawn);
                        FileLog.LogBuffered("Checking TaleNews list...");
                        List <TaleNewsReference> listReferences = card.KnowledgeList;
                        if (listReferences == null)
                        {
                            FileLog.LogBuffered("This card has a null list.");
                        }
                        else
                        {
                            if (listReferences.Count == 0)
                            {
                                FileLog.LogBuffered("This list is empty.");
                            }
                            else
                            {
                                foreach (TaleNewsReference reference in listReferences)
                                {
                                    if (reference == null)
                                    {
                                        FileLog.LogBuffered("Reading null entry.");
                                    }
                                    else
                                    {
                                        if (reference.UnderlyingTaleNews == null)
                                        {
                                            FileLog.LogBuffered("INVALID ENTRY! Null underlying news.");
                                        }
                                        else
                                        {
                                            FileLog.LogBuffered("Reading entry: " + reference.ToString());
                                            if (reference.UnderlyingTaleNews is TaleNewsPawnDied taleNewsPawnDied)
                                            {
                                                FileLog.LogBuffered("Entry is TaleNewsPawnDied.");
                                                Pawn primaryVictim = taleNewsPawnDied.PrimaryVictim;
                                                if (primaryVictim == null)
                                                {
                                                    FileLog.LogBuffered("Victim is NULL!!!");
                                                }
                                                else
                                                {
                                                    FileLog.LogBuffered("Victim is " + primaryVictim);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            FileLog.Log("System time is now " + DateTime.Now.ToShortDateString() + "; releasing results:");
            FileLog.FlushBuffer();
        }