Skip to content

Game.Prefabs.ObsoleteIdentifiers

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

Type: class

Base: ComponentBase

Summary:
ObsoleteIdentifiers is a small ComponentBase-derived class intended to hold a list of legacy/obsolete prefab identifier mappings (PrefabIdentifierInfo entries). It provides hooks (GetPrefabComponents and GetArchetypeComponents) that are invoked by the prefab/archetype processing pipeline so that the component can declare which ECS ComponentType entries are required on the generated prefab or archetype. In the provided source both hooks are empty, so this component by itself does not add any ECS components; it primarily acts as a data container for prefab identifier information and a place to implement migration/compatibility logic if needed.


Fields

  • public PrefabIdentifierInfo[] m_PrefabIdentifiers
    Array of PrefabIdentifierInfo entries. Each element represents an obsolete/legacy identifier mapping or related metadata for prefabs. This field is public so it can be serialized/inspected in editors. The concrete structure and fields of PrefabIdentifierInfo are defined elsewhere in the codebase; typically such types contain the old identifier, replacement identifier, and any flags required for migration.

Properties

  • None
    This class does not declare any public properties. It exposes the identifier data through the public field m_PrefabIdentifiers.

Constructors

  • public ObsoleteIdentifiers()
    No explicit constructor is declared in the source; the default parameterless constructor provided by C# will be used. Initialization of m_PrefabIdentifiers (if needed) should be performed in editor code or by assignment at runtime.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Called by the prefab-building pipeline to let this component add required ComponentType entries to the prefab's component set. In the current implementation this method is empty (no components are added). If you need the prefab to include specific ECS components (for example, an identifier component used at runtime or for migration), add them to the provided HashSet here, e.g.: components.Add(ComponentType.ReadWrite());

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Called by the archetype-building pipeline to let this component add required ComponentType entries to the archetype's component set. As with GetPrefabComponents, the method is empty in the supplied code. Use this method to ensure the entity archetype includes any ECS components required for handling obsolete identifiers at runtime.

Notes on both methods: - Both methods receive a HashSet that should be mutated (components.Add(...)) to declare required components. - Keep additions minimal and deterministic; adding different sets depending on runtime state can lead to inconsistent archetypes. - If you do not need to add runtime ECS components, leaving these methods empty is valid — the component then functions purely as serialized data.

Usage Example

// Example: populate obsolete identifiers in inspector or via code
void SetupObsoleteIdentifiers(ObsoleteIdentifiers o)
{
    o.m_PrefabIdentifiers = new PrefabIdentifierInfo[]
    {
        // PrefabIdentifierInfo structure assumed to have fields like oldId/newId; adjust to actual definition.
        new PrefabIdentifierInfo(/*oldId*/ "old_prefab_name", /*newId*/ "new_prefab_name")
    };
}

// Example: ensure a runtime component is included on prefab/archetype so code processing obsolete identifiers can run
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
    base.GetPrefabComponents(components);
    // Ensure PrefabIdentifierProcessorComponent exists on the prefab's archetype.
    components.Add(ComponentType.ReadWrite<PrefabIdentifierProcessorComponent>());
}

public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
    base.GetArchetypeComponents(components);
    components.Add(ComponentType.ReadWrite<PrefabIdentifierProcessorComponent>());
}

If you plan to implement migration/compatibility logic, implement a small runtime processor/authoring component (e.g., PrefabIdentifierProcessorComponent) and declare it here so the prefab/archetype will contain the necessary ECS data for that processor to run.