using Content.Server._NF.Books.Components; using Content.Shared._NF.Books.Systems; using Content.Shared.Interaction; using Content.Shared.Verbs; using Robust.Shared.Player; namespace Content.Server._NF.Books.Systems { public sealed class BookSystem : EntitySystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnActivate); SubscribeLocalEvent>(AddAltVerb); } private void OnActivate(EntityUid uid, HyperlinkBookComponent component, ActivateInWorldEvent args) { if (!TryComp(args.User, out var actor)) return; OpenURL(actor.PlayerSession, component.URL); } private void AddAltVerb(EntityUid uid, HyperlinkBookComponent component, GetVerbsEvent args) { if (!args.CanAccess || !args.CanInteract) return; if (!TryComp(args.User, out var actor)) return; AlternativeVerb verb = new() { Act = () => { OpenURL(actor.PlayerSession, component.URL); }, Text = Loc.GetString("book-read-verb"), Priority = -2 }; args.Verbs.Add(verb); } public void OpenURL(ICommonSession session, string url) { var ev = new OpenURLEvent(url); RaiseNetworkEvent(ev, session.Channel); } } }