Skip to content
ShineSyndrome edited this page Jun 10, 2023 · 2 revisions

ModCallbackAttribute

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.

Example:

        public const string NAMESPACE = "Pandaros.Settlers";

        [ModLoader.ModCallback(ModLoader.EModCallbackType.OnAssemblyLoaded, NAMESPACE + ".OnAssemblyLoaded")]
        public static void OnAssemblyLoaded(string path)
        {
            MOD_FOLDER = Path.GetDirectoryName(path);
        }

ModCallbackDependsOn

The ModCallbackDependsOn attribute will ensure the decorated method is called AFTER the input identifier.

Example:

        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()
        {

        }

ModCallbackProvidesFor

The ModCallbackProvidesFor attribute will ensure the decorated method is called *BEFORE *the input identifier.

Example:

        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()
        {

        }