I'm rewriting my multiplayer system for a first person shooter. Reasons for doing so include moving closer to OO design patters (or at least trying not to mix with other patterns) and also to make it cleaner to use. First of all, I'm using Python and not the usual C++.
So, my first question involves entity systems. I have found few resources that relate them to Python, but they seem to be simply isolated update methods for the "entity". The pattern involves avoiding interaction (direct) between components, and using messages if necessary.
Assuming that my understanding is correct, can I ask if anyone has successfully implemented an entity system with networking for a First Person Shooter?
Following from this, here are my questions before they are extended:
- I don't like the way in which I must add endless methods to a GameObject entity to simply send its state. How would anyone recommend enabling serialisation of an object? At the moment I scrape data and pack it into bytes, but I am open to the idea of networked attributes (properties / fields). Be aware that there is a far more implied meaning of private variables than other language; for the most part they don't exist, simply name-mangled.
- How would one allow for object serialisation? In terms of collecting any data serialised? At present, I have a manager class that calls the to_bytes method of each entity (GameObject) and in turn returns a sum of the bytes. It seems a lengthy step, especially when unserialising is a similar process.
Here are my qualms about it:
At present, I use an inheritance model. This is fine, save for the following points:
- Adding any new behaviour essentially involves rewriting the inherited method
- Serialising the object still requires a dedicated method for doing so
Now, my point about serialisation is almost avoidable at present. I could add an inspection layer that deduces the attributes of the object that should be replicated, but then I am most likely better to use an entity system for the isolation it provides with the components (avoiding cluttering the Object class directly) (see here for a good example (in my opinion) of a networked ES (although for generic game models, and non-authoritative I believe) ).
Overall, I think I have too many questions than I can easily define on paper. So perhaps let me try and summarise (sort of!)
- What are the main methods for state replication? Is it advantageous to use RPC updates that invoke state changes, or just use a full state / delta encoded state system instead
- Are there any good resources other than I've mentioned on EntitySystems? Can anyone offer any insight into alternative yet relatively tolerant uses of OO that could work as a solution?
- What is the most common architecture for dealing with game state? E.g Object heirarchy, object manager, ownership of update methods, serialise methods etc.
Thank you all if you've got this far!!