Game.Prefabs.ParkingLaneData
Assembly:
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents parking-lane configuration data used by the game's ECS. Contains geometry and placement parameters for individual parking slots (size, angle, spacing, and allowed vehicle length) and the set of road types the parking lane applies to. Implements ISerializable to read/write its fields to the game's network/serialization system and IComponentData so it can be attached to entities in the DOTS/ECS world.
Fields
-
public float2 m_SlotSize
Size of a single parking slot. This is a float2 (width, length) in the game's world units. -
public float m_SlotAngle
Orientation angle of each parking slot. This uses Unity.Mathematics types (angles are typically represented in radians in Unity.Mathematics-based code). -
public float m_SlotInterval
Spacing/interval between consecutive parking slots along the lane. -
public float m_MaxCarLength
Maximum car length that the slot is intended to accommodate. -
public RoadTypes m_RoadTypes
Bitmask/enum indicating which RoadTypes this parking lane applies to. Serialized as a byte.
Properties
- None (the struct exposes fields directly; there are no C# properties defined).
Constructors
public ParkingLaneData()
Structs in C# have an implicit parameterless default constructor that leaves fields uninitialized to their default values. Typical usage is to create an instance and then assign fields explicitly before use or serialization.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the struct fields to the provided writer in the following order:- m_SlotSize (float2)
- m_SlotAngle (float)
- m_SlotInterval (float)
- m_MaxCarLength (float)
- m_RoadTypes (written as a single byte)
This method is used by the Colossal/Net serialization stack to send/persist parking-lane data.
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads fields from the provided reader in the same order they are written. The deserialization contains a compatibility check:- If reader.context.version >= Version.roadPatchImprovements, the next byte is read and cast to RoadTypes.
- Otherwise (older versions), m_RoadTypes is set to RoadTypes.Car by default.
This ensures backward compatibility with save/network data that predates the addition of the RoadTypes field.
Usage Example
// Example: creating and populating a ParkingLaneData instance
var parking = new ParkingLaneData
{
m_SlotSize = new float2(2.4f, 5.0f), // width x length in game units
m_SlotAngle = 0f, // 0 radians (aligned with lane)
m_SlotInterval = 6.0f, // spacing between slot starts
m_MaxCarLength = 4.8f, // allow cars up to this length
m_RoadTypes = RoadTypes.Car | RoadTypes.Bus // example bitmask
};
// Serialization (pseudo-code; depends on the game's writer implementation)
using (var writer = GetWriterForNetworkOrSave())
{
parking.Serialize(writer);
}
// Deserialization (pseudo-code; depends on the game's reader implementation)
var parkingLoaded = new ParkingLaneData();
using (var reader = GetReaderFromNetworkOrSave())
{
parkingLoaded.Deserialize(reader);
}
{{ Additional notes: - Because ParkingLaneData implements IComponentData and IQueryTypeParameter, it is intended to be attached to ECS entities and used in queries/systems. - The Serialize/Deserialize contract must be kept in sync; changing order or type of fields will break compatibility unless handled carefully with version checks. - RoadTypes is stored as a byte on the wire; if you extend RoadTypes to contain more values, ensure compatibility with the serialization size. }}