Skip to content

Game.Prefabs.Modes.GameModeInfoPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes

Type: public class

Base: PrefabBase

Summary:
Prefab that represents a game mode entry (mode settings, display images and localized description rules). It supplies ECS component requirements via GetPrefabComponents (adds GameModeInfoData) and builds a GameModeInfo DTO via GetGameModeInfo(), converting GameModeRule entries into LocalizedString instances (optionally with formatted numeric arguments).


Fields

  • public ModeSetting m_ModeSetting
    Holds a reference to the ModeSetting prefab used to identify this game mode. When constructing the GameModeInfo.id the code uses m_ModeSetting.prefab.name; if m_ModeSetting is null the id becomes an empty string.

  • public string m_Image
    Path or identifier for the main image used for the game mode UI.

  • public string m_DecorateImage
    Path or identifier for an additional/decorative image used in the UI.

  • public GameModeRule[] m_Descriptions
    Array of GameModeRule entries describing rules/parameters for the mode. Each element is converted into a LocalizedString (with optional argument substitution) by GetGameModeInfo().

Properties

  • None declared on this class. (All fields are public instance fields; behavior is exposed via methods.)

Constructors

  • public GameModeInfoPrefab()
    Default parameterless constructor (provided by C#). No custom construction logic in the source file.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds required ECS component types for the prefab. Implementation:
  • Calls base.GetPrefabComponents(components).
  • Adds ComponentType.ReadWrite() to the provided set. This signals that instances of this prefab require a GameModeInfoData component with read/write access.

  • public GameModeInfo GetGameModeInfo()
    Creates and returns a GameModeInfo object populated from the prefab fields:

  • Converts m_Descriptions (if not null) into a LocalizedString[]:
    • For each GameModeRule:
    • If gameModeRule.m_ArgName is empty string, constructs a LocalizedString using LocalizedString.Id("Menu.GAME_MODE_RULES[" + m_Term + "]").
    • Otherwise constructs a LocalizedString with a replacements dictionary mapping the argument name to a LocalizedNumber(m_ArgValue, gameModeRule.GetUnit()) so numeric arguments are localized/formatted using the rule's unit.
  • Sets id to m_ModeSetting.prefab.name (or "" if m_ModeSetting is null).
  • Sets image and decorateImage from m_Image and m_DecorateImage.
  • Uses the constructed descriptions array, or Array.Empty() if m_Descriptions is null.

Notes: - The method relies on GameModeRule containing fields m_Term, m_ArgName, m_ArgValue and a GetUnit() method (not shown here). - Uses Game.UI.Localization.LocalizedString and LocalizedNumber to support localized text with numeric substitutions.

Usage Example

// Example: retrieving a GameModeInfo DTO from a prefab instance
GameModeInfoPrefab prefab = /* obtain prefab instance */;
GameModeInfo info = prefab.GetGameModeInfo();
// info.id, info.image, info.decorateImage, info.descriptions are now populated

// Example: prefab registering required ECS components (internal use by prefab system)
var components = new HashSet<ComponentType>();
prefab.GetPrefabComponents(components);
// components now contains ComponentType.ReadWrite<GameModeInfoData>()