Added configuration for wave shader (#439)
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Content.Shared._CP14.Configuration;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Placement;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -7,16 +11,19 @@ namespace Content.Client._CP14.Wave;
|
||||
|
||||
public sealed class CP14WaveShaderSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _configuration = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private ShaderInstance _shader = default!;
|
||||
private bool _enabled;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_shader = _protoMan.Index<ShaderPrototype>("Wave").InstanceUnique();
|
||||
_enabled = _configuration.GetCVar(CP14ConfigVars.WaveShaderEnabled);
|
||||
|
||||
SubscribeLocalEvent<CP14WaveShaderComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<CP14WaveShaderComponent, ComponentShutdown>(OnShutdown);
|
||||
@@ -36,7 +43,7 @@ public sealed class CP14WaveShaderSystem : EntitySystem
|
||||
|
||||
private void SetShader(Entity<SpriteComponent?> entity, ShaderInstance? instance)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp, false))
|
||||
if (!Resolve(entity, ref entity.Comp, false) || !_enabled)
|
||||
return;
|
||||
|
||||
entity.Comp.PostShader = instance;
|
||||
@@ -46,6 +53,9 @@ public sealed class CP14WaveShaderSystem : EntitySystem
|
||||
|
||||
private void OnBeforeShaderPost(Entity<CP14WaveShaderComponent> entity, ref BeforePostShaderRenderEvent args)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
_shader.SetParameter("Speed", entity.Comp.Speed);
|
||||
_shader.SetParameter("Dis", entity.Comp.Dis);
|
||||
_shader.SetParameter("Offset", entity.Comp.Offset);
|
||||
|
||||
11
Content.Shared/_CP14/Configuration/CP14ConfigVars.cs
Normal file
11
Content.Shared/_CP14/Configuration/CP14ConfigVars.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Shared._CP14.Configuration;
|
||||
|
||||
[CVarDefs]
|
||||
public sealed class CP14ConfigVars : CVars
|
||||
{
|
||||
public static readonly CVarDef<bool>
|
||||
WaveShaderEnabled = CVarDef.Create("cp14_rendering.wave_shader_enabled", true, CVar.CLIENT);
|
||||
}
|
||||
Reference in New Issue
Block a user