]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Move TabletopItemVisualizerSystem into TabletopSystem (#13921)
authorVisne <39844191+Visne@users.noreply.github.com>
Sun, 5 Feb 2023 20:02:49 +0000 (21:02 +0100)
committerGitHub <noreply@github.com>
Sun, 5 Feb 2023 20:02:49 +0000 (13:02 -0700)
Content.Client/Tabletop/TabletopSystem.cs
Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs [deleted file]
Content.Client/Tabletop/Visualizers/TabletopItemVisualizerSystem.cs [deleted file]
Content.Server/Entry/IgnoredComponents.cs
Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml
Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml
Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml

index c97e6460fa03cd7d5cf8190e2238350bd0434f69..64e89b63021ef07ed982b237fe3fafccd49bf592 100644 (file)
@@ -26,6 +26,7 @@ namespace Content.Client.Tabletop
         [Dependency] private readonly IUserInterfaceManager _uiManger = default!;
         [Dependency] private readonly IPlayerManager _playerManager = default!;
         [Dependency] private readonly IGameTiming _gameTiming = default!;
+        [Dependency] private readonly AppearanceSystem _appearance = default!;
 
         // Time in seconds to wait until sending the location of a dragged entity to the server again
         private const float Delay = 1f / 10; // 10 Hz
@@ -48,6 +49,7 @@ namespace Content.Client.Tabletop
             SubscribeNetworkEvent<TabletopPlayEvent>(OnTabletopPlay);
             SubscribeLocalEvent<TabletopDraggableComponent, ComponentHandleState>(HandleComponentState);
             SubscribeLocalEvent<TabletopDraggableComponent, ComponentRemove>(HandleDraggableRemoved);
+            SubscribeLocalEvent<TabletopDraggableComponent, AppearanceChangeEvent>(OnAppearanceChange);
         }
 
         private void HandleDraggableRemoved(EntityUid uid, TabletopDraggableComponent component, ComponentRemove args)
@@ -203,6 +205,24 @@ namespace Content.Client.Tabletop
             return false;
         }
 
+        private void OnAppearanceChange(EntityUid uid, TabletopDraggableComponent comp, ref AppearanceChangeEvent args)
+        {
+            if (args.Sprite == null)
+                return;
+
+            // TODO: maybe this can work more nicely, by maybe only having to set the item to "being dragged", and have
+            //  the appearance handle the rest
+            if (_appearance.TryGetData<Vector2>(uid, TabletopItemVisuals.Scale, out var scale, args.Component))
+            {
+                args.Sprite.Scale = scale;
+            }
+
+            if (_appearance.TryGetData<int>(uid, TabletopItemVisuals.DrawDepth, out var drawDepth, args.Component))
+            {
+                args.Sprite.DrawDepth = drawDepth;
+            }
+        }
+
         #endregion
 
         #region Utility
diff --git a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs b/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs
deleted file mode 100644 (file)
index 9b75c0f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace Content.Client.Tabletop.Visualizers;
-
-[RegisterComponent]
-public sealed class TabletopItemVisualizerComponent : Component
-{}
diff --git a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerSystem.cs b/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerSystem.cs
deleted file mode 100644 (file)
index 42ee3ab..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-using Content.Shared.Tabletop;
-using Robust.Client.GameObjects;
-
-namespace Content.Client.Tabletop.Visualizers;
-
-public sealed class TabletopItemVisualizerSystem : VisualizerSystem<TabletopItemVisualizerComponent>
-{
-    protected override void OnAppearanceChange(EntityUid uid, TabletopItemVisualizerComponent comp, ref AppearanceChangeEvent args)
-    {
-        if (args.Sprite == null)
-            return;
-
-        // TODO: maybe this can work more nicely, by maybe only having to set the item to "being dragged", and have
-        //  the appearance handle the rest
-        if (AppearanceSystem.TryGetData<Vector2>(uid, TabletopItemVisuals.Scale, out var scale, args.Component))
-        {
-            args.Sprite.Scale = scale;
-        }
-
-        if (AppearanceSystem.TryGetData<int>(uid, TabletopItemVisuals.DrawDepth, out var drawDepth, args.Component))
-        {
-            args.Sprite.DrawDepth = drawDepth;
-        }
-    }
-}
index d179d2b7b130947db463e0d51be6f8c8b0be232f..a0d8e41f685bfac35b9ac6e3844a6015e845d646 100644 (file)
@@ -20,7 +20,6 @@ namespace Content.Server.Entry
             "PuddleVisualizer",
             "UIFragment",
             "PDABorderColor",
-            "TabletopItemVisualizer",
         };
     }
 }
index c4144a7950fc204f668416ee02be50d7cc0f675a..e2249faaaf51333ae8534834e84dd4d1e3e78cc9 100644 (file)
@@ -35,7 +35,6 @@
     netsync: false
     noRot: true
   - type: Appearance
-  - type: TabletopItemVisualizer
 
 # The pieces
 - type: entity
index 3bdfb4049e28bf2d42b5c1ad385431d5750963f1..a1b5496c4a758ab8d3d1f1b86ed21d3abc2cc8fb 100644 (file)
@@ -36,7 +36,6 @@
     netsync: false
     noRot: true
   - type: Appearance
-  - type: TabletopItemVisualizer
 
 # White pieces
 - type: entity
index bed3fe243a1b95a3311dff0674f66890001006f2..637c07a6a0ec1cf0fde6d14b520dc19b36d14fb7 100644 (file)
@@ -9,7 +9,6 @@
     noRot: true
     sprite: Objects/Fun/Tabletop/generic_pieces.rsi
   - type: Appearance
-  - type: TabletopItemVisualizer
 
 - type: entity
   id: RedTabletopPiece