Game1CodeGenerator
Introduction
Game1CodeGenerator is a base class for code generators which inject code into Game1.Generated.cs. It provides the following methods for derived classes to override:
GenerateClassScope
GenerateInitialize
GenerateUpdate
GenerateDraw
Creating a Game1CodeGenerator-Inheriting Class
Typically Game1CodeGenerator instances are associated with a specific plugin. Therefore, typical steps for creating a new Game1CodeGenerator-inheriting class are:
Add a new class to your plugin.
Inherit from Game1CodeGenerator
Override the desired methods. For example, to add code to the game's initialization, override GenerateInitialize.
The following shows an example of an empty Game1CodeGenerator-inheriting class:
Instantiating a Game1CodeGenerator
As mentioned above, Game1CodeGenerators are typically associated with plugins. Therefore, it is common to instantiate and register a code generator in a plugin's StartUp method as shown in the following code snippet
Typically, Glue will generate Game1 whenever a project is loaded. A plugin can forcefully generate Game1 generated code as well using the following code:
Last updated