using Content.Shared._NF.Bank.Components; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Server._NF.Power.Components; /// /// An entity with this will pay out a given sector bank account regularly depending on the amount of power received. /// Payouts occur at a fixed period, but the rate of pay depends on the average power input over that period. /// At high power input, the incremental rate of pay diminishes logarithmically. /// [RegisterComponent, AutoGenerateComponentPause] public sealed partial class PowerTransmissionComponent : Component { #region Power /// /// The name of the node to be connected/disconnected. /// [DataField] public string NodeName = "input"; /// /// The period between depositing money into a sector account. /// Also the T in Tk*a^(log10(x/T)-R) for rate calculation /// [DataField] public TimeSpan DepositPeriod = TimeSpan.FromSeconds(20); /// /// The next time this power plant is selling accumulated power. /// Should not be changedduring runtime, will cause errors in deposit amounts. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] public TimeSpan NextDeposit; /// /// The total energy accumulated, in joules. /// [DataField] public float AccumulatedEnergy; /// /// The account to deposit funds from sold energy into. /// [DataField(required: true)] public SectorBankAccount Account = SectorBankAccount.Invalid; #endregion Power Sale #region Linear Rates /// /// The rate per joule to credit the account while in the linear mode. /// [DataField] public float LinearRate = 0.00006f; // $6/100 kJ // Horizon 0.00003>>0.00006 /// /// The maximum value (inclusive) of the linear mode per deposit, in watts /// [DataField] public float LinearMaxValue = 5_000_000; // 5 MW ($300/s) // Horizon 1_000_000>>5_000_000 #endregion Linear Rates // Logarithmic fields: at very high levels of power generation, incremental gains decrease logarithmically to prevent runaway cash generation #region Logarithmic Rates /// /// The base on power the logarithmic mode: a in Tk*a^(log10(x/T)-R) /// [DataField] public float LogarithmRateBase = 2.5f; /// /// The coefficient of the logarithmic mode: k in Tk*a^(log10(x/T)-R) /// Note: should be set to LinearRate*LinearMaxValue for a continuous function. /// [DataField] public float LogarithmCoefficient = 300f; // Horizon 30>>300 /// /// The exponential subtrahend of the logarithmic mode: R in Tk*a^(log10(x/T)-R) /// Note: should be set to log10(LinearMaxValue) for a continuous function. /// [DataField] public float LogarithmSubtrahend = 6.69f; // log10(5_000_000) // Horizon 6>>6.69 #endregion Logarithmic Rates /// /// [DataField] public float MaxValuePerSecond = 450.0f; // ~57 MW, ~$540k/h // Horizon 150>>450 /// /// True if the entity was powered last tick. /// [ViewVariables] public bool LastPowered; /// /// The minimum requestable power, in watts. /// [DataField] public float MinimumRequestablePower = 500; // 500 W /// /// The maximum requestable power, in watts. /// [DataField] public float MaximumRequestablePower = 100_000_000_000; // 100 GW }