Game.Tutorials.TriggerCompleted
Assembly: Assembly-CSharp.dll (typical game assembly; actual assembly name may vary by project)
Namespace: Game.Tutorials
Type: struct
Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
TriggerCompleted is a marker (tag) component used by the tutorial system to mark that a particular tutorial trigger has been completed. It is an empty value type with an explicit StructLayout attribute setting Size = 1 so the type has a non-zero size in memory (common pattern for zero-data ECS components to ensure predictable layout and to satisfy runtime requirements). Because it implements IComponentData it can be added to Entities; implementing IQueryTypeParameter allows it to be used directly in queries/type parameter contexts in Unity's Entities API.
Fields
- This struct defines no instance fields. It is an empty marker component, the size is enforced by the StructLayout attribute.
Properties
- This type has no properties.
Constructors
public TriggerCompleted()
(implicit default)
This is a value type with the implicit default constructor. No explicit constructors are defined.
Methods
- No methods are defined on this struct. It is used purely as a tag component.
Usage Example
// Mark an entity's trigger as completed
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
if (!em.HasComponent<TriggerCompleted>(entity))
{
em.AddComponent<TriggerCompleted>(entity);
}
// Remove the completed mark
if (em.HasComponent<TriggerCompleted>(entity))
{
em.RemoveComponent<TriggerCompleted>(entity);
}
// Querying entities with the TriggerCompleted tag inside a SystemBase
protected override void OnUpdate()
{
Entities
.WithAll<TriggerCompleted>()
.ForEach((Entity e) =>
{
// Handle already-completed tutorial trigger
})
.Schedule();
}
Notes and best practices: - Use this component as a flag only; do not attempt to store state in it. For state, define a non-empty IComponentData. - The StructLayout(Size = 1) attribute ensures the component has non-zero size which helps avoid edge cases in some ECS runtimes that expect non-zero sized components. - Adding or removing this component is inexpensive and intended for marking/toggling completion state on entities representing tutorial triggers.