Game.UI.InGame.UITransportLineData
Assembly:
Assembly-CSharp (game code / modding runtime)
Namespace:
Game.UI.InGame
Type:
readonly struct
Base:
System.ValueType, IJsonWritable, IComparable
Summary:
Represents a compact, immutable snapshot of a transport line used by the in-game UI. The struct stores identifying and statistical information about a transport line (entity, type, visual color, schedule id, length, stops, vehicle/cargo counts and usage). It can be written to a JSON writer (IJsonWritable) and compared (IComparable) — CompareTo orders first by TransportType and then by the entity's Index. Color is taken from a Game.Routes.Color instance (stored as a Color32) and the provided RouteSchedule is stored as an integer.
Fields
- This struct declares no explicit private fields in source — it exposes all data via read-only auto-properties (see Properties). The compiler will generate backing fields for those properties, but they are not directly declared in the source.
Properties
-
public Unity.Entities.Entity entity { get; }
Holds the ECS Entity that identifies the transport line. -
public bool active { get; }
Whether the transport line is currently active. -
public bool visible { get; }
Whether the transport line is marked visible in the UI. -
public bool isCargo { get; }
True when the line is a cargo line. -
public UnityEngine.Color32 color { get; }
Visual color for the line. Set from Game.Routes.Color.m_Color in the constructor. -
public int schedule { get; }
Schedule identifier stored as an int (constructed by casting a RouteSchedule enum/value to int). -
public TransportType type { get; }
TransportType enum describing the transport mode (bus, metro, etc.). -
public float length { get; }
Total length of the route (units as used by the game). -
public int stops { get; }
Number of stops on the route. -
public int vehicles { get; }
Number of vehicles assigned to the line. -
public int cargo { get; }
Cargo capacity / cargo statistic for cargo lines (int). -
public float usage { get; }
Usage measure (float) describing how heavily the line is used.
Constructors
public UITransportLineData(Entity entity, bool active, bool visible, bool isCargo, Game.Routes.Color color, RouteSchedule schedule, TransportType type, float length, int stops, int vehicles, int cargo, float usage)
Creates a new UITransportLineData by copying the provided values. Important details:- color is pulled from the provided Game.Routes.Color via its m_Color field and stored as Color32.
- schedule is stored as an int via cast: (int)schedule.
- All properties are assigned and remain read-only afterwards.
Methods
public int CompareTo(UITransportLineData other)
Implements IComparable. Comparison logic: - First compares this.type to other.type using TransportType.CompareTo.
- If types are equal, compares entity.Index to other.entity.Index.
-
Returns the int result suitable for sorting (negative, zero, positive).
-
public void Write(IJsonWriter writer)
Implements IJsonWritable. Serializes the struct to the provided IJsonWriter: - Begins a typed object using the struct's full type name.
- Writes each property as a JSON property: entity, active, visible, isCargo, color, schedule, type, length, stops, vehicles, cargo, usage.
- For type it writes the enum name using Enum.GetName(typeof(TransportType), type).
- Ends the typed object.
Usage Example
// Construct from game data (example variables shown)
Entity myEntity = /* obtain entity */;
bool isActive = true;
bool isVisible = true;
bool isCargo = false;
Game.Routes.Color routeColor = /* obtain route color */;
RouteSchedule routeSchedule = /* obtain schedule */;
TransportType transportType = TransportType.Bus;
float routeLength = 12.5f;
int stopCount = 10;
int vehicleCount = 3;
int cargoCount = 0;
float usage = 0.75f;
var lineData = new UITransportLineData(
myEntity,
isActive,
isVisible,
isCargo,
routeColor,
routeSchedule,
transportType,
routeLength,
stopCount,
vehicleCount,
cargoCount,
usage
);
// Serialize to JSON
IJsonWriter writer = /* obtain writer */;
lineData.Write(writer);
// Sorting example
var list = new List<UITransportLineData> { lineData, /* other items */ };
list.Sort(); // sorts by TransportType then entity.Index via CompareTo
Notes: - The struct is immutable from the outside — useful for passing snapshots of UI data without risk of modification. - When reading/writing JSON, the "type" property is serialized as the enum name (string), while "schedule" is serialized as an integer.