Skip to content

Game.Prefabs.ProcessingRequirementPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: UnlockRequirementPrefab

Summary:
ProcessingRequirementPrefab is a prefab component used by the unlocking system to express an unlock requirement tied to processed production of a specific resource. When the prefab is initialized into an ECS entity it: - Adds an UnlockRequirement entry to the entity's UnlockRequirement buffer (using UnlockFlags.RequireAll). - Adds and sets a ProcessingRequirementData component on the entity with the resource identifier resolved from the editor selection and the minimum produced amount threshold. This prefab therefore connects an editor-configured resource + threshold to the runtime ECS data used by the unlock/requirement logic.


Fields

  • public ResourceInEditor m_ResourceType
    Holds the resource selection as exposed in the editor. During LateInitialize this is converted to the runtime resource identifier via EconomyUtils.GetResource and stored into the ProcessingRequirementData component.

  • public int m_MinimumProducedAmount = 10000
    The minimum produced amount (threshold) required to satisfy this unlock condition. This value is copied into ProcessingRequirementData.m_MinimumProducedAmount during LateInitialize.

Properties

  • (None declared in this class)
    This prefab does not declare any C# properties; it exposes configuration via public fields intended for the editor/inspector.

Constructors

  • public ProcessingRequirementPrefab()
    Default constructor (implicit). Typical usage is via Unity prefab instantiation; no custom construction logic is present in this class.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Overrides the base to collect any prefab dependencies. This implementation just calls base.GetDependencies(prefabs) and does not add extra dependencies.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Calls the base implementation and then adds the ECS component type ProcessingRequirementData to the component set: components.Add(ComponentType.ReadWrite());
    This informs the prefab system that entities created from this prefab will include a ProcessingRequirementData component.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Finalizes entity initialization for the prefab. This method:

  • Calls base.LateInitialize(entityManager, entity).
  • Adds a new UnlockRequirement entry to the entity's UnlockRequirement buffer with UnlockFlags.RequireAll.
  • Resolves the editor resource to the runtime resource via EconomyUtils.GetResource(m_ResourceType) and writes a ProcessingRequirementData component to the entity with the resolved resource and m_MinimumProducedAmount. This is where the editor-configured data is converted and applied to the ECS entity.

Usage Example

// Example showing what LateInitialize does at runtime for a ProcessingRequirementPrefab instance:
public override void LateInitialize(EntityManager entityManager, Entity entity)
{
    base.LateInitialize(entityManager, entity);

    // Adds unlock buffer entry (RequireAll)
    entityManager.GetBuffer<UnlockRequirement>(entity).Add(new UnlockRequirement(entity, UnlockFlags.RequireAll));

    // Convert editor resource to runtime resource and set the ProcessingRequirementData
    entityManager.SetComponentData(entity, new ProcessingRequirementData
    {
        m_ResourceType = EconomyUtils.GetResource(m_ResourceType),
        m_MinimumProducedAmount = m_MinimumProducedAmount
    });
}

{{ Additional notes: - ProcessingRequirementData and UnlockRequirement are runtime ECS types expected by the unlocking and economy systems. Ensure those components are present/defined in your mod environment. - m_ResourceType is a designer/editor field and must be a valid resource recognized by EconomyUtils.GetResource; otherwise the resolved value may be invalid at runtime. - This prefab is intended to be placed/configured in the game's prefab/asset pipeline (inspector), not constructed manually at runtime. }}