Understanding the PatchScript

Parent Previous Next

The PatchScript for the Bigger Back Pack Mod let's us change the Assembly-CSharp.dll at build time, allowing us to increase the size of the Back Pack.



The PatchScripts are C# Scripts. You can either use Visual Studio, or even Notepad++ for them.


This will not be an in depth tutorial on how to write C#, but rather just to show the anatomy of a SDX PatchScript




The public class BiggerBackPack, inheirits from the IPatcherMod. This IPatcherMod is an SDX class which allows patching. All your PatchScripts need this.


Two functions are required:

       bool Patch( ModuleDefinition module )

       bool Link( ModuleDefinition gameModule, ModuleDefinition modModule )


The Patch() call does the initial assembly, and is where most of the work gets called at. The Link() happens after the compile. In the Bigger Back Pack Mod, we do not use the Link() method, but it still needs to exists, even if it's only does a simple return true.


The rest of the methods, SetAccessLevels(), SetBackpackSize(), UpdateBackPack(), SetMethodToVirtual, SetMethodToPublic, and SetFieldToPublic() are methods we declared to help us out. Some of the fields in the Assembly-CSharp.dll are private, and therefore cannot be access by SDX without changing.


The SetMethodToVirtual, SetFieldToPublic and SetMethodToPublic are all helper functions that can be called to change these private variables, to public ones.


The supplied BiggerBackPack.cs is a documented C# script. We encourage you to review it, and understand what it's doing.



Created with the Personal Edition of HelpNDoc: iPhone web sites made easy