Game.Prefabs.EventData
Assembly:
Game (Assembly-CSharp)
Namespace:
Game.Prefabs
Type:
struct
Base:
System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
EventData is a small ECS component used to describe an event "prefab" in the game's entity system. It stores an EntityArchetype that represents the archetype to be instantiated/used for the event and an integer limit that controls how many concurrent instances of that event are allowed. This component is intended to be attached to entities that represent event definitions or prefabs so systems can query and spawn event instances while respecting the concurrency limit.
Fields
-
public Unity.Entities.EntityArchetype m_Archetype
Holds the archetype describing the entity layout for instances of this event. Systems can use this archetype with an EntityManager to create new event entities matching the expected set of components. -
public int m_ConcurrentLimit
A limit on how many instances of this event may be active at the same time. Systems that spawn events should consult this value to enforce concurrency constraints (for example, not spawning when the current active count >= m_ConcurrentLimit).
Properties
- This type has no properties. It exposes two public fields only.
Constructors
public EventData()
Implicit default constructor. When default-constructed, m_Archetype will be default(EntityArchetype) and m_ConcurrentLimit will be 0. Initialize fields explicitly before use.
Methods
- This struct defines no methods.
Usage Example
// Example: register an event "prefab" and attach EventData to an entity that represents it.
using Unity.Entities;
public void RegisterEventPrefab(EntityManager entityManager)
{
// Create an archetype for event instances (example components)
var eventArchetype = entityManager.CreateArchetype(
typeof(SomeEventComponent),
typeof(TransformComponent),
typeof(LifetimeComponent)
);
// Create an entity to hold the event definition/prefab data
var prefabEntity = entityManager.CreateEntity();
var eventData = new Game.Prefabs.EventData
{
m_Archetype = eventArchetype,
m_ConcurrentLimit = 3
};
entityManager.AddComponentData(prefabEntity, eventData);
// Later, a system can read EventData from prefabEntity and
// create instances using eventData.m_Archetype while enforcing m_ConcurrentLimit.
}