mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* What if Skia were awesome instead of sucking * Shhh Yaml Linter... Shhh * Small change to make it feel more consistant * Reworked shadowwalking to be lazy Much faster, preserves most of the feel * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update Content.Shared/_DV/Overlays/Components/DarkVisionComponent.cs Signed-off-by: pathetic meowmeow <uhhadd@gmail.com> --------- Signed-off-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pathetic meowmeow <uhhadd@gmail.com>
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using Content.Shared._DV.Overlays.Components;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Client._DV.Overlays;
|
|
|
|
public sealed class DarkVisionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
[Dependency] private readonly ISharedPlayerManager _playerMan = default!;
|
|
|
|
private DarkVisionOverlay _overlay = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<DarkVisionComponent, ComponentInit>(OnInit);
|
|
SubscribeLocalEvent<DarkVisionComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<DarkVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<DarkVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
|
|
|
|
_overlay = new();
|
|
}
|
|
|
|
private void OnInit(Entity<DarkVisionComponent> ent, ref ComponentInit args)
|
|
{
|
|
if (ent.Owner == _playerMan.LocalEntity)
|
|
EnableOverlay(ent.Comp);
|
|
}
|
|
|
|
private void OnShutdown(Entity<DarkVisionComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
if (ent.Owner == _playerMan.LocalEntity)
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnPlayerAttached(Entity<DarkVisionComponent> ent, ref LocalPlayerAttachedEvent args)
|
|
{
|
|
EnableOverlay(ent.Comp);
|
|
}
|
|
|
|
private void OnPlayerDetached(Entity<DarkVisionComponent> ent, ref LocalPlayerDetachedEvent args)
|
|
{
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void EnableOverlay(DarkVisionComponent comp)
|
|
{
|
|
_overlay.LightFloor = comp.LightFloor;
|
|
_overlay.LightGain = comp.LightGain;
|
|
_overlay.LightExp = comp.LightExp;
|
|
if (!_overlayMan.HasOverlay<DarkVisionOverlay>())
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
}
|