mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Separate from the shaders toggle because some want one and the other. --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Added a toggle for the mood visual effects, for the ones with sensitive eyes. (cherry picked from commit cf3cdc970967b8a491d83b69c9df9a05d9fa2ced)
85 lines
2.7 KiB
C#
85 lines
2.7 KiB
C#
using Content.Shared.CCVar;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.Mood;
|
|
using Content.Shared.Overlays;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Client.Overlays;
|
|
|
|
public sealed class SaturationScaleSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;
|
|
[Dependency] private readonly IConfigurationManager _cfgMan = default!;
|
|
|
|
private SaturationScaleOverlay _overlay = default!;
|
|
private bool _moodEffectsEnabled;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_overlay = new();
|
|
_moodEffectsEnabled = _cfgMan.GetCVar(CCVars.MoodVisualEffects);
|
|
_cfgMan.OnValueChanged(CCVars.MoodVisualEffects, HandleMoodEffectsUpdated);
|
|
|
|
SubscribeLocalEvent<SaturationScaleOverlayComponent, ComponentInit>(OnInit);
|
|
SubscribeLocalEvent<SaturationScaleOverlayComponent, ComponentShutdown>(OnShutdown);
|
|
|
|
SubscribeLocalEvent<SaturationScaleOverlayComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<SaturationScaleOverlayComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
|
|
}
|
|
|
|
private void HandleMoodEffectsUpdated(bool moodEffectsEnabled)
|
|
{
|
|
if (_overlayMan.HasOverlay<SaturationScaleOverlay>() && !moodEffectsEnabled)
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
|
|
_moodEffectsEnabled = moodEffectsEnabled;
|
|
}
|
|
|
|
private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
|
|
{
|
|
if (!_moodEffectsEnabled)
|
|
return;
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerDetached(EntityUid uid, SaturationScaleOverlayComponent component, PlayerDetachedEvent args)
|
|
{
|
|
if (!_moodEffectsEnabled)
|
|
return;
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerAttached(EntityUid uid, SaturationScaleOverlayComponent component, PlayerAttachedEvent args)
|
|
{
|
|
if (!_moodEffectsEnabled)
|
|
return;
|
|
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, SaturationScaleOverlayComponent component, ComponentShutdown args)
|
|
{
|
|
if (uid != _playerMan.LocalEntity || !_moodEffectsEnabled)
|
|
return;
|
|
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnInit(EntityUid uid, SaturationScaleOverlayComponent component, ComponentInit args)
|
|
{
|
|
if (uid != _playerMan.LocalEntity || !_moodEffectsEnabled)
|
|
return;
|
|
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
}
|