Skip to content

Game.Prefabs.Modes.EconomyParametersMode

Assembly: Assembly-CSharp
Namespace: Game.Prefabs.Modes

Type: class

Base: EntityQueryModePrefab

Summary:
EconomyParametersMode is a mode prefab used to configure and apply global economic parameters in the game's ECS world. It maps inspector-exposed fields to the EconomyParameterData singleton component (an ECS component), allowing modders or game modes to change wages, consumption, efficiencies, refunds, loan rates, and other economy-related tunables. The mode can apply its values to the singleton component at runtime and can restore defaults from an EconomyPrefab via the PrefabSystem.


Fields

  • public float m_ExtractorCompanyExportMultiplier
    Tunable multiplier applied to extractor company exports. Assigned into EconomyParameterData.m_ExtractorCompanyExportMultiplier.

  • public int m_Wage0

  • public int m_Wage1
  • public int m_Wage2
  • public int m_Wage3
  • public int m_Wage4
    Wage tier values for different education/skill levels. These map to corresponding fields on EconomyParameterData.

  • public float m_CommuterWageMultiplier
    Multiplier applied to wages for commuters.

  • public float m_CityServiceWageAdjustment
    Adjustment applied to city service wages.

  • public int m_CompanyBankruptcyLimit
    Threshold for company bankruptcy logic.

  • public int m_ResidentialMinimumEarnings
    Minimum earnings for residential population.

  • public int m_UnemploymentBenefit
    Base unemployment benefit amount.

  • public int m_Pension
    Pension payment amount.

  • public int m_FamilyAllowance
    Family allowance amount.

  • public float2 m_ResourceConsumptionMultiplier
    Multiplier (per resource type) for resource consumption; stored as float2.

  • public float m_ResourceConsumptionPerCitizen
    Base resource consumption per citizen.

  • public float m_TouristConsumptionMultiplier
    Multiplier for tourist consumption.

  • public float m_WorkDayStart
    Work day start time (game time units).

  • public float m_WorkDayEnd
    Work day end time (game time units).

  • public float m_IndustrialEfficiency
    Global industrial efficiency factor.

  • public float m_CommercialEfficiency
    Global commercial efficiency factor.

  • public float m_ExtractorProductionEfficiency
    Extractor production efficiency.

  • public float m_TrafficReduction
    Traffic reduction factor applied by city policies/effects.

  • public float m_MaxCitySpecializationBonus
    Maximum bonus applied for city specialization.

  • public int m_ResourceProductionCoefficient
    Coefficient used for converting resource input to production.

  • public float m_MixedBuildingCompanyRentPercentage
    Rent percentage for mixed-use buildings with companies.

  • public float3 m_LandValueModifier
    Modifiers to land value across categories (stored as float3).

  • public float3 m_RentPriceBuildingZoneTypeBase
    Base rent price per building zone type (float3).

  • public float m_ResidentialUpkeepLevelExponent
    Exponent used in residential upkeep calculations.

  • public float m_CommercialUpkeepLevelExponent
    Exponent used in commercial upkeep calculations.

  • public float m_IndustrialUpkeepLevelExponent
    Exponent used in industrial upkeep calculations.

  • public int m_PerOfficeResourceNeededForIndustrial
    Number of office resources required per industrial unit.

  • public float m_UnemploymentAllowanceMaxDays
    Maximum days for unemployment allowance.

  • public int m_ShopPossibilityIncreaseDivider
    Divider used when computing shop possibility increases.

  • public int m_PlayerStartMoney
    Amount of money a player starts with.

  • public float3 m_BuildRefundPercentage
    Refund percentages for building removal (per category).

  • public float3 m_BuildRefundTimeRange
    Time ranges used to compute build refunds.

  • public float m_RelocationCostMultiplierOverride
    Override multiplier for relocation costs.

  • public float3 m_RoadRefundPercentage
    Refund percentages for roads (per category).

  • public float3 m_RoadRefundTimeRange
    Time ranges used to compute road refunds.

  • public int3 m_TreeCostMultipliers
    Cost multipliers for tree placement/removal (per category).

  • public AnimationCurve m_MapTileUpkeepCostMultiplier
    Curve controlling upkeep cost multiplier per map tile; converted into an AnimationCurve1 when applied to component data.

  • public float2 m_LoanMinMaxInterestRate
    Min and max interest rates for loans.

Properties

  • This class does not declare any public properties. It overrides methods from its base class to implement behavior.

Constructors

  • public EconomyParametersMode()
    No explicit constructor is defined in source; the default parameterless constructor is used. Initialization is driven by inspector values (serialized fields) and the base class constructors.

Methods

  • public override EntityQueryDesc GetEntityQueryDesc()
    Returns an EntityQueryDesc that selects entities with a read-only EconomyParameterData component. This mode targets the EconomyParameterData singleton so that ApplyModeData can set the singleton values.

Behavior: - Creates an EntityQueryDesc with All = [ReadOnly()].

  • protected override void RecordChanges(EntityManager entityManager, Entity entity)
    Records changes for the given entity. Implementation simply reads the EconomyParameterData component (likely to mark the entity as touched for prefab recording or change-tracking).

Parameters: - entityManager: EntityManager to access component data. - entity: The entity whose EconomyParameterData is to be read.

  • public override JobHandle ApplyModeData(EntityManager entityManager, EntityQuery requestedQuery, JobHandle deps)
    Applies the mode's inspector-configured values to the EconomyParameterData singleton component.

Behavior: - Gets the singleton entity via requestedQuery.GetSingletonEntity(). - Reads EconomyParameterData, writes each corresponding field from this prefab (m_... fields) into componentData. - Converts the AnimationCurve m_MapTileUpkeepCostMultiplier to the runtime-friendly AnimationCurve1 via new AnimationCurve1(m_MapTileUpkeepCostMultiplier). - Sets the updated componentData back to the singleton entity via entityManager.SetComponentData. - Returns the incoming JobHandle deps unchanged (this method runs synchronously on main thread, not scheduling jobs).

Notes: - This method is an override intended to be called by the mode/prefab system; it does not schedule jobs and simply returns deps.

  • public override void RestoreDefaultData(EntityManager entityManager, ref NativeArray<Entity> entities, PrefabSystem prefabSystem)
    Restores default economy parameter values from the EconomyPrefab associated with the provided entity.

Behavior: - Uses entities[0] to find the prefab entity. - Fetches the EconomyPrefab instance from prefabSystem.GetPrefab(entity). - Reads EconomyParameterData from entityManager, overwrites fields from the economyPrefab values, and writes the updated componentData back to the entity. - Also converts the prefab's AnimationCurve to AnimationCurve1 for the component.

Parameters: - entityManager: EntityManager to get/set component data. - entities: Array of entities relevant to this prefab (expects the first to reference the Economy prefab). - prefabSystem: PrefabSystem used to obtain the EconomyPrefab defaults.

Usage Example

// Example: programmatically update wages on the mode and apply to the EconomyParameterData singleton.
EconomyParametersMode mode = /* obtain reference to mode prefab instance (e.g. from a loaded prefab) */;
mode.m_Wage0 = 120;
mode.m_Wage1 = 150;

// Suppose you have an EntityManager and an EntityQuery that matches EconomyParameterData (mode.GetEntityQueryDesc()).
EntityQuery query = entityManager.CreateEntityQuery(mode.GetEntityQueryDesc());
JobHandle deps = default;

// Apply values from the mode to the singleton component.
mode.ApplyModeData(entityManager, query, deps);

Notes and tips for modders: - This prefab is intended to be edited in the editor/inspector; values set there will be applied to the game's EconomyParameterData when the mode system calls ApplyModeData. - RestoreDefaultData uses the EconomyPrefab to reset values — useful when implementing a "reset to default" UI. - The conversion to AnimationCurve1 is required because ECS component data cannot directly hold UnityEngine.AnimationCurve; the helper wrapper AnimationCurve1 is used instead. Ensure your custom curves are compatible. - ApplyModeData updates the singleton synchronously and returns the incoming JobHandle unchanged; if you need to perform asynchronous or scheduled work, schedule jobs externally and combine JobHandles as needed.