mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
it works? (#100)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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 void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
if (ScreenTexture == null)
|
||||
return;
|
||||
if (_playerManager.LocalPlayer?.ControlledEntity is not {Valid: true} player)
|
||||
return;
|
||||
if (!_entityManager.HasComponent<DogVisionComponent>(player))
|
||||
return;
|
||||
|
||||
_dogVisionShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
||||
|
||||
|
||||
var worldHandle = args.WorldHandle;
|
||||
var viewport = args.WorldBounds;
|
||||
worldHandle.SetTransform(Matrix3.Identity);
|
||||
worldHandle.UseShader(_dogVisionShader);
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Content.Shared.Abilities;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
|
||||
namespace Content.Client.Nyanotrasen.Overlays;
|
||||
|
||||
public sealed partial class DogVisionSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
[Dependency] private readonly IOverlayManager _overlayMan = default!;
|
||||
|
||||
private DogVisionOverlay _overlay = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DogVisionComponent, ComponentInit>(OnDogVisionInit);
|
||||
SubscribeLocalEvent<DogVisionComponent, ComponentShutdown>(OnDogVisionShutdown);
|
||||
|
||||
SubscribeLocalEvent<DogVisionComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
||||
SubscribeLocalEvent<DogVisionComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
||||
|
||||
_overlay = new();
|
||||
}
|
||||
|
||||
private void OnPlayerAttached(EntityUid uid, DogVisionComponent component, PlayerAttachedEvent args)
|
||||
{
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnPlayerDetached(EntityUid uid, DogVisionComponent component, PlayerDetachedEvent args)
|
||||
{
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnDogVisionInit(EntityUid uid, DogVisionComponent component, ComponentInit args)
|
||||
{
|
||||
if (_player.LocalPlayer?.ControlledEntity == uid)
|
||||
_overlayMan.AddOverlay(_overlay);
|
||||
}
|
||||
|
||||
private void OnDogVisionShutdown(EntityUid uid, DogVisionComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (_player.LocalPlayer?.ControlledEntity == uid)
|
||||
{
|
||||
_overlayMan.RemoveOverlay(_overlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Abilities;
|
||||
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
|
||||
public sealed partial class DogVisionComponent : Component
|
||||
{}
|
||||
@@ -0,0 +1,4 @@
|
||||
- type: shader
|
||||
id: DogVision
|
||||
kind: source
|
||||
path: "/Textures/Nyanotrasen/Shaders/dogvision.swsl"
|
||||
@@ -0,0 +1,5 @@
|
||||
- type: trait
|
||||
id: Colorblindness
|
||||
name: Colorblindness
|
||||
components:
|
||||
- type: DogVision
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user