How to get the current category with custom posts

The good basic technique to go from specifics to more general context is to look at the calls you already have.

You already call single_cat_title(), which somehow knows current category, right? If you look inside you will see it passes call to single_term_title(). And how does that one in turn knows?

$term = get_queried_object();

So there is your way to get to the full category object when on category archive page.

Still it’s a little unclear from your code example what do you want to do with “all” posts. If you want to display all posts, in a context that already does appropriate query, you should be properly modifying main query via pre_get_post or such. It shouldn’t be done in template for performance and compatibility reasons.