MDK²-SE (Malware's Development Kit for Space Engineers)
repository·main·Indexed 42 days ago
https://github.com/malforge/mdk2A specialized development toolkit for Space Engineers creators to build programmable block scripts and external mods. It features Visual Studio integration, automated project scaffolding, code analysis for game-restricted APIs, a code minifier, and the MDK2 Hub GUI for project and package management. Includes specialized packagers and analyzers available via NuGet to streamline the compilation of C# projects into game-compatible formats.
What's inside MDK²-SE
- MDK Mod Packager is a tool designed for Space Engineers modders. It enables the use of full C# projects for mod development, allowing for separate code files and mixin (shared project) libraries. The tool works by reading these projects and compiling them into a final mod format compatible with the game.
Overview of MDK²-SE
mainMDK²-SE (Malware's Development Kit for SE) is a toolkit designed for developing both programmable block scripts and mods for the game Space Engineers.
Key capabilities include:
- Visual Studio Integration: Automatically creates a fully connected Visual Studio project with all necessary references configured.
- Code Analysis: Includes an analyzer that warns developers when using code that is disallowed within the Space Engineers environment.
- Code Reuse: Supports Visual Studio Shared Projects, allowing you to share code between scripts and mods.
- Script Deployment: For programmable block scripts, it deploys the script directly into a single file in your local Workshop folder, eliminating the need for manual copy/pasting.
- Minification: Provides an optional code minifier to help programmable block scripts stay within the game's size and instruction limits.
Key features of MDK2 Hub
mainThe MDK2 Hub provides several management capabilities for MDK2 projects:
- Project Overview: View all MDK2 projects, sorted by most recently used.
- Package Management: Check for and install MDK package updates across individual projects or all projects simultaneously.
- Quick Actions: Open projects directly in your IDE, browse to project folders, or copy deployed scripts.
- Build Integration: Receive build notifications from Visual Studio or Rider and automatic registration of new projects.
- Configuration Editor: A visual editor for
mdk.inisettings that includes validation. - Cross-Platform Support: Runs on both Windows and Linux.
Understand the MDK Hub Styling System architecture
mainThe styling system follows a strict three-layer architecture to enable full theme switching (e.g., adding Light Mode) by only modifying the base color definitions.
- Layer 1: Colors (
Colors.axaml): Defines the raw color palette using semantic names that describe what the color is (e.g.,AccentPrimaryColor,SuccessColor). - Layer 2: Brushes (
Brushes.axaml): Defines usage-specific brushes that reference colors. These names describe where the color goes (e.g.,BackgroundAccentBrush,ForegroundAccentBrush). - Layer 3: Styles: Reference brushes, never colors directly. This indirection ensures that changing a color in Layer 1 propagates through the brushes to the styles automatically.
- Layer 1: Colors (
Follow naming conventions for Colors and Brushes
mainTo maintain consistency, follow these naming patterns:
Colors
Use semantic names describing purpose, not usage. Use suffixes for state variants.
AccentPrimaryColor(Primary action color)SuccessColor(Success indicator)DangerColor(Error/Destructive state)TextBodyColor(Standard text)BackgroundPrimaryColor(Main window background)- State Suffixes:
AccentPrimaryHoverColor,AccentPrimaryPressedColor
Brushes
Use prefixes that indicate the intended property type. A single color can feed multiple brushes with different prefixes.
Foreground*Brush: For text, icons, and foreground elements.Background*Brush: For fills and background properties.Border*Brush: For borders and strokes.Overlay*Brush: For transparent layers and hover effects.
MDK2 Hub architecture and technology stack
mainFor developers looking to contribute to the Hub, the application is built using the following technologies:
- Avalonia UI: Cross-platform .NET UI framework.
- .NET 9: Modern C# and runtime.
- Velopack: Update and installation system.
- Mal.SourceGeneratedDI: Compile-time dependency injection.
Architectural Patterns:
- Feature-based Organization: Services are located in
Features/folders alongside their corresponding ViewModels and Views. - Global UI State: The
IShellservice manages overlays, toasts, and global UI state. - Configuration Layering: Project configuration follows a layered hierarchy:
default$\rightarrow$main.ini$\rightarrow$local.ini. - Background Tasks: Update checking is handled via
UpdateManagerandProjectUpdateChecker.
Getting Started with MDK²-SE
mainTo begin using MDK²-SE, you must refer to the official documentation site for specific instructions on setting up your environment for various IDEs and editors.
Prerequisites:
- You must have Space Engineers installed on your system (the game does not need to be running during development).
Setup Instructions: Consult the documentation site for step-by-step guides tailored to your preferred development environment.
Install MDK Mod Analyzers via NuGet
mainTo use the MDK Mod Analyzers in your Space Engineers mod project, simply reference the NuGet package. Once referenced, the analyzer will automatically begin scanning your project for usage of .NET framework components or game APIs that are restricted by the Space Engineers whitelist.Create a new MDK project
mainOnce MDK Hub is installed, you can start a new project using one of three methods:
- Via MDK Hub UI: Use the Hub's project creation interface (recommended for VS Code users).
- Via IDE: Use MDK templates directly through the "New Project" menu in Visual Studio or Rider.
- Via CLI: Use standard
dotnet newcommands.
When creating a project, you must choose between a Script or Mod project type and configure your output paths. MDK will handle the deployment to Space Engineers.
Copy Space Engineers DLLs locally for unit testing
mainBy default, assemblies are referenced directly from the Space Engineers installation folder. If you need to run unit tests, you must copy these assemblies to your local project directory. To enable this, add the
<SpaceEngineersBinCopyLocal>property to the initialPropertyGroupin your.csprojfile.Warning: These assemblies are property of Keen Software House. You are not permitted to pack or redistribute these DLLs. This package exists specifically to automate referencing without redistribution.
<SpaceEngineersBinCopyLocal>true</SpaceEngineersBinCopyLocal>Get started with MDK2 Hub
mainFor New Users
On the first run, the Hub performs the following:
- Checks for prerequisites (such as the .NET SDK and templates).
- Offers to install any missing components.
- Checks for available updates.
Once prerequisites are installed, you can create projects using three methods:
- Via the Hub: Use the "New Project" wizard to create a script or mod project.
- Via your IDE: Use the MDK templates available in the Visual Studio or Rider "New Project" dialogs.
- Via command line: Use the
dotnet newcommand.
After building a project in your IDE, the Hub will automatically detect it and add it to your project list.
For Existing MDK 2.1 Users
The Hub automatically finds and imports your existing MDK2 projects on the first run. It will then track these projects and notify you of available updates.
# Create a programmable block script project dotnet new mdk2pbscript # Create a mod project dotnet new mdk2modInstall MDK Hub on Linux via AppImage
mainTo run MDK Hub on Linux, use the AppImage format. Note that on Linux, you must manually configure the paths to your Space Engineers binaries, script output, and mod output folders during the first launch, as there is no registry to auto-detect them.
Steps:
- Download
Malforge.MdkHub.AppImagefrom the latest release. - Make the file executable.
- Run the AppImage.
chmod +x Malforge.MdkHub.AppImage ./Malforge.MdkHub.AppImage- Download