How to Check if Array is Empty Before a ForEachLoop?

I am having an issue where I am checking the validity of a combat mode initializer where it gets all actors of class BP_Example_Enemy and if there are no more on the map it won’t tell the game that I am no longer in combat and will stay in combat mode. What essentially happens is that when it’s empty it will keep trying to iterate through the foreachloop but not progress to the first IsValid? check and what I want it to do is even if the array is empty I want it to end combat mode. What options do I have available to me? The blueprints are below:

You can do this by keeping track of all the enemies in a Game Mode.

All enemies must notify the game mode when they are relevant. An easy example is adding the enemy when it spawns and removing it when it’s killed. You must also ensure that the actors are always valid. I would personally do this by calling the Remove Enemy function when the enemy receives the End Play event.

Building your code like this lets you add enemies of any actor type to the array. Here’s what it would look like to have the enemy actors notify the game mode.