sledge-formats icon indicating copy to clipboard operation
sledge-formats copied to clipboard

Add `IFileResolver` implementation for `IPackage` instances

Open LogicAndTrick opened this issue 1 year ago • 0 comments

To fully emulate a game environment for some games, IPackage instances need to be added as sources to a CompositeFileResolver. Add a PackageFileResolver to the Sledge.Formats.Packages library that will accept an IPackage as its source.

Also consider cases where a package (or just a different folder) might need to be added to CompositeFileResolver with a different root - not sure if any games actually require that, but would be good for extensibility. I think this could be solved by having something like a VirtualSubdirectoryFileResolver that wraps another IFileResolver and prefixes all its files with a subfolder path.

For example:

  • GameName/ModName/models/abc.mdl
  • GameName/ModName/models.pak -> def.mdl

Root would be GameName/ModName, and models.pak should be added with a prefix of models/. Like so:

var modelsPak = new PakPackage("GameName/ModName/models.pak");
var environment = new CompositeFileResolver(new IFileResolver[]
{
    new DiskFileResolver("GameName/ModName/"),
    new VirtualSubdirectoryFileResolver("models/", new PackageFileResolver(modelsPak))
});

LogicAndTrick avatar Jul 07 '24 03:07 LogicAndTrick