I have an issue with one of my classes. It has many bools in it, and the functions in said class have to handle many different paths based on these values. All of these paths make the code very bloated and hard to read. I was wondering if there was a design pattern or some principle rule I could follow to made the code run the same but easier to understand and read.
To be more specific, the class is called Actor. It is for a video game that I'm helping with. The Actor class manages the hands of a humanoid in the game. The hands work together in some actions and operate independently in others. So there are a massive amount of Boolean variables to check what each of them are doing. This is all in the update loop (somewhere) and I think this functionality should be moved or simplified somehow. I think there are about 20 different bool values, with more on the way.
Also, I know my post is game dev related, but I feel the question is a general one.
So are there any ways to fix / help this?
Edit:
I'll explain more. Say you have 4 bools: isAttacking, isDefending, isCasting, isDrugged.
So you have to check each hand if it is busy and handle the the paths like: Player tries to attack with a two handed weapon ->
if not isDefending and not isCasting then isAttacking = true, if isDrugged then attack with value 1 else 5.
It just gets complicated quickly and when you factor in more bools it gets very complex. So what I'm saying is: I'm lazy is there a better way to do this?