diff --git a/Content.Client/Clothing/NightVisionOverlay.cs b/Content.Client/Clothing/NightVisionOverlay.cs new file mode 100644 index 00000000000..feeddb01a6e --- /dev/null +++ b/Content.Client/Clothing/NightVisionOverlay.cs @@ -0,0 +1,52 @@ +using Robust.Client.Graphics; +using Robust.Shared.Enums; +using Robust.Shared.Prototypes; + +namespace Content.Client.Clothing; + +/// +/// Made by BL02DL from _LostParadise +/// + +public sealed class NightVisionOverlay : Overlay +{ + private readonly IPrototypeManager _prototypeManager; + private readonly NightVisionSystem _nightVisionSystem; + + public override bool RequestScreenTexture => true; + public override OverlaySpace Space => OverlaySpace.WorldSpace; + + private readonly ShaderInstance _shader; + + public NightVisionOverlay(NightVisionSystem nightVisionSystem) + { + IoCManager.InjectDependencies(this); + _nightVisionSystem = nightVisionSystem; + _prototypeManager = IoCManager.Resolve(); + _shader = _prototypeManager.Index("NightVision").InstanceUnique(); + } + + protected override void Draw(in OverlayDrawArgs args) + { + if (ScreenTexture == null) + return; + + var handle = args.WorldHandle; + var nightcomp = _nightVisionSystem.GetNightComp(); + + if (nightcomp == null) + { + Logger.Error("Failed to get night vision component from eyes."); + return; + } + + _shader.SetParameter("SCREEN_TEXTURE", ScreenTexture); + _shader.SetParameter("tint", nightcomp.Tint); + _shader.SetParameter("luminance_threshold", nightcomp.Strength); + _shader.SetParameter("noise_amount", nightcomp.Noise); + + handle.UseShader(_shader); + handle.DrawRect(args.WorldBounds, Color.White); + handle.UseShader(null); + } +} diff --git a/Content.Client/Clothing/NightVisionSystem.cs b/Content.Client/Clothing/NightVisionSystem.cs new file mode 100644 index 00000000000..557f29921a7 --- /dev/null +++ b/Content.Client/Clothing/NightVisionSystem.cs @@ -0,0 +1,72 @@ +using Content.Shared.Clothing; +using Content.Shared.GameTicking; +using Robust.Client.Player; +using Robust.Client.Graphics; +using Content.Client.Inventory; +using Content.Shared.Inventory.Events; + +namespace Content.Client.Clothing; + +/// +/// Made by BL02DL from _LostParadise +/// + +public sealed class NightVisionSystem : SharedNightVisionSystem +{ + [Dependency] private readonly IOverlayManager _overlayMan = default!; + [Dependency] private readonly ILightManager _lightManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IEntityManager _entityManager = default!; + + private NightVisionOverlay _overlay = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnRestart); + SubscribeLocalEvent(OnGotUnequipped); + + _overlay = new(this); + } + + public NightVisionComponent? GetNightComp() + { + var playerUid = EntityUid.Parse(_playerManager.LocalPlayer?.ControlledEntity.ToString()); + var slot = _entityManager.GetComponent(playerUid); + _entityManager.TryGetComponent(slot.SlotData["eyes"].HeldEntity, out var nightvision); + return nightvision; + } + + protected override void UpdateNightVisionEffects(EntityUid parent, EntityUid uid, bool state, NightVisionComponent? component = null) + { + if (!Resolve(uid, ref component)) + return; + + state = state && component.Enabled; + + if (state) + { + _lightManager.DrawLighting = false; + _overlayMan.AddOverlay(_overlay); + } + else + { + _lightManager.DrawLighting = true; + _overlayMan.RemoveOverlay(_overlay); + } + } + private void OnGotUnequipped(EntityUid uid, NightVisionComponent component, GotUnequippedEvent args) + { + if (args.Slot == component.Slot) + { + _overlayMan.RemoveOverlay(_overlay); + _lightManager.DrawLighting = true; + } + } + private void OnRestart(RoundRestartCleanupEvent ev) + { + _overlayMan.RemoveOverlay(_overlay); + _lightManager.DrawLighting = true; + } +} diff --git a/Content.Server/Clothing/NightVisionSystem.cs b/Content.Server/Clothing/NightVisionSystem.cs new file mode 100644 index 00000000000..16daec7ce35 --- /dev/null +++ b/Content.Server/Clothing/NightVisionSystem.cs @@ -0,0 +1,31 @@ +using Content.Shared.Clothing; +using Content.Shared.Inventory.Events; + +namespace Content.Server.Clothing; + +/// +/// Made by BL02DL from _LostParadise +/// + +public sealed class NightVisionSystem : SharedNightVisionSystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnGotEquipped); + SubscribeLocalEvent(OnGotUnequipped); + } + + private void OnGotUnequipped(EntityUid uid, NightVisionComponent component, GotUnequippedEvent args) + { + if (args.Slot == component.Slot) + UpdateNightVisionEffects(args.Equipee, uid, false, component); + } + + private void OnGotEquipped(EntityUid uid, NightVisionComponent component, GotEquippedEvent args) + { + if (args.Slot == component.Slot) + UpdateNightVisionEffects(args.Equipee, uid, true, component); + } +} diff --git a/Content.Shared/Clothing/NightVisionComponent.cs b/Content.Shared/Clothing/NightVisionComponent.cs new file mode 100644 index 00000000000..ca186755d74 --- /dev/null +++ b/Content.Shared/Clothing/NightVisionComponent.cs @@ -0,0 +1,51 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Clothing; + +/// +/// Made by BL02DL from _LostParadise +/// + +[RegisterComponent, NetworkedComponent(), AutoGenerateComponentState] +[Access(typeof(SharedNightVisionSystem))] +public sealed partial class NightVisionComponent : Component +{ + [DataField] + public EntProtoId ToggleAction = "ActionToggleNightVision"; + + [DataField, AutoNetworkedField] + public EntityUid? ToggleActionEntity; + + [DataField, AutoNetworkedField] + public bool Enabled; + + [DataField] + public float Tint1 { get; set; } = 0.3f; + + [DataField] + public float Tint2 { get; set; } = 0.3f; + + [DataField] + public float Tint3 { get; set; } = 0.3f; + + public Vector3 Tint + { + get => new(Tint1, Tint2, Tint3); + set + { + Tint1 = value.X; + Tint2 = value.Y; + Tint3 = value.Z; + } + } + + [DataField] + public float Strength = 2f; + + [DataField] + public float Noise = 0.5f; + + [DataField] + public string Slot = "eyes"; +} diff --git a/Content.Shared/Clothing/SharedNightVisionSystem.cs b/Content.Shared/Clothing/SharedNightVisionSystem.cs new file mode 100644 index 00000000000..0c7ce6f753b --- /dev/null +++ b/Content.Shared/Clothing/SharedNightVisionSystem.cs @@ -0,0 +1,94 @@ +using Content.Shared.Actions; +using Content.Shared.Clothing.EntitySystems; +using Content.Shared.Inventory; +using Content.Shared.Item; +using Content.Shared.Toggleable; +using Content.Shared.Verbs; +using Robust.Shared.Containers; + +namespace Content.Shared.Clothing; + +/// +/// Made by BL02DL from _LostParadise +/// + +public abstract class SharedNightVisionSystem : EntitySystem +{ + [Dependency] private readonly ClothingSystem _clothing = default!; + [Dependency] private readonly InventorySystem _inventory = default!; + [Dependency] private readonly SharedActionsSystem _sharedActions = default!; + [Dependency] private readonly SharedActionsSystem _actionContainer = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedContainerSystem _sharedContainer = default!; + [Dependency] private readonly SharedItemSystem _item = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent>(AddToggleVerb); + SubscribeLocalEvent(OnGetActions); + SubscribeLocalEvent(OnToggleNightVision); + SubscribeLocalEvent(OnMapInit); + } + + private void OnMapInit(EntityUid uid, NightVisionComponent component, MapInitEvent args) + { + _actionContainer.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction); + Dirty(uid, component); + } + + private void OnToggleNightVision(EntityUid uid, NightVisionComponent component, ToggleNightVisionEvent args) + { + if (args.Handled) + return; + + args.Handled = true; + + ToggleNightVision(uid, component); + } + + private void ToggleNightVision(EntityUid uid, NightVisionComponent nightvision) + { + nightvision.Enabled = !nightvision.Enabled; + + if (_sharedContainer.TryGetContainingContainer(uid, out var container) && + _inventory.TryGetSlotEntity(container.Owner, "eyes", out var entityUid) && entityUid == uid) + UpdateNightVisionEffects(container.Owner, uid, true, nightvision); + + if (TryComp(uid, out var item)) + { + _item.SetHeldPrefix(uid, nightvision.Enabled ? "on" : null, component: item); + _clothing.SetEquippedPrefix(uid, nightvision.Enabled ? "on" : null); + } + + _appearance.SetData(uid, ToggleVisuals.Toggled, nightvision.Enabled); + OnChanged(uid, nightvision); + Dirty(uid, nightvision); + } + + protected virtual void UpdateNightVisionEffects(EntityUid parent, EntityUid uid, bool state, NightVisionComponent? component) { } + + protected void OnChanged(EntityUid uid, NightVisionComponent component) + { + _sharedActions.SetToggled(component.ToggleActionEntity, component.Enabled); + } + + private void AddToggleVerb(EntityUid uid, NightVisionComponent component, GetVerbsEvent args) + { + if (!args.CanAccess || !args.CanInteract) + return; + + ActivationVerb verb = new(); + verb.Text = Loc.GetString("toggle-nightvision-verb-get-data-text"); + verb.Act = () => ToggleNightVision(uid, component); + args.Verbs.Add(verb); + } + + private void OnGetActions(EntityUid uid, NightVisionComponent component, GetItemActionsEvent args) + { + args.AddAction(ref component.ToggleActionEntity, component.ToggleAction); + } +} + +public sealed partial class ToggleNightVisionEvent : InstantActionEvent {} diff --git a/Resources/Locale/en-US/NightVision/NightVision.ftl b/Resources/Locale/en-US/NightVision/NightVision.ftl new file mode 100644 index 00000000000..6475d00cc3f --- /dev/null +++ b/Resources/Locale/en-US/NightVision/NightVision.ftl @@ -0,0 +1,17 @@ +ent-ActionBaseToggleNightVision = Toggle night vision goggles + .desc = Toggles the night vision goggles on and off. +ent-ActionToggleNightVision = { ent-ActionBaseToggleNightVision } + .desc = { ent-ActionBaseToggleNightVision } +ent-ClothingEyesNVG = night vision goggles + .desc = Now you can see in the dark! It has the label "BL CORP technology". +toggle-nightvision-verb-get-data-text = Toggle Night Vision Goggles +ent-ClothingEyesNVG = night vision goggles + .desc = Now you can see in the dark! It has the label "BL CORP technology". +ent-ClothingEyesMesonNVG = engineering night vision goggles + .desc = { ent-ClothingEyesNVG.desc } +ent-ClothingEyesMedNVG = medical night vision goggles + .desc = { ent-ClothingEyesNVG.desc } +ent-ClothingEyesSecNVG = security night vision goggles + .desc = { ent-ClothingEyesNVG.desc } +ent-ClothingEyesDiagnosticNVG = diagnostic night vision goggles + .desc = { ent-ClothingEyesNVG.desc } \ No newline at end of file diff --git a/Resources/Locale/ru-RU/NightVision/NightVision.ftl b/Resources/Locale/ru-RU/NightVision/NightVision.ftl new file mode 100644 index 00000000000..e9999dae776 --- /dev/null +++ b/Resources/Locale/ru-RU/NightVision/NightVision.ftl @@ -0,0 +1,15 @@ +ent-ActionBaseToggleNightVision = Переключить ПНВ + .desc = Включате и выключает ПНВ. +ent-ActionToggleNightVision = { ent-ActionBaseToggleNightVision } + .desc = { ent-ActionBaseToggleNightVision } +ent-ClothingEyesNVG = ПНВ + .desc = Теперь ты можешь видеть в темноте! Имеет этикетку "BL CORP technology". +toggle-nightvision-verb-get-data-text = Переключить прибор ночного видения +ent-ClothingEyesMesonNVG = мезонный ПНВ + .desc = { ent-ClothingEyesNVG.desc } +ent-ClothingEyesMedNVG = медицинский ПНВ + .desc = { ent-ClothingEyesNVG.desc } +ent-ClothingEyesSecNVG = охранный ПНВ + .desc = { ent-ClothingEyesNVG.desc } +ent-ClothingEyesDiagnosticNVG = диагностирующий ПНВ + .desc = { ent-ClothingEyesNVG.desc } \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/NightVision.yml b/Resources/Prototypes/Entities/Clothing/Eyes/NightVision.yml new file mode 100644 index 00000000000..a031e0e06a9 --- /dev/null +++ b/Resources/Prototypes/Entities/Clothing/Eyes/NightVision.yml @@ -0,0 +1,117 @@ +- type: entity + parent: ClothingEyesBase + id: ClothingEyesNVG + name: night vision goggles + description: Now you can see in the dark! It has the label "BL CORP technology". + components: + - type: Sprite + sprite: Clothing/Eyes/NVG/nightvision.rsi + layers: + - state: icon + map: [ "enum.ToggleVisuals.Layer" ] + - type: Clothing + sprite: Clothing/Eyes/NVG/nightvision.rsi + - type: NightVision + tint1: 0.3 # Red + tint2: 1.0 # Green + tint3: 0.3 # Blue + # strength: 2 # Add if you need + # noise: 0.5 # Add if you need + - type: Appearance + - type: GenericVisualizer + visuals: + enum.ToggleVisuals.Toggled: + enum.ToggleVisuals.Layer: + True: {state: icon-on} + False: {state: icon} + - type: StaticPrice + price: 200 + - type: Tag + tags: + - WhitelistChameleon + +- type: entity + id: ClothingEyesMesonNVG + parent: ClothingEyesNVG + name: engineering night vision goggles + components: + - type: EyeProtection + +- type: entity + id: ClothingEyesSecNVG + parent: [ClothingEyesNVG, ShowSecurityIcons] + name: security night vision goggles + components: + - type: Tag + tags: + - HudSecurity + - type: NightVision + tint1: 1.0 + tint2: 0.3 + tint3: 0.3 + - type: Sprite + sprite: Clothing/Eyes/NVG/secnightvision.rsi + - type: Clothing + sprite: Clothing/Eyes/NVG/secnightvision.rsi + - type: FlashImmunity + +- type: entity + id: ClothingEyesMedNVG + parent: ClothingEyesNVG + name: medical night vision goggles + components: + - type: ShowHealthBars + damageContainers: + - Biological + - type: ShowHealthIcons + damageContainers: + - Biological + - type: Tag + tags: + - HudMedical + - type: NightVision + tint1: 0.3 + tint2: 0.3 + tint3: 0.7 + - type: Sprite + sprite: Clothing/Eyes/NVG/mednightvision.rsi + - type: Clothing + sprite: Clothing/Eyes/NVG/mednightvision.rsi + +- type: entity + id: ClothingEyesDiagnosticNVG + parent: ClothingEyesNVG + name: diagnostic night vision goggles + components: + - type: NightVision + tint1: 1.0 + tint2: 1.0 + tint3: 0.3 + - type: Sprite + sprite: Clothing/Eyes/NVG/diagnosticnightvision.rsi + - type: Clothing + sprite: Clothing/Eyes/NVG/diagnosticnightvision.rsi + - type: EyeProtection + - type: ShowHealthBars + damageContainers: + - Inorganic + - Silicon + +- type: entity + id: ActionBaseToggleNightVision + name: Toggle NVG + description: Toggles the NVG on and off. + noSpawn: true + components: + - type: InstantAction + itemIconStyle: NoItem + event: !type:ToggleNightVisionEvent + +- type: entity + id: ActionToggleNightVision + parent: ActionBaseToggleNightVision + noSpawn: true + components: + - type: InstantAction + icon: { sprite: Clothing/Eyes/NVG/nightvision.rsi, state: toggle-on } + iconOn: { sprite: Clothing/Eyes/NVG/nightvision.rsi, state: toggle-off } diff --git a/Resources/Prototypes/Shaders/shaders.yml b/Resources/Prototypes/Shaders/shaders.yml index 41d04137bbe..af8ae69e3fc 100644 --- a/Resources/Prototypes/Shaders/shaders.yml +++ b/Resources/Prototypes/Shaders/shaders.yml @@ -122,4 +122,9 @@ - type: shader id: Ethereal kind: source - path: "/Textures/Shaders/ethereal.swsl" \ No newline at end of file + path: "/Textures/Shaders/ethereal.swsl" + +- type: shader + id: NightVision + kind: source + path: "/Textures/Shaders/nightvision.swsl" \ No newline at end of file diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/equipped-EYES.png new file mode 100644 index 00000000000..bc45f57ae02 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/icon-on.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/icon-on.png new file mode 100644 index 00000000000..c27068e1f1f Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/icon-on.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/icon.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/icon.png new file mode 100644 index 00000000000..8bcf7105c2b Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/icon.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/inhand-left.png new file mode 100644 index 00000000000..04fff80e4df Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/inhand-right.png new file mode 100644 index 00000000000..d80344136fc Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/meta.json b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/meta.json new file mode 100644 index 00000000000..76398eb54e4 --- /dev/null +++ b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/meta.json @@ -0,0 +1,41 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from Blue Moon ss13 https://github.com/BlueMoon-Labs/MOLOT-BlueMoon-Station", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + }, + { + "name": "equipped-EYES", + "directions": 4 + }, + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + }, + { + "name": "icon-on" + }, + { + "name": "on-equipped-EYES", + "directions": 4 + }, + { + "name": "on-inhand-left", + "directions": 4 + }, + { + "name": "on-inhand-right", + "directions": 4 + } + ] +} diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-equipped-EYES.png new file mode 100644 index 00000000000..b0b75165ac6 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-inhand-left.png new file mode 100644 index 00000000000..da7cf291d21 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-inhand-right.png new file mode 100644 index 00000000000..d891cb8cb20 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/diagnosticnightvision.rsi/on-inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/equipped-EYES.png new file mode 100644 index 00000000000..518ee78ffec Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/icon-on.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/icon-on.png new file mode 100644 index 00000000000..11413cf3dd2 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/icon-on.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/icon.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/icon.png new file mode 100644 index 00000000000..52522c080e8 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/icon.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/inhand-left.png new file mode 100644 index 00000000000..bccfe98d09b Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/inhand-right.png new file mode 100644 index 00000000000..f9c17318b4e Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/meta.json b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/meta.json new file mode 100644 index 00000000000..76398eb54e4 --- /dev/null +++ b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/meta.json @@ -0,0 +1,41 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from Blue Moon ss13 https://github.com/BlueMoon-Labs/MOLOT-BlueMoon-Station", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + }, + { + "name": "equipped-EYES", + "directions": 4 + }, + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + }, + { + "name": "icon-on" + }, + { + "name": "on-equipped-EYES", + "directions": 4 + }, + { + "name": "on-inhand-left", + "directions": 4 + }, + { + "name": "on-inhand-right", + "directions": 4 + } + ] +} diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-equipped-EYES.png new file mode 100644 index 00000000000..3b26ab6b182 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-inhand-left.png new file mode 100644 index 00000000000..0976a8fbf0c Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-inhand-right.png new file mode 100644 index 00000000000..94d32783e0a Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/mednightvision.rsi/on-inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/equipped-EYES.png new file mode 100644 index 00000000000..7d15515f7ad Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/icon-on.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/icon-on.png new file mode 100644 index 00000000000..bf770f70f89 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/icon-on.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/icon.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/icon.png new file mode 100644 index 00000000000..a2d457c0c9e Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/icon.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/inhand-left.png new file mode 100644 index 00000000000..995b37471b3 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/inhand-right.png new file mode 100644 index 00000000000..c3efa67f837 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/meta.json b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/meta.json new file mode 100644 index 00000000000..4f8e3c50c72 --- /dev/null +++ b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/meta.json @@ -0,0 +1,47 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from Blue Moon ss13 https://github.com/BlueMoon-Labs/MOLOT-BlueMoon-Station, toggle-on/off by @timxx7019 from Lost Paradise", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + }, + { + "name": "equipped-EYES", + "directions": 4 + }, + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + }, + { + "name": "icon-on" + }, + { + "name": "on-equipped-EYES", + "directions": 4 + }, + { + "name": "on-inhand-left", + "directions": 4 + }, + { + "name": "on-inhand-right", + "directions": 4 + }, + { + "name": "toggle-on" + }, + { + "name": "toggle-off" + } + ] +} diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-equipped-EYES.png new file mode 100644 index 00000000000..5ddabf1024e Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-inhand-left.png new file mode 100644 index 00000000000..f7ea640aeec Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-inhand-right.png new file mode 100644 index 00000000000..c90f8a48622 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/on-inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/toggle-off.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/toggle-off.png new file mode 100644 index 00000000000..93c05c1e5fb Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/toggle-off.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/toggle-on.png b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/toggle-on.png new file mode 100644 index 00000000000..d38018fc26d Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/nightvision.rsi/toggle-on.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/equipped-EYES.png new file mode 100644 index 00000000000..0c70aaa3ea7 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/icon-on.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/icon-on.png new file mode 100644 index 00000000000..81f695aa460 Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/icon-on.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/icon.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/icon.png new file mode 100644 index 00000000000..80ae69d53ba Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/icon.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/inhand-left.png new file mode 100644 index 00000000000..02b00b1591e Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/inhand-right.png new file mode 100644 index 00000000000..6ba4b3e64ee Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/inhand-right.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/meta.json b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/meta.json new file mode 100644 index 00000000000..9e0e84aba42 --- /dev/null +++ b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/meta.json @@ -0,0 +1,42 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from Blue Moon ss13 https://github.com/BlueMoon-Labs/MOLOT-BlueMoon-Station", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + }, + { + "name": "equipped-EYES", + "directions": 4 + }, + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + }, + { + "name": "icon-on" + }, + { + "name": "on-equipped-EYES", + "directions": 4 + }, + { + "name": "on-inhand-left", + "directions": 4 + }, + { + "name": "on-inhand-right", + "directions": 4 + } + ] +} + diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-equipped-EYES.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-equipped-EYES.png new file mode 100644 index 00000000000..b73779a280e Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-equipped-EYES.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-inhand-left.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-inhand-left.png new file mode 100644 index 00000000000..c93ac180ffe Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-inhand-left.png differ diff --git a/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-inhand-right.png b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-inhand-right.png new file mode 100644 index 00000000000..6ba4b3e64ee Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/NVG/secnightvision.rsi/on-inhand-right.png differ diff --git a/Resources/Textures/Shaders/nightvision.swsl b/Resources/Textures/Shaders/nightvision.swsl new file mode 100644 index 00000000000..8a3e7706ada --- /dev/null +++ b/Resources/Textures/Shaders/nightvision.swsl @@ -0,0 +1,38 @@ +light_mode unshaded; + +uniform sampler2D SCREEN_TEXTURE; +uniform highp vec3 tint; // Colour of the tint +uniform highp float luminance_threshold; // number between 0 and 1 +uniform highp float noise_amount; // number between 0 and 1 + +lowp float rand (lowp vec2 n) { + return 0.5 + 0.5 * fract (sin (dot (n.xy, vec2 (12.9898, 78.233)))* 43758.5453); +} + +void fragment() { + + highp vec4 color = zTextureSpec(SCREEN_TEXTURE, FRAGCOORD.xy * SCREEN_PIXEL_SIZE); + + // convert color to grayscale using luminance + highp float grey = dot(color.rgb, vec3(0.298, 0.5882, 0.1137)); + + // calculate local threshold + highp float threshold = grey * luminance_threshold; + + // amplify low luminance parts + if (grey < threshold) { + grey += (threshold - grey) * 0.5; + if (grey > 1.0) { + grey = 1.0; + } + } + + // apply night vision color tint + color.rgb = mix(color.rgb, tint, grey); + + // add some noise for realism + lowp float noise = rand(FRAGCOORD.xy + TIME) * noise_amount / 10.0; + color.rgb += noise; + + COLOR = color; +}