Skip to content

Commit

Permalink
add: crit heartbeat sound
Browse files Browse the repository at this point in the history
  • Loading branch information
ThereDrD0 committed Jan 14, 2025
1 parent add9c64 commit ad879ff
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Content.Shared/_Sunrise/CritHeartbeat/CritHeartbeatComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;

namespace Content.Shared._Sunrise.CritHeartbeat;

[RegisterComponent, NetworkedComponent]
public sealed partial class CritHeartbeatComponent : Component
{
[DataField]
public SoundSpecifier HeartbeatSound = new SoundPathSpecifier("/Audio/_Sunrise/Effects/heartbeat.ogg");

public EntityUid? AudioStream;
}
24 changes: 24 additions & 0 deletions Content.Shared/_Sunrise/CritHeartbeat/CritHeartbeatSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Shared.Mobs;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;

namespace Content.Shared._Sunrise.CritHeartbeat;

public sealed class CritHeartbeatSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<CritHeartbeatComponent, MobStateChangedEvent>(OnMobStateChanged);
}

private void OnMobStateChanged(Entity<CritHeartbeatComponent> ent, ref MobStateChangedEvent args)
{
ent.Comp.AudioStream = args.NewMobState == MobState.Critical
? _audio.PlayEntity(ent.Comp.HeartbeatSound, ent, ent, AudioParams.Default.WithLoop(true))?.Entity
: _audio.Stop(ent.Comp.AudioStream);
}
}
Binary file added Resources/Audio/_Sunrise/Effects/heartbeat.ogg
Binary file not shown.
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
- type: Carriable
- type: CanEscapeInventory
- type: Mood
- type: CritHeartbeat
# Sunrise-End
- type: Barotrauma
damage:
Expand Down

0 comments on commit ad879ff

Please sign in to comment.