Client only version of this template
- Space Engineers
- Python 3.12 (requires 3.12 or newer)
- Pulsar — plugin loader for Space Engineers (game client)
- Magnetar — the Space Engineers server with plugin support
- .NET Framework 4.8.1 Developer Pack and .NET 10 SDK
- Click on Use this template (top right corner on GitHub) and follow the wizard to create your repository
- Clone your repository to have a local working copy
- Run
setup.py, enter the name of your plugin project inCapitalizedWordsformat - Let
setup.pyauto-detect your install locations or fill them in manually - Open the solution in Visual Studio or Rider
- Make a test build
- Add the repository as a development folder to Pulsar (client) and Magnetar (server), then test that the empty plugin can be enabled in both
- Replace the contents of this file with the description of your plugin
- Follow the TODO comments in the source code
- Look into the source code of other plugins for examples on how to patch the game
You may find the source code of these plugins inspirational:
In case of questions please feel free to ask the SE plugin developer community on the Pulsar Discord server in their relevant text channels. They also have dedicated channels for plugin ideas, should you look for a new one.
Good luck!
The plugin version lives in Version.Build.props, which is committed and imported by
Directory.Build.props. Keeping the version separate from the local path overrides means it
is shared by all contributors and stays under version control. Bump the version there.
Directory.Build.props is committed and declares the overridable folder paths with empty
defaults:
Bin64— the folder containingSpaceEngineers.exeDedicated64— the folder containingSpaceEngineersDedicated.exePulsar— the Pulsar folder the client plugin is deployed into after each build, empty by default (see Deployment)Magnetar— the Magnetar installation folder, the one holding the launcher executables and theirLibraries, which is wherePluginSdk.dllis referenced fromMagnetarData— the Magnetar config folder the server plugin is deployed into, the one holdingLocal,SourcesandProfiles, empty by default (see Deployment)
It optionally imports Directory.Build.props.user from the repository root, which is not
committed (matched by *.user in .gitignore), so each contributor keeps their own local
paths there.
To override a path manually, copy the first PropertyGroup of Directory.Build.props into
Directory.Build.props.user, wrapped into a top-level <Project> element, and fill in your
paths. setup.py writes that file for you with the auto-detected install locations, creating
it if needed and keeping any other overrides already in it.
Leaving Bin64, Dedicated64 or Magnetar empty (or having no Directory.Build.props.user
at all) falls back to the auto-detection in Directory.Build.props, which reads the Steam
registry keys on Windows and the usual Steam locations on Linux, then resolves the game and the
Dedicated Server through Steam's libraryfolders.vdf, so installs on a secondary Steam library
are found as well. Magnetar defaults to the Magnetar\ tree next to the server install on
Windows and to $XDG_CONFIG_HOME/Magnetar (~/.config/Magnetar) on Linux.
The build fails with a clear message if Bin64, Dedicated64 or Magnetar's PluginSdk.dll
cannot be resolved.
Pulsar and MagnetarData are never auto-detected. Leaving them empty turns off deployment.
Builds don't deploy anything by default. Load your working copy through a development folder
instead: start Pulsar or Magnetar with -sources and add it with the Sources button. The loader
then compiles the plugin from source at startup.
A deployed DLL shows up in the loader as a separate local plugin. If you later disable the development folder, that stale copy can still be enabled and shadow the published version of your plugin.
To deploy anyway, set the loader folders in Directory.Build.props.user, or pass them to a
single build with dotnet build -p:Pulsar=... -p:MagnetarData=.... The usual values:
| Property | Windows | Linux |
|---|---|---|
Pulsar |
$(APPDATA)\Pulsar |
$(HOME)/.config/Pulsar |
MagnetarData |
$(Magnetar)\Magnetar |
$(Magnetar)/Magnetar |
$(Magnetar) is the auto-detected Magnetar install folder. Its Magnetar subfolder holds
the configuration, including Local, and both launchers (Legacy and Interim) use it.
Each successful build then copies itself into its loader's Local plugin folder:
| Project | Build | Deployed to |
|---|---|---|
ClientPlugin |
net48 |
<Pulsar>/Legacy/Local/<PluginName>/ |
ClientPlugin |
net10.0 |
<Pulsar>/Interim/Local/<PluginName>/ |
ServerPlugin |
net10.0 |
<MagnetarData>/Local/ |
Pulsar identifies a plugin by its folder, so the client DLL is copied as plugin.dll, its
symbols as plugin.pdb and the PluginHub registration XML from the repository root as
plugin.xml. Magnetar identifies a plugin by its DLL file name, so the server plugin is
copied flat as <PluginName>.dll, with the MagnetarHub registration XML next to it as
<PluginName>.dll.xml. Either way the loader shows the plugin under its friendly name and
honours the runtime and platform restrictions declared in the XML.
Interim is the Pulsar executable running Space Engineers 1 on .NET 10. It falls back to the
Legacy data folder when <Pulsar>/Interim does not exist, and so does the deployment.
(<Pulsar>/Modern belongs to Space Engineers 2 and is never a deployment target here.)
MagnetarInterim is its dedicated server counterpart, but Magnetar keeps one config folder
for both of its launchers, <Magnetar>/Magnetar, so only one build of the server plugin can
be deployed: the net10.0 one, which is also the only one on Linux, where only the Interim
launchers exist. Run the launcher with -useHome or -config and set MagnetarData to
that folder to deploy there instead.
You can have a nice configuration dialog with little effort in the game client.
Customize the Config class in the ClientPlugin project, just follow the examples.
It supports many different data types, including key binding. Once you have more
options than can fit on the screen the dialog will have a vertical scrollbar.
The server plugin configuration works differently, please see the Config folder
of the Shared project for that. The client side Config class is not integrated
with the server side configuration, currently.
-
Put any code you can share between the plugin projects into the Shared project. Try to keep the redundancy at the minimum.
-
The DLLs required by your Shared code need to be added as a dependency to all the projects, even if some of the code is not used by one of the projects.
-
You can delete the projects you don't need. If you want only a single project, then move over what is in the Shared one, then you can delete Shared.
Please use the EnsureCode attribute on patch methods to safely skip loading the plugin
with an error logged should the code in any of the methods patched would change as part of
a game update. It is a good way to prevent blaming crashes on your plugin after game updates,
so your plugin can remain safely enabled (but effectively disabled) until you have a chance
to release an update for compatibility with the new game version. Please see the examples in
the Shared/Patches folder on how to use this attribute.
The hexadecimal hash code is logged in case of a mismatch, so you can read them from the logs
for any new method you patch, just leave the string initially empty in the EnsureCode
attribute, then replace with the value from the error log line after you run your plugin
with the patch for the first time.
On Proton (Linux) this check tends to cause issues, therefore it is automatically skipped when the plugin detects it is running under Wine/Proton.
- Always use a debug build if you want to set breakpoints and see variable values.
- A debug build defines
DEBUG, so you can add conditional code in#if DEBUGblocks. - While debugging a specific target unload the other one. It prevents the IDE to be confused.
- If breakpoints do not "stick" or do not work, then make sure that:
- Other projects are unloaded, only the debugged one and Shared are loaded.
- Debugger is attached to the running process.
- You are debugging the code which is running (no code changes made since the build).
- Transpiler patches will write a
harmony.log.txtfile to yourDesktopwhile runningDebugbuilds. Never release a debug build to your users, because that would litter their desktop as well. - To debug transpiler changes to the IL code it is most practical to generate the files
of the method's IL code before and after the change made, so you can just diff them.
Please see the transpiler example under the
Shared/Patchesfolder for the details.
Enable the Krafs publicizer to significantly reduce the amount of reflections you need to write.
This can be done by systematically uncommenting the code sections marked with "Uncomment to enable publicizer support".
Make sure not to miss any of those. List the game assemblies you need to publicize in GameAssembliesToPublicize.cs.
In case of problems read about the Krafs Publicizer or reach out on the Pulsar Discord server.
Please consider using se-dev-skills for better outcomes.
- If the IDE looks confused, then restarting it and the debugged game usually works.
- If the restart did not work, then try to delete caches used by your IDE and restart.
- If your build fails to copy the plugin into the
Localfolder, then something locks the DLL file. - Look for running game or server processes (maybe stuck running in the background) and kill them.
- Always make your final release from a RELEASE build. (More optimized, removes debug code.)
- Always test your RELEASE build before publishing. Sometimes it behaves differently.
- In case of client plugins the Pulsar compiles your code, watch out for differences.
- Register client plugins into PluginHub, so they become available in Pulsar.
- Register server plugins into MagnetarHub, so they become available in Magnetar.
- In your documentation always include how players or server admins should report bugs.
- Try to be reachable and respond on a timely manner over your communication channels.
- Be open for constructive critics.
- Always consider finding a new maintainer, ask around at least once.
- If you ever abandon the project, then make it clear on its GitHub page.
- Abandoned projects should be made hidden on PluginHub and MagnetarHub.
- Keep the code available on GitHub, so it can be forked and continued by others.
