Skip to content

Game.Prefabs.OutsideTradeParameterPrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
A prefab (ScriptableObject-based) configuration asset that contains settings for outside trade and service-import behaviour. When initialized it populates an ECS component OutsideTradeParameterData on an entity with prices for importing/exporting electricity, water and sewage, pollution tolerance for water exports, distance/weight multipliers for transport types, and service import fees (ambulance, hearse, fire engine, garbage, police). This prefab is intended to be used by the prefab/initialization system to provide runtime parameters for outside trade systems in the game.


Fields

  • public float m_ElectricityImportPrice
    Expense for importing 0.1 kW of electricity for 24h (configured in Inspector via Tooltip "Expense for importing 0.1 kW of electricity for 24h").

  • public float m_ElectricityExportPrice
    Revenue for exporting 0.1 kW of electricity for 24h (configured in Inspector via Tooltip "Revenue for exporting 0.1 kW of electricity for 24h").

  • public float m_WaterImportPrice
    Expense for importing 1 m^3 of water for 24h (Tooltip: "Expense for importing 1m^3 of water for 24h").

  • public float m_WaterExportPrice
    Revenue for exporting 1 m^3 of water for 24h (Tooltip: "Revenue for exporting 1m^3 of water for 24h").

  • public float m_WaterExportPollutionTolerance = 0.1f
    Percentage of pollution when the water export revenue becomes zero. Range constrained to 0.0–1.0 (Tooltip & [Range(0f, 1f)]).

  • public float m_SewageExportPrice
    Expense for importing 1 m^3 of sewage for 24h (Tooltip indicates sewage export price).

  • public float m_AirWeightMultiplier
    Weight multiplier for air transport in resource trade calculations.

  • public float m_RoadWeightMultiplier
    Weight multiplier for road transport in resource trade calculations.

  • public float m_TrainWeightMultiplier
    Weight multiplier for train transport in resource trade calculations.

  • public float m_ShipWeightMultiplier
    Weight multiplier for ship transport in resource trade calculations.

  • public float m_AirDistanceMultiplier
    Distance multiplier for air transport in resource trade calculations.

  • public float m_RoadDistanceMultiplier
    Distance multiplier for road transport in resource trade calculations.

  • public float m_TrainDistanceMultiplier
    Distance multiplier for train transport in resource trade calculations.

  • public float m_ShipDistanceMultiplier
    Distance multiplier for ship transport in resource trade calculations.

  • public float m_AmbulanceImportServiceFee = 1f
    Service fee multiplier for ambulance import service (multiplied by population). Default: 1.

  • public float m_HearseImportServiceFee = 1f
    Service fee multiplier for hearse import service (multiplied by population). Default: 1.

  • public float m_FireEngineImportServiceFee = 1f
    Service fee multiplier for fire engine import service (multiplied by population). Default: 1.

  • public float m_GarbageImportServiceFee = 1f
    Service fee multiplier for garbage import service (multiplied by population). Default: 1.

  • public float m_PoliceImportServiceFee = 1f
    Service fee multiplier for police import service (multiplied by population). Default: 1.

  • public int m_OCServiceTradePopulationRange = 1000
    Population range used to scale service fees from outside (Tooltip: describes bucketed scaling such as 0–1000 => fee * 1000, 1000–2000 => fee * 2000). Default: 1000.

Notes: many fields are exposed in the Inspector with Headers/Tooltips to guide designers.

Properties

  • This class does not declare public properties. It exposes configuration via public fields and implements prefab lifecycle methods.

Constructors

  • public OutsideTradeParameterPrefab()
    No explicit constructor is defined; uses the default ScriptableObject/PrefabBase construction semantics. Instances are normally created/managed by the prefab system or via ScriptableObject utilities in the editor.

Methods

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds the runtime ECS component type required by this prefab: ComponentType.ReadWrite(). This informs the prefab system which component types this prefab will provide to an entity. Implementation calls base.GetPrefabComponents(components) then components.Add(...).

  • public override void Initialize(EntityManager entityManager, Entity entity)
    Initializes the provided entity's OutsideTradeParameterData component with values taken from the prefab fields. It constructs an OutsideTradeParameterData struct with matching fields and calls entityManager.SetComponentData(entity, new OutsideTradeParameterData { ... }). Note: the target entity must already have the OutsideTradeParameterData component present (typically ensured by the prefab system because GetPrefabComponents advertises it).

Important: OutsideTradeParameterData must be defined in the project and have matching fields; Initialize maps prefab fields directly to that component's fields.

Usage Example

// Example: create an entity with the required component, then initialize it from the prefab.
// (This is a minimal illustration — in-game the prefab/asset pipeline usually creates and initializes prefabs.)

// Ensure OutsideTradeParameterData is part of the entity archetype:
var archetype = entityManager.CreateArchetype(typeof(OutsideTradeParameterData));
var entity = entityManager.CreateEntity(archetype);

// Create and configure the prefab instance (editor or runtime)
var prefab = ScriptableObject.CreateInstance<Game.Prefabs.OutsideTradeParameterPrefab>();
prefab.m_ElectricityImportPrice = 0.5f;
prefab.m_WaterExportPrice = 1.2f;
prefab.m_AirDistanceMultiplier = 1.5f;
// ... set other values as needed

// Initialize the entity's component data from the prefab
prefab.Initialize(entityManager, entity);

Additional notes: - This prefab is intended to be edited in the Unity Inspector (Headers and Tooltips guide each field). - The prefab is a bridge between design-time settings and the runtime ECS component OutsideTradeParameterData used by the game's outside trade systems.