Skip to content

Game.PathDebugSystem

Assembly: Assembly-CSharp
Namespace: Game.Debug

Type: class

Base: BaseDebugSystem

Summary: PathDebugSystem is a debug/system utility that visualizes entity path data (PathElement buffers and curves) in the editor/game view using the game's gizmo batching system. It schedules a Burst-compiled IJobChunk (PathGizmoJob) which iterates entity chunks that contain PathElement buffers and draws lines, curves, flow arrows and wire nodes for path segments (net curves and straight segments). The system exposes a set of toggleable options to filter which kinds of path owners are drawn (personal cars, delivery trucks, service vehicles, citizens, companies, transport routes, requests, etc.). It uses GizmosSystem to obtain a GizmoBatcher for drawing and ToolSystem to check for a currently selected entity to restrict drawing to a single selection.


Fields

  • private EntityQuery m_PathGroup
    Used to query all entities that contain PathElement buffers and are not marked Deleted. This query is used to determine whether any path data exists and to schedule the drawing job.

  • private GizmosSystem m_GizmosSystem
    Cached reference to the GizmosSystem retrieved from the world; used to get a GizmoBatcher for batched drawing within the job.

  • private ToolSystem m_ToolSystem
    Cached reference to the ToolSystem retrieved from the world; used to check for a selected entity so the job can draw only the selected entity's path.

  • private Option m_PersonalCarOption
    Toggle option for drawing paths belonging to personal cars (enabled by default).

  • private Option m_DeliveryTruckOption
    Toggle option for drawing paths belonging to delivery trucks (enabled by default).

  • private Option m_ServiceVehicleOption
    Toggle option for drawing service vehicle paths (enabled by default).

  • private Option m_ResidentOption
    Toggle option for drawing creature/citizen instance paths (enabled by default).

  • private Option m_CitizenOption
    Toggle option for drawing citizen agent paths (disabled by default).

  • private Option m_CompanyOption
    Toggle option for drawing company-related paths (disabled by default).

  • private Option m_RouteOption
    Toggle option for drawing transport route segments (disabled by default).

  • private Option m_DeliveryRequestOption
    Toggle option for drawing goods delivery requests (disabled by default).

  • private Option m_ServiceRequestOption
    Toggle option for drawing service requests (disabled by default).

  • private TypeHandle __TypeHandle
    Generated helper struct instance used to cache and assign Entity/Component/Buffer/Lookup handles needed by the scheduled job. It centralizes handle acquisition for the job scheduling.

Notes: PathGizmoJob and TypeHandle are nested generated types inside PathDebugSystem. PathGizmoJob is Burst-compiled and implements IJobChunk to process archetype chunks; TypeHandle provides GetComponentTypeHandle/GetBufferTypeHandle/GetComponentLookup assignments.

Properties

  • (none publicly exposed)

Constructors

  • public PathDebugSystem()
    Default constructor (preserved). The system performs initialization in OnCreate; the constructor itself is generated/preserved and empty.

Methods

  • protected override void OnCreate() : System.Void
    Initializes system references and options:
  • Retrieves/creates GizmosSystem and ToolSystem from the world.
  • Builds the m_PathGroup EntityQuery for PathElement buffers (excluding Deleted entities).
  • Registers toggleable options for different path-owner types (personal cars, delivery trucks, service vehicles, residents, citizens, companies, routes, delivery/service requests).
  • Disables the system by default (base.Enabled = false).

  • protected override void OnUpdate() : System.Void
    Called each frame. If the path query contains entities (m_PathGroup.IsEmptyIgnoreFilter is false), schedules the path gizmo drawing job via DrawPathGizmos and chains its JobHandle into base.Dependency.

  • private JobHandle DrawPathGizmos(EntityQuery group, JobHandle inputDeps) : JobHandle
    Prepares and schedules the Burst-compiled PathGizmoJob as a parallel chunk job:

  • Acquires Entity/Component/Buffer/Lookup handles from the cached TypeHandle and base.CheckedStateRef via InternalCompilerInterface.
  • Passes option boolean values and runtime data (Time.realtimeSinceStartup, selected entity from ToolSystem).
  • Obtains a GizmosBatcher from m_GizmosSystem (this produces a JobHandle dependency which is combined).
  • Adds a writer registration for the returned job handle with m_GizmosSystem.
  • Returns the job's JobHandle so it can be combined into system dependencies.

  • private void __AssignQueries(ref SystemState state) : (inlined helper)
    Generated helper that ensures query assignment (present as compiled scaffolding, here it is effectively a no-op except for a temporary EntityQueryBuilder call).

  • protected override void OnCreateForCompiler() : System.Void
    Compiler-time helper used to assign queries and component handles for the generated TypeHandle. Calls __AssignQueries and __TypeHandle.__AssignHandles.

Nested type: PathGizmoJob (private struct, [BurstCompile], implements IJobChunk) - Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask) : void
- Iterates entities in the chunk (or only a selected entity if one is selected). - Filters chunks based on presence of various marker/component types and the corresponding options (vehicles, personal car vs delivery truck vs service vehicle, creatures, citizen types, job/school seekers, households, companies, route segments, delivery/service requests). - Reads the PathOwner component to determine the starting PathElement index. - Reads the DynamicBuffer for the entity and iterates the path elements from the PathOwner's element index. - For each PathElement: - If the target is a net Curve (m_CurveData.HasComponent), uses MathUtils.Cut to get a Bezier segment and draws either a flow curve (with arrows) or a standard curve depending on segment length. - Otherwise, resolves a position from Position or Transform component lookup and draws straight connections (lines) or converts to a straight Bezier to call the same draw routine. - Draws wire nodes at the start (red) and end (green) of each path, magenta connectors when connecting discontinuous segments. - Uses DrawPathCurve helper to draw either flow curves (with arrow counts proportional to length) or simple curves.

  • private void DrawPathCurve(Bezier4x3 curve, float length, float timeOffset, UnityEngine.Color color) : void
  • Chooses between DrawFlowCurve (with arrowCount derived from length) and DrawCurve for shorter segments.

Notes about PathGizmoJob: - Reads several ComponentLookups (Curve, Position, Transform) and many ComponentTypeHandles/BufferTypeHandles. - Uses GizmoBatcher for efficient batched draw calls. Batcher is obtained via m_GizmosSystem.GetGizmosBatcher(out dependencies) when scheduling.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_GizmosSystem = base.World.GetOrCreateSystemManaged<GizmosSystem>();
    m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
    m_PathGroup = GetEntityQuery(ComponentType.ReadOnly<PathElement>(), ComponentType.Exclude<Deleted>());
    m_PersonalCarOption = AddOption("Personal cars", defaultEnabled: true);
    m_DeliveryTruckOption = AddOption("Delivery trucks", defaultEnabled: true);
    m_ServiceVehicleOption = AddOption("Service vehicles", defaultEnabled: true);
    m_ResidentOption = AddOption("Citizens (instance)", defaultEnabled: true);
    m_CitizenOption = AddOption("Citizens (agent)", defaultEnabled: false);
    m_CompanyOption = AddOption("Companies", defaultEnabled: false);
    m_RouteOption = AddOption("Transport routes", defaultEnabled: false);
    m_DeliveryRequestOption = AddOption("Delivery requests", defaultEnabled: false);
    m_ServiceRequestOption = AddOption("Service requests", defaultEnabled: false);
    base.Enabled = false;
}

Additional notes for modders: - The drawing job is Burst-compiled and scheduled as a parallel JobChunk; be mindful of component access patterns when modifying component types used here. - Filtering of drawn entities relies on presence of marker components (e.g., PersonalCar, DeliveryTruck, Vehicle, Citizen, Creature). If you introduce custom types or alter component usage, update the filtering logic accordingly. - The system reads PathElement buffers and Curve/Position/Transform component lookups — ensure those components remain available and consistent if interacting with path data.