Interface IGhostSerializer
Interface that expose a raw, unsafe interface to copy all the component ghost fields to the snapshot buffer. It is mostly for internal use by code-gen and should not be used direcly nor implemented by user code.
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
public interface IGhostSerializer
Properties
ChangeMaskSizeInBits
The number of bits necessary for change mask
Declaration
int ChangeMaskSizeInBits { get; }
Property Value
Type | Description |
---|---|
int |
HasGhostFields
True if the serialized component has some serialized fields.
Declaration
bool HasGhostFields { get; }
Property Value
Type | Description |
---|---|
bool |
SizeInSnapshot
The size of the serialized data in the snapshot buffer.
Declaration
int SizeInSnapshot { get; }
Property Value
Type | Description |
---|---|
int |
Methods
CalculateChangeMask(IntPtr, IntPtr, IntPtr, int)
Compute the change mask for the snapshot in respect to the given baseline
Declaration
void CalculateChangeMask(IntPtr snapshot, IntPtr baseline, IntPtr changeMaskData, int startOffset)
Parameters
Type | Name | Description |
---|---|---|
Int |
snapshot | Snapshot pointer |
Int |
baseline | Snapshot baseline |
Int |
changeMaskData | Change mask data |
int | startOffset | Start offset |
CopyFromSnapshot(in GhostDeserializerState, IntPtr, float, float, IntPtr, IntPtr)
Copy/Convert the snapshot to component. Perform interpolation if necessary.
Declaration
void CopyFromSnapshot(in GhostDeserializerState serializerState, IntPtr component, float snapshotInterpolationFactor, float snapshotInterpolationFactorRaw, IntPtr snapshotBefore, IntPtr snapshotAfter)
Parameters
Type | Name | Description |
---|---|---|
Ghost |
serializerState | Serializer state |
Int |
component | Component |
float | snapshotInterpolationFactor | Interpolation factor |
float | snapshotInterpolationFactorRaw | Interpolation factor |
Int |
snapshotBefore | Snapshot before |
Int |
snapshotAfter | Snapshot after |
CopyToSnapshot(in GhostSerializerState, IntPtr, IntPtr)
Copy/Convert the component data to the snapshot.
Declaration
void CopyToSnapshot(in GhostSerializerState serializerState, IntPtr snapshot, IntPtr component)
Parameters
Type | Name | Description |
---|---|---|
Ghost |
serializerState | Serializer state |
Int |
snapshot | Snapshot pointer |
Int |
component | Component |
Deserialize(ref DataStreamReader, in StreamCompressionModel, IntPtr, int, IntPtr, IntPtr)
Read the data from the reader
stream into the snapshot data.
Declaration
void Deserialize(ref DataStreamReader reader, in StreamCompressionModel compressionModel, IntPtr changeMask, int startOffset, IntPtr snapshot, IntPtr baseline)
Parameters
Type | Name | Description |
---|---|---|
Data |
reader | Data stream reader |
Stream |
compressionModel | compression model |
Int |
changeMask | change mask |
int | startOffset | start offset |
Int |
snapshot | Snapshot pointer |
Int |
baseline | Snapshot baseline |
PredictDelta(IntPtr, IntPtr, IntPtr, ref GhostDeltaPredictor)
Calculate the predicted snapshot from the two baseline
Declaration
void PredictDelta(IntPtr snapshotData, IntPtr baseline1Data, IntPtr baseline2Data, ref GhostDeltaPredictor predictor)
Parameters
Type | Name | Description |
---|---|---|
Int |
snapshotData | Predicted snapshot data |
Int |
baseline1Data | Snapshot baseline |
Int |
baseline2Data | Snapshot baseline |
Ghost |
predictor | Delta predictor |
ReportPredictionErrors(IntPtr, IntPtr, IntPtr, int)
Calculate the prediction error for this component.
Declaration
void ReportPredictionErrors(IntPtr component, IntPtr backup, IntPtr errorsList, int errorsCount)
Parameters
Type | Name | Description |
---|---|---|
Int |
component | Component |
Int |
backup | Backup buffer |
Int |
errorsList | Error list pointer |
int | errorsCount | Number of errors |
RestoreFromBackup(IntPtr, IntPtr)
Restore the component data from the prediction backup buffer. Only serialised fields are restored.
Declaration
void RestoreFromBackup(IntPtr component, IntPtr backup)
Parameters
Serialize(IntPtr, IntPtr, IntPtr, int, ref DataStreamWriter, in StreamCompressionModel)
Serialise the snapshot dato to the writer
based on the calculated changemask.
Expecte the changemask bits be all already set.
Declaration
void Serialize(IntPtr snapshot, IntPtr baseline, IntPtr changeMaskData, int startOffset, ref DataStreamWriter writer, in StreamCompressionModel compressionModel)
Parameters
Type | Name | Description |
---|---|---|
Int |
snapshot | Snapshot pointer |
Int |
baseline | Snapshot baseline |
Int |
changeMaskData | Change mask data |
int | startOffset | start offset |
Data |
writer | data stream writer |
Stream |
compressionModel | comrpession model |
SerializeCombined(IntPtr, IntPtr, IntPtr, int, ref DataStreamWriter, in StreamCompressionModel)
Serialise the snapshot data to the writer
and calculate the current changemask.
Declaration
void SerializeCombined(IntPtr snapshot, IntPtr baseline, IntPtr changeMaskData, int startOffset, ref DataStreamWriter writer, in StreamCompressionModel compressionModel)
Parameters
Type | Name | Description |
---|---|---|
Int |
snapshot | Snapshot pointer |
Int |
baseline | Snapshot baseline |
Int |
changeMaskData | Change mask data |
int | startOffset | Start offset |
Data |
writer | Datastream writer |
Stream |
compressionModel | Compression model |
SerializeWithPredictedBaseline(IntPtr, IntPtr, IntPtr, IntPtr, ref GhostDeltaPredictor, IntPtr, int, ref DataStreamWriter, in StreamCompressionModel)
Serialise the snapshot dato to the writer
and calculate the current changemask.
Declaration
void SerializeWithPredictedBaseline(IntPtr snapshot, IntPtr baseline0, IntPtr baseline1, IntPtr baseline2, ref GhostDeltaPredictor predictor, IntPtr changeMaskData, int startOffset, ref DataStreamWriter writer, in StreamCompressionModel compressionModel)
Parameters
Type | Name | Description |
---|---|---|
Int |
snapshot | Snapshot pointer |
Int |
baseline0 | Snapshot baseline |
Int |
baseline1 | Snapshot baseline |
Int |
baseline2 | Snapshot baseline |
Ghost |
predictor | Delta predicot |
Int |
changeMaskData | Change mask data |
int | startOffset | Start offset |
Data |
writer | Datastream writer |
Stream |
compressionModel | Compression model |