Struct GhostComponentSerializer.State
This buffer is added to the GhostCollection singleton entity. Stores serialization meta-data for the ghost. Too large to be stored in chunk memory. Values are generated by the Source Generators.
Implements
Inherited Members
Namespace: Unity.NetCode.LowLevel.Unsafe
Assembly: Unity.NetCode.dll
Syntax
[InternalBufferCapacity(0)]
public struct GhostComponentSerializer.State : IBufferElementData
Fields
ChangeMaskBits
The number of bits necessary for the change mask.
Declaration
public int ChangeMaskBits
Field Value
Type | Description |
---|---|
int |
ComponentSize
The size of the component, as reported by the Unity.Entities.TypeManager.
Declaration
public int ComponentSize
Field Value
Type | Description |
---|---|
int |
ComponentType
The type of component this serializer act on.
Declaration
public ComponentType ComponentType
Field Value
Type | Description |
---|---|
ComponentType |
CopyFromSnapshot
Delegate method used to transfer data from the snapshot buffer to the destination component.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> CopyFromSnapshot
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> |
CopyToSnapshot
Delegate method used to transfer the component data to the snapshot buffer.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> CopyToSnapshot
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> |
Deserialize
Deserialize the component and buffer data from the received snapshot and store it inside the SnapshotDataBuffer.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.DeserializeDelegate> Deserialize
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.DeserializeDelegate> |
GhostFieldsHash
The hash of all serializer fields, along with their GhostFieldAttribute options properties. Used to calculate the NetworkProtocolVersion.
Declaration
public ulong GhostFieldsHash
Field Value
Type | Description |
---|---|
ulong |
NumPredictionErrors
The number of predicted errors that is calculated by the GhostComponentSerializer.ReportPredictionErrorsDelegate method. Can be larger then the NumPredictionErrorNames, since the name list is capped to 512 bytes.
Declaration
public int NumPredictionErrors
Field Value
Type | Description |
---|---|
int |
PostSerialize
Delegate method to use to post-serialize the component when the ghost use pre-serialization optimization.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.PostSerializeDelegate> PostSerialize
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.PostSerializeDelegate> |
PostSerializeBuffer
Delegate method to use to post-serialize buffers when the ghost use pre-serialization optimization.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.PostSerializeBufferDelegate> PostSerializeBuffer
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.PostSerializeBufferDelegate> |
PredictDelta
Calculate the prediction delta for components and buffer. Used for delta-compression.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.PredictDeltaDelegate> PredictDelta
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.PredictDeltaDelegate> |
PredictionErrorNames
String buffer, containing the list of all replicated field names. Empty for component type that can be only interpolated. (see PrefabType).
Declaration
public FixedString512Bytes PredictionErrorNames
Field Value
Type | Description |
---|---|
FixedString512Bytes |
PrefabType
Store the PrefabType if the attribute is present on the component. Otherwise is set to All. TODO - Try to deduplicate this data by reading the ComponentTypeSerializationStrategy directly.
Declaration
public GhostPrefabType PrefabType
Field Value
Type | Description |
---|---|
GhostPrefabType |
ProfilerMarker
Marker used to profile the performance of the serializer.
Declaration
public ProfilerMarker ProfilerMarker
Field Value
Type | Description |
---|---|
ProfilerMarker |
ReportPredictionErrors
Used by the GhostPredictionDebugSystem, collect and report the prediction error for all the replicated fields.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.ReportPredictionErrorsDelegate> ReportPredictionErrors
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.ReportPredictionErrorsDelegate> |
RestoreFromBackup
Delegate method used to restore the state of a replicated component from the GhostPredictionHistoryState buffer. Because the history buffer perform a memory copy of the whole component data, it is necessary to call this method to ensure only the replicated portion of the component is actually restored.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.RestoreFromBackupDelegate> RestoreFromBackup
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.RestoreFromBackupDelegate> |
SendMask
Indicates for which type of ghosts the component should be replicated. The mask is set by code-gen base on the PrefabType constraint.
Declaration
public GhostSendType SendMask
Field Value
Type | Description |
---|---|
GhostSendType |
SendToOwner
Store the OwnerSendType if the attribute is present on the component. Otherwise is set to All.
Declaration
public SendToOwnerType SendToOwner
Field Value
Type | Description |
---|---|
SendToOwnerType |
SerializationStrategyIndex
Internal. Indexer into the SerializationStrategies list.
Declaration
public short SerializationStrategyIndex
Field Value
Type | Description |
---|---|
short |
Serialize
Delegate method used to serialize the component data for the root entity into the outgoing data stream. Work in batch.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.SerializeDelegate> Serialize
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.SerializeDelegate> |
SerializeBuffer
Delegate method used to serialize the buffer content for the whole chunk. Work in batch for the whole chunk.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.SerializeBufferDelegate> SerializeBuffer
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.SerializeBufferDelegate> |
SerializeChild
Delegate method used to serialize the component data present in the child entity into the outgoing data stream. Work on a single entity at time.
Declaration
[Obsolete("The SerializeChild method has been deprecated. Please use only Serialize instead", false)]
public PortableFunctionPointer<GhostComponentSerializer.SerializeChildDelegate> SerializeChild
Field Value
Type | Description |
---|---|
PortableFunctionPointer<GhostComponentSerializer.SerializeChildDelegate> |
SerializerHash
An unique hash computed by source generator that identify the serializer type.
Declaration
public ulong SerializerHash
Field Value
Type | Description |
---|---|
ulong |
SerializesEnabledBit
True if this component has the GhostEnabledBitAttribute and thus should replicate the enable bit flag.
Declaration
public byte SerializesEnabledBit
Field Value
Type | Description |
---|---|
byte |
Remarks
Note that serializing the enabled bit is different from the main "serializer". I.e. "Empty Variants" can have serialized enable bits.
SnapshotSize
The size of the component inside the snapshot buffer.
Declaration
public int SnapshotSize
Field Value
Type | Description |
---|---|
int |
VariantHash
An hash identifying the specific variation used for this serializer (see GhostComponentVariationAttribute). If no variation is used, this will be the hash of the ComponentType itself, and IsDefaultSerializer will be true.
Declaration
public ulong VariantHash
Field Value
Type | Description |
---|---|
ulong |
VariantTypeFullNameHash
For internal use only. The hash of the ghost variation type fullname. Used mostly for validation
Declaration
public ulong VariantTypeFullNameHash
Field Value
Type | Description |
---|---|
ulong |
Properties
HasGhostFields
Whether SnapshotSize is greater than zero.
Declaration
public bool HasGhostFields { get; }
Property Value
Type | Description |
---|---|
bool |