Beispiel #1
0
    static EnemyManager()
    {
        defHandler = new DefHandler <EnemyDef>("Defs/Enemy");
        defHandler.LoadDefs();

        enemyPoolDict = new Dictionary <string, ObjectPool <GameObject> >();
    }
Beispiel #2
0
        public IEnumerable <DefFile> LoadDefFiles()
        {
            using var fs = new FileStream(LodPath, FileMode.Open, FileAccess.Read);
            var defHandler = new DefHandler();

            foreach (var item in TableOfContents)
            {
                if (!string.Equals(Path.GetExtension(item.Name), ".def", StringComparison.InvariantCultureIgnoreCase))
                {
                    yield return(null);

                    continue;
                }

                fs.Seek(item.DataOffset, SeekOrigin.Begin);

                byte[] defData;
                if (item.CompressedDataSize != 0)
                {
                    var compressed = new byte[item.CompressedDataSize];
                    fs.Read(compressed, 0, compressed.Length);

                    defData = Decompress(compressed, item.UncompressedDataSize);
                }
                else
                {
                    defData = new byte[item.UncompressedDataSize];
                    fs.Read(defData, 0, defData.Length);
                }
                var result = defHandler.LoadDef(Path.GetFileNameWithoutExtension(item.Name), defData);
                yield return(result);
            }
        }