Skip to content

Game.EdgeColor

Assembly: Game
Namespace: Game.Net

Type: public struct

Base: System.ValueType, implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.IEmptySerializable

Summary: EdgeColor is a small value-type ECS component used to store compact color-related data for network edges (e.g., road/track segments) in Cities: Skylines 2. The struct holds three byte fields: an index and two value bytes. It implements IComponentData so it can be attached to entities, IQueryTypeParameter to be usable in ECS queries, and IEmptySerializable to participate in Colossal's serialization pipeline.


Fields

  • public byte m_Index
    Used to store an index or identifier for the edge color entry (e.g., palette index or variant id). Interpreted by game systems that read EdgeColor components.

  • public byte m_Value0
    A compact byte value storing color-related data (channel, variant, or other small numeric state). Exact meaning is determined by the consuming rendering or net logic.

  • public byte m_Value1
    A second compact byte value storing color-related data (channel, variant, or other small numeric state). Like m_Value0, semantics depend on the systems that consume this component.

Properties

  • This struct does not declare any C# properties.

Constructors

  • public EdgeColor(byte index, byte value0, byte value1)
    Initializes all three fields. Use this to create and assign the component in code or when adding to an entity.

Methods

  • This struct does not declare any methods.

Usage Example

// Create an EdgeColor instance and assign it to an existing entity (EntityManager-based example)
var edgeColor = new EdgeColor(index: 1, value0: 128, value1: 255);
entityManager.SetComponentData(edgeEntity, edgeColor);

// Add the component to a newly created entity
var newEntity = entityManager.CreateEntity();
entityManager.AddComponentData(newEntity, new EdgeColor(0, 64, 64));

// In a SystemBase/ISystem use a query to read or modify EdgeColor components
Entities
    .ForEach((ref EdgeColor ec) =>
    {
        // Example: modify channels
        ec.m_Value0 = (byte)((ec.m_Value0 + 1) & 0xFF);
    })
    .Schedule();

Notes: - Because EdgeColor is an IComponentData, prefer using EntityManager or ECS systems to add/read/modify it. - IEmptySerializable is a marker used by Colossal's serialization system; the precise persistence/replication behavior depends on the game's serialization conventions.