Guide/Working with the Game Files

Looking at the game files can help provide valuable insight into game mechanics, as well as providing higher-quality art for use on wiki pages. The game files can be found through Steam, by right-clicking on the game in your Library and following Properties, Local Files tab, Browse Local Files...

Code
To look at the code, you need a C# decompiler. Some options are dotPeek, ILSpy, and dnSpy (each have their strengths and weaknesses, you may want to use multiple). Once you have a decompiler, you can decompile the  file, which contains most of the game code. Some more engine-related code is also in the adjacent  file.

Note that decompiled code is not as easy to read as normal source code, so it may be difficult to follow some parts (for example, local variable names are inferred by the decompiler and can be pretty unhelpful, and all comments are lost). Here are some tips about the organization of the code:


 * is often a good starting point for looking at the code, because you can first search for the in-game name of an entity, and then the variable name will tell you what the code calls it. For example, "Wheezewort" leads to "Coldbreather".
 * TUNING contains a lot of balance information, but can't always be linked to the code that uses it due to compiler optimizations.
 * Most game code is in the root namespace.
 * Most entities have two objects for their code, a main object, which typically handles their state machine information (how they control their time-based behavior), and a Config object, which sets up most of their components and assigns values; the main object is useful for understanding behavior, while the Config is useful for understanding balance.
 * Sometimes you will encounter a message being sent as a long number. These are hashes; you can look for the more informative name in GameHashes, SimHashes, SimMessageHashes, etc.
 * Sometimes dotPeek will have trouble decompiling some code and show it as a lot of compiler-generated fields. dnSpy often handles these sections better.

Config
Most of Config files (like that for world-gen) and some simple balance can be found in subfolders of. The data format of most files is YAML.
 * : The in-game codex.
 * : Templates and world-gen dedicated for the DLC
 * : Elements properties, including their  (defined in  ), specific heat capacity, light absorption factor and more.
 * : Translation of entities' name. They are also helpful for English uses as they matches context (used in code, like ) with id (English name, like "(That means they climb it.)").
 * : In-game structure,.
 * : World generation.

Assets
Some tuning and all of the art is in the asset bundles, which are the  files directly inside of. These can be opened with Unity Assets Bundle Extractor or AssetStudio. One tip for the Assets Bundle Extractor: you can box-select files to extract in bulk by dragging from the right of the listing area, or using  and   combinations with   or arrows for multiselection.

The bundle extractor can extract textures as png images, which is useful for getting material for the wiki. However, you may found that most images are consist of components of the corresponding objects. These components can be used to assemble more complicated textures and replay the animation with the help of the TextAsset files,  and. An animation tool generates  files which can be opened with Spriter (essential edition is available for free in Don't Stave Mod Tools) and exported as png files of rendered images. It is said that gif animations can be exported if a pro version of Spriter is available.

and  is likely to be a Klei format, and on inspection appears to be similar to the one they used in Don't Starve (Together). There may be more information in the  files in , and the tools built for Don't Starve may be a good starting point for our own tool for working with these anims.

Note that some textures have non-obvious names, like "cuprite" for copper ore and "CookedEgg" for omelette. You can discover the internal name by creating the desired item or substance in game, saving it as a template, and then looking up the "id" field in the YAML file. Also, note that capital letters sort before lowercase letters and that capitalization of the id field might be different than the asset name. For instance, the id for an omelette is "CookedEgg" but the texture name starts with "cookedegg".

Many properties of the elements, including their material properties and freezing/melting points, can be found in the "sharedassets2.assets" file, as text assets named "Solid", "Liquid" and "Gas", with the solid, liquid, and gaseous forms of each element defined. Other advanced/optional properties, like the element's decor, live in the LegacyModMain class.

Reference
游戏数据处理