Skip to content

Game.Prefabs.UnlockRequirementPrefab

Assembly:
Assembly-CSharp

Namespace: Game.Prefabs

Type:
abstract class

Base:
PrefabBase

Summary:
UnlockRequirementPrefab is an abstract prefab base used to represent a requirement that must be met/unlocked in the game. It exposes a label identifier (m_LabelID) and ensures the associated ECS component (UnlockRequirementData) is included for prefabs that derive from it. This class participates in the prefab component collection process for Unity.Entities-based systems, so derived prefabs automatically include the required data component.


Fields

  • public string m_LabelID
    A string identifier for the requirement's label (likely used to look up a localized label or UI text). This field is public and intended to be set on the prefab to identify the requirement in UI/logic.

Properties

  • None declared on this type.
    Derived types or the PrefabBase may expose additional properties if needed.

Constructors

  • public UnlockRequirementPrefab()
    Implicit default constructor is available. As this is an abstract class it cannot be instantiated directly; concrete subclasses will call the base constructor implicitly.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Collects ECS component types required by this prefab. Implementation details:
  • Calls base.GetPrefabComponents(components) to include any components defined by the PrefabBase.
  • Adds ComponentType.ReadWrite() to the provided set so that instances of this prefab will include the UnlockRequirementData component in the entity archetype.

This method is used at prefab registration time to build the set of ECS components that the prefab's entities must include.

Usage Example

// Example of a concrete prefab deriving from UnlockRequirementPrefab
public class ExampleUnlockRequirementPrefab : UnlockRequirementPrefab
{
    public ExampleUnlockRequirementPrefab()
    {
        // Set the label id used by UI/localization
        m_LabelID = "REQ_BUILD_BRIDGE";
    }

    // Optionally add more components required by this concrete prefab
    public override void GetPrefabComponents(HashSet<ComponentType> components)
    {
        base.GetPrefabComponents(components);

        // e.g. add some custom data component for this requirement
        // components.Add(ComponentType.ReadWrite<ExampleRequirementData>());
    }
}

Notes: - UnlockRequirementData must be a defined ECS component (IComponentData or similar) elsewhere in the codebase; this prefab ensures it is included on the entity. - Because the class is abstract, create concrete subclasses to set m_LabelID and to add any additional components or initialization logic.