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",
|
"PuddleVisualizer",
|
||||||
"UIFragment",
|
"UIFragment",
|
||||||
"PDABorderColor",
|
"PDABorderColor",
|
||||||
|
"TabletopItemVisualizer",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,7 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: TabletopItemVisualizer
|
||||||
- type: TabletopItemVisualizer
|
|
||||||
|
|
||||||
# The pieces
|
# The pieces
|
||||||
- type: entity
|
- type: entity
|
||||||
|
|||||||
@@ -36,8 +36,7 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: TabletopItemVisualizer
|
||||||
- type: TabletopItemVisualizer
|
|
||||||
|
|
||||||
# White pieces
|
# White pieces
|
||||||
- type: entity
|
- type: entity
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
noRot: true
|
noRot: true
|
||||||
sprite: Objects/Fun/Tabletop/generic_pieces.rsi
|
sprite: Objects/Fun/Tabletop/generic_pieces.rsi
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: TabletopItemVisualizer
|
||||||
- type: TabletopItemVisualizer
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: RedTabletopPiece
|
id: RedTabletopPiece
|
||||||
|
|||||||
Reference in New Issue
Block a user