Welcome to our guide for Mazelit’s Source Code DLC! In this guide, we will show you how to get the most out of this DLC. We will walk you through the game’s structure, how to build the game, and how to add Steam integration using C++. Let’s get started!
What you can and cannot do with the code, disclaimers
https://store.steampowered.com/subscriber_agreement
As a very short version, this code is provided for your personal use for educational purposes and for modding Mazelit itself. You should not publish it anywhere and you should also not use it as part of your own game. You are also not allowed to publish Mazelit under the same or a different name on Steam or any other platform.
It is important to mention that game development is hard and there is no guarantee that the game will even run on your system when compiled from source due to differences in systems, compilers, etc. (Please note, we cannot provide individualized support for building the game.)
In addition to the Steam Subscriber Agreement, you may also use small portions of the code to create and publish mods (including the source code), blog posts, videos, and other content, as long as:
- It is clear to the viewer where the code is coming from. In case of a mod, add a code comment to any code sections you copied. In case of a video, place a link to the store page.
- Your mod does not disable any DLC checks that are in the game.
- You are not publishing a game playable without a purchase of the Mazelit game on Steam.
- When you publish a mod, place it under a license (e.g. the MIT license) that disclaims any warranties.
Note, that some folders contain content under an open source license, which you can use freely according to their own license. Please see the text documents in the “licenses” folder for details.
The folder structure
addons
The gdserialize[github.com] library, which is responsible for creating and reading JSON data structures in a safe way. This library is available under the open source MIT license.
assets
Most assets such as graphics and sounds are in this folder.
characters
Player graphics and NPC scenes.
collectible
Scene and code for the collectibles.
dist
We create the ZIP file we upload to Steam from this folder. It contains all the additional files we need to ship with the game.
drone
Pickup drone scene and code.
enemy
Scary, scary enemy code here.
integration
Code for the Steam integration written in C++. Please see the last section for details.
intermission
Level up and upgrade screens.
level
Level loader and the level itself. It is worth noting that for later levels, generating and especially spawning the nodes in Godot takes a long time (up to 15 seconds), which is why the level loader uses multiple threads in conjunction with the maze generator and solver. Unfortunately, Godot’s multi-threading is still in the early stages and rough around the edges, so be careful when changing this code.
lib
Pre-built Steam integration you can use if you do not want to rebuild from
source.
licenses
Licenses for the third-party components we use.
maze
Maze implementation, maze generator, and a maze solver. Currently, we only use the scene-based maze system due to limitation in Godot’s tilemap implementation, but we also left a tilemap impementation in here which you may find useful.
As noted with the level folder, the maze generator and solver run multi-threaded, which is something that is not as well-documented in Godot, so be careful when editing this part of the code.
menu
Main menu, escape menu, settings, etc.
player
Player code and player data which is responsible for handling save games.
portal
Portal code and scene.
system
The general folder for anything that is happening in the background. Player settings, input mapping, Steam integration, etc. It makes heavy use of gdserialize[github.com] and there are quite a few quirks around how Godot handles resources here.
trap
Trap code and scene.
ui
UI components that don’t fit in elsewhere.
How to run the game in Godot
The game folder contains a copy of the supported version of Godot (4.2.1). If you simply want to run the game, you can click Godot.exe / Godot.x86_64 and it will run the game with all your modifications. You can also run the GodotEditor / GodotEditor.sh file to open the editor.
The development version will use the Steam integration from the lib folder (mazelit-debug.dll and libmazelit-debug.so) and should work with
your Steam client. If you get an error message about the Steam client, please make sure you start Steam before starting the game.
If you need additional debug info, you can open the Steam console. On Windows, press Windows+R and type steam://open/console. On Linux, run steam steam://open/console from a terminal. Here, you can enter set_spew_level 4 4 to get a debug output.
If you want to test the achievements, you can use the achievement_clear [appid] [achievementname] command in the console to remove an achievement from your profile.
To test how your changes behave with your mod, you can use the enable_license and disable_license commands to add or remove a DLC license with the correct app ID on your account.
The app IDs for the game are:
- Base game: 2816120
- Style DLC: 2912560
- Code DLC: 2906580
If you would like to run the game on a different, non-supported platform (e.g. MacOS), you will need to compile the C++ Steam integration hooks for that platform and download the corresponding version of Godot from the Godot website: https://godotengine.org/
Building the C++ Steam integrations on Windows and Linux
First, you will need to decide if you want to just compile the Steam hooks without actually using the Steamworks SDK, or if you want the full Steam integration.
Just compiling the hooks is useful if you want to get the game to run on a platform or with a compiler that Steamworks does not support. We wrote the code for all functions to return a sensible default when running with just the hooks. You can still play the game but achievements and DLC checks will, of course, not work.
If you want to compile with the full integration, you will need to download the Steamworks SDK here: https://partner.steamgames.com/doc/sdk
Rename the downloaded ZIP file to steamworks_sdk.zip and place it in the integration/steam/vendor folder. This automatically enables building with the full integration.
Next, you will need to decide on your compiler toolchain. On Windows, you will need Visual Studio for the full integration as the Steamworks SDK does not support – and will not work – with MinGW. (Save yourself the pain, it fails in very non-obvious ways.)
On Linux, you will need to use cmake and gcc to compile both the hooks and the full integration.
For all platforms, please make sure that you have git installed.
Before you proceed, we recommend reading the GDExtension documentation
for Godot:
https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/what_is_gdextension.html
In order to compile with Visual Studio, you will need to set up Visual Studio to build C++ projects.
⚠️ You can use a different code editor, such as Visual Studio Code or CLion, but you must use the Visual Studio C++ compiler toolchain.
In your IDE, open the “integrations/steam” folder and configure cmake. (In Visual Studio, you should get an option to configure cmake after you open the folder if you have the C++ compiler correctly installed.)
You can now build the project. It will automatically download godot-cpp for you and build it (this may take a while). Once the build is finished, you can run the install process (Build → Install in Visual Studio) to dump the build debug library into the “lib” folder.
To compile on Linux, you need to have gcc, cmake, and git installed. You can either use an IDE or run the following commands in the console to compile the extension:
cmake -DCMAKE_BUILD_TYPE=Debug -B cmake-build-debug-gcc .
cd cmake-build-debug-gcc
make -j 8
make install
The result will be the “libmazelit-debug.so” file in the “lib” folder.
If you compiled for an unsupported platform or architecture, please make sure to edit the mazelit.gdextension file in the lib folder before you start Godot.
When you start Godot, watch out for any error messages in the Output tab indicating a gdextension loading error.
And that wraps up our share on Mazelit: Mazelit – Source Code DLC. If you have any additional insights or tips to contribute, don’t hesitate to drop a comment below. For a more in-depth read, you can refer to the original article here by Something Pink, who deserves all the credit. Happy gaming!