RigsOfRods / rigs-of-rods

Main development repository for Rigs of Rods soft-body physics simulator
https://www.rigsofrods.org
GNU General Public License v3.0
1.01k stars 177 forks source link

New mod type: asset pack (.assetpack) #3129

Closed ohlidalp closed 7 months ago

ohlidalp commented 7 months ago

Quick 2hr draft - ~BUILDS, NOT TESTED.~ Tested, added example mods.

A new file type "*.assetpack" was added to modcache with all the usual treatment:

Assetpacks are referenced by the file name (standard approach) and can be used for both terrains and actors:

Note that, unlike any other mod, assetpacks aren't loaded to their own resource group but rather to the resoruce group of the mod which requested them. Therefore try to name all resources in an unique way to avoid clashes.

Test mods - a wacky mini terrain I created for future tests, and one mesh (with multiple .ODEFs) I extracted from it:

cryham commented 7 months ago

Great.

Note that, unlike any other mod, assetpacks aren't loaded to their own resource group but rather to the resoruce group of the mod which requested them. Therefore try to name all resources in an unique way to avoid clashes.

One thing I have in mind is version. What if I someday decide to make a newer version of e.g. SR_Terrain asset pack? E.g. fixing some texures or adding some more. IMO version should also be a part of a pack identifier. But with logic that would let us replace older version of same asset pack. Do you agree or do you have a different approach to such case?

Also I understand that this other resource group is just name, but game will look into it just like for other resources, right? So terrain etc will search it too in case some assets are for it?

BTW. we need to name resources inside also uniquely right? E.g. grass2.png, palm.png etc are already in paged.zip, so for SR assets I need to rename such cases to something not present in RoR already.

ohlidalp commented 7 months ago

Assetpacks are referenced exclusively by filename of the .assetpack, same as all other mods in the game. For a different version or any customized edition, just use new filename. Anything more would be excess complexity.

My goal is to use explicit RGs everywhere but former OGRE versions defaulted to searching everything and former RoR Devs didn't care. IIRC paged is hardcoded to use the default RG.

Yes, resources must be named to avoid clashes with any prepacked media.

cryham commented 7 months ago

Allright. So e.g. I'll have a SR_objects_v1 pack and in future will do a SR_objects_v2 and users will just get that instead and disable the v1. Sounds fair.

ohlidalp commented 7 months ago

@cryham Have you tested it yet? You can download the github-actions devbuild below.

cryham commented 7 months ago

Not yet, I'll test later today.

cryham commented 7 months ago

Allright this works well.

cryham commented 7 months ago

So how small should I make these? I think with smaller I'd have more work but maybe less download for users. Is e.g. one sr-terrain-v1 with say 300 MB of png data okay? and other with 200 MB called sr-terrain-extra-v1? Or should I even make each scenery textures separate? Other packs e.g.: sr-grasses, sr-trees, sr-trees_old, sr-trees_ch, sr-objects0ad, sr-objectsCity etc? I think this is good so right? This way less upload size for me and download (on changes) for users, but more maintenance to keep track of it all.. I think I'll put all materials and checkpoints into separate packs too, not sure yet.

BTW can I call all SR tracks with prefix: ^Grc2-Coast or +Grc2-Coast or so in RoR? It's easier since they're on top of list. Or will there be a new group? Still would be mixed in list when all visible.

Also how will this work for users? E.g. someone gets from repo in game a track Grc2-Coast, then will RoR auto download all needed packs for it if not present?

ohlidalp commented 7 months ago

That sounds perfectly fine. I don't know the assets so I'll leave it to you to partition them so that it makes sense - I skimmed through the online map viewer at stuntrally website and I see you've got maps categorized by theme with prefixes. We have nothing like that as every map was individual. But I like it, go ahead.

@CuriousMike56 Any opinions on this?

CuriousMike56 commented 7 months ago

Tested demo files, works fine. No issues with the file format 👍

Also how will this work for users? E.g. someone gets from repo in game a track Grc2-Coast, then will RoR auto download all needed packs for it if not present?

Best solution IMO would be to add a "required files/dependencies" prompt when downloading from the in-game repo. Not sure how this would work on the website side.

ohlidalp commented 7 months ago

As a matter of fact, the Tuning branch #3096 internally modified modcache and enabled background updates. It was needed to save tuneups which must be modcache entries and must be created during simulation. This means:

I just realized a similar mechanism would be useful to recommend downloading mods which are preloaded in terrain (for example locos and railcars in TrainValley). No special syntax is needed actually, modcache can pick it up directly from the .tobj files and just prompt and then search.