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,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;