japsuu / KorpiEngine

Simple, modern, code-only C# game engine!
https://japsuu.github.io/KorpiEngine/
MIT License
18 stars 1 forks source link

Add Asset Compression support #63

Open japsuu opened 1 day ago

japsuu commented 1 day ago

Is your feature request related to a problem? Please describe. Currently, external game assets are not compressed in any way during build, but are copied straight into the build folder. This causes bloated build sizes, and any game assets can be easily edited by anyone without any deeper knowledge of the engine functionality, possibly allowing for very easy cheating in games.

Describe the solution you'd like Game assets should be compressed when a project is built, and placed into a separate "GameData" directory.

However, this somewhat complicates purposefully allowing user-generated-content (UGC) to be imported into a built game, as the content would have to be compressed using a standalone tool. One solution could be to expose the raw file importers and allow users to import their own files with them.

Describe alternatives you've considered Not supporting asset compression.

Additional context None.

japsuu commented 1 day ago

If we want any kind of custom compression for asset files, we most likely need a separate editor layer/executable.

The editor layer can even just be a standalone asset editor executable, that takes raw asset files (images, meshes, audio files) as input, and outputs custom compressed packages. Only the asset editor would have access to the asset importers. The asset editor could be set to run automatically in headless mode each time the project is built, so that it would process the raw assets, and output packages in the project build directory.

Let's say that the Asset class has an abstract Serialize(FileStream stream) -method, which is meant to serialize the asset to a file. This method could be called by the asset editor for each imported asset to package them.