diff --git a/Content.Client/GameObjects/Components/SubFloorHideComponent.cs b/Content.Client/GameObjects/Components/SubFloorHideComponent.cs index 7ff9c67333..6b9ec1c228 100644 --- a/Content.Client/GameObjects/Components/SubFloorHideComponent.cs +++ b/Content.Client/GameObjects/Components/SubFloorHideComponent.cs @@ -1,22 +1,24 @@ -using Content.Shared.Maps; -using Robust.Client.Interfaces.GameObjects.Components; +using Robust.Client.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components.Transform; namespace Content.Client.GameObjects.Components { /// - /// Simple component that automatically hides the sibling when the tile it's on - /// is not a sub floor (plating). + /// Simple component that automatically hides the sibling + /// when the tile it's on is not a sub floor + /// (plating). /// - /// + /// [RegisterComponent] public sealed class SubFloorHideComponent : Component { private SnapGridComponent _snapGridComponent; + /// public override string Name => "SubFloorHide"; + /// public override void Initialize() { base.Initialize(); @@ -39,6 +41,7 @@ namespace Content.Client.GameObjects.Components base.Shutdown(); _snapGridComponent.OnPositionChanged -= SnapGridOnPositionChanged; + Owner.EntityManager.RaiseEvent(Owner, new SubFloorHideDirtyEvent()); } private void SnapGridOnPositionChanged() @@ -47,7 +50,5 @@ namespace Content.Client.GameObjects.Components } } - internal sealed class SubFloorHideDirtyEvent : EntitySystemMessage - { - } + internal sealed class SubFloorHideDirtyEvent : EntitySystemMessage { } } diff --git a/Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs b/Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs index 98b8fa1bd5..a373cf1ad9 100644 --- a/Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/SubFloorHideSystem.cs @@ -1,4 +1,4 @@ -using Content.Client.GameObjects.Components; +using Content.Client.GameObjects.Components; using Content.Shared.Maps; using Robust.Client.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects.Components.Transform; @@ -39,12 +39,9 @@ namespace Content.Client.GameObjects.EntitySystems return; } - var sprite = senderEnt.GetComponent(); var grid = _mapManager.GetGrid(senderEnt.Transform.GridID); - var position = senderEnt.Transform.GridPosition; - var tileRef = grid.GetTileRef(position); - var tileDef = (ContentTileDefinition) _tileDefinitionManager[tileRef.Tile.TypeId]; - sprite.Visible = tileDef.IsSubFloor; + var indices = grid.WorldToTile(senderEnt.Transform.WorldPosition); + UpdateTile(grid, indices); } private void MapManagerOnTileChanged(object sender, TileChangedEventArgs e) @@ -67,13 +64,13 @@ namespace Content.Client.GameObjects.EntitySystems foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center)) { var entity = snapGridComponent.Owner; - if (!entity.HasComponent() || + if (!entity.TryGetComponent(out SubFloorHideComponent subFloorComponent) || !entity.TryGetComponent(out ISpriteComponent spriteComponent)) { continue; } - spriteComponent.Visible = tileDef.IsSubFloor; + spriteComponent.Visible = !subFloorComponent.Running || tileDef.IsSubFloor; } } }