Class CustomGhostSerializerHelpers
Contains helper methods to write custom chunk serializers.
See Ghost
Inherited Members
Namespace: Unity.NetCode .LowLevel .Unsafe
Assembly: Unity.NetCode.dll
Syntax
public static class CustomGhostSerializerHelpers
Methods
CopyBufferToSnapshot<T>(T, ArchetypeChunk, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int, ref int)
Copy all buffers in the chunk for a given Dynamic
Declaration
public static void CopyBufferToSnapshot<T>(this T serializer, ArchetypeChunk chunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset, ref int dynamicSnapshotDataOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the serializer to use |
Archetype |
chunk | the chunk to copy |
Ghost |
context | the serialization context |
Dynamic |
typeHandles | the component type handles |
Ghost |
index | the Ghost |
Int |
snapshotData | the snapshot buffer |
int | snapshotOffset | the start offset from the beginning of the snapshot buffer |
int | dynamicSnapshotDataOffset | the offset in the dynamic snapshot data buffer where the buffer data is stored |
Type Parameters
Name | Description |
---|---|
T | the buffer type |
CopyChildBufferToSnapshot<T>(T, ArchetypeChunk, int, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int, ref int)
Copy a single buffer on a child entity for a given Dynamic
Declaration
public static void CopyChildBufferToSnapshot<T>(this T serializer, ArchetypeChunk chunk, int indexInChunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset, ref int dynamicSnapshotOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the serializer to use |
Archetype |
chunk | the chunk to copy |
int | indexInChunk | the index in the chunk |
Ghost |
context | the serialization context |
Dynamic |
typeHandles | the component type handles |
Ghost |
index | the Ghost |
Int |
snapshotData | the snapshot buffer |
int | snapshotOffset | the start offset from the beginning of the snapshot buffer |
int | dynamicSnapshotOffset | the offset in the dynamic snapshot data buffer where the buffer data is stored |
Type Parameters
Name | Description |
---|---|
T | the buffer type |
CopyChildComponentToSnapshot<T>(T, ArchetypeChunk, int, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int)
Copy a single component data for a child component to the snapshot buffer.
Declaration
public static void CopyChildComponentToSnapshot<T>(this T serializer, ArchetypeChunk chunk, int indexInChunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the serializer to use |
Archetype |
chunk | the chunk to copy |
int | indexInChunk | the index in the chunk |
Ghost |
context | the serialization context |
Dynamic |
typeHandles | the component type handles |
Ghost |
index | the Ghost |
Int |
snapshotData | the snapshot buffer |
int | snapshotOffset | the start offset from the beginning of the snapshot buffer |
Type Parameters
Name | Description |
---|---|
T | the component type |
CopyComponentToSnapshot<T>(T, ArchetypeChunk, ref Context, DynamicComponentTypeHandle*, in GhostCollectionComponentIndex, IntPtr, ref int)
Copy the component data to the snapshot buffer for the whole chunk starting from
index start
Declaration
public static void CopyComponentToSnapshot<T>(this T serializer, ArchetypeChunk chunk, ref GhostPrefabCustomSerializer.Context context, DynamicComponentTypeHandle* typeHandles, in GhostCollectionComponentIndex index, IntPtr snapshotData, ref int snapshotOffset) where T : unmanaged, IGhostSerializer
Parameters
Type | Name | Description |
---|---|---|
T | serializer | the current serializer to use |
Archetype |
chunk | the chunk |
Ghost |
context | the serialization context |
Dynamic |
typeHandles | the component typehandles |
Ghost |
index | the Ghost |
Int |
snapshotData | the snapshot buffer data store |
int | snapshotOffset | the offset in bytes where the component data should be stored |
Type Parameters
Name | Description |
---|---|
T | the unmanaged component type |
CopyEnableBits(ArchetypeChunk, int, int, int, ref DynamicComponentTypeHandle, byte*, ref int)
Copy all the enable bits state for the given Dynamic
Declaration
public static void CopyEnableBits(ArchetypeChunk chunk, int startIndex, int endIndex, int snapshotStride, ref DynamicComponentTypeHandle componentTypeHandle, byte* enableMasks, ref int maskOffset)
Parameters
Type | Name | Description |
---|---|---|
Archetype |
chunk | the chunk |
int | startIndex | the start entity index |
int | endIndex | the end entity index (not inclusive) |
int | snapshotStride | the stride in bytes (the size) of the snapshot data for the given archretype |
Dynamic |
componentTypeHandle | the component type handle to extrac |
byte* | enableMasks | the snapshot enable bit mask array |
int | maskOffset | the offset in bits in the array |