Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Content.Shared/Sound/SharedEmitSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Throwing;
using Content.Shared.UserInterface;
using Content.Shared.Whitelist;
using Content.Shared._CorvaxGoob.Sound.Components; // CorvaxGoob
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
Expand Down Expand Up @@ -53,7 +54,9 @@ public override void Initialize()
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(OnEmitSoundOnDrop);
SubscribeLocalEvent<EmitSoundOnInteractUsingComponent, InteractUsingEvent>(OnEmitSoundOnInteractUsing);
SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);

SubscribeLocalEvent<EmitAmbientOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitAmbientOnUIOpen); // CorvaxGoob
SubscribeLocalEvent<EmitAmbientOnUIOpenComponent, BoundUIClosedEvent>(HandleEmitAmbientOnUIClose); // CorvaxGoob
SubscribeLocalEvent<EmitSoundOnUICloseComponent, BoundUIClosedEvent>(HandleEmitSoundOnUIClose);// CorvaxGoob
Comment on lines +57 to +59

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не легче CorvaxGoob-Start и Corvax-End поставить?

SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);

SubscribeLocalEvent<SoundWhileAliveComponent, MobStateChangedEvent>(OnMobState);
Expand Down Expand Up @@ -197,4 +200,24 @@ private void OnEmitSoundOnCollide(EntityUid uid, EmitSoundOnCollideComponent com
public virtual void SetEnabled(Entity<SpamEmitSoundComponent?> entity, bool enabled)
{
}

// CorvaxGoob start
private void HandleEmitAmbientOnUIOpen(EntityUid uid, EmitAmbientOnUIOpenComponent component, AfterActivatableUIOpenEvent args) {
if (_whitelistSystem.IsWhitelistFail(component.Blacklist, args.User))
{
if (TryComp<AmbientSoundComponent>(uid, out var ambient))
_ambient.SetAmbience(uid, true, ambient);
}
}

private void HandleEmitAmbientOnUIClose(EntityUid uid, EmitAmbientOnUIOpenComponent component, BoundUIClosedEvent args) {
if (TryComp<AmbientSoundComponent>(uid, out var ambient))
_ambient.SetAmbience(uid, false, ambient);
}

private void HandleEmitSoundOnUIClose(EntityUid uid, EmitSoundOnUICloseComponent component, BoundUIClosedEvent args) {
if (_whitelistSystem.IsWhitelistFail(component.Blacklist, args.Actor))
TryEmitSound(uid, component, args.Actor);
}
Comment on lines +205 to +221

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entity<T> попробуй

TryComp заменить на Resolve , чище будет

// CorvaxGoob end
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;

namespace Content.Shared._CorvaxGoob.Sound.Components;

/// <summary>
/// Emit ambient while UI is open.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class EmitAmbientOnUIOpenComponent : Component
{
[DataField]
[AutoNetworkedField]
public EntityWhitelist Blacklist = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Content.Shared.Sound.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;

namespace Content.Shared._CorvaxGoob.Sound.Components;

/// <summary>
/// Emit sound when UI is closed.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class EmitSoundOnUICloseComponent : BaseEmitSoundComponent
{
[DataField]
public EntityWhitelist Blacklist = new();
}
Loading