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:
@@ -166,13 +166,17 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
|
|||||||
var xform = Transform(uid);
|
var xform = Transform(uid);
|
||||||
|
|
||||||
SpawnMaterialsFromComposition(uid, item, completion * component.Efficiency, xform: xform);
|
SpawnMaterialsFromComposition(uid, item, completion * component.Efficiency, xform: xform);
|
||||||
SpawnChemicalsFromComposition(uid, item, completion, component, xform);
|
|
||||||
|
|
||||||
if (CanGib(uid, item, component))
|
if (CanGib(uid, item, component))
|
||||||
{
|
{
|
||||||
|
SpawnChemicalsFromComposition(uid, item, completion, false, component, xform);
|
||||||
_body.GibBody(item, true);
|
_body.GibBody(item, true);
|
||||||
_appearance.SetData(uid, RecyclerVisuals.Bloody, true);
|
_appearance.SetData(uid, RecyclerVisuals.Bloody, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SpawnChemicalsFromComposition(uid, item, completion, true, component, xform);
|
||||||
|
}
|
||||||
|
|
||||||
QueueDel(item);
|
QueueDel(item);
|
||||||
}
|
}
|
||||||
@@ -213,6 +217,7 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
|
|||||||
private void SpawnChemicalsFromComposition(EntityUid reclaimer,
|
private void SpawnChemicalsFromComposition(EntityUid reclaimer,
|
||||||
EntityUid item,
|
EntityUid item,
|
||||||
float efficiency,
|
float efficiency,
|
||||||
|
bool sound = true,
|
||||||
MaterialReclaimerComponent? reclaimerComponent = null,
|
MaterialReclaimerComponent? reclaimerComponent = null,
|
||||||
TransformComponent? xform = null,
|
TransformComponent? xform = null,
|
||||||
PhysicalCompositionComponent? composition = null)
|
PhysicalCompositionComponent? composition = null)
|
||||||
@@ -248,7 +253,7 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
|
|||||||
_solutionContainer.TryTransferSolution(reclaimer, reclaimerComponent.OutputSolution, totalChemicals, totalChemicals.Volume);
|
_solutionContainer.TryTransferSolution(reclaimer, reclaimerComponent.OutputSolution, totalChemicals, totalChemicals.Volume);
|
||||||
if (totalChemicals.Volume > 0)
|
if (totalChemicals.Volume > 0)
|
||||||
{
|
{
|
||||||
_puddle.TrySpillAt(reclaimer, totalChemicals, out _, transformComponent: xform);
|
_puddle.TrySpillAt(reclaimer, totalChemicals, out _, sound, transformComponent: xform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,17 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<MaterialReclaimerComponent, EntityUnpausedEvent>(OnUnpaused);
|
SubscribeLocalEvent<MaterialReclaimerComponent, EntityUnpausedEvent>(OnUnpaused);
|
||||||
SubscribeLocalEvent<MaterialReclaimerComponent, ExaminedEvent>(OnExamined);
|
SubscribeLocalEvent<MaterialReclaimerComponent, ExaminedEvent>(OnExamined);
|
||||||
SubscribeLocalEvent<MaterialReclaimerComponent, GotEmaggedEvent>(OnEmagged);
|
SubscribeLocalEvent<MaterialReclaimerComponent, GotEmaggedEvent>(OnEmagged);
|
||||||
|
SubscribeLocalEvent<MaterialReclaimerComponent, MapInitEvent>(OnMapInit);
|
||||||
SubscribeLocalEvent<CollideMaterialReclaimerComponent, StartCollideEvent>(OnCollide);
|
SubscribeLocalEvent<CollideMaterialReclaimerComponent, StartCollideEvent>(OnCollide);
|
||||||
SubscribeLocalEvent<ActiveMaterialReclaimerComponent, ComponentStartup>(OnActiveStartup);
|
SubscribeLocalEvent<ActiveMaterialReclaimerComponent, ComponentStartup>(OnActiveStartup);
|
||||||
SubscribeLocalEvent<ActiveMaterialReclaimerComponent, EntityUnpausedEvent>(OnActiveUnpaused);
|
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)
|
private void OnShutdown(EntityUid uid, MaterialReclaimerComponent component, ComponentShutdown args)
|
||||||
{
|
{
|
||||||
component.Stream?.Stop();
|
component.Stream?.Stop();
|
||||||
@@ -109,8 +115,11 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Timing.CurTime > component.NextSound)
|
if (Timing.CurTime > component.NextSound)
|
||||||
component.Stream = _audio.PlayPvs(component.Sound, uid);
|
{
|
||||||
|
component.Stream = _audio.PlayPredicted(component.Sound, uid, user);
|
||||||
|
|
||||||
component.NextSound = Timing.CurTime + component.SoundCooldown;
|
component.NextSound = Timing.CurTime + component.SoundCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
var duration = GetReclaimingDuration(uid, item, component);
|
var duration = GetReclaimingDuration(uid, item, component);
|
||||||
// if it's instant, don't bother with all the active comp stuff.
|
// if it's instant, don't bother with all the active comp stuff.
|
||||||
|
|||||||
Reference in New Issue
Block a user