Make funding allocation computer more configurable (#36790)
* Make funding allocation computer more configurable * admin logging * unused * ccvar enabled --------- Co-authored-by: ScarKy0 <scarky0@onet.eu>
This commit is contained in:
committed by
GitHub
parent
1197d9b038
commit
907f4b39cd
@@ -17,9 +17,9 @@ public sealed class FundingAllocationConsoleBoundUserInterface(EntityUid owner,
|
|||||||
|
|
||||||
_menu = this.CreateWindow<FundingAllocationMenu>();
|
_menu = this.CreateWindow<FundingAllocationMenu>();
|
||||||
|
|
||||||
_menu.OnSavePressed += d =>
|
_menu.OnSavePressed += (dicts, primary, lockbox) =>
|
||||||
{
|
{
|
||||||
SendMessage(new SetFundingAllocationBuiMessage(d));
|
SendMessage(new SetFundingAllocationBuiMessage(dicts, primary, lockbox));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||||
Title="{Loc 'cargo-funding-alloc-console-menu-title'}"
|
Title="{Loc 'cargo-funding-alloc-console-menu-title'}">
|
||||||
SetSize="680 310"
|
|
||||||
MinSize="680 310">
|
|
||||||
<BoxContainer Orientation="Vertical"
|
<BoxContainer Orientation="Vertical"
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
Margin="10 5 10 10">
|
Margin="10 5 10 10">
|
||||||
<Label Name="HelpLabel" HorizontalAlignment="Center" StyleClasses="LabelSubText"/>
|
<controls:TableContainer Columns="2" HorizontalExpand="True" VerticalExpand="True">
|
||||||
<Control MinHeight="10"/>
|
<RichTextLabel Name="PrimaryCutLabel" Text="{Loc 'cargo-funding-alloc-console-label-primary-cut'}"/>
|
||||||
|
<SpinBox Name="PrimaryCut"/>
|
||||||
|
<RichTextLabel Name="LockboxCutLabel" Text="{Loc 'cargo-funding-alloc-console-label-lockbox-cut'}"/>
|
||||||
|
<SpinBox Name="LockboxCut"/>
|
||||||
|
</controls:TableContainer>
|
||||||
|
<Label Name="HelpLabel" HorizontalAlignment="Center" StyleClasses="LabelSubText" Margin="0 10"/>
|
||||||
<PanelContainer VerticalExpand="True" HorizontalExpand="True" VerticalAlignment="Top" MaxHeight="250">
|
<PanelContainer VerticalExpand="True" HorizontalExpand="True" VerticalAlignment="Top" MaxHeight="250">
|
||||||
<PanelContainer.PanelOverride>
|
<PanelContainer.PanelOverride>
|
||||||
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E"/>
|
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E"/>
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.Message;
|
using Content.Client.Message;
|
||||||
using Content.Client.UserInterface.Controls;
|
using Content.Client.UserInterface.Controls;
|
||||||
using Content.Shared.Cargo.Components;
|
using Content.Shared.Cargo.Components;
|
||||||
using Content.Shared.Cargo.Prototypes;
|
using Content.Shared.Cargo.Prototypes;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
@@ -15,14 +18,21 @@ namespace Content.Client.Cargo.UI;
|
|||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public sealed partial class FundingAllocationMenu : FancyWindow
|
public sealed partial class FundingAllocationMenu : FancyWindow
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
private readonly EntityQuery<StationBankAccountComponent> _bankQuery;
|
private readonly EntityQuery<StationBankAccountComponent> _bankQuery;
|
||||||
|
|
||||||
public event Action<Dictionary<ProtoId<CargoAccountPrototype>, int>>? OnSavePressed;
|
public event Action<Dictionary<ProtoId<CargoAccountPrototype>, int>, double, double>? OnSavePressed;
|
||||||
|
|
||||||
private EntityUid? _station;
|
private EntityUid? _station;
|
||||||
|
private bool _allowPrimaryAccountAllocation;
|
||||||
|
private bool _allowPrimaryCutAdjustment;
|
||||||
|
private bool _lockboxCutEnabled;
|
||||||
|
|
||||||
|
private double _primaryCut;
|
||||||
|
private double _lockboxCut;
|
||||||
|
|
||||||
private readonly HashSet<Control> _addedControls = new();
|
private readonly HashSet<Control> _addedControls = new();
|
||||||
private readonly List<SpinBox> _spinBoxes = new();
|
private readonly List<SpinBox> _spinBoxes = new();
|
||||||
@@ -35,30 +45,65 @@ public sealed partial class FundingAllocationMenu : FancyWindow
|
|||||||
|
|
||||||
_bankQuery = _entityManager.GetEntityQuery<StationBankAccountComponent>();
|
_bankQuery = _entityManager.GetEntityQuery<StationBankAccountComponent>();
|
||||||
|
|
||||||
|
PrimaryCut.ValueChanged += args =>
|
||||||
|
{
|
||||||
|
_primaryCut = (double)args.Value / 100.0;
|
||||||
|
UpdateButtonDisabled();
|
||||||
|
};
|
||||||
|
|
||||||
|
LockboxCut.ValueChanged += args =>
|
||||||
|
{
|
||||||
|
_lockboxCut = 1.0 - (double)args.Value / 100.0;
|
||||||
|
UpdateButtonDisabled();
|
||||||
|
};
|
||||||
|
|
||||||
SaveButton.OnPressed += _ =>
|
SaveButton.OnPressed += _ =>
|
||||||
{
|
{
|
||||||
if (!_entityManager.TryGetComponent<StationBankAccountComponent>(_station, out var bank))
|
if (!_entityManager.TryGetComponent<StationBankAccountComponent>(_station, out var bank))
|
||||||
return;
|
return;
|
||||||
var accounts = bank.Accounts.Keys.OrderBy(p => p.Id).ToList();
|
var accounts = EditableAccounts(bank).OrderBy(p => p.Key).Select(p => p.Key).ToList();
|
||||||
var dicts = new Dictionary<ProtoId<CargoAccountPrototype>, int>();
|
var dicts = new Dictionary<ProtoId<CargoAccountPrototype>, int>();
|
||||||
for (var i = 0; i< accounts.Count; i++)
|
for (var i = 0; i< accounts.Count; i++)
|
||||||
{
|
{
|
||||||
dicts.Add(accounts[i], _spinBoxes[i].Value);
|
dicts.Add(accounts[i], _spinBoxes[i].Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnSavePressed?.Invoke(dicts);
|
OnSavePressed?.Invoke(dicts, _primaryCut, _lockboxCut);
|
||||||
SaveButton.Disabled = true;
|
SaveButton.Disabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_cfg.OnValueChanged(CCVars.AllowPrimaryAccountAllocation, enabled => { _allowPrimaryAccountAllocation = enabled; }, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.AllowPrimaryCutAdjustment, enabled => { _allowPrimaryCutAdjustment = enabled; }, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.LockboxCutEnabled, enabled => { _lockboxCutEnabled = enabled; }, true);
|
||||||
|
|
||||||
BuildEntries();
|
BuildEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<KeyValuePair<ProtoId<CargoAccountPrototype>, int>> EditableAccounts(StationBankAccountComponent bank)
|
||||||
|
{
|
||||||
|
foreach (var kvp in bank.Accounts)
|
||||||
|
{
|
||||||
|
if (_allowPrimaryAccountAllocation || kvp.Key != bank.PrimaryAccount)
|
||||||
|
{
|
||||||
|
yield return kvp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void BuildEntries()
|
private void BuildEntries()
|
||||||
{
|
{
|
||||||
if (!_entityManager.TryGetComponent<StationBankAccountComponent>(_station, out var bank))
|
if (!_entityManager.TryGetComponent<StationBankAccountComponent>(_station, out var bank))
|
||||||
return;
|
return;
|
||||||
HelpLabel.Text = Loc.GetString("cargo-funding-alloc-console-label-help",
|
|
||||||
|
if (_allowPrimaryCutAdjustment)
|
||||||
|
{
|
||||||
|
HelpLabel.Text = Loc.GetString("cargo-funding-alloc-console-label-help-adjustible");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HelpLabel.Text = Loc.GetString("cargo-funding-alloc-console-label-help-non-adjustible",
|
||||||
("percent", (int) (bank.PrimaryCut * 100)));
|
("percent", (int) (bank.PrimaryCut * 100)));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var ctrl in _addedControls)
|
foreach (var ctrl in _addedControls)
|
||||||
{
|
{
|
||||||
@@ -69,7 +114,21 @@ public sealed partial class FundingAllocationMenu : FancyWindow
|
|||||||
_spinBoxes.Clear();
|
_spinBoxes.Clear();
|
||||||
_balanceLabels.Clear();
|
_balanceLabels.Clear();
|
||||||
|
|
||||||
var accounts = bank.Accounts.ToList().OrderBy(p => p.Key);
|
_primaryCut = bank.PrimaryCut;
|
||||||
|
_lockboxCut = bank.LockboxCut;
|
||||||
|
|
||||||
|
LockboxCut.OverrideValue(100 - (int)(_lockboxCut * 100));
|
||||||
|
PrimaryCut.OverrideValue((int)(_primaryCut * 100));
|
||||||
|
|
||||||
|
LockboxCut.IsValid = val => val is >= 0 and <= 100;
|
||||||
|
PrimaryCut.IsValid = val => val is >= 0 and <= 100;
|
||||||
|
|
||||||
|
LockboxCut.Visible = _lockboxCutEnabled;
|
||||||
|
LockboxCutLabel.Visible = _lockboxCutEnabled;
|
||||||
|
PrimaryCut.Visible = _allowPrimaryCutAdjustment;
|
||||||
|
PrimaryCutLabel.Visible = _allowPrimaryCutAdjustment;
|
||||||
|
|
||||||
|
var accounts = EditableAccounts(bank).OrderBy(p => p.Key);
|
||||||
foreach (var (account, balance) in accounts)
|
foreach (var (account, balance) in accounts)
|
||||||
{
|
{
|
||||||
var accountProto = _prototypeManager.Index(account);
|
var accountProto = _prototypeManager.Index(account);
|
||||||
@@ -127,7 +186,7 @@ public sealed partial class FundingAllocationMenu : FancyWindow
|
|||||||
var incorrectSum = sum != 100;
|
var incorrectSum = sum != 100;
|
||||||
|
|
||||||
var differs = false;
|
var differs = false;
|
||||||
var accounts = bank.Accounts.Keys.OrderBy(p => p.Id).ToList();
|
var accounts = EditableAccounts(bank).OrderBy(p => p.Key).Select(p => p.Key).ToList();
|
||||||
for (var i = 0; i < accounts.Count; i++)
|
for (var i = 0; i < accounts.Count; i++)
|
||||||
{
|
{
|
||||||
var percent = _spinBoxes[i].Value;
|
var percent = _spinBoxes[i].Value;
|
||||||
@@ -137,6 +196,7 @@ public sealed partial class FundingAllocationMenu : FancyWindow
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
differs = differs || _primaryCut != bank.PrimaryCut || _lockboxCut != bank.LockboxCut;
|
||||||
|
|
||||||
SaveButton.Disabled = !differs || incorrectSum;
|
SaveButton.Disabled = !differs || incorrectSum;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.Cargo.Components;
|
using Content.Shared.Cargo.Components;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Emag.Systems;
|
using Content.Shared.Emag.Systems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
@@ -9,12 +10,18 @@ namespace Content.Server.Cargo.Systems;
|
|||||||
|
|
||||||
public sealed partial class CargoSystem
|
public sealed partial class CargoSystem
|
||||||
{
|
{
|
||||||
|
private bool _allowPrimaryAccountAllocation;
|
||||||
|
private bool _allowPrimaryCutAdjustment;
|
||||||
|
|
||||||
public void InitializeFunds()
|
public void InitializeFunds()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleWithdrawFundsMessage>(OnWithdrawFunds);
|
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleWithdrawFundsMessage>(OnWithdrawFunds);
|
||||||
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleToggleLimitMessage>(OnToggleLimit);
|
SubscribeLocalEvent<CargoOrderConsoleComponent, CargoConsoleToggleLimitMessage>(OnToggleLimit);
|
||||||
SubscribeLocalEvent<FundingAllocationConsoleComponent, SetFundingAllocationBuiMessage>(OnSetFundingAllocation);
|
SubscribeLocalEvent<FundingAllocationConsoleComponent, SetFundingAllocationBuiMessage>(OnSetFundingAllocation);
|
||||||
SubscribeLocalEvent<FundingAllocationConsoleComponent, BeforeActivatableUIOpenEvent>(OnFundAllocationBuiOpen);
|
SubscribeLocalEvent<FundingAllocationConsoleComponent, BeforeActivatableUIOpenEvent>(OnFundAllocationBuiOpen);
|
||||||
|
|
||||||
|
_cfg.OnValueChanged(CCVars.AllowPrimaryAccountAllocation, enabled => { _allowPrimaryAccountAllocation = enabled; }, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.AllowPrimaryCutAdjustment, enabled => { _allowPrimaryCutAdjustment = enabled; }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWithdrawFunds(Entity<CargoOrderConsoleComponent> ent, ref CargoConsoleWithdrawFundsMessage args)
|
private void OnWithdrawFunds(Entity<CargoOrderConsoleComponent> ent, ref CargoConsoleWithdrawFundsMessage args)
|
||||||
@@ -102,7 +109,8 @@ public sealed partial class CargoSystem
|
|||||||
!TryComp<StationBankAccountComponent>(station, out var bank))
|
!TryComp<StationBankAccountComponent>(station, out var bank))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (args.Percents.Count != bank.RevenueDistribution.Count)
|
var expectedCount = _allowPrimaryAccountAllocation ? bank.RevenueDistribution.Count : bank.RevenueDistribution.Count - 1;
|
||||||
|
if (args.Percents.Count != expectedCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var differs = false;
|
var differs = false;
|
||||||
@@ -114,6 +122,7 @@ public sealed partial class CargoSystem
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
differs = differs || args.PrimaryCut != bank.PrimaryCut || args.LockboxCut != bank.LockboxCut;
|
||||||
|
|
||||||
if (!differs)
|
if (!differs)
|
||||||
return;
|
return;
|
||||||
@@ -121,18 +130,33 @@ public sealed partial class CargoSystem
|
|||||||
if (args.Percents.Values.Sum() != 100)
|
if (args.Percents.Values.Sum() != 100)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var primaryCut = bank.RevenueDistribution[bank.PrimaryAccount];
|
||||||
bank.RevenueDistribution.Clear();
|
bank.RevenueDistribution.Clear();
|
||||||
foreach (var (account, percent )in args.Percents)
|
foreach (var (account, percent )in args.Percents)
|
||||||
{
|
{
|
||||||
bank.RevenueDistribution.Add(account, percent / 100.0);
|
bank.RevenueDistribution.Add(account, percent / 100.0);
|
||||||
}
|
}
|
||||||
|
if (!_allowPrimaryAccountAllocation)
|
||||||
|
{
|
||||||
|
bank.RevenueDistribution.Add(bank.PrimaryAccount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_allowPrimaryCutAdjustment && args.PrimaryCut is >= 0.0 and <= 1.0)
|
||||||
|
{
|
||||||
|
bank.PrimaryCut = args.PrimaryCut;
|
||||||
|
}
|
||||||
|
if (_lockboxCutEnabled && args.LockboxCut is >= 0.0 and <= 1.0)
|
||||||
|
{
|
||||||
|
bank.LockboxCut = args.LockboxCut;
|
||||||
|
}
|
||||||
|
|
||||||
Dirty(station, bank);
|
Dirty(station, bank);
|
||||||
|
|
||||||
_audio.PlayPvs(ent.Comp.SetDistributionSound, ent);
|
_audio.PlayPvs(ent.Comp.SetDistributionSound, ent);
|
||||||
_adminLogger.Add(
|
_adminLogger.Add(
|
||||||
LogType.Action,
|
LogType.Action,
|
||||||
LogImpact.Medium,
|
LogImpact.Medium,
|
||||||
$"{ToPrettyString(args.Actor):player} set station {ToPrettyString(station)} fund distribution: {string.Join(',', bank.RevenueDistribution.Select(p => $"{p.Key}: {p.Value}").ToList())}");
|
$"{ToPrettyString(args.Actor):player} set station {ToPrettyString(station)} fund distribution: {string.Join(',', bank.RevenueDistribution.Select(p => $"{p.Key}: {p.Value}").ToList())}, primary cut: {bank.PrimaryCut}, lockbox cut: {bank.LockboxCut}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFundAllocationBuiOpen(Entity<FundingAllocationConsoleComponent> ent, ref BeforeActivatableUIOpenEvent args)
|
private void OnFundAllocationBuiOpen(Entity<FundingAllocationConsoleComponent> ent, ref BeforeActivatableUIOpenEvent args)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Shared.Cargo.BUI;
|
|||||||
using Content.Shared.Cargo.Components;
|
using Content.Shared.Cargo.Components;
|
||||||
using Content.Shared.Cargo.Events;
|
using Content.Shared.Cargo.Events;
|
||||||
using Content.Shared.Cargo.Prototypes;
|
using Content.Shared.Cargo.Prototypes;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -18,6 +19,7 @@ public sealed partial class CargoSystem
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private static readonly SoundPathSpecifier ApproveSound = new("/Audio/Effects/Cargo/ping.ogg");
|
private static readonly SoundPathSpecifier ApproveSound = new("/Audio/Effects/Cargo/ping.ogg");
|
||||||
|
private bool _lockboxCutEnabled;
|
||||||
|
|
||||||
private void InitializeShuttle()
|
private void InitializeShuttle()
|
||||||
{
|
{
|
||||||
@@ -28,6 +30,8 @@ public sealed partial class CargoSystem
|
|||||||
SubscribeLocalEvent<CargoPalletConsoleComponent, CargoPalletSellMessage>(OnPalletSale);
|
SubscribeLocalEvent<CargoPalletConsoleComponent, CargoPalletSellMessage>(OnPalletSale);
|
||||||
SubscribeLocalEvent<CargoPalletConsoleComponent, CargoPalletAppraiseMessage>(OnPalletAppraise);
|
SubscribeLocalEvent<CargoPalletConsoleComponent, CargoPalletAppraiseMessage>(OnPalletAppraise);
|
||||||
SubscribeLocalEvent<CargoPalletConsoleComponent, BoundUIOpenedEvent>(OnPalletUIOpen);
|
SubscribeLocalEvent<CargoPalletConsoleComponent, BoundUIOpenedEvent>(OnPalletUIOpen);
|
||||||
|
|
||||||
|
_cfg.OnValueChanged(CCVars.LockboxCutEnabled, (enabled) => { _lockboxCutEnabled = enabled; }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Console
|
#region Console
|
||||||
@@ -340,10 +344,11 @@ public sealed partial class CargoSystem
|
|||||||
Dictionary<ProtoId<CargoAccountPrototype>, double> distribution;
|
Dictionary<ProtoId<CargoAccountPrototype>, double> distribution;
|
||||||
if (sellComponent != null)
|
if (sellComponent != null)
|
||||||
{
|
{
|
||||||
|
var cut = _lockboxCutEnabled ? bankAccount.LockboxCut : bankAccount.PrimaryCut;
|
||||||
distribution = new Dictionary<ProtoId<CargoAccountPrototype>, double>
|
distribution = new Dictionary<ProtoId<CargoAccountPrototype>, double>
|
||||||
{
|
{
|
||||||
{ sellComponent.OverrideAccount, sellComponent.OverrideCut },
|
{ sellComponent.OverrideAccount, cut },
|
||||||
{ bankAccount.PrimaryAccount, 1.0 - sellComponent.OverrideCut },
|
{ bankAccount.PrimaryAccount, 1.0 - cut },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ using Content.Server.Radio.EntitySystems;
|
|||||||
using Content.Shared.Cargo;
|
using Content.Shared.Cargo;
|
||||||
using Content.Shared.Cargo.Components;
|
using Content.Shared.Cargo.Components;
|
||||||
using Content.Shared.Cargo.Prototypes;
|
using Content.Shared.Cargo.Prototypes;
|
||||||
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using Content.Shared.Mobs.Components;
|
using Content.Shared.Mobs.Components;
|
||||||
using Content.Shared.Paper;
|
using Content.Shared.Paper;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@ namespace Content.Server.Cargo.Systems;
|
|||||||
|
|
||||||
public sealed partial class CargoSystem : SharedCargoSystem
|
public sealed partial class CargoSystem : SharedCargoSystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
|
|||||||
26
Content.Shared/CCVar/CCVars.Cargo.cs
Normal file
26
Content.Shared/CCVar/CCVars.Cargo.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Robust.Shared.Configuration;
|
||||||
|
|
||||||
|
namespace Content.Shared.CCVar;
|
||||||
|
|
||||||
|
public sealed partial class CCVars
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the primary account of a bank should be listed
|
||||||
|
/// in the funding allocation console
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> AllowPrimaryAccountAllocation =
|
||||||
|
CVarDef.Create("cargo.allow_primary_account_allocation", false, CVar.REPLICATED);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the primary cut of a bank should be manipulable
|
||||||
|
/// in the funding allocation console
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> AllowPrimaryCutAdjustment =
|
||||||
|
CVarDef.Create("cargo.allow_primary_cut_adjustment", true, CVar.REPLICATED);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not the separate lockbox cut is enabled
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<bool> LockboxCutEnabled =
|
||||||
|
CVarDef.Create("cargo.enable_lockbox_cut", true, CVar.REPLICATED);
|
||||||
|
}
|
||||||
@@ -24,10 +24,14 @@ public sealed partial class FundingAllocationConsoleComponent : Component
|
|||||||
public sealed class SetFundingAllocationBuiMessage : BoundUserInterfaceMessage
|
public sealed class SetFundingAllocationBuiMessage : BoundUserInterfaceMessage
|
||||||
{
|
{
|
||||||
public Dictionary<ProtoId<CargoAccountPrototype>, int> Percents;
|
public Dictionary<ProtoId<CargoAccountPrototype>, int> Percents;
|
||||||
|
public double PrimaryCut;
|
||||||
|
public double LockboxCut;
|
||||||
|
|
||||||
public SetFundingAllocationBuiMessage(Dictionary<ProtoId<CargoAccountPrototype>, int> percents)
|
public SetFundingAllocationBuiMessage(Dictionary<ProtoId<CargoAccountPrototype>, int> percents, double primaryCut, double lockboxCut)
|
||||||
{
|
{
|
||||||
Percents = percents;
|
Percents = percents;
|
||||||
|
PrimaryCut = primaryCut;
|
||||||
|
LockboxCut = lockboxCut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,4 @@ public sealed partial class OverrideSellComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField(required: true)]
|
[DataField(required: true)]
|
||||||
public ProtoId<CargoAccountPrototype> OverrideAccount;
|
public ProtoId<CargoAccountPrototype> OverrideAccount;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The cut that the OverrideAccount will get from the price. The rest is given to the primary station account.
|
|
||||||
/// </summary>
|
|
||||||
[DataField]
|
|
||||||
public float OverrideCut = 0.75f;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ public sealed partial class StationBankAccountComponent : Component
|
|||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public double PrimaryCut = 0.50;
|
public double PrimaryCut = 0.50;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When giving funds to a particular account from an override sell, the proportion of funds they should receive compared to remaining accounts.
|
||||||
|
/// </summary>
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public double LockboxCut = 0.75;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dictionary corresponding to the money held by each cargo account.
|
/// A dictionary corresponding to the money held by each cargo account.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -72,7 +72,11 @@ cargo-funding-alloc-console-label-code = [bold] Code [/bold]
|
|||||||
cargo-funding-alloc-console-label-balance = [bold] Balance [/bold]
|
cargo-funding-alloc-console-label-balance = [bold] Balance [/bold]
|
||||||
cargo-funding-alloc-console-label-cut = [bold] Revenue Division (%) [/bold]
|
cargo-funding-alloc-console-label-cut = [bold] Revenue Division (%) [/bold]
|
||||||
|
|
||||||
cargo-funding-alloc-console-label-help = Cargo receives {$percent}% of all profits. The rest is split as specified below:
|
cargo-funding-alloc-console-label-primary-cut = Cargo's cut of funds from non-lockbox sources (%):
|
||||||
|
cargo-funding-alloc-console-label-lockbox-cut = Cargo's cut of funds from lockbox sales (%):
|
||||||
|
|
||||||
|
cargo-funding-alloc-console-label-help-non-adjustible = Cargo receives {$percent}% of profits from non-lockbox sales. The rest is split as specified below:
|
||||||
|
cargo-funding-alloc-console-label-help-adjustible = Remaining funds from non-lockbox sources are distributed as specified below:
|
||||||
cargo-funding-alloc-console-button-save = Save Changes
|
cargo-funding-alloc-console-button-save = Save Changes
|
||||||
cargo-funding-alloc-console-label-save-fail = [bold]Revenue Divisions Invalid![/bold] [color=red]({$pos ->
|
cargo-funding-alloc-console-label-save-fail = [bold]Revenue Divisions Invalid![/bold] [color=red]({$pos ->
|
||||||
[1] +
|
[1] +
|
||||||
|
|||||||
Reference in New Issue
Block a user