User Tools

Site Tools


ipacketserializationservice

This is an old revision of the document!


IPacketSerializationService

This service is responsible for serializing Entities into EntityPackets and applying EntityPacket data back onto existing Entities. Component state is serialized through the packet serialization strategy associated with each supported Component type. Only Components that have a registered serialization strategy are serialized; Components without a corresponding strategy are ignored and do not contribute data to the EntityPacket.

Component packets may be serialized using either encoded packet identifiers or packet type names. Encoded packets reduce serialized size by replacing type names with numeric identifiers, but depend on the packet registration ordering remaining compatible between serialization and deserialization. Non-encoded packets use packet type names and are therefore more robust when packet types are added or changed.

Methods

Method EntityPacket SerializeEntityPacket(IEntity entity, bool encodeComponentPackets, params Type[] componentTypes)
Description Serializes specified IEntity into an EntityPacket. If componentTypes are supplied, only supported Components matching those Types are considered for serialization. If no component Types are supplied, all Components on the Entity are considered. In either case, a Component is only serialized if a packet serialization strategy exists for its Type; Components without a serialization strategy are ignored. The Entity's static data ID is stored in the packet, together with its identifier if it contains an IEntityIdentifierComponent; otherwise the packet identifier is set to zero. If encodeComponentPackets is true, Component packet types are stored using numeric identifiers instead of their type names.
Method bool DeserializeEntityPacket(EntityPacket entityPacket, IEntity entity, bool containsEncodedPackets)
Description Deserializes the Component packets contained in specified EntityPacket onto specified IEntity. The containsEncodedPackets value must match the encoding mode used when the packet was serialized. Component packets whose packet type cannot be resolved or whose corresponding Component does not exist on the Entity are ignored. Returns false if a Component serialization strategy fails to deserialize its packet; otherwise returns true. An EntityPacket containing no Component packets is considered successfully deserialized.
ipacketserializationservice.1786778256.txt.gz · Last modified: by diviner

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki