/**
 *  Base for a standard Shootmania game mode
 */
#Extends "Modes/ShootMania/Base/ModeMatchmaking2.Script.txt"

#Const MS_Version			"2017-01-31"
#Const MS_ScriptName	"Modes/ShootMania/ModeShootmania.Script.txt"

/*

This template use a structure with several nested loops
representing the progression of the game mode.

Server -> Match -> Map -> Round -> Turn -> PlayLoop

The server can launch a match. 
This match can be played on several maps. 
Each maps can be divided into several rounds.
Each rounds can be further divided into several turns.

The playloop is executed repeatedly until an upper
level section (turn, round, map, match or server)
is requested to stop.

Each loop has several plugs at the beginning
and the end allowing you to implement the
game mode logic.

This is a simplified overview of the loops and available plugs :
- InitServer
- StartServer
	- InitMatch
	- StartMatch
		- InitMap
		- StartMap
			- InitRound
			- StartRound
				- InitTurn
				- StartTurn
					- PlayLoop
				- EndTurn
			- EndRound
		- EndMap
	- EndMatch
- EndServer

To extends this template and write your game mode
you have to start your script with the following line :
#Extends "Modes/ShootMania/Base/ModeShootmania.Script.txt"

Then you write your code inside the plugs like that :
***NameOfThePlug***
***
// Your code here
***

By example if you want to update the status message
of the server at the beginning of each map
to display the name of the current map
you can do :
***StartMap***
***
ModeStatusMessage = "Current map : "^Map.MapInfo.Name;
***

Below you will find a list of all available
plugs with a description of what you can do
inside them.

The plugs prefixed by "Lobby_" are only executed
in the context of the matchmaking lobby. If you are
writing a game mode you most probably want to use
the plugs prefixed by "Match_".

*/


// ---------------------------------- //
/**	Here you can write code that need
 *	to be executed whenever the script
 *	is updated.
 */
***MB_Private_Yield***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_Yield+++ }
	default									: { +++Match_Yield+++ }
}
***

// ---------------------------------- //
/**	Here you can declare and set settings specific 
 *	to the mode. Unlike the #Settings they won't 
 *	be accessible from the outside.
 *	This includes some default settings like the
 *	automatic handling of the ladder, hud,
 *	scores or spectators ...
 */
***MB_Private_Settings***
***
// Open and close the ladder at the begining and end of the map
MB_Settings_UseDefaultLadder = True;
// Play the mediatracker intro sequence when starting the map						
MB_Settings_UseDefaultIntroSequence = True;
// Play the podium sequence at the end of the map
MB_Settings_UseDefaultPodiumSequence = True;
// Manage the UISequence and UI overlay
MB_Settings_UseDefaultUIManagement = True;
// Start and stop the timer at the begining and end of the turn
MB_Settings_UseDefaultTimer = True;
// Load the default HUD module when launching the server
MB_Settings_UseDefaultHud = True;
// Initialize the player scores
MB_Settings_UseDefaultScores = True;
// Display the clans info overlay at the top of the screen
MB_Settings_UseDefaultClansScoresUI = True;
// Display the scores and map info on the spawn screen
MB_Settings_UseDefaultSpawnScreen = True;
// Turn on the lights on the landmarks (poles, spawns, ...)
MB_Settings_UseDefaultBaseIllumination = True;
// Play sounds at the begining/ending of some sections
MB_Settings_UseDefaultSounds = True;
// Manage objects automatically
MB_Settings_UseDefaultObjects = True;
// In the development environment, warn the player on how to implement the matchmaking
MB_Settings_UseMatchmakingImplementationHelper = True;
// Use the default matchmaking implementation
MB_Settings_UseDefaultMatchmaking = True;

switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_Settings+++ }
	default									: { +++Match_Settings+++ }
}
***

// ---------------------------------- //
/// You can load your libraries here
***MB_Private_LoadLibraries***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_LoadLibraries+++ }
	default									: { +++Match_LoadLibraries+++ }
}
***

// ---------------------------------- //
/// You can log your script versions here
***MB_Private_LogVersions***
***
Log::RegisterScript(MS_ScriptName, MS_Version);

switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_LogVersions+++ }
	default									: { +++Match_LogVersions+++ }
}
***

// ---------------------------------- //
/**	This is the place to setup the
 *	matchmaking. Check the MM_SetFormat()
 *	and MM_SetProgressiveFormats() for
 *	more info.
 */
***MM_Private_SetupMatchmaking***
***
+++MM_SetupMatchmaking+++
***

// ---------------------------------- //
/// This plug is executed before the loading of the hud module
***MB_Private_BeforeLoadHud***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeLoadHud+++ }
	default									: { +++Match_BeforeLoadHud+++ }
}
***

// ---------------------------------- //
/**	Here you can load a HUD module.
 *	If the default HUD is enabled
 *	(MB_Settings_UseDefaultHud) then this
 *	plug is not executed
 */
***MB_Private_LoadHud***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_LoadHud+++ }
	default									: { +++Match_LoadHud+++ }
}
***


// ---------------------------------- //
/// This plug is executed after the loading of the hud module
***MB_Private_AfterLoadHud***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterLoadHud+++ }
	default									: { +++Match_AfterLoadHud+++ }
}
***

// ---------------------------------- //
/**	Here you can describe your mode
 *	and its rules. It is recommended to
 *	use the ModeInfo library to do that.
 */
***MB_Private_Rules***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_Rules+++ }
	default									: { +++Match_Rules+++ }
}
***

// ---------------------------------- //
/**	Here you can define the rules of 
 *	the mode played during a matchmaking match.
 *	It will be displayed in the lobby.
 */
***Lobby_Private_MatchRulesManialink***
***
ManialinkRules = "";
+++Lobby_MatchRulesManialink+++
***

// ---------------------------------- //
/** Use this plug to declare variables
 *	that will be accessible in the following
 *	child section : Server, Match, Map, Round, Turn, PlayLoop.
 *	This plug is executed once at the
 *	start of the server or if the script
 *	is restarted.
 */
***MB_Private_InitServer***
***
+++Match_InitServer+++
+++Lobby_InitServer+++
***

// ---------------------------------- //
/** Use this plug to initialize the server.
 *	This plug is executed once at the
 *	start of the server or if the script
 *	is restarted.
 */
***MB_Private_StartServer***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_StartServer+++ }
	default									: { +++Match_StartServer+++ }
}
***

// ---------------------------------- //
/** This plug is executed before the
 *	initialization of the SpawnScreen
 *	library
 */
***MB_Private_BeforeSpawnScreen***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeSpawnScreen+++ }
	default									: { +++Match_BeforeSpawnScreen+++ }
}
***

// ---------------------------------- //
/**	Here you can initialize the SpawnScreen
 *	library.
 *	If the default spawn screen is enabled
 *	(MB_Settings_UseDefaultSpawnScreen) 
 *	then this plug is not executed
 */
***MB_Private_SpawnScreen***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_SpawnScreen+++ }
	default									: { +++Match_SpawnScreen+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	initialization of the SpawnScreen
 *	library
 */
***MB_Private_AfterSpawnScreen***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterSpawnScreen+++ }
	default									: { +++Match_AfterSpawnScreen+++ }
}
***

// ---------------------------------- //
/** Use this plug to declare variables
 *	that will be accessible in the following
 *	child section : Match, Map, Round, Turn, PlayLoop.
 *	This plug is executed at the start 
 *	of each match.
 */
***MB_Private_InitMatch***
***
+++Match_InitMatch+++
+++Lobby_InitMatch+++
***

// ---------------------------------- //
/** Use this plug to initialize the match.
 *	This plug is executed at the start 
 *	of each match.
 */
***MB_Private_StartMatch***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_StartMatch+++ }
	default									: { +++Match_StartMatch+++ }
}
***

// ---------------------------------- //
/** This plug is executed before the
 *	loading of the map
 */
***MB_Private_BeforeLoadMap***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeLoadMap+++ }
	default									: { +++Match_BeforeLoadMap+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	loading of the map
 */
***MB_Private_AfterLoadMap***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterLoadMap+++ }
	default									: { +++Match_AfterLoadMap+++ }
}
***

// ---------------------------------- //
/** Use this plug to declare variables
 *	that will be accessible in the following
 *	child section : Map, Round, Turn, PlayLoop.
 *	This plug is executed at the start 
 *	of each map.
 */
***MB_Private_InitMap***
***
+++Match_InitMap+++
+++Lobby_InitMap+++
***

// ---------------------------------- //
/** This plug is executed before the
 *	introduction sequence of the map
 */
***MB_Private_BeforeIntroSequence***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeIntroSequence+++ }
	default									: { +++Match_BeforeIntroSequence+++ }
}
***

// ---------------------------------- //
/**	Here you can manage the introduction
 *	sequence as you wish.
 *	If the default introduction sequence
 *	is enabled (MB_Settings_UseDefaultIntroSequence) 
 *	then this plug is not executed
 */
***MB_Private_IntroSequence***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_IntroSequence+++ }
	default									: { +++Match_IntroSequence+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	introduction sequence of the map
 */
***MB_Private_AfterIntroSequence***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterIntroSequence+++ }
	default									: { +++Match_AfterIntroSequence+++ }
}
***

// ---------------------------------- //
/** This plug is executed before the
 *	opening of the match on the ladder
 */
***MB_Private_BeforeOpenLadder***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeOpenLadder+++ }
	default									: { +++Match_BeforeOpenLadder+++ }
}
***

// ---------------------------------- //
/**	Here you can manage the opening
 *	of the match on the ladder.
 *	If the default ladder is enabled
 *	(MB_Settings_UseDefaultLadder) 
 *	then this plug is not executed
 */
***MB_Private_OpenLadder***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_OpenLadder+++ }
	default									: { +++Match_OpenLadder+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	opening of the match on the ladder
 */
***MB_Private_AfterOpenLadder***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterOpenLadder+++ }
	default									: { +++Match_AfterOpenLadder+++ }
}
***

// ---------------------------------- //
/** Use this plug to initialize the map.
 *	This plug is executed at the start 
 *	of each map.
 */
***MB_Private_StartMap***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_StartMap+++ }
	default									: { +++Match_StartMap+++ }
}
***

// ---------------------------------- //
/** Use this plug to declare variables
 *	that will be accessible in the following
 *	child section : Round, Turn, PlayLoop.
 *	This plug is executed at the start 
 *	of each round.
 */
***MB_Private_InitRound***
***
+++Match_InitRound+++
+++Lobby_InitRound+++
***

// ---------------------------------- //
/** Use this plug to initialize the round.
 *	This plug is executed at the start 
 *	of each round.
 */
***MB_Private_StartRound***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_StartRound+++ }
	default									: { +++Match_StartRound+++ }
}
***

// ---------------------------------- //
/** Use this plug to declare variables
 *	that will be accessible in the following
 *	child section : Turn, PlayLoop.
 *	This plug is executed at the start 
 *	of each turn.
 */
***MB_Private_InitTurn***
***
+++Match_InitTurn+++
+++Lobby_InitTurn+++
***

// ---------------------------------- //
/** Use this plug to initialize the turn.
 *	This plug is executed at the start 
 *	of each turn.
 */
***MB_Private_StartTurn***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_StartTurn+++ }
	default									: { +++Match_StartTurn+++ }
}
***

// ---------------------------------- //
/** Use this plug to declare variables
 *	that will be accessible in the
 *	PlayLoop section.
 *	This plug is executed once at the start 
 *	of the play loop.
 */
***MB_Private_InitPlayLoop***
***
+++Match_InitPlayLoop+++
+++Lobby_InitPlayLoop+++
***

// ---------------------------------- //
/** Use this plug to initialize the play loop.
 *	This plug is executed once at the start 
 *	of the play loop.
 */
***MB_Private_StartPlayLoop***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_StartPlayLoop+++ }
	default									: { +++Match_StartPlayLoop+++ }
}
***

// ---------------------------------- //
/** This is where the core of the game mode
 *	will be scripted. This plug is executed
 *	for each play loop until a parent section
 *	(Turn, Round, Map, Match, Server) is requested
 *	to stop.
 */
***MB_Private_PlayLoop***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_PlayLoop+++ }
	default									: { +++Match_PlayLoop+++ }
}
***

// ---------------------------------- //
/** This plug is executed once when 
 *	exiting the play loop.
 */
***MB_Private_EndPlayLoop***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_EndPlayLoop+++ }
	default									: { +++Match_EndPlayLoop+++ }
}
***

// ---------------------------------- //
/**	This plug is executed at the end 
 *	of each turn.
 */
***MB_Private_EndTurn***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_EndTurn+++ }
	default									: { +++Match_EndTurn+++ }
}
***

// ---------------------------------- //
/**	This plug is executed at the end 
 *	of each round.
 */
***MB_Private_EndRound***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_EndRound+++ }
	default									: { +++Match_EndRound+++ }
}
***

// ---------------------------------- //
/**	This plug is executed at the end 
 *	of each map.
 */
***MB_Private_EndMap***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_EndMap+++ }
	default									: { +++Match_EndMap+++ }
}
***

// ---------------------------------- //
/** This plug is executed before the
 *	closing of the match on the ladder
 */
***MB_Private_BeforeCloseLadder***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeCloseLadder+++ }
	default									: { +++Match_BeforeCloseLadder+++ }
}
***

// ---------------------------------- //
/**	Here you can manage the closing
 *	of the match on the ladder.
 *	If the default ladder is enabled
 *	(MB_Settings_UseDefaultLadder) 
 *	then this plug is not executed
 */
***MB_Private_CloseLadder***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_CloseLadder+++ }
	default									: { +++Match_CloseLadder+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	closing of the match on the ladder
 */
***MB_Private_AfterCloseLadder***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterCloseLadder+++ }
	default									: { +++Match_AfterCloseLadder+++ }
}
***

// ---------------------------------- //
/** This plug is executed before the
 *	podium sequence.
 */
***MB_Private_BeforePodiumSequence***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforePodiumSequence+++ }
	default									: { +++Match_BeforePodiumSequence+++ }
}
***

// ---------------------------------- //
/**	Here you can manage the podium
 *	sequence as you wish.
 *	If the default podium sequence
 *	is enabled (MB_Settings_UseDefaultPodiumSequence) 
 *	then this plug is not executed.
 */
***MB_Private_PodiumSequence***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_PodiumSequence+++ }
	default									: { +++Match_PodiumSequence+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	podium sequence.
 */
***MB_Private_AfterPodiumSequence***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterPodiumSequence+++ }
	default									: { +++Match_AfterPodiumSequence+++ }
}
***

// ---------------------------------- //
/** This plug is executed before the
 *	unloading of the map.
 */
***MB_Private_BeforeUnloadMap***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_BeforeUnloadMap+++ }
	default									: { +++Match_BeforeUnloadMap+++ }
}
***

// ---------------------------------- //
/** This plug is executed after the
 *	unloading of the map.
 */
***MB_Private_AfterUnloadMap***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_AfterUnloadMap+++ }
	default									: { +++Match_AfterUnloadMap+++ }
}
***

// ---------------------------------- //
/**	This plug is executed at the end 
 *	of each match.
 */
***MB_Private_EndMatch***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_EndMatch+++ }
	default									: { +++Match_EndMatch+++ }
}
***

// ---------------------------------- //
/**	This plug is executed once just
 *	before the server shut down when 
 *	it is requested to stop.
 */
***MB_Private_EndServer***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_EndServer+++ }
	default									: { +++Match_EndServer+++ }
}
***

// ---------------------------------- //
/// You can unload your libraries here.
***MB_Private_UnloadLibraries***
***
switch (MB_Private_ExtendMode) {
	case C_ExtendMode_Lobby	: { +++Lobby_UnloadLibraries+++ }
	default									: { +++Match_UnloadLibraries+++ }
}
***

// ---------------------------------- //
// Functions
// ---------------------------------- //
// ---------------------------------- //
/// Restart the script from the beginning
Void MB_RestartScript() {
	MB_Private_RestartScript();
}

// ---------------------------------- //
/// Request the stop of a section
Void MB_StopServer() {
	MB_Private_StopServer();
}
Void MB_StopMatch() {
	MB_Private_StopMatch();
}
Void MB_StopMap() {
	MB_Private_StopMap();
}
Void MB_StopRound() {
	MB_Private_StopRound();
}
Void MB_StopTurn() {
	MB_Private_StopTurn();
}

// ---------------------------------- //
/** Check if the a section can continue
 *	to run or if it was requested to stop
 *
 *	@return														True if the section can be played
 *																		False if it was requested to stop
 */
Boolean MB_ServerIsRunning() {
	return MB_Private_ServerIsRunning();
}
Boolean MB_MatchIsRunning() {
	return MB_Private_MatchIsRunning();
}
Boolean MB_MapIsRunning() {
	return MB_Private_MapIsRunning();
}
Boolean MB_RoundIsRunning() {
	return MB_Private_RoundIsRunning();
}
Boolean MB_TurnIsRunning() {
	return MB_Private_TurnIsRunning();
}

// ---------------------------------- //
/** Get the number of times a section
 *	has been played
 *
 *	@return														The number of times the section 
 *																		has been played
 */
Integer MB_GetMatchCount() {
	return MB_Private_GetMatchCount();
}
Integer MB_GetMapCount() {
	return MB_Private_GetMapCount();
}
Integer MB_GetRoundCount() {
	return MB_Private_GetRoundCount();
}
Integer MB_GetTurnCount() {
	return MB_Private_GetTurnCount();
}

// ---------------------------------- //
/**	The yield; instruction update the state 
 *	of the script. In particular the old 
 *	events will be flushed and replaced 
 *	by the ones that happened since 
 *	the last yield.
 *	To ensure that no event is lost,
 *	yield must be executed at one
 *	and only one point in the script.
 *	Inside the MB_Yield() function.
 *	As long as you only use this function
 *	to yield, you can be sure
 *	that the code inside ***Match_Yield***
 *	and ***Lobby_Yield*** will be
 *	executed whenever the script
 *	state is updated.
 *
 *	Functions like sleep() or wait() will
 *	execute the yield; instruction
 *	automatically. You must not use these
 *	functions.
 */
Void MB_Yield() {
  MB_Private_Yield();
}

// ---------------------------------- //
/** Replace the sleep() function safely
 *	Read the description of the MB_Yield()
 *	function for more info.
 *
 *	@param	_Duration									The duration of the sleep
 */
Void MB_Sleep(Integer _Duration) {
	MB_Private_Sleep(_Duration);
}

// ---------------------------------- //
/** Check if a map is already loaded
 *	and if it is not the case, load the
 *	next map in the playlist.
 */
Void MB_LoadMap() {
  MB_Private_LoadMap();
}

// ---------------------------------- //
/** Check if a map is loaded and if
 *	it is the case, unload it.
 */
Void MB_UnloadMap() {
  MB_Private_UnloadMap();
}

// ---------------------------------- //
/** Close any previous match and open
 *	a new one on the ladder.
 *	If the default ladder is enabled
 *	(MB_Settings_UseDefaultLadder)
 *	this function is already called
 *	automatically at the start of the map.
 */
Void MB_OpenLadder() {
	MB_Private_OpenLadder();
}

// ---------------------------------- //
/** Close any open match on the ladder.
 *	If the default ladder is enabled
 *	(MB_Settings_UseDefaultLadder)
 *	this function is already called
 *	automatically at the end of the map.
 *
 *	@param	_ValidMatch								If True the match will be validated
 *																		and players will receive ladder points.
 *																		If False the match will be canceled
 *																		and players won't receive ladder points.
 */
Void MB_CloseLadder(Boolean _ValidMatch) {
	MB_Private_CloseLadder(_ValidMatch);
}

// ---------------------------------- //
/** If the default ladder is enabled
 *	(MB_Settings_UseDefaultLadder) call
 *	this function before ***Match_CloseLadder***
 *	to cancel the ongoing match on the
 *	ladder and prevent players from 
 *	receiving any ladder points.
 */
Void MB_CancelMatchOnLadder() {
	MB_Private_CancelMatchOnLadder();
}

// ---------------------------------- //
/** Force the server to wait for the
 *	synchronization of all players
 *	before continuing
 */
Void MB_Synchro() {
	MB_Private_Synchro();
}

// ---------------------------------- //
/** Let the built-in algorithm balance
 *	the teams
 */
Void MB_AutoTeamBalance() {
	MB_Private_AutoTeamBalance();
}

// ---------------------------------- //
/** Setup the UI to enable or disable
 *	the players spawning, the notifications,
 *	or the mouse cursor for example.
 *	If you are using the default UI management
 *	(MB_Settings_UseDefaultUIManagement)
 *	this function is already called
 *	automatically at the start and end
 *	of the turn.
 *
 *	@param	_Enabled									True to let players spawn,
 *																		False otherwise
 */
Void MB_EnablePlayMode(Boolean _Enabled) {
	MB_Private_EnablePlayMode(_Enabled);
}

// ---------------------------------- //
/** Play the mediatracker introduction
 *	sequence of the map.
 *	If you are using the default intro
 *	sequence (MB_Settings_UseDefaultIntroSequence)
 *	this function is already called
 *	automatically at the start of the map.
 */
Void MB_IntroSequence() {
	MB_Private_IntroSequence();
}

// ---------------------------------- //
/** Play the players presentation sequence.
 *	This sequence display two panels
 *	containing informations about the
 *	players or teams.
 *
 *	@param	_Duration									Duration of the sequence
 */
Void MB_PlayersPresentationSequence(Integer _Duration) {
	MB_Private_PlayersPresentationSequence(_Duration);
}

// ---------------------------------- //
/** Play the podium sequence.
 *	This sequence display the players
 *	on the podium if there is one
 *	in the map. The scores table is
 *	displayed after a few seconds.
 *	If you are using the default
 *	podium sequence (MB_Settings_UseDefaultPodiumSequence)
 *	this functions is already called
 *	automatically at the end of the map.
 */
Void MB_PodiumSequence() {
	MB_Private_PodiumSequence();
}

// ---------------------------------- //
/** Call this function during a map
 *	to skip the podium sequence at the
 *	end of the map
 */
Void MB_SkipPodiumSequence() {
	MB_Private_SkipPodiumSequence();
}

// ---------------------------------- //
// Matchmaking
// ---------------------------------- //
// ---------------------------------- //
/** Check if the matchmaking is active
 *
 *	@return														True if the matchmaking is active,
 *																		False otherwise
 */
Boolean MM_IsMatchmakingServer() {
	return MM_Private_IsMatchmakingServer();
}

// ---------------------------------- //
/** Check if the matchmaking is active
 *	AND the universal setting is enabled
 *
 *	@return														True if the matchmaking is active and 
 *																		the universal setting is enabled,
 *																		False otherwise
 */
Boolean MM_IsUniversalServer() {
	return MM_Private_IsUniversalServer();
}

// ---------------------------------- //
/** Check if the matchmaking is active
 *	AND it is in match mode
 *
 *	@return														True if the matchmaking is active and in match mode,
 *																		False otherwise
 */
Boolean MM_IsMatchServer() {
	return MM_Private_IsMatchServer();
}

// ---------------------------------- //
/** Check if the matchmaking is active
 *	AND it is in lobby mode
 *
 *	@return														True if the matchmaking is active and in lobby mode,
 *																		False otherwise
 */
Boolean MM_IsLobbyServer() {
	return MM_Private_IsLobbyServer();
}

// ---------------------------------- //
/**	Set how many teams and how many
 *	players per team a match should
 *	have to be played.
 *	Eg: a 1vs1 match use this format [1, 1]
 *	a 1vs3 match [1, 3], a 3vs3vs3 [3, 3, 3]
 *
 *	This function shoud be called once inside
 *	***MM_SetupMatchmaking***
 */
Void MM_SetFormat(Integer[] _Format) {
	MM_Private_SetFormat(_Format);
}

// ---------------------------------- //
/** Set the progressive matchmaking formats 
 *	available on this game mode.
 *	Progressive matchmaking allow matches
 *	to be played with different amounts of
 *	players as soon as enough of them are
 *	waiting in the lobby.
 *	Eg: a mode can start in 3vs3 and after
 *	welcome more players during the game
 *	until it reaches 6vs6. To do this you
 *	have to pass the following formats :
 *	[[3, 3], [4, 4], [5, 5], [6, 6]]
 *
 *	This function shoud be called once inside
 *	***MM_SetupMatchmaking***
 *	
 *	@param	_Formats									The available formats
 */
Void MM_SetProgressiveFormats(Integer[][] _Formats) {
	MM_Private_SetProgressiveFormats(_Formats);
}

// ---------------------------------- //
/** Utility function to generate progressive
 *	matchmaking formats automatically.
 *	Eg: if you pass a format of [1, 1, 1]
 *	a minimum number of players of 3 and
 *	a maximum of 5, the function  will generate
 *	the following formats : [[3, 3, 3], [4, 4, 4], [5, 5, 5]]
 *
 *	This function shoud be called once inside
 *	***MM_SetupMatchmaking***
 *
 *	@param	_Format										The base format
 *	@param	_MinPlayersNb							Minimum number of players
 *	@param	_MaxPlayersNb							Maximum number of players
 */
Void MM_SetProgressiveFormats(Integer[] _Format, Integer _MinPlayersNb, Integer _MaxPlayersNb) {
	MM_Private_SetProgressiveFormats(_Format, _MinPlayersNb, _MaxPlayersNb);
}

// ---------------------------------- //
/** Open a matchmaking match session
 *	and prepare the map for it.
 *	You can either create a new session
 *	or continue the previous one.
 *	Starting a new session will request
 *	the match info to the api, wait for
 *	the players and start a map vote when
 *	everyone is ready.
 *	Continuing the current session will
 *	conserve the current match info, 
 *	wait for the players and start
 *	the new map when they are ready.
 *
 *	This function shoud be called once inside
 *	***Match_StartMap***.
 *
 *	If MB_Settings_UseDefaultMatchmaking is True,
 *	this function is already called
 *	automatically for you.
 *
 *	@param	_NewSession								Start a new matchmaking session
 *																		or continue the previous one
 */
Void MM_OpenSession(Boolean _NewSession) {
	MM_Private_OpenSession(_NewSession);
}

// ---------------------------------- //
/** Close the matchmaking match session.
 *	If the match is finished the players
 *	can vote for a rematch. 
 *	If the rematch is validated the players
 *	can vote for the next map and the session
 *	can be reopened at the begining of the
 *	new map.
 *	If the vote result is negative or if 
 *	a rematch is not possible anymore
 *	the players are sent back to the lobby
 *	and a new session must be created at the
 *	begining of the new map.
 *	You can pass a player login to 
 *	the function to select the match
 *	Master.
 *	The Master is the player that played
 *	the best during the match. His
 *	name will be displayed in the
 *	lobby.
 *
 *	This function shoud be called once inside
 *	***Match_BeforeUnloadMap***.
 *
 *	If MB_Settings_UseDefaultMatchmaking is True,
 *	this function is already called
 *	automatically for you.
 *
 *	@param	_MasterLogin							Login of the match master.
 *
 *	@return														True if a new session must be created
 *																		False if the session can be reopened
 */
Boolean MM_CloseSession(Text _MasterLogin) {
	return MM_Private_CloseSession(_MasterLogin);
}

// ---------------------------------- //
/** Check if a player is in the list
 *	of players allowed to play a match
 *	on the server.
 *	If the matchmaking is disabled,
 *	this function return True.
 *
 *	@param	_Player										The player to check
 *
 *	@return														True if the player is allowed to play,
 *																		False otherwise
 */
Boolean MM_PlayerIsAllowedToPlay(CPlayer _Player) {
	return MM_Private_PlayerIsValid(_Player);
}

// ---------------------------------- //
/**	Save the login of the match Master
 *	for the current session.
 *	The Master is the player that played
 *	the best during the match. His
 *	name will be displayed in the
 *	lobby.
 *
 *	If MM_CloseSession() is called
 *	automatically, then you can call
 *	this function once inside
 *	***Match_EndMap*** to override
 *	the default Master login.
 *	If you call MM_CloseSession()
 *	manually, then you don't need
 *	to use this function.
 *
 *	@param	_Login										The login of the new match Master
 */
Void MM_SetMasterLogin(Text _Login) {
	MM_Private_SetMasterLogin(_Login);
}

// ---------------------------------- //
/** If the matchmaking is activated
 *	this function will return the clan
 *	assigned by the matchmaking to
 *	the player.
 *	If the matchmaking is disabled
 *	this function will return the 
 *	default _Player.RequestedClan
 *
 *	If your mode support the matchmaking
 *	you must use this function to get
 *	the player requested clan
 *
 *	@param	_Player										The player to check
 *
 *	@return														The clan assigned by the matchmaking
 *																		to the given player.
 */
Integer MM_GetRequestedClan(CPlayer _Player) {
	return MM_Private_GetRequestedClan(_Player);
}

// ---------------------------------- //
/** When using the universal matchmaking
 *	lobby the players can join teams
 *	and select a slot inside. The slots are
 *	numbered from 1 to N. Where N is the number
 *	of slots in the team.
 *	This function allow the match server
 *	to get the slot selected by a player.
 *	This can be used to determine before
 *	the match the order in which the players
 *	are going to play in Elite for example.
 *
 *	@param	_Player										The player to check
 *
 *	@return														The slot of the player
 */
Integer MM_GetRequestedSlot(CPlayer _Player) {
	return MM_Private_GetRequestedSlot(_Player);
}

// ---------------------------------- //
/** Send the map score to the matchmaking API.
 *	It will be displayed in the lobby to
 *	the players that are offered to join
 *	a match as a substitute as an indication
 *	of the match progress.
 *
 *	@param	_Scores										The scores to send
 */
Void MM_SetScores(Integer[] _Scores) {
	MM_Private_SetScores(_Scores);
}

// ---------------------------------- //
/** When a player leaves an ongoing
 *	match, the matchmaking will search
 *	a substitute to take its place.
 *	However it's not always desired
 *	to received a substitute. By example
 *	if the match is nearly finished.
 *	This function allow you to turn on
 *	or off the requests for substitutes
 *	players.
 *
 *	@param	_AllowSubstitutes					True to allow the search for a subsitute,
 *																		False to disable it.
 */
Void MM_AllowSubstitutes(Boolean _AllowSubstitutes) {
	MM_Private_AllowSubstitutes(_AllowSubstitutes);
}

// ---------------------------------- //
/** Check if the substitutes are enabled
 *	or disabled.
 *
 *	@return														The current substitutes status.
 */
Boolean MM_SubstitutesAreAllowed() {
	return MM_Private_SubstitutesAreAllowed();
}