-
Notifications
You must be signed in to change notification settings - Fork 81
Mod API Attributes
ShineSyndrome edited this page Jun 10, 2023
·
2 revisions
The ModCallbackAttribute is the main attribute that Colony Survival identifies your Callbacks and when to call them. ModCallbackAttribute Requires 2 arguments. The call back type and the identifier. The identifier needs to be unique for all callbacks registered. To ensure your name is unique and does not interfere with other mods and the base game, include your namespace in the the name of the callback and then the name of the method.
public const string NAMESPACE = "Pandaros.Settlers";
[ModLoader.ModCallback(ModLoader.EModCallbackType.OnAssemblyLoaded, NAMESPACE + ".OnAssemblyLoaded")]
public static void OnAssemblyLoaded(string path)
{
MOD_FOLDER = Path.GetDirectoryName(path);
}
The ModCallbackDependsOn attribute will ensure the decorated method is called AFTER the input identifier.
public const string NAMESPACE = "Pandaros.Settlers";
[ModLoader.ModCallback(ModLoader.EModCallbackType.AfterWorldLoad, NAMESPACE + ".Localize")]
[ModLoader.ModCallbackDependsOn("pipliz.server.localization.waitforloading")]
[ModLoader.ModCallbackProvidesFor("pipliz.server.localization.convert")]
public static void Localize()
{
}
The ModCallbackProvidesFor attribute will ensure the decorated method is called *BEFORE *the input identifier.
public const string NAMESPACE = "Pandaros.Settlers";
[ModLoader.ModCallback(ModLoader.EModCallbackType.AfterWorldLoad, NAMESPACE + ".Localize")]
[ModLoader.ModCallbackDependsOn("pipliz.server.localization.waitforloading")]
[ModLoader.ModCallbackProvidesFor("pipliz.server.localization.convert")]
public static void Localize()
{
}