Game.Events.AddAccidentSite
Assembly: Assembly-CSharp
Namespace: Game.Events
Type: struct
Base: Implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
AddAccidentSite is a plain data component used as an event marker in the game's ECS to request creation/registration of an accident site (for example a traffic accident, vehicle crash, or related incident). Systems that process accident/events will query for this component, read its data, perform the required game logic (spawn visuals, block lanes, create related game objects/entities), and then typically remove the event component or destroy the event entity. As a blittable struct implementing IComponentData it is suitable for use in jobs and entity queries.
Fields
-
public Unity.Entities.Entity m_Event
This is an Entity that represents the event instance itself. It can be used by processing systems as a handle to the event (for example to mark the event processed, attach child entities, or destroy the event entity after processing). When creating the event entity you commonly set this field to the created entity. -
public Unity.Entities.Entity m_Target
The target Entity affected by the accident. Typical targets include a road segment, vehicle, pedestrian, or building entity that the accident is associated with. Processing systems use this to determine location, affected lanes, or to drive contextual behavior (e.g., spawn roadblocks at the segment). -
public AccidentSiteFlags m_Flags
Flags that describe characteristics of the accident site. AccidentSiteFlags is an enum defined elsewhere in the codebase and encodes modifiers such as severity, whether traffic should be blocked, special handling (pedestrian involved, emergency required), or other qualifiers. Check the AccidentSiteFlags definition for exact flag values and meanings.
Properties
public Unity.Jobs.JobHandle producerHandle { get; private set }
This struct does not define any properties. (Note: the template lists a producerHandle property—this is not present on AddAccidentSite. The component is a plain data struct without properties.)
Constructors
public AddAccidentSite()
No explicit constructors are defined in code. The struct uses the default value-type constructor. Initialize fields directly when creating the component data.
Methods
protected virtual OnCreate() : System.Void
No methods are declared on this struct. Lifecycle and processing logic is implemented in ECS systems that read this component.
Usage Example
// Create an event entity and add the AddAccidentSite component to request an accident site.
// This example uses EntityManager directly.
void SpawnAccidentEvent(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity targetEntity, AccidentSiteFlags flags)
{
// Create a simple event entity (can be a temporary marker)
var eventEntity = entityManager.CreateEntity();
// Add the AddAccidentSite event component. Commonly m_Event is set to the event entity itself.
var eventData = new Game.Events.AddAccidentSite
{
m_Event = eventEntity,
m_Target = targetEntity,
m_Flags = flags
};
entityManager.AddComponentData(eventEntity, eventData);
// A system that processes AddAccidentSite components will pick this up on the next update,
// create the accident site, and then remove or destroy the event entity.
}
Notes and tips: - This component is intended as an ephemeral event marker. Typical processing patterns are: create a short-lived event entity with this component, let the relevant system handle it and then remove the component or destroy the entity. - Use EntityCommandBuffer (ECB) if creating events from a job or structural change within a job to avoid structural changes during iteration. - Because AddAccidentSite implements IComponentData and is blittable, it is efficient to use in Burst-compiled jobs and parallel queries. - To understand exactly what behavior each flag encodes, inspect the AccidentSiteFlags enum definition (it contains the authoritative list of options and meanings).