Skip to content

Game.UI.InGame.ContentPrerequisiteSection

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

Type: class

Base: InfoSectionBase

Summary:
A UI info-section used in the in-game UI to show a content prerequisite for the currently selected prefab. This section checks for a ContentPrerequisiteData component on the selected prefab and displays itself when the required content prefab is not enabled/available. It also resolves and exposes the name of the required content prefab for serialization (JSON output). The class uses EntityManager and the game's prefab system to perform these checks and lookups.


Fields

  • private string contentPrefab { get; set; }
    Holds the resolved name of the required content prefab (populated in OnProcess and cleared in Reset). This is written out by OnWriteProperties for UI/serialization purposes.

Properties

  • protected override bool displayForUpgrades => true
    Indicates this section should be displayed when the selected prefab is an upgrade.

  • protected override bool displayForUnderConstruction => true
    Indicates this section should be displayed when the selected prefab is under construction.

  • protected override bool displayForDestroyedObjects => true
    Indicates this section should be displayed for destroyed objects.

  • protected override bool displayForOutsideConnections => true
    Indicates this section should be displayed for outside connections.

  • protected override string group => "ContentPrerequisiteSection"
    Group identifier used by the InfoSection system to categorize this section.

Constructors

  • public ContentPrerequisiteSection()
    Default constructor. Marked with [Preserve] attribute to avoid being stripped by code stripping. No special initialization logic in the constructor.

Methods

  • [Preserve] protected override void OnUpdate()
    Sets the base.visible flag depending on whether the selected prefab has a ContentPrerequisiteData component and the required content prefab is not enabled. Implementation:
  • Tries to get ContentPrerequisiteData for the selectedPrefab via EntityManager.TryGetComponent.
  • Checks EntityManager.HasEnabledComponent(component.m_ContentPrerequisite).
  • Sets base.visible to true only when the data exists and the prerequisite prefab is not enabled.

  • protected override void Reset()
    Resets the contentPrefab field to an empty string. Called when the section is reset/cleared.

  • protected override void OnProcess()
    When a selected prefab contains ContentPrerequisiteData, resolves the name of the required content prefab using m_PrefabSystem.GetPrefabName(component.m_ContentPrerequisite) and stores it in contentPrefab for display/serialization.

  • public override void OnWriteProperties(IJsonWriter writer)
    Writes the contentPrefab value into the provided JSON writer under the property name "contentPrefab". Used to serialize the section's displayed data into JSON.

Usage Example

// Example: how the section serializes the resolved content prefab name
[Preserve]
public override void OnWriteProperties(IJsonWriter writer)
{
    base.OnWriteProperties(writer);
    writer.PropertyName("contentPrefab");
    writer.Write(contentPrefab);
}

Notes for modders: - This section depends on the existence of ContentPrerequisiteData and PrefabData components and on the InfoSectionBase's exposed members such as EntityManager, selectedPrefab and m_PrefabSystem. - To change display logic or presentation, consider deriving a new section from InfoSectionBase or modifying this class in a mod (respecting game policies).