Skip to content

Game.UI.InGame.DevTreeUISystem

Assembly: Assembly-CSharp
Namespace: Game.UI.InGame

Type: class

Base: UISystemBase

Summary:
DevTreeUISystem is a UI system responsible for exposing the game's development tree (dev tree) to the UI layer. It creates EntityQueries to read dev tree points, nodes and services, sets up JSON bindings used by the UI (points, services, nodes, service/node details) and handles purchase requests for dev tree nodes. It uses PrefabSystem/PrefabUISystem to resolve prefab metadata and ImageSystem to provide icons/thumbnails.


Fields

  • private struct DevTreeNodeInfo
    Internal helper struct used to package a dev tree node's Entity, PrefabData, DevTreeNodeData and whether it is locked. Used when producing node lists for the UI.

  • private struct TypeHandle
    Holds ECS type handles (EntityTypeHandle, ComponentTypeHandle, ComponentTypeHandle, ComponentTypeHandle) and provides __AssignHandles to initialize them against a SystemState. Used for efficient chunk iteration in GetDevTreeNodes.

  • private const string kGroup = "devTree"
    UI group name/string constant used for registering bindings and triggers.

  • private PrefabSystem m_PrefabSystem
    Cached reference to PrefabSystem (used to resolve PrefabData to concrete Prefab objects like ServicePrefab and DevTreeNodePrefab).

  • private PrefabUISystem m_PrefabUISystem
    Cached reference to PrefabUISystem (used to bind prefab requirements in UI output).

  • private DevTreeSystem m_DevTreeSystem
    Cached reference to DevTreeSystem (used to purchase dev tree nodes).

  • private ImageSystem m_ImageSystem
    Cached reference to ImageSystem (used to fetch icons and thumbnails, with fallback to placeholder icon).

  • private EntityQuery m_DevTreePointsQuery
    Query for DevTreePoints component (singleton that stores current dev tree points).

  • private EntityQuery m_DevTreeNodeQuery
    Query that matches entities with PrefabData + DevTreeNodeData and excludes Deleted/Temp — used to enumerate all dev tree nodes.

  • private EntityQuery m_UnlockedServiceQuery
    Query matching Unlock component to detect unlocked services (used to determine when to refresh service lists).

  • private EntityQuery m_ModifiedDevTreeNodeQuery
    Query to detect created/updated/deleted DevTreeNodeData/PrefabData to refresh nodes bindings when they change.

  • private EntityQuery m_LockedDevTreeNodeQuery
    Query filtering PrefabData + DevTreeNodeData + Locked (excluding Deleted/Temp) — used to calculate max dev tree points (sum of locked node costs).

  • private GetterValueBinding<int> m_PointsBinding
    Binding that exposes the current dev tree points integer to the UI (devTree.points) via GetDevTreePoints.

  • private RawValueBinding m_ServicesBinding
    Binding that writes the services list JSON (devTree.services) via BindServices.

  • private RawMapBinding<Entity> m_ServiceDetailsBinding
    Map binding that writes details for a selected service entity (devTree.serviceDetails) via BindServiceDetails.

  • private RawMapBinding<Entity> m_NodesBinding
    Map binding that writes node lists per service (devTree.nodes) via BindNodes.

  • private RawMapBinding<Entity> m_NodeDetailsBinding
    Map binding that writes details for a selected node entity (devTree.nodeDetails) via BindNodeDetails.

  • private TypeHandle __TypeHandle
    Instance of the TypeHandle struct used to cache component type handles for chunk iteration (passed to InternalCompilerInterface in GetDevTreeNodes).

Properties

  • (none publicly exposed)
    This system exposes UI data only through registered bindings/triggers; it does not expose public properties.

Constructors

  • public DevTreeUISystem()
    Default constructor. Initialization of systems and bindings is done in OnCreate.

Methods

  • protected override void OnCreate()
    Initializes the system: resolves and caches subsystem references (PrefabSystem, PrefabUISystem, DevTreeSystem, ImageSystem), creates EntityQueries, adds UI bindings (points, services, serviceDetails, nodes, nodeDetails) and registers a TriggerBinding for "devTree.purchaseNode" which forwards to PurchaseNode. Called by the framework when the system is created.

  • protected override void OnUpdate()
    Runs each frame: updates the points binding always; updates node and node-detail bindings when nodes changed or new unlocks occurred; updates services and service-details bindings when services unlocked. Uses queries (m_ModifiedDevTreeNodeQuery, m_UnlockedServiceQuery) to minimize unnecessary updates.

  • private void PurchaseNode(Entity node)
    Handler called by the TriggerBinding when the UI requests a node purchase. Forwards call to m_DevTreeSystem.Purchase(node).

  • private int GetDevTreePoints()
    Returns the current dev tree points clamped to the maximum possible points (by summing costs of locked dev tree nodes). If no DevTreePoints singleton exists returns 0.

  • private int GetMaxDevTreePoints()
    Calculates the sum of costs of all currently locked dev tree nodes by reading DevTreeNodeData from m_LockedDevTreeNodeQuery. Uses a temporary NativeArray and disposes it before returning the sum.

  • private void BindServices(IJsonWriter writer)
    Writes a JSON array describing the unique services that have dev tree nodes. For each service it writes entity id, name, icon (via ImageSystem), locked state and uiTag, and uses PrefabUISystem.BindPrefabRequirements to append requirement info. Obtains the sorted list via GetSortedDevTreeServices and disposes resources.

  • private NativeList<UIObjectInfo> GetSortedDevTreeServices(Allocator allocator)
    Builds a deduplicated list of services referenced by dev tree nodes, collects PrefabData and UIObjectData.priority, sorts by priority and returns the list. Uses temporary NativeArray/NativeParallelHashSet and returns a NativeList allocated with the provided allocator.

  • private void BindServiceDetails(IJsonWriter binder, Entity service)
    Writes details for a single service entity (name, icon, locked state, milestone requirement). If the service is null or doesn't have expected components, writes null.

  • private void BindNodes(IJsonWriter binder, Entity service)
    Writes JSON array of nodes for a given service. For each node it writes entity, name, icon, cost, locked, position, requirements (list of required node entities) and whether the node is currently unlockable. Uses GetDevTreeNodes to gather nodes for the service.

  • private NativeList<DevTreeNodeInfo> GetDevTreeNodes(Entity service, Allocator allocator)
    Iterates archetype chunks from m_DevTreeNodeQuery using cached component type handles (via __TypeHandle and InternalCompilerInterface) and returns a NativeList of DevTreeNodeInfo for nodes that belong to the specified service. Properly inspects EnabledMask to determine if Locked component is enabled for each chunk element.

  • private void BindNodeDetails(IJsonWriter binder, Entity node)
    Writes detailed JSON for a given dev tree node (entity, name, icon, cost, locked, unlockable, requirementCount, milestoneRequirement). If node is invalid or missing components, writes null.

  • private string GetDevTreeIcon(DevTreeNodePrefab prefab)
    Returns the appropriate icon path/string for a dev tree node prefab. Preference order: explicit m_IconPath, thumbnail from m_IconPrefab (via ImageSystem.GetThumbnail), otherwise ImageSystem.placeholderIcon.

  • private void __AssignQueries(ref SystemState state)
    Compiler helper that may create or assign queries at compile-time. In this implementation it's effectively a placeholder that calls EntityQueryBuilder and disposes it (no-op here).

  • protected override void OnCreateForCompiler()
    Compiler-targeted initialization method: calls base.OnCreateForCompiler(), __AssignQueries(ref base.CheckedStateRef) and __TypeHandle.__AssignHandles(ref base.CheckedStateRef) to prepare type handles for chunk iteration used by generated/IL2CPP code paths.

  • TypeHandle.__AssignHandles(ref SystemState state)
    (nested method) Assigns the EntityTypeHandle and ComponentTypeHandles (PrefabData, DevTreeNodeData, Locked) by calling state.GetXXXTypeHandle. Used by OnCreateForCompiler to cache handles.

Usage Example

// Example: purchase a dev tree node from code (outside of the UI trigger).
// This mimics what the UI TriggerBinding calls internally.

using Unity.Entities;

// obtain the DevTreeSystem from the active World (match how DevTreeUISystem caches it)
var world = World.DefaultGameObjectInjectionWorld;
var devTreeSystem = world.GetOrCreateSystemManaged<Game.DevTreeSystem>();

// nodeEntity is the Entity representing a DevTree node you want to purchase
devTreeSystem.Purchase(nodeEntity);

Notes: - The system is designed to minimize JSON/binding updates by checking EntityQuery change conditions (created/updated/deleted/Unlock). - Many internal methods allocate Native containers (NativeArray, NativeList, NativeParallelHashSet) — these are disposed after use; callers of helper methods that return NativeLists must respect the allocator and dispose when done (the system itself disposes in its flows).