Skip to content

Game.Net.AreaLane

Assembly: Assembly-CSharp
Namespace: Game.Net

Type: struct

Base: System.ValueType, IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents a lane definition inside an "area" network structure. The struct stores four integer node indices (Unity.Mathematics.int4) that describe the lane's node references. It is an ECS component (IComponentData) and supports serialization via ISerializable for save/load and network operations.


Fields

  • public Unity.Mathematics.int4 m_Nodes Holds up to four node indices that make up the lane. Typically each element is an index/ID referencing a node in the area's node buffer. Uses Unity.Mathematics.int4 for compact storage and SIMD-friendly operations.

Properties

  • This type defines no properties. It exposes its data directly via the public field m_Nodes.

Constructors

  • public AreaLane()
    Structs have a default parameterless constructor. Initialize m_Nodes explicitly when creating instances to avoid default-zeroed values if that is not desired.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the m_Nodes field using the provided writer. Intended for saving or transmitting the component data. The writer is from Colossal.Serialization.Entities and must support writing Unity.Mathematics.int4.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes m_Nodes from the provided reader. Restores the lane's node indices during load/receive operations.

Usage Example

// Example: creating and storing an AreaLane as an ECS component
using Unity.Entities;
using Unity.Mathematics;
using Game.Net;

public class AreaLaneExample
{
    public void AddAreaLane(EntityManager entityManager, Entity entity)
    {
        var lane = new AreaLane
        {
            m_Nodes = new int4(100, 101, 102, 103) // node indices
        };

        // Add or set the component on an entity
        if (!entityManager.HasComponent<AreaLane>(entity))
            entityManager.AddComponentData(entity, lane);
        else
            entityManager.SetComponentData(entity, lane);
    }

    // Example: serialize to a generic writer
    public void SaveLane<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
    {
        var lane = new AreaLane { m_Nodes = new int4(1, 2, 3, 4) };
        lane.Serialize(writer);
    }

    // Example: deserialize from a generic reader
    public void LoadLane<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
    {
        var lane = new AreaLane();
        lane.Deserialize(reader);
        // use lane.m_Nodes as needed
    }
}