private void VerifyMapValid() { if (GameModeData.MapId.HasValue == false) { throw new Exception($"Map Id not set. Set it using /{Commands.COMMAND_GAMEMODE_SET_MAP}."); } BaseGameModeMapData mapData = _gameModeHandler.GetMap(GetGameModeData().MapId.Value); if (mapData == null) { throw new Exception($"Map Id not found. Verify game map json data required. Contact owner!"); } }
public void SetMaxPlayers(uint maxPlayers) { try { VerifyMapValid(); BaseGameModeMapData mapData = GetMapData(); if (maxPlayers > mapData.MaxPlayers) { throw new Exception($"Map does not support that amount of players! Max Players Supported :{mapData.MaxPlayers}"); } GameModeData.MaxPlayers = maxPlayers; Main.Logger.LogClient(GameModeData.EventHost, $"Max players set to {maxPlayers}"); } catch (Exception e) { throw e; } }
public void SetGameModeMapId(uint mapId) { BaseGameModeMapData mapData = _gameModeHandler.GetMap(mapId); if (mapData == null) { throw new System.Exception("Map not found!"); } if (mapData.SuitedGameModes.Contains(GameModeData.Type) == false) { throw new System.Exception("Map is not suited to this game mode!"); } GameModeData.MapId = mapId; if (mapData.MaxPlayers < GameModeData.MaxPlayers) { Main.Logger.LogClient(GameModeData.EventHost, $"Map does not support number of players {GameModeData.MaxPlayers}, lowering to {mapData.MaxPlayers}."); GameModeData.MaxPlayers = (uint)mapData.SpawnPoints.Length; } Main.Logger.LogClient(GameModeData.EventHost, $"Map changed to ({mapData.MapId}) {mapData.DisplayName}."); }
protected GamePosition GetRandomSpawnPosition() { BaseGameModeMapData mapData = GetMapData(); return(mapData.SpawnPoints[Main.Random.Next(mapData.SpawnPoints.Length)]); }