Skip to content

Game.Events.AddCriminal

Assembly:
Assembly-CSharp (game runtime — the assembly containing game code and mod API)

Namespace:
Game.Events

Type:
struct

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

Summary:
Represents an ECS event component used to notify the game that a criminal action should be added/processed. This struct is an IComponentData so it can be attached to entities in the Unity DOTS ECS world and is intended to be used as a lightweight event payload conveying which event entity originated the action, which target entity is affected, and flags describing the criminal action. Typically consumed by systems that process criminal-related events (e.g., law enforcement, citizen behavior, crime tracking).


Fields

  • public Entity m_Event
    The event entity that originated this AddCriminal payload. Consumers can use this to track or complete the event lifecycle (for example, to remove or mark the event entity when processed).

  • public Entity m_Target
    The target entity of the criminal action (for example a citizen, building, vehicle, etc.). Systems processing the event will inspect this to determine what object the criminal behavior affects.

  • public CriminalFlags m_Flags
    Flags describing the nature or parameters of the criminal action. CriminalFlags is an enum (defined in Game.Citizens) that encodes details such as type/severity of crime, modifiers, or behavior hints for processing systems. Use these flags to alter how the event is handled.

Properties

  • None

Constructors

  • None (uses the default value-type constructor)
    You can construct an instance using object-initializer syntax when setting the component data.

Methods

  • None

Usage Example

// Example: creating an AddCriminal event and attaching it to a new entity
using Unity.Entities;
using Game.Citizens;    // for CriminalFlags
using Game.Events;

// inside a system or method with access to an EntityManager (em)
Entity eventEntity = em.CreateEntity(); // optional: create a dedicated event entity
Entity targetEntity = /* obtain target entity reference */;
var addCriminal = new AddCriminal {
    m_Event = eventEntity,
    m_Target = targetEntity,
    m_Flags = CriminalFlags.Pickpocket // example flag; replace with appropriate enum value
};

// Attach the component to an event entity so systems can pick it up
em.AddComponentData(eventEntity, addCriminal);

// Alternatively, create a transient event entity that only carries the component:
Entity transient = em.CreateEntity(typeof(AddCriminal));
em.SetComponentData(transient, addCriminal);

// In jobs/systems, prefer using an EntityCommandBuffer to create and set the component
// so it is safe across threads and frames.

Notes and tips: - As an event component, instances are commonly created on short-lived "event entities" that are consumed by dedicated systems, then destroyed or have the component removed once handled. - Because this type implements IQueryTypeParameter, it is intended to be used within ECS queries/handler patterns; check consumer systems to see how they read and clear the event. - Inspect the CriminalFlags enum (Game.Citizens) to see available options and choose appropriate flags for the criminal action you're generating.