Skip to content

Game.UI.InGame.DeveloperSection

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

Type: public class DeveloperSection

Base: InfoSectionBase, ISubsectionProvider, ISectionSource, IJsonWritable

Summary:
DeveloperSection is an info panel section used by the in-game developer/debug UI. It acts as a container/provider of subsections (ISubsectionSource) and controls visibility, update and serialization of those subsections depending on the currently selected entity and prefab. The section always displays for destroyed objects, outside connections, under-construction items and upgrades (overrides of the base class behavior).


Fields

  • This class does not declare any private instance fields. All storage is via auto-properties (see Properties) and base-class members.
    {{ The DeveloperSection stores its state primarily in the subsections list (an auto-property). There are no explicit private backing fields in the source shown. }}

Properties

  • public List<ISubsectionSource> subsections { get; private set; }
    {{ Holds the list of subsection providers that this DeveloperSection manages. Subsections are queried for display and updated/serialized when appropriate. The setter is private and the list is initialized in OnCreate. }}

  • protected override string group => "DeveloperSection"
    {{ Overrides the base InfoSectionBase.group to identify this section group as "DeveloperSection". }}

  • protected override bool displayForDestroyedObjects => true
    {{ Ensures the section can be displayed for destroyed objects. }}

  • protected override bool displayForOutsideConnections => true
    {{ Ensures the section can be displayed for outside connections. }}

  • protected override bool displayForUnderConstruction => true
    {{ Ensures the section can be displayed for items under construction. }}

  • protected override bool displayForUpgrades => true
    {{ Ensures the section can be displayed for upgrade operations. }}

Constructors

  • public DeveloperSection()
    {{ Default constructor. The actual initialization of the subsections list happens in OnCreate, which is called by the UI lifecycle; the constructor is attributed with [Preserve] in the source to keep it from being stripped. }}

Methods

  • public void AddSubsection(ISubsectionSource subsection)
    {{ Adds a subsection provider to the internal list. The method appends to subsections (no duplicate checks). Callers should provide an object implementing ISubsectionSource. }}

  • [Preserve] protected override void OnCreate()
    {{ Lifecycle method called when the section is created. Calls base.OnCreate() and initializes subsections to a new List(). Marked with [Preserve] to avoid stripping. }}

  • protected override void Reset()
    {{ Override of a lifecycle/reset hook. Empty in the provided implementation (no custom reset behavior). }}

  • private bool Visible()
    {{ Internal helper that returns true if at least one registered subsection reports it should be displayed for the current selectedEntity and selectedPrefab. Iterates subsections and calls DisplayFor(selectedEntity, selectedPrefab) on each. Used to control section visibility. }}

  • [Preserve] protected override void OnUpdate()
    {{ Called each update tick by the UI system. Updates the base.visible flag based on the Visible() helper so the section appears/disappears automatically. Calls base implementation behavior (if any). }}

  • protected override void OnProcess()
    {{ Called when the section should (re)process its contents. Iterates registered subsections and for any that return true from DisplayFor(selectedEntity, selectedPrefab) calls OnRequestUpdate(selectedEntity, selectedPrefab) on that subsection so it can refresh its content. }}

  • private int GetSubsectionCount()
    {{ Returns the count of subsections that currently want to be displayed (i.e., number of subsections whose DisplayFor returns true for the current selection). Used to size the JSON array when writing properties. }}

  • public override void OnWriteProperties(IJsonWriter writer)
    {{ Serializes the section's properties to the provided IJsonWriter. Writes a "subsections" property and an array containing only the subsections that return true from DisplayFor for the current selection, using writer.Write(subsection) for each displayed subsection. The writer.ArrayBegin is given the count from GetSubsectionCount() to pre-size the array. }}

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // initialize the subsection list so AddSubsection and other methods work
    subsections = new List<ISubsectionSource>();
}

// Elsewhere, add a subsection provider:
var mySubsection = new MyDeveloperSubsection(); // implements ISubsectionSource
developerSection.AddSubsection(mySubsection);

{{ Example shows initializing the subsections list in OnCreate (the class already does this) and demonstrates adding a subsection. Subsections must implement ISubsectionSource and will be queried for visibility and updates by DeveloperSection. }}