Skip to content

Game.Simulation.DemandUtils

Assembly: Assembly-CSharp (game assembly)
Namespace: Game.Simulation

Type: public static class DemandUtils

Base: System.Object

Summary:
Utility class that centralizes constants and a helper method used by the simulation to compute and schedule demand-related updates. It provides a fixed update interval and several per-category update offsets (company, commercial, industrial, residential, zone spawn). It also provides GetDemandFactorEffect which converts a floating "effect" multiplier into an integer demand factor (percentage) using Unity's Mathf rounding.


Fields

  • public const int kUpdateInterval = 16
    Interval (in simulation ticks/frames) used as the base update cadence for demand-related updates. Used to distribute work across frames.

  • public const int kCountCompanyUpdateOffset = 1
    Offset (in ticks/frames) from the base update time when company count updates should occur.

  • public const int kCommercialUpdateOffset = 4
    Offset for commercial demand/updates relative to the base update interval.

  • public const int kIndustrialUpdateOffset = 7
    Offset for industrial demand/updates relative to the base update interval.

  • public const int kResidentialUpdateOffset = 10
    Offset for residential demand/updates relative to the base update interval.

  • public const int kZoneSpawnUpdateOffset = 13
    Offset for zone spawn updates relative to the base update interval.

Properties

This static utility class does not define any properties.

Constructors

  • This is a static class; it cannot be instantiated and no constructors are defined.

Methods

  • public static int GetDemandFactorEffect(int total, float effect) : System.Int32
    Converts a floating-point effect multiplier into an integer demand factor (percentage). Implementation multiplies the effect by 100 and returns the nearest integer using UnityEngine.Mathf.RoundToInt. Note: the total parameter is present in the signature but is unused in the current implementation.

Parameters: - int total — (present but unused in current implementation; reserved for potential future logic). - float effect — multiplier/ratio representing the effect; typically expected to be in a range where multiplying by 100 yields a percentage.

Returns: - int — the rounded integer percentage corresponding to effect * 100.

Usage Example

// Example usage in simulation code:
int someTotal = 42;        // currently unused by the method
float effectMultiplier = 0.75f; // e.g., 75% demand effect

int demandPercent = Game.Simulation.DemandUtils.GetDemandFactorEffect(someTotal, effectMultiplier);
// demandPercent == 75 (because Mathf.RoundToInt(100f * 0.75f) == 75)