def _create_building(chunk_key, design, building_chunks):
	_pos = chunk_key
	_rooms = {}
	_building = {}
	_building_chunk_keys = []
	_build_queue = [design['build_order']]
	_to_build = design['chunks'].keys()
	
	while _build_queue:
		_room_name = _build_queue.pop(0)
		_to_build.remove(_room_name)
		_building[_room_name] = {'chunk_keys': []}
		_room = design['chunks'][_room_name]
		
		if 'flags' in _room:
			_flags = _room['flags']
		else:
			_flags = {}
		
		if _rooms:
			_start_chunk = connect_to_chunks(_room['doors'], _building, _room['chunks'], building_chunks)
			
			if not _start_chunk:
				return False
			
			if _start_chunk == -1:
				return -1
			
			_path = walker(_start_chunk, _room['chunks'], building_chunks, avoid_chunk_keys=_building_chunk_keys, add_first=True)
			_rooms[_room_name] = _path[:]
			_building[_room_name] = {'chunk_keys': _rooms[_room_name],
			                         'type': _room['type'],
			                         'floor': _room['floor'],
			                         'walls': _room['walls'],
			                         'doors': _room['doors'],
			                         'no_doors': [],
			                         'items': _room['items'],
			                         'flags': _flags,
			                         'spawns': {'away_from_door': [],
			                                    'door': [],
			                                    'middle': [],
			                                    'floor': [],
			                                    'edge': []}}
			_building_chunk_keys.extend(_rooms[_room_name])
		else:
			_rooms[_room_name] = walker(_pos, _room['chunks'], building_chunks, avoid_chunk_keys=_building_chunk_keys, add_first=True)
			_building_chunk_keys.extend(_rooms[_room_name])
			_building[_room_name] = {'chunk_keys': _rooms[_room_name],
			                         'type': _room['type'],
			                         'floor': _room['floor'],
			                         'walls': _room['walls'],
			                         'doors': _room['doors'],
			                         'no_doors': [],
			                         'items': _room['items'],
			                         'flags': _flags,
			                         'spawns': {'away_from_door': [],
			                                    'door': [],
			                                    'middle': [],
			                                    'floor': [],
			                                    'edge': []}}
		
		if _room['doors']:
			_build_queue.extend([d for d in _room['doors'] if d in _to_build and not d in _build_queue])
	
	return _building
dataset/ETHPy150Open flags/Reactor-3/buildinggen.py/_create_building/original