Our game engine will be built in a system similar to Unity, making use of two key objects: GameObjects, and Components (or classes that inherit from the IComponent interface)
With this system, we’ll be able to define any type of behavior for our GameObjects by creating child classes of IComponent (the interface class for components). And we can also create what are essentially “Prefabs” (pre-fabricated/defined GameObjects with given characteristics) by making child classes of GameObjects, and adding in components that we defined.
The components of GameObjects should communicate with each other directly by reference. For example, a Poison : IComponent would directly update the health
attribute Health : IComponent of a Entity : NetworkObject.
NetworkObjects (: GameObjects) are just GameObjects with the additional list of INetworkComponents (interface) on top of the list of IComponents, plus some additional functionality (network IDs and some additional methods like serialization/deserialization). And these INetworkComponents (: IComponent) are just IComponents with the additional features of serialization/deserialization.
These will be used in a similar fashion to GameObjects and Components, but obviously, they’ll be sending data to and from the server, or on the server end, to and from the client. When implemented, the serialization/deserialization methods of the NetworkObjects should just call the serialization/deserialization methods of each of it’s NetworkComponents.
Now, not all components need to be networked. For example, client-side, the animation system as a whole is done entirely client-side, thus, so long as it is getting the correct data from other NetworkComponents (for example, position from the NetTransform networked component), then the animation system components shouldn’t need to be networked.
The first step is to understand how we want to do serialization and deserialization. There are a few key points to take note of:
To explain in more detail:
What about functions/attributes specific to one side? Just make them in the header and only implement and call them on their respective sides.