From the smug smile that flashed, "I've got this under control", to the horrible realization that he was an adulterer, murderer, deceiver, liar, and betrayer, his world was reduced to the cesspool of reality that he was drowning in.
At that moment only the answers to two questions mattered. What does God say you should do? Are you going to do it?
What appears to be a script for a movie or TV show is a story from ancient times, sadly acted out over and over in the centuries since.
David, second king of Israel, had it all and lost it when lust controlled him. It is then that he answers those two most fundamental of questions. His answer can be read in the 51st Psalm.
Have mercy upon me, Oh God, according to Your loving kindness; according to the multitude of Your tender mercies, blot out my transgressions.
Wash me thoroughly from my iniquity, and cleanse me from my sin. For I acknowledge my transgressions, and my sin is always before me.
David betrayed God, asked for forgiveness and is granted it, yet David still suffered the consequences of that sin (two of his sons die). In spite of all this both the prophet Samuel and Luke describe David as a man after God's own heart.
Those two questions remain for you to answer. What does God say you should do and Are you going to do it?