From f755768866f90115b1f602ef40701adfb5d93319 Mon Sep 17 00:00:00 2001 From: Ruddygreat Date: Sat, 28 Dec 2024 18:29:17 +0000 Subject: [PATCH 1/6] outlines for the stealth shader --- Content.Client/Stealth/StealthSystem.cs | 35 ++++++++- .../_Impstation/Shaders/shaders.yml | 4 ++ .../Shaders/accesible_full_stealth.swsl | 72 +++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 Resources/Prototypes/_Impstation/Shaders/shaders.yml create mode 100644 Resources/Textures/_Impstation/Shaders/accesible_full_stealth.swsl diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index adb25e1ef63b09..1cace9d632d15d 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -1,9 +1,11 @@ +using Content.Client.Administration.Managers; using Content.Client.Interactable.Components; -using Content.Client.StatusIcon; +using Content.Shared.Ghost; using Content.Shared.Stealth; using Content.Shared.Stealth.Components; using Robust.Client.GameObjects; using Robust.Client.Graphics; +using Robust.Client.Player; using Robust.Shared.Prototypes; namespace Content.Client.Stealth; @@ -12,6 +14,8 @@ public sealed class StealthSystem : SharedStealthSystem { [Dependency] private readonly IPrototypeManager _protoMan = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IClientAdminManager _adminManager = default!; private ShaderInstance _shader = default!; @@ -19,7 +23,7 @@ public override void Initialize() { base.Initialize(); - _shader = _protoMan.Index("Stealth").InstanceUnique(); + _shader = _protoMan.Index("AccesibleFullStealth").InstanceUnique(); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnStartup); @@ -86,6 +90,33 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos reference.X = -reference.X; var visibility = GetVisibility(uid, component); + //imp special - show an outline for people that should see it, goes along with complete invisibility + //includes the entity with the component, any admins & any ghosts + //todo want this to check for if the player's entity is inside a container as well + _shader.SetParameter("ShowOutline", false); //make sure it's always false by default + + bool isAdmin = false; + bool isCorrectSession = false; + bool isGhost = false; + bool isInContainer = false; + + if (_playerManager.LocalSession != null) + { + if (_playerManager.TryGetSessionByEntity(uid, out var playerSession)) + { + isCorrectSession = playerSession.UserId == _playerManager.LocalSession.UserId; + } + + isAdmin = _adminManager.IsAdmin(); + isGhost = HasComp(_playerManager.LocalSession.AttachedEntity); + } + + if (isAdmin || isCorrectSession || isGhost || isInContainer) + { + _shader.SetParameter("ShowOutline", true); + } + //imp special end + // actual visual visibility effect is limited to +/- 1. visibility = Math.Clamp(visibility, -1f, 1f); diff --git a/Resources/Prototypes/_Impstation/Shaders/shaders.yml b/Resources/Prototypes/_Impstation/Shaders/shaders.yml new file mode 100644 index 00000000000000..487beb576a3331 --- /dev/null +++ b/Resources/Prototypes/_Impstation/Shaders/shaders.yml @@ -0,0 +1,4 @@ +- type: shader + id: AccesibleFullStealth + kind: source + path: "/Textures/_Impstation/Shaders/accesible_full_stealth.swsl" diff --git a/Resources/Textures/_Impstation/Shaders/accesible_full_stealth.swsl b/Resources/Textures/_Impstation/Shaders/accesible_full_stealth.swsl new file mode 100644 index 00000000000000..790e6795e4e393 --- /dev/null +++ b/Resources/Textures/_Impstation/Shaders/accesible_full_stealth.swsl @@ -0,0 +1,72 @@ +light_mode unshaded; + +uniform sampler2D SCREEN_TEXTURE; +uniform highp float visibility; // number between -1 and 1 +uniform bool ShowOutline; + +uniform highp float outline_width = 2.0; +uniform highp vec4 outline_color = vec4(0.0,1.0,0.0,0.33); +uniform bool outline_fullbright = false; +uniform highp float light_boost = 4.0; +uniform highp float light_gamma = 1.0; +uniform highp float light_whitepoint = 1.0; + +void fragment() { + highp vec4 spriteCol = zTexture(UV); + highp vec4 outlineCol = getOutlineCol(); + highp float clampedVis = clamp(visibility, 0, 1); + + if (outlineCol.a > 0.1 && ShowOutline) { + COLOR.rgb = outlineCol.rgb; + COLOR.a = outlineCol.a * (1 - clampedVis); + } else { + COLOR.rgb = spriteCol.rgb; + COLOR.a = spriteCol.a * clampedVis; + } +} + +highp vec4 getOutlineCol() { + highp vec4 col = zTexture(UV); + highp vec2 ps = TEXTURE_PIXEL_SIZE; + highp float a; + highp float maxa = col.a; + highp float mina = col.a; + + // note: these bypass zTexture because only alpha is queried. + a = texture2D(TEXTURE, UV + vec2(0.0, -outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(-outline_width, -outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(0.0, outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(outline_width, -outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(-outline_width,0.0)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(-outline_width, outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(outline_width, 0.0)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + a = texture2D(TEXTURE, UV + vec2(outline_width, outline_width)*ps).a; + maxa = max(a, maxa); + mina = min(a, mina); + + //todo figure out how to make this not look like ass + //the original outline shader has some dark magic in it, maybe move that up to the main method? + + return vec4(outline_color.rgb, maxa - col.a); +} From e19c89f7abfa11c3c10d5f32d5c21abc8d2df9ee Mon Sep 17 00:00:00 2001 From: Ruddygreat Date: Sat, 28 Dec 2024 21:23:21 +0000 Subject: [PATCH 2/6] typo fix --- Content.Client/Stealth/StealthSystem.cs | 2 +- Resources/Prototypes/_Impstation/Shaders/shaders.yml | 4 ++-- ...cesible_full_stealth.swsl => accessible_full_stealth.swsl} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename Resources/Textures/_Impstation/Shaders/{accesible_full_stealth.swsl => accessible_full_stealth.swsl} (100%) diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index 1cace9d632d15d..77c6d0fbf830ac 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -23,7 +23,7 @@ public override void Initialize() { base.Initialize(); - _shader = _protoMan.Index("AccesibleFullStealth").InstanceUnique(); + _shader = _protoMan.Index("AccessibleFullStealth").InstanceUnique(); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnStartup); diff --git a/Resources/Prototypes/_Impstation/Shaders/shaders.yml b/Resources/Prototypes/_Impstation/Shaders/shaders.yml index 487beb576a3331..77c32c7067bf2d 100644 --- a/Resources/Prototypes/_Impstation/Shaders/shaders.yml +++ b/Resources/Prototypes/_Impstation/Shaders/shaders.yml @@ -1,4 +1,4 @@ - type: shader - id: AccesibleFullStealth + id: AccessibleFullStealth kind: source - path: "/Textures/_Impstation/Shaders/accesible_full_stealth.swsl" + path: "/Textures/_Impstation/Shaders/accessible_full_stealth.swsl" diff --git a/Resources/Textures/_Impstation/Shaders/accesible_full_stealth.swsl b/Resources/Textures/_Impstation/Shaders/accessible_full_stealth.swsl similarity index 100% rename from Resources/Textures/_Impstation/Shaders/accesible_full_stealth.swsl rename to Resources/Textures/_Impstation/Shaders/accessible_full_stealth.swsl From 9534dd28dacdb5ec72805eeb49fbbd1f63e14ead Mon Sep 17 00:00:00 2001 From: Ruddygreat Date: Sun, 29 Dec 2024 12:56:48 +0000 Subject: [PATCH 3/6] outlines for containing entities --- Content.Client/Stealth/StealthSystem.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index 77c6d0fbf830ac..d643e098bea24c 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -16,6 +16,7 @@ public sealed class StealthSystem : SharedStealthSystem [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IClientAdminManager _adminManager = default!; + [Dependency] private readonly ContainerSystem _containerSystem = default!; private ShaderInstance _shader = default!; @@ -92,7 +93,6 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos //imp special - show an outline for people that should see it, goes along with complete invisibility //includes the entity with the component, any admins & any ghosts - //todo want this to check for if the player's entity is inside a container as well _shader.SetParameter("ShowOutline", false); //make sure it's always false by default bool isAdmin = false; @@ -109,6 +109,11 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos isAdmin = _adminManager.IsAdmin(); isGhost = HasComp(_playerManager.LocalSession.AttachedEntity); + + if (_playerManager.LocalSession.AttachedEntity is { } entity) + { + isInContainer = _containerSystem.ContainsEntity(uid, entity); + } } if (isAdmin || isCorrectSession || isGhost || isInContainer) From 04f1924d0a4a5c357d2cc715481409797fdc01c8 Mon Sep 17 00:00:00 2001 From: Ruddygreat Date: Sun, 29 Dec 2024 16:03:13 +0000 Subject: [PATCH 4/6] added ability to toggle between old and new shaders; anomalies still use the old shader --- Content.Client/Stealth/StealthSystem.cs | 41 +++++++++++++++---- .../Changeling/ChangelingSystem.Abilities.cs | 2 + .../Stealth/Components/StealthComponent.cs | 11 ++++- Content.Shared/Stealth/SharedStealthSystem.cs | 16 +++++++- .../Entities/Clothing/OuterClothing/suits.yml | 1 + .../Structures/Storage/Closets/big_boxes.yml | 1 + 6 files changed, 63 insertions(+), 9 deletions(-) diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index d643e098bea24c..c2b751b334522f 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -19,18 +19,41 @@ public sealed class StealthSystem : SharedStealthSystem [Dependency] private readonly ContainerSystem _containerSystem = default!; private ShaderInstance _shader = default!; + private ShaderInstance _altShader = default!; + + private float timer = 0; public override void Initialize() { base.Initialize(); - _shader = _protoMan.Index("AccessibleFullStealth").InstanceUnique(); + _shader = _protoMan.Index("Stealth").InstanceUnique(); + _altShader = _protoMan.Index("AccessibleFullStealth").InstanceUnique(); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnShaderRender); } + //don't like doing this but it's the only good way to have the shader update as far as I can tell + //though there's probably a better way, been staring at this for a while and kinda just want to be done with it + //it works well, but it's not a very elegant solution + public override void Update(float frameTime) + { + + //don't do this every frame at least + timer += frameTime; + if (timer < 0.1f) + return; + timer = 0; + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var ent, out var component)) + { + SetShader(ent, component.Enabled); + } + } + public override void SetEnabled(EntityUid uid, bool value, StealthComponent? component = null) { if (!Resolve(uid, ref component) || component.Enabled == value) @@ -46,7 +69,10 @@ private void SetShader(EntityUid uid, bool enabled, StealthComponent? component return; sprite.Color = Color.White; - sprite.PostShader = enabled ? _shader : null; + //imp special - use the alternative full-invis shader if we're set to + var shaderToUse = component.UseAltShader ? _altShader : _shader; + sprite.PostShader = enabled ? shaderToUse : null; + //imp special end sprite.GetScreenTexture = enabled; sprite.RaiseShaderEvent = enabled; @@ -93,7 +119,8 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos //imp special - show an outline for people that should see it, goes along with complete invisibility //includes the entity with the component, any admins & any ghosts - _shader.SetParameter("ShowOutline", false); //make sure it's always false by default + var shaderToUse = component.UseAltShader ? _altShader : _shader; + shaderToUse.SetParameter("ShowOutline", false); //make sure it's always false by default bool isAdmin = false; bool isCorrectSession = false; @@ -110,7 +137,7 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos isAdmin = _adminManager.IsAdmin(); isGhost = HasComp(_playerManager.LocalSession.AttachedEntity); - if (_playerManager.LocalSession.AttachedEntity is { } entity) + if (_playerManager.LocalSession.AttachedEntity is { } entity) //why can you not just use a normal nullcheck for this I hate c# { isInContainer = _containerSystem.ContainsEntity(uid, entity); } @@ -118,15 +145,15 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos if (isAdmin || isCorrectSession || isGhost || isInContainer) { - _shader.SetParameter("ShowOutline", true); + shaderToUse.SetParameter("ShowOutline", true); } //imp special end // actual visual visibility effect is limited to +/- 1. visibility = Math.Clamp(visibility, -1f, 1f); - _shader.SetParameter("reference", reference); - _shader.SetParameter("visibility", visibility); + shaderToUse.SetParameter("reference", reference); + shaderToUse.SetParameter("visibility", visibility); visibility = MathF.Max(0, visibility); args.Sprite.Color = new Color(visibility, visibility, 1, 1); diff --git a/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs b/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs index ad839511cb0597..5575462f83daf9 100644 --- a/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs +++ b/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs @@ -593,7 +593,9 @@ public void OnChameleonSkin(EntityUid uid, ChangelingComponent comp, ref ActionC } EnsureComp(uid); + _stealth.SetUseAltShader(uid, true); _stealth.SetMinVisibility(uid, 0); + _stealth.SetEnabled(uid, true); var stealthOnMove = EnsureComp(uid); stealthOnMove.MovementVisibilityRate = 1; diff --git a/Content.Shared/Stealth/Components/StealthComponent.cs b/Content.Shared/Stealth/Components/StealthComponent.cs index 1a8a647768a8b5..3e881a7ec93583 100644 --- a/Content.Shared/Stealth/Components/StealthComponent.cs +++ b/Content.Shared/Stealth/Components/StealthComponent.cs @@ -72,6 +72,13 @@ public sealed partial class StealthComponent : Component /// [DataField("examinedDesc")] public string ExaminedDesc = "stealth-visual-effect"; + + /// + /// Toggle for if the entity should use the alternate full invis shader + /// + [DataField("useAltShader")] + [ViewVariables(VVAccess.ReadWrite)] + public bool UseAltShader; } [Serializable, NetSerializable] @@ -80,11 +87,13 @@ public sealed class StealthComponentState : ComponentState public readonly float Visibility; public readonly TimeSpan? LastUpdated; public readonly bool Enabled; + public readonly bool UseAltShader; - public StealthComponentState(float stealthLevel, TimeSpan? lastUpdated, bool enabled) + public StealthComponentState(float stealthLevel, TimeSpan? lastUpdated, bool enabled, bool useAltShader) { Visibility = stealthLevel; LastUpdated = lastUpdated; Enabled = enabled; + UseAltShader = useAltShader; } } diff --git a/Content.Shared/Stealth/SharedStealthSystem.cs b/Content.Shared/Stealth/SharedStealthSystem.cs index 7ba45375ab4fb7..1711bdb01b69ce 100644 --- a/Content.Shared/Stealth/SharedStealthSystem.cs +++ b/Content.Shared/Stealth/SharedStealthSystem.cs @@ -98,7 +98,7 @@ protected virtual void OnInit(EntityUid uid, StealthComponent component, Compone private void OnStealthGetState(EntityUid uid, StealthComponent component, ref ComponentGetState args) { - args.State = new StealthComponentState(component.LastVisibility, component.LastUpdated, component.Enabled); + args.State = new StealthComponentState(component.LastVisibility, component.LastUpdated, component.Enabled, component.UseAltShader); } private void OnStealthHandleState(EntityUid uid, StealthComponent component, ref ComponentHandleState args) @@ -109,6 +109,7 @@ private void OnStealthHandleState(EntityUid uid, StealthComponent component, ref SetEnabled(uid, cast.Enabled, component); component.LastVisibility = cast.Visibility; component.LastUpdated = cast.LastUpdated; + component.UseAltShader = cast.UseAltShader; } private void OnMove(EntityUid uid, StealthOnMoveComponent component, ref MoveEvent args) @@ -222,4 +223,17 @@ public void SetMinVisibility(EntityUid uid, float value, StealthComponent? compo Dirty(uid, component); } + + /// + /// Sets whether the alternate full invis shader should be used + /// + public void SetUseAltShader(EntityUid uid, bool value, StealthComponent? component = null) + { + if (!Resolve(uid, ref component)) + return; + + component.UseAltShader = value; + + Dirty(uid, component); + } } diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml index 69733f094a7eae..2be57e84907ba3 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml @@ -164,6 +164,7 @@ - type: Stealth minVisibility: 0.1 lastVisibility: 0.1 + useAltShader: true - type: PowerCellDraw drawRate: 1.8 # 200 seconds on the default cell - type: ToggleCellDraw diff --git a/Resources/Prototypes/Entities/Structures/Storage/Closets/big_boxes.yml b/Resources/Prototypes/Entities/Structures/Storage/Closets/big_boxes.yml index 42362d2db1c7ec..ef47b29672a8f5 100644 --- a/Resources/Prototypes/Entities/Structures/Storage/Closets/big_boxes.yml +++ b/Resources/Prototypes/Entities/Structures/Storage/Closets/big_boxes.yml @@ -68,6 +68,7 @@ quiet: true - type: Stealth hadOutline: true + useAltShader: true - type: StealthOnMove passiveVisibilityRate: -0.37 movementVisibilityRate: 0.20 From 3c36dec0b41a9c492fbfd955fd65b3e567b40e8e Mon Sep 17 00:00:00 2001 From: Ruddygreat Date: Sun, 29 Dec 2024 16:06:35 +0000 Subject: [PATCH 5/6] remove a single unnecessary method call --- .../_Goobstation/Changeling/ChangelingSystem.Abilities.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs b/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs index 5575462f83daf9..e991318f5ef6a7 100644 --- a/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs +++ b/Content.Server/_Goobstation/Changeling/ChangelingSystem.Abilities.cs @@ -595,7 +595,6 @@ public void OnChameleonSkin(EntityUid uid, ChangelingComponent comp, ref ActionC EnsureComp(uid); _stealth.SetUseAltShader(uid, true); _stealth.SetMinVisibility(uid, 0); - _stealth.SetEnabled(uid, true); var stealthOnMove = EnsureComp(uid); stealthOnMove.MovementVisibilityRate = 1; From ced400a6e24c2134eab6efa927ea0368eca10f4a Mon Sep 17 00:00:00 2001 From: Ruddygreat Date: Mon, 30 Dec 2024 21:14:59 +0000 Subject: [PATCH 6/6] fixing comp networking & removing admi-specific outline check --- Content.Client/Stealth/StealthSystem.cs | 4 +--- Content.Shared/Stealth/Components/StealthComponent.cs | 4 +++- Content.Shared/Stealth/Components/StealthOnMoveComponent.cs | 6 +++--- Content.Shared/Stealth/SharedStealthSystem.cs | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Content.Client/Stealth/StealthSystem.cs b/Content.Client/Stealth/StealthSystem.cs index c2b751b334522f..c11b60423c7ca5 100644 --- a/Content.Client/Stealth/StealthSystem.cs +++ b/Content.Client/Stealth/StealthSystem.cs @@ -122,7 +122,6 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos var shaderToUse = component.UseAltShader ? _altShader : _shader; shaderToUse.SetParameter("ShowOutline", false); //make sure it's always false by default - bool isAdmin = false; bool isCorrectSession = false; bool isGhost = false; bool isInContainer = false; @@ -134,7 +133,6 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos isCorrectSession = playerSession.UserId == _playerManager.LocalSession.UserId; } - isAdmin = _adminManager.IsAdmin(); isGhost = HasComp(_playerManager.LocalSession.AttachedEntity); if (_playerManager.LocalSession.AttachedEntity is { } entity) //why can you not just use a normal nullcheck for this I hate c# @@ -143,7 +141,7 @@ private void OnShaderRender(EntityUid uid, StealthComponent component, BeforePos } } - if (isAdmin || isCorrectSession || isGhost || isInContainer) + if (isCorrectSession || isGhost || isInContainer) { shaderToUse.SetParameter("ShowOutline", true); } diff --git a/Content.Shared/Stealth/Components/StealthComponent.cs b/Content.Shared/Stealth/Components/StealthComponent.cs index 3e881a7ec93583..ba5c16ed75d254 100644 --- a/Content.Shared/Stealth/Components/StealthComponent.cs +++ b/Content.Shared/Stealth/Components/StealthComponent.cs @@ -88,12 +88,14 @@ public sealed class StealthComponentState : ComponentState public readonly TimeSpan? LastUpdated; public readonly bool Enabled; public readonly bool UseAltShader; + public readonly float MinVisibility; - public StealthComponentState(float stealthLevel, TimeSpan? lastUpdated, bool enabled, bool useAltShader) + public StealthComponentState(float stealthLevel, TimeSpan? lastUpdated, bool enabled, bool useAltShader, float minVisibility) { Visibility = stealthLevel; LastUpdated = lastUpdated; Enabled = enabled; UseAltShader = useAltShader; + MinVisibility = minVisibility; } } diff --git a/Content.Shared/Stealth/Components/StealthOnMoveComponent.cs b/Content.Shared/Stealth/Components/StealthOnMoveComponent.cs index 77c300759d5463..73bd2cb94f68a4 100644 --- a/Content.Shared/Stealth/Components/StealthOnMoveComponent.cs +++ b/Content.Shared/Stealth/Components/StealthOnMoveComponent.cs @@ -6,19 +6,19 @@ namespace Content.Shared.Stealth.Components /// When added to an entity with stealth component, this component will change the visibility /// based on the entity's (lack of) movement. /// - [RegisterComponent, NetworkedComponent] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class StealthOnMoveComponent : Component { /// /// Rate that effects how fast an entity's visibility passively changes. /// - [DataField("passiveVisibilityRate")] + [DataField("passiveVisibilityRate"), AutoNetworkedField] public float PassiveVisibilityRate = -0.15f; /// /// Rate for movement induced visibility changes. Scales with distance moved. /// - [DataField("movementVisibilityRate")] + [DataField("movementVisibilityRate"), AutoNetworkedField] public float MovementVisibilityRate = 0.2f; } } diff --git a/Content.Shared/Stealth/SharedStealthSystem.cs b/Content.Shared/Stealth/SharedStealthSystem.cs index 1711bdb01b69ce..ad9002fceeaee0 100644 --- a/Content.Shared/Stealth/SharedStealthSystem.cs +++ b/Content.Shared/Stealth/SharedStealthSystem.cs @@ -98,7 +98,7 @@ protected virtual void OnInit(EntityUid uid, StealthComponent component, Compone private void OnStealthGetState(EntityUid uid, StealthComponent component, ref ComponentGetState args) { - args.State = new StealthComponentState(component.LastVisibility, component.LastUpdated, component.Enabled, component.UseAltShader); + args.State = new StealthComponentState(component.LastVisibility, component.LastUpdated, component.Enabled, component.UseAltShader, component.MinVisibility); } private void OnStealthHandleState(EntityUid uid, StealthComponent component, ref ComponentHandleState args) @@ -110,6 +110,7 @@ private void OnStealthHandleState(EntityUid uid, StealthComponent component, ref component.LastVisibility = cast.Visibility; component.LastUpdated = cast.LastUpdated; component.UseAltShader = cast.UseAltShader; + component.MinVisibility = cast.MinVisibility; } private void OnMove(EntityUid uid, StealthOnMoveComponent component, ref MoveEvent args)