When Ryan Keith Cox and his co-workers heard the gunshots, he rushed to get them to safety but sacrificed himself to try to save others.

Cox was one of 12 victims of Friday's shooting at a Virginia Beach municipal building, and one of his co-workers says the longtime public utilities worker died a hero.

Christi Dewar, also a longtime employee of the public utility department, told NPR and the Virginian-Pilot that she thought the gunshots were a nail gun at first. Then, a co-worker came rushing down the hall to tell them it was real.

"We ran to the back door of our office, which is near the south stairwell, and one of the girls screamed, 'It's too late, it's too late! Run the other way,'" Dewar told the Virginian-Pilot.

More:Virginia Beach shooting: What we know about the motive, the victims

Cox led Dewar and other co-workers into a break room and told them to stand against a wall, she told the newspaper.

"If at all possible, I knew he was going to lead us to safety. We felt safe. He stayed calm. He didn't have any anxious thought in his voice," she said.

Cox stood guard and then told the group to lock themselves into an office when it looked clear. But he wasn't staying with them.

"I said, 'Keith, come on,'" Dewar told the Virginian-Pilot. "He said, 'I've got to see if anybody else needs help.' He said, 'Barricade the door. Do it now.'"

A 'woman of God,' a Scottish music lover:These are the victims of Virginia Beach shooting

Dewar told NPR that the group then barricaded the door with file cabinets and stayed quiet. They didn't hear Cox outside the room.

Then they heard gunshots.

"Two bullets almost came through the back of the cabinet," Dewar told NPR. "We fell to the ground; then we heard other shots close to us. ... That's when he got Keith."

Dewar called 911 when the gunshots faded away. Police eventually made their way to the office where the group was hiding. One of the women opened the door and saw Cox lying on the floor, Dewar told the Virginian-Pilot.

'Officer hit! Officer hit!':How the dramatic Virginia Beach shooting unfolded

When the group was escorted out the building, Dewar said she was told not to look down.

"All I could see was just splintered wood, doors that were off their hinges just broken. It looked like a freaking war zone," she told the newspaper. She had to step over another dead co-worker's body to get out.

The day after the shooting, Dewar said she went to Cox's parents' house to tell them of their son's heroics. The two had long been friends, with Cox often driving Dewar home or giving her a hug when she was down.

"I called him my big teddy bear," Dewar told NPR. "Every time I was upset, he would give me a hug. When I was upset about something, he knew exactly what to say to make you smile. He's the type of person who you know would lay down his life for someone, just like he did."

Follow USA TODAY's Ryan Miller on Twitter @RyanW_Miller