Skip to content

Game.Debug.TerrainAttractivenessDebugSystem

Assembly: Game
Namespace: Game.Debug

Type: class

Base: BaseDebugSystem

Summary:
TerrainAttractivenessDebugSystem is a debug ECS system used by the game to visualize terrain attractiveness per terrain cell. It schedules a short-lived job (TerrainAttractivenessGizmoJob) that samples the terrain height and attractiveness map, evaluates an attractiveness value for each cell using AttractivenessParameterData, and issues gizmo draw calls via the GizmosSystem's GizmoBatcher. The system obtains read-only access to TerrainAttractivenessSystem, TerrainSystem, and the attractiveness parameter singleton. It is disabled by default in OnCreate and intended to be enabled only when the developer/modder wants to visualize the attractiveness map.


Fields

  • private struct TerrainAttractivenessGizmoJob : IJob
    This nested job iterates all cells in the TerrainAttractiveness cell map, samples the terrain height, evaluates attraction using TerrainAttractivenessSystem.EvaluateAttractiveness, and draws wireframe cubes (via GizmoBatcher) for positive attractiveness values. Internal job fields:
  • m_Map (CellMapData) — read-only cell map data for attractiveness.
  • m_HeightData (TerrainHeightData) — read-only height data used for sampling.
  • m_Parameters (AttractivenessParameterData) — parameters used in evaluation.
  • m_GizmoBatcher (GizmoBatcher) — used to emit gizmo draw calls.

  • private TerrainAttractivenessSystem m_TerrainAttractivenessSystem
    Reference to the core TerrainAttractivenessSystem used to retrieve cell data and register readers for job dependency management.

  • private TerrainSystem m_TerrainSystem
    Reference to the TerrainSystem to access height data and to register a CPU height reader dependency.

  • private EntityQuery m_ParameterQuery
    EntityQuery used to fetch the AttractivenessParameterData singleton component.

  • private GizmosSystem m_GizmosSystem
    Reference to the GizmosSystem used to obtain a GizmoBatcher for drawing and to register the batcher writer dependency.

Properties

  • (None — this system does not expose additional public properties)
    The system relies on internal fields and the ECS query to obtain required data.

Constructors

  • public TerrainAttractivenessDebugSystem()
    Default constructor (marked with [Preserve] in source). The constructor is empty; real initialization is performed in OnCreate. The [Preserve] attribute prevents IL stripping of the constructor for runtime reflection/creation.

Methods

  • protected override void OnCreate()
    Initializes references to required systems (GizmosSystem, TerrainAttractivenessSystem, TerrainSystem), creates an EntityQuery for AttractivenessParameterData, and disables the system by default (base.Enabled = false). This ensures the system does not run unless explicitly enabled by a developer/modder.

  • protected override JobHandle OnUpdate(JobHandle inputDeps)
    Schedules the TerrainAttractivenessGizmoJob:

  • Acquires read-only cell map data from TerrainAttractivenessSystem (and receives its dependency handle).
  • Obtains a GizmoBatcher from GizmosSystem (and receives its dependency handle).
  • Reads TerrainSystem height data and the AttractivenessParameterData singleton.
  • Schedules the job combining inputDeps with the map and gizmo dependencies.
  • Registers the scheduled job with the GizmosSystem, TerrainAttractivenessSystem, and TerrainSystem so they can track readers/writers and ensure proper dependency ordering.
  • Returns the job handle.

  • private void TerrainAttractivenessGizmoJob.Execute()
    Job execution body: loops over all cells, computes each cell's world center, samples height, evaluates attractiveness, and emits a wireframe cube with height proportional to attractiveness if the evaluated value is positive.

Usage Example

// Example: enabling the debug system at runtime to visualize terrain attractiveness.
// Typically executed from a debug menu or initialization code in a mod/tool.

var world = /* obtain World reference, e.g., World.DefaultGameObjectInjectionWorld or the game's World */;
var debugSystem = world.GetOrCreateSystemManaged<Game.Debug.TerrainAttractivenessDebugSystem>();

// Enable the debug system so it starts scheduling its gizmo job every tick:
debugSystem.Enabled = true;

// When finished, disable to stop drawing and scheduling:
debugSystem.Enabled = false;

For reference, the system's OnCreate implementation (from source) initializes dependencies and disables itself by default:

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    m_GizmosSystem = base.World.GetOrCreateSystemManaged<GizmosSystem>();
    m_TerrainAttractivenessSystem = base.World.GetOrCreateSystemManaged<TerrainAttractivenessSystem>();
    m_TerrainSystem = base.World.GetOrCreateSystemManaged<TerrainSystem>();
    m_ParameterQuery = GetEntityQuery(ComponentType.ReadOnly<AttractivenessParameterData>());
    base.Enabled = false; // Disabled by default; enable when you want to visualize
}