Files
tbd-station-14/Content.Server/Tabletop/TabletopSession.cs
Visne 973926fc9a Add chess (and mostly just tabletop backend stuff) (#4429)
* 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>
2021-09-13 19:58:44 +10:00

56 lines
1.7 KiB
C#

using System.Collections.Generic;
using Robust.Server.Player;
using Robust.Shared.Map;
namespace Content.Server.Tabletop
{
/// <summary>
/// A struct for storing data about a running tabletop game.
/// </summary>
public struct TabletopSession
{
/// <summary>
/// The map ID associated with this tabletop game session.
/// </summary>
public MapId MapId;
/// <summary>
/// The set of players currently playing this tabletop game.
/// </summary>
private readonly HashSet<IPlayerSession> _currentPlayers;
/// <param name="mapId">The map ID associated with this tabletop game.</param>
public TabletopSession(MapId mapId)
{
MapId = mapId;
_currentPlayers = new();
}
/// <summary>
/// Returns true if the given player is currently playing this tabletop game.
/// </summary>
public bool IsPlaying(IPlayerSession playerSession)
{
return _currentPlayers.Contains(playerSession);
}
/// <summary>
/// Store that this player has started playing this tabletop game. If the player was already playing, nothing
/// happens.
/// </summary>
public void StartPlaying(IPlayerSession playerSession)
{
_currentPlayers.Add(playerSession);
}
/// <summary>
/// Store that this player has stopped playing this tabletop game. If the player was not playing, nothing
/// happens.
/// </summary>
public void StopPlaying(IPlayerSession playerSession)
{
_currentPlayers.Remove(playerSession);
}
}
}