Modding:Adding Code to the Player

Add Code to Player on a New Game
You can use the  attribute and   interface to modify the player object before the game begins, immediately after the player   is first created.

This method works only when the player starts a New Game. If a player loads your mod on an existing save,  code is never called.

This structure allows you to run custom code on the player object. For example, you might add custom parts to the player from your mod, which is otherwise very difficult to do.

Any class tagged with the  attribute is instantiated after the player object is created and assigned, and the   method is called with the player as the parameter. For example:

Add Code to Player on a Save Load
You can use the  and   attributes to modify the player object whenever a save game is loaded. This method can be useful if you want your mod changes to apply even to existing save games (rather than just new games).

Note that this method works only on loaded saves - if you want your code to also run on a new game, you must combine this method with the PlayerMutator method described above.