/**
 *	Respawn behaviour library
 */
#Const	Version			"2016-09-07"
#Const	ScriptName	"Libs/Nadeo/TrackMania/RespawnBehaviour.Script.txt"

// ---------------------------------- //
// Globales
// ---------------------------------- //
declare Boolean G_AllowRespawn; //< Game mode setting value
declare CTmMode::ETMRespawnBehaviour G_RespawnBehaviour; //< Wished respawn behaviour

// ---------------------------------- //
// Functions
// ---------------------------------- //
// ---------------------------------- //
// Public
// ---------------------------------- //
// ---------------------------------- //
/**	Return the version number of the script
 *
 *	@return														The version number of the script
 */
Text GetScriptVersion() {
	return Version;
}

// ---------------------------------- //
/**	Return the name of the script
 *
 *	@return														The name of the script
 */
Text GetScriptName() {
	return ScriptName;
}

// ---------------------------------- //
/** Set the wished respawn behaviour
 *
 *	@param	_RespawnBehaviour					The new respawn behaviour
 */
Void Set(CTmMode::ETMRespawnBehaviour _RespawnBehaviour) {
	G_RespawnBehaviour = _RespawnBehaviour;
	if (G_AllowRespawn) {
		RespawnBehaviour = G_RespawnBehaviour;
	} else {
		RespawnBehaviour = CTmMode::ETMRespawnBehaviour::AlwaysGiveUp;
	}
}

// ---------------------------------- //
/** Get the wished respawn behaviour
 *
 *	@return														The wished respawn behaviour
 */
CTmMode::ETMRespawnBehaviour Get() {
	return G_RespawnBehaviour;
}

// ---------------------------------- //
/** Function to call at each yield
 *	to update the library
 */
Void Yield(Boolean _AllowRespawn) {
	if (G_AllowRespawn != _AllowRespawn) {
		G_AllowRespawn = _AllowRespawn;
		Set(Get());
	}
}

// ---------------------------------- //
/// Unload the library
Void Unload() {
	G_AllowRespawn = True;
	G_RespawnBehaviour = CTmMode::ETMRespawnBehaviour::GiveUpBeforeFirstCheckPoint;
}

// ---------------------------------- //
/// Load the library
Void Load() {
	Unload();
}