Skip to content

Game.Tutorials.PolicyAdjustmentTriggerData

Assembly: Assembly-CSharp
Namespace: Game.Tutorials

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
PolicyAdjustmentTriggerData is an ECS component used to mark an entity as the source/target of a tutorial trigger related to policy adjustments. It carries two flag fields: one describing which policy-related events or categories triggered the tutorial, and one describing the intended target(s) of the trigger (for example player, city, or UI target). The struct is a plain, blittable value type suitable for use with Unity.Entities queries and systems.


Fields

  • public PolicyAdjustmentTriggerFlags m_Flags
    Holds the policy-related trigger flags. This is typically a bitmask enum (PolicyAdjustmentTriggerFlags) describing which specific policy adjustments or categories caused the trigger (for example tax change, zoning policy change, etc.). Systems can inspect these flags to decide how to respond.

  • public PolicyAdjustmentTriggerTargetFlags m_TargetFlags
    Holds target-related flags (PolicyAdjustmentTriggerTargetFlags). This bitmask enum indicates which target(s) the trigger should apply to or notify (for example the player, the city, a specific UI panel, etc.). Systems and handlers use this to route or filter the trigger.

Properties

  • None. The struct exposes its data as public fields and does not define properties.

Constructors

  • public PolicyAdjustmentTriggerData(PolicyAdjustmentTriggerFlags flags, PolicyAdjustmentTriggerTargetFlags targetFlags)
    Creates a new PolicyAdjustmentTriggerData with the given flag sets. Use this constructor to construct the component before adding it to an entity.

Example:

var data = new PolicyAdjustmentTriggerData(
    PolicyAdjustmentTriggerFlags.TaxChanged | PolicyAdjustmentTriggerFlags.ServicePolicy,
    PolicyAdjustmentTriggerTargetFlags.Player | PolicyAdjustmentTriggerTargetFlags.City
);

Methods

  • None. This type stores data only and does not provide behavior methods. It is intended to be read and handled by ECS systems and job code.

Usage Example

// Add the component to an entity
var triggerData = new PolicyAdjustmentTriggerData(
    PolicyAdjustmentTriggerFlags.TaxChanged,
    PolicyAdjustmentTriggerTargetFlags.Player
);
entityManager.AddComponentData(entity, triggerData);

// Query and handle triggers in a SystemBase
public partial class PolicyTutorialSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .ForEach((Entity e, ref PolicyAdjustmentTriggerData trigger) =>
            {
                if ((trigger.m_Flags & PolicyAdjustmentTriggerFlags.TaxChanged) != 0)
                {
                    // react to tax change trigger...
                }
                // Remove or modify the component after handling if appropriate:
                // EntityManager.RemoveComponent<PolicyAdjustmentTriggerData>(e);
            })
            .WithStructuralChanges() // if you remove components here
            .Run();
    }
}

Notes: - PolicyAdjustmentTriggerFlags and PolicyAdjustmentTriggerTargetFlags are expected to be enum bitmasks (flags). Check their definitions to know available values. - Because the type implements IQueryTypeParameter, it is intended to be used directly in queries/ForEach patterns in the ECS workflow. - This struct is data-only; implement behavior in systems or jobs that read this component and perform the tutorial logic.