* This adds the basic wirework for the gnomes, very unfinished * GNOMES ARE DONE EXCEPT FOR GLUE WOOO * removes gnome id, fixes ai and punch sounds, comments out the code for glue to take fuel * changed sounds to non meme versions * HAT NOW GIVES THE GNOME ACCENT TOO * fixes a typo with Unclippable being Unclipable * removed cuffable component (iforgotaboutit) * added unrevivable to gnomes so defibs wont try (it was immpossible anyways but this is better) * removes scrap code i put in the repair system * remove the carrot mutation code i made (its bad) clean up some things in the repairable system * changes accent system from rplacging g to replacing no * Fix the conflict (plz work) * adds another comment bleh bleh im trying to fix things * PAIN.jpeg * work plz? * FIX FOR REAL * camel case mayhaps? * adds unfinished glue use code (you can still see lit or not lit when held >:/ ) * temporary fix * add: GNOMES REVAMPED * fix: fix accent, sounds and add spawners * add: gnome seeds to seed vendor --------- Co-authored-by: BITTERLYNX <gagestemmerman@gmail.com>
79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using Content.Shared.Mobs;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server._White.Other.DeathGasps;
|
|
|
|
public sealed class OnDeath : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<DeathGaspsComponent, MobStateChangedEvent>(HandleDeathEvent);
|
|
SubscribeLocalEvent<DeathGaspsComponent, PlayerDetachedEvent>(OnDetach);
|
|
}
|
|
|
|
private readonly Dictionary<EntityUid, EntityUid> _playingStreams = new();
|
|
|
|
|
|
private void HandleDeathEvent(EntityUid uid, DeathGaspsComponent component, MobStateChangedEvent args)
|
|
{
|
|
//^.^
|
|
switch (args.NewMobState)
|
|
{
|
|
case MobState.Invalid:
|
|
StopPlayingStream(uid);
|
|
break;
|
|
case MobState.Alive:
|
|
StopPlayingStream(uid);
|
|
break;
|
|
case MobState.Critical:
|
|
PlayPlayingStream(uid, component);
|
|
break;
|
|
case MobState.Dead:
|
|
StopPlayingStream(uid);
|
|
PlayDeathSound(uid, component);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void PlayPlayingStream(EntityUid uid, DeathGaspsComponent component)
|
|
{
|
|
if (_playingStreams.TryGetValue(uid, out var currentStream))
|
|
{
|
|
_audio.Stop(currentStream);
|
|
}
|
|
|
|
var newStream = _audio.PlayEntity(component.HeartSounds, uid, uid, AudioParams.Default.WithLoop(true));
|
|
|
|
if (newStream.HasValue)
|
|
{
|
|
_playingStreams[uid] = newStream.Value.Entity;
|
|
}
|
|
}
|
|
|
|
private void StopPlayingStream(EntityUid uid)
|
|
{
|
|
if (!_playingStreams.TryGetValue(uid, out var currentStream))
|
|
return;
|
|
|
|
_audio.Stop(currentStream);
|
|
_playingStreams.Remove(uid);
|
|
}
|
|
|
|
private void PlayDeathSound(EntityUid uid, DeathGaspsComponent component)
|
|
{
|
|
if (component.CanOtherHearDeathSound)
|
|
_audio.PlayPvs(component.DeathSounds, uid, AudioParams.Default);
|
|
else
|
|
_audio.PlayEntity(component.DeathSounds, uid, uid, AudioParams.Default);
|
|
}
|
|
|
|
private void OnDetach(EntityUid uid, DeathGaspsComponent component, PlayerDetachedEvent args)
|
|
{
|
|
StopPlayingStream(args.Entity);
|
|
}
|
|
}
|