Fix inability to engage with economic Cargonia (#36668)
Fix inability to engage with cargo supremacy
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Cargo.Components;
|
||||
using Content.Shared.Cargo.Prototypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -36,30 +35,21 @@ public abstract class SharedCargoSystem : EntitySystem
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For a station, creates a distribution between one "primary" account and the other accounts.
|
||||
/// The primary account receives the majority cut specified, with the remaining accounts getting cuts
|
||||
/// distributed through the remaining amount, based on <see cref="StationBankAccountComponent.RevenueDistribution"/>
|
||||
/// For a station, creates a distribution between one the bank's account and the other accounts.
|
||||
/// The primary account receives the majority percentage listed on the bank account, with the remaining
|
||||
/// funds distributed to all accounts based on <see cref="StationBankAccountComponent.RevenueDistribution"/>
|
||||
/// </summary>
|
||||
public Dictionary<ProtoId<CargoAccountPrototype>, double> CreateAccountDistribution(
|
||||
ProtoId<CargoAccountPrototype> primary,
|
||||
StationBankAccountComponent stationBank,
|
||||
double primaryCut = 1.0)
|
||||
public Dictionary<ProtoId<CargoAccountPrototype>, double> CreateAccountDistribution(Entity<StationBankAccountComponent> stationBank)
|
||||
{
|
||||
var distribution = new Dictionary<ProtoId<CargoAccountPrototype>, double>
|
||||
{
|
||||
{ primary, primaryCut }
|
||||
{ stationBank.Comp.PrimaryAccount, stationBank.Comp.PrimaryCut }
|
||||
};
|
||||
var remaining = 1.0 - primaryCut;
|
||||
var remaining = 1.0 - stationBank.Comp.PrimaryCut;
|
||||
|
||||
var allAccountPercentages = new Dictionary<ProtoId<CargoAccountPrototype>, double>(stationBank.RevenueDistribution);
|
||||
allAccountPercentages.Remove(primary);
|
||||
var weightsSum = allAccountPercentages.Values.Sum();
|
||||
|
||||
foreach (var (account, percentage) in allAccountPercentages)
|
||||
foreach (var (account, percentage) in stationBank.Comp.RevenueDistribution)
|
||||
{
|
||||
var adjustedPercentage = percentage / weightsSum;
|
||||
|
||||
distribution.Add(account, remaining * adjustedPercentage);
|
||||
distribution.Add(account, remaining * percentage);
|
||||
}
|
||||
return distribution;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user