public RainMaker(Game game) : base(game) { terrariaAssembly = Assembly.GetAssembly(game.GetType()); main = terrariaAssembly.GetType("Terraria.Main"); worldGen = terrariaAssembly.GetType("Terraria.WorldGen"); }
/// <summary> /// Binds the game into the kernel. /// </summary> /// <param name="game">The game.</param> /// <param name="kernel">The kernel to bind into.</param> /// <param name="bindGraphicsDevice">if set to <c>true</c> binds game.GraphicsDevice.</param> /// <param name="bindContentManager">if set to <c>true</c> binds game.Content.</param> /// <param name="bindServiceContainer">if set to <c>true</c> binds game.Services.</param> public static void BindGame(Game game, IKernel kernel, bool bindGraphicsDevice = true, bool bindContentManager = true, bool bindServiceContainer = true, bool bindComponentCollection = true) { // bind the game to a singleton instance var thisType = game.GetType(); kernel.Bind(thisType).ToConstant(game); kernel.Bind<Game>().ToConstant(game); // bind the graphics device if (bindGraphicsDevice) kernel.Bind<GraphicsDevice>().ToMethod(c => game.GraphicsDevice); // bind the content manager if (bindContentManager) kernel.Bind<ContentManager>().ToMethod(c => game.Content); // bind services if (bindServiceContainer) { kernel.Bind<GameServiceContainer>().ToMethod(c => game.Services); kernel.Bind<IServiceProvider>().ToMethod(c => game.Services); } if (bindComponentCollection) { kernel.Bind<GameComponentCollection>().ToMethod(c => game.Components); } }
public GamePlayScreen(Game game, GameStateManager manager) : base(game, manager) { if (!(game is MainGame)) throw new Exception("GamePlayScreen constructor: Param 'game' is of type " + game.GetType() + "!"); Log.Info("Setting game world..."); World = ((MainGame) game).World; }
public GamerServicesComponent(Game game) : base(game) { #if WINDOWS_PHONE var assembly = game.GetType().Assembly; if (assembly != null) { object[] objects = assembly.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false); if (objects.Length > 0) { MonoGamerPeer.applicationIdentifier = ((System.Runtime.InteropServices.GuidAttribute)objects[0]).Value; } } #endif Guide.Initialise(game); }