Game.Prefabs.TutorialPolicyAdjustmentTriggerPrefab
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: TutorialTriggerPrefabBase
Summary:
Prefab component used to create tutorial triggers that respond to policy adjustments. This prefab exposes two public flag fields (m_Flags and m_TargetFlags) which are packaged into a PolicyAdjustmentTriggerData component and attached to the created entity. The class ensures the PolicyAdjustmentTriggerData component is present on entities created from this prefab and initializes it from the prefab fields. The class is also annotated with a ComponentMenu attribute so it can be added via the Unity editor menus.
Fields
-
public PolicyAdjustmentTriggerFlags m_Flags
Stores the policy adjustment trigger flags that define what kinds of policy changes the trigger reacts to. These flags are passed into the PolicyAdjustmentTriggerData component during initialization. -
public PolicyAdjustmentTriggerTargetFlags m_TargetFlags
Specifies target-related flags for the trigger (which target(s) the policy adjustment should apply to or consider). These are combined with m_Flags when creating the PolicyAdjustmentTriggerData component.
Properties
- None declared on this type. (All behavior is provided via public fields and overridden methods; inherited properties from TutorialTriggerPrefabBase remain available.)
Constructors
public TutorialPolicyAdjustmentTriggerPrefab()
Implicit default constructor. Uses the base class constructor (no custom construction logic in this class).
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds required ECS component types to the provided set so that an entity created from this prefab will have the right component layout. Implementation calls the base method and then adds ComponentType.ReadWrite() to ensure the PolicyAdjustmentTriggerData component is present and modifiable. -
public override void Initialize(EntityManager entityManager, Entity entity)
Called when the prefab is instantiated into an ECS entity. Calls the base Initialize and then sets the PolicyAdjustmentTriggerData component on the entity: entityManager.SetComponentData(entity, new PolicyAdjustmentTriggerData(m_Flags, m_TargetFlags)); This transfers the prefab's flag values into the runtime ECS component used by systems handling tutorial policy adjustments.
Usage Example
// Prefab class (already matches the actual implementation)
[ComponentMenu("Tutorials/Triggers/", new Type[] { })]
public class TutorialPolicyAdjustmentTriggerPrefab : TutorialTriggerPrefabBase
{
public PolicyAdjustmentTriggerFlags m_Flags;
public PolicyAdjustmentTriggerTargetFlags m_TargetFlags;
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
base.GetPrefabComponents(components);
components.Add(ComponentType.ReadWrite<PolicyAdjustmentTriggerData>());
}
public override void Initialize(EntityManager entityManager, Entity entity)
{
base.Initialize(entityManager, entity);
entityManager.SetComponentData(entity, new PolicyAdjustmentTriggerData(m_Flags, m_TargetFlags));
}
}
Notes: - PolicyAdjustmentTriggerData is the runtime ECS component that carries the two flag sets; systems reacting to policy changes will read that component. - The ComponentMenu attribute makes this prefab accessible in Unity's Add Component menu under "Tutorials/Triggers/".