Skip to content

Game.Tutorials.ObjectPlacementTriggerCountData

Assembly:
Assembly-CSharp (typical for game scripts)

Namespace:
Game.Tutorials

Type:
public struct

Base:
System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
A lightweight ECS component used by tutorial systems to track how many objects a player has placed and how many are required to satisfy a placement trigger. Intended for use with Unity DOTS (IComponentData) as part of tutorial progression or trigger evaluation.


Fields

  • public System.Int32 m_RequiredCount
    Holds the number of object placements required to satisfy the trigger. Set at creation (via constructor) and read when evaluating completion.

  • public System.Int32 m_Count
    Tracks the current number of placed objects. Systems should increment this value as the player places relevant objects and write it back to the component.

Properties

This type does not expose any properties; it only contains the two public fields above.

Constructors

  • public ObjectPlacementTriggerCountData(int requiredCount)
    Initializes a new instance with m_RequiredCount set to the provided value and m_Count initialized to 0. Use this to create the component with the required threshold for the placement trigger.

Methods

This struct defines no methods. It is a plain data container (IComponentData) and should be manipulated via EntityManager/ComponentSystem/ISystem APIs (GetComponentData/SetComponentData or component modifications within jobs where applicable).

Usage Example

// Adding the component to an entity with a required count of 3
var data = new ObjectPlacementTriggerCountData(3);
entityManager.AddComponentData(entity, data);

// Incrementing the count in a system (synchronous example)
var comp = entityManager.GetComponentData<ObjectPlacementTriggerCountData>(entity);
comp.m_Count += 1;
entityManager.SetComponentData(entity, comp);

// For DOTS jobified systems, read/modify via appropriate ComponentDataFromEntity or by using system APIs

Notes: - Because this implements IComponentData, it must remain a blittable value type. - If you update m_Count from jobs, ensure proper synchronization (use parallel-friendly patterns or job handles) as with any ECS component updates.