From 66a01ccbf233ba5a52d9d98820437770f6a1e2a7 Mon Sep 17 00:00:00 2001 From: Checkraze <71046427+Cheackraze@users.noreply.github.com> Date: Tue, 10 Jan 2023 04:55:59 -0500 Subject: [PATCH] cargo system cleanup (#13396) --- .../Cargo/Systems/CargoSystem.Telepad.cs | 4 +++- .../Cargo/Systems/CargoSystem.Orders.cs | 6 ++---- .../Cargo/Systems/CargoSystem.Shuttle.cs | 17 +++++++++++------ .../Cargo/Systems/CargoSystem.Telepad.cs | 12 +++++++----- Content.Server/Cargo/Systems/CargoSystem.cs | 5 +++-- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs b/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs index 4d73caacb2..74fdf149d9 100644 --- a/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs +++ b/Content.Client/Cargo/Systems/CargoSystem.Telepad.cs @@ -7,6 +7,8 @@ namespace Content.Client.Cargo.Systems; public sealed partial class CargoSystem { + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + private static readonly Animation CargoTelepadBeamAnimation = new() { Length = TimeSpan.FromSeconds(0.5), @@ -65,7 +67,7 @@ public sealed partial class CargoSystem if (!Resolve(component.Owner, ref sprite)) return; - component.TryGetData(CargoTelepadVisuals.State, out CargoTelepadState? state); + _appearance.TryGetData(component.Owner, CargoTelepadVisuals.State, out CargoTelepadState? state); AnimationPlayerComponent? player = null; switch (state) diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 60763a2e97..886cbc6889 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -159,9 +159,7 @@ namespace Content.Server.Cargo.Systems _idCardSystem.TryFindIdCard(player, out var idCard); order.SetApproverData(idCard); - - - SoundSystem.Play(component.ConfirmSound.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid); + _audio.PlayPvs(_audio.GetSound(component.ConfirmSound), uid); // Log order approval _adminLogger.Add(LogType.Action, LogImpact.Low, @@ -233,7 +231,7 @@ namespace Content.Server.Cargo.Systems private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component) { - SoundSystem.Play(component.ErrorSound.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid); + _audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid); } private CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, int index) diff --git a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs index 0ab1ab07bc..b3ef320e72 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs @@ -288,13 +288,18 @@ public sealed partial class CargoSystem var possibleNames = _protoMan.Index(prototype.NameDataset).Values; var name = _random.Pick(possibleNames); - var shuttleUid = _map.LoadGrid(CargoMap.Value, prototype.Path.ToString()); - var xform = Transform(shuttleUid!.Value); - MetaData(shuttleUid!.Value).EntityName = name; + if (!_map.TryLoad(CargoMap.Value, prototype.Path.ToString(), out var gridList) || gridList == null) + { + _sawmill.Error($"Could not load the cargo shuttle!"); + return; + } + var shuttleUid = gridList[0]; + var xform = Transform(shuttleUid); + MetaData(shuttleUid).EntityName = name; // TODO: Something better like a bounds check. xform.LocalPosition += 100 * _index; - var comp = EnsureComp(shuttleUid!.Value); + var comp = EnsureComp(shuttleUid); comp.Station = component.Owner; comp.Coordinates = xform.Coordinates; @@ -302,7 +307,7 @@ public sealed partial class CargoSystem comp.NextCall = _timing.CurTime + TimeSpan.FromSeconds(comp.Cooldown); UpdateShuttleCargoConsoles(comp); _index++; - _sawmill.Info($"Added cargo shuttle to {ToPrettyString(shuttleUid!.Value)}"); + _sawmill.Info($"Added cargo shuttle to {ToPrettyString(shuttleUid)}"); } private void SellPallets(CargoShuttleComponent component, StationBankAccountComponent bank) @@ -512,7 +517,7 @@ public sealed partial class CargoSystem if (IsBlocked(shuttle)) { _popup.PopupEntity(Loc.GetString("cargo-shuttle-console-organics"), player.Value, player.Value); - SoundSystem.Play(component.DenySound.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid); + _audio.PlayPvs(_audio.GetSound(component.DenySound), uid); return; }; diff --git a/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs b/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs index c8dd15077c..e44ad80f74 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Telepad.cs @@ -1,3 +1,4 @@ +using Content.Server.Cargo.Systems; using Content.Server.Cargo.Components; using Content.Server.Labels.Components; using Content.Server.Paper; @@ -13,6 +14,7 @@ namespace Content.Server.Cargo.Systems; public sealed partial class CargoSystem { [Dependency] private readonly PaperSystem _paperSystem = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; private void InitializeTelepad() { @@ -32,7 +34,7 @@ public sealed partial class CargoSystem if (comp.CurrentState == CargoTelepadState.Unpowered) { comp.CurrentState = CargoTelepadState.Idle; - appearance?.SetData(CargoTelepadVisuals.State, CargoTelepadState.Idle); + _appearance.SetData(comp.Owner, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance); comp.Accumulator = comp.Delay; continue; } @@ -43,7 +45,7 @@ public sealed partial class CargoSystem if (comp.Accumulator > 0f) { comp.CurrentState = CargoTelepadState.Idle; - appearance?.SetData(CargoTelepadVisuals.State, CargoTelepadState.Idle); + _appearance.SetData(comp.Owner, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance); continue; } @@ -78,12 +80,12 @@ public sealed partial class CargoSystem if (order.Amount <= 0) orderDatabase.Orders.Remove(index); - SoundSystem.Play(comp.TeleportSound.GetSound(), Filter.Pvs(comp.Owner), comp.Owner, AudioParams.Default.WithVolume(-8f)); + _audio.PlayPvs(_audio.GetSound(comp.TeleportSound), comp.Owner, AudioParams.Default.WithVolume(-8f)); SpawnProduct(comp, order); UpdateOrders(orderDatabase); comp.CurrentState = CargoTelepadState.Teleporting; - appearance?.SetData(CargoTelepadVisuals.State, CargoTelepadState.Teleporting); + _appearance.SetData(comp.Owner, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance); comp.Accumulator += comp.Delay; } } @@ -106,7 +108,7 @@ public sealed partial class CargoSystem TryComp(component.Owner, out var appearance); component.CurrentState = CargoTelepadState.Unpowered; - appearance?.SetData(CargoTelepadVisuals.State, CargoTelepadState.Unpowered); + _appearance.SetData(component.Owner, CargoTelepadVisuals.State, CargoTelepadState.Unpowered, appearance); } private void OnTelepadPowerChange(EntityUid uid, CargoTelepadComponent component, ref PowerChangedEvent args) diff --git a/Content.Server/Cargo/Systems/CargoSystem.cs b/Content.Server/Cargo/Systems/CargoSystem.cs index a6401ad839..7297e5ab93 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.cs @@ -11,6 +11,7 @@ public sealed partial class CargoSystem : SharedCargoSystem { [Dependency] private readonly IPrototypeManager _protoMan = default!; [Dependency] private readonly ItemSlotsSystem _slots = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; private ISawmill _sawmill = default!; @@ -45,8 +46,8 @@ public sealed partial class CargoSystem : SharedCargoSystem } // please don't delete this thank you - public void UpdateBankAccount(StationBankAccountComponent component, int BalanceAdded) + public void UpdateBankAccount(StationBankAccountComponent component, int balanceAdded) { - component.Balance += BalanceAdded; + component.Balance += balanceAdded; } }