Ejemplo n.º 1
0
 public object Get(string name, Type expected)
 {
     if (name == null)
     {
         return(null);
     }
     if (expected == typeof(Animation))
     {
         name = name.Substring(0, name.Length - 5).ToLowerInvariant(); //remove .anim
         string filename = null;
         if (AnimHostBCF.TryGetValue(name, out filename))
         {
             var bcf  = BCFProvider.Get(filename);
             var anim = bcf.Animations.FirstOrDefault(x => x.Name.ToLowerInvariant() == name);
             if (anim == null)
             {
                 return(null);
             }
             if (anim.Translations == null)
             {
                 //enrich animation with CFP
                 var cfp = CFPProvider.Get((anim.XSkillName + ".cfp").ToLowerInvariant());
                 if (cfp == null)
                 {
                     return(null);
                 }
                 cfp.EnrichAnim(anim);
             }
             return(anim);
         }
         return(null);
     }
     else if (expected == typeof(Appearance))
     {
         name = name.Substring(0, name.Length - 4).ToLowerInvariant(); //remove .apr
         string filename = null;
         if (SkinHostBCF.TryGetValue(name, out filename))
         {
             var bcf  = BCFProvider.Get(filename);
             var skin = bcf.Appearances.FirstOrDefault(x => x.Name.ToLowerInvariant() == name);
             return(skin);
         }
         return(null);
     }
     else if (expected == typeof(Skeleton))
     {
         name = name.Substring(0, name.Length - 5).ToLowerInvariant(); //remove .skel
         string filename = null;
         if (SkelHostBCF.TryGetValue(name, out filename))
         {
             var bcf  = BCFProvider.Get(filename);
             var skel = bcf.Skeletons.FirstOrDefault(x => x.Name.ToLowerInvariant() == name);
             return(skel);
         }
         return(null);
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 2
0
        private DecodedSFX GetAudioFrom(string fileName)
        {
            if (fileName == null)
            {
                return(null);
            }
            fileName = fileName.ToLowerInvariant();
            var ext   = Path.GetExtension(fileName);
            var fname = Path.GetFileName(fileName);

            switch (ext)
            {
            case ".wav":
                return(WAVSounds.Get(fname));

            case ".mp3":
                return(MP3Sounds.Get(fname));

            case ".xa":
                return(XASounds.Get(fname));

            case ".utk":
                return(UTKSounds.Get(fname));
            }
            Console.WriteLine("what... " + ext);
            return(null);
        }
Ejemplo n.º 3
0
        protected override Func<string, GameObjectResource> GenerateResource(GameObjectReference reference)
        {
            return (fname) =>
            {
                /** Better set this up! **/
                IffFile iff = null;

                if (reference.Source == GameObjectSource.Far)
                {
                    iff = GameObjects.Get(reference.FileName.ToLower());
                    if (iff != null) iff.RuntimeInfo.Path = reference.FileName;
                }
                else
                {
                    //unused
                    iff = new IffFile(reference.FileName);
                    iff.RuntimeInfo.Path = reference.FileName;
                    iff.RuntimeInfo.State = IffRuntimeState.Standalone;
                }

                if (iff != null)
                {
                    if (iff != null && iff.RuntimeInfo.State == IffRuntimeState.PIFFPatch)
                    {
                        //OBJDs may have changed due to patch. Remove all file references
                        ResetFile(iff);
                    }
                    iff.RuntimeInfo.UseCase = IffUseCase.Object;
                }

                return new GameObjectResource(iff, null, null, reference.FileName);
            };
        }
Ejemplo n.º 4
0
        private DecodedSFX GetAudioFrom(string fileName)
        {
            var ext   = Path.GetExtension(fileName);
            var fname = Path.GetFileName(fileName);

            switch (ext)
            {
            case ".wav":
                return(WAVSounds.Get(fname));

            case ".mp3":
                return(MP3Sounds.Get(fname));

            case ".xa":
                return(XASounds.Get(fname));

            case ".utk":
                return(UTKSounds.Get(fname));
            }

            return(null);
        }