DebrainedSystem.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-FileCopyrightText: 2024 Piras314 <p1r4s@proton.me>
  2. // SPDX-FileCopyrightText: 2024 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
  3. // SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
  4. //
  5. // SPDX-License-Identifier: AGPL-3.0-or-later
  6. using Content.Server._Shitmed.DelayedDeath;
  7. using Content.Shared._Shitmed.Body.Organ;
  8. using Content.Shared.Body.Systems;
  9. using Content.Server.Popups;
  10. using Content.Shared.Speech;
  11. using Content.Shared.Standing;
  12. using Content.Shared.Stunnable;
  13. namespace Content.Server._Shitmed.Body.Systems;
  14. /// <summary>
  15. /// This system handles behavior on entities when they lose their head or their brains are removed.
  16. /// MindComponent fuckery should still be mainly handled on BrainSystem as usual.
  17. /// </summary>
  18. public sealed class DebrainedSystem : EntitySystem
  19. {
  20. [Dependency] private readonly SharedBodySystem _bodySystem = default!;
  21. [Dependency] private readonly PopupSystem _popupSystem = default!;
  22. [Dependency] private readonly StandingStateSystem _standingSystem = default!;
  23. public override void Initialize()
  24. {
  25. base.Initialize();
  26. SubscribeLocalEvent<DebrainedComponent, ComponentInit>(OnComponentInit);
  27. SubscribeLocalEvent<DebrainedComponent, ComponentRemove>(OnComponentRemove);
  28. SubscribeLocalEvent<DebrainedComponent, SpeakAttemptEvent>(OnSpeakAttempt);
  29. SubscribeLocalEvent<DebrainedComponent, StandAttemptEvent>(OnStandAttempt);
  30. }
  31. private void OnComponentInit(EntityUid uid, DebrainedComponent _, ComponentInit args)
  32. {
  33. if (TerminatingOrDeleted(uid))
  34. return;
  35. EnsureComp<DelayedDeathComponent>(uid);
  36. EnsureComp<StunnedComponent>(uid);
  37. _standingSystem.Down(uid);
  38. }
  39. private void OnComponentRemove(EntityUid uid, DebrainedComponent _, ComponentRemove args)
  40. {
  41. if (TerminatingOrDeleted(uid))
  42. return;
  43. RemComp<DelayedDeathComponent>(uid);
  44. RemComp<StunnedComponent>(uid);
  45. if (_bodySystem.TryGetBodyOrganEntityComps<HeartComponent>(uid, out var _))
  46. RemComp<DelayedDeathComponent>(uid);
  47. }
  48. private void OnSpeakAttempt(EntityUid uid, DebrainedComponent _, SpeakAttemptEvent args)
  49. {
  50. _popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
  51. args.Cancel();
  52. }
  53. private void OnStandAttempt(EntityUid uid, DebrainedComponent _, StandAttemptEvent args)
  54. {
  55. args.Cancel();
  56. }
  57. }