Resolves TabletopItemVisualizer is Obsolete (#13911)
This commit is contained in:
@@ -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<IEntityManager>();
|
||||
if (!entities.TryGetComponent<SpriteComponent>(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<Vector2>(TabletopItemVisuals.Scale, out var scale))
|
||||
{
|
||||
sprite.Scale = scale;
|
||||
}
|
||||
|
||||
if (appearance.TryGetData<int>(TabletopItemVisuals.DrawDepth, out var drawDepth))
|
||||
{
|
||||
sprite.DrawDepth = drawDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Content.Client.Tabletop.Visualizers;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class TabletopItemVisualizerComponent : Component
|
||||
{}
|
||||
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace Content.Server.Entry
|
||||
"PuddleVisualizer",
|
||||
"UIFragment",
|
||||
"PDABorderColor",
|
||||
"TabletopItemVisualizer",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
netsync: false
|
||||
noRot: true
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: TabletopItemVisualizer
|
||||
|
||||
# The pieces
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
netsync: false
|
||||
noRot: true
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: TabletopItemVisualizer
|
||||
|
||||
# White pieces
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
noRot: true
|
||||
sprite: Objects/Fun/Tabletop/generic_pieces.rsi
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: TabletopItemVisualizer
|
||||
|
||||
- type: entity
|
||||
|
||||
Reference in New Issue
Block a user