Look at BGECore Framework. The problem with this is that there is no game to actually see how things should be implemented, but you can see how things are implemented in the core so it’s something.
- State management
States are usually attributes of behaviours or other classes (that aren’t behaviours). However most of the time those are modified usung a setter instead of directly (unless it’s the instance itself tham modifies them).
- Interaction between objects
Not somthing common to see in BGECore source, but basically if you have a snipper, the snipper has a “SnipperBehaviour” (or something alike). When you pull the trigger (you check if a key is enabled and then call the method “pullTriger()” of the behavior, you do that from the scene behavior), that instance does a raycast to check if it’s colliding with anything that has an “Enemy” property, that’s on an “Enemy” list or something like that. When the raycast returns an object that meets the conditions you call the “bulletInpact(x, y, z, other arguments…)” of the AI behavior (or any other behavior that represents an human being).
- Storing
I don’t know if you meant saving data or storing the data on memory. For the first:
You basically save the attributes of all the behaviors that you consider rellevant. If you where to save everything next time you load the game it would look exactly like when you left, including if you let some menu opened where there was in item selected on the inventory. That’s usually not what you want to happen so you need to see what’s worth saving and what souldn’t be saved. Usually if there is a Player behavior, that’s worth saving, the state of a menu isn’t.
For the second, you just store object behaviors on a dictionary inside the scene behavior (should be unique for scene), and you can optionally save other behaviors inside an object behavior attribute. For example inside a Player behavior you can save a ControlFirstPerson Behavior and a PlayerAnimation behavior.
But of course this is just how I would do it, there are other ways to do good OOP in BGE.