Game.OutsideTradeParameterData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary:
Represents outside-trade related parameters used by the game's outside-connection and trade systems. This component stores per-city multipliers, prices and service fees for importing/exporting resources (electricity, water, sewage) and for various transported goods/services (ambulance, hearse, fire, garbage, police). It also contains weight and distance multipliers for different outside connection transport types (Air, Road, Train, Ship). Modders can attach or query this component to control outside-trade costs and availability for a city.
Fields
-
public float m_ElectricityImportPrice
Price (fee) for importing electricity from outside connections. -
public float m_ElectricityExportPrice
Price (payment/fee) for exporting electricity to outside connections. -
public float m_WaterImportPrice
Price for importing water. -
public float m_WaterExportPrice
Price for exporting water. -
public float m_WaterExportPollutionTolerance
Tolerance factor related to exporting polluted water (sewage/wastewater). Controls pollution constraints for water exports. -
public float m_SewageExportPrice
Price for exporting sewage (sewage sold to outside connections). -
public float m_AirWeightMultiplier
Weight multiplier applied for transport cost calculations when using Air outside connections. -
public float m_RoadWeightMultiplier
Weight multiplier for Road outside connections. -
public float m_TrainWeightMultiplier
Weight multiplier for Train outside connections. -
public float m_ShipWeightMultiplier
Weight multiplier for Ship outside connections. -
public float m_AirDistanceMultiplier
Distance multiplier applied for transport cost calculations when using Air outside connections. -
public float m_RoadDistanceMultiplier
Distance multiplier for Road outside connections. -
public float m_TrainDistanceMultiplier
Distance multiplier for Train outside connections. -
public float m_ShipDistanceMultiplier
Distance multiplier for Ship outside connections. -
public float m_AmbulanceImportServiceFee
Import service fee for ambulance-related outside services. -
public float m_HearseImportServiceFee
Import service fee for hearse (burial/transport of dead) outside services. -
public float m_FireEngineImportServiceFee
Import service fee for fire engine services. -
public float m_GarbageImportServiceFee
Import service fee for garbage collection services. -
public float m_PoliceImportServiceFee
Import service fee for police services. -
public int m_OCServiceTradePopulationRange
Population range parameter used when determining if service-type outside trade is available (affects service trade eligibility based on population).
Properties
- This struct exposes no C# properties. It is a plain IComponentData with public fields.
Constructors
public OutsideTradeParameterData()
Struct has the default parameterless constructor provided by C#. Use field initializers or object initializer syntax to set values when creating an instance.
Methods
-
private float GetDistanceCostSingle(OutsideConnectionTransferType type)
Returns the distance multiplier for a single outside connection transfer type. Maps OutsideConnectionTransferType.Air/Road/Train/Ship to the corresponding m_*DistanceMultiplier fields. Unknown/default types return 0f. -
public float GetDistanceCost(OutsideConnectionTransferType type)
Intended to compute the effective distance cost for the given transfer type. Implementation initializes num = float.MaxValue and loops with a bit-shifting index (1; index < 32; index <<= 1) computing math.min(num, GetDistanceCostSingle(type)). Because GetDistanceCostSingle does not depend on the loop index, this method effectively returns the same value as GetDistanceCostSingle(type). Returns float.MaxValue if no mapping exists (but GetDistanceCostSingle returns 0f for unknown types, so effective result is that 0f is returned for unknowns).
Note for modders: the looping pattern suggests the original intent might have been to evaluate multiple flags/bits (e.g., bitmask of transfer types), but as implemented it just returns the single-type multiplier. If you need multi-flag behavior, adjust the implementation accordingly.
-
private float GetWeightCostSingle(OutsideConnectionTransferType type)
Returns the weight multiplier for a single transfer type, mapping to m_*WeightMultiplier. Unknown/default types return 0f. -
public float GetWeightCost(OutsideConnectionTransferType type)
Same loop pattern as GetDistanceCost; effectively returns the value from GetWeightCostSingle(type). -
public float GetFee(PlayerResource resource, bool export = false)
Returns the applicable fee for the given PlayerResource. Behavior: - PlayerResource.Electricity: returns m_ElectricityImportPrice if export == false, otherwise m_ElectricityExportPrice.
- PlayerResource.Water: returns m_WaterImportPrice if import, otherwise m_WaterExportPrice.
- PlayerResource.Sewage: returns m_SewageExportPrice if import==false (i.e., export==false?), and returns 0f for export. (Implementation: case Sewage: if (!export) return m_SewageExportPrice; return 0f;)
- All other resources: returns 0f.
Note: The Sewage branch uses m_SewageExportPrice for non-export case, which may be semantically confusing — verify intent in caller code when using this method.
-
public bool Importable(PlayerResource resource)
Returns true if GetFee(resource) != 0f. Use to check whether a resource can be imported based on configured price (non-zero price indicates import allowed). -
public bool Exportable(PlayerResource resource)
Returns true if GetFee(resource, export: true) != 0f. Use to check whether a resource can be exported.
Usage Example
// Example: create and use an OutsideTradeParameterData instance
var trade = new OutsideTradeParameterData
{
m_ElectricityImportPrice = 1.2f,
m_ElectricityExportPrice = 0.8f,
m_WaterImportPrice = 0.5f,
m_WaterExportPrice = 0.4f,
m_SewageExportPrice = 0.3f,
m_AirDistanceMultiplier = 2.0f,
m_RoadDistanceMultiplier = 1.0f,
m_TrainDistanceMultiplier = 1.5f,
m_ShipDistanceMultiplier = 1.8f,
m_AirWeightMultiplier = 2.5f,
m_RoadWeightMultiplier = 1.0f,
m_TrainWeightMultiplier = 1.3f,
m_ShipWeightMultiplier = 1.7f,
m_AmbulanceImportServiceFee = 5f,
m_HearseImportServiceFee = 3f,
m_FireEngineImportServiceFee = 4f,
m_GarbageImportServiceFee = 2f,
m_PoliceImportServiceFee = 6f,
m_OCServiceTradePopulationRange = 10000
};
// Query fees and availability
float elecImportFee = trade.GetFee(PlayerResource.Electricity, export: false);
bool waterExportAllowed = trade.Exportable(PlayerResource.Water);
float roadDistanceMultiplier = trade.GetDistanceCost(OutsideConnectionTransferType.Road);
float shipWeightMultiplier = trade.GetWeightCost(OutsideConnectionTransferType.Ship);
Additional notes for modders: - The type references PlayerResource and OutsideConnectionTransferType enums (defined elsewhere in game code). Ensure you use the correct enum values when calling GetFee / GetDistanceCost / GetWeightCost. - The GetDistanceCost/GetWeightCost loop is effectively redundant in the shipped implementation. If you expect to pass a bitmask of multiple transfer types, you will need to modify these methods to iterate over bits and combine multipliers as desired.