Game.UI.InGame.TransformerSection
Assembly:
Assembly-CSharp (game assembly; compiled into the game's managed assembly)
Namespace:
Game.UI.InGame
Type:
class
Base:
InfoSectionBase
Summary:
UI info-section used by the in-game inspector for Transformer building entities. This section queries ECS component/buffer data required to compute transformer capacity and current flow, stores those values in private properties, and exposes them via JSON when the UI system serializes the section. The implementation uses a compiler-generated TypeHandle struct to cache ComponentLookup/BufferLookup handles and performs queries in OnProcess(). The section is visible only when the selected entity has a Transformer building component.
Fields
-
private TypeHandle __TypeHandle
Holds component- and buffer-lookup fields (ComponentLookup/ BufferLookup ) used to access ECS data needed to compute transformer stats. The nested TypeHandle provides a method to assign those lookups from a SystemState. -
private int capacity
(implemented as a private auto-property) Stores the computed capacity value for the currently selected transformer entity after OnProcess runs. -
private int flow
(implemented as a private auto-property) Stores the computed flow (current transfer) for the currently selected transformer entity after OnProcess runs.
Properties
-
protected override string group => "TransformerSection"
Identifier used by the UI system to group/label this info section. This override returns the literal "TransformerSection". -
private int capacity { get; set; }
Auto-property for the transformer's capacity (set during OnProcess()). -
private int flow { get; set; }
Auto-property for the transformer's current flow (set during OnProcess()).
Constructors
public TransformerSection()
Parameterless constructor. Marked with [Preserve] attribute to avoid being stripped by managed code stripping; no custom initialization logic beyond base constructor.
Methods
-
protected override void Reset()
Resets the section's runtime values (sets capacity and flow to 0). Called by the UI system when resetting the info section state. -
private bool Visible()
Returns whether this section should be visible for the currently selected entity. Implementation returns true when the selectedEntity has a Game.Buildings.Transformer component. -
[Preserve] protected override void OnUpdate()
Updates the section's base.visible flag based on the Visible() check. Called each frame/update tick by the UI framework. -
protected override void OnProcess()
Main processing routine for the section. Ensures dependencies are complete, constructs a Game.Simulation.TransformerData wrapper populated with the ComponentLookup/BufferLookup instances from the TypeHandle, calls GetTransformerData(selectedEntity, out capacity, out flow) to update the internal capacity and flow values. -
public override void OnWriteProperties(IJsonWriter writer)
Serializes the section properties to JSON for the UI system. Writes "capacity" and "flow" numeric properties. -
[MethodImpl(MethodImplOptions.AggressiveInlining)] private void __AssignQueries(ref SystemState state)
Compiler-generated query assignment helper that currently creates/ disposes an EntityQueryBuilder (no queries are created in this implementation). Used by OnCreateForCompiler. -
protected override void OnCreateForCompiler()
Called at creation-time by the compiler-generated wiring. Calls __AssignQueries and assigns the lookup handles in __TypeHandle by calling __TypeHandle.__AssignHandles with the CheckedStateRef. This sets up ComponentLookup/BufferLookup instances used later in OnProcess. -
private struct TypeHandle
/public void __AssignHandles(ref SystemState state)
Nested struct that declares read-only ComponentLookupand BufferLookup fields for all ECS types read by this section (Deleted, PrefabRef, ElectricityConnectionData, InstalledUpgrade, SubNet, Node, ElectricityNodeConnection, ElectricityValveConnection, ConnectedFlowEdge, ElectricityFlowEdge). __AssignHandles initializes each lookup from the provided SystemState with isReadOnly: true.
Usage Example
// This shows where capacity/flow are computed and serialized in the section.
// The class already implements these methods; this snippet demonstrates how
// the values are available after OnProcess and are written to JSON.
[Preserve]
protected override void OnProcess()
{
// Ensure dependencies are complete and reads are accessible
CompleteDependency();
// Build TransformerData (the actual code uses InternalCompilerInterface to populate lookups)
Game.Simulation.TransformerData transformerData = /* populated from TypeHandle lookups */;
// Query transformer values for selectedEntity (internal API)
transformerData.GetTransformerData(selectedEntity, out var computedCapacity, out var computedFlow);
// Store values on the section
capacity = computedCapacity;
flow = computedFlow;
}
public override void OnWriteProperties(IJsonWriter writer)
{
writer.PropertyName("capacity");
writer.Write(capacity);
writer.PropertyName("flow");
writer.Write(flow);
}
Notes and implementation details: - The section relies on ECS lookups via the nested TypeHandle; these are assigned once in OnCreateForCompiler and converted to runtime interfaces via InternalCompilerInterface.GetComponentLookup / GetBufferLookup in OnProcess. - Visibility is driven by checking whether the selected entity has a Game.Buildings.Transformer component. - The class is compiler-generated (has [CompilerGenerated] on the containing class) and uses [Preserve] attributes on entry points to keep methods available with managed code stripping.