Game Mount Resources

Started by ducc · one year ago · 4 replies · 1,326 views

#1
ducc
Banned
JoinedSep 2022 Posts101 Score155
This is a thread for sharing game mounting resources, for people who are currently experimenting with the new mount system being developed for Sandbox.

Also, even if you have nothing to share here, feel free to ask questions about coding a BaseGameMount. I'll try to respond if I know the answer.

GameMaker Mount

I'm currently working on a mount for GameMaker games. Currently, it can extract textures, but only from newer games such as Deltarune, Pizza Tower, and Crunky's Fun Rager: sbox-gamemaker-mount

It also extracts embedded audio and can load loose ogg music (such as that of Deltarune), but Pizza Tower's sounds and music are not loaded because they are in FMOD banks, and I don't know how to open those.

LZ4 Encoder/Decoder

While working on a different mount, I found that attempting to use K4os.Compression.LZ4 in an editor project would cause compiler errors (SB500) because of the unsafe code. So, I trimmed down LZ4Net until it would compile using the slow, safe fallback option. 

The code for that should be attached here.

Doesn't seem like it got attached, maybe because it's a zip file? DM me on Discord if you want it, I guess.
#2
fishy
Member
JoinedFeb 2023 Posts82 Score1,548
Going to give myself a little side project with mounts as well.
We'll see how it all goes.
#3
trende
Member
JoinedJul 2022 Posts60 Score4,556
i'm mounting half life 2
edited one year ago#4
Marlamin
Member
JoinedJul 2021 Posts1 Score0
I'm working on a World of Warcraft mount.
GitHub: https://github.com/Marlamin/WoWSBoxMount/(isn't buildable from that repo given current weirdness around 3rd-party libraries)
Posting regular updates here: https://bsky.app/profile/marlam.in
#5
ducc
Banned
JoinedSep 2022 Posts101 Score155
Mount file paths can be confusing to talk or reason about.

When writing a mount, you must consider three different types of path, which I will explain in this post.

Source Path

The source path is an absolute, canonical path of the original game data as it exists on the user's system.

Here's example of the source path of a loose sound file, AUDIO_DRONE from DELTARUNE:
C:\Program Files (x86)\Steam\steamapps\common\DELTARUNE\mus\AUDIO_DRONE.ogg
For files that are packed within an archive, a full source path will include the path of the archive as well as the information necessary to find that file within the archive. 

The type of information used may be unique to the game or engine, and may include the following:
  • File offset, with or without length.
  • An index or name used by a file table within the archive.
  • A record type and index within that set of records.

Display Path

Whenever you add a resource to a MountContext, you must specify a path. This path will be added to the hierarchy of folders that your mount will display in the Asset Browser.

I call this path the display path because it does not necessarily have any relationship to the source path we discussed previously, and most of the path can be set to anything you want.

For example, that AUDIO_DRONE.ogg I described earlier, could have a display path of:
sounds/launcher/AUDIO_DRONE.ogg
Any directory or filename may be used in a display path, however the extension should match the ResourceType given to the MountContext, if applicable.

For example, because AUDIO_DRONE.ogg is meant to be handled as a sound file, its display path should end with .vsnd, like:
sounds/launcher/AUDIO_DRONE.ogg.vsnd
And you could even replace the existing extension, like:
sounds/launcher/AUDIO_DRONE.vsnd
 The ResourceType values of Model, Material, Texture, and Sound are expected to correlate with extensions .vmdl, .vmat, .vtex, and .vsnd respectively.

As of the time of this writing, the Scene ResourceType is not supported. As far as I know, there is no special behavior associated with ResourceTypes None, Text, or Binary.

If a specific extension or ResourceType should be handled specially, then any game using your mount will need to account for this behavior itself.

For example, let's say that your mount should provide information on how a sprite maps to a texture atlas. You arbitrarily decide that every sprite your mount will adhere to the following conventions when added to the MountContext:
  • ResourceType.Text is used
  • The display path ends in .sprite
  • The value returned by ResourceLoader.Load is a JSON string with properties for: 
    • Texture atlas index
    • Texture atlas size
    • The position and size of the sprite
Any game using your mount would need to be aware of all of these conventions, and know to load sprites in this way.

Resource Path

The third path we'll discuss is a resource path that is used in any context where it's unclear to what mount or FileSystem a given path is expected to belong.

A resource path is a display path that it is prepended by both:
  • A mount URI scheme, i.e., mount:// 
  • A directory with a name matching the ident of your BaseGameMount
For example:
mount://deltarune/sounds/launcher/AUDIO_DRONE.vsnd
If a method such as Texture.Load is used to fetch your resource using a path string, that method will expect a resource path as an argument.

IMPORTANT: Because a display path is local to your BaseGameMount, static methods that load a resource will fail when given a display path instead of a resource path!

Mount Troubleshooting

Here are some common problems with mounts, and solutions for dealing with them.

The mount section of Asset Browser is missing:
  1. Right click on a blank area on the left part of the Asset Browser
  2. Click "Show Mounts" in the menu that appears
A mount is missing from the list appears when right-clicking on Mounts:
  1. Ensure that your BaseGameMount is in the Editor C# project generated for your s&box project
  2. Ensure that BaseGameMount.IsInstalled is set to true in BaseGameMount.Initialize.
A mount is loaded, but one or more of its resources are missing from the Asset Browser:
  1. Ensure that the display path of the resource does not contain special directories such as ../ that could confuse s&box.
A mount resource appears in the Asset Browser, but an exception is thrown when clicking on the resource or generating its thumbnail:
  1. Ensure that your ResourceLoader for that type of resource is not throwing an exception.
  2. Ensure that the resource path of the resource consistently uses the same style of slash characters.
  3. Ensure that the file extension of your display path matches the extension expected for that type of resource.
A Model appears in the scene when dragged from the Asset Browser to the scene editor, but will not load again after saving and reloading the scene:
  1. Ensure that ModelBuilder.WithName is given the resource path of your Model.
  2. Ensure that your Model display path ends with .vmdl
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.