- add: Toggleable night vision (#31)
* - add: Toggleable night vision * - add: Add death squad huds & night vision
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared._Miracle.Systems;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared._White.Overlays;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -6,7 +7,7 @@ using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Client._White.Overlays;
|
||||
|
||||
public sealed class NightVisionSystem : EntitySystem
|
||||
public sealed class NightVisionSystem : SharedNightVisionSystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
||||
@@ -18,9 +19,6 @@ public sealed class NightVisionSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<NightVisionComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<NightVisionComponent, ComponentRemove>(OnRemove);
|
||||
|
||||
SubscribeLocalEvent<NightVisionComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
||||
SubscribeLocalEvent<NightVisionComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRestart);
|
||||
@@ -30,38 +28,25 @@ public sealed class NightVisionSystem : EntitySystem
|
||||
|
||||
private void OnPlayerAttached(EntityUid uid, NightVisionComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
if (_player.LocalSession != args.Player)
|
||||
return;
|
||||
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
_lightManager.DrawLighting = false;
|
||||
UpdateNightVision(uid, component.IsActive);
|
||||
}
|
||||
|
||||
private void OnPlayerDetached(EntityUid uid, NightVisionComponent component, PlayerDetachedEvent args)
|
||||
{
|
||||
if (_player.LocalSession != args.Player)
|
||||
return;
|
||||
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
_lightManager.DrawLighting = true;
|
||||
UpdateNightVision(uid, false);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, NightVisionComponent component, ComponentInit args)
|
||||
protected override void UpdateNightVision(EntityUid uid, bool active)
|
||||
{
|
||||
if (_player.LocalSession?.AttachedEntity != uid)
|
||||
return;
|
||||
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
_lightManager.DrawLighting = false;
|
||||
}
|
||||
if (active)
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
else
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
|
||||
private void OnRemove(EntityUid uid, NightVisionComponent component, ComponentRemove args)
|
||||
{
|
||||
if (_player.LocalSession?.AttachedEntity != uid)
|
||||
return;
|
||||
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
_lightManager.DrawLighting = true;
|
||||
_lightManager.DrawLighting = !active;
|
||||
}
|
||||
|
||||
private void OnRestart(RoundRestartCleanupEvent ev)
|
||||
|
||||
7
Content.Server/_Miracle/Systems/NightVisionSystem.cs
Normal file
7
Content.Server/_Miracle/Systems/NightVisionSystem.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Content.Shared._Miracle.Systems;
|
||||
|
||||
namespace Content.Server._Miracle.Systems;
|
||||
|
||||
public sealed class NightVisionSystem : SharedNightVisionSystem
|
||||
{
|
||||
}
|
||||
44
Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs
Normal file
44
Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,38 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._White.Overlays;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class NightVisionComponent : Component
|
||||
{
|
||||
[DataField("tint"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public Vector3 Tint = new(0.3f, 0.3f, 0.3f);
|
||||
|
||||
[DataField("strength"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public float Strength = 2f;
|
||||
|
||||
[DataField("noise"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public float Noise = 0.5f;
|
||||
|
||||
[DataField("color"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public Color Color = Color.FromHex("#98FB98");
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||
public bool IsActive = true;
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier? ToggleSound = new SoundPathSpecifier("/Audio/Items/flashlight_pda.ogg");
|
||||
|
||||
[DataField]
|
||||
public EntProtoId? ToggleAction = "ToggleNightVision";
|
||||
|
||||
[ViewVariables]
|
||||
public EntityUid? ToggleActionEntity;
|
||||
}
|
||||
|
||||
public sealed partial class ToggleNightVisionEvent : InstantActionEvent
|
||||
{
|
||||
}
|
||||
|
||||
2
Resources/Locale/ru-RU/_miracle/night_vision.ftl
Normal file
2
Resources/Locale/ru-RU/_miracle/night_vision.ftl
Normal file
@@ -0,0 +1,2 @@
|
||||
ent-ToggleNightVision = Переключить ночное зрение
|
||||
.desc = Переключает ночное зрение.
|
||||
@@ -248,6 +248,9 @@
|
||||
- type: Clothing
|
||||
sprite: Clothing/Eyes/Glasses/ninjavisor.rsi
|
||||
- type: FlashImmunity
|
||||
- type: ClothingGrantComponent
|
||||
component:
|
||||
- type: NightVision
|
||||
|
||||
- type: entity
|
||||
parent: ClothingEyesBase
|
||||
|
||||
@@ -767,6 +767,13 @@
|
||||
Caustic: 0.95
|
||||
- type: FlashImmunity # WD edit
|
||||
- type: EyeProtection # WD edit
|
||||
- type: ShowHealthIcons
|
||||
damageContainers:
|
||||
- Biological
|
||||
- type: ClothingGrantComponent
|
||||
component:
|
||||
- type: NightVision
|
||||
- type: ShowWhiteHealthBars
|
||||
|
||||
#MISC. HARDSUITS
|
||||
#Clown Hardsuit
|
||||
|
||||
@@ -27,3 +27,17 @@
|
||||
sprite: White/Objects/Weapons/hardlight_spear.rsi
|
||||
state: spear
|
||||
event: !type:ActivateHardlightSpearImplantEvent
|
||||
|
||||
- type: entity
|
||||
id: ToggleNightVision
|
||||
name: Toggle night vision.
|
||||
description: Toggles night vision.
|
||||
noSpawn: true
|
||||
components:
|
||||
- type: InstantAction
|
||||
itemIconStyle: BigAction
|
||||
priority: -20
|
||||
icon:
|
||||
sprite: White/Clothing/Head/nightvision.rsi
|
||||
state: icon
|
||||
event: !type:ToggleNightVisionEvent
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
- type: ClothingGrantComponent
|
||||
component:
|
||||
- type: NightVision
|
||||
toggleAction: null
|
||||
toggleSound: null
|
||||
color: White
|
||||
- type: ShowWhiteHealthBars
|
||||
damageContainers:
|
||||
|
||||
Reference in New Issue
Block a user