All of the above is true and YET every check and balance of society from school,mental health and especially law enforcement allowed this to happen. Even during the actual incident the security/police were epic failures.
His mental health: All adults who knew that the shooter was mentally ill should have done more to prevent him from having a weapon- his mother, her friends, their neighbors, the teachers who knew of his gun collection.
He was diagnosed with: Autism, OCD, ADHD, depression and compulsive defiant disorder. There may have been more issues that was missed, like FAS or other disorders.
From the mosaic of public records, interviews with friends, neighbors, family and online interactions, it appears that Cruz was unstable and violent to himself and those around him and that when notified about his threatening behaviour, law enforcement did nothing to stop it.