New status effect system (#37238)

* spectra

* documentation

* added into liquid anomaly

* Update TemporaryStealthComponent.cs

* Update TemporaryStealthComponent.cs

* integrated

* new system

* mark old status effect system as obsolete

* ForcedSleeping new status effect

* work with reagents

* networking???

* Revert "integrated"

This reverts commit bca02b82bae18ae131af593d7eb86e6de2745157.

* Revert "Update TemporaryStealthComponent.cs"

This reverts commit 4a5be8c4b704a0d1ff9544b2e245d8b2701ec580.

* Revert "Update TemporaryStealthComponent.cs"

This reverts commit a4875bcb41347638854bd723d96a51c3e6d38034.

* Revert "added into liquid anomaly"

This reverts commit df5086b14bb35f1467158a36807c0f2163a16d99.

* Revert "documentation"

This reverts commit 3629b9466758cbdfa4dd5e67ece122fa2f181138.

* Revert "spectra"

This reverts commit 2d03d88c16d16ad6831c19a7921b84600daeb284.

* drowsiness status effect remove

* reagents work

* polish, remove test changes

* first Fildrance review part

* Update misc.yml

* more fildrance review

* final part

* fix trailing spaces

* sleeping status effect

* drowsiness status effect

* Create ModifyStatusEffect.cs

* some tweak

* Yay!!! Manual networking

* minor nitpick

* oopsie

* refactor: xml-docs, notnullwhen attributes, whitespaces

* fildrance and emo review

* refactor: simplify check in SharedStatusEffectsSystem by using pattern matching, TryEffectsWithComp now returns set of Entity<T, StatusEffectComponent>

---------

Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
This commit is contained in:
Red
2025-06-25 14:41:35 +03:00
committed by GitHub
parent 8be0b7a614
commit 78a94730be
35 changed files with 913 additions and 170 deletions

View File

@@ -1,7 +1,7 @@
using Content.Shared.Drowsiness;
using Content.Shared.StatusEffectNew;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Drowsiness;
@@ -9,6 +9,7 @@ public sealed class DrowsinessSystem : SharedDrowsinessSystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly SharedStatusEffectsSystem _statusEffects = default!;
private DrowsinessOverlay _overlay = default!;
@@ -16,35 +17,47 @@ public sealed class DrowsinessSystem : SharedDrowsinessSystem
{
base.Initialize();
SubscribeLocalEvent<DrowsinessComponent, ComponentInit>(OnDrowsinessInit);
SubscribeLocalEvent<DrowsinessComponent, ComponentShutdown>(OnDrowsinessShutdown);
SubscribeLocalEvent<DrowsinessStatusEffectComponent, StatusEffectAppliedEvent>(OnDrowsinessApply);
SubscribeLocalEvent<DrowsinessStatusEffectComponent, StatusEffectRemovedEvent>(OnDrowsinessShutdown);
SubscribeLocalEvent<DrowsinessComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<DrowsinessComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<DrowsinessStatusEffectComponent, StatusEffectPlayerAttachedEvent>(OnStatusEffectPlayerAttached);
SubscribeLocalEvent<DrowsinessStatusEffectComponent, StatusEffectPlayerDetachedEvent>(OnStatusEffectPlayerDetached);
_overlay = new();
}
private void OnPlayerAttached(EntityUid uid, DrowsinessComponent component, LocalPlayerAttachedEvent args)
private void OnDrowsinessApply(Entity<DrowsinessStatusEffectComponent> ent, ref StatusEffectAppliedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}
private void OnPlayerDetached(EntityUid uid, DrowsinessComponent component, LocalPlayerDetachedEvent args)
{
_overlay.CurrentPower = 0;
_overlayMan.RemoveOverlay(_overlay);
}
private void OnDrowsinessInit(EntityUid uid, DrowsinessComponent component, ComponentInit args)
{
if (_player.LocalEntity == uid)
if (_player.LocalEntity == args.Target)
_overlayMan.AddOverlay(_overlay);
}
private void OnDrowsinessShutdown(EntityUid uid, DrowsinessComponent component, ComponentShutdown args)
private void OnDrowsinessShutdown(Entity<DrowsinessStatusEffectComponent> ent, ref StatusEffectRemovedEvent args)
{
if (_player.LocalEntity == uid)
if (_player.LocalEntity != args.Target)
return;
if (!_statusEffects.HasEffectComp<DrowsinessStatusEffectComponent>(_player.LocalEntity.Value))
{
_overlay.CurrentPower = 0;
_overlayMan.RemoveOverlay(_overlay);
}
}
private void OnStatusEffectPlayerAttached(Entity<DrowsinessStatusEffectComponent> ent, ref StatusEffectPlayerAttachedEvent args)
{
if (_player.LocalEntity != args.Target)
return;
_overlayMan.AddOverlay(_overlay);
}
private void OnStatusEffectPlayerDetached(Entity<DrowsinessStatusEffectComponent> ent, ref StatusEffectPlayerDetachedEvent args)
{
if (_player.LocalEntity != args.Target)
return;
if (!_statusEffects.HasEffectComp<DrowsinessStatusEffectComponent>(_player.LocalEntity.Value))
{
_overlay.CurrentPower = 0;
_overlayMan.RemoveOverlay(_overlay);