Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed stinger grenades causing massive lag spikes #220

Merged
merged 3 commits into from
Sep 7, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Explosion.Components;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Shared.Timing;

namespace Content.Server.Explosion.EntitySystems;

Expand Down Expand Up @@ -114,8 +115,12 @@ public override void Update(float frameTime)
RaiseLocalEvent(uid, ref ev);
}
}
// delete the empty shell of the clusterbomb
Del(uid);
// move the exploded grenade to null space
if (TryComp(uid, out TransformComponent? xform))
_transformSystem.DetachEntity(uid, xform);

// wait a second before deleting to prevent a flood of errors from projectiles
Timer.Spawn(TimeSpan.FromSeconds(1), () => QueueDel(uid));
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Content.Shared/Sound/Components/BaseEmitSoundComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ public abstract partial class BaseEmitSoundComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField(required: true)]
public SoundSpecifier? Sound;

[AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public bool Detach = false;
}
16 changes: 14 additions & 2 deletions Content.Shared/Sound/SharedEmitSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,24 @@ protected void TryEmitSound(EntityUid uid, BaseEmitSoundComponent component, Ent

if (predict)
{
_audioSystem.PlayPredicted(component.Sound, uid, user);
if (component.Detach)
{
if (TryComp(uid, out TransformComponent? xform))
_audioSystem.PlayPredicted(component.Sound, xform.Coordinates, user);
}
else
_audioSystem.PlayPredicted(component.Sound, uid, user);
}
else if (_netMan.IsServer)
{
// don't predict sounds that client couldn't have played already
_audioSystem.PlayPvs(component.Sound, uid);
if (component.Detach)
{
if (TryComp(uid, out TransformComponent? xform))
_audioSystem.PlayPvs(component.Sound, xform.Coordinates);
}
else
_audioSystem.PlayPvs(component.Sound, uid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
- type: EmitSoundOnTrigger
sound:
path: "/Audio/Effects/flash_bang.ogg"
detach: true
- type: SpawnOnTrigger
proto: GrenadeFlashEffect
- type: TimerTriggerVisuals
Expand Down
Loading