User Tools

Site Tools


guide_firstsrmod

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
guide_firstsrmod [2019/07/04 11:48] – [Method 2 (Harmony Postfix)] umfdevguide_firstsrmod [2019/07/04 11:52] – [Method 3 (Harmony Traverse)] umfdev
Line 247: Line 247:
   - Rename ''Patch_PURPOSEOFPATCH.cs'' to ''Patch_MaxHealth.cs'' along with the class name for it.   - Rename ''Patch_PURPOSEOFPATCH.cs'' to ''Patch_MaxHealth.cs'' along with the class name for it.
   - Add the following to the top of ''Patch_MaxHealth.cs'': <sxh csharp>using MonomiPark.SlimeRancher.DataModel;</sxh>   - Add the following to the top of ''Patch_MaxHealth.cs'': <sxh csharp>using MonomiPark.SlimeRancher.DataModel;</sxh>
-    * This lets us target the **PlayerModel** class which is inside the **MonomiPark.SlimeRancher.DataModel** namespace+    * This lets us target the **PlayerModel** class which is inside the **MonomiPark.SlimeRancher.DataModel** namespace without having to type the full namespace everytime.
-    * You could also use **MonomiPark.SlimeRancher.DataModel.PlayerModel** instead for anything targeting it.+
   - Set **typeof** in the first HarmonyPatch attribute to use the **PlayerModel** class we discovered with dnSpy. <sxh csharp>[HarmonyPatch(typeof(PlayerModel))]</sxh>   - Set **typeof** in the first HarmonyPatch attribute to use the **PlayerModel** class we discovered with dnSpy. <sxh csharp>[HarmonyPatch(typeof(PlayerModel))]</sxh>
 +    * You could also use **MonomiPark.SlimeRancher.DataModel.PlayerModel** instead for the type.
   - Set the second **HarmonyPatch** attribute to the **ApplyUpgrade** function we discovered with dnSpy. <sxh csharp>[HarmonyPatch("ApplyUpgrade")]</sxh>   - Set the second **HarmonyPatch** attribute to the **ApplyUpgrade** function we discovered with dnSpy. <sxh csharp>[HarmonyPatch("ApplyUpgrade")]</sxh>
   - Inside the patch class create the following postfix function: <sxh csharp>        public static void Postfix(PlayerModel __instance)   - Inside the patch class create the following postfix function: <sxh csharp>        public static void Postfix(PlayerModel __instance)
Line 309: Line 309:
     * The Traverse will bypass any private or readonly variable and let you read/write to it.     * The Traverse will bypass any private or readonly variable and let you read/write to it.
     * Traverse does not need to be used inside a Harmony patch, it can be used anywhere anytime in any code, however you have to make sure it doesn't try to access code that has not yet been loaded into the game.     * Traverse does not need to be used inside a Harmony patch, it can be used anywhere anytime in any code, however you have to make sure it doesn't try to access code that has not yet been loaded into the game.
 +    * This will function exactly like Method 2, and is wholly unnecessary since **maxHealth** is public and not readonly.
   - See [[#Building]] for the next steps.   - See [[#Building]] for the next steps.
 \\ \\

This topic does not exist yet

You've followed a link to a topic that doesn't exist yet. If permissions allow, you may create it by clicking on Create this page.

guide_firstsrmod.txt · Last modified: 2019/07/04 12:27 by umfdev