* closed door interact popup, resolve #564 * tweak * uh * removed old comment * Update attributions.yml * fix * Update CP14SharedDoorInteractionPopupSystem.cs * fixes --------- Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com> Co-authored-by: Ed <edwardxperia2000@gmail.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared._CP14.Door;
|
||||
|
||||
[RegisterComponent, Access(typeof(CP14DoorInteractionPopupSystem))]
|
||||
public sealed partial class CP14DoorInteractionPopupComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Time delay between interactions to avoid spam.
|
||||
/// </summary>
|
||||
[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;
|
||||
|
||||
}
|
||||
@@ -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<CP14DoorInteractionPopupComponent, ActivateInWorldEvent>(OnActivatedInWorld);
|
||||
}
|
||||
|
||||
private void OnActivatedInWorld(Entity<CP14DoorInteractionPopupComponent> door, ref ActivateInWorldEvent args)
|
||||
{
|
||||
if (TryComp<LockComponent>(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;
|
||||
}
|
||||
}
|
||||
9
Resources/Audio/_CP14/Structures/attributions.yml
Normal file
9
Resources/Audio/_CP14/Structures/attributions.yml
Normal file
@@ -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/"
|
||||
BIN
Resources/Audio/_CP14/Structures/doorknob_1.ogg
Normal file
BIN
Resources/Audio/_CP14/Structures/doorknob_1.ogg
Normal file
Binary file not shown.
BIN
Resources/Audio/_CP14/Structures/doorknob_2.ogg
Normal file
BIN
Resources/Audio/_CP14/Structures/doorknob_2.ogg
Normal file
Binary file not shown.
1
Resources/Locale/en-US/_CP14/doors/door.ftl
Normal file
1
Resources/Locale/en-US/_CP14/doors/door.ftl
Normal file
@@ -0,0 +1 @@
|
||||
cp14-closed-door-interact-popup = Locked.
|
||||
1
Resources/Locale/ru-RU/_CP14/doors/door.ftl
Normal file
1
Resources/Locale/ru-RU/_CP14/doors/door.ftl
Normal file
@@ -0,0 +1 @@
|
||||
cp14-closed-door-interact-popup = Заперто.
|
||||
@@ -18,4 +18,10 @@
|
||||
- type: Lock
|
||||
locked: false
|
||||
- type: PlacementReplacement
|
||||
key: walls
|
||||
key: walls
|
||||
- type: CP14DoorInteractionPopup
|
||||
interactSound:
|
||||
collection: CP14Doorknob
|
||||
params:
|
||||
variation: 0.03
|
||||
volume: -5
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
- type: soundCollection
|
||||
id: CP14Doorknob
|
||||
files:
|
||||
- /Audio/_CP14/Structures/doorknob_1.ogg
|
||||
- /Audio/_CP14/Structures/doorknob_2.ogg
|
||||
Reference in New Issue
Block a user