Move TabletopItemVisualizerSystem into TabletopSystem (#13921)
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Content.Client.Tabletop
|
|||||||
[Dependency] private readonly IUserInterfaceManager _uiManger = default!;
|
[Dependency] private readonly IUserInterfaceManager _uiManger = default!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = 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
|
// 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
|
private const float Delay = 1f / 10; // 10 Hz
|
||||||
@@ -48,6 +49,7 @@ namespace Content.Client.Tabletop
|
|||||||
SubscribeNetworkEvent<TabletopPlayEvent>(OnTabletopPlay);
|
SubscribeNetworkEvent<TabletopPlayEvent>(OnTabletopPlay);
|
||||||
SubscribeLocalEvent<TabletopDraggableComponent, ComponentHandleState>(HandleComponentState);
|
SubscribeLocalEvent<TabletopDraggableComponent, ComponentHandleState>(HandleComponentState);
|
||||||
SubscribeLocalEvent<TabletopDraggableComponent, ComponentRemove>(HandleDraggableRemoved);
|
SubscribeLocalEvent<TabletopDraggableComponent, ComponentRemove>(HandleDraggableRemoved);
|
||||||
|
SubscribeLocalEvent<TabletopDraggableComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleDraggableRemoved(EntityUid uid, TabletopDraggableComponent component, ComponentRemove args)
|
private void HandleDraggableRemoved(EntityUid uid, TabletopDraggableComponent component, ComponentRemove args)
|
||||||
@@ -203,6 +205,24 @@ namespace Content.Client.Tabletop
|
|||||||
return false;
|
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<Vector2>(uid, TabletopItemVisuals.Scale, out var scale, args.Component))
|
||||||
|
{
|
||||||
|
args.Sprite.Scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_appearance.TryGetData<int>(uid, TabletopItemVisuals.DrawDepth, out var drawDepth, args.Component))
|
||||||
|
{
|
||||||
|
args.Sprite.DrawDepth = drawDepth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Utility
|
#region Utility
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
namespace Content.Client.Tabletop.Visualizers;
|
|
||||||
|
|
||||||
[RegisterComponent]
|
|
||||||
public sealed class TabletopItemVisualizerComponent : Component
|
|
||||||
{}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
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,7 +20,6 @@ namespace Content.Server.Entry
|
|||||||
"PuddleVisualizer",
|
"PuddleVisualizer",
|
||||||
"UIFragment",
|
"UIFragment",
|
||||||
"PDABorderColor",
|
"PDABorderColor",
|
||||||
"TabletopItemVisualizer",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: TabletopItemVisualizer
|
|
||||||
|
|
||||||
# The pieces
|
# The pieces
|
||||||
- type: entity
|
- type: entity
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
noRot: true
|
noRot: true
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: TabletopItemVisualizer
|
|
||||||
|
|
||||||
# White pieces
|
# White pieces
|
||||||
- type: entity
|
- type: entity
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
noRot: true
|
noRot: true
|
||||||
sprite: Objects/Fun/Tabletop/generic_pieces.rsi
|
sprite: Objects/Fun/Tabletop/generic_pieces.rsi
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: TabletopItemVisualizer
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: RedTabletopPiece
|
id: RedTabletopPiece
|
||||||
|
|||||||
Reference in New Issue
Block a user