diff --git a/Content.Shared/_CP14/Door/CP14DoorInteractionPopupComponent.cs b/Content.Shared/_CP14/Door/CP14DoorInteractionPopupComponent.cs new file mode 100644 index 0000000000..60a6c7575f --- /dev/null +++ b/Content.Shared/_CP14/Door/CP14DoorInteractionPopupComponent.cs @@ -0,0 +1,24 @@ +using Robust.Shared.Audio; + +namespace Content.Shared._CP14.Door; + +[RegisterComponent, Access(typeof(CP14DoorInteractionPopupSystem))] +public sealed partial class CP14DoorInteractionPopupComponent : Component +{ + /// + /// Time delay between interactions to avoid spam. + /// + [DataField("interactDelay")] + [ViewVariables(VVAccess.ReadWrite)] + public TimeSpan InteractDelay = TimeSpan.FromSeconds(1.0); + + [DataField("interactString")] + public string InteractString = "cp14-closed-door-interact-popup"; + + [DataField("interactSound")] + public SoundSpecifier InteractSound; + + [ViewVariables(VVAccess.ReadWrite)] + public TimeSpan LastInteractTime = TimeSpan.Zero; + +} diff --git a/Content.Shared/_CP14/Door/CP14SharedDoorInteractionPopupSystem.cs b/Content.Shared/_CP14/Door/CP14SharedDoorInteractionPopupSystem.cs new file mode 100644 index 0000000000..7e53cbc76a --- /dev/null +++ b/Content.Shared/_CP14/Door/CP14SharedDoorInteractionPopupSystem.cs @@ -0,0 +1,36 @@ +using Content.Shared.Interaction; +using Content.Shared.Lock; +using Content.Shared.Popups; +using Robust.Shared.Audio.Systems; +using Robust.Shared.Timing; + +namespace Content.Shared._CP14.Door; + +public sealed class CP14DoorInteractionPopupSystem : EntitySystem +{ + [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnActivatedInWorld); + } + + private void OnActivatedInWorld(Entity door, ref ActivateInWorldEvent args) + { + if (TryComp(args.Target, out var lockComponent) && !lockComponent.Locked) + return; + + var curTime = _timing.CurTime; + + if (curTime < door.Comp.LastInteractTime + door.Comp.InteractDelay) + return; + + _popup.PopupPredicted(Loc.GetString(door.Comp.InteractString), args.Target, args.Target); + _audio.PlayPredicted(door.Comp.InteractSound, args.Target, args.Target); + + door.Comp.LastInteractTime = curTime; + } +} diff --git a/Resources/Audio/_CP14/Structures/attributions.yml b/Resources/Audio/_CP14/Structures/attributions.yml new file mode 100644 index 0000000000..2a36dc7a44 --- /dev/null +++ b/Resources/Audio/_CP14/Structures/attributions.yml @@ -0,0 +1,9 @@ +- files: ["doorknob_1.ogg"] + license: "CC-BY-3.0" + copyright: 'by Leady.' + source: "https://freesound.org/people/Leady/sounds/12739/" + +- files: ["doorknob_2.ogg"] + license: "CC0-1.0" + copyright: 'by BenjaminNelan.' + source: "https://freesound.org/people/BenjaminNelan/sounds/321087/" diff --git a/Resources/Audio/_CP14/Structures/doorknob_1.ogg b/Resources/Audio/_CP14/Structures/doorknob_1.ogg new file mode 100644 index 0000000000..da69a8f5ac Binary files /dev/null and b/Resources/Audio/_CP14/Structures/doorknob_1.ogg differ diff --git a/Resources/Audio/_CP14/Structures/doorknob_2.ogg b/Resources/Audio/_CP14/Structures/doorknob_2.ogg new file mode 100644 index 0000000000..4287e1d89b Binary files /dev/null and b/Resources/Audio/_CP14/Structures/doorknob_2.ogg differ diff --git a/Resources/Locale/en-US/_CP14/doors/door.ftl b/Resources/Locale/en-US/_CP14/doors/door.ftl new file mode 100644 index 0000000000..e63e0e22a4 --- /dev/null +++ b/Resources/Locale/en-US/_CP14/doors/door.ftl @@ -0,0 +1 @@ +cp14-closed-door-interact-popup = Locked. diff --git a/Resources/Locale/ru-RU/_CP14/doors/door.ftl b/Resources/Locale/ru-RU/_CP14/doors/door.ftl new file mode 100644 index 0000000000..116b2eab6d --- /dev/null +++ b/Resources/Locale/ru-RU/_CP14/doors/door.ftl @@ -0,0 +1 @@ +cp14-closed-door-interact-popup = Заперто. diff --git a/Resources/Prototypes/_CP14/Entities/Structures/Doors/base.yml b/Resources/Prototypes/_CP14/Entities/Structures/Doors/base.yml index 7204121b41..6c47b3375d 100644 --- a/Resources/Prototypes/_CP14/Entities/Structures/Doors/base.yml +++ b/Resources/Prototypes/_CP14/Entities/Structures/Doors/base.yml @@ -18,4 +18,10 @@ - type: Lock locked: false - type: PlacementReplacement - key: walls \ No newline at end of file + key: walls + - type: CP14DoorInteractionPopup + interactSound: + collection: CP14Doorknob + params: + variation: 0.03 + volume: -5 diff --git a/Resources/Prototypes/_CP14/SoundCollections/structures.yml b/Resources/Prototypes/_CP14/SoundCollections/structures.yml new file mode 100644 index 0000000000..16369b7d8a --- /dev/null +++ b/Resources/Prototypes/_CP14/SoundCollections/structures.yml @@ -0,0 +1,5 @@ +- type: soundCollection + id: CP14Doorknob + files: + - /Audio/_CP14/Structures/doorknob_1.ogg + - /Audio/_CP14/Structures/doorknob_2.ogg