mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
# Description I'm going to go put powergamers on suicide watch. This PR makes it so that specializing in psionic traits, and specializing in cybernetic traits are both mutually exclusive. You are only allowed to have a single cybernetric trait if you wish to have psionic traits. And you are only allowed to have Latent Psychic with no other traits if you wish to have Cybernetics. Also fixes a bug with Thermographic Vision not correctly being measured in seconds. You now get a 2 second pulse with Thermographic vision, as intended. # Changelog 🆑 - tweak: Psionic traits are now mutually exclusive with cybernetic traits, and vice versa. - fix: Thermographic Vision now correctly measures its pulse duration in seconds instead of nanoseconds. It provides a 2 second scan. --------- Co-authored-by: stellar-novas <stellar_novas@riseup.net> (cherry picked from commit 87eb664fa6e95b659c5753b07115d1aaea82b442)
106 lines
3.2 KiB
C#
106 lines
3.2 KiB
C#
using System.Reflection.Metadata;
|
|
using Content.Shared.Inventory;
|
|
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 _timing = default!;
|
|
|
|
private BaseSwitchableOverlay<NightVisionComponent> _overlay = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<NightVisionComponent, SwitchableOverlayToggledEvent>(OnToggle);
|
|
|
|
_overlay = new BaseSwitchableOverlay<NightVisionComponent>();
|
|
}
|
|
|
|
protected override void OnRefreshComponentHud(EntityUid uid,
|
|
NightVisionComponent component,
|
|
RefreshEquipmentHudEvent<NightVisionComponent> args)
|
|
{
|
|
if (component.IsEquipment)
|
|
return;
|
|
|
|
base.OnRefreshComponentHud(uid, component, args);
|
|
}
|
|
|
|
protected override void OnRefreshEquipmentHud(EntityUid uid,
|
|
NightVisionComponent component,
|
|
InventoryRelayedEvent<RefreshEquipmentHudEvent<NightVisionComponent>> args)
|
|
{
|
|
if (!component.IsEquipment)
|
|
return;
|
|
|
|
base.OnRefreshEquipmentHud(uid, component, args);
|
|
}
|
|
|
|
private void OnToggle(Entity<NightVisionComponent> ent, ref SwitchableOverlayToggledEvent args)
|
|
{
|
|
RefreshOverlay(args.User);
|
|
}
|
|
|
|
protected override void UpdateInternal(RefreshEquipmentHudEvent<NightVisionComponent> args)
|
|
{
|
|
base.UpdateInternal(args);
|
|
|
|
var active = false;
|
|
NightVisionComponent? nvComp = null;
|
|
foreach (var comp in args.Components)
|
|
{
|
|
if (!comp.IsActive && (comp.PulseTime <= 0 || _timing.CurTime < comp.PulseEndTime))
|
|
continue;
|
|
|
|
if (nvComp == null)
|
|
nvComp = comp;
|
|
else if (!nvComp.DrawOverlay && comp.DrawOverlay)
|
|
nvComp = comp;
|
|
else if (nvComp.DrawOverlay == comp.DrawOverlay && nvComp.PulseTime > 0 && comp.PulseTime <= 0)
|
|
nvComp = comp;
|
|
}
|
|
|
|
UpdateNightVision(active);
|
|
UpdateOverlay(nvComp);
|
|
}
|
|
|
|
protected override void DeactivateInternal()
|
|
{
|
|
base.DeactivateInternal();
|
|
|
|
UpdateNightVision(false);
|
|
UpdateOverlay(null);
|
|
}
|
|
|
|
private void UpdateNightVision(bool active)
|
|
{
|
|
_lightManager.DrawLighting = !active;
|
|
}
|
|
|
|
private void UpdateOverlay(NightVisionComponent? nvComp)
|
|
{
|
|
_overlay.Comp = nvComp;
|
|
|
|
switch (nvComp)
|
|
{
|
|
case not null when !_overlayMan.HasOverlay<BaseSwitchableOverlay<NightVisionComponent>>():
|
|
_overlayMan.AddOverlay(_overlay);
|
|
break;
|
|
case null:
|
|
_overlayMan.RemoveOverlay(_overlay);
|
|
break;
|
|
}
|
|
|
|
if (_overlayMan.TryGetOverlay<BaseSwitchableOverlay<ThermalVisionComponent>>(out var overlay))
|
|
overlay.IsActive = nvComp == null;
|
|
}
|
|
}
|