Game.Debug.PropertyDebugSystem
Assembly: Game
Namespace: Game.Debug
Type: class
Base: BaseDebugSystem
Summary: PropertyDebugSystem is a debug/system tool used by the game to visualize building-related property data in the editor/debug view. It queries building entities that have either CrimeProducer or Renter data and uses a scheduled IJobChunk (PropertyGizmoJob) to draw wireframe gizmos (wire cubes) representing crime accumulation, residential availability shortage, and residential crime depending on enabled debug options. The system uses GizmosSystem to batch drawing and runs as a scheduled job for performance.
Fields
-
private EntityQuery m_PropertyQuery
Holds the entity query used to select Building entities that have either CrimeProducer or Renter buffers and are not Deleted/Temp/Hidden. The query is required for update (RequireForUpdate). -
private GizmosSystem m_GizmosSystem
Reference to the GizmosSystem used to obtain a GizmoBatcher for drawing wire gizmos in a job-friendly manner. -
private Option m_ResidentialAvailableOption
Debug option toggle controlling whether residential availability (vacancy/space) visualization is drawn. -
private Option m_ResidentialCrimeOption
Debug option toggle controlling whether residential-specific crime visualization is drawn. -
private Option m_CrimeOption
Master debug option controlling crime accumulation visualization. When disabled the job early-outs and no gizmos are drawn. -
private TypeHandle __TypeHandle
Struct instance that caches all Entity/Component/Buffer/Lookup handles required by the job. Populated via __AssignHandles during OnCreateForCompiler.
Properties
- None (no public properties are declared on this system)
{{ The system exposes no public properties. All configuration is handled via internal/private Option objects and the system's Enabled flag. }}
Constructors
public PropertyDebugSystem()
Default constructor. Marked with [Preserve] to avoid stripping. Initialization of runtime state occurs in OnCreate rather than in the constructor.
{{ The constructor itself does not perform setup; OnCreate initializes queries, options and acquires the GizmosSystem. }}
Methods
protected override void OnCreate()
Initializes the system:- Acquires/creates the GizmosSystem via World.GetOrCreateSystemManaged
(). - Builds m_PropertyQuery to include Building and either CrimeProducer or Renter components, excluding Deleted/Temp/Hidden.
- Adds three debug Option toggles: "Residential Crime", "Residential Available", and "Crime Accumulation" (default enabled).
-
Calls RequireForUpdate with the property query and disables the system by default (base.Enabled = false).
-
protected override JobHandle OnUpdate(JobHandle inputDeps)
Prepares and schedules PropertyGizmoJob: - Fills job data with component type handles and ComponentLookup instances via InternalCompilerInterface and cached __TypeHandle entries.
- Obtains a GizmoBatcher from m_GizmosSystem (which may produce additional dependencies).
- Schedules the job using JobChunkExtensions.ScheduleParallel over m_PropertyQuery and combines dependencies.
-
Registers the returned dependency with m_GizmosSystem via AddGizmosBatcherWriter and returns the job handle.
-
protected override void OnCreateForCompiler()
Compiler-time helpers are invoked: calls __AssignQueries and __TypeHandle.__AssignHandles to ensure the Entity/Component handles are prepared for the burst/job codegen used by the system. -
private void __AssignQueries(ref SystemState state)
Internal helper intended for compiler/codegen; currently contains a no-op EntityQueryBuilder usage (likely placeholder to satisfy codegen expectations). -
private struct PropertyGizmoJob : IJobChunk
IJobChunk implementation that performs per-chunk processing and draws gizmos: - Fields include EntityTypeHandle, ComponentTypeHandles for PrefabRef and CrimeProducer, BufferTypeHandle
, ComponentLookup , ComponentLookup , GizmoBatcher, and debug option booleans. - Execute reads chunk entity array and relevant component arrays/buffers.
- If m_CrimeOption is false, the job returns early.
- For each entity in the chunk:
- If m_ResidentialCrimeOption is enabled and CrimeProducer component present: draws a wire cube whose height represents crime using Draw(Entity, float, int).
- Else if m_ResidentialAvailableOption is enabled and Renter buffer and BuildingPropertyData present: compares building's residential capacity to current renters and draws a (green) wire cube representing available residential slots using Draw(Entity, float, int, Color).
- Contains two overloads of Draw(...) that compute positions from Game.Objects.Transform, rotate offsets and call m_GizmoBatcher.DrawWireCube with computed position, size and color.
-
The job schedules and runs in parallel across chunks.
-
private struct TypeHandle
Container struct holding Entity/Component/Buffer/ComponentLookup handles needed by the job. Has method: public void __AssignHandles(ref SystemState state)
— obtains and assigns the various type handles/read-only lookups from the provided SystemState.
{{ Note: Many members are marked [Preserve] to keep them available for reflection and to avoid stripping. The job uses ComponentLookup for transform and prefab data to avoid requiring those components to be present on the same archetype/chunk. }}
Usage Example
// Enable and use the debug system at runtime (for developer/debug builds)
var debugSystem = World.DefaultGameObjectInjectionWorld.GetOrCreateSystemManaged<Game.Debug.PropertyDebugSystem>();
debugSystem.Enabled = true;
// The internal options ("Residential Crime", "Residential Available", "Crime Accumulation")
// are added by the system in OnCreate. In editor/debug UI they can be toggled
// (the exact UI hooks are project-specific). The system schedules a JobChunk
// that draws gizmos via the GizmosSystem every update while enabled.
{{ Typical use is simply to enable the system in a development or debug session; it will then visualize building crime/availability in the scene using GizmosSystem. }}