
--Room 1: 3562, 10897, 3569, 10906, -2
--Room 2: 3572, 10893, 3577, 10906, -2
-- Xóa tất cả mọi thứ trên square nếu có obj
--1, tạo cầu thang lên xuống
--2, tạo nền nhà trong phạm vi ngôi nhà sẵn có
--3, thêm tường, phòng, công tác đèn cho phòng
--4, thêm đồ đạc

require "vl_quest_utils"
require "buildingstructure/vl_buildingstructure_utils"
-- require "buildingstructure/vl_bunker_labroom_basement"

--VLBS = VLBS or {}

assert(VLBS, "Stack trace: Missing dependency: VLBS - vl_bunker_labroom_basement.lua")
assert(VLF,  "Stack trace: Missing dependency: VLF - vl_bunker_labroom_basement.lua")

local GetOrCreateSquare = VLF.GetOrCreateSquare
local AddObjectToSquare = VLF.AddObjectToSquare
local AddFurniture = VLBS.AddFurniture
--local AddWall = VLBS.AddWall
local AddStair = VLBS.AddStair
local AddEmptyRoom = VLBS.AddEmptyRoom
local AddRimBunker = VLBS.AddRimBunker
local AttachFloorOverlay = VLBS.AttachFloorOverlay
--local AttachWallOverlay = VLBS.AttachWallOverlay
local AddLight = VLBS.AddLight
local AddCeilingLight = VLBS.AddCeilingLight
local GetObjectOnSquare = VLF.GetObjectOnSquare
local AddOrRepairGenerator = VLF.AddOrRepairGenerator
local AddFenceAroundArea = VLBS.AddFenceAroundArea
local AddSpecialWallsAroundArea = VLBS.AddSpecialWallsAroundArea

--tìm địa điểm đặt Bunker
--7185, 7490, 0


function VLBS.AddLabRoomX5Y7(isTransmit, x, y, x2, y2, z) --VLBS.AddLabRoomX5Y7(isTransmit, x, y, x2, y2, z)
	if not x or not y or not x2 or not y2 or not z then return end
	AddEmptyRoom({isTransmit = isTransmit, x = x, y = y, x2 = x2, y2 = y2, z = z, wallID = 10, doorID = 1, doorDir = "E", floorSprite = "floors_interior_tilesandwood_01_12", removeObj = false, attachWall = true, attachFloor = true, addLights = true})
	AddFurniture("location_community_medical_01_78", {isTransmit = isTransmit, x = x, y = y2 - 1, z = z, isNorth = true, numOfSquare = 2}) --bàn mổ
	AddObjectToSquare(nil, "industry_01_12", {isTransmit = isTransmit, x = x + 2, y = y2 - 2, z = z, objType = "IsoObject"}) --sàn thoát nước
	--AddFurniture("location_community_medical_01_72", {isTransmit = isTransmit, x = x, y = y2 - 1, z = z, isNorth = true, numOfSquare = 2}) --giường bệnh --N
	AddFurniture("location_community_medical_01_16", {isTransmit = isTransmit, x = x + 2, y = y2 - 3, z = z, isNorth = true, numOfSquare = 2}) --giường bệnh --N
	AddFurniture("location_community_medical_01_118", {isTransmit = isTransmit, x = x + 2, y = y2 - 4, z = z, isNorth = true, numOfSquare = 2}) --máy hỗ trợ --N
	AddObjectToSquare(nil, "location_community_medical_01_26", {isTransmit = isTransmit, x = x + 3, y = y2 - 4, z = z, objType = "IsoObject"}) --thanh đứng giữ truyền nước
	
	AddObjectToSquare(nil, "location_community_medical_01_66", {isTransmit = isTransmit, x = x, y = y2 - 1, z = z, objType = "IsoObject"}) --ốp tường W
	AddObjectToSquare(nil, "location_community_medical_01_66", {isTransmit = isTransmit, x = x, y = y2 - 2, z = z, objType = "IsoObject"})
	AddObjectToSquare(nil, "location_community_medical_01_66", {isTransmit = isTransmit, x = x, y = y2 - 3, z = z, objType = "IsoObject"})
	AddFurniture("furniture_tables_high_01_50", {isTransmit = isTransmit, x = x + 3, y = y2 - 7, z = z, isNorth = false, numOfSquare = 2}) --bàn --not N
	AddLight({isTransmit = isTransmit, x = x + 3, y = y2 - 7, z = z, attachLoc = "Table", lightID = 8, dir = "W", isInBuilding = false}) --đèn bàn
	AddObjectToSquare(nil, "location_community_medical_01_10", {isTransmit = isTransmit, x = x + 4, y = y2 - 6, z = z, objType = "IsoObject"}) --ghế xoay
	
	AddObjectToSquare(nil, "location_community_medical_01_88", {isTransmit = isTransmit, x = x + 2, y = y2 - 7, z = z, objType = "IsoObject"}) --hộp y tế
	AddObjectToSquare(nil, "fixtures_sinks_01_24", {isTransmit = isTransmit, x = x + 2, y = y2 - 7, z = z, objType = "IsoObject"}) --bồn rửa tay
	AddObjectToSquare(nil, "location_community_medical_01_103", {isTransmit = isTransmit, x = x, y = y2 - 7, z = z, objType = "IsoObject"}) --tủ kĩ thuật
	AddObjectToSquare(nil, "fixtures_counters_01_35", {isTransmit = isTransmit, x = x, y = y2 - 6, z = z, objType = "IsoObject"}) --tủ sắt
	AddObjectToSquare(nil, "location_community_medical_01_137", {isTransmit = isTransmit, x = x, y = y2 - 6, z = z, objType = "IsoObject"}) --kính hiển vi
	AddObjectToSquare(nil, "fixtures_counters_01_35", {isTransmit = isTransmit, x = x, y = y2 - 5, z = z, objType = "IsoObject"}) --tủ sắt
	AddObjectToSquare(nil, "fixtures_sinks_01_4", {isTransmit = isTransmit, x = x, y = y2 - 5, z = z, objType = "IsoObject"}) --bồn rửa trên tủ sắt
	AddObjectToSquare(nil, "fixtures_counters_01_35", {isTransmit = isTransmit, x = x, y = y2 - 4, z = z, objType = "IsoObject"}) --tủ sắt
	AddObjectToSquare(nil, "fixtures_bathroom_01_29", {isTransmit = isTransmit, x = x, y = y2 - 5, z = z, objType = "IsoObject"}) --tủ treo
	
	AddObjectToSquare(nil, "location_community_medical_01_54", {isTransmit = isTransmit, x = x, y = y2 - 4, z = z, objType = "IsoObject"}) --đèn ảnh X quang
	AddObjectToSquare(nil, "location_community_medical_01_161", {isTransmit = isTransmit, x = x, y = y2 - 4, z = z, objType = "IsoObject"}) --ảnh X quang
	AddObjectToSquare(nil, "location_community_medical_01_55", {isTransmit = isTransmit, x = x + 1, y = y2 - 7, z = z, objType = "IsoObject"}) --đèn ảnh X quang
	AddObjectToSquare(nil, "location_community_medical_01_156", {isTransmit = isTransmit, x = x + 1, y = y2 - 7, z = z, objType = "IsoObject"}) --ảnh X quang
	
	AddObjectToSquare(nil, "appliances_refrigeration_01_42", {isTransmit = isTransmit, x = x + 2, y = y2 - 1, z = z, objType = "IsoObject"}) --tủ lạnh
	AddObjectToSquare(nil, "location_community_medical_01_64", {isTransmit = isTransmit, x = x + 3, y = y2 - 1, z = z, objType = "IsoObject"}) --bồn hóa chất
	AddObjectToSquare(nil, "appliances_com_01_147", {isTransmit = isTransmit, x = x + 4, y = y2 - 1, z = z, objType = "IsoObject"}) --máy móc 1
	AddObjectToSquare(nil, "appliances_com_01_76", {isTransmit = isTransmit, x = x + 4, y = y2 - 7, z = z, objType = "IsoObject"}) --máy tính --N
	
	AddCeilingLight(isTransmit, x + 2, y + 4, z, 1, 3, true, false)
end
local AddLabRoomX5Y7 = VLBS.AddLabRoomX5Y7

function VLBS.AddBedRoomX4Y4_1(isTransmit, x, y, x2, y2, z)
	if not x or not y or not x2 or not y2 or not z then return end
	AddEmptyRoom({isTransmit = isTransmit, x = x, y = y, x2 = x2, y2 = y2, z = z, wallID = 10, doorID = 3, doorDir = "S", floorSprite = "floors_exterior_street_01_16", removeObj = false, attachWall = true, attachFloor = true, addLights = false})
	AddFurniture("furniture_bedding_01_62", {isTransmit = isTransmit, x = x, y = y + 3, z = z, isNorth = true, numOfSquare = 2}) --giường ngủ 2 ô--N
	AddObjectToSquare(nil, "furniture_storage_02_0", {isTransmit = isTransmit, x = x, y = y, z = z, objType = "IsoObject"}) --tủ quần áo sắt
	AddObjectToSquare(nil, "furniture_storage_02_0", {isTransmit = isTransmit, x = x + 1, y = y, z = z, objType = "IsoObject"}) --tủ quần áo sắt
	AddFurniture("location_business_office_generic_01_5", {isTransmit = isTransmit, x = x + 2, y = y, z = z, isNorth = false, numOfSquare = 2}) --bàn làm việc 2 ô --not N
	AddObjectToSquare(nil, "furniture_seating_indoor_03_47", {isTransmit = isTransmit, x = x + 3, y = y + 1, z = z, objType = "IsoObject"}) --ghế tựa lưng
	AddObjectToSquare(nil, "location_business_office_generic_01_25", {isTransmit = isTransmit, x = x + 3, y = y + 3, z = z, objType = "IsoObject"}) --tủ tài liệu
	AddObjectToSquare(nil, "furniture_storage_01_54", {isTransmit = isTransmit, x = x + 1, y = y + 3, z = z, objType = "IsoObject"}) --tủ tài liệu
	AddCeilingLight(isTransmit, x + 1, y + 1, z, 2, 2, false, false)
end
local AddBedRoomX4Y4_1 = VLBS.AddBedRoomX4Y4_1

function VLBS.AddToiletRoomX4Y3_1(isTransmit, x, y, x2, y2, z)
	if not x or not y or not x2 or not y2 or not z then return end
	AddEmptyRoom({isTransmit = isTransmit, x = x, y = y, x2 = x2, y2 = y2, z = z, wallID = 10, doorID = 3, doorDir = "W", removeObj = false, attachWall = true, attachFloor = true})
	AddObjectToSquare(nil, "fixtures_bathroom_01_32", {isTransmit = isTransmit, x = x, y = y, z = z, objType = "IsoObject"}) --nội thất bồn tắm đứng
	AddObjectToSquare(nil, "fixtures_bathroom_01_34", {isTransmit = isTransmit, x = x + 1, y = y, z = z, objType = "IsoObject"}) --vách ngăn
	AddObjectToSquare(nil, "fixtures_bathroom_01_35", {isTransmit = isTransmit, x = x, y = y + 1, z = z, objType = "IsoObject"}) --vách ngăn
	AddObjectToSquare(nil, "fixtures_bathroom_01_36", {isTransmit = isTransmit, x = x + 1, y = y + 1, z = z, objType = "IsoObject"}) --pillar vách ngăn
	AddObjectToSquare(nil, "fixtures_bathroom_01_0", {isTransmit = isTransmit, x = x + 2, y = y, z = z, objType = "IsoObject"}) --bồn cầu
	AddObjectToSquare(nil, "fixtures_bathroom_01_14", {isTransmit = isTransmit, x = x, y = y + 2, z = z, objType = "IsoObject"}) --hộp khăn giấy
	AddObjectToSquare(nil, "fixtures_sinks_01_28", {isTransmit = isTransmit, x = x + 1, y = y + 2, z = z, objType = "IsoObject"}) --bồn rửa tay
	AddObjectToSquare(nil, "fixtures_bathroom_01_37", {isTransmit = isTransmit, x = x + 1, y = y + 2, z = z, objType = "IsoObject"}) --tủ treo
	AddLight({isTransmit = isTransmit, x = x + 1, y = y, z = z, attachLoc = "Wall", lightID = 5, dir = "N", isInBuilding = false})
end
local AddToiletRoomX4Y3_1 = VLBS.AddToiletRoomX4Y3_1

function VLBS.AddBunkerLabRoom(args) --VLBS.AddBunkerLabRoom({isTransmit = false, x = x, y = y, x2 = x2, y2 = y2, z = z})
	local x, y, x2, y2, z = math.floor(args.x), math.floor(args.y), math.floor(args.x2), math.floor(args.y2), math.floor(args.z)
	if not x or not y or not x2 or not y2 or not z then return end
	local isTransmit = args.isTransmit or false
	
	--Bunker
	AddEmptyRoom({isTransmit = isTransmit, x = x, y = y, x2 = x2, y2 = y2, z = z, wallID = 9, doorID = 1, doorDir = "E", isGaradoor = true, floorSprite = "floors_exterior_street_01_16", roofSprite = "blends_natural_01_32", removeObj = true, attachWall = true, attachFloor = true, addLights = true})
	AddRimBunker({isTransmit = isTransmit, x = x, y = y, x2 = x2, y2 = y2, z = z, floorSprite = "blends_street_01_16"})
	
	--add tường đặc biệt trên mái Bunker
	AddSpecialWallsAroundArea({isTransmit = isTransmit, x = x, y = y, x2 = x2, y2 = y2, z = z + 1})
	
	--add hàng rào
	AddFenceAroundArea({isTransmit = isTransmit, x = x - 5, y = y - 5, x2 = x2 + 5, y2 = y2 + 5, z = z, fenceID = 2, doorID = 2, doorDir = "E", removeObj = false})
	
	local _x, _y, _x2, _y2, _z = x - 7, y - 6, x2, y2, z - 1 --tọa độ basement B1
	--add basement
	AddEmptyRoom({isTransmit = isTransmit, x = _x, y = _y, x2 = _x2, y2 = _y2, z = _z, wallID = 10, floorSprite = "floors_exterior_street_01_16", removeObj = true, borderUndergrd = true})
	
	--add stair
	AddStair({isTransmit = isTransmit, x = x, y = y + 4, z = z - 1, isNorth = true, stairID = 2, side = "W", floorSprite = "floors_exterior_street_01_16"})
	
	--Phòng thí nghiệm
	AddLabRoomX5Y7(isTransmit, _x, _y2 - 7, _x + 5, _y2, _z)
	
	--Phòng ngủ
	AddBedRoomX4Y4_1(isTransmit, _x, _y, _x + 4, _y + 4, _z)
	AddBedRoomX4Y4_1(isTransmit, _x + 4, _y, _x + 8, _y + 4, _z)
	AddObjectToSquare(nil, "appliances_com_01_76", {isTransmit = isTransmit, x = _x + 7, y = _y, z = _z, objType = "IsoObject"}) --máy tính --N
	AddBedRoomX4Y4_1(isTransmit, _x + 8, _y, _x + 12, _y + 4, _z)
	
	--[[
	--Phòng kỹ thuật
	AddEmptyRoom({isTransmit = isTransmit, x = _x2 - 3, y = _y2 - 3, x2 = _x2, y2 = _y2, z = _z, wallID = 10, doorID = 3, doorDir = "W", removeObj = false, attachWall = true, attachFloor = true})
	AddObjectToSquare(nil, "industry_02_164", {isTransmit = isTransmit, x = _x2 - 3, y = _y2 - 3, z = _z, objType = "IsoObject"})
	AddObjectToSquare(nil, "industry_02_165", {isTransmit = isTransmit, x = _x2 - 2, y = _y2 - 3, z = _z, objType = "IsoObject"})
	AddObjectToSquare(nil, "industry_02_169", {isTransmit = isTransmit, x = _x2 - 1, y = _y2 - 3, z = _z, objType = "IsoObject"})
	AddLight({isTransmit = isTransmit, x = _x2 - 1, y = _y2 - 1, z = _z, attachLoc = "Wall", lightID = 5, dir = "S", isInBuilding = false})
	AddLight({isTransmit = isTransmit, x = _x2 - 2, y = _y2 - 1, z = _z, attachLoc = "Wall", lightID = 5, dir = "S", isInBuilding = false})
	]]
	
	--Phòng vệ sinh
	AddToiletRoomX4Y3_1(isTransmit, _x2 - 3, _y2 - 3, _x2, _y2, _z)

	--Phòng chứa đồ
	AddEmptyRoom({isTransmit = isTransmit, x = _x2 - 3, y = _y2 - 7, x2 = _x2, y2 = _y2 - 3, z = _z, wallID = 10, doorID = 3, doorDir = "W", removeObj = false, attachWall = true, attachFloor = true, addLights = true})
	AddObjectToSquare(nil, "furniture_storage_02_0", {isTransmit = isTransmit, x = _x2 - 3, y = _y2 - 7, z = _z, objType = "Container"})
	AddObjectToSquare(nil, "furniture_storage_02_0", {isTransmit = isTransmit, x = _x2 - 2, y = _y2 - 7, z = _z, objType = "Container"})
	AddObjectToSquare(nil, "furniture_storage_02_0", {isTransmit = isTransmit, x = _x2 - 1, y = _y2 - 7, z = _z, objType = "Container"})
	AddObjectToSquare(nil, "furniture_storage_02_2", {isTransmit = isTransmit, x = _x2 - 3, y = _y2 - 4, z = _z, objType = "Container"})
	AddObjectToSquare(nil, "furniture_storage_02_2", {isTransmit = isTransmit, x = _x2 - 2, y = _y2 - 4, z = _z, objType = "Container"})
	AddObjectToSquare(nil, "furniture_storage_02_2", {isTransmit = isTransmit, x = _x2 - 1, y = _y2 - 4, z = _z, objType = "Container"})
	
	--Overlay hành lang
	AttachFloorOverlay({isTransmit = isTransmit, x = _x + 5, y = _y + 4, x2 = _x2 - 3, y2 = _y2, z = _z, sideID = 2, midID = 6, rateSqToAdd = 5})
	AttachFloorOverlay({isTransmit = isTransmit, x = _x, y = _y + 4, x2 = _x2, y2 = _y + 5, z = _z, sideID = 2, midID = 6, rateSqToAdd = 5})
	AddObjectToSquare(nil, "trashcontainers_01_17", {isTransmit = isTransmit, x = _x + 5, y = _y2 - 1, z = _z, objType = "IsoObject"}) --thùng rác
	AddObjectToSquare(nil, "location_business_office_generic_01_49", {isTransmit = isTransmit, x = _x + 7, y = _y + 4, z = _z, objType = "IsoObject"}) --bình nước nóng
	
	--Add Lights
	AddLight({isTransmit = isTransmit, x = _x + 5, y = _y2 - 2, z = _z, attachLoc = "Wall", lightID = 8, dir = "W", isInBuilding = false})
	AddLight({isTransmit = isTransmit, x = _x + 5, y = _y2 - 6, z = _z, attachLoc = "Wall", lightID = 8, dir = "W", isInBuilding = false})
	AddLight({isTransmit = isTransmit, x = _x + 1, y = _y + 4, z = _z, attachLoc = "Wall", lightID = 8, dir = "N", isInBuilding = false})
	AddLight({isTransmit = isTransmit, x = _x + 5, y = _y + 4, z = _z, attachLoc = "Wall", lightID = 8, dir = "N", isInBuilding = false})
	AddLight({isTransmit = isTransmit, x = _x + 9, y = _y + 4, z = _z, attachLoc = "Wall", lightID = 8, dir = "N", isInBuilding = false})
	
	local xG, yG, zG = ((_x + _x2) / 2), ((_y + _y2) / 2), _z - 1
	local sq = GetOrCreateSquare(xG, yG, zG)
	if sq then
		AddOrRepairGenerator(isTransmit, "Base.Generator_Yellow", xG, yG, zG)
	end
	print("Shared---AddBunkerLabRoom---Added=", x, y, x2, y2, z)
end
--VLBS.AddBunkerLabRoom({isTransmit = false, x = getPlayer():getX(), y = getPlayer():getY(), x2 = getPlayer():getX()+5, y2 = getPlayer():getY()+7, z = 0})







