Exemple #1
0
        public SkinPack GetFiles(string rootPath, bool allowMultiple = false)
        {
            var reader   = new SkinReader();
            var files    = new SkinPack();
            var pakFiles = GetAllPakFiles(rootPath);

            foreach (var file in pakFiles)
            {
                var relPath     = Path.GetRelativePath(rootPath, file.FullName);
                var useMultiple = allowMultiple || file.Name.Contains("MULTI") || file.Length < 8192;
                if (useMultiple)
                {
                    var idents = reader.ReadAllSkinSlots(file.FullName);
                    if (idents == null || !idents.Any())
                    {
                        files.ExtraFiles.Add(relPath);
                    }
                    else if (idents.Count() > 1)
                    {
                        files.MultiSkinFiles.Add(relPath, idents);
                    }
                    else
                    {
                        files.Skins.Add(relPath, idents.First());
                    }
                }
                else
                {
                    var ident = reader.ReadSkinSlot(file.FullName);
                    if (ident != null)
                    {
                        files.Skins.Add(relPath, ident);
                    }
                    else
                    {
                        files.ExtraFiles.Add(relPath);
                    }
                }
            }
            var textFiles = Directory.EnumerateFiles(rootPath, "*.txt", SearchOption.TopDirectoryOnly);

            files.ReadmeFiles = textFiles.Count() > 0 ? textFiles.Select(f => Path.GetRelativePath(rootPath, f)).ToList() : new List <string>();
            return(files);
        }
Exemple #2
0
        public static void Load(uint fileDataId, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            var model = new M2Model
            {
                FileDataId = fileDataId,
                Position   = position,
                Rotation   = rotation,
                Scale      = scale
            };

            // Parse the M2 format
            M2Reader.ReadM2(fileDataId, model);

            // Parse the SKIN format.
            foreach (var skinFile in M2Reader.SkinFileIds)
            {
                SkinReader.ReadSkin(skinFile, model);
            }

            M2Data.EnqueuedModels.Enqueue(model);
        }