Game.Prefabs.Modes.CitizenHappinessParameterMode
Assembly:
Assembly-CSharp
Namespace:
Game.Prefabs.Modes
Type:
class
Base:
EntityQueryModePrefab
Summary:
A Mode prefab component used to configure and apply CitizenHappinessParameterData (the game data that controls citizen happiness and penalties related to pollution, electricity, water, sewage, deaths, homelessness, etc.). Exposed public fields are editable in the prefab inspector (Mode Parameters) and are applied to the game's singleton CitizenHappinessParameterData either from the prefab defaults (RestoreDefaultData) or from the mode instance values (ApplyModeData). The component also defines the entity query that targets CitizenHappinessParameterData so the mode system can locate the relevant singleton entity.
Fields
-
public int m_PollutionBonusDivisor
Sets the divisor used when calculating pollution-related happiness bonuses/penalties. -
public int m_MaxAirAndGroundPollutionBonus
Maximum bonus/penalty applied for air and ground pollution. -
public int m_MaxNoisePollutionBonus
Maximum bonus/penalty applied for noise pollution. -
public float m_ElectricityWellbeingPenaltyMultiplier
Multiplier used to compute wellbeing penalty when electricity is unavailable or insufficient. -
public byte m_ElectricityPenaltyDelayMultiplier
Delay multiplier (as byte) for electricity penalty (Min attribute enforces >= 1 in inspector). Converted to int when stored in component data. -
public AnimationCurve m_ElectricityFeeWellbeingEffect
AnimationCurve controlling how electricity fees affect wellbeing; converted to AnimationCurve1 when written into component data. -
public int m_WaterHealthPenaltyMultiplier
Multiplier applied to health penalties related to water problems. -
public int m_WaterWellbeingPenaltyMultiplier
Multiplier applied to wellbeing penalties related to water problems. -
public byte m_WaterPenaltyDelayMultiplier
Delay multiplier (byte) for water-related penalties (Min attribute enforces >= 1). Converted to int in component data. -
public float m_WaterPollutionMultiplierOverriden
Overrides the water pollution multiplier used when computing water-related effects. -
public int m_SewageHealthEffectMultiplier
Multiplier for health effects due to sewage problems. -
public int m_SewageWellbeingEffectMultiplier
Multiplier for wellbeing effects due to sewage problems. -
public byte m_SewagePenaltyDelayMultiplier
Delay multiplier (byte) for sewage-related penalties (Min attribute enforces >= 1). Converted to int in component data. -
public AnimationCurve m_WaterFeeHealthEffect
AnimationCurve controlling water fee → health effect; converted to AnimationCurve1 in component data. -
public AnimationCurve m_WaterFeeWellbeingEffect
AnimationCurve controlling water fee → wellbeing effect; converted to AnimationCurve1 in component data. -
public int m_HealthProblemHealthPenalty
Health penalty applied for health problems. -
public int m_DeathWellbeingPenalty
Wellbeing penalty applied when deaths occur. -
public int m_DeathHealthPenalty
Health penalty applied when deaths occur. -
public int m_LowWellbeing
Threshold/penalty representing low wellbeing. -
public int m_LowHealth
Threshold/penalty representing low health. -
public int m_PenaltyEffect
Generic penalty effect value (used by happiness system). -
public int m_HomelessHealthEffect
Health effect applied to homeless citizens. -
public int m_HomelessWellbeingEffect
Wellbeing effect applied to homeless citizens.
Properties
- None declared on this class. (Behavior is applied via public fields and component data; query/interaction is handled through EntityQueryModePrefab overrides.)
Constructors
public CitizenHappinessParameterMode()
Default parameterless constructor (no custom initialization in source). Instances are typically created/managed by the prefab system and edited in the inspector.
Methods
-
public override EntityQueryDesc GetEntityQueryDesc()
Returns an EntityQueryDesc that matches a component of type CitizenHappinessParameterData (ReadOnly). This is used by the mode/prefab system to locate the singleton entity holding the happiness parameter data. -
protected override void RecordChanges(EntityManager entityManager, Entity entity)
Called by the mode system to record current state before changes. Implementation reads the current CitizenHappinessParameterData via entityManager.GetComponentData to ensure the data is captured (no modifications are made here). -
public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
Restores the default parameter values from the engine prefab (CitizenHappinessPrefab) into the runtime CitizenHappinessParameterData component of the provided entity. Performs mapping and conversions: - Reads the CitizenHappinessPrefab via prefabSystem.GetPrefab
(entity). - Copies numeric fields and casts byte-prefab delays to int component fields.
- Converts AnimationCurve fields into AnimationCurve1 instances for component storage.
-
Writes the resulting CitizenHappinessParameterData back to the entity via entityManager.SetComponentData.
-
public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
Applies the mode's inspector-set values to the singleton CitizenHappinessParameterData found via requestedQuery.GetSingletonEntity(). Maps public fields into the component, handling conversions (byte → int, AnimationCurve → AnimationCurve1) the same way as RestoreDefaultData. Returns the incoming JobHandle (no additional jobs scheduled here).
Usage Example
// Typical usage: the prefab is added to the Mode Parameters menu in the editor.
// The mode system will call RestoreDefaultData for defaults or ApplyModeData when the mode is activated.
// Example showing how ApplyModeData maps inspector fields into component data is internal to the prefab;
// in code you normally create and configure the prefab in the editor and let the mode system call ApplyModeData.
//
// If you need to trigger ApplyModeData manually (not typical):
EntityQuery query = entityManager.CreateEntityQuery(typeof(CitizenHappinessParameterData));
CitizenHappinessParameterMode modePrefab = /* obtain reference to your prefab/component */;
modePrefab.m_PollutionBonusDivisor = 5; // set desired values in prefab instance
modePrefab.ApplyModeData(entityManager, query, default);
Notes: - AnimationCurve fields are converted to a serializable AnimationCurve1 when written into component data. - Delay multiplier fields are stored as bytes on the prefab but converted to int in the component data. - This class is meant to be edited as a prefab (Mode Parameters) in the editor; the runtime mode/prefab system drives when RestoreDefaultData / ApplyModeData are invoked.