PulsarMod Class - PULSAR-Modders/pulsar-mod-loader GitHub Wiki

This class is necessary for mod loading. If a mod file does not have this class, the mod loader will not load it. It contains many overridable objects however the only one which must be overridden is the HarmonyIdentifier() method. For standardization, name this extension class 'Mod'.

Example

class Mod : PulsarModLoader.PulsarMod
{
    public override string HarmonyIdentifier()
    {
        return "ModAuthor.ModName";
    }
}

Overridable Objects

Basic mod details

These details can be viewed in game by users using the F5 menu.

It is recommended to use an 'X.X.X' format for your mod version to provide consistency to the user experience. The first position generally represents major versions of the mod, best used in cases where 1.0.0 looks entirely different from 2.0.0. The second position is for minor versions of the mod, best used when new features have been added. The third position is for patches and bug fixes where the user should not expect new features.

public override string Version => "1.0.0";
public override string Name => "Mod Name";
public override string Author => "Your Username";
public override string ShortDescription => "A brief description";
public override string LongDescription => "All the details";

MPRequirements

MPRequirements are used to signal for the mod loader which clients need the mod for multiplayer connectivity. The available codes can be found in the enum at PulsarModLoader.MPModChecks.MPRequirement. There are 4 options available at this time:

  • None - No requirements, best for client side mods.
  • HideFromServerList - Hidden from server listings, and will not be sent to the host or clients.
  • Host - Clients will not connect to games when the host has this mod.
  • All - The host and clients must have this mod.
  • MatchVersion - Similar to none, but will ensure versions match.

In the cases of 'Host' and 'All', Hash values are passed from client to host to verify integrity of the mod files.

public override int MPRequirements => (int)MPRequirement.None;

//MPFunctionality will be removed in the future, and is currently marked as obsolete.
public override int MPFunctionality => base.MPFunctionality;

ModID

Currently not implemented, intended to provide a link for mod download.

public override string ModID => base.ModID;

Enable/Disable

This is meant to act like an on/off switch for the mod. CanBeDisabled() signals whether the mod has this option. Enable() and Disable() are used as functions which run when the mod is enabled and disabled. IsEnabled() returns the current setting.

public override bool CanBeDisabled() {}
public override void Disable() {}
public override void Enable() {}
public override bool IsEnabled() {}

HarmonyIdentifier

This method is used to return a unique mod identifier. We prefer to use a format of ModAuther.ModName, however this is not mandatory.

public override string HarmonyIdentifier()

Unload

This code is run when a user forcibly unloads the mod. It is best used to release resources or return the game to a more vanilla state. When a mod is unloaded it will unpatch all harmony patched code.

public override void Unload()