General Modding
Cubivox is a game that is meant to be modded to create minigames or other environments. Modding
Cubivox is very easy thanks to the Cubivox Core API.
Cubivox mods can target either a single environment (like the Client or Server) or both.
Creating Mods
This documentation will cover how to create a Cubivox mod using C# and Visual Studio 2022.
First, we need to create a new project for our mod. Choose the Class Library
option from the
list that targets .NET or the .NET Standard.
Then save it where you want to and choose .NET Standard 2.1
as the Framework.
Linking to CubivoxCore
Be certain to download the latest CubivoxCore
dll file. Then right client the solution in Visual Studio and select Add > Project Reference...
.
The click the Browse...
button and select the CubivoxCore.dll
file.
Extending CubivoxMod
Now it is time to add the code for the new mod. Go ahead and create a new C# file, for this article we'll use TestMod
as the name.
The base class of the Cubivox mod should extend CubivoxMod
.
using CubivoxCore.Console;
using CubivoxCore.Mods;
namespace TestMod
{
public class TestMod : CubivoxMod
{
public TestMod(ModDescriptionFile modDescriptionFile, Logger logger) : base(modDescriptionFile, logger)
{
}
public override void OnEnable()
{
}
}
}
Two additional items need to be added to the class after extending CubivoxMod
.
- A construct needs to be provided that passes a
ModDescriptionFile
andLogger
to theCubivoxMod
base class. - The
OnEnable
method is required for all mods.
No calls to Cubivox APIs should be made in the constructor of the CubivoxMod. Instead, use OnEnable or one of the loading stage methods.
Logging
Cubivox provides a logger for your mod to use. It can be accessed from the by using the GetLogger()
method.
public override void OnEnable()
{
GetLogger().Info("Test Mod has been enabled!");
}
The logger will work on both the Server and Client environments, logging in the proper place.
mod.json
Some information about the mod needs to be provided to Cubivox in a seperate mod.json
file. When adding the mod.json
file,
be sure to tell Visual Studio to embed the resource into the compiled dll file.
Here are the required parameters to have in the mod.json file:
{
"ModName": "TestMod",
"MainClass": "TestMod.TestMod",
"Description": "The test mod for Cubivox",
"Version": "1.0",
"Authors": [ "Ryandw11" ]
}
ModName
is the name of the mod.MainClass
is the path to the main class of the mod (extendsCubivoxMod
). Include the namespaces here. For example, theTestMod
class is in theTestMod
namespace so it isTestMod.TestMod
.Description
is the description of the mod.Version
is the version of the mod.Authors
is the list of authors who developed the mod.
Building Mods
Now you can build the mod by select Build > Build Solution
.
The built dll
can be found at .\TestMod\bin\Debug\netstandard2.1\TestMod.dll
or .\TestMod\bin\Release\netstandard2.1\TestMod.dll
.
Unless you included other resources, the mod dll file is the only thing you need to distribute your mod.
This file can be placed in the mods
folder of both the server or the client.