When creating your project, you will need to add a reference to KitchenLib-Workshop.dll
, the latest version of this .dll can be found here or by subscribing here.
Optionally, instead of adding references manually, you can use the following community made NuGet Package. You can install it into your project using the Visual Studio Package Manager after you have created the project. (You will still need to subscribe to KitchenLib here)
Once your C# Project is setup, you will need to create a new main class and name it as you wish (for the purposes of this guide we will call it Main.cs
).
Inside this class you will need to add using
to both KitchenLib
, and System.Reflection
, this will allow you to have your class derive BaseMod
. Deriving from BaseMod
rqeuires a constructor with the following arguments
public Main() : base(string modID, string modName, string author, string modVersion, string betaVersion, string compatibleVersions, Assembly assembly) { }
string modID //modID is the identifier for your mod, it's recommended to use the com.yourname.yourmod format
string modName //modName is the display name of your mod, this is what will appear in-game
string author //author is the name of the primary developer for this mod
string modVersion //modVersion this is the current version of the mod, this should comply with SemVersion formatting
string betaVersion //betaVersion this is the beta version of your mod, and will automatically be prefixed with "b"
string compatibleVersions //compatibleVersions shows which version(s) of PlateUp! this mod is compatible with, this should comply with SemVersion formatting
Assembly assembly //assembly is the executing assembly for the mod.
That is technically a complete setup, although there are a couple of additional things we suggest.
Debug logs are fundamental to mod development, and debugging and it's highly recommended to setup properly.
You will need to add the following block inside your Main
class.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void LogInfo(string message)
{
Debug.Log("[Example Mod] " + message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void LogWarning(string message)
{
Debug.LogWarning("[Example Mod] " + message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void LogError(string message)
{
Debug.LogError("[Example Mod] " + message);
}
This code-block will allow you to use these methods throughout your entire project.
Main.LogInfo("This is an Info log!");
Main.LogWarning("This is a Warning log!");
Main.LogError("This is an Error log!");
Assetbundles are a useful tool when developing Content Mods as they're created in the Unity Editor, and can be used at runtime in your mod.
These AssetBundles can contain many things to assist with development such as Prefabs, Icons, etc. When exporting these bundles you must ensure they have the .assets
extension.
You will need to add the following block inside your Main
class.
internal static AssetBundle bundle;
protected override void OnPostActivate(Mod mod)
{
bundle = mod.GetPacks<AssetBundleModPack>().SelectMany(e => e.AssetBundles).FirstOrDefault() ?? throw new MissingAssetBundleException(MOD_ID);
}
This code-block will allow you to access your AssetBundle throughout your entire project with Main.bundle
If you have setup your project correctly it should look something like this.
namespace ExampleMod
{
public class Main : BaseMod
{
public Main() : base("com.starfluxgames.examplemod", "Example Mod", "StarFluxGames", "0.1.0", "", ">=1.1.6", Assembly.GetExecutingAssembly()) {}
internal static AssetBundle bundle;
protected override void OnPostActivate(Mod mod)
{
bundle = mod.GetPacks<AssetBundleModPack>().SelectMany(e => e.AssetBundles).FirstOrDefault() ?? throw new MissingAssetBundleException(MOD_ID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void LogInfo(string message)
{
Debug.Log("[Example Mod] " + message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void LogWarning(string message)
{
Debug.LogWarning("[Example Mod] " + message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void LogError(string message)
{
Debug.LogError("[Example Mod] " + message);
}
}
}