Game.Tutorials.TutorialFireActivationSystem
Assembly: Assembly-CSharp.dll
Namespace: Game.Tutorials
Type: class
Base: GameSystemBase
Summary:
System that detects active building and forest fires and activates the corresponding tutorial entities. It watches for entities with OnFire + Building (or Tree) and, when a matching tutorial entity (BuildingFireActivationData or ForestFireActivationData) exists that is not yet activated or completed, it adds a TutorialActivated component to those tutorial entities via a modification barrier (ModificationBarrier4). The system uses EntityQuery.IsEmptyIgnoreFilter checks to avoid unnecessary command buffer creation and performs the component additions at playback using EntityQueryCaptureMode.AtPlayback. The class is decorated with [Preserve] on lifecycle methods to avoid code stripping.
Fields
-
protected EntityCommandBufferSystem m_BarrierSystem
Used to create an EntityCommandBuffer for applying structural changes (adding TutorialActivated) safely from the system's update. Initialized to the world's ModificationBarrier4 system in OnCreate. -
private EntityQuery m_BuildingFireQuery
EntityQuery selecting entities currently on fire that represent buildings. Composed of ComponentType.ReadOnly, ComponentType.ReadOnly , and excludes Temp and Deleted. Used to detect active building fires. -
private EntityQuery m_ForestFireQuery
EntityQuery selecting entities currently on fire that represent trees/forest. Composed of ComponentType.ReadOnly, ComponentType.ReadOnly , and excludes Temp and Deleted. Used to detect active forest fires. -
private EntityQuery m_BuildingFireTutorialQuery
EntityQuery selecting tutorial entities that correspond to building-fire tutorial activation (BuildingFireActivationData) and that are not already activated or completed. Excludes TutorialActivated and TutorialCompleted. -
private EntityQuery m_ForestFireTutorialQuery
EntityQuery selecting tutorial entities that correspond to forest-fire tutorial activation (ForestFireActivationData) and that are not already activated or completed. Excludes TutorialActivated and TutorialCompleted.
Properties
- This type does not declare any public properties.
Constructors
public TutorialFireActivationSystem()
Default parameterless constructor. Present and annotated with [Preserve] in the source to prevent stripping, but contains no custom initialization beyond what OnCreate performs.
Methods
protected override void OnCreate() : System.Void
Initializes the system:- Calls base.OnCreate().
- Retrieves the ModificationBarrier4 system from the world and stores it in m_BarrierSystem.
-
Creates the EntityQueries used by the system:
- m_BuildingFireQuery: OnFire + Building, excludes Temp and Deleted.
- m_ForestFireQuery: OnFire + Tree, excludes Temp and Deleted.
- m_BuildingFireTutorialQuery: BuildingFireActivationData, excludes TutorialActivated and TutorialCompleted.
- m_ForestFireTutorialQuery: ForestFireActivationData, excludes TutorialActivated and TutorialCompleted. Method is annotated with [Preserve].
-
protected override void OnUpdate() : System.Void
Per-frame logic: - Checks whether there are any forest fires and any forest-fire tutorial entities not yet activated/completed (using IsEmptyIgnoreFilter).
- Checks similarly for building fires and building-fire tutorial entities.
- If either condition is true, creates an EntityCommandBuffer from m_BarrierSystem.
-
Adds the TutorialActivated component to matched tutorial entities using entityCommandBuffer.AddComponent
(entityQuery, EntityQueryCaptureMode.AtPlayback). This defers structural changes until the barrier system plays back the recorded commands. -
public TutorialFireActivationSystem()
Public constructor (same as above; present and [Preserve] attributed in the source).
Usage Example
// Example: create a tutorial entity that will be activated once a building catches fire.
// The TutorialFireActivationSystem will add TutorialActivated to this entity automatically
// when it detects a Building entity with OnFire.
Entity tutorialEntity = EntityManager.CreateEntity();
EntityManager.AddComponentData(tutorialEntity, new BuildingFireActivationData { /* fill fields as needed */ });
// Later, when a Building entity receives an OnFire component (and the Building is not Temp/Deleted),
// the TutorialFireActivationSystem will add the TutorialActivated component to tutorialEntity
// (unless TutorialCompleted is already present), using the ModificationBarrier4 command buffer.
Additional notes: - The system uses EntityQuery.IsEmptyIgnoreFilter to ignore transient filters and detect the presence of relevant entities efficiently. - Structural changes are issued via a ModificationBarrier4-backed EntityCommandBuffer and applied at playback to ensure thread-safety and correct order with other systems. - The [Preserve] attributes on lifecycle methods and constructor prevent the methods from being stripped by linkers or build optimizers.