Game.Tutorials.TutorialPhaseActive
Assembly:
Assembly-CSharp (game)
Namespace:
Game.Tutorials
Type:
struct
Base:
System.ValueType, implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
A lightweight tag/marker component used by the game's tutorial systems to indicate that a particular tutorial phase is active on an entity or in a query. The struct is explicitly laid out with Size = 1 to minimize memory usage (one-byte marker). Because it implements IComponentData it can be added to entities, and as IQueryTypeParameter it can be used as a query parameter/type filter in ECS queries.
Fields
- (none)
This is an empty marker struct; no data fields are defined. The StructLayout(Size = 1) attribute reserves one byte for layout but no explicit fields are present.
Properties
- (none)
No properties are defined — this type is a pure tag.
Constructors
- (implicit) public TutorialPhaseActive()
{{ This is a default parameterless value-type constructor provided by C#. You create the tag by using "new TutorialPhaseActive()" when adding it to an entity. Because the struct contains no fields, the default instance carries no payload; it simply serves as a presence flag. }}
Methods
- (none)
No methods are defined on this struct.
Usage Example
using Unity.Entities;
using Game.Tutorials;
public partial class TutorialPhaseSystem : SystemBase
{
protected override void OnCreate()
{
// Optionally create an archetype that includes the tag
EntityArchetype archetype = EntityManager.CreateArchetype(
typeof(Translation), // example other component
typeof(TutorialPhaseActive)
);
// Create an entity with the tag
Entity tutorialEntity = EntityManager.CreateEntity(archetype);
}
protected override void OnUpdate()
{
// Query entities that have the tutorial-phase-active tag
Entities
.WithAll<TutorialPhaseActive>()
.ForEach((Entity entity) =>
{
// Do tutorial-phase-related work for this entity
})
.Schedule();
}
void ExampleAddRemove(Entity e)
{
// Add the tag to an existing entity
EntityManager.AddComponentData(e, new TutorialPhaseActive());
// Check for the tag
bool has = EntityManager.HasComponent<TutorialPhaseActive>(e);
// Remove the tag when phase ends
if (has)
EntityManager.RemoveComponent<TutorialPhaseActive>(e);
}
}
Notes: - Use this as a tag (presence/absence) rather than storing state. If you need payload data for the tutorial phase, create a separate component with fields. - The StructLayout attribute (Size = 1) helps keep memory overhead minimal for large numbers of entities.