Skip to content

Game.Prefabs.ForceTutorialCompletion

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
class

Base:
ComponentBase

Summary:
A prefab component used during prefab conversion to ensure an ECS component (Game.Tutorials.ForceTutorialCompletion) is added to the resulting entity prefab. This class is intended for use with tutorial-related prefabs (see ComponentMenu attribute which places it under "Tutorials/" and registers it alongside TutorialPhasePrefab). It does not add any archetype-level components and only contributes the tutorial completion marker component to the prefab.


Fields

  • None.
    There are no instance or static fields declared in this class.

Properties

  • None.
    No explicit properties are defined on this class.

Constructors

  • public ForceTutorialCompletion()
    The default parameterless constructor is implicit. The class does not perform any initialization in ctor.

Methods

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    This override is intentionally empty — the component does not add any archetype-level components to the entity archetype during conversion.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the ECS component to the prefab conversion set: components.Add(ComponentType.ReadWrite()); This ensures the resulting prefab entity will include a writable Game.Tutorials.ForceTutorialCompletion component, which is typically used by the tutorial system to mark/force completion for a tutorial phase.

Notes: - ComponentType.ReadWrite() is used so the component is added in read-write access mode. - The component being added belongs to the Game.Tutorials namespace.

Usage Example

using System;
using System.Collections.Generic;
using Game.Tutorials;
using Unity.Entities;

namespace Game.Prefabs
{
    [ComponentMenu("Tutorials/", new Type[] { typeof(TutorialPhasePrefab) })]
    public class ForceTutorialCompletion : ComponentBase
    {
        public override void GetArchetypeComponents(HashSet<ComponentType> components)
        {
            // No archetype components required
        }

        public override void GetPrefabComponents(HashSet<ComponentType> components)
        {
            // Add the tutorial completion ECS component to the prefab entity
            components.Add(ComponentType.ReadWrite<Game.Tutorials.ForceTutorialCompletion>());
        }
    }
}

Additional information: - Attach this component to a prefab that represents a tutorial phase when you want the resulting entity to carry the ForceTutorialCompletion marker. - Because this only marks the prefab with the ECS component, the actual behavior (forcing tutorial completion) is implemented elsewhere in the tutorial system (systems that react to Game.Tutorials.ForceTutorialCompletion). Use cautiously to avoid unintended forced completions.