Files
OldThink/Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs
Aviu00 c05a1d09c2 Ling update (#183)
* - add: Augmented Eyesight.

* - add: Dissonant Shriek.

* - tweak: Nuke use delays.

* - tweak: Tweak chemical regeneration and chemical costs.

* - add: Add chitinous helmet.

* - fix: Fix chem regeneration while dead.

* - tweak: Faster fleshmend.

* - add: Void Adaptation.

* - tweak: No lesser form delay.

* - tweak: Lesser form tweaks.

* - tweak: Stasis doafter is hidden now.

* - add: Refund after absorbing.

* - tweak: Some tweaks.
2024-03-13 19:19:30 +03:00

61 lines
1.9 KiB
C#

using Content.Shared._White.Overlays;
using Content.Shared.Actions;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
namespace Content.Shared._Miracle.Systems;
public abstract class SharedNightVisionSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NightVisionComponent, ToggleNightVisionEvent>(OnToggle);
SubscribeLocalEvent<NightVisionComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<NightVisionComponent, ComponentRemove>(OnRemove);
}
private void OnRemove(EntityUid uid, NightVisionComponent component, ComponentRemove args)
{
_actions.RemoveAction(uid, component.ToggleActionEntity);
if (HasComp<TemporaryNightVisionComponent>(uid))
return;
UpdateNightVision(uid, false);
}
private void OnInit(EntityUid uid, NightVisionComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
if (!component.IsActive && HasComp<TemporaryNightVisionComponent>(uid))
return;
UpdateNightVision(uid, component.IsActive);
}
protected virtual void UpdateNightVision(EntityUid uid, bool active) { }
private void OnToggle(EntityUid uid, NightVisionComponent component, ToggleNightVisionEvent args)
{
if (!_timing.IsFirstTimePredicted)
return;
component.IsActive = !component.IsActive;
_audio.PlayPredicted(component.ToggleSound, uid, uid);
args.Handled = true;
if (!component.IsActive && HasComp<TemporaryNightVisionComponent>(uid))
return;
UpdateNightVision(uid, component.IsActive);
}
}