To add on, that wasn't all he said and did. He also told me that “everything is all in your head” and how “you make everything that is small big” and that “everyone says that about you”. Also that “we haven't spoken about you in years and that you bring drama and you are dramatic”. I wanted to cry and i was so mad that he invited me all the way to his home to say all this. When i went silent, he asked me to leave if i had a bf.  After collecting my words, i told him that he was very rude. He then insisted that he is a good person and that he was just rude so he can protect himself. 
After all that, he completely changed in demeanor and started being all friendly out of nowhere, telling me that he used to liked me before and it hurt him seeing me with other guys. But i just felt so dehumanized after everything that was said earlier…but my body couldn't leave either. I tried to let it go but i couldn't. 
I eventually pretended like it didn't bother me and my body went into autodrive. I ended up staying at his for like hours afterwards listening to him talk about his mental health. Eventually i tried to be friendly and he eventually got touchy with me and kept hugging me too, which confused my feelings. He even told me not to leave at some point and said he would have asked me to stay all night if he was living alone.
I went home confused by the whole thing, i didnt text him again. Two days later, i saw him at our lectures and his whole demeanor changed and he lashed out on me unprovoked, telling me to leave him alone and never to speak to him again. I texted him asking what i did wrong and he said even more horrible, nasty things to me. Like he never liked me, im forcing myself onto him, that i bring poison to his life and many more horrible things and then he unfriended me. I was so hurt and confused. I feel like he shouldn't have invited me to his home, tore apart my character and personality, told me that life is peaceful for everyone without me, then got all touchy with me,just to discard me again two days later and say horrible things again…
I already suffer from depression, anxiety and ptsd and this is just pushing me over the edge. What do you think happened? Because im so confused and how should i deal with this?