// Token: 0x0600002E RID: 46 RVA: 0x000035EC File Offset: 0x000017EC
        public static List <Texture2D> GetTexturesFromDirectory(string directoryPath)
        {
            bool             flag = !Directory.Exists(directoryPath);
            List <Texture2D> result;

            if (flag)
            {
                Tools.PrintError <string>(directoryPath + " not found.", "FF0000");
                result = null;
            }
            else
            {
                List <Texture2D> list = new List <Texture2D>();
                foreach (string text in Directory.GetFiles(directoryPath))
                {
                    bool flag2 = !text.EndsWith(".png");
                    if (!flag2)
                    {
                        Texture2D item = ResourceExtractor.BytesToTexture(File.ReadAllBytes(text), Path.GetFileName(text).Replace(".png", ""));
                        list.Add(item);
                    }
                }
                result = list;
            }
            return(result);
        }
        // Token: 0x0600002F RID: 47 RVA: 0x00003694 File Offset: 0x00001894
        public static Texture2D GetTextureFromFile(string fileName, string extension = ".png")
        {
            fileName = fileName.Replace(extension, "");
            string    text = Path.Combine(ResourceExtractor.spritesDirectory, fileName + extension);
            bool      flag = !File.Exists(text);
            Texture2D result;

            if (flag)
            {
                Tools.PrintError <string>(text + " not found.", "FF0000");
                result = null;
            }
            else
            {
                Texture2D texture2D = ResourceExtractor.BytesToTexture(File.ReadAllBytes(text), fileName);
                result = texture2D;
            }
            return(result);
        }
Exemple #3
0
        public static IEnumerable <RoomData> BuildFromZipFile(string zipFilePath)
        {
            if (!ZipFile.IsZipFile(zipFilePath))
            {
                Tools.Log($"Not a valid zip file!");
                yield break;
            }
            using (var zipFile = ZipFile.Read(zipFilePath))
            {
                //Tools.PrintNoID("did it work?");
                foreach (var entry in zipFile.Entries)
                {
                    var fileName  = Path.GetFileNameWithoutExtension(entry.FileName);
                    var extension = Path.GetExtension(entry.FileName);
                    if (!string.Equals(extension, ".room", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    byte[] zipData;
                    int    capacity = (int)entry.UncompressedSize;
                    if (capacity < 0)
                    {
                        continue;
                    }

                    using (var ms = new MemoryStream(capacity))
                    {
                        entry.Extract(ms);
                        zipData = ms.ToArray();
                    }

                    var texture  = ResourceExtractor.BytesToTexture(zipData, fileName);
                    var roomData = ExtractRoomDataFromBytes(zipData);
                    roomData.room = Build(texture, roomData);

                    yield return(roomData);
                }
            }
        }