DigOrDie.DODModAPI 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DigOrDie.DODModAPI --version 1.0.2
                    
NuGet\Install-Package DigOrDie.DODModAPI -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DigOrDie.DODModAPI" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DigOrDie.DODModAPI" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="DigOrDie.DODModAPI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DigOrDie.DODModAPI --version 1.0.2
                    
#r "nuget: DigOrDie.DODModAPI, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DigOrDie.DODModAPI@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DigOrDie.DODModAPI&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=DigOrDie.DODModAPI&version=1.0.2
                    
Install as a Cake Tool

DODModAPI

Core API plugin used by the other plugins.

DODModAPI does not add gameplay content by itself. Instead, it provides a standardized modding layer built on top of Dig or Die code, allowing other plugins to add custom content in Dig or Die without manually patching every game system. It solves hard problems in Dig or Die modding, making modifying the game much easier.

This plugin is intended as a dependency. If another plugin contains [BepInDependency(DODModAPI.DODModAPIPlugin.GUID)], then DODModAPI must be installed for that plugin to work.

A complete example plugin is available in dodmodapi/example-mod. It demonstrates items, recipes, units, events, game modes, save data, network messages, UI screens, commands, and Harmony helpers.

If you have a plugin that uses DODModAPI while not having DODModAPI plugin itself installed, you will see a similar error message in the console or in the log file (DigOrDie_Data/output_log.txt):

[Error  :   BepInEx] Could not load [<NAME> <VERSION>] because it has missing dependencies: dodmodapi

Features

DODModAPI provides registration systems and helpers for:

  • Custom items (ItemManager)
  • Custom recipes and recipe groups (ItemManager)
  • Custom units (UnitManager)
  • Custom events (EventManager)
  • Custom game modes (ModeManager)
  • Custom save data stored inside game save files (SaveManager)
  • Custom network messages for multiplayer synchronization (NetworkManager)
  • Custom UI screens (ScreenManager)
  • Custom chat commands (CommandManager)
  • Chat message preprocessors (CommandManager)
  • Custom textures, sprites, tiles, surfaces, and background surfaces (TextureManager, SurfaceManager)
  • Improved Harmony IL patching through CodeCursor
  • Useful utility functions (Misc)

Provided managers

Manager Description
ItemManager Registers custom items, recipes, recipe groups, and item plugin data.
UnitManager Registers custom unit descriptors.
EventManager Registers custom events based on ModEnvironment.
ModeManager Registers custom game modes without requiring external Lua files.
SaveManager Stores and loads custom mod data inside save files.
NetworkManager Registers custom network messages, with automatic or manual message IDs.
ScreenManager Registers custom SSingletonScreen<T> UI screens.
CommandManager Registers custom chat commands, tab completion, and chat preprocessors.
TextureManager Registers embedded textures and custom sprite/tile references.
SurfaceManager Registers custom surfaces and background surfaces.

Helper utilities

Utility Description
CodeCursor Replacement for Harmony CodeMatcher with a more predictable pattern-matching and insertion API.
CommandArgs Helper for parsing chat command arguments, including relative coordinates, items, units, players, enums, and more.
Misc General helpers for localization, math, formatting, chat messages, cell flags, rectangles, string matching, and more.
WeakTable<TKey, TValue> Weak-reference table similar to ConditionalWeakTable, useful for attaching data to game objects without keeping them alive.
GameAssets Accessors for built-in UI sprites and sound IDs.
Extensions Reflection helpers for methods, fields, constructors, and coroutine fields.

Basic usage

Other plugins should reference DODModAPI and declare it as a dependency:

using BepInEx;

[BepInPlugin("my-mod", "My Mod", "1.0.0")]
// BepInDependency is required
[BepInDependency(DODModAPI.DODModAPIPlugin.GUID)]
public class MyMod : BaseUnityPlugin {
    private void Awake() {
        // register embedded textures generated by AssetPacker or loaded manually.
        DODModAPI.TextureManager.RegisterTexture(MyAssets.TileSpritesheetResource);

        // register custom content.
        DODModAPI.ItemManager.RegisterAllItems(typeof(MyItems));
        DODModAPI.UnitManager.RegisterAllUnits(typeof(MyUnits));

        // register a custom command.
        DODModAPI.CommandManager.Register("/my-command", new() {
            Local = true,
            DisableAchievements = true,
            TabCompleter = argIdx => argIdx == 0 ? ["hello"] : null,
        }, args => {
            string subCommand = args.ArgString("subcommand");
            args.ArgNone();

            if (subCommand == "hello") {
                DODModAPI.Misc.SendChatMessageLocal("Hello from my mod!");
            } else {
                throw new DODModAPI.CommandException("Unknown subcommand", args.Index);
            }
        });
    }
}

Registration rules

Custom content must usually be registered inside your plugin's Awake() method.

Most DODModAPI managers lock registration after the relevant game initialization phase has completed. For example, ItemManager locks item registration after SItems.OnInit has been called.

If registration happens too late, a LateRegistrationException is thrown.

For example:

private void Awake() {
    // Correct: register during plugin initialization.
    DODModAPI.ItemManager.RegisterItem(MyItems.exampleWall);
}

AssetPacker

DODModAPI also includes the optional DigOrDie.DODModAPI.AssetPacker MSBuild task that is available on NuGet.

It can generate C# bindings and optimized sprite atlases from a simple asset configuration file. Instead of manually packing sprites and writing boilerplate code, you describe your assets in a configuration file and AssetPacker generates the required class at build time.

Add package reference to AssetPacker with:

<ItemGroup>
  <PackageReference Include="DigOrDie.DODModAPI.AssetPacker" Version="..." />
</ItemGroup>

or with command:

dotnet add package DigOrDie.DODModAPI.AssetPacker --version ...

Create a configuration file (like assets.cfg, sprites.cfg, etc.):

TILE exampleWall example_wall.png
TILE exampleDevice tile=example_device.png icon=example_device_icon.png

SPRITE exampleBullet example_bullet.png

SURFACE exampleSurface material=example_surface_mat.png top=example_surface_top.png

UNIT exampleUnit stand=example_unit_stand1.png run=example_unit_run1.png+example_unit_run2.png

Then register it in your .csproj:

<ItemGroup>
    <ModAtlas Include="assets.cfg" AtlasName="ExampleAssets" />
</ItemGroup>

Now, all assets you defined in the configuration file will be available in ExampleAssets class, directly in the C# code. Don't forget to register the corresponding texture resource names in the Awake() with DODModAPI.TextureManager.RegisterTexture()!

See AssetPacker/README.md for the full documentation.

Example Mod

The repository contains an example plugin in dodmodapi/example-mod.

It demonstrates how to use TextureManager, ItemManager, UnitManager, EventManager, ModeManager, SaveManager, NetworkManager, ScreenManager, CommandManager, CodeCursor and AssetPacker-generated textures

The example mod is primarily intended for developers reading the source code. It is not designed as a regular gameplay mod.

Configuration

This plugin does not have any configuration options.

Product Compatible and additional computed target framework versions.
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 129 8/3/2026
1.0.2 135 8/2/2026
1.0.1 118 8/2/2026
1.0.0 122 8/2/2026