Skip to content

Game.Prefabs.DlcRequirement

Assembly: Assembly-CSharp (inferred)
Namespace: Game.Prefabs

Type: class

Base: ContentRequirementBase

Summary:
DlcRequirement is a content-requirement component used by content prefabs (e.g., ContentPrefab, UIWhatsNewPanelPrefab) to require ownership of a specific DLC. It is annotated with a ComponentMenu attribute so it appears under "Prefabs/Content/" in the editor. The class stores a DlcId identifying the required DLC, returns a human-readable debug string for the DLC, and checks DLC ownership using PlatformManager. It intentionally does not add any ECS components to prefab or archetype component sets.


Fields

  • public DlcId m_Dlc
    Holds the identifier of the required DLC. DlcId is an enum/type defined elsewhere in the game code that enumerates available DLCs. This field is used by GetDebugString and CheckRequirement.

Properties

  • This class exposes no public properties.

Constructors

  • public DlcRequirement()
    No explicit constructor is defined in source; the default parameterless constructor is used. Initialization is typically done by the prefab system or by setting m_Dlc directly.

Methods

  • public override string GetDebugString()
    Returns a human-readable name of the required DLC, as reported by PlatformManager, with a " DLC" suffix. Implementation:
  • Calls PlatformManager.instance.GetDlcName(m_Dlc)
  • Calls Nicify() on the returned name string
  • Appends " DLC"

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Empty implementation. This requirement does not add any runtime ECS components to the prefab's component set.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Empty implementation. This requirement does not add any components to the generated ECS archetype.

  • public override bool CheckRequirement()
    Checks whether the DLC denoted by m_Dlc is owned by the current platform/user. Implementation uses PlatformManager.instance.IsDlcOwned(m_Dlc) and returns that boolean.

Additional notes: - The class is decorated with [ComponentMenu("Prefabs/Content/", new Type[] { typeof(ContentPrefab), typeof(UIWhatsNewPanelPrefab) })], which controls where the component appears in editor menus and indicates typical prefab owners. - The class relies on PlatformManager (singleton) for DLC name lookup and ownership checks.

Usage Example

// Create and use DlcRequirement in code (typical usage is as a component on a prefab)
var requirement = new DlcRequirement();
requirement.m_Dlc = DlcId.SomeDlc; // set to the desired DLC enum value

// Debug string for logging/display
string debug = requirement.GetDebugString(); // e.g. "My Expansion DLC"

// Check whether the requirement is satisfied
if (requirement.CheckRequirement())
{
    // DLC is owned — enable or show content
}
else
{
    // DLC not owned — hide or lock content
}