mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
* fix: thermals and night vision now work * fix: it has to be this way Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: I hate the way they are separated * fix: now cult actions close examine menu (#1046) Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: railins and some other things now dont snap to south upon being built (#1029) * fix: who did this translation wtf * fix: assball bat can now wideswing (#1030) Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: spend flares are actually spent now (#959) Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: made part exchange system a bit less shitty I really have no time or interest in it to rewrite it completely rn Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * fix: fixed cult factories timers being broken Also fixed them being openable by anyone. Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> * Apply suggestions from code review Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com> Co-authored-by: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com> --------- Signed-off-by: Remuchi <RemuchiOfficial@gmail.com> Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com> Co-authored-by: RedFoxIV <38788538+RedFoxIV@users.noreply.github.com>
76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.Overlays.Switchable;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.Overlays.Switchable;
|
|
|
|
public sealed class NightVisionSystem : EquipmentHudSystem<NightVisionComponent>
|
|
{
|
|
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
|
[Dependency] private readonly ILightManager _lightManager = default!;
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
|
|
private NightVisionOverlay _overlay = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<NightVisionComponent, SwitchableOverlayToggledEvent>(OnToggle);
|
|
|
|
_overlay = new()
|
|
{
|
|
IsActive = false
|
|
};
|
|
_overlayMan.AddOverlay(_overlay);
|
|
}
|
|
|
|
public override void Shutdown()
|
|
{
|
|
base.Shutdown();
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
}
|
|
|
|
private void OnToggle(Entity<NightVisionComponent> ent, ref SwitchableOverlayToggledEvent args)
|
|
{
|
|
if (!_gameTiming.IsFirstTimePredicted)
|
|
return;
|
|
|
|
_overlay.SetParams(ent.Comp.Tint, ent.Comp.Strength, ent.Comp.Noise, ent.Comp.Color, ent.Comp.PulseTime);
|
|
RefreshOverlay();
|
|
}
|
|
|
|
protected override void UpdateInternal(RefreshEquipmentHudEvent<NightVisionComponent> args)
|
|
{
|
|
var active = false;
|
|
NightVisionComponent? nvComp = null;
|
|
foreach (var comp in args.Components)
|
|
{
|
|
if (comp.IsActive || comp.PulseTime > 0f && comp.PulseAccumulator < comp.PulseTime)
|
|
active = true;
|
|
else
|
|
continue;
|
|
|
|
if (comp.DrawOverlay)
|
|
{
|
|
if (nvComp == null || nvComp.PulseTime > 0f && comp.PulseTime <= 0f)
|
|
nvComp = comp;
|
|
}
|
|
|
|
if (active && nvComp is { PulseTime: <= 0 })
|
|
break;
|
|
}
|
|
|
|
UpdateNightVision(active);
|
|
}
|
|
|
|
protected override void DeactivateInternal() => UpdateNightVision(false);
|
|
|
|
private void UpdateNightVision(bool active)
|
|
{
|
|
_lightManager.DrawLighting = !active;
|
|
_overlay.IsActive = active;
|
|
}
|
|
}
|