diff --git a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizer.cs b/Content.Client/Tabletop/Visualizers/TabletopItemVisualizer.cs deleted file mode 100644 index 0a705a8863..0000000000 --- a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizer.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Content.Shared.Tabletop; -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Maths; - -namespace Content.Client.Tabletop.Visualizers -{ - [UsedImplicitly] - public sealed class TabletopItemVisualizer : AppearanceVisualizer - { - [Obsolete("Subscribe to AppearanceChangeEvent instead.")] - public override void OnChangeData(AppearanceComponent appearance) - { - var entities = IoCManager.Resolve(); - if (!entities.TryGetComponent(appearance.Owner, out var sprite)) - { - 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(TabletopItemVisuals.Scale, out var scale)) - { - sprite.Scale = scale; - } - - if (appearance.TryGetData(TabletopItemVisuals.DrawDepth, out var drawDepth)) - { - sprite.DrawDepth = drawDepth; - } - } - } -} diff --git a/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs b/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs new file mode 100644 index 0000000000..9b75c0f2fd --- /dev/null +++ b/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerComponent.cs @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000000..42ee3abb70 --- /dev/null +++ b/Content.Client/Tabletop/Visualizers/TabletopItemVisualizerSystem.cs @@ -0,0 +1,25 @@ +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 a0d8e41f68..d179d2b7b1 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -20,6 +20,7 @@ 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 963b989306..c4144a7950 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/checkers.yml @@ -35,8 +35,7 @@ netsync: false noRot: true - type: Appearance - visuals: - - type: TabletopItemVisualizer + - 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 ee88d8d129..3bdfb4049e 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/chess.yml @@ -36,8 +36,7 @@ netsync: false noRot: true - type: Appearance - visuals: - - type: TabletopItemVisualizer + - 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 edf7bcf93d..bed3fe243a 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/Tabletop/tabletopGeneric.yml @@ -9,8 +9,7 @@ noRot: true sprite: Objects/Fun/Tabletop/generic_pieces.rsi - type: Appearance - visuals: - - type: TabletopItemVisualizer + - type: TabletopItemVisualizer - type: entity id: RedTabletopPiece