Skip to content

Game.Prefabs.PathwayData

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
PathwayData is a lightweight ECS component used by pathway/footpath prefabs. It stores the movement speed limit applied to the pathway and a boolean flag indicating whether the pathway acts as a leisure provider. The struct implements Colossal's ISerializable so the speed-limit value can be persisted; note that only m_SpeedLimit is serialized/deserialized by the provided implementations — m_LeisureProvider is not written/read by the serializer and therefore will not persist across save/load unless handled elsewhere.


Fields

  • public float m_SpeedLimit
    Holds the movement speed limit for the pathway. This field is written by Serialize and read by Deserialize. Default (when not set) is 0.0f.

  • public bool m_LeisureProvider
    Flag indicating whether the pathway is considered a leisure-provider. This field is part of the ECS component for runtime logic but is not serialized by the provided Serialize/Deserialize methods. Default is false.

Properties

  • This type defines no properties. It exposes fields directly and is intended for use as an ECS component / query parameter.

Constructors

  • public PathwayData()
    No explicit constructors are defined. The struct uses the default parameterless constructor (all fields zero-initialized: m_SpeedLimit = 0f, m_LeisureProvider = false).

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_SpeedLimit to the provided writer (writer.Write(m_SpeedLimit)). Used by the game's serialization system to persist the speed limit.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the m_SpeedLimit from the provided reader (reader.Read(out m_SpeedLimit)). Because only m_SpeedLimit is read, m_LeisureProvider remains at its default value after deserialization unless set elsewhere.

Usage Example

// Creating an entity and adding the PathwayData component
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var entity = entityManager.CreateEntity();
entityManager.AddComponentData(entity, new PathwayData {
    m_SpeedLimit = 5.0f,
    m_LeisureProvider = true
});

// Accessing in a system (example DOTS syntax)
Entities.ForEach((ref PathwayData pathway) =>
{
    // Modify runtime-only flag
    if (pathway.m_SpeedLimit < 1f)
        pathway.m_LeisureProvider = false;
}).Schedule();

// Note: serialization is handled by the game's Colossal.Serialization system.
// The provided Serialize/Deserialize implementations only persist m_SpeedLimit.
// If you need to persist m_LeisureProvider, extend the serialization implementation accordingly,
// e.g. writer.Write(m_LeisureProvider) and reader.Read(out m_LeisureProvider).