Skip to content

Game.Prefabs.LandValuePrefab

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: class

Base: PrefabBase

Summary:
Represents the prefab that exposes configurable parameters for land value calculations in the game. This prefab holds inspector-exposed fields (multipliers, baselines and references) which are converted into a runtime component (LandValueParameterData) during prefab initialization. Modders can adjust these values in the prefab to affect how land value is calculated and displayed (info view, gizmos and bonuses/penalties for services, transport and pollution).


Fields

  • public InfoviewPrefab m_LandValueInfoViewPrefab
    Reference to an InfoviewPrefab used to display land-value related UI/info for tiles or districts. During LateInitialize this reference is converted to an Entity via PrefabSystem.GetEntity and stored in the runtime component.

  • public float m_LandValueBaseline = 10f
    Baseline land value. Land value less than or equal to this baseline will not be shown with gizmos (per the tooltip). Useful to set the minimum threshold for visualization.

  • public float m_HealthCoverageBonusMultiplier = 5f
    Multiplier applied to the health service coverage bonus when computing land value.

  • public float m_EducationCoverageBonusMultiplier = 5f
    Multiplier applied to the education service coverage bonus.

  • public float m_PoliceCoverageBonusMultiplier = 5f
    Multiplier applied to the police service coverage bonus.

  • public float m_AttractivenessBonusMultiplier = 3f
    Multiplier applied to both terrain attractiveness and tourism building attractiveness bonuses.

  • public float m_TelecomCoverageBonusMultiplier = 20f
    Multiplier applied to telecom coverage bonus.

  • public float m_CommercialServiceBonusMultiplier = 10f
    Multiplier applied to commercial service bonus.

  • public float m_BusBonusMultiplier = 5f
    Multiplier applied to bus transportation bonus.

  • public float m_TramSubwayBonusMultiplier = 50f
    Multiplier applied to tram or subway transportation bonus.

  • public int m_CommonFactorMaxBonus = 100
    Maximum bonus money a common factor can contribute. Limits per-factor contribution.

  • public float m_GroundPollutionPenaltyMultiplier = 10f
    Multiplier applied to ground pollution penalties (reduces land value).

  • public float m_AirPollutionPenaltyMultiplier = 5f
    Multiplier applied to air pollution penalties.

  • public float m_NoisePollutionPenaltyMultiplier = 0.01f
    Multiplier applied to noise pollution penalties.

Properties

  • None declared on this class. (All configuration is exposed as public fields and converted into a runtime component.)

Constructors

  • public LandValuePrefab()
    Default parameterless constructor (inherited behavior). Typical prefab instances are created/edited via the Unity editor rather than constructed directly in code.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds any dependent PrefabBase objects to the provided list. This implementation calls the base and then adds the referenced m_LandValueInfoViewPrefab so that the info view prefab is included as a dependency when building/serializing prefabs.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Reports which ECS component types the prefab will require on the prefab entity. This implementation adds ComponentType.ReadWrite() so that the runtime prefab entity contains the LandValueParameterData component.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Called after the prefab entity is created; it assembles a LandValueParameterData instance from the inspector fields and writes it to the entity with entityManager.SetComponentData. It uses PrefabSystem.GetEntity(m_LandValueInfoViewPrefab) to convert the referenced InfoviewPrefab into its entity handle and sets all multiplier/baseline/penalty values into the component.

Notes and implementation details: - Requires a PrefabSystem to be present in the world (retrieved via entityManager.World.GetOrCreateSystemManaged). - After this method runs, any system that reads LandValueParameterData from the prefab entity can use these configured values for calculations or visualization.

Usage Example

// Example: reading configured LandValueParameterData from the prefab entity at runtime
var world = World.DefaultGameObjectInjectionWorld;
var prefabSystem = world.GetOrCreateSystemManaged<PrefabSystem>();
var entityManager = world.EntityManager;

// Suppose you have a reference to the LandValuePrefab scriptable object instance:
LandValuePrefab landValuePrefabSO = /* obtain from resources or serialized field */;

// Convert the prefab scriptable to the prefab entity
Entity prefabEntity = prefabSystem.GetEntity(landValuePrefabSO);

// Read the runtime component with the configured parameters
if (entityManager.HasComponent<LandValueParameterData>(prefabEntity))
{
    var paramsData = entityManager.GetComponentData<LandValueParameterData>(prefabEntity);
    Debug.Log($"Land value baseline: {paramsData.m_LandValueBaseline}");
    // Use paramsData.* multipliers in your systems
}

Additional tips: - Edit the public fields on the LandValuePrefab in the Unity inspector to adjust land value behavior without changing code. - When creating custom systems that consume land value parameters, read the LandValueParameterData from the prefab entity rather than relying on hardcoded values. - Ensure your mod runs after prefab initialization if you depend on values set in LateInitialize (use proper system update order or schedule as a ManagedSystem that runs after PrefabSystem initialization).