add exploding pen from goldeneye (#14421)

This commit is contained in:
deltanedas
2023-03-20 19:32:28 +00:00
committed by GitHub
parent 1ca6ced0cc
commit 93425f0dd5
7 changed files with 71 additions and 8 deletions

View File

@@ -16,11 +16,12 @@ namespace Content.Server.Paper
{
public sealed class PaperSystem : EntitySystem
{
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
@@ -31,6 +32,8 @@ namespace Content.Server.Paper
SubscribeLocalEvent<PaperComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<PaperComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<PaperComponent, PaperInputTextMessage>(OnInputTextMessage);
SubscribeLocalEvent<ActivateOnPaperOpenedComponent, PaperWriteEvent>(OnPaperWrite);
}
private void OnInit(EntityUid uid, PaperComponent paperComp, ComponentInit args)
@@ -81,6 +84,8 @@ namespace Content.Server.Paper
{
if (_tagSystem.HasTag(args.Used, "Write"))
{
var writeEvent = new PaperWriteEvent(uid, args.User);
RaiseLocalEvent(args.Used, ref writeEvent);
if (!TryComp<ActorComponent>(args.User, out var actor))
return;
@@ -124,6 +129,11 @@ namespace Content.Server.Paper
UpdateUserInterface(uid, paperComp);
}
private void OnPaperWrite(EntityUid uid, ActivateOnPaperOpenedComponent comp, ref PaperWriteEvent args)
{
_interaction.UseInHandInteraction(args.User, uid);
}
/// <summary>
/// Accepts the name and state to be stamped onto the paper, returns true if successful.
/// </summary>
@@ -170,4 +180,10 @@ namespace Content.Server.Paper
_uiSystem.GetUiOrNull(uid, PaperUiKey.Key)?.SetState(new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode));
}
}
/// <summary>
/// Event fired when using a pen on paper, opening the UI.
/// </summary>
[ByRefEvent]
public record struct PaperWriteEvent(EntityUid User, EntityUid Paper);
}