forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1702 from hivehum/new-vision-disabilities
[DV/Nyano/Frontier Port] Deuteranopia (DogVision) and Tritanopia (UltraVision) traits
- Loading branch information
Showing
17 changed files
with
318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
using Content.Shared.Abilities; | ||
using System.Numerics; | ||
|
||
namespace Content.Client._DV.Overlays; | ||
|
||
public sealed partial class UltraVisionOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
[Dependency] IEntityManager _entityManager = default!; | ||
|
||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
private readonly ShaderInstance _ultraVisionShader; | ||
|
||
public UltraVisionOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_ultraVisionShader = _prototypeManager.Index<ShaderPrototype>("UltraVision").Instance().Duplicate(); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (_playerManager.LocalEntity is not { Valid: true } player | ||
|| !_entityManager.HasComponent<UltraVisionComponent>(player)) | ||
{ | ||
return false; | ||
} | ||
|
||
return base.BeforeDraw(in args); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture is null) | ||
return; | ||
|
||
_ultraVisionShader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
|
||
var worldHandle = args.WorldHandle; | ||
var viewport = args.WorldBounds; | ||
worldHandle.SetTransform(Matrix3x2.Identity); | ||
worldHandle.UseShader(_ultraVisionShader); | ||
worldHandle.DrawRect(viewport, Color.White); | ||
worldHandle.UseShader(null); // important - as of writing, construction overlay breaks without this | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Content.Shared.Abilities; | ||
using Content.Shared._DV.CCVars; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client._DV.Overlays; | ||
|
||
public sealed partial class UltraVisionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly ISharedPlayerManager _playerMan = default!; | ||
|
||
private UltraVisionOverlay _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<UltraVisionComponent, ComponentInit>(OnUltraVisionInit); | ||
SubscribeLocalEvent<UltraVisionComponent, ComponentShutdown>(OnUltraVisionShutdown); | ||
SubscribeLocalEvent<UltraVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<UltraVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached); | ||
|
||
Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged); | ||
|
||
_overlay = new(); | ||
} | ||
|
||
private void OnUltraVisionInit(EntityUid uid, UltraVisionComponent component, ComponentInit args) | ||
{ | ||
if (uid == _playerMan.LocalEntity && !_cfg.GetCVar(DCCVars.NoVisionFilters)) | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnUltraVisionShutdown(EntityUid uid, UltraVisionComponent component, ComponentShutdown args) | ||
{ | ||
if (uid == _playerMan.LocalEntity) | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, UltraVisionComponent component, LocalPlayerAttachedEvent args) | ||
{ | ||
if (!_cfg.GetCVar(DCCVars.NoVisionFilters)) | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, UltraVisionComponent component, LocalPlayerDetachedEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnNoVisionFiltersChanged(bool enabled) | ||
{ | ||
if (enabled) | ||
_overlayMan.RemoveOverlay(_overlay); | ||
else | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Numerics; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
using Content.Shared.Abilities; | ||
|
||
namespace Content.Client._Nyanotrasen.Overlays; | ||
|
||
public sealed partial class DogVisionOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
[Dependency] IEntityManager _entityManager = default!; | ||
|
||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
private readonly ShaderInstance _dogVisionShader; | ||
|
||
public DogVisionOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_dogVisionShader = _prototypeManager.Index<ShaderPrototype>("DogVision").Instance().Duplicate(); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (_playerManager.LocalEntity is not { Valid: true } player | ||
|| !_entityManager.HasComponent<DogVisionComponent>(player)) | ||
{ | ||
return false; | ||
} | ||
|
||
return base.BeforeDraw(in args); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture is null) | ||
return; | ||
|
||
_dogVisionShader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
|
||
var worldHandle = args.WorldHandle; | ||
var viewport = args.WorldBounds; | ||
worldHandle.SetTransform(Matrix3x2.Identity); | ||
worldHandle.UseShader(_dogVisionShader); | ||
worldHandle.DrawRect(viewport, Color.White); | ||
worldHandle.UseShader(null); // important - as of writing, construction overlay breaks without this | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Content.Shared.Abilities; | ||
using Content.Shared._DV.CCVars; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client._Nyanotrasen.Overlays; | ||
|
||
public sealed partial class DogVisionSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly ISharedPlayerManager _playerMan = default!; | ||
|
||
private DogVisionOverlay _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DogVisionComponent, ComponentInit>(OnDogVisionInit); | ||
SubscribeLocalEvent<DogVisionComponent, ComponentShutdown>(OnDogVisionShutdown); | ||
SubscribeLocalEvent<DogVisionComponent, LocalPlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<DogVisionComponent, LocalPlayerDetachedEvent>(OnPlayerDetached); | ||
|
||
Subs.CVar(_cfg, DCCVars.NoVisionFilters, OnNoVisionFiltersChanged); | ||
|
||
_overlay = new(); | ||
} | ||
|
||
private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args) | ||
{ | ||
if (uid == _playerMan.LocalEntity && !_cfg.GetCVar(DCCVars.NoVisionFilters)) | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args) | ||
{ | ||
if (uid == _playerMan.LocalEntity) | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, DogVisionComponent component, LocalPlayerAttachedEvent args) | ||
{ | ||
if (!_cfg.GetCVar(DCCVars.NoVisionFilters)) | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, DogVisionComponent component, LocalPlayerDetachedEvent args) | ||
{ | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnNoVisionFiltersChanged(bool enabled) | ||
{ | ||
if (enabled) | ||
_overlayMan.RemoveOverlay(_overlay); | ||
else | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Robust.Shared.GameStates; | ||
namespace Content.Shared.Abilities; | ||
|
||
[RegisterComponent] | ||
[NetworkedComponent] | ||
|
||
public sealed partial class UltraVisionComponent : Component | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Content.Shared/_Nyanotrasen/Abilities/DogVisionComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Abilities | ||
{ | ||
[RegisterComponent] | ||
[NetworkedComponent] | ||
|
||
public sealed partial class DogVisionComponent : Component | ||
{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ui-options-tab-extra = Extra | ||
ui-options-general-forknotice = Note: These settings are fork-specific and might not apply on other servers. | ||
ui-options-no-filters = Disable trait-specific shaders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- type: shader | ||
id: UltraVision | ||
kind: source | ||
path: "/Textures/_DV/Shaders/ultravision.swsl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- type: trait | ||
id: UltraVision | ||
name: trait-ultravision-name | ||
description: trait-ultravision-desc | ||
category: Disabilities | ||
components: | ||
- type: UltraVision | ||
|
||
- type: trait | ||
id: DogVision | ||
name: trait-deuteranopia-name | ||
description: trait-deuteranopia-desc | ||
category: Disabilities | ||
components: | ||
- type: DogVision |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- type: shader | ||
id: DogVision | ||
kind: source | ||
path: "/Textures/_Nyanotrasen/Shaders/dogvision.swsl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
uniform sampler2D SCREEN_TEXTURE; | ||
|
||
void fragment() { | ||
highp vec4 color = zTextureSpec(SCREEN_TEXTURE, UV); | ||
|
||
highp mat3 m = mat3( | ||
vec3(0.000,1.000,0.000), | ||
vec3(0.000,0.000,1.000), | ||
vec3(-0.165,0.165,1.000) | ||
); | ||
highp vec3 result = color.rgb * m; | ||
|
||
COLOR = vec4(result, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
uniform sampler2D SCREEN_TEXTURE; | ||
|
||
void fragment() { | ||
highp vec4 color = zTextureSpec(SCREEN_TEXTURE, UV); | ||
|
||
highp mat3 m = mat3( | ||
vec3(0.625,0.375,0.000), | ||
vec3(0.700,0.300,0.000), | ||
vec3(0.000,0.300,0.700) | ||
); | ||
highp vec3 result = color.rgb * m; | ||
|
||
COLOR = vec4(result, 1); | ||
} |