From 11dbc2eabc9a2edb4a5663adee3d5878c7c63f43 Mon Sep 17 00:00:00 2001 From: Visne <39844191+Visne@users.noreply.github.com> Date: Sun, 5 Feb 2023 21:02:49 +0100 Subject: [PATCH] Move TabletopItemVisualizerSystem into TabletopSystem (#13921) --- Content.Client/Tabletop/TabletopSystem.cs | 20 +++++++++++++++ .../TabletopItemVisualizerComponent.cs | 5 ---- .../TabletopItemVisualizerSystem.cs | 25 ------------------- Content.Server/Entry/IgnoredComponents.cs | 1 - .../Objects/Fun/Tabletop/checkers.yml | 1 - .../Entities/Objects/Fun/Tabletop/chess.yml | 1 - .../Objects/Fun/Tabletop/tabletopGeneric.yml | 1 - 7 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs delete mode 100644 Content.Client/Tabletop/Visualizers/TabletopItemVisualizerSystem.cs diff --git a/Content.Client/Tabletop/TabletopSystem.cs b/Content.Client/Tabletop/TabletopSystem.cs index c97e6460fa..64e89b6302 100644 --- a/Content.Client/Tabletop/TabletopSystem.cs +++ b/Content.Client/Tabletop/TabletopSystem.cs @@ -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(OnTabletopPlay); SubscribeLocalEvent(HandleComponentState); SubscribeLocalEvent(HandleDraggableRemoved); + SubscribeLocalEvent(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(uid, TabletopItemVisuals.Scale, out var scale, args.Component)) + { + args.Sprite.Scale = scale; + } + + if (_appearance.TryGetData(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 index 9b75c0f2fd..0000000000 --- a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs +++ /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 index 42ee3abb70..0000000000 --- a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerSystem.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Content.Shared.Tabletop; -using Robust.Client.GameObjects; - -namespace Content.Client.Tabletop.Visualizers; - -public sealed class TabletopItemVisualizerSystem : VisualizerSystem -{ - 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(uid, TabletopItemVisuals.Scale, out var scale, args.Component)) - { - args.Sprite.Scale = scale; - } - - if (AppearanceSystem.TryGetData(uid, TabletopItemVisuals.DrawDepth, out var drawDepth, args.Component)) - { - args.Sprite.DrawDepth = drawDepth; - } - } -} diff --git a/Content.Server/Entry/IgnoredComponents.cs b/Content.Server/Entry/IgnoredComponents.cs index d179d2b7b1..a0d8e41f68 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -20,7 +20,6 @@ namespace Content.Server.Entry "PuddleVisualizer", "UIFragment", "PDABorderColor", - "TabletopItemVisualizer", }; } } diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml index c4144a7950..e2249faaaf 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml @@ -35,7 +35,6 @@ netsync: false noRot: true - type: Appearance - - type: TabletopItemVisualizer # The pieces - type: entity diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml index 3bdfb4049e..a1b5496c4a 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml @@ -36,7 +36,6 @@ netsync: false noRot: true - type: Appearance - - type: TabletopItemVisualizer # White pieces - type: entity diff --git a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml index bed3fe243a..637c07a6a0 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml @@ -9,7 +9,6 @@ noRot: true sprite: Objects/Fun/Tabletop/generic_pieces.rsi - type: Appearance - - type: TabletopItemVisualizer - type: entity id: RedTabletopPiece