/** 
 *	TrackMania Map library
 */

#Const Version		"2013-12-17"
#Const ScriptName	"Map.Script.txt"

// ---------------------------------- //
// 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;
}

Vec3 GetBlockSize(Text _Enviro) {	
	switch (_Enviro) {
		case "Valley": {
			return <32., 8., 32.>;
		}
		case "Canyon": {
			return <64., 16., 64.>;
		}
		case "Stadium": {
			return <32., 8., 32.>;
		}
	}
	
	return <0., 0., 0.>;
}

Vec3 GetBlockSize() {
	if (Map == Null) return <0., 0., 0.>;
	return GetBlockSize(Map.CollectionName);
}

Vec3 GetBlockPosition(Int3 _BlockPosition) {
	declare Vec3 Position;
	declare Vec3 ShiftPosition;
	declare BlockPosition = _BlockPosition;
	declare BlockSize = <32., 8., 32.>;
	
	if (Map != Null && Map.CollectionName == "Valley") {
		BlockSize = GetBlockSize();
		BlockPosition.Y -= 5;
	} else if (Map != Null && Map.CollectionName == "Canyon") {
		BlockSize = GetBlockSize();
		BlockPosition.Y -= 15;
	} else if (Map != Null && Map.CollectionName == "Stadium") {
		BlockSize = GetBlockSize();
		BlockPosition.Y -= 9;
		ShiftPosition = <0., 9.3, 0.>;
	}
	
	for (I, 0, 2) {
		Position[I] = (BlockPosition[I] * BlockSize[I]) + (BlockSize[I] / 2.) + ShiftPosition[I];
	}
	
	return Position;
}