Departmental Economy (#36445)

* Cargo Accounts, Request Consoles, and lock boxes

* Funding Allocation Computer

* final changes

* test fix

* remove dumb code

* ScarKy0 review

* first cour

* second cour

* Update machines.yml

* review

---------

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Co-authored-by: Milon <milonpl.git@proton.me>
This commit is contained in:
Nemanja
2025-04-13 09:22:36 -04:00
committed by GitHub
parent 5f78b72763
commit 12b75beeab
62 changed files with 2106 additions and 331 deletions

View File

@@ -0,0 +1,77 @@
using Content.Shared.Cargo.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Cargo.Components;
/// <summary>
/// Added to the abstract representation of a station to track its money.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedCargoSystem)), AutoGenerateComponentPause, AutoGenerateComponentState]
public sealed partial class StationBankAccountComponent : Component
{
/// <summary>
/// The account that receives funds by default
/// </summary>
[DataField, AutoNetworkedField]
public ProtoId<CargoAccountPrototype> PrimaryAccount = "Cargo";
/// <summary>
/// When giving funds to a particular account, the proportion of funds they should receive compared to remaining accounts.
/// </summary>
[DataField, AutoNetworkedField]
public double PrimaryCut = 0.75;
/// <summary>
/// A dictionary corresponding to the money held by each cargo account.
/// </summary>
[DataField, AutoNetworkedField]
public Dictionary<ProtoId<CargoAccountPrototype>, int> Accounts = new()
{
{ "Cargo", 2000 },
{ "Engineering", 1000 },
{ "Medical", 1000 },
{ "Science", 1000 },
{ "Security", 1000 },
{ "Service", 1000 },
};
/// <summary>
/// A baseline distribution used for income and dispersing leftovers after sale.
/// </summary>
[DataField, AutoNetworkedField]
public Dictionary<ProtoId<CargoAccountPrototype>, double> RevenueDistribution = new()
{
{ "Cargo", 0.00 },
{ "Engineering", 0.25 },
{ "Medical", 0.30 },
{ "Science", 0.15 },
{ "Security", 0.20 },
{ "Service", 0.10 },
};
/// <summary>
/// How much the bank balance goes up per second, every Delay period. Rounded down when multiplied.
/// </summary>
[DataField]
public int IncreasePerSecond = 2;
/// <summary>
/// The time at which the station will receive its next deposit of passive income
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan NextIncomeTime;
/// <summary>
/// How much time to wait (in seconds) before increasing bank accounts balance.
/// </summary>
[DataField]
public TimeSpan IncomeDelay = TimeSpan.FromSeconds(50);
}
/// <summary>
/// Broadcast and raised on station ent whenever its balance is updated.
/// </summary>
[ByRefEvent]
public readonly record struct BankBalanceUpdatedEvent(EntityUid Station, Dictionary<ProtoId<CargoAccountPrototype>, int> Balance);