Game.Prefabs.CitizenParametersData
Assembly:
Game (or the mod/game assembly where this component is defined)
Namespace:
Game.Prefabs
Type:
struct (value type)
Base:
IComponentData, IQueryTypeParameter
Summary:
Data-only ECS component that holds a set of citizen-related probability/rate parameters used by game systems that simulate family formation, birth, and job-seeking behavior. This component is intended to be attached to entities (for example, prefabs or settings entities) so systems can read these parameters in jobs or queries. All fields are blittable value types suitable for use in Unity's ECS and jobs.
Fields
-
public float m_DivorceRate
Probability/rate of divorce for citizens. Interpreted as a relative probability used by the simulation; the exact unit (per tick, per day, etc.) depends on the consuming systems. Typical normalized range: 0.0 — 1.0 (0% — 100%), but values outside that range will also be accepted by the data type. -
public float m_LookForPartnerRate
Rate at which a citizen looks for a partner. Higher values increase the frequency/probability that the simulation will attempt partner-search logic for an individual. -
public float2 m_LookForPartnerTypeRate
Two-component vector describing type-specific partner search rates. The two components can represent different categories (for example different age groups, genders, or social types) depending on how the consuming system interprets them. Use float2.x and float2.y to access the components. -
public float m_BaseBirthRate
Base birth rate applied by the simulation when evaluating birth events. Acts as the baseline multiplier or probability for births before other modifiers are applied. -
public float m_AdultFemaleBirthRateBonus
Additional birth rate applied specifically to adult female citizens. Treated as a bonus (additive) to the base birth rate when the subject is an adult female. -
public float m_StudentBirthRateAdjust
Adjustment to birth rate for citizens identified as students. This typically decreases (negative values) or increases (positive values) the effective birth probability for the student demographic. -
public float m_SwitchJobRate
Rate/probability that a citizen will attempt to switch jobs. A higher value increases the frequency of job-switching behavior. -
public float m_LookForNewJobEmployableRate
Rate at which employable citizens look for a new job. This is likely used when evaluating job-search behavior for citizens who are able to be employed.
Properties
- None.
This struct exposes only public fields; there are no managed properties. Because it implements IComponentData, it's intended to be used as plain data in ECS queries and AddComponentData/SetComponentData operations.
Constructors
public CitizenParametersData()
(implicit default)
As a struct, it has an implicit default constructor that initializes all floats to 0.0 and float2 to (0,0). Consumers should explicitly set fields to appropriate values before use.
Methods
- None.
This is a pure data container with no methods. All behavior originates from systems that read this component.
Usage Example
// Example: create and attach CitizenParametersData to an entity (EntityManager approach)
using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;
public static class CitizenParametersSetup
{
public static void AddCitizenParameters(EntityManager entityManager, Entity targetEntity)
{
var parameters = new CitizenParametersData
{
m_DivorceRate = 0.02f, // ~2% per simulation unit (interpretation depends on system)
m_LookForPartnerRate = 0.5f,
m_LookForPartnerTypeRate = new float2(0.6f, 0.4f),
m_BaseBirthRate = 0.03f,
m_AdultFemaleBirthRateBonus = 0.01f,
m_StudentBirthRateAdjust = -0.02f,
m_SwitchJobRate = 0.15f,
m_LookForNewJobEmployableRate = 0.25f
};
// Add or set the component on the entity
if (!entityManager.HasComponent<CitizenParametersData>(targetEntity))
entityManager.AddComponentData(targetEntity, parameters);
else
entityManager.SetComponentData(targetEntity, parameters);
}
}
Notes and tips: - This component is designed for read access in systems and jobs; keep it immutable where possible or update rarely to avoid cache thrashing. - Because field units are defined by the consuming systems, prefer normalized ranges (0–1) for probabilities unless you know the system expects different scaling. - Use float2 to pack two closely related rates efficiently (e.g., two demographic types).