2021-11-22 23:22:59 -08:00
|
|
|
using Content.Shared.Tabletop;
|
2021-09-13 11:58:44 +02:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Client.GameObjects;
|
2021-11-22 23:22:59 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-05 18:09:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-09-13 11:58:44 +02:00
|
|
|
using Robust.Shared.Maths;
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.Tabletop.Visualizers
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class TabletopItemVisualizer : AppearanceVisualizer
|
2021-09-13 11:58:44 +02:00
|
|
|
{
|
|
|
|
|
public override void OnChangeData(AppearanceComponent appearance)
|
|
|
|
|
{
|
2021-12-05 18:09:01 +01:00
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
if (!entities.TryGetComponent<ISpriteComponent>(appearance.Owner, out var sprite))
|
2021-09-13 11:58:44 +02:00
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|