Facepunch / sbox-issues

176 stars 12 forks source link

Map streaming progress #4666

Open youarereadingthis opened 8 months ago

youarereadingthis commented 8 months ago

For?

S&Box

What can't you do?

I haven't been able to find a way to tell the game to load/stream a map file and retrieve the progress in real time. I have only found a way to tell the game to load a map using MapInstance and knowing when it is done through OnMapLoaded or IsLoaded.

How would you like it to work?

Could be as simple as adding MapInstance.LoadingProgress.

Either have it be a fraction of loading(for pre-existing or cloud downloaded maps) or have it be a struct that tells you the mbps, fraction, total file size, etc.

What have you tried?

Looking through decompiled class files, to no avail.

Additional context

I want this so that I can have a custom level selection screen where you pick a map and THEN it downloads, and you can see a progress bar, instead of having it just say "Loading/Downloading Map.." for up to a minute or so depending on connection.

With a custom select screen I can have it tell you what place you are on the leaderboard, what your best time was, get your best "medal" etc, per level.

Something like this would also be very useful for content streaming in general! But relevantly, if I have like 20 levels in my game I don't want to have players download them all at once or not know when the download is done.

MrBrax commented 8 months ago

considering the entire game freezes for a solid 15+ seconds while loading the map, it would need to do a lot of background loading first before streaming would be viable

youarereadingthis commented 8 months ago

I tested it and I can set the map path of my MapInstance at runtime and it'll stream the map in as I am playing, though with some lag understandably. But that's not a problem if you're sitting at a loading screen after the scene has loaded.