Loudspeaker

This commit is contained in:
BIGZi0348
2024-12-29 16:00:55 +03:00
parent 7d103834d2
commit 1907ecc399
11 changed files with 153 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
using Robust.Shared.Audio;
namespace Content.Server._White.HopSpeaker;
[RegisterComponent]
public sealed partial class HopSpeakerComponent : Component
{
[DataField("delay")]
public TimeSpan Delay = TimeSpan.FromSeconds(5);
[ViewVariables(VVAccess.ReadOnly)]
public TimeSpan DelayEnd = TimeSpan.Zero;
[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/White/Effects/dynamicNEXT_.ogg");
}

View File

@@ -0,0 +1,39 @@
using Content.Server.Explosion.EntitySystems;
using Content.Server.Chat.Systems;
using Content.Server.Power.Components;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server._White.HopSpeaker;
public sealed partial class HopSpeakerSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HopSpeakerComponent, TriggerEvent>(HandleChatOnTrigger);
}
private void HandleChatOnTrigger(EntityUid uid, HopSpeakerComponent component, TriggerEvent args)
{
if (component.DelayEnd > _gameTiming.CurTime)
return;
if (!TryComp<ApcPowerReceiverComponent>(uid, out var receiverComponent) || !receiverComponent.Powered)
return;
_chat.TrySendInGameICMessage(uid, Loc.GetString("hopspeaker-next"), InGameICChatType.Speak,
ChatTransmitRange.Normal);
_audio.PlayEntity(component.Sound, Filter.Local(), uid, false, AudioParams.Default.WithVolume(-2f));
component.DelayEnd = _gameTiming.CurTime + component.Delay;
}
}

View File

@@ -0,0 +1,10 @@
namespace Content.Server._White.HopSpeaker;
/// <summary>
/// Entity with this component will have a pixel font while speaking.
/// </summary>
[RegisterComponent]
public sealed partial class PapersSpeechComponent : Component
{
}