Fix sound on material reclaimer (#21030)

* Fix saw sound error on client

The sound tried to play using shared PlayPvs which doesn't work on client. PlayPredicted handles client and server.

Fixed NextSound not playing again while continuously gibbing items.

* Fix duplicate splat sound on Recycler gibbing
This commit is contained in:
ShadowCommander
2023-10-15 22:30:35 -07:00
committed by GitHub
parent e40172e07b
commit c20bf50f40
2 changed files with 18 additions and 4 deletions

View File

@@ -35,11 +35,17 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
SubscribeLocalEvent<MaterialReclaimerComponent, EntityUnpausedEvent>(OnUnpaused);
SubscribeLocalEvent<MaterialReclaimerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<MaterialReclaimerComponent, GotEmaggedEvent>(OnEmagged);
SubscribeLocalEvent<MaterialReclaimerComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<CollideMaterialReclaimerComponent, StartCollideEvent>(OnCollide);
SubscribeLocalEvent<ActiveMaterialReclaimerComponent, ComponentStartup>(OnActiveStartup);
SubscribeLocalEvent<ActiveMaterialReclaimerComponent, EntityUnpausedEvent>(OnActiveUnpaused);
}
private void OnMapInit(EntityUid uid, MaterialReclaimerComponent component, MapInitEvent args)
{
component.NextSound = Timing.CurTime;
}
private void OnShutdown(EntityUid uid, MaterialReclaimerComponent component, ComponentShutdown args)
{
component.Stream?.Stop();
@@ -109,8 +115,11 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
}
if (Timing.CurTime > component.NextSound)
component.Stream = _audio.PlayPvs(component.Sound, uid);
component.NextSound = Timing.CurTime + component.SoundCooldown;
{
component.Stream = _audio.PlayPredicted(component.Sound, uid, user);
component.NextSound = Timing.CurTime + component.SoundCooldown;
}
var duration = GetReclaimingDuration(uid, item, component);
// if it's instant, don't bother with all the active comp stuff.