diff --git a/Content.Server/Andromeda/Signature/SignatureSystem.cs b/Content.Server/Andromeda/Signature/SignatureSystem.cs new file mode 100644 index 00000000000..c34ef13cdc5 --- /dev/null +++ b/Content.Server/Andromeda/Signature/SignatureSystem.cs @@ -0,0 +1,90 @@ +using Content.Server.Access.Systems; +using Content.Server.Paper; +using Content.Server.Popups; +using Content.Shared.Paper; +using Content.Shared.Popups; +using Content.Shared.Tag; +using Content.Shared.Verbs; +using Robust.Server.Audio; +using Robust.Shared.Player; + +namespace Content.Server.DeltaV.Paper; + +public sealed class SignatureSystem : EntitySystem +{ + [Dependency] private readonly AudioSystem _audio = default!; + [Dependency] private readonly IdCardSystem _idCard = default!; + [Dependency] private readonly PaperSystem _paper = default!; + [Dependency] private readonly PopupSystem _popup = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; + private const string SignatureStampState = "paper_stamp-signature"; + + public override void Initialize() + { + SubscribeLocalEvent>(OnGetAltVerbs); + } + + private void OnGetAltVerbs(EntityUid uid, PaperComponent component, GetVerbsEvent args) + { + if (!args.CanAccess || !args.CanInteract) + return; + + var pen = args.Using; + if (pen == null || !_tagSystem.HasTag(pen.Value, "Write")) + return; + + AlternativeVerb verb = new() + { + Act = () => + { + TrySignPaper((uid, component), args.User); + }, + Text = Loc.GetString("paper-sign-verb"), + DoContactInteraction = true, + Priority = 10 + }; + args.Verbs.Add(verb); + } + + public bool TrySignPaper(Entity paper, EntityUid signer) + { + var paperComp = paper.Comp; + if (!Resolve(paper, ref paperComp)) + return false; + + var signatureName = DetermineEntitySignature(signer); + + var stampInfo = new StampDisplayInfo() + { + StampedName = signatureName, + StampedColor = Color.DarkSlateGray, + }; + + if (!paperComp.StampedBy.Contains(stampInfo) && _paper.TryStamp(paper, stampInfo, SignatureStampState, paperComp)) + { + var signedSelfMessage = Loc.GetString("paper-signed-self", ("target", paper)); + _popup.PopupEntity(signedSelfMessage, signer, signer); + + _audio.PlayPvs(paperComp.Sound, signer); + + _paper.UpdateUserInterface(paper, paperComp); + + return true; + } + else + { + _popup.PopupEntity(Loc.GetString("paper-signed-failure", ("target", paper)), signer, signer, PopupType.SmallCaution); + return false; + } + } + + private string DetermineEntitySignature(EntityUid uid) + { + if (_idCard.TryFindIdCard(uid, out var id) && !string.IsNullOrWhiteSpace(id.Comp.FullName)) + { + return id.Comp.FullName; + } + + return Name(uid); + } +} \ No newline at end of file diff --git a/Resources/Locale/ru-RU/Andromeda/papers/signature.ftl b/Resources/Locale/ru-RU/Andromeda/papers/signature.ftl new file mode 100644 index 00000000000..bafe2ff0a40 --- /dev/null +++ b/Resources/Locale/ru-RU/Andromeda/papers/signature.ftl @@ -0,0 +1,3 @@ +paper-sign-verb = Расписаться +paper-signed-self = Вы расписались. +paper-signed-failure = Вы не можете расписаться. \ No newline at end of file diff --git a/Resources/Textures/Objects/Misc/bureaucracy.rsi/meta.json b/Resources/Textures/Objects/Misc/bureaucracy.rsi/meta.json index 6f679c90426..56fdc52a4d4 100644 --- a/Resources/Textures/Objects/Misc/bureaucracy.rsi/meta.json +++ b/Resources/Textures/Objects/Misc/bureaucracy.rsi/meta.json @@ -262,6 +262,9 @@ }, { "name": "paper_stamp-psychologist" + }, + { + "name": "paper_stamp-signature" } ] } diff --git a/Resources/Textures/Objects/Misc/bureaucracy.rsi/paper_stamp-signature.png b/Resources/Textures/Objects/Misc/bureaucracy.rsi/paper_stamp-signature.png new file mode 100644 index 00000000000..6a7aa083ee5 Binary files /dev/null and b/Resources/Textures/Objects/Misc/bureaucracy.rsi/paper_stamp-signature.png differ