]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Crayonsystem cleanup (#13400)
authorCheckraze <71046427+Cheackraze@users.noreply.github.com>
Sun, 26 Feb 2023 12:55:44 +0000 (07:55 -0500)
committerGitHub <noreply@github.com>
Sun, 26 Feb 2023 12:55:44 +0000 (23:55 +1100)
Co-authored-by: 0x6273 <0x40@keemail.me>
Content.Server/Crayon/CrayonSystem.cs

index 82fb9c157ffb2d40b0e335efe84a20c60005dadf..3cd43f16545d81f5150aae1c62fab8d656a93ecb 100644 (file)
@@ -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<ActorComponent>(args.User, out var actor)) return;
+        if (!TryComp<ActorComponent>(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<ActorComponent>(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)