* Add draggable tabletop component * Use EntityCoordinates instead * Don't send coordinates every frame * Add chessboard + verb WIP * Add documentation, verb networking works now * Work so far Need PVS refactor before being able to continue Current code is broken * viewsubscriber magic * yes * Fix map creation * Add chess pieces, attempt prediction * Add chess sprites and yml * Clamping + other stuff * fix * stuff * StopDragging() StartDragging() * add piece grabbing * Refactor dragging player to seperate event * 🤣 Who did this 🤣💯👌 * 📮 sussy 📮 * Update chessboard sprite, scale piece while dragging * yes * ye * y * Close tabletop window when player dies * Make interaction check more sane * Fix funny behaviour when stunned * Add icon * Fix rsi * Make time passed check more accurate Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Use EyeManager.PixelsPerMeter Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Add missing import * Move viewport properties to XAML * Make shared system and component abstract * Use built in EntityManager * Use RaiseNetworkEvent instead of SendSystemNetworkMessage * Cache ViewSubscriberSystem * Move unnecessary code to prototype * Delete map on component shutdown instead of round restart * Make documentation match rest of codebase * Use ComponentManager instead of TryGetComponent * Use TryGetComponent instead of GetComponent * Add nullspace check to ClampPositionToViewport() * Set world pos instead of local pos * Improve server side verification * Use visualizer * Add netsync: false to sprites using visualizer * Close window when chessboard is picked up * Update to master * Fix bug when opening window while another is opened * Use ComponentManager * Use TryGetValue Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
using System;
|
|
using Content.Shared.Hands.Components;
|
|
using Content.Shared.Interaction.Helpers;
|
|
using Content.Shared.MobState.Components;
|
|
using Content.Shared.Stunnable;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Shared.Tabletop
|
|
{
|
|
public abstract class SharedTabletopSystem : EntitySystem
|
|
{
|
|
[Serializable, NetSerializable]
|
|
public sealed class TabletopDraggableComponentState : ComponentState
|
|
{
|
|
public NetUserId? DraggingPlayer;
|
|
|
|
public TabletopDraggableComponentState(NetUserId? draggingPlayer)
|
|
{
|
|
DraggingPlayer = draggingPlayer;
|
|
}
|
|
}
|
|
|
|
#region Utility
|
|
|
|
/// <summary>
|
|
/// Whether the table exists, is in range and the player is alive.
|
|
/// </summary>
|
|
/// <param name="playerEntity">The player entity to check.</param>
|
|
/// <param name="table">The table entity to check.</param>
|
|
protected static bool CanSeeTable(IEntity playerEntity, IEntity? table)
|
|
{
|
|
if (table?.Transform.Parent?.Owner is not { } parent)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (!parent.HasComponent<MapComponent>() && !parent.HasComponent<IMapGridComponent>())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var alive = playerEntity.TryGetComponent<SharedMobStateComponent>(out var mob) && mob.IsAlive();
|
|
var inRange = playerEntity.InRangeUnobstructed(table);
|
|
|
|
return alive && inRange;
|
|
}
|
|
|
|
protected static bool StunnedOrNoHands(IEntity playerEntity)
|
|
{
|
|
var stunned = playerEntity.TryGetComponent<SharedStunnableComponent>(out var stun) &&
|
|
stun.Stunned;
|
|
var hasHand = playerEntity.TryGetComponent<SharedHandsComponent>(out var handsComponent) &&
|
|
handsComponent.Hands.Count > 0;
|
|
|
|
return stunned || !hasHand;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|