--[[
	Loop that flashes the alert lights for rooms that are not pressurized.
]]

function RoomManager._flashAlerts()
	coroutine.wrap(
		function()
			local onColor = Color3.fromRGB(255, 0, 0)
			local offColor = Color3.fromRGB(0, 0, 0)
			while true do
				local allAlerts = {}

				for _, room in pairs(RoomManager.getRooms()) do
					if not room:isPressurized() then
						local alerts = room:getModel().AlertLights:GetChildren()
						for _, alert in pairs(alerts) do
							table.insert(allAlerts, alert)
						end
					end
				end

				for _, alert in pairs(allAlerts) do
					local lamp = alert:FindFirstChild("Lamp")
					local light = lamp:FindFirstChild("Bulb"):FindFirstChild("Light")

					light.Enabled = true
					lamp.Part.Color = onColor
				end

				wait(1)

				for _, alert in pairs(allAlerts) do
					local lamp = alert:FindFirstChild("Lamp")
					local light = lamp:FindFirstChild("Bulb"):FindFirstChild("Light")

					light.Enabled = false
					lamp.Part.Color = offColor
				end

				wait(1)
			end
		end
	)()
end

function RoomManager.resetRooms()
	for _, room in pairs(rooms:getAll()) do
		room:reset()
	end
end
