- add: Toggleable night vision (#31)

* - add: Toggleable night vision

* - add: Add death squad huds & night vision
This commit is contained in:
Aviu00
2024-02-07 00:40:41 +09:00
committed by GitHub
parent cb1b96e6c5
commit 1105109152
9 changed files with 112 additions and 29 deletions

View File

@@ -0,0 +1,44 @@
using Content.Shared._White.Overlays;
using Content.Shared.Actions;
using Robust.Shared.Audio.Systems;
namespace Content.Shared._Miracle.Systems;
public abstract class SharedNightVisionSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedActionsSystem _actions = 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);
UpdateNightVision(uid, false);
}
private void OnInit(EntityUid uid, NightVisionComponent component, ComponentInit args)
{
_actions.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
UpdateNightVision(uid, component.IsActive);
}
protected virtual void UpdateNightVision(EntityUid uid, bool active) { }
private void OnToggle(EntityUid uid, NightVisionComponent component, ToggleNightVisionEvent args)
{
component.IsActive = !component.IsActive;
_audio.PlayPredicted(component.ToggleSound, uid, uid);
UpdateNightVision(uid, component.IsActive);
Dirty(uid, component);
args.Handled = true;
}
}