Struct GhostSpawnBuffer
The GhostSpawnBuffer is the data for a GhostSpawnQueue singleton. It contains a list of ghosts which will be spawned by the GhostSpawnSystem at the beginning of next frame. It is populated by the GhostReceiveSystem and there needs to be a classification system updating after the GhostReceiveSystem which sets the SpawnType so the spawn system knows how to spawn the ghost. A classification system should only modify the SpawnType and PredictedSpawnEntity fields of this struct. InternalBufferCapacity allocated to almost max out chunk memory.
Implements
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
[InternalBufferCapacity(240)]
public struct GhostSpawnBuffer : IBufferElementData
Fields
DataOffset
Offset im bytes used to retrieve from the temporary SnapshotDataBuffer, present on the GhostSpawnQueue singleton, the first received snapshot from the server.
Declaration
public int DataOffset
Field Value
Type | Description |
---|---|
int |
DynamicDataSize
The size of the initial dynamic buffers data associated with the entity.
Declaration
public uint DynamicDataSize
Field Value
Type | Description |
---|---|
uint |
GhostID
The ghost id that will be assigned to the new ghost instance.
Declaration
public int GhostID
Field Value
Type | Description |
---|---|
int |
GhostType
The index of the ghost type in the GhostCollectionPrefab collection. Used to classify the ghost (GhostSpawnClassificationSystem).
Declaration
public int GhostType
Field Value
Type | Description |
---|---|
int |
PredictedSpawnEntity
Entity reference assigned by a classification system, when a predicted spawned entity for a newly received ghost is found. When assigning this HasClassifiedPredictedSpawn should also be set to true. If the referenced entity is different than Unity.Entities.Entity.Null the ghost type must be set to Predicted.
Declaration
public Entity PredictedSpawnEntity
Field Value
Type | Description |
---|---|
Entity |
ServerSpawnTick
The tick this ghost was spawned on the server. For any predicted spawning this is the tick that should match since you are interested in when the server spawned the ghost, not when the server first sent the ghost to the client. Using this also means you are not considering ghosts becoming relevant as spawning.
Declaration
public NetworkTick ServerSpawnTick
Field Value
Type | Description |
---|---|
NetworkTick |
SpawnType
The type of ghost to spawn. Based on the spawn type, some components may be enable/disabled or removed from the instantiated ghost.
Declaration
public GhostSpawnBuffer.Type SpawnType
Field Value
Type | Description |
---|---|
GhostSpawnBuffer.Type |
Properties
HasClassifiedPredictedSpawn
Should be set to true when a ghost classification system has processed this particular ghost spawn instance. It will then not be processed again in a system running later in the frame (like the default classification system).
Declaration
public bool HasClassifiedPredictedSpawn { get; set; }
Property Value
Type | Description |
---|---|
bool |