* reduced motion flash effect * reduced motion drug overlay * Revert "reduced motion flash effect" This reverts commit e350b2899d0acc78c9833b5bc23a9680e03b2736.
66 lines
2.1 KiB
C#
66 lines
2.1 KiB
C#
using Content.Shared.Drugs;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Client.Drugs;
|
|
|
|
/// <summary>
|
|
/// System to handle drug related overlays.
|
|
/// </summary>
|
|
public sealed class DrugOverlaySystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPlayerManager _player = default!;
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
private RainbowOverlay _overlay = default!;
|
|
|
|
public static string RainbowKey = "SeeingRainbows";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SeeingRainbowsComponent, ComponentInit>(OnInit);
|
|
SubscribeLocalEvent<SeeingRainbowsComponent, ComponentShutdown>(OnShutdown);
|
|
|
|
SubscribeLocalEvent<SeeingRainbowsComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<SeeingRainbowsComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
_overlay = new();
|
|
}
|
|
|
|
private void OnPlayerAttached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerAttachedEvent args)
|
|
{
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerDetached(EntityUid uid, SeeingRainbowsComponent component, LocalPlayerDetachedEvent args)
|
|
{
|
|
_overlay.Intoxication = 0;
|
|
_overlay.TimeTicker = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnInit(EntityUid uid, SeeingRainbowsComponent component, ComponentInit args)
|
|
{
|
|
if (_player.LocalEntity == uid)
|
|
{
|
|
_overlay.Phase = _random.NextFloat(MathF.Tau); // random starting phase for movement effect
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, SeeingRainbowsComponent component, ComponentShutdown args)
|
|
{
|
|
if (_player.LocalEntity == uid)
|
|
{
|
|
_overlay.Intoxication = 0;
|
|
_overlay.TimeTicker = 0;
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
}
|
|
}
|