Fix tabletop error (#7830)

This commit is contained in:
Leon Friedrich
2022-04-28 19:57:51 +12:00
committed by GitHub
parent 0a51fbff1e
commit c2b4a4acef
9 changed files with 54 additions and 121 deletions

View File

@@ -1,28 +0,0 @@
using Content.Shared.Tabletop.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.ViewVariables;
using static Content.Shared.Tabletop.SharedTabletopSystem;
namespace Content.Server.Tabletop.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedTabletopDraggableComponent))]
public sealed class TabletopDraggableComponent : SharedTabletopDraggableComponent
{
private NetUserId? _draggingPlayer;
// The player dragging the piece
[ViewVariables]
public NetUserId? DraggingPlayer
{
get => _draggingPlayer;
set
{
_draggingPlayer = value;
Dirty();
}
}
}
}

View File

@@ -1,11 +1,10 @@
using Content.Server.Tabletop.Components;
using Content.Shared.Tabletop;
using Content.Shared.Tabletop.Components;
using Content.Shared.Tabletop.Events;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Server.Tabletop
@@ -34,18 +33,7 @@ namespace Content.Server.Tabletop
if (!session.Players.ContainsKey(playerSession))
return;
// Return if can not see table or stunned/no hands
if (!EntityManager.EntityExists(msg.TableUid))
return;
if (!CanSeeTable(playerEntity, msg.TableUid) || StunnedOrNoHands(playerEntity))
return;
// Check if moved entity exists and has tabletop draggable component
if (!EntityManager.EntityExists(msg.MovedEntityUid))
return;
if (!EntityManager.HasComponent<TabletopDraggableComponent>(msg.MovedEntityUid))
if (!CanSeeTable(playerEntity, msg.TableUid) || !CanDrag(playerEntity, msg.MovedEntityUid, out _))
return;
// TODO: some permission system, disallow movement if you're not permitted to move the item
@@ -63,6 +51,7 @@ namespace Content.Server.Tabletop
if (!EntityManager.TryGetComponent<TabletopDraggableComponent?>(dragged, out var draggableComponent)) return;
draggableComponent.DraggingPlayer = msg.IsDragging ? args.SenderSession.UserId : null;
Dirty(draggableComponent);
if (!EntityManager.TryGetComponent<AppearanceComponent?>(dragged, out var appearance)) return;

View File

@@ -103,11 +103,8 @@ namespace Content.Server.Tabletop
var gamerUid = (gamer).Owner;
if (actor.PlayerSession.Status > SessionStatus.Connected || CanSeeTable(gamerUid, gamer.Tabletop)
|| !StunnedOrNoHands(gamerUid))
continue;
CloseSessionFor(actor.PlayerSession, gamer.Tabletop);
if (actor.PlayerSession.Status != SessionStatus.InGame || !CanSeeTable(gamerUid, gamer.Tabletop))
CloseSessionFor(actor.PlayerSession, gamer.Tabletop);
}
}
}