diff --git a/Content.Client/Commands/DebugCommands.cs b/Content.Client/Commands/DebugCommands.cs index 09b8ee3a72..1f94d59228 100644 --- a/Content.Client/Commands/DebugCommands.cs +++ b/Content.Client/Commands/DebugCommands.cs @@ -4,11 +4,12 @@ using System; using Content.Client.GameObjects.Components; using Content.Client.GameObjects.EntitySystems; using Content.Client.Interfaces; +using Content.Shared.GameObjects.Components; +using Content.Shared.GameObjects.EntitySystems; using Robust.Client.GameObjects; using Robust.Shared.Console; using Robust.Shared.GameObjects; using Robust.Shared.IoC; -using Robust.Shared.Maths; using DrawDepth = Content.Shared.GameObjects.DrawDepth; namespace Content.Client.Commands @@ -37,7 +38,7 @@ namespace Content.Client.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { EntitySystem.Get() - .EnableAll ^= true; + .ShowAll ^= true; } } @@ -51,7 +52,7 @@ namespace Content.Client.Commands public void Execute(IConsoleShell shell, string argStr, string[] args) { EntitySystem.Get() - .EnableAll = true; + .ShowAll = true; var components = IoCManager.Resolve().ComponentManager .EntityQuery(true); diff --git a/Content.Client/GameObjects/Components/Disposal/DisposalVisualizer.cs b/Content.Client/GameObjects/Components/Disposal/DisposalVisualizer.cs index 8766d5443f..17ff4aad4a 100644 --- a/Content.Client/GameObjects/Components/Disposal/DisposalVisualizer.cs +++ b/Content.Client/GameObjects/Components/Disposal/DisposalVisualizer.cs @@ -1,4 +1,5 @@ using System; +using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components.Disposal; using JetBrains.Annotations; using Robust.Client.GameObjects; diff --git a/Content.Client/Sandbox/SandboxManager.cs b/Content.Client/Sandbox/SandboxManager.cs index ec6c0edeac..3341345d0d 100644 --- a/Content.Client/Sandbox/SandboxManager.cs +++ b/Content.Client/Sandbox/SandboxManager.cs @@ -1,6 +1,7 @@ using System; using Content.Client.GameObjects.EntitySystems; using Content.Client.UserInterface; +using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Input; using Content.Shared.Sandbox; using Robust.Client.Console; @@ -73,7 +74,7 @@ namespace Content.Client.Sandbox ToggleShadowsButton = new Button { Text = Loc.GetString("Toggle Shadows"), ToggleMode = true, Pressed = !IoCManager.Resolve().DrawShadows }; vBox.AddChild(ToggleShadowsButton); - ToggleSubfloorButton = new Button { Text = Loc.GetString("Toggle Subfloor"), ToggleMode = true, Pressed = EntitySystem.Get().EnableAll }; + ToggleSubfloorButton = new Button { Text = Loc.GetString("Toggle Subfloor"), ToggleMode = true, Pressed = EntitySystem.Get().ShowAll }; vBox.AddChild(ToggleSubfloorButton); SuicideButton = new Button { Text = Loc.GetString("Suicide") }; diff --git a/Content.Server/IgnoredComponents.cs b/Content.Server/IgnoredComponents.cs index 86f6d25498..49a1f6fc2b 100644 --- a/Content.Server/IgnoredComponents.cs +++ b/Content.Server/IgnoredComponents.cs @@ -6,7 +6,6 @@ namespace Content.Server public static string[] List => new [] { "ConstructionGhost", "IconSmooth", - "SubFloorHide", "LowWall", "ReinforcedWall", "InteractionOutline", diff --git a/Content.Client/GameObjects/Components/SubFloorHideComponent.cs b/Content.Shared/GameObjects/Components/SubFloorHideComponent.cs similarity index 78% rename from Content.Client/GameObjects/Components/SubFloorHideComponent.cs rename to Content.Shared/GameObjects/Components/SubFloorHideComponent.cs index 7fbff47bdf..64eef269e2 100644 --- a/Content.Client/GameObjects/Components/SubFloorHideComponent.cs +++ b/Content.Shared/GameObjects/Components/SubFloorHideComponent.cs @@ -1,9 +1,8 @@ -using System.Diagnostics; -using Robust.Client.GameObjects; +#nullable enable using Robust.Shared.GameObjects; -using Robust.Shared.Utility; +using Robust.Shared.Log; -namespace Content.Client.GameObjects.Components +namespace Content.Shared.GameObjects.Components { /// /// Simple component that automatically hides the sibling @@ -20,14 +19,6 @@ namespace Content.Client.GameObjects.Components /// public override string Name => "SubFloorHide"; - /// - public override void Initialize() - { - base.Initialize(); - - _snapGridComponent = Owner.GetComponent(); - } - /// protected override void Startup() { @@ -54,8 +45,13 @@ namespace Content.Client.GameObjects.Components private void OnAddSnapGrid() { - DebugTools.AssertNotNull(_snapGridComponent); - _snapGridComponent!.OnPositionChanged += SnapGridOnPositionChanged; + if (_snapGridComponent == null) + { + // Shouldn't happen but allows us to use nullables. OnPositionChanged needs to be componentbus anyway. + Logger.Error("Snapgrid was null for subfloor {Owner}"); + return; + } + _snapGridComponent.OnPositionChanged += SnapGridOnPositionChanged; } private void SnapGridOnPositionChanged() diff --git a/Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs b/Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs similarity index 79% rename from Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs rename to Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs index 83a815745b..c1be2b7ade 100644 --- a/Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs @@ -1,31 +1,32 @@ -using Content.Client.GameObjects.Components; +#nullable enable +using Content.Shared.GameObjects.Components; using Content.Shared.Maps; -using Robust.Client.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.ViewVariables; -namespace Content.Client.GameObjects.EntitySystems +namespace Content.Shared.GameObjects.EntitySystems { /// /// Entity system backing . /// - internal sealed class SubFloorHideSystem : EntitySystem + public class SubFloorHideSystem : EntitySystem { [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; - private bool _enableAll; + private bool _showAll; [ViewVariables(VVAccess.ReadWrite)] - public bool EnableAll + public bool ShowAll { - get => _enableAll; + get => _showAll; set { - _enableAll = value; + if (_showAll == value) return; + _showAll = value; UpdateAll(); } @@ -90,16 +91,16 @@ namespace Content.Client.GameObjects.EntitySystems continue; } - var enabled = EnableAll || !subFloorComponent.Running || tileDef.IsSubFloor; - - if (entity.TryGetComponent(out ISpriteComponent? spriteComponent)) + // Show sprite + if (entity.TryGetComponent(out SharedSpriteComponent? spriteComponent)) { - spriteComponent.Visible = enabled; + spriteComponent.Visible = ShowAll || !subFloorComponent.Running || tileDef.IsSubFloor; } + // So for collision all we care about is that the component is running. if (entity.TryGetComponent(out PhysicsComponent? physicsComponent)) { - physicsComponent.CanCollide = enabled; + physicsComponent.CanCollide = !subFloorComponent.Running; } } }