コード例 #1
0
        private bool LoadAnimation()
        {
            string path = FileSystem.Normalize(Path.Combine(label.install_path, "anim"));

            if (!System.IO.Directory.Exists(path))
            {
                return(false);
            }
            int           num           = 0;
            DirectoryInfo directoryInfo = new DirectoryInfo(path);

            DirectoryInfo[] directories = directoryInfo.GetDirectories();
            foreach (DirectoryInfo directoryInfo2 in directories)
            {
                DirectoryInfo[] directories2 = directoryInfo2.GetDirectories();
                foreach (DirectoryInfo directoryInfo3 in directories2)
                {
                    KAnimFile.Mod mod   = new KAnimFile.Mod();
                    FileInfo[]    files = directoryInfo3.GetFiles();
                    foreach (FileInfo fileInfo in files)
                    {
                        if (fileInfo.Extension == ".png")
                        {
                            byte[]    data      = File.ReadAllBytes(fileInfo.FullName);
                            Texture2D texture2D = new Texture2D(2, 2);
                            texture2D.LoadImage(data);
                            mod.textures.Add(texture2D);
                        }
                        else if (fileInfo.Extension == ".bytes")
                        {
                            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name);
                            byte[] array = File.ReadAllBytes(fileInfo.FullName);
                            if (fileNameWithoutExtension.EndsWith("_anim"))
                            {
                                mod.anim = array;
                            }
                            else if (fileNameWithoutExtension.EndsWith("_build"))
                            {
                                mod.build = array;
                            }
                            else
                            {
                                DebugUtil.LogWarningArgs($"Unhandled TextAsset ({fileInfo.FullName})...ignoring");
                            }
                        }
                        else
                        {
                            DebugUtil.LogWarningArgs($"Unhandled asset ({fileInfo.FullName})...ignoring");
                        }
                    }
                    string name = directoryInfo3.Name + "_kanim";
                    if (mod.IsValid() && (bool)ModUtil.AddKAnimMod(name, mod))
                    {
                        num++;
                    }
                }
            }
            return(true);
        }