mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-04 05:17:28 +00:00
Arcade machine improvements (#24200)
* Give 'em something to talk about
* Wire panel visuals
* Wire graphics tweak
* More ads and thanks
* More ads for a noisy arcade
* New screen for space villain machines
* Implement EmitSoundIntervalComponent and a bunch of arcade noises
* Require power for sounds
* Allow earlier startup intervals
* Orange glow
* Audio attributions
* Include the PR link
* Replace EmitSoundInterval with expanded SpamEmitSound
* Remove pacman-themed arcade sounds
* Documentation good.
* Updated methods to use Entity<T>
* Refactored SpamEmitSound to get rid of accumulator and chance.
* Fixed prewarm logic
* Moved stuff to Shared
* Fix outdated YAML
* Better prediction, auto pause handling
* Make enable/disable reset the timer instead of trying to save it.
(cherry picked from commit b1ba6b5bb6)
This commit is contained in:
@@ -2,12 +2,17 @@ using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Sound.Components;
|
||||
using Content.Shared.UserInterface;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Sound.Components;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Server.Sound;
|
||||
|
||||
public sealed class EmitSoundSystem : SharedEmitSoundSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
@@ -18,18 +23,13 @@ public sealed class EmitSoundSystem : SharedEmitSoundSystem
|
||||
if (!soundSpammer.Enabled)
|
||||
continue;
|
||||
|
||||
soundSpammer.Accumulator += frameTime;
|
||||
if (soundSpammer.Accumulator < soundSpammer.RollInterval)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
soundSpammer.Accumulator -= soundSpammer.RollInterval;
|
||||
|
||||
if (Random.Prob(soundSpammer.PlayChance))
|
||||
if (_timing.CurTime >= soundSpammer.NextSound)
|
||||
{
|
||||
if (soundSpammer.PopUp != null)
|
||||
Popup.PopupEntity(Loc.GetString(soundSpammer.PopUp), uid);
|
||||
TryEmitSound(uid, soundSpammer, predict: false);
|
||||
|
||||
SpamEmitSoundReset((uid, soundSpammer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,8 @@ public sealed class EmitSoundSystem : SharedEmitSoundSystem
|
||||
|
||||
SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger);
|
||||
SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);
|
||||
|
||||
SubscribeLocalEvent<SpamEmitSoundComponent, MapInitEvent>(HandleSpamEmitSoundMapInit);
|
||||
}
|
||||
|
||||
private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args)
|
||||
@@ -52,4 +54,39 @@ public sealed class EmitSoundSystem : SharedEmitSoundSystem
|
||||
TryEmitSound(uid, component, args.User, false);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void HandleSpamEmitSoundMapInit(Entity<SpamEmitSoundComponent> entity, ref MapInitEvent args)
|
||||
{
|
||||
SpamEmitSoundReset(entity);
|
||||
|
||||
// Prewarm so multiple entities have more variation.
|
||||
entity.Comp.NextSound -= Random.Next(entity.Comp.MaxInterval);
|
||||
Dirty(entity);
|
||||
}
|
||||
|
||||
private void SpamEmitSoundReset(Entity<SpamEmitSoundComponent> entity)
|
||||
{
|
||||
if (_net.IsClient)
|
||||
return;
|
||||
|
||||
entity.Comp.NextSound = _timing.CurTime + ((entity.Comp.MinInterval < entity.Comp.MaxInterval)
|
||||
? Random.Next(entity.Comp.MinInterval, entity.Comp.MaxInterval)
|
||||
: entity.Comp.MaxInterval);
|
||||
|
||||
Dirty(entity);
|
||||
}
|
||||
|
||||
public override void SetEnabled(Entity<SpamEmitSoundComponent?> entity, bool enabled)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp, false))
|
||||
return;
|
||||
|
||||
if (entity.Comp.Enabled == enabled)
|
||||
return;
|
||||
|
||||
entity.Comp.Enabled = enabled;
|
||||
|
||||
if (enabled)
|
||||
SpamEmitSoundReset((entity, entity.Comp));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user