Using passive states is probably the best way to go for most circumstances. There are a couple of reasons why I went with states that aren't removed by death as my usual method. Firstly, although I thought it unlikely that I would ever want an actor to change sex mid game, if I did decide to do so, it would be easy to change the actor's gender state.
Secondly, I experimented with having a small number of actors but letting the player select a face (which determines both body and gender), class, and input a name for each party member. For passive states to act as passive states (not be removed by either death or "Recover All"), they have to be assigned by a notetag, or by a notetag of the gender plugin, not during the early stages of play.
You may have realised that I don't like using the "Recover All" command in sleep. There are other states (such as "Poison", "Disease", and "Horny") that I don't want removed by sleep.
You want characters to change sex in the middle of the game? Do you mean sex or gender? If they get a sex change, it means they lose their peepee and get a vayvay, or lose their vayvay for a peepee. A gender change is simply the person identifying as the other sex.
The thing is, if it is going to be a gender change, then not much would change to the characters stats, right? Only the presentation would change (speaking from a dev's POV). You could just change the name and images of that actor.
If it is a sex, then it is in my eyes the best option to just remove the old-sex character, and replace it with the new-sex character.
Like when a man becomes a women, then when you make the sex-change happen, you remove the male character (with the male state and all) and replace it with a similar looking female character (with female state at all).
This has other additional features. Lets say you have a Bruce how later on becomes Caitlyn, you can have a condition in an event checking: "Is Bruce in party" to know it is still a man, or "Is Caitlyn in party" to find out it is after the sex change. It also instantly makes Caitlyn be able to wear after-sex-change-clothing, while Bruce wears his pre-operation-suit. (Like Bruce might wear lumberjack vests, while Caitlyn wears a flower dress and heals.)
I think, replacing the character with a new character during a sex change has 10x as many upsides as trying to change everything about the original character during a sex change.
And somehow it even makes sense: Bruce would be considered dead and Caitlyn would start a new life as a new person.
And I assume this would be only 1 character in the game, that changes their sex, right? If it was more characters, then this might be a hassle... but if you have more characters change their sex in a single story, then it either is a story about sex change, or else it is too many sex changes.
😛 I try to say: If it is not the focus of the game, then don't make it a common thing. 1 sex-change in a game is already woke. And more realistic. A sex-change operation isn't really that common.
---
However... If you still really want your genders to be variable, then instead of binding the states to an actor, bind it to equipment. Lock that equipment (in slots specially made for sex/genders) with the equipcore, also by yanfly.
Simply make a slot called Gender (instead of Weapon, Head, Chest, etc.)
Make equipment for each gender, and bind the state to that equipment. Note that this doesn't have to look like equipment to the player.
Make sure each actor has a gender equiped at the start. Those are locked with EquipCore, so the player can't unequip it. However, you as dev can use event commands to change that equipment, simply changing a man into a woman, or a woman into a man.
If you do it like this, don't forget the unequipped sex/gender to be removed from players inventory right after the sex change. It would seem real weird to the player if they suddenly find a female in their equipment.
😛