Пример #1
0
        private void OnInteractUsing(EntityUid uid, PaperComponent paperComp, InteractUsingEvent args)
        {
            if (_tagSystem.HasTag(args.Used, "Write"))
            {
                if (!TryComp <ActorComponent>(args.User, out var actor))
                {
                    return;
                }

                paperComp.Mode = PaperAction.Write;
                UpdateUserInterface(uid, paperComp);
                _uiSystem.GetUiOrNull(uid, PaperUiKey.Key)?.Open(actor.PlayerSession);
                return;
            }

            // If a stamp, attempt to stamp paper
            if (TryComp <StampComponent>(args.Used, out var stampComp) && TryStamp(uid, stampComp.StampedName, stampComp.StampState, paperComp))
            {
                // successfully stamped, play popup
                var stampPaperOtherMessage = Loc.GetString("paper-component-action-stamp-paper-other", ("user", args.User), ("target", args.Target), ("stamp", args.Used));
                _popupSystem.PopupEntity(stampPaperOtherMessage, args.User, Filter.Pvs(args.User, entityManager: EntityManager).RemoveWhereAttachedEntity(puid => puid == args.User));
                var stampPaperSelfMessage = Loc.GetString("paper-component-action-stamp-paper-self", ("target", args.Target), ("stamp", args.Used));
                _popupSystem.PopupEntity(stampPaperSelfMessage, args.User, Filter.Entities(args.User));
            }
        }
Пример #2
0
        private void OnExamined(EntityUid uid, PaperComponent paperComp, ExaminedEvent args)
        {
            if (!args.IsInDetailsRange)
            {
                return;
            }

            if (paperComp.Content != "")
            {
                args.Message.AddMarkup(
                    Loc.GetString(
                        "paper-component-examine-detail-has-words", ("paper", uid)
                        )
                    );
            }

            if (paperComp.StampedBy.Count > 0)
            {
                args.Message.PushNewline();
                string commaSeparated = string.Join(", ", paperComp.StampedBy);
                args.Message.AddMarkup(
                    Loc.GetString(
                        "paper-component-examine-detail-stamped-by", ("paper", uid), ("stamps", commaSeparated))
                    );
            }
        }
Пример #3
0
        private void OnInit(EntityUid uid, PaperComponent paperComp, ComponentInit args)
        {
            paperComp.Mode = PaperAction.Read;
            UpdateUserInterface(uid, paperComp);

            if (TryComp <AppearanceComponent>(uid, out var appearance))
            {
                if (paperComp.Content != "")
                {
                    appearance.SetData(PaperVisuals.Status, PaperStatus.Written);
                }

                if (paperComp.StampState != null)
                {
                    appearance.SetData(PaperVisuals.Stamp, paperComp.StampState);
                }
            }
        }
Пример #4
0
        private void OnInputTextMessage(EntityUid uid, PaperComponent paperComp, PaperInputTextMessage args)
        {
            if (string.IsNullOrEmpty(args.Text))
            {
                return;
            }

            if (args.Text.Length + paperComp.Content.Length <= paperComp.ContentSize)
            {
                paperComp.Content += args.Text + '\n';
            }

            if (TryComp <AppearanceComponent>(uid, out var appearance))
            {
                appearance.SetData(PaperVisuals.Status, PaperStatus.Written);
            }

            if (TryComp <MetaDataComponent>(uid, out var meta))
            {
                meta.EntityDescription = "";
            }

            UpdateUserInterface(uid, paperComp);
        }
Пример #5
0
 private void BeforeUIOpen(EntityUid uid, PaperComponent paperComp, BeforeActivatableUIOpenEvent args)
 {
     paperComp.Mode = PaperAction.Read;
     UpdateUserInterface(uid, paperComp);
 }
Пример #6
0
 private void AfterUIOpen(EntityUid uid, PaperComponent component, BeforeActivatableUIOpenEvent args)
 {
     component.Mode = SharedPaperComponent.PaperAction.Read;
     component.UpdateUserInterface();
 }