Nexus.Client.Games.GameModeRegistry.RegisterGameMode C# (CSharp) Method

RegisterGameMode() public method

Registers the specified game mode.
public RegisterGameMode ( IGameModeFactory p_gmfGameModeFactory ) : void
p_gmfGameModeFactory IGameModeFactory The factory for the game mode to register.
return void
		public void RegisterGameMode(IGameModeFactory p_gmfGameModeFactory)
		{
			if (m_dicGameModeFactories.ContainsKey(p_gmfGameModeFactory.GameModeDescriptor.ModeId))
			{
				string strError = String.Format("{0} has the same Game Mode Id as {1}. {0} will be replaced in the registry.", m_dicGameModeFactories[p_gmfGameModeFactory.GameModeDescriptor.ModeId].GameModeDescriptor.Name, p_gmfGameModeFactory.GameModeDescriptor.Name);
				Trace.TraceWarning(strError);
			}
			m_dicGameModeFactories[p_gmfGameModeFactory.GameModeDescriptor.ModeId] = p_gmfGameModeFactory;
		}

Usage Example

        /// <summary>
        /// Loads the factories for games that have been previously detected as installed.
        /// </summary>
        /// <param name="supportedGameModes">A registry containing the factories for all supported game modes.</param>
        /// <param name="environmentInfo">The application's environment info.</param>
        /// <returns>A registry containing all of the game mode factories for games that were previously detected as installed.</returns>
        public static GameModeRegistry LoadInstalledGameModes(GameModeRegistry supportedGameModes, EnvironmentInfo environmentInfo)
        {
            Trace.TraceInformation("Loading Game Mode Factories for Installed Games...");
            Trace.Indent();

            var installedGameModes = new GameModeRegistry();

            foreach (var gameId in environmentInfo.Settings.InstalledGames)
            {
                Trace.Write($"Loading {gameId}: ");

                if (supportedGameModes.IsRegistered(gameId))
                {
                    Trace.WriteLine("Supported");
                    installedGameModes.RegisterGameMode(supportedGameModes.GetGameMode(gameId));
                }
                else
                {
                    Trace.WriteLine("Not Supported");
                }
            }

            Trace.Unindent();
            return(installedGameModes);
        }
All Usage Examples Of Nexus.Client.Games.GameModeRegistry::RegisterGameMode