Skip to content

Game.Simulation.IElectricityStatisticsSystem

Assembly: Assembly-CSharp.dll
Namespace: Game.Simulation

Type: Interface

Base: None

Summary:
Interface that exposes aggregated electricity statistics for the simulation. Implementations provide read-only integer values for current production, consumption, how much consumption is being fulfilled, and battery charge/capacity. These values are intended to be polled by systems or UI that display city power statistics.


Fields

  • This interface defines no fields
    No backing fields are declared by the interface itself; implementations will provide any required storage.

Properties

  • int production { get; }
    Total electricity production aggregated by the simulation (integer simulation units). Represents how much power is currently being generated.

  • int consumption { get; }
    Total electricity demand/consumption aggregated by the simulation (integer simulation units). Represents how much power is currently required.

  • int fulfilledConsumption { get; }
    Amount of the consumption that is currently fulfilled by available production and stored battery charge (integer simulation units). Useful to compute shortages: consumption - fulfilledConsumption.

  • int batteryCharge { get; }
    Current stored energy in city battery storage (integer simulation units). Represents how much energy is available from storage.

  • int batteryCapacity { get; }
    Total battery storage capacity available to the city (integer simulation units). Used together with batteryCharge to show fill percentage.

Constructors

  • None (interfaces cannot declare constructors)
    Implementations will define their own constructors and initialization logic.

Methods

  • This interface declares no methods
    Only read-only properties are defined. Any update/refresh behavior is implemented by the concrete type.

Usage Example

// Example implementation of IElectricityStatisticsSystem
public class ElectricityStatisticsSystem : IElectricityStatisticsSystem
{
    private int _production;
    private int _consumption;
    private int _fulfilledConsumption;
    private int _batteryCharge;
    private int _batteryCapacity;

    public int production => _production;
    public int consumption => _consumption;
    public int fulfilledConsumption => _fulfilledConsumption;
    public int batteryCharge => _batteryCharge;
    public int batteryCapacity => _batteryCapacity;

    public ElectricityStatisticsSystem()
    {
        // Initialize fields or subscribe to simulation update events
        _production = 0;
        _consumption = 0;
        _fulfilledConsumption = 0;
        _batteryCharge = 0;
        _batteryCapacity = 0;
    }

    // Example update method called by the simulation each tick
    public void UpdateStats(int production, int consumption, int batteryCharge, int batteryCapacity)
    {
        _production = production;
        _consumption = consumption;
        _batteryCharge = batteryCharge;
        _batteryCapacity = batteryCapacity;
        _fulfilledConsumption = Math.Min(consumption, production + batteryCharge);
    }
}