Game.Prefabs.CitizenHappinessPrefab
Assembly:
Namespace: Game.Prefabs
Type: class
Base: PrefabBase
Summary:
Prefab class that defines all configurable citizen happiness/health parameters used by the game simulation (pollution, utilities, welfare, crime, taxation effects, etc.). Exposed as inspector-editable fields and converted into a CitizenHappinessParameterData component on the prefab entity during LateInitialize so systems can read the runtime parameters.
Fields
-
public int m_PollutionDivisor = 600
Divisor used when computing pollution impact on citizens. -
public int m_MaxAirAndGroundPollution = 50
Maximum effect for air & ground pollution. -
public int m_MaxNoisePollution = 15
Maximum effect for noise pollution. -
public float m_ElectricityWellbeingPenalty = 20f
How much lack of electricity reduces citizen well-being. -
public byte m_ElectricityPenaltyDelay = 32
Delay (in ticks, ~1.42 in-game minutes per tick) until the electricity penalty is fully applied. Min attribute enforces >= 1. -
public AnimationCurve m_ElectricityFeeWellbeingEffect
Curve describing how electricity fee (0–200%) affects well-being. -
public int m_WaterHealthPenalty = 20
Health penalty for lack of water. -
public int m_WaterWellbeingPenalty = 20
Well-being penalty for lack of water. -
public byte m_WaterPenaltyDelay = 32
Delay (ticks) for water penalty application. Min enforced. -
public float m_WaterPollutionMultiplier = -10f
Multiplier describing how water pollution affects health (negative reduces health). -
public int m_SewageHealthEffect = 10
Health effect for lack of sewage treatment. -
public int m_SewageWellbeingEffect = 20
Well-being effect for lack of sewage treatment. -
public byte m_SewagePenaltyDelay = 32
Delay (ticks) for sewage penalty application. Min enforced. -
public AnimationCurve m_WaterFeeHealthEffect
Curve describing how water fee (0–200%) affects health. -
public AnimationCurve m_WaterFeeWellbeingEffect
Curve describing how water fee (0–200%) affects well-being. -
public int4 m_WealthyMoneyAmount = new int4(0, 1000, 3000, 5000)
Wealth-level thresholds (Wretched, Poor, Modest, Comfortable). Above Comfortable is Wealthy. -
public float m_HealthCareHealthMultiplier = 2f
Multiplier for how health care affects citizen health. -
public float m_HealthCareWellbeingMultiplier = 0.8f
Multiplier for how health care affects citizen well-being. -
public float m_EducationWellbeingMultiplier = 3f
Multiplier for how education affects well-being. -
public float m_NeutralEducation = 5f
Neutral education baseline. -
public float m_EntertainmentWellbeingMultiplier = 20f
Multiplier for entertainment's effect on well-being. -
public int m_NegligibleCrime = 5000
Crime below this has no effect on well-being. -
public float m_CrimeMultiplier = 0.0004f
Multiplier for crime impact on well-being. -
public int m_MaxCrimePenalty = 30
Cap for crime-related well-being penalty. -
public float m_MailMultiplier = 2f
Multiplier for mail-related effects. -
public int m_NegligibleMail = 25
Mail metric below this is negligible. -
public float m_TelecomBaseline = 0.3f
Baseline telecom metric. -
public float m_TelecomBonusMultiplier = 10f
Multiplier applied for telecom bonuses. -
public float m_TelecomPenaltyMultiplier = 20f
Multiplier applied for telecom penalties. -
public float m_WelfareMultiplier = 2f
Welfare multiplier affecting citizens. -
public int m_HealthProblemHealthPenalty = 20
Health penalty when health problems are present. -
public int m_DeathWellbeingPenalty = 20
Well-being penalty applied on death events. -
public int m_DeathHealthPenalty = 10
Health penalty applied on death events. -
public float m_ConsumptionMultiplier = 1f
General consumption multiplier. -
public int m_LowWellbeing = 40
Threshold used for stats to divide low well-being citizens. -
public int m_LowHealth = 40
Threshold for low health. -
public float m_TaxUneducatedMultiplier = -0.25f
Tax effect multipliers for different education tiers. -
public float m_TaxPoorlyEducatedMultiplier = -0.5f
-
public float m_TaxEducatedMultiplier = -1f
-
public float m_TaxWellEducatedMultiplier = -1.5f
-
public float m_TaxHighlyEducatedMultiplier = -2f
-
public int m_PenaltyEffect = -30
Temporary penalty for teleporting due to traffic problems. -
public int m_HomelessHealthEffect = -20
Health effect for homelessness. -
public int m_HomelessWellbeingEffect = -20
Well-being effect for homelessness.
Properties
- None declared in this prefab class. (All parameters are exposed as public fields and later converted to a component.)
Constructors
public CitizenHappinessPrefab()
No explicit constructor defined in code — uses default constructor. Initialization of default field values is done inline.
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the read/write requirement for CitizenHappinessParameterData to the prefab components set. This ensures the prefab entity will include that component type. -
public override void LateInitialize(EntityManager entityManager, Entity entity)
Called after prefab creation. This method converts all prefab field values into a CitizenHappinessParameterData instance and writes it into the provided entity via entityManager.SetComponentData(...). AnimationCurve fields are wrapped into AnimationCurve1 prior to being stored. This is the key method that exposes the inspector-configured values to ECS systems.
Usage Example
// Typical pattern: after the prefab's LateInitialize has run you can read the parameter data:
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity prefabEntity = /* obtain the prefab entity for the citizen happiness prefab */;
// Read the component written by LateInitialize:
CitizenHappinessParameterData data = entityManager.GetComponentData<CitizenHappinessParameterData>(prefabEntity);
// Example: read electricity penalty delay
int electricityDelay = data.m_ElectricityPenaltyDelay;
Notes: - The prefab is intended to be edited in the inspector (ComponentMenu attribute present) to tune gameplay. - LateInitialize maps all public fields to the runtime CitizenHappinessParameterData component; modifying the prefab fields in editor affects simulation behavior after the prefab is (re)loaded.