Game.Vehicles.WatercraftNavigationLane
Assembly:
Game (assembly inferred from file path; adjust if different in your project)
Namespace:
Game.Vehicles
Type:
struct
Base:
IBufferElementData, ISerializable
Summary:
WatercraftNavigationLane is a buffer-element data structure used by the ECS (Unity.Entities) to represent a navigation lane reference for watercraft. It stores an Entity reference to the lane, a 2D curve position (Unity.Mathematics.float2) used for navigation calculations, and a bitflag field (WatercraftLaneFlags) describing lane properties. The struct is marked with [InternalBufferCapacity(8)], giving buffer instances a default inline capacity of 8 elements before additional memory is allocated. The struct implements a simple binary serialization/deserialization scheme via ISerializable.
Fields
-
public Entity m_Lane
Holds an Entity reference to the lane this navigation entry refers to. Serialized/deserialized directly as an Entity. -
public float2 m_CurvePosition
A float2 (X,Y) representing the position on the lane's curve used for navigation/pathing for the watercraft. Serialized/deserialized using the writer/reader's float2 handling. -
public WatercraftLaneFlags m_Flags
Bitflags describing lane properties (type, direction, special markers, etc.). Serialized as an unsigned integer and cast back to the enum during deserialization.
Properties
- This type does not define any C# properties. It exposes plain public fields only.
Constructors
public WatercraftNavigationLane()
Default value-type constructor (implicitly provided). Creates a struct with default/zeroed values:- m_Lane = Entity.Null (or default Entity)
- m_CurvePosition = float2(0f, 0f)
- m_Flags = default(WatercraftLaneFlags)
You can create an initialized instance with an object initializer to set fields explicitly.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the struct contents into the provided writer in the following order:- m_Lane (Entity)
- m_CurvePosition (float2)
- m_Flags (written as uint)
The method uses a local copy for each field before calling writer.Write.
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the struct contents from the provided reader and assigns them to this instance in the expected order:- Reads an Entity into m_Lane
- Reads a float2 into m_CurvePosition
- Reads a uint and casts to WatercraftLaneFlags for m_Flags
The method reads directly into the fields by reference.
Notes: - The serialization uses an explicit cast for the enum (m_Flags) => written as uint and reconstructed by casting back to the enum type during deserialization. This keeps the serialized representation compact and version-stable as an integer. - Because this is a buffer element (IBufferElementData), instances are intended to be stored in dynamic buffers attached to entities in the ECS world.
Usage Example
// Creating and initializing a buffer element
var navEntry = new WatercraftNavigationLane {
m_Lane = someLaneEntity,
m_CurvePosition = new float2(12.34f, 56.78f),
m_Flags = WatercraftLaneFlags.None
};
// Adding to an entity's dynamic buffer (example usage in Unity.Entities context)
var buffer = entityManager.GetBuffer<WatercraftNavigationLane>(navOwnerEntity);
buffer.Add(navEntry);
// Serializing an instance with a writer that implements IWriter
navEntry.Serialize(writer);
// Deserializing into an instance with a reader that implements IReader
var readEntry = new WatercraftNavigationLane();
readEntry.Deserialize(reader);
Additional implementation notes: - Ensure the reader/writer implementations used match the serialization order and types above. - The [InternalBufferCapacity(8)] attribute is a hint for Unity's buffer implementation and affects memory layout/performance; pick an appropriate capacity depending on typical per-entity lane counts.