Game.Tutorials.TutorialDeactivationSystemBase
Assembly: Assembly-CSharp (game code / modding assembly)
Namespace: Game.Tutorials
Type: abstract class
Base: Game.Common.GameSystemBase
Summary:
Base system for tutorial-phase deactivation logic. This abstract system prepares a query that finds tutorial phases which are both active and marked as able to deactivate, and provides a reference to the modification/command buffer barrier system (ModificationBarrier3) so derived systems can make structural changes safely. It encapsulates common setup so derived tutorial deactivation systems can focus on deactivation logic and scheduling commands.
Fields
-
private Unity.Entities.EntityQuery m_ActivePhaseQuery
Holds an EntityQuery that selects entities with TutorialPhaseData, TutorialPhaseActive and TutorialPhaseCanDeactivate components. Used to test whether any phases are currently active and eligible for deactivation. -
protected Unity.Entities.EntityCommandBufferSystem m_BarrierSystem
Reference to the world’s ModificationBarrier3 (an EntityCommandBufferSystem). Derived systems should use this to create/record EntityCommandBuffer operations (or schedule jobs that use command buffers) so structural changes are applied at the appropriate sync point.
Properties
protected bool phaseCanDeactivate { get; }
Computed read-only property. Returns true when the m_ActivePhaseQuery is non-empty (i.e., there exists at least one active tutorial phase that can be deactivated). Note: the name indicates the presence of phases eligible for deactivation; it does not perform any deactivation itself.
Constructors
protected TutorialDeactivationSystemBase()
Parameterless protected constructor. The class does no special construction work beyond what GameSystemBase provides; initialization is performed in OnCreate.
Methods
protected override void OnCreate() : System.Void
Initializes the system:- Retrieves or creates the ModificationBarrier3 system from the world and stores it in m_BarrierSystem.
- Builds m_ActivePhaseQuery to select entities with TutorialPhaseData, TutorialPhaseActive and TutorialPhaseCanDeactivate components. This method is marked with [Preserve] in the source to avoid stripping by the linker. Derived systems should call base.OnCreate() in their overrides.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate(); // sets up m_BarrierSystem and m_ActivePhaseQuery
}
// Example OnUpdate in a derived system:
protected override void OnUpdate()
{
// If any active phases can deactivate, perform deactivation logic
if (phaseCanDeactivate)
{
var ecb = m_BarrierSystem.CreateCommandBuffer(); // record structural changes
// Example: add a component to mark phase as deactivated, or remove TutorialPhaseActive
// ecb.RemoveComponent<TutorialPhaseActive>(entity);
// ecb.AddComponent(entity, new TutorialPhaseDeactivated { ... });
// If scheduling jobs that write to command buffer, use m_BarrierSystem.CreateCommandBuffer().ToConcurrent() etc.
}
}
Notes and best practices: - Use m_BarrierSystem to record structural changes rather than applying them immediately. - The query built in OnCreate uses ReadOnly component types for efficient matching; if you need different filters, adjust or create a new query in the derived system. - Respect the ECS update model (jobs / main-thread) when creating or scheduling work that uses the barrier.