-
-
Notifications
You must be signed in to change notification settings - Fork 39
Home
Welcome to the wiki of HKMP! This wiki will mostly contain information regarding the HKMP API.
The core idea of the API is to expose internal workings of HKMP to so-called "addon". This will allow developers to create integrations of existing mods with HKMP or create new specific features that are not necessarily fit to be included in the HKMP codebase. Addons are divided in two parts, namely "client addons" and "server addons" and are similar to Hollow Knight mods in that they are assemblies that are loaded and can interact with another codebase. In this case, the client and server addons are loaded separately by the client-side and server-side of HKMP and can then interact with their respective APIs (namely, the client API and server API). This is important to keep in mind, because it means that you can be either developing for the client-side, the server-side of both sides of HKMP in terms of addons. The reason for having this divide between client and server addons is basically due to the existence of the standalone server. The standalone server has no notion of the game code, because it runs independently of Hollow Knight, but it may still be interesting to have a server addon that solely interacts with the server API. Addons that require networking are allowed a channel over which they can communicate with their respective counterpart using the existing HKMP network implementation. This means that in order to use networking in your addons, you will need to develop both a client and a server addon. These addons can then communicate with each other to relay important information.
The first thing to do when trying to develop an addon for HKMP is to create a new C# class library. The framework you should be targeting is .NETFramework v4.7.2
, similar to Hollow Knight mods. Next, you should add the reference to the HKMP DLL (HKMP.dll
) in your project. The latest DLL can be found on the releases page.
Then, we can start writing code. In order for HKMP to recognise your class library as an HKMP addon, you'll need to extend either the ClientAddon
or the ServerAddon
class. See the code snippets below for an example:
using Hkmp.Api.Client;
namespace ExampleAddon {
public class ExampleClientAddon : ClientAddon {
public ExampleClientAddon(IClientApi clientApi) : base(clientApi) {
}
public override void Initialize() {
Logger.Info(this, "Initializing client-side example addon!");
}
protected override string Name => "ExampleAddon";
protected override string Version => "0.0.1";
public override bool NeedsNetwork => true;
}
}
using Hkmp.Api.Server;
namespace ExampleAddon {
public class ExampleServerAddon : ServerAddon {
public ExampleServerAddon(IServerApi serverApi) : base(serverApi) {
}
public override void Initialize() {
Logger.Info(this, "Initializing server-side example addon!");
}
protected override string Name => "ExampleAddon";
protected override string Version => "0.0.1";
public override bool NeedsNetwork => true;
}
}
These classes are the starting point of your addon and will allow you to access the respective API. The client and server APIs are passed as a parameter through the constructor, but they are also accessible as a protected
member variable in the ClientAddon
and ServerAddon
classes.
The APIs offer the addons a way to communicate with their respective counterpart through the existing HKMP networking. This is discussed in more detail and with examples below.
WIP