Explosive grenade sound (#15582)

This commit is contained in:
Slava0135
2023-05-02 18:13:39 +03:00
committed by GitHub
parent 21388d0fa6
commit 25e5930c07
13 changed files with 31 additions and 21 deletions

View File

@@ -22,7 +22,4 @@ public sealed class ActiveTimerTriggerComponent : Component
[DataField("beepSound")] [DataField("beepSound")]
public SoundSpecifier? BeepSound; public SoundSpecifier? BeepSound;
[DataField("beepParams")]
public AudioParams BeepParams = AudioParams.Default;
} }

View File

@@ -29,9 +29,6 @@ namespace Content.Server.Explosion.Components
[DataField("beepInterval")] [DataField("beepInterval")]
public float BeepInterval = 1; public float BeepInterval = 1;
[DataField("beepParams")]
public AudioParams BeepParams = AudioParams.Default.WithVolume(-2f);
/// <summary> /// <summary>
/// Should timer be started when it was stuck to another entity. /// Should timer be started when it was stuck to another entity.
/// Used for C4 charges and similar behaviour. /// Used for C4 charges and similar behaviour.

View File

@@ -28,8 +28,7 @@ public sealed partial class TriggerSystem
timerTrigger.Delay, timerTrigger.Delay,
timerTrigger.BeepInterval, timerTrigger.BeepInterval,
timerTrigger.InitialBeepDelay, timerTrigger.InitialBeepDelay,
timerTrigger.BeepSound, timerTrigger.BeepSound);
timerTrigger.BeepParams);
} }
else else

View File

@@ -31,8 +31,7 @@ public sealed partial class TriggerSystem
component.Delay, component.Delay,
component.BeepInterval, component.BeepInterval,
component.InitialBeepDelay, component.InitialBeepDelay,
component.BeepSound, component.BeepSound);
component.BeepParams);
} }
private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args) private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
@@ -150,8 +149,7 @@ public sealed partial class TriggerSystem
component.Delay, component.Delay,
component.BeepInterval, component.BeepInterval,
component.InitialBeepDelay, component.InitialBeepDelay,
component.BeepSound, component.BeepSound);
component.BeepParams);
args.Handled = true; args.Handled = true;
} }

View File

@@ -52,6 +52,7 @@ namespace Content.Server.Explosion.EntitySystems
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly BodySystem _body = default!; [Dependency] private readonly BodySystem _body = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -155,7 +156,7 @@ namespace Content.Server.Explosion.EntitySystems
return triggerEvent.Handled; return triggerEvent.Handled;
} }
public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay , float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound, AudioParams beepParams) public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay , float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound)
{ {
if (delay <= 0) if (delay <= 0)
{ {
@@ -198,7 +199,6 @@ namespace Content.Server.Explosion.EntitySystems
var active = AddComp<ActiveTimerTriggerComponent>(uid); var active = AddComp<ActiveTimerTriggerComponent>(uid);
active.TimeRemaining = delay; active.TimeRemaining = delay;
active.User = user; active.User = user;
active.BeepParams = beepParams;
active.BeepSound = beepSound; active.BeepSound = beepSound;
active.BeepInterval = beepInterval; active.BeepInterval = beepInterval;
active.TimeUntilBeep = initialBeepDelay == null ? active.BeepInterval : initialBeepDelay.Value; active.TimeUntilBeep = initialBeepDelay == null ? active.BeepInterval : initialBeepDelay.Value;
@@ -222,15 +222,16 @@ namespace Content.Server.Explosion.EntitySystems
private void UpdateTimer(float frameTime) private void UpdateTimer(float frameTime)
{ {
HashSet<EntityUid> toRemove = new(); HashSet<EntityUid> toRemove = new();
foreach (var timer in EntityQuery<ActiveTimerTriggerComponent>()) var query = EntityQueryEnumerator<ActiveTimerTriggerComponent>();
while (query.MoveNext(out var uid, out var timer))
{ {
timer.TimeRemaining -= frameTime; timer.TimeRemaining -= frameTime;
timer.TimeUntilBeep -= frameTime; timer.TimeUntilBeep -= frameTime;
if (timer.TimeRemaining <= 0) if (timer.TimeRemaining <= 0)
{ {
Trigger(timer.Owner, timer.User); Trigger(uid, timer.User);
toRemove.Add(timer.Owner); toRemove.Add(uid);
continue; continue;
} }
@@ -238,8 +239,7 @@ namespace Content.Server.Explosion.EntitySystems
continue; continue;
timer.TimeUntilBeep += timer.BeepInterval; timer.TimeUntilBeep += timer.BeepInterval;
var filter = Filter.Pvs(timer.Owner, entityManager: EntityManager); _audio.PlayPvs(timer.BeepSound, uid, timer.BeepSound.Params);
SoundSystem.Play(timer.BeepSound.GetSound(), filter, timer.Owner, timer.BeepParams);
} }
foreach (var uid in toRemove) foreach (var uid in toRemove)

View File

@@ -74,8 +74,7 @@ namespace Content.Server.Nutrition.EntitySystems
timerTrigger.Delay, timerTrigger.Delay,
timerTrigger.BeepInterval, timerTrigger.BeepInterval,
timerTrigger.InitialBeepDelay, timerTrigger.InitialBeepDelay,
timerTrigger.BeepSound, timerTrigger.BeepSound);
timerTrigger.BeepParams);
} }
} }
} }

View File

@@ -27,3 +27,8 @@
license: "CC0-1.0" license: "CC0-1.0"
copyright: "Taken from felix.blume via freesound.org and cropped + mixed from stereo to mono." copyright: "Taken from felix.blume via freesound.org and cropped + mixed from stereo to mono."
source: "https://freesound.org/people/felix.blume/sounds/414093/" source: "https://freesound.org/people/felix.blume/sounds/414093/"
- files: ["beep1.ogg"]
license: "CC0-1.0"
copyright: "Taken from thisusernameis via freesound.org + mixed from stereo to mono."
source: "https://freesound.org/people/thisusernameis/sounds/426891/"

Binary file not shown.

View File

@@ -1232,6 +1232,8 @@
delay: 10 delay: 10
beepSound: beepSound:
path: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg #funny sfx use path: /Audio/Weapons/Guns/MagOut/pistol_magout.ogg #funny sfx use
params:
volume: -2
beepInterval: 1 beepInterval: 1
- type: Explosive - type: Explosive
explosionType: Default explosionType: Default

View File

@@ -25,6 +25,8 @@
delayOptions: [3, 5, 10, 15, 30] delayOptions: [3, 5, 10, 15, 30]
initialBeepDelay: 0 initialBeepDelay: 0
beepSound: /Audio/Machines/Nuke/general_beep.ogg beepSound: /Audio/Machines/Nuke/general_beep.ogg
params:
volume: -2
- type: StaticPrice - type: StaticPrice
price: 40 price: 40

View File

@@ -178,6 +178,8 @@
delay: 7 delay: 7
initialBeepDelay: 0 initialBeepDelay: 0
beepSound: /Audio/Machines/Nuke/general_beep.ogg beepSound: /Audio/Machines/Nuke/general_beep.ogg
params:
volume: -2
- type: ExplodeOnTrigger - type: ExplodeOnTrigger
- type: GibOnTrigger - type: GibOnTrigger
deleteItems: true deleteItems: true

View File

@@ -18,6 +18,8 @@
- type: OnUseTimerTrigger - type: OnUseTimerTrigger
delay: 180 delay: 180
beepSound: /Audio/Machines/Nuke/general_beep.ogg beepSound: /Audio/Machines/Nuke/general_beep.ogg
params:
volume: -2
- type: ExplodeOnTrigger - type: ExplodeOnTrigger
- type: Explosive - type: Explosive
explosionType: Default explosionType: Default

View File

@@ -45,6 +45,13 @@
intensitySlope: 3 intensitySlope: 3
totalIntensity: 120 # about a ~4 tile radius totalIntensity: 120 # about a ~4 tile radius
canCreateVacuum: false canCreateVacuum: false
- type: OnUseTimerTrigger
beepSound:
path: "/Audio/Effects/beep1.ogg"
params:
volume: 5
initialBeepDelay: 0
beepInterval: 2 # 2 beeps total (at 0 and 2)
- type: entity - type: entity
name: flashbang name: flashbang