allow selection of game mode via command line

This commit is contained in:
in0finite 2021-03-02 23:47:51 +01:00
parent 805eaefea7
commit f7eeaa379e

View file

@ -1,4 +1,6 @@
using System.Collections;
using System.Linq;
using SanAndreasUnity.GameModes;
using UnityEngine;
using SanAndreasUnity.Utilities;
@ -30,6 +32,17 @@ namespace SanAndreasUnity.Net
string serverIp = "127.0.0.1";
CmdLineUtils.GetArgument("serverIp", ref serverIp);
string gameModeName = null;
CmdLineUtils.GetArgument("gameMode", ref gameModeName);
if (!string.IsNullOrWhiteSpace(gameModeName))
{
var gameModeInfo = GameModeManager.Instance.GameModes.FirstOrDefault(gm => gm.Name == gameModeName);
if (gameModeInfo != null)
GameModeManager.Instance.SelectGameMode(gameModeInfo);
else
Debug.LogError($"Game mode with name '{gameModeName}' not found");
}
if (CmdLineUtils.HasArgument("startServer"))
{
Debug.LogFormat("Starting server in headless mode, params: {0}, {1}, {2}", portNum, sceneName, maxNumPlayers);