From 50916f88823dca2c925754abe8e5ca441e63cb1e Mon Sep 17 00:00:00 2001 From: desuwatch Date: Fri, 17 May 2024 15:09:40 +0300 Subject: [PATCH] update event raising on upstream --- .../Station/Systems/StationSpawningSystem.cs | 10 +++++++++- Content.Server/_NF/Bank/BankSystem.cs | 15 --------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index e8946328c2f..46604fe3524 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -30,7 +30,10 @@ using Robust.Shared.Random; using Robust.Shared.Utility; using Content.Server.Spawners.Components; -using Content.Shared.Bank.Components; // DeltaV +using Content.Shared.Bank.Components; +using Content.Shared._NF.Bank.Events; +using FastAccessors.Monads; +using Robust.Server.Player; // DeltaV namespace Content.Server.Station.Systems; @@ -44,6 +47,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!; [Dependency] private readonly IdCardSystem _cardSystem = default!; [Dependency] private readonly PdaSystem _pdaSystem = default!; @@ -237,6 +241,10 @@ public EntityUid SpawnPlayerMob( var bank = EnsureComp(entity.Value); bank.Balance = bankBalance; + if (_playerManager.TryGetSessionByEntity(entity.Value, out var player)) + { + RaiseLocalEvent(new BalanceChangedEvent(bankBalance, player)); + } } var gearEquippedEv = new StartingGearEquippedEvent(entity.Value); diff --git a/Content.Server/_NF/Bank/BankSystem.cs b/Content.Server/_NF/Bank/BankSystem.cs index 1279a6b0247..f04586de0c3 100644 --- a/Content.Server/_NF/Bank/BankSystem.cs +++ b/Content.Server/_NF/Bank/BankSystem.cs @@ -31,21 +31,6 @@ public override void Initialize() InitializeStationATM(); } - // attaches the bank component directly on to the player's mob. Could be attached to something else on the player later. - // we may have to change this later depending on mind rework. - // then again, maybe the bank account should stay attached to the mob - private void OnPlayerSpawn (PlayerSpawnCompleteEvent args) - { - var mobUid = args.Mob; - var bank = EnsureComp(mobUid); - bank.Balance = args.Profile.BankBalance; - if (_playerManager.TryGetSessionByEntity(mobUid, out var player)) - { - RaiseLocalEvent(new BalanceChangedEvent(bank.Balance, player)); - } - Dirty(bank); - } - // To ensure that bank account data gets saved, we are going to update the db every time the component changes // I at first wanted to try to reduce database calls, however notafet suggested I just do it every time the account changes // TODO: stop it from running 5 times every time