All computers play the keyboard sound + small research client cleanup (#7312)

This commit is contained in:
Rane
2022-04-08 17:17:05 -04:00
committed by GitHub
parent 6e91538baf
commit 427f7378c3
7 changed files with 22 additions and 26 deletions

View File

@@ -23,6 +23,7 @@ namespace Content.Client.Entry
"EmitSoundOnLand", "EmitSoundOnLand",
"EmitSoundOnTrigger", "EmitSoundOnTrigger",
"EmitSoundOnActivate", "EmitSoundOnActivate",
"EmitSoundOnUIOpen",
"NameIdentifier", "NameIdentifier",
"HeatResistance", "HeatResistance",
"EntityStorage", "EntityStorage",

View File

@@ -17,9 +17,6 @@ namespace Content.Server.Research.Components
[Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[DataField("sound")]
private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard");
[ViewVariables] private bool Powered => !_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private bool Powered => !_entMan.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ResearchConsoleUiKey.Key);
@@ -92,19 +89,5 @@ namespace Content.Server.Research.Components
return new ResearchConsoleBoundInterfaceState(points, pointsPerSecond); return new ResearchConsoleBoundInterfaceState(points, pointsPerSecond);
} }
/// <summary>
/// Open the user interface on a certain player session.
/// </summary>
/// <param name="session">Session where the UI will be shown</param>
public void OpenUserInterface(IPlayerSession session)
{
UserInterface?.Open(session);
}
public void PlayKeyboardSound()
{
SoundSystem.Play(Filter.Pvs(Owner), _soundCollectionName.GetSound(), Owner, AudioParams.Default);
}
} }
} }

View File

@@ -1,8 +1,6 @@
using Content.Server.UserInterface;
using Content.Server.Research.Components; using Content.Server.Research.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace Content.Server.Research namespace Content.Server.Research
{ {
[UsedImplicitly] [UsedImplicitly]
@@ -17,12 +15,6 @@ namespace Content.Server.Research
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<ResearchConsoleComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpen);
}
private void OnAfterUIOpen(EntityUid uid, ResearchConsoleComponent component, AfterActivatableUIOpenEvent args)
{
component.PlayKeyboardSound();
} }
public bool RegisterServer(ResearchServerComponent server) public bool RegisterServer(ResearchServerComponent server)

View File

@@ -0,0 +1,10 @@
namespace Content.Server.Sound.Components
{
/// <summary>
/// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
/// </summary>
[RegisterComponent]
public sealed class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
{
}
}

View File

@@ -2,6 +2,7 @@ using Content.Server.Explosion.EntitySystems;
using Content.Server.Interaction.Components; using Content.Server.Interaction.Components;
using Content.Server.Sound.Components; using Content.Server.Sound.Components;
using Content.Server.Throwing; using Content.Server.Throwing;
using Content.Server.UserInterface;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Throwing; using Content.Shared.Throwing;
@@ -29,6 +30,7 @@ namespace Content.Server.Sound
SubscribeLocalEvent<EmitSoundOnThrowComponent, ThrownEvent>(HandleEmitSoundOnThrown); SubscribeLocalEvent<EmitSoundOnThrowComponent, ThrownEvent>(HandleEmitSoundOnThrown);
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld); SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld);
SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger); SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger);
SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);
} }
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args) private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
@@ -64,6 +66,11 @@ namespace Content.Server.Sound
arg.Handled = true; arg.Handled = true;
} }
private void HandleEmitSoundOnUIOpen(EntityUid eUI, BaseEmitSoundComponent component, AfterActivatableUIOpenEvent arg)
{
TryEmitSound(component);
}
private void TryEmitSound(BaseEmitSoundComponent component) private void TryEmitSound(BaseEmitSoundComponent component)
{ {
var audioParams = component.AudioParams.WithPitchScale((float) _random.NextGaussian(1, component.PitchVariation)); var audioParams = component.AudioParams.WithPitchScale((float) _random.NextGaussian(1, component.PitchVariation));

View File

@@ -41,3 +41,6 @@
autoRot: true autoRot: true
offset: "0, 0.4" # shine from the top, not bottom of the computer offset: "0, 0.4" # shine from the top, not bottom of the computer
castShadows: false castShadows: false
- type: EmitSoundOnUIOpen
sound:
collection: Keyboard

View File

@@ -1,5 +1,5 @@
- type: soundCollection - type: soundCollection
id: keyboard id: Keyboard
files: files:
- /Audio/Machines/Keyboard/keyboard1.ogg - /Audio/Machines/Keyboard/keyboard1.ogg
- /Audio/Machines/Keyboard/keyboard2.ogg - /Audio/Machines/Keyboard/keyboard2.ogg