Game.Objects.SpawnLocation
Assembly: Assembly-CSharp
Namespace: Game.Objects
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
SpawnLocation is an ECS component struct representing a spawn point in the game world. It stores references to related lane Entities, curve positions along those lanes, an optional access-restriction Entity, a group index, and spawn-location flags. The struct implements ISerializable and includes version-aware Serialize/Deserialize implementations so saved data remains compatible across game versions.
Fields
-
public Unity.Entities.Entity m_AccessRestriction
Reference Entity that encodes access restrictions for this spawn location (present when the serialized version includes pathfindAccessRestriction). May be Entity.Null when no restriction applies. -
public Unity.Entities.Entity m_ConnectedLane1
Entity reference to the primary connected lane for this spawn location. Used together with m_CurvePosition1 to locate the exact spawn point on the lane. -
public Unity.Entities.Entity m_ConnectedLane2
Entity reference to a secondary connected lane (optional) for this spawn location. Used together with m_CurvePosition2. -
public float m_CurvePosition1
Curve position (typically 0..1) along the primary connected lane where the spawn location lies. -
public float m_CurvePosition2
Curve position for the secondary connected lane. -
public int m_GroupIndex
Index indicating the group this spawn location belongs to. Present when serialized version includes spawnLocationGroup. -
public SpawnLocationFlags m_Flags
Bitmask/enum describing spawn location flags (e.g., restrictions, special behaviors). Serialized as a uint when the reader/writer version supports pathfindRestrictions.
Properties
- This struct exposes no properties; it is a plain component data struct with public fields.
Constructors
public SpawnLocation()
Default value-type constructor (compiler-generated). Initialize fields explicitly when creating instances in code.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the struct fields to the provided writer. The implementation writes the access restriction Entity, the two connected lanes, both curve positions, the group index, and the flags (flags are written as uint). The writer usage is not conditional here because callers are expected to write fields in the order matching the expected save format. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads fields from reader in a version-aware way: - If reader.context.version >= Version.pathfindAccessRestriction then m_AccessRestriction is read.
- If reader.context.version >= Version.spawnLocationRefactor then connected lanes and both curve positions are read; otherwise older format values are skipped (reads placeholder Entity and float).
- If reader.context.version >= Version.spawnLocationGroup then m_GroupIndex is read.
- If reader.context.version >= Version.pathfindRestrictions then flags are read as uint and cast to SpawnLocationFlags.
This ensures compatibility with older save formats while supporting newer fields when present.
Usage Example
// Create and initialize a spawn location
var spawn = new SpawnLocation
{
m_AccessRestriction = Entity.Null,
m_ConnectedLane1 = laneEntityA,
m_ConnectedLane2 = laneEntityB,
m_CurvePosition1 = 0.25f,
m_CurvePosition2 = 0.75f,
m_GroupIndex = 1,
m_Flags = SpawnLocationFlags.None
};
// Example: serialize using an IWriter implementation
// (IWriter is provided by the game's serialization system)
public void SaveSpawn<TWriter>(TWriter writer, SpawnLocation s) where TWriter : IWriter
{
s.Serialize(writer);
}
// Example: deserialize using an IReader implementation
public SpawnLocation LoadSpawn<TReader>(TReader reader) where TReader : IReader
{
var s = new SpawnLocation();
s.Deserialize(reader);
return s;
}