Class IEntitySerialiser

Class Documentation

class IEntitySerialiser

The serialiser is responsible for converting a SpaceEntity instance into a data structure that both SignalR and our servers can understand and use.

To use the serialiser, Start with BeginEntity(), then use the write(bool, int, etc) functions to write data at the Entity level. Use BeginComponents() to start writing as the Server component data, with each BeginComponent and EndComponent brace dictating information written into a server component. Within a component, use WriteProperty() to write the individual data. Ensure you finish by closing out the relevant sections with the ‘End’ functions.

Public Functions

virtual void BeginEntity() = 0

Start the serialisiation.

virtual void EndEntity() = 0

End the serialisiation.

virtual void WriteBool(bool Value) = 0

Write a boolean field of the entity.

Parameters

Value – bool : The value to write.

virtual void WriteByte(uint8_t Value) = 0

Write a byte field of the entity.

Parameters

Value – uint8_t : The value to write.

virtual void WriteDouble(double Value) = 0

Write a double field of the entity.

Parameters

Value – double : The value to write.

virtual void WriteInt64(int64_t Value) = 0

Write an int64_t field of the entity.

Parameters

Value – int64_t : The value to write.

virtual void WriteUInt64(uint64_t Value) = 0

Write a uint64_t field of the entity.

Parameters

Value – uint64_t : The value to write.

virtual void WriteString(const csp::common::String &Value) = 0

Write a string field of the entity.

Parameters

Valuecsp::common::String : The value to write.

virtual void WriteNull() = 0

Write a null field of the entity.

virtual void BeginArray() = 0

Start an array section.

virtual void EndArray() = 0

Finish an array section.

virtual void BeginComponents() = 0

Start the components section.

virtual void EndComponents() = 0

Finish the components section.

virtual void BeginComponent(uint16_t Id, uint64_t Type) = 0

Begin writing component with the given ID and type.

Parameters

Id – uint16_t : The ID of the component.

virtual void EndComponent() = 0

Finish a component section.

virtual void WriteProperty(uint64_t Id, const ReplicatedValue &Value) = 0

Write the given component property.

Parameters
  • Id – uint64_t : ID of the component property.

  • ValueReplicatedValue : The value to be written.

virtual void AddViewComponent(uint16_t Id, const ReplicatedValue &Value) = 0

Specific handler for writing view components.

View Components are data that is stored in specific keys on the server, it allows us to discretely update these singular data pieces, rather than replicating larger chunks of data, and also allows us to always know where in a data structure this data will be.

Parameters
  • Id – uint16_t : The ID of the component

  • ValueReplicatedValue : The value of the component data to add

Protected Functions

virtual ~IEntitySerialiser() = default