Skip to content

Game.Prefabs.TrafficSignData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType

Summary:
TrafficSignData is an ECS component (IComponentData) used to represent traffic sign information on an entity: a bitmask encoding the sign type(s) and an integer speed limit value. It also implements IQueryTypeParameter to allow use as a parameterized query type in Unity's ECS query APIs. The m_TypeMask uses a bit position mapping determined by the TrafficSignType enum; use the provided GetTypeMask helper to produce the correct mask for a given TrafficSignType.


Fields

  • public uint m_TypeMask
    Holds a bitmask representing one or more traffic sign types. Use TrafficSignData.GetTypeMask(type) to generate the mask for a single type; masks for multiple types can be combined with bitwise OR.

  • public int m_SpeedLimit
    Integer value for the posted speed limit associated with the sign (units depend on game conventions, typically km/h). Only meaningful for sign types that convey a speed limit.

Properties

  • This struct declares no properties.

Constructors

  • public TrafficSignData()
    Implicit default value-type constructor is available. Typical instantiation is with an object initializer: var data = new TrafficSignData { m_TypeMask = TrafficSignData.GetTypeMask(TrafficSignType.SpeedLimit), m_SpeedLimit = 50 };

Methods

  • public static uint GetTypeMask(TrafficSignType type)
    Returns a single-bit mask for the given TrafficSignType. If type is TrafficSignType.None the method returns 0. Internally it computes (uint)(1 << (17 - (int)type)), so it expects TrafficSignType values to fall into the range that makes (17 - type) a valid shift amount (the original code uses 17 as a mapping offset). Use this helper to ensure consistent bit position mapping when setting m_TypeMask.

Notes: - The method returns 0 for TrafficSignType.None. - Do not pass enum values outside the expected range; the shift relies on the enum mapping and can produce incorrect masks for unexpected values.

Usage Example

// Example: create a component with a speed limit sign and add it to an entity
var signData = new TrafficSignData
{
    m_TypeMask = TrafficSignData.GetTypeMask(TrafficSignType.SpeedLimit),
    m_SpeedLimit = 50
};

// With Entities package you might add it to an entity like:
entityManager.AddComponentData(signEntity, signData);

// If you need a mask for multiple sign types, combine masks with bitwise OR:
uint combinedMask = TrafficSignData.GetTypeMask(TrafficSignType.SpeedLimit)
                 | TrafficSignData.GetTypeMask(TrafficSignType.NoParking);
signData.m_TypeMask = combinedMask;

Additional remarks: - TrafficSignType is an enum defined elsewhere in the codebase; consult its definition to know valid values and their meaning. - This component is a plain data container; systems will interpret m_TypeMask and m_SpeedLimit when implementing sign behavior, rendering or simulation logic.