From 93425f0dd5442fe7980b21be0e67c52dab649ea5 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Mon, 20 Mar 2023 19:32:28 +0000 Subject: [PATCH] add exploding pen from goldeneye (#14421) --- .../Components/OnUseTimerTriggerComponent.cs | 8 ++++++- .../EntitySystems/TriggerSystem.OnUse.cs | 2 +- .../Paper/ActivateOnPaperOpenedComponent.cs | 10 +++++++++ Content.Server/Paper/PaperSystem.cs | 22 ++++++++++++++++--- .../Locale/en-US/store/uplink-catalog.ftl | 3 +++ .../Prototypes/Catalog/uplink_catalog.yml | 16 +++++++++++--- .../Entities/Objects/Weapons/Bombs/pen.yml | 18 +++++++++++++++ 7 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 Content.Server/Paper/ActivateOnPaperOpenedComponent.cs create mode 100644 Resources/Prototypes/Entities/Objects/Weapons/Bombs/pen.yml diff --git a/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs b/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs index be66d23f9d..54969c7752 100644 --- a/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs +++ b/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs @@ -15,7 +15,7 @@ namespace Content.Server.Explosion.Components public List? DelayOptions = null; /// - /// If not null, this timer will periodically play this sound wile active. + /// If not null, this timer will periodically play this sound while active. /// [DataField("beepSound")] public SoundSpecifier? BeepSound; @@ -44,5 +44,11 @@ namespace Content.Server.Explosion.Components /// [DataField("canToggleStartOnStick")] public bool AllowToggleStartOnStick; + + /// + /// Whether you can examine the item to see its timer or not. + /// + [DataField("examinable")] + public bool Examinable = true; } } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs index 4e4ea2cd11..826ed29e12 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs @@ -37,7 +37,7 @@ public sealed partial class TriggerSystem private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args) { - if (args.IsInDetailsRange) + if (args.IsInDetailsRange && component.Examinable) args.PushText(Loc.GetString("examine-trigger-timer", ("time", component.Delay))); } diff --git a/Content.Server/Paper/ActivateOnPaperOpenedComponent.cs b/Content.Server/Paper/ActivateOnPaperOpenedComponent.cs new file mode 100644 index 0000000000..c702ec5850 --- /dev/null +++ b/Content.Server/Paper/ActivateOnPaperOpenedComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Server.Paper; + +/// +/// Activates the item when used to write on paper, as if Z was pressed. +/// +[RegisterComponent] +[Access(typeof(PaperSystem))] +public sealed class ActivateOnPaperOpenedComponent : Component +{ +} diff --git a/Content.Server/Paper/PaperSystem.cs b/Content.Server/Paper/PaperSystem.cs index a5d819477b..a9f4235aa1 100644 --- a/Content.Server/Paper/PaperSystem.cs +++ b/Content.Server/Paper/PaperSystem.cs @@ -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(OnExamined); SubscribeLocalEvent(OnInteractUsing); SubscribeLocalEvent(OnInputTextMessage); + + SubscribeLocalEvent(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(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); + } + /// /// Accepts the name and state to be stamped onto the paper, returns true if successful. /// @@ -170,4 +180,10 @@ namespace Content.Server.Paper _uiSystem.GetUiOrNull(uid, PaperUiKey.Key)?.SetState(new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode)); } } + + /// + /// Event fired when using a pen on paper, opening the UI. + /// + [ByRefEvent] + public record struct PaperWriteEvent(EntityUid User, EntityUid Paper); } diff --git a/Resources/Locale/en-US/store/uplink-catalog.ftl b/Resources/Locale/en-US/store/uplink-catalog.ftl index 6c92ddd29b..55cb414003 100644 --- a/Resources/Locale/en-US/store/uplink-catalog.ftl +++ b/Resources/Locale/en-US/store/uplink-catalog.ftl @@ -42,6 +42,9 @@ uplink-c4-bundle-desc = Because sometimes quantity is quality. Contains 8 C-4 pl uplink-emp-grenade-name = Emp Grenade uplink-emp-grenade-desc = Releases electromagnetic pulses that disrupt or damage many electronic devices or drain power cells. +uplink-exploding-pen-name = Exploding pen +uplink-exploding-pen-desc = A class IV explosive device contained within a standard pen. Comes with a 4 second fuse. + # Ammo uplink-pistol-magazine-name = Pistol Magazine (.35 auto) uplink-pistol-magazine-desc = Pistol magazine with 10 catridges. Compatible with Viper. diff --git a/Resources/Prototypes/Catalog/uplink_catalog.yml b/Resources/Prototypes/Catalog/uplink_catalog.yml index a6928fbc60..fb638897b7 100644 --- a/Resources/Prototypes/Catalog/uplink_catalog.yml +++ b/Resources/Prototypes/Catalog/uplink_catalog.yml @@ -152,6 +152,16 @@ categories: - UplinkExplosives +- type: listing + id: UplinkExplodingPen + name: uplink-exploding-pen-name + description: uplink-exploding-pen-desc + productEntity: PenExploding + cost: + Telecrystal: 5 + categories: + - UplinkExplosives + # Ammo - type: listing @@ -568,7 +578,7 @@ blacklist: components: - SurplusBundle - + - type: listing id: uplinkRevolverCapGunFake name: uplink-revolver-cap-gun-fake-name @@ -750,7 +760,7 @@ Telecrystal: 8 categories: - UplinkMisc - + - type: listing id: UplinkStimkit name: uplink-stimkit-name @@ -760,7 +770,7 @@ Telecrystal: 12 categories: - UplinkMisc - + - type: listing id: UplinkStimpackExperimental name: uplink-experimental-stimpack-name diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Bombs/pen.yml b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/pen.yml new file mode 100644 index 0000000000..f7e746e00f --- /dev/null +++ b/Resources/Prototypes/Entities/Objects/Weapons/Bombs/pen.yml @@ -0,0 +1,18 @@ +- type: entity + name: pen + suffix: Exploding + parent: Pen + description: A dark ink pen. + id: PenExploding + components: + - type: OnUseTimerTrigger + delay: 4 + examinable: false + - type: Explosive + explosionType: Default + maxIntensity: 8 + intensitySlope: 5 + totalIntensity: 20 + canCreateVacuum: false + - type: ActivateOnPaperOpened + - type: ExplodeOnTrigger -- 2.52.0