using Content.Shared.ActionBlocker; using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Shared.Analyzers; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Tabletop.Components { /// /// A component that makes an object playable as a tabletop game. /// [RegisterComponent, Friend(typeof(TabletopSystem))] public class TabletopGameComponent : Component { public override string Name => "TabletopGame"; [DataField("boardName")] public string BoardName { get; } = "tabletop-default-board-name"; [DataField("setup", required: true)] public TabletopSetup Setup { get; } = new TabletopChessSetup(); [DataField("size")] public Vector2i Size { get; } = (300, 300); [DataField("cameraZoom")] public Vector2 CameraZoom { get; } = Vector2.One; [ViewVariables] public TabletopSession? Session { get; set; } = null; /// /// A verb that allows the player to start playing a tabletop game. /// [Verb] public class PlayVerb : Verb { protected override void GetData(IEntity user, TabletopGameComponent component, VerbData data) { if (!user.HasComponent() || !EntitySystem.Get().CanInteract(user)) { data.Visibility = VerbVisibility.Invisible; return; } data.Text = Loc.GetString("tabletop-verb-play-game"); data.IconTexture = "/Textures/Interface/VerbIcons/die.svg.192dpi.png"; } protected override void Activate(IEntity user, TabletopGameComponent component) { if(user.TryGetComponent(out ActorComponent? actor)) EntitySystem.Get().OpenSessionFor(actor.PlayerSession, component.Owner.Uid); } } } }