Skip to content

Game.Tutorials.TutorialNextPhase

Assembly: Assembly-CSharp
Namespace: Game.Tutorials

Type: public struct

Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
A simple ECS component that stores a reference to the next tutorial phase as an Entity. Use this component to mark tutorial-related entities with the entity representing the next phase so systems can read the target and trigger transitions. The struct is blittable and safe to use in jobs and entity queries.


Fields

  • public Unity.Entities.Entity m_NextPhase
    Stores the Entity that represents the next tutorial phase. When present on an entity, systems can read this field to determine which phase to activate next.

Properties

  • None.
    This struct exposes a single public field and does not define any properties.

Constructors

  • Default (implicit) constructor: public TutorialNextPhase()
    The default constructor initializes the struct with default values (m_NextPhase will be Entity.Null unless explicitly set).

Methods

  • None.
    This component is a plain data container and does not provide methods. All logic should be implemented in systems that read or write this component.

Usage Example

// Add the component to an entity (EntityManager)
Entity nextPhaseEntity = /* obtain or create the next phase entity */;
Entity tutorialEntity = entityManager.CreateEntity();
entityManager.AddComponentData(tutorialEntity, new TutorialNextPhase { m_NextPhase = nextPhaseEntity });

// Or using an EntityCommandBuffer (preferred in jobs/systems scheduling structural changes)
ecb.AddComponent(tutorialEntity, new TutorialNextPhase { m_NextPhase = nextPhaseEntity });

// Reading the component inside a SystemBase
protected override void OnUpdate()
{
    Entities
        .ForEach((Entity e, ref TutorialNextPhase next) =>
        {
            // Example: if current tutorial finished, enable next phase
            if (ShouldAdvanceTutorial(e))
            {
                ActivateTutorialPhase(next.m_NextPhase);
                // Optionally remove or update this component
            }
        })
        .WithoutBurst()
        .Run();
}

Additional notes: - Because this is an IComponentData and contains an Entity, it is safe and efficient to use in jobs and queries. - Use Entity.Null to represent "no next phase". - Prefer EntityCommandBuffer when adding/removing this component from within jobs or parallel systems to avoid structural change issues.