Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

update event raising on upstream #185

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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!;
Expand Down Expand Up @@ -237,6 +241,10 @@ public EntityUid SpawnPlayerMob(

var bank = EnsureComp<BankAccountComponent>(entity.Value);
bank.Balance = bankBalance;
if (_playerManager.TryGetSessionByEntity(entity.Value, out var player))
{
RaiseLocalEvent(new BalanceChangedEvent(bankBalance, player));
}
}

var gearEquippedEv = new StartingGearEquippedEvent(entity.Value);
Expand Down
15 changes: 0 additions & 15 deletions Content.Server/_NF/Bank/BankSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BankAccountComponent>(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
Expand Down
Loading