Jump to content

dunno why parameter naming can affect the mod


Recommended Posts

this question is about coding in the mod, but i can't find good explanation from google.

i attempt to apply color changes to a mod building, using codes of others.
 

        [HarmonyPatch(typeof(BuildingComplete))]
        [HarmonyPatch("OnSpawn")]
        public static class BuildingComplete_OnSpawn_Patch
        {
            public static void Postfix(BuildingComplete __instance)

...

                    kAnimBase.TintColour = color;

when i initially adopt this coding, i just named the parameter as "instance".
but the game keep prompting to restart the game on started repeatedly.

when this parameter is follow exactly and putting in the double underscore prefix "__instance"
the restart prompt no longer happen, and the color changes worked.

afaik, that naming shouldn't affect anything, but it does!

Link to comment
Share on other sites

As already mentioned, Harmony is to blame for this one. It's explained on this page. Parameters are linked to parameters of the same name in the method you patch. On top of that, there are special parameters where the most used ones are __instance and __result. I recommend reading the entire harmony wiki prior to modding.

Do note that ONI automatically bootstrap mods meaning you can skip the page telling about how to bootstrap your harmony patches.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...