Game.Prefabs.TutorialHealthProblemActivation
Assembly: Game
Namespace: Game.Prefabs
Type: class
Base: TutorialActivation
Summary:
TutorialHealthProblemActivation is a prefab component used by the tutorial system to activate a tutorial objective when a specified number of citizens exhibit one or more health problems. The component exposes configuration fields (HealthProblemFlags and required count) which are written into the ECS entity as a HealthProblemActivationData component during prefab initialization. It contributes a ReadOnly
Fields
-
public HealthProblemFlags m_Flags
Holds the set of health problem flags to require (bitmask). This determines which kinds of health issues count toward the activation goal. -
public int m_RequiredCount = 10
Number of citizens with the specified health problems required to trigger activation. Defaults to 10.
Properties
- This type does not declare public properties.
Constructors
public TutorialHealthProblemActivation()
Default constructor (implicitly provided). No custom construction logic is defined in this class.
Methods
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Override left empty. The method can be used to add component types required by the archetype used to spawn this prefab; in this implementation nothing extra is added here. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the ReadOnlycomponent type to the provided components set by calling the base implementation and then: components.Add(ComponentType.ReadOnly ());
This ensures the prefab archetype includes the HealthProblemActivationData component in a read-only form. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab instance is initialized in the ECS world. This implementation calls base.Initialize(...) and then writes a HealthProblemActivationData component to the entity using the configured fields: entityManager.SetComponentData(entity, new HealthProblemActivationData { m_Require = m_Flags, m_RequiredCount = m_RequiredCount });
This copies the prefab configuration into the runtime component so systems can evaluate activation conditions.
Usage Example
// Example: the prefab will write its configuration into the entity on Initialize.
// The class already implements this, but here is the essential behavior shown explicitly.
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
entityManager.SetComponentData(entity, new HealthProblemActivationData
{
m_Require = m_Flags, // HealthProblemFlags chosen in the prefab inspector
m_RequiredCount = m_RequiredCount
});
}
// Example of configuring the prefab in code (or via the Inspector):
var prefab = /* obtain TutorialHealthProblemActivation prefab instance */;
prefab.m_Flags = HealthProblemFlags.Pollution | HealthProblemFlags.Disease;
prefab.m_RequiredCount = 20;
Additional notes: - HealthProblemFlags is expected to be an enum/bitmask defined elsewhere in the game code that enumerates health problem types. - HealthProblemActivationData is an ECS component struct (with fields such as m_Require and m_RequiredCount) consumed by tutorial or monitoring systems; ensure systems reading that component expect the same field names/types.