From: Checkraze <71046427+Cheackraze@users.noreply.github.com> Date: Sun, 26 Feb 2023 12:55:44 +0000 (-0500) Subject: Crayonsystem cleanup (#13400) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6ac3c4dc088df25e9429c89ca722c74916a771d4;p=space-station-14.git Crayonsystem cleanup (#13400) Co-authored-by: 0x6273 <0x40@keemail.me> --- diff --git a/Content.Server/Crayon/CrayonSystem.cs b/Content.Server/Crayon/CrayonSystem.cs index 82fb9c157f..3cd43f1654 100644 --- a/Content.Server/Crayon/CrayonSystem.cs +++ b/Content.Server/Crayon/CrayonSystem.cs @@ -23,6 +23,8 @@ public sealed class CrayonSystem : SharedCrayonSystem [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly DecalSystem _decals = default!; [Dependency] private readonly PopupSystem _popup = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; public override void Initialize() { @@ -68,7 +70,7 @@ public sealed class CrayonSystem : SharedCrayonSystem return; if (component.UseSound != null) - SoundSystem.Play(component.UseSound.GetSound(), Filter.Pvs(uid), uid, AudioHelpers.WithVariation(0.125f)); + _audio.PlayPvs(component.UseSound, uid, AudioHelpers.WithVariation(0.125f)); // Decrease "Ammo" component.Charges--; @@ -86,14 +88,18 @@ public sealed class CrayonSystem : SharedCrayonSystem if (args.Handled) return; - if (!TryComp(args.User, out var actor)) return; + if (!TryComp(args.User, out var actor) || + component.UserInterface == null) + { + return; + } - component.UserInterface?.Toggle(actor.PlayerSession); + _uiSystem.ToggleUi(component.UserInterface, actor.PlayerSession); - if (component.UserInterface?.SessionHasOpen(actor.PlayerSession) == true) + if (component.UserInterface?.SubscribedSessions.Contains(actor.PlayerSession) == true) { // Tell the user interface the selected stuff - component.UserInterface.SetState(new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color)); + _uiSystem.SetUiState(component.UserInterface, new CrayonBoundUserInterfaceState(component.SelectedState, component.SelectableColor, component.Color)); } args.Handled = true; @@ -134,7 +140,7 @@ public sealed class CrayonSystem : SharedCrayonSystem private void OnCrayonDropped(EntityUid uid, CrayonComponent component, DroppedEvent args) { if (TryComp(args.User, out var actor)) - component.UserInterface?.Close(actor.PlayerSession); + _uiSystem.TryClose(uid, SharedCrayonComponent.CrayonUiKey.Key, actor.PlayerSession); } private void UseUpCrayon(EntityUid uid, EntityUid user)