User:Greys/GameData and Assets

From Kerbal Space Program Wiki
Jump to: navigation, search

GameData is a folder in the KSP install directory where the majority of assets, plugins, and CFG files are stored. For the most part GameData is treated as a read-only repository, but it is possible for community plugins (mods) to modify files in GameData. The most common reason is to modify text files that only relate to that plugin, sometimes logs, sometimes cfgs, sometimes a personal save file.

By the stricted definition Assets are inert pieces such as mesh and textures, which will be used by the code to represent stuff. By the loosest definition Assets are anything in GameData. It is generally useful to distinguish between assemblies, otherwise known as plugins, and everything else. For this document Assets will include art assets such as mesh, textures, audio files, particle systems, etc; but not cfg files or plugins.

Loading

When KSP is executed it goes through several stages of loading from GameData. It's important to note that not everything that ends up in the game comes from GameData, but unless you're well versed with the ToS, EULA, Forum Rules, and Addon-Release Rules, you should avoid thinking about these other things.

When searching the file system KSP always goes depth first and in alphanumeric order with numbers coming before letters. This does impact the state of the game, parts will appear in that order as well, which is why Squad's parts typically show up after mod parts. This can also impact the resolution of dependencies in plugins; if you make a plugin which depends on another plugin and that plugin is alphabetically after yours, you may experience problems with loading. This can be resolved by prepending a character such as "z" to the start of your mod's folder in GameData, in order to change it's position in the loading queue. Though it has become common practice in such situations to use 000 or zzz, to ensure there are no 'natural competitors' for that position.

The first thing KSP loads is always plugins. Because of this it is possible to run code prior to there being any loaded cfg or assets.

Following that KSP loads all of the assets. For textures in particular this means loading the .MBM, .PNG, .TGA, and .JPG files found in GameData, and converting them to either DXT1 or DXT5, depending on if that texture in particular has an alpha channel. This is one of the most time consuming steps to the loading process.

Next all of the cfg files are loaded, parsed into ConfigNodes, and placed into the GameDatabase. From there KSP iterates over all the ConfigNodes in the GameDatabase and builds whatever they describe. This can be the most time consuming step of the loading process depending on how many cfg files you have; it's also the most likely step to break.

Types of Assets

Textures

Audio

.Mu Files