예제 #1
0
        public void DoPurge()
        {
            for (int index = 0; index < AddedSinceLastPrune.Count; index++)
            {
                var characterParser = AddedSinceLastPrune[index];
                //   characterParser.UpdateCultural();

                if (characterParser == null)
                {
                    Characters.RemoveAt(index);
                    continue;
                }
                if (characterParser.ID == 1014792)
                {
                }
                if (characterParser.HadTitle)
                {
                    continue;
                }
                int age = characterParser.DistanceBeforeImportantDate;
                if (age > 60)
                {
                    Characters.Remove(characterParser);
                    CharacterMap.Remove(characterParser.ID);
                    AliveCharacters.Remove(characterParser);
                    characterParser.Purged = true;
                    continue;
                }

                if (age > 60)
                {
                    if (characterParser.Kids.Count > 0 && (!characterParser.HadTitle) && (characterParser.Spouses[characterParser.Spouses.Count - 1].HadTitle))
                    {
                        Characters.Remove(characterParser);
                        CharacterMap.Remove(characterParser.ID);
                        AliveCharacters.Remove(characterParser);
                        characterParser.Purged = true;
                    }
                    else if (!characterParser.HadTitle && characterParser.Kids.Count > 0)
                    {
                        bool keep = false;
                        foreach (var parser in characterParser.Kids)
                        {
                            if (parser.HadTitle)
                            {
                                keep = true;
                            }
                            if (parser.Kids.Count > 0)
                            {
                                keep = true;
                            }
                        }

                        if (!keep)
                        {
                            Characters.Remove(characterParser);
                            CharacterMap.Remove(characterParser.ID);
                            AliveCharacters.Remove(characterParser);
                            characterParser.Purged = true;
                        }
                    }
                }
            }
            AddedSinceLastPrune.Clear();
            for (int index = 0; index < AliveCharacters.Count; index++)
            {
                var characterParser = AliveCharacters[index];
                if (characterParser == null)
                {
                    AliveCharacters.RemoveAt(index);
                    index--;
                    continue;
                }

                if (characterParser.Age > 100)
                {
                    SimulationManager.DoDeath(characterParser);
                    AliveCharacters.Remove(characterParser);
                    index--;
                }
            }
        }