Skip to content

Game.Prefabs.CrimeData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
CrimeData is a component (IComponentData) used to describe configurable parameters for crime-related prefab events in Cities: Skylines 2. It holds the crime type, target selection mode, probability ranges, timing/duration ranges, income impact ranges and incarceration related parameters. Each "Bounds1" field encodes a numeric range (min/max) that the game can sample from when generating an instance of the crime event. This struct is intended to be attached to entities (ECS) that represent crime-capable prefabs or used as a query parameter type (IQueryTypeParameter) when searching entities with crime configuration.


Fields

  • public EventTargetType m_RandomTargetType
    The type of target selection used when picking a victim/target for the crime (enum). Controls whether the crime targets random citizens, vehicles, buildings, etc., depending on the EventTargetType enum values.

  • public CrimeType m_CrimeType
    Specifies the kind of crime this data configures (enum), e.g., theft, vandalism, assault — used to determine behavior, consequences and which game systems respond to the event.

  • public Bounds1 m_OccurenceProbability
    Range ([min, max]) representing the probability that the crime will occur when evaluated. Values are typically in the 0..1 range but follow the game's probability conventions. The game samples from this Bounds1 when deciding whether to spawn the event.

  • public Bounds1 m_RecurrenceProbability
    Range for the probability that the same or similar crime will reoccur (recurrence). Also expressed as a [min, max] range; sampled when determining repeat events.

  • public Bounds1 m_AlarmDelay
    Range describing delay before an alarm or alert is raised for the crime. Units are game time units (commonly seconds) — check game API/other data for exact unit expectations.

  • public Bounds1 m_CrimeDuration
    Range for how long the crime event lasts (duration). Sampled to set the event lifetime; units are game time units.

  • public Bounds1 m_CrimeIncomeAbsolute
    Range for absolute monetary impact of the crime (flat currency amount). Used to compute direct monetary losses for victims or city income adjustments.

  • public Bounds1 m_CrimeIncomeRelative
    Range for relative monetary impact (multiplier or percentage) applied to some base value. Combined with absolute values to determine final income/cost effect.

  • public Bounds1 m_JailTimeRange
    Range for jail time assigned to offenders when sentenced (short-term detention). Units are game time units; sampled to determine how long an offender will be jailed.

  • public Bounds1 m_PrisonTimeRange
    Range for prison time (long-term incarceration) assigned to offenders. Units are game time units; sampled when offenders receive prison sentences.

  • public float m_PrisonProbability
    A single probability (0..1) controlling the chance that an offender is sent to prison rather than a shorter jail sentence. Use with m_JailTimeRange/m_PrisonTimeRange to determine incarceration outcome.

Properties

This struct has no managed properties; it only exposes public fields. It is a plain IComponentData value type intended for direct read/write by ECS systems.

Constructors

  • public CrimeData()
    As a struct, CrimeData has the implicit default constructor which zero-initializes fields. Populate the fields explicitly when creating instances to ensure meaningful ranges and values.

Methods

There are no instance methods defined on CrimeData. It is a plain data container (IComponentData) and is used by systems that implement the logic for sampling Bounds1 values and applying effects.

Usage Example

// Example: create an entity and add CrimeData to it using EntityManager
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var crimeEntity = entityManager.CreateEntity();

// Construct Bounds1 values according to the game/math API; typical constructor: new Bounds1(min, max)
var crimeData = new CrimeData
{
    m_RandomTargetType = EventTargetType.RandomCitizen,
    m_CrimeType = CrimeType.Pickpocket,
    m_OccurenceProbability = new Bounds1(0.1f, 0.25f),    // 10%..25%
    m_RecurrenceProbability = new Bounds1(0.0f, 0.05f),   // 0%..5%
    m_AlarmDelay = new Bounds1(1f, 5f),                   // seconds (example)
    m_CrimeDuration = new Bounds1(10f, 30f),
    m_CrimeIncomeAbsolute = new Bounds1(50f, 200f),       // game currency units
    m_CrimeIncomeRelative = new Bounds1(0.0f, 0.5f),      // multiplier
    m_JailTimeRange = new Bounds1(60f, 300f),             // seconds / game time units
    m_PrisonTimeRange = new Bounds1(3600f, 14400f),
    m_PrisonProbability = 0.15f                           // 15% chance of prison
};

entityManager.AddComponentData(crimeEntity, crimeData);

// Notes:
// - Bounds1 is a small value-range type used throughout the game's math library. Check its API for exact constructors and fields (e.g., Min/Max).
// - Probabilities are typically expected in [0,1]. Timing units (seconds vs in-game ticks) depend on surrounding game systems — inspect other data or code for conventions.
// - Systems that process CrimeData should sample values from each Bounds1 (e.g., using a random float between min and max) to produce concrete, per-event parameters.