Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ability to use assets defined in src/test #71

Open
keturn opened this issue Oct 6, 2021 · 1 comment
Open

add ability to use assets defined in src/test #71

keturn opened this issue Oct 6, 2021 · 1 comment
Labels
Size: M Medium-sized effort likely requiring some research and work in multiple areas Type: Improvement Request for or addition/enhancement of a feature

Comments

@keturn
Copy link
Contributor

keturn commented Oct 6, 2021

I was looking at writing tests for DynamicCities. It has systems that depend heavily on prefab assets for configuration. Sure, we can change those things to add programmatic interfaces for configuration as well, but it's a reasonable design: Configuration of these things should be data-driven, and the way modules load data is through the asset manager.

But I don't want the assets I define for specific test scenarios mixed in with all the other assets meant for gameplay.

[original discussion]

@keturn keturn added Type: Improvement Request for or addition/enhancement of a feature Size: M Medium-sized effort likely requiring some research and work in multiple areas labels Oct 6, 2021
@keturn
Copy link
Contributor Author

keturn commented Nov 8, 2021

dumping a draft here:

class ModuleFactory {
    public static Module registerClasspathAssets(String packageName) {
        // This is essentially ModuleFactory.createPackageModule, but for only assets (no classes) and
        // no support for precompiled reflections cache.
        ModuleMetadata metadata = new ModuleMetadata(new Name(packageName), new Version(0, 0, 1));
        Reflections assetManifest = new Reflections(new ConfigurationBuilder()
                .addScanners(new ResourcesScanner())
                .forPackages(packageName)
        );
        ModuleFileSource fileSource = new ClasspathFileSource(assetManifest, packageName.replace('.', '/'));
        return new Module(metadata, fileSource, Collections.emptyList(), assetManifest, x -> false);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: M Medium-sized effort likely requiring some research and work in multiple areas Type: Improvement Request for or addition/enhancement of a feature
Projects
None yet
Development

No branches or pull requests

1 participant