All objects intended to be synchronized through CryNetwork should have a function called NetSerialize(). In the GameObject with the function IGameObject::NetSerialize(). This function uses a TSerialize object of type ISerialize to transform relevant data to a stream.
The serialization follow different aspects and profiles to distinguish the types of stream.
Serialized data for a given aspect and profile must remain fixed. In example, if you serialized four floats, you must always serialize four floats.
Aspects should be used to group data that logically belongs together, especially important given the constraints of compression.
Information about GameObjects is being propagated through the network by the function RequestRemoteUpdate() which takes EEntityAspects flags as a parameter to determine how the update should be performed.
The aspects are defined as follows:
Profiles allow a particular aspects fixed format data to be different. There are potentially 8 profiles per aspect. Usually they are only used for physics aspects (i.e. switching between ragdoll and living entity). Profiles requires aspect to be setup using the eAF_ServerManagedProfile flag.
The network layer takes care of compression and quantization based on the usage of Tserialize::Value. The quantization and/or compression can be controlled via a compression policy.
The different quantization and compression types are defined inside the XML file: Game/Scripts/Network/CompressionPolicy.xml
. A 4 character code will be assigned the type.
Here is an entry example:
<policy name="team" impl="RangedInt">
<params min="0" max="7" />
</policy>
The policy implementation are written in C++ and can be found within the CryNetwork project.
Here is the list of policies currently implemented:
It's possible to implement a new policy inside CryNetwork by deriving the ICompressionPolicy interface and calling the REGISTER_COMPRESSION_POLICY(class, name) macro.