Description
Currently, the way the pirates coordinate between one another is a little awkward. You have a squad leader, and different behaviors are used in the same state machine state depending on whether a pirate is a squad leader or not.
When a leader dies, this leads to situations where the state has to be 'reset' so that new behaviors are recreated, and the correct signals connected to.
Alternative ideas
- Double up states: You have leader states and squaddie states. When a new leader is selected, he transitions to the leader-version of his currently assigned state. The squaddies don't need to change - they are just waiting for a signal to switch to rest/patrol/attack.
- Overseer: Squads are built inside of a squad controller parent object. It is the squad leader, in effect, as a nebulous overseer entity over the squad. All squaddies are followers, but follow-the-leader style behaviors are configured by the overseer.
The former would be simple in implementation, while the second one could help with extension down the line or more complex behaviors if the game expands that far.
Since, ultimately, it'd be nice to have pirates that do different jobs - attackers, miners and workers, transports that go to their own station, etc - the latter will probably be more useful in the long run.