コード例 #1
0
 /// <summary>
 /// Forces garbage collection.
 /// </summary>
 public void Clear()
 {
     GameObjects.Clear();
     TranslationLookup.Clear();
     Translations.Clear();
     Races.Clear();
     StatStructures.Clear();
     TextureAtlases.Clear();
     GC.Collect();
     GC.WaitForPendingFinalizers();
     GC.Collect();
 }
コード例 #2
0
        /// <summary>
        /// Reads the stats and converts them into a StatStructure list.
        /// Uses reflection to dynamically generate data.
        /// </summary>
        /// <param name="pak">The pak to search in.</param>
        /// <returns>Whether the stats were read.</returns>
        private bool ReadData(string pak)
        {
            var dataDir = FileHelper.GetPath($"{pak}\\Public\\{pak}\\Stats\\Generated\\Data");

            if (Directory.Exists(dataDir))
            {
                var dataFiles = Directory.EnumerateFiles(dataDir, "*.txt").Where(file => !ExcludedData.Contains(Path.GetFileNameWithoutExtension(file))).ToList();
                foreach (var file in dataFiles)
                {
                    var fileType = Models.StatStructures.StatStructure.FileType(file);
                    var line     = string.Empty;
                    using (var fileStream = new System.IO.StreamReader(file))
                    {
                        while ((line = fileStream.ReadLine()) != null)
                        {
                            if (line.Contains("new entry"))
                            {
                                StatStructures.Add(Models.StatStructures.StatStructure.New(fileType, line.Substring(10)));
                            }
                            else if (line.IndexOf("type") == 0)
                            {
                                StatStructures.Last().Type = fileType;
                            }
                            else if (line.IndexOf("using") == 0)
                            {
                                StatStructures.Last().InheritProperties(line, StatStructures);
                            }
                            else if (!string.IsNullOrEmpty(line))
                            {
                                StatStructures.Last().LoadProperty(line);
                            }
                        }
                    }
                }
                return(true);
            }
            return(false);
        }