I am currently building a turn-based framework (Unity,C#)
I was tired of my former tight-coupled systems and opted for a state machine this time, basically all components subscribe to the state-Enter and state-Exit event. I am aiming for scalability and structure.
But I ran into a problem. If the components cannot communicate directly, how to store and forward data in between states?
Example: The game starts with unit placement. The player has the option to select a unit in his pool via the ui and place it on the board. The Unit-creation logic is and should(?) be handled inside the level script. How does it know where to create which unit? Ive done a workaround with a static container class, with is basically my clipboard. The player assigns a grid cell for his selected unit and the game leaves the state. While leaving the state the level scripts scans the clipboard and creates any assigned units.
But I feel like a cheated my attempt to really work strictly within a firm structure this time to guide the design process.
Is there a better way?