Game.TriggerLimitData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
TriggerLimitData is a lightweight Unity ECS component used to specify a frame-based interval for limiting how often a trigger (typically on a prefab) can fire. The single field m_FrameInterval represents the number of frames to wait between allowed trigger activations. This component is intended for use with entity systems that evaluate prefab triggers and want to enforce a simple rate limit.
Fields
public uint m_FrameInterval
Number of frames to wait between trigger activations. Interpreted as a frame count (not seconds). A value of 0 commonly means "no enforced delay" (i.e., trigger can run every frame) — systems using this component should define the exact semantics. Use unsigned to allow a larger non-negative range. When adding this to an entity, set to the desired interval (for example, 60 for ~1 second at 60 FPS).
Properties
- No public properties are defined on this struct.
As an IComponentData plain struct, its fields are accessed directly when reading/writing component data.
Constructors
public TriggerLimitData()
Implicit default constructor initializes m_FrameInterval to 0. You can also initialize explicitly when adding the component (see usage example).
Methods
- This struct defines no methods. It is a pure data component intended for use in ECS systems and queries. Because it implements IQueryTypeParameter, it may be used directly in query-type parameters where supported.
Usage Example
// Add the component to an entity with a 60-frame interval
entityManager.AddComponentData(entity, new Game.Prefabs.TriggerLimitData { m_FrameInterval = 60 });
// Example read in a SystemBase update
protected override void OnUpdate()
{
uint currentFrame = (uint)Time.frameCount;
Entities.ForEach((ref Game.Prefabs.TriggerLimitData limitData, in TriggerStateData state) =>
{
// Example logic (systems must store last trigger frame somewhere, e.g. another component)
// if (currentFrame - state.lastTriggeredFrame >= limitData.m_FrameInterval) { ... }
}).Schedule();
}
{{ Additional notes: - Intended usage: rate-limiting trigger evaluation on prefab entities in Cities: Skylines 2 mod systems. - Because this is an IComponentData struct, prefer Burst-compatible and job-friendly access patterns when used in performance-sensitive systems. - Ensure consuming systems define and maintain any auxiliary state required to track the last trigger time (e.g., a separate LastTriggerFrame component). }}