Skip to content

Game.Tutorials.TutorialActive

Assembly:
Assembly-CSharp

Namespace:
Game.Tutorials

Type:
struct

Base:
IComponentData, IQueryTypeParameter

Summary:
TutorialActive is a tag/marker ECS component (an empty value type) used to mark entities related to an active tutorial state. It is laid out with a fixed size of 1 byte via the StructLayout attribute so it consumes minimal memory and can be used efficiently in queries and archetypes. Implementing IComponentData makes it a Unity.Entities component; implementing IQueryTypeParameter allows it to be used efficiently in query type parameters (e.g., Entities.ForEach or Component queries).


Fields

  • (none)
    This struct has no instance fields. It is intentionally empty and used as a marker component. The source does include the attribute [StructLayout(LayoutKind.Sequential, Size = 1)] which forces a size of 1 byte.

Properties

  • (none)

Constructors

  • public TutorialActive()
    Structs have an implicit parameterless constructor. No explicit constructors are defined in source.

Methods

  • (none)

Usage Example

// Mark an entity as participating in the tutorial
EntityManager.AddComponent<TutorialActive>(entity);

// Check whether an entity is marked
bool isActive = EntityManager.HasComponent<TutorialActive>(entity);

// Remove the marker
EntityManager.RemoveComponent<TutorialActive>(entity);

// Typical use inside a system to operate on entities that have the marker
public partial class TutorialSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .WithAll<TutorialActive>()
            .ForEach((Entity e, in SomeOtherComponent comp) =>
            {
                // handle tutorial-specific logic for this entity
            }).Schedule();
    }
}

Notes: - Because this is a tag component, prefer AddComponent/RemoveComponent or WithAll() queries rather than storing data on it. - The 1-byte layout is an optimization to minimize memory footprint for many tagged entities.