diff --git a/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs b/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs index 606e39fa86..f11819d931 100644 --- a/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs +++ b/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs @@ -1,12 +1,14 @@ -using System; +using System; using System.Collections.Generic; using Content.Client.GameObjects.EntitySystems; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Serialization.Manager.Attributes; +using Robust.Shared.Utility; using static Robust.Client.GameObjects.SpriteComponent; namespace Content.Client.GameObjects.Components.IconSmoothing @@ -25,6 +27,8 @@ namespace Content.Client.GameObjects.Components.IconSmoothing [RegisterComponent] public class IconSmoothComponent : Component { + [Dependency] private readonly IMapManager _mapManager = default!; + [DataField("mode")] private IconSmoothingMode _mode = IconSmoothingMode.Corners; @@ -32,8 +36,6 @@ namespace Content.Client.GameObjects.Components.IconSmoothing internal ISpriteComponent? Sprite { get; private set; } - internal SnapGridComponent? SnapGrid { get; private set; } - private (GridId, Vector2i) _lastPosition; /// @@ -62,7 +64,6 @@ namespace Content.Client.GameObjects.Components.IconSmoothing { base.Initialize(); - SnapGrid = Owner.GetComponent(); Sprite = Owner.GetComponent(); } @@ -71,15 +72,14 @@ namespace Content.Client.GameObjects.Components.IconSmoothing { base.Startup(); - if (SnapGrid != null) + if (Owner.Transform.Anchored) { - SnapGrid.OnPositionChanged += SnapGridOnPositionChanged; - // ensures lastposition initial value is populated on spawn. Just calling // the hook here would cause a dirty event to fire needlessly - _lastPosition = (Owner.Transform.GridID, SnapGrid.Position); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + _lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates)); - Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner,null, SnapGrid.Offset, Mode)); + Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode)); } if (Sprite != null && Mode == IconSmoothingMode.Corners) @@ -115,20 +115,22 @@ namespace Content.Client.GameObjects.Components.IconSmoothing private void CalculateNewSpriteCardinal() { - if (SnapGrid == null || Sprite == null) + if (!Owner.Transform.Anchored || Sprite == null) { return; } var dirs = CardinalConnectDirs.None; - if (MatchingEntity(SnapGrid.GetInDir(Direction.North))) + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var position = Owner.Transform.Coordinates; + if (MatchingEntity(grid.GetInDir(position, Direction.North))) dirs |= CardinalConnectDirs.North; - if (MatchingEntity(SnapGrid.GetInDir(Direction.South))) + if (MatchingEntity(grid.GetInDir(position, Direction.South))) dirs |= CardinalConnectDirs.South; - if (MatchingEntity(SnapGrid.GetInDir(Direction.East))) + if (MatchingEntity(grid.GetInDir(position, Direction.East))) dirs |= CardinalConnectDirs.East; - if (MatchingEntity(SnapGrid.GetInDir(Direction.West))) + if (MatchingEntity(grid.GetInDir(position, Direction.West))) dirs |= CardinalConnectDirs.West; Sprite.LayerSetState(0, $"{StateBase}{(int) dirs}"); @@ -151,19 +153,21 @@ namespace Content.Client.GameObjects.Components.IconSmoothing protected (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill() { - if (SnapGrid == null) + if (!Owner.Transform.Anchored) { return (CornerFill.None, CornerFill.None, CornerFill.None, CornerFill.None); } - var n = MatchingEntity(SnapGrid.GetInDir(Direction.North)); - var ne = MatchingEntity(SnapGrid.GetInDir(Direction.NorthEast)); - var e = MatchingEntity(SnapGrid.GetInDir(Direction.East)); - var se = MatchingEntity(SnapGrid.GetInDir(Direction.SouthEast)); - var s = MatchingEntity(SnapGrid.GetInDir(Direction.South)); - var sw = MatchingEntity(SnapGrid.GetInDir(Direction.SouthWest)); - var w = MatchingEntity(SnapGrid.GetInDir(Direction.West)); - var nw = MatchingEntity(SnapGrid.GetInDir(Direction.NorthWest)); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var position = Owner.Transform.Coordinates; + var n = MatchingEntity(grid.GetInDir(position, Direction.North)); + var ne = MatchingEntity(grid.GetInDir(position, Direction.NorthEast)); + var e = MatchingEntity(grid.GetInDir(position, Direction.East)); + var se = MatchingEntity(grid.GetInDir(position, Direction.SouthEast)); + var s = MatchingEntity(grid.GetInDir(position, Direction.South)); + var sw = MatchingEntity(grid.GetInDir(position, Direction.SouthWest)); + var w = MatchingEntity(grid.GetInDir(position, Direction.West)); + var nw = MatchingEntity(grid.GetInDir(position, Direction.NorthWest)); // ReSharper disable InconsistentNaming var cornerNE = CornerFill.None; @@ -234,28 +238,28 @@ namespace Content.Client.GameObjects.Components.IconSmoothing { base.Shutdown(); - if (SnapGrid != null) + if (Owner.Transform.Anchored) { - SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged; - Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode)); + Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode)); } } - private void SnapGridOnPositionChanged() + public void SnapGridOnPositionChanged() { - if (SnapGrid != null) + if (Owner.Transform.Anchored) { - Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, SnapGrid.Offset, Mode)); - _lastPosition = (Owner.Transform.GridID, SnapGrid.Position); + Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode)); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + _lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates)); } } [System.Diagnostics.Contracts.Pure] - protected bool MatchingEntity(IEnumerable candidates) + protected bool MatchingEntity(IEnumerable candidates) { foreach (var entity in candidates) { - if (!entity.TryGetComponent(out IconSmoothComponent? other)) + if (!Owner.EntityManager.ComponentManager.TryGetComponent(entity, out IconSmoothComponent? other)) { continue; } diff --git a/Content.Client/GameObjects/Components/LowWallComponent.cs b/Content.Client/GameObjects/Components/LowWallComponent.cs index 7c40805c7f..a6d3c89712 100644 --- a/Content.Client/GameObjects/Components/LowWallComponent.cs +++ b/Content.Client/GameObjects/Components/LowWallComponent.cs @@ -1,10 +1,13 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using Content.Client.GameObjects.Components.IconSmoothing; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; using Robust.Shared.Maths; +using Robust.Shared.Utility; using Robust.Shared.ViewVariables; using static Robust.Client.GameObjects.SpriteComponent; @@ -23,6 +26,8 @@ namespace Content.Client.GameObjects.Components { public override string Name => "LowWall"; + [Dependency] private readonly IMapManager _mapManager = default!; + public CornerFill LastCornerNE { get; private set; } public CornerFill LastCornerSE { get; private set; } public CornerFill LastCornerSW { get; private set; } @@ -65,19 +70,22 @@ namespace Content.Client.GameObjects.Components { base.CalculateNewSprite(); - if (Sprite == null || SnapGrid == null || _overlaySprite == null) + if (Sprite == null || !Owner.Transform.Anchored || _overlaySprite == null) { return; } - var (n, nl) = MatchingWall(SnapGrid.GetInDir(Direction.North)); - var (ne, nel) = MatchingWall(SnapGrid.GetInDir(Direction.NorthEast)); - var (e, el) = MatchingWall(SnapGrid.GetInDir(Direction.East)); - var (se, sel) = MatchingWall(SnapGrid.GetInDir(Direction.SouthEast)); - var (s, sl) = MatchingWall(SnapGrid.GetInDir(Direction.South)); - var (sw, swl) = MatchingWall(SnapGrid.GetInDir(Direction.SouthWest)); - var (w, wl) = MatchingWall(SnapGrid.GetInDir(Direction.West)); - var (nw, nwl) = MatchingWall(SnapGrid.GetInDir(Direction.NorthWest)); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + + var (n, nl) = MatchingWall(grid.GetInDir(coords, Direction.North)); + var (ne, nel) = MatchingWall(grid.GetInDir(coords, Direction.NorthEast)); + var (e, el) = MatchingWall(grid.GetInDir(coords, Direction.East)); + var (se, sel) = MatchingWall(grid.GetInDir(coords, Direction.SouthEast)); + var (s, sl) = MatchingWall(grid.GetInDir(coords, Direction.South)); + var (sw, swl) = MatchingWall(grid.GetInDir(coords, Direction.SouthWest)); + var (w, wl) = MatchingWall(grid.GetInDir(coords, Direction.West)); + var (nw, nwl) = MatchingWall(grid.GetInDir(coords, Direction.NorthWest)); // ReSharper disable InconsistentNaming var cornerNE = CornerFill.None; @@ -194,9 +202,9 @@ namespace Content.Client.GameObjects.Components LastCornerSW = cornerSW; LastCornerNW = cornerNW; - foreach (var entity in SnapGrid.GetLocal()) + foreach (var entity in grid.GetLocal(coords)) { - if (entity.TryGetComponent(out WindowComponent? window)) + if (Owner.EntityManager.ComponentManager.TryGetComponent(entity, out WindowComponent? window)) { window.UpdateSprite(); } @@ -204,11 +212,11 @@ namespace Content.Client.GameObjects.Components } [Pure] - private (bool connected, bool lowWall) MatchingWall(IEnumerable candidates) + private (bool connected, bool lowWall) MatchingWall(IEnumerable candidates) { foreach (var entity in candidates) { - if (!entity.TryGetComponent(out IconSmoothComponent? other)) + if (!Owner.EntityManager.ComponentManager.TryGetComponent(entity, out IconSmoothComponent? other)) { continue; } diff --git a/Content.Client/GameObjects/Components/WindowComponent.cs b/Content.Client/GameObjects/Components/WindowComponent.cs index e7261333a4..13b980b8d8 100644 --- a/Content.Client/GameObjects/Components/WindowComponent.cs +++ b/Content.Client/GameObjects/Components/WindowComponent.cs @@ -1,8 +1,11 @@ -using System.Diagnostics.CodeAnalysis; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Content.Client.GameObjects.EntitySystems; using Content.Shared.GameObjects.Components; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; using Robust.Shared.Serialization.Manager.Attributes; using static Content.Client.GameObjects.Components.IconSmoothing.IconSmoothComponent; @@ -12,18 +15,18 @@ namespace Content.Client.GameObjects.Components [ComponentReference(typeof(SharedWindowComponent))] public sealed class WindowComponent : SharedWindowComponent { + [Dependency] private readonly IMapManager _mapManager = default!; + [DataField("base")] private string? _stateBase; private ISpriteComponent? _sprite; - private SnapGridComponent? _snapGrid; public override void Initialize() { base.Initialize(); _sprite = Owner.GetComponent(); - _snapGrid = Owner.GetComponent(); } /// @@ -31,11 +34,6 @@ namespace Content.Client.GameObjects.Components { base.Startup(); - if (_snapGrid != null) - { - _snapGrid.OnPositionChanged += SnapGridOnPositionChanged; - } - Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new WindowSmoothDirtyEvent(Owner)); if (_sprite != null) @@ -67,18 +65,7 @@ namespace Content.Client.GameObjects.Components } } - /// - protected override void Shutdown() - { - if (_snapGrid != null) - { - _snapGrid.OnPositionChanged -= SnapGridOnPositionChanged; - } - - base.Shutdown(); - } - - private void SnapGridOnPositionChanged() + public void SnapGridOnPositionChanged() { Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new WindowSmoothDirtyEvent(Owner)); } @@ -102,14 +89,14 @@ namespace Content.Client.GameObjects.Components private LowWallComponent? FindLowWall() { - if (_snapGrid == null) - { + if (!Owner.Transform.Anchored) return null; - } - foreach (var entity in _snapGrid.GetLocal()) + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + foreach (var entity in grid.GetLocal(coords)) { - if (entity.TryGetComponent(out LowWallComponent? lowWall)) + if (Owner.EntityManager.ComponentManager.TryGetComponent(entity, out LowWallComponent? lowWall)) { return lowWall; } diff --git a/Content.Client/GameObjects/Components/WindowVisualizer.cs b/Content.Client/GameObjects/Components/WindowVisualizer.cs index bc790ba1f5..7763d70bd0 100644 --- a/Content.Client/GameObjects/Components/WindowVisualizer.cs +++ b/Content.Client/GameObjects/Components/WindowVisualizer.cs @@ -1,9 +1,11 @@ -using System; +using System; using Content.Shared.GameObjects.Components; using Content.Shared.Utility; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; namespace Content.Client.GameObjects.Components { @@ -15,10 +17,10 @@ namespace Content.Client.GameObjects.Components base.OnChangeData(component); var sprite = component.Owner.GetComponent(); - if (!component.Owner.TryGetComponent(out SnapGridComponent? snapGrid)) + if (!component.Owner.Transform.Anchored) return; - var lowWall = FindLowWall(snapGrid); + var lowWall = FindLowWall(IoCManager.Resolve(), component.Owner.Transform); if (lowWall == null) return; @@ -48,11 +50,13 @@ namespace Content.Client.GameObjects.Components } } - private static LowWallComponent? FindLowWall(SnapGridComponent snapGrid) + private static LowWallComponent? FindLowWall(IMapManager mapManager, ITransformComponent transform) { - foreach (var entity in snapGrid.GetLocal()) + var grid = mapManager.GetGrid(transform.GridID); + var coords = transform.Coordinates; + foreach (var entity in grid.GetLocal(coords)) { - if (entity.TryGetComponent(out LowWallComponent? lowWall)) + if (transform.Owner.EntityManager.ComponentManager.TryGetComponent(entity, out LowWallComponent? lowWall)) { return lowWall; } diff --git a/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs b/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs index 5a5c058d2c..7a435e9dbf 100644 --- a/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Content.Client.GameObjects.Components.IconSmoothing; using JetBrains.Annotations; @@ -6,6 +6,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; using Robust.Shared.Maths; +using Robust.Shared.Utility; namespace Content.Client.GameObjects.EntitySystems { @@ -17,7 +18,7 @@ namespace Content.Client.GameObjects.EntitySystems { [Dependency] private readonly IMapManager _mapManager = default!; - private readonly Queue _dirtyEntities = new(); + private readonly Queue _dirtyEntities = new(); private int _generation; @@ -27,13 +28,18 @@ namespace Content.Client.GameObjects.EntitySystems base.Initialize(); SubscribeLocalEvent(HandleDirtyEvent); + + SubscribeLocalEvent(HandleSnapGridMove); } + public override void Shutdown() { base.Shutdown(); UnsubscribeLocalEvent(); + + UnsubscribeLocalEvent(HandleSnapGridMove); } public override void FrameUpdate(float frameTime) @@ -63,20 +69,20 @@ namespace Content.Client.GameObjects.EntitySystems senderEnt.TryGetComponent(out IconSmoothComponent? iconSmooth) && iconSmooth.Running) { - var snapGrid = senderEnt.GetComponent(); + var grid1 = _mapManager.GetGrid(senderEnt.Transform.GridID); + var coords = senderEnt.Transform.Coordinates; - _dirtyEntities.Enqueue(senderEnt); - AddValidEntities(snapGrid.GetInDir(Direction.North)); - AddValidEntities(snapGrid.GetInDir(Direction.South)); - AddValidEntities(snapGrid.GetInDir(Direction.East)); - AddValidEntities(snapGrid.GetInDir(Direction.West)); + _dirtyEntities.Enqueue(senderEnt.Uid); + AddValidEntities(grid1.GetInDir(coords, Direction.North)); + AddValidEntities(grid1.GetInDir(coords, Direction.South)); + AddValidEntities(grid1.GetInDir(coords, Direction.East)); + AddValidEntities(grid1.GetInDir(coords, Direction.West)); if (ev.Mode == IconSmoothingMode.Corners) { - - AddValidEntities(snapGrid.GetInDir(Direction.NorthEast)); - AddValidEntities(snapGrid.GetInDir(Direction.SouthEast)); - AddValidEntities(snapGrid.GetInDir(Direction.SouthWest)); - AddValidEntities(snapGrid.GetInDir(Direction.NorthWest)); + AddValidEntities(grid1.GetInDir(coords, Direction.NorthEast)); + AddValidEntities(grid1.GetInDir(coords, Direction.SouthEast)); + AddValidEntities(grid1.GetInDir(coords, Direction.SouthWest)); + AddValidEntities(grid1.GetInDir(coords, Direction.NorthWest)); } } @@ -85,43 +91,43 @@ namespace Content.Client.GameObjects.EntitySystems { var pos = ev.LastPosition.Value.pos; - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(1, 0), ev.Offset)); - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(-1, 0), ev.Offset)); - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(0, 1), ev.Offset)); - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(0, -1), ev.Offset)); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(1, 0))); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(-1, 0))); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(0, 1))); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(0, -1))); if (ev.Mode == IconSmoothingMode.Corners) { - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(1, 1), ev.Offset)); - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(-1, -1), ev.Offset)); - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(-1, 1), ev.Offset)); - AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(1, -1), ev.Offset)); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(1, 1))); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(-1, -1))); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(-1, 1))); + AddValidEntities(grid.GetAnchoredEntities(pos + new Vector2i(1, -1))); } } } - private void AddValidEntities(IEnumerable candidates) + private static void HandleSnapGridMove(EntityUid uid, IconSmoothComponent component, SnapGridPositionChangedEvent args) + { + component.SnapGridOnPositionChanged(); + } + + private void AddValidEntities(IEnumerable candidates) { foreach (var entity in candidates) { - if (entity.HasComponent()) + if (ComponentManager.HasComponent(entity)) { _dirtyEntities.Enqueue(entity); } } } - private void AddValidEntities(IEnumerable candidates) - { - AddValidEntities(candidates.Select(c => c.Owner)); - } - - private void CalculateNewSprite(IEntity entity) + private void CalculateNewSprite(EntityUid euid) { // The generation check prevents updating an entity multiple times per tick. // As it stands now, it's totally possible for something to get queued twice. // Generation on the component is set after an update so we can cull updates that happened this generation. - if (!entity.IsValid() - || !entity.TryGetComponent(out IconSmoothComponent? smoothing) + if (!EntityManager.EntityExists(euid) + || !ComponentManager.TryGetComponent(euid, out IconSmoothComponent? smoothing) || smoothing.UpdateGeneration == _generation) { return; @@ -138,16 +144,14 @@ namespace Content.Client.GameObjects.EntitySystems /// public sealed class IconSmoothDirtyEvent : EntityEventArgs { - public IconSmoothDirtyEvent(IEntity sender, (GridId grid, Vector2i pos)? lastPosition, SnapGridOffset offset, IconSmoothingMode mode) + public IconSmoothDirtyEvent(IEntity sender, (GridId grid, Vector2i pos)? lastPosition, IconSmoothingMode mode) { LastPosition = lastPosition; - Offset = offset; Mode = mode; Sender = sender; } public (GridId grid, Vector2i pos)? LastPosition { get; } - public SnapGridOffset Offset { get; } public IconSmoothingMode Mode { get; } public IEntity Sender { get; } } diff --git a/Content.Client/GameObjects/EntitySystems/WindowSystem.cs b/Content.Client/GameObjects/EntitySystems/WindowSystem.cs index 77f0133cdd..96ef802c9c 100644 --- a/Content.Client/GameObjects/EntitySystems/WindowSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/WindowSystem.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Client.GameObjects.Components; using JetBrains.Annotations; using Robust.Shared.GameObjects; @@ -15,6 +15,7 @@ namespace Content.Client.GameObjects.EntitySystems base.Initialize(); SubscribeLocalEvent(HandleDirtyEvent); + SubscribeLocalEvent(HandleSnapGridMove); } public override void Shutdown() @@ -22,6 +23,7 @@ namespace Content.Client.GameObjects.EntitySystems base.Shutdown(); UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(HandleSnapGridMove); } private void HandleDirtyEvent(WindowSmoothDirtyEvent ev) @@ -32,6 +34,11 @@ namespace Content.Client.GameObjects.EntitySystems } } + private static void HandleSnapGridMove(EntityUid uid, WindowComponent component, SnapGridPositionChangedEvent args) + { + component.SnapGridOnPositionChanged(); + } + public override void FrameUpdate(float frameTime) { base.FrameUpdate(frameTime); diff --git a/Content.Server/Commands/GameTicking/TileWallsCommand.cs b/Content.Server/Commands/GameTicking/TileWallsCommand.cs index 69c18f1982..1e1a64f6ed 100644 --- a/Content.Server/Commands/GameTicking/TileWallsCommand.cs +++ b/Content.Server/Commands/GameTicking/TileWallsCommand.cs @@ -90,7 +90,7 @@ namespace Content.Server.Commands.GameTicking continue; } - if (!childEntity.TryGetComponent(out SnapGridComponent? snapGrid)) + if (!childEntity.Transform.Anchored) { continue; } diff --git a/Content.Server/Construction/Completions/SnapToGrid.cs b/Content.Server/Construction/Completions/SnapToGrid.cs index 33b015aacf..dba3151742 100644 --- a/Content.Server/Construction/Completions/SnapToGrid.cs +++ b/Content.Server/Construction/Completions/SnapToGrid.cs @@ -4,10 +4,8 @@ using Content.Server.Utility; using Content.Shared.Construction; using JetBrains.Annotations; using Robust.Shared.GameObjects; -using Robust.Shared.Serialization; using Robust.Shared.Maths; using Robust.Shared.Serialization.Manager.Attributes; -using YamlDotNet.Serialization; namespace Content.Server.Construction.Completions { @@ -15,14 +13,13 @@ namespace Content.Server.Construction.Completions [DataDefinition] public class SnapToGrid : IGraphAction { - [DataField("offset")] public SnapGridOffset Offset { get; private set; } = SnapGridOffset.Center; [DataField("southRotation")] public bool SouthRotation { get; private set; } = false; public async Task PerformAction(IEntity entity, IEntity? user) { if (entity.Deleted) return; - entity.SnapToGrid(Offset); + entity.SnapToGrid(); if (SouthRotation) { entity.Transform.LocalRotation = Angle.Zero; diff --git a/Content.Server/GameObjects/Components/AnchorableComponent.cs b/Content.Server/GameObjects/Components/AnchorableComponent.cs index e529354283..185dfe52d3 100644 --- a/Content.Server/GameObjects/Components/AnchorableComponent.cs +++ b/Content.Server/GameObjects/Components/AnchorableComponent.cs @@ -10,7 +10,6 @@ using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Physics; -using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components @@ -105,7 +104,7 @@ namespace Content.Server.GameObjects.Components } if (Snap) - Owner.SnapToGrid(SnapGridOffset.Center, Owner.EntityManager); + Owner.SnapToGrid(Owner.EntityManager); Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new AnchoredMessage(), false); diff --git a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs index 0d3a351348..cfaf5a0d21 100644 --- a/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs @@ -3,6 +3,8 @@ using Content.Server.GameObjects.EntitySystems; using Content.Shared.Atmos; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Serialization.Manager.Attributes; @@ -14,6 +16,8 @@ namespace Content.Server.GameObjects.Components.Atmos [RegisterComponent] public class AirtightComponent : Component, IMapInit { + [Dependency] private readonly IMapManager _mapManager = default!; + private (GridId, Vector2i) _lastPosition; private AtmosphereSystem _atmosphereSystem = default!; @@ -77,14 +81,13 @@ namespace Content.Server.GameObjects.Components.Atmos _atmosphereSystem = EntitySystem.Get(); - // Using the SnapGrid is critical for performance, and thus if it is absent the component - // will not be airtight. A warning is much easier to track down than the object magically - // not being airtight, so log one if the SnapGrid component is missing. - Owner.EnsureComponentWarn(out SnapGridComponent _); - if (_fixAirBlockedDirectionInitialize) RotateEvent(new RotateEvent(Owner, Angle.Zero, Owner.Transform.WorldRotation)); + // Adding this component will immediately anchor the entity, because the atmos system + // requires airtight entities to be anchored for performance. + Owner.Transform.Anchored = true; + UpdatePosition(); } @@ -116,28 +119,25 @@ namespace Content.Server.GameObjects.Components.Atmos return newAirBlockedDirs; } + /// public void MapInit() { - if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) + if (Owner.Transform.Anchored) { - snapGrid.OnPositionChanged += OnTransformMove; - _lastPosition = (Owner.Transform.GridID, snapGrid.Position); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + _lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates)); } UpdatePosition(); } + /// protected override void Shutdown() { base.Shutdown(); _airBlocked = false; - if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) - { - snapGrid.OnPositionChanged -= OnTransformMove; - } - UpdatePosition(_lastPosition.Item1, _lastPosition.Item2); if (_fixVacuum) @@ -146,21 +146,25 @@ namespace Content.Server.GameObjects.Components.Atmos } } - private void OnTransformMove() + public void OnTransformMove() { UpdatePosition(_lastPosition.Item1, _lastPosition.Item2); UpdatePosition(); - if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) + if (Owner.Transform.Anchored) { - _lastPosition = (Owner.Transform.GridID, snapGrid.Position); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + _lastPosition = (Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates)); } } private void UpdatePosition() { - if (Owner.TryGetComponent(out SnapGridComponent? snapGrid)) - UpdatePosition(Owner.Transform.GridID, snapGrid.Position); + if (Owner.Transform.Anchored) + { + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + UpdatePosition(Owner.Transform.GridID, grid.TileIndicesFor(Owner.Transform.Coordinates)); + } } private void UpdatePosition(GridId gridId, Vector2i pos) diff --git a/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs b/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs index 4cf8b27980..8019c0b313 100644 --- a/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GasCanisterComponent.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Collections.Generic; using System.Linq; using Content.Server.Atmos; using Content.Server.GameObjects.Components.Atmos.Piping; @@ -11,6 +12,8 @@ using Content.Shared.GameObjects.EntitySystems.ActionBlocker; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; using Robust.Shared.Physics; @@ -24,6 +27,8 @@ namespace Content.Server.GameObjects.Components.Atmos [ComponentReference(typeof(IActivate))] public class GasCanisterComponent : Component, IGasMixtureHolder, IActivate { + [Dependency] private readonly IMapManager _mapManager = default!; + public override string Name => "GasCanister"; private const int MaxLabelLength = 32; @@ -114,9 +119,11 @@ namespace Content.Server.GameObjects.Components.Atmos public void TryConnectToPort() { - if (!Owner.TryGetComponent(out var snapGrid)) return; - var port = snapGrid.GetLocal() - .Select(entity => entity.TryGetComponent(out var port) ? port : null) + if (!Owner.Transform.Anchored) return; + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + var port = grid.GetLocal(coords) + .Select(entity => Owner.EntityManager.ComponentManager.TryGetComponent(entity, out var port) ? port : null) .Where(port => port != null) .Where(port => !port!.ConnectedToCanister) .FirstOrDefault(); diff --git a/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs b/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs index 315bebea6a..c97745d136 100644 --- a/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/Piping/GasCanisterPortComponent.cs @@ -1,9 +1,12 @@ #nullable enable +using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.NodeContainer; using Content.Server.GameObjects.Components.NodeContainer.Nodes; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Log; +using Robust.Shared.Map; using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.Atmos.Piping @@ -13,6 +16,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping { public override string Name => "GasCanisterPort"; + [Dependency] private readonly IMapManager _mapManager = default!; + [ViewVariables] public GasCanisterComponent? ConnectedCanister { get; private set; } @@ -27,12 +32,14 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping base.Initialize(); Owner.EnsureComponentWarn(); SetGasPort(); - if (Owner.TryGetComponent(out var snapGrid)) + if (Owner.Transform.Anchored) { - var entities = snapGrid.GetLocal(); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + var entities = grid.GetLocal(coords); foreach (var entity in entities) { - if (entity.TryGetComponent(out var canister) && canister.Anchored && !canister.ConnectedToPort) + if (Owner.EntityManager.ComponentManager.TryGetComponent(entity, out var canister) && canister.Anchored && !canister.ConnectedToPort) { canister.TryConnectToPort(); break; diff --git a/Content.Server/GameObjects/Components/Chemistry/SolutionAreaEffectComponent.cs b/Content.Server/GameObjects/Components/Chemistry/SolutionAreaEffectComponent.cs index 0a1dfb4057..206193bbe2 100644 --- a/Content.Server/GameObjects/Components/Chemistry/SolutionAreaEffectComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/SolutionAreaEffectComponent.cs @@ -1,11 +1,10 @@ -#nullable enable +#nullable enable using System; using System.Linq; using Content.Server.GameObjects.Components.Atmos; using Content.Server.Utility; using Content.Shared.Chemistry; using Content.Shared.GameObjects.EntitySystems; -using Content.Shared.Interfaces.GameObjects.Components; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Log; @@ -24,7 +23,6 @@ namespace Content.Server.GameObjects.Components.Chemistry [Dependency] protected readonly IMapManager MapManager = default!; [Dependency] protected readonly IPrototypeManager PrototypeManager = default!; - [ComponentDependency] protected readonly SnapGridComponent? SnapGridComponent = default!; [ComponentDependency] protected readonly SolutionContainerComponent? SolutionContainerComponent = default!; public int Amount { get; set; } public SolutionAreaEffectInceptionComponent? Inception { get; set; } @@ -63,26 +61,20 @@ namespace Content.Server.GameObjects.Components.Chemistry return; } - if (SnapGridComponent == null) - { - Logger.Error("AreaEffectComponent attached to " + Owner.Prototype.ID + - " couldn't get SnapGridComponent from owner."); - return; - } - void SpreadToDir(Direction dir) { - foreach (var neighbor in SnapGridComponent.GetInDir(dir)) + var grid = MapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + foreach (var neighbor in grid.GetInDir(coords, dir)) { - if (neighbor.TryGetComponent(out SolutionAreaEffectComponent? comp) && comp.Inception == Inception) + if (Owner.EntityManager.ComponentManager.TryGetComponent(neighbor, out SolutionAreaEffectComponent? comp) && comp.Inception == Inception) return; - if (neighbor.TryGetComponent(out AirtightComponent? airtight) && airtight.AirBlocked) + if (Owner.EntityManager.ComponentManager.TryGetComponent(neighbor, out AirtightComponent? airtight) && airtight.AirBlocked) return; } - var newEffect = - Owner.EntityManager.SpawnEntity(Owner.Prototype.ID, SnapGridComponent.DirectionToGrid(dir)); + var newEffect = Owner.EntityManager.SpawnEntity(Owner.Prototype.ID, grid.DirectionToGrid(coords, dir)); if (!newEffect.TryGetComponent(out SolutionAreaEffectComponent? effectComponent)) { diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs index a240ee60db..0b31b4f8bd 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalMailingUnitComponent.cs @@ -26,6 +26,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Log; +using Robust.Shared.Map; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Physics; using Robust.Shared.Player; @@ -43,6 +44,7 @@ namespace Content.Server.GameObjects.Components.Disposal public class DisposalMailingUnitComponent : SharedDisposalMailingUnitComponent, IInteractHand, IActivate, IInteractUsing, IDragDropOn { [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IMapManager _mapManager = default!; private const string HolderPrototypeId = "DisposalHolder"; @@ -277,17 +279,17 @@ namespace Content.Server.GameObjects.Components.Disposal return false; } - var snapGrid = Owner.GetComponent(); - var entry = snapGrid - .GetLocal() - .FirstOrDefault(entity => entity.HasComponent()); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + var entry = grid.GetLocal(coords) + .FirstOrDefault(entity => Owner.EntityManager.ComponentManager.HasComponent(entity)); - if (entry == null) + if (entry == default) { return false; } - var entryComponent = entry.GetComponent(); + var entryComponent = Owner.EntityManager.ComponentManager.GetComponent(entry); var entities = _container.ContainedEntities.ToList(); foreach (var entity in _container.ContainedEntities.ToList()) { diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs index f0102384cd..22806c2daf 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalTubeComponent.cs @@ -1,5 +1,6 @@ #nullable enable using System; +using System.Collections.Generic; using System.Linq; using Content.Shared.GameObjects.Components.Disposal; using Content.Shared.GameObjects.EntitySystems; @@ -12,6 +13,7 @@ using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -26,6 +28,7 @@ namespace Content.Server.GameObjects.Components.Disposal public abstract class DisposalTubeComponent : Component, IDisposalTubeComponent, IBreakAct { [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IMapManager _mapManager = default!; private static readonly TimeSpan ClangDelay = TimeSpan.FromSeconds(0.5); private TimeSpan _lastClang; @@ -67,12 +70,13 @@ namespace Content.Server.GameObjects.Components.Disposal public IDisposalTubeComponent? NextTube(DisposalHolderComponent holder) { var nextDirection = NextDirection(holder); - var snapGrid = Owner.GetComponent(); var oppositeDirection = new Angle(nextDirection.ToAngle().Theta + Math.PI).GetDir(); - foreach (var entity in snapGrid.GetInDir(nextDirection)) + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var position = Owner.Transform.Coordinates; + foreach (var entity in grid.GetInDir(position, nextDirection)) { - if (!entity.TryGetComponent(out IDisposalTubeComponent? tube)) + if (!Owner.EntityManager.ComponentManager.TryGetComponent(entity, out IDisposalTubeComponent? tube)) { continue; } diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs index b0fbafa4e4..cb043e2702 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs @@ -28,6 +28,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Log; +using Robust.Shared.Map; using Robust.Shared.Physics; using Robust.Shared.Player; using Robust.Shared.Random; @@ -44,6 +45,7 @@ namespace Content.Server.GameObjects.Components.Disposal public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IThrowCollide, IGasMixtureHolder { [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IMapManager _mapManager = default!; public override string Name => "DisposalUnit"; @@ -260,17 +262,17 @@ namespace Content.Server.GameObjects.Components.Disposal return false; } - var snapGrid = Owner.GetComponent(); - var entry = snapGrid - .GetLocal() - .FirstOrDefault(entity => entity.HasComponent()); + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + var entry = grid.GetLocal(coords) + .FirstOrDefault(entity => Owner.EntityManager.ComponentManager.HasComponent(entity)); - if (entry == null) + if (entry == default) { return false; } - var entryComponent = entry.GetComponent(); + var entryComponent = Owner.EntityManager.ComponentManager.GetComponent(entry); if (Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos) && tileAtmos.Air != null && diff --git a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs index a64f11fefa..acb752be08 100644 --- a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs @@ -78,7 +78,6 @@ namespace Content.Server.GameObjects.Components.Fluids private bool _overflown; private SpriteComponent _spriteComponent = default!; - private SnapGridComponent _snapGrid = default!; public ReagentUnit MaxVolume { @@ -112,7 +111,6 @@ namespace Content.Server.GameObjects.Components.Fluids base.Initialize(); _contents = Owner.EnsureComponentWarn(); - _snapGrid = Owner.EnsureComponent(); // Smaller than 1m^3 for now but realistically this shouldn't be hit MaxVolume = ReagentUnit.New(1000); @@ -348,8 +346,9 @@ namespace Content.Server.GameObjects.Components.Fluids puddle = default; var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; - if (!Owner.Transform.Coordinates.Offset(direction).TryGetTileRef(out var tile)) + if (!coords.Offset(direction).TryGetTileRef(out var tile)) { return false; } @@ -360,16 +359,19 @@ namespace Content.Server.GameObjects.Components.Fluids return false; } - foreach (var entity in _snapGrid.GetInDir(direction)) + if (!Owner.Transform.Anchored) + return false; + + foreach (var entity in mapGrid.GetInDir(coords, direction)) { - if (entity.TryGetComponent(out IPhysBody? physics) && + if (Owner.EntityManager.ComponentManager.TryGetComponent(entity, out IPhysBody? physics) && (physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0) { puddle = default; return false; } - if (entity.TryGetComponent(out PuddleComponent? existingPuddle)) + if (Owner.EntityManager.ComponentManager.TryGetComponent(entity, out PuddleComponent? existingPuddle)) { if (existingPuddle._overflown) { @@ -382,8 +384,7 @@ namespace Content.Server.GameObjects.Components.Fluids if (puddle == default) { - var grid = _snapGrid.DirectionToGrid(direction); - puddle = () => Owner.EntityManager.SpawnEntity(Owner.Prototype?.ID, grid).GetComponent(); + puddle = () => Owner.EntityManager.SpawnEntity(Owner.Prototype?.ID, mapGrid.DirectionToGrid(coords, direction)).GetComponent(); } return true; diff --git a/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs b/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs index cc11f684d7..8d29c0d697 100644 --- a/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs +++ b/Content.Server/GameObjects/Components/Items/RCD/RCDComponent.cs @@ -101,7 +101,7 @@ namespace Content.Server.GameObjects.Components.Items.RCD var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager)); var tile = mapGrid.GetTileRef(eventArgs.ClickLocation); - var snapPos = mapGrid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center); + var snapPos = mapGrid.TileIndicesFor(eventArgs.ClickLocation); //Using an RCD isn't instantaneous var cancelToken = new CancellationTokenSource(); diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs index 1531dd4d57..7f7f0310b4 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/AMENodeGroup.cs @@ -8,6 +8,7 @@ using Content.Server.GameObjects.Components.Power.AME; using Robust.Shared.GameObjects; using Robust.Shared.Random; using Robust.Shared.IoC; +using Robust.Shared.Map; using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups @@ -68,12 +69,13 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups //Check each shield node to see if it meets core criteria foreach (Node node in Nodes) { - if (!node.Owner.TryGetComponent(out var shield)) { continue; } - var nodeNeighbors = node.Owner - .GetComponent() - .GetCellsInSquareArea() - .Select(sgc => sgc.Owner) - .Where(entity => entity != node.Owner) + var nodeOwner = node.Owner; + if (!nodeOwner.TryGetComponent(out var shield)) { continue; } + + var grid = IoCManager.Resolve().GetGrid(nodeOwner.Transform.GridID); + var nodeNeighbors = grid.GetCellsInSquareArea(nodeOwner.Transform.Coordinates, 1) + .Select(sgc => nodeOwner.EntityManager.GetEntity(sgc)) + .Where(entity => entity != nodeOwner) .Select(entity => entity.TryGetComponent(out var adjshield) ? adjshield : null) .Where(adjshield => adjshield != null); diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs index 33d367bb03..fc17a1c6c9 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs @@ -1,6 +1,7 @@ #nullable enable using System.Collections.Generic; -using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.GameObjects.Components.NodeContainer.Nodes @@ -13,22 +14,27 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes { protected override IEnumerable GetReachableNodes() { - if (!Owner.TryGetComponent(out SnapGridComponent? snap)) + if (!Owner.Transform.Anchored) yield break; - foreach (var cell in snap.GetCardinalNeighborCells()) - foreach (var entity in cell.GetLocal()) + var grid = IoCManager.Resolve().GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + foreach (var cell in grid.GetCardinalNeighborCells(coords)) { - if (!entity.TryGetComponent(out var container)) continue; - - foreach (var node in container.Nodes.Values) + foreach (var entity in grid.GetLocal(Owner.EntityManager.GetEntity(cell).Transform.Coordinates)) { - if (node != null && node != this) - { - yield return node; - } - } + if (!Owner.EntityManager.GetEntity(entity).TryGetComponent(out var container)) + continue; + foreach (var node in container.Nodes.Values) + { + if (node != null && node != this) + { + yield return node; + } + } + + } } } } diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs index 985d110d74..0218a1b02d 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs @@ -6,6 +6,8 @@ using Content.Server.Interfaces; using Content.Shared.GameObjects.Components.Atmos; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; @@ -169,14 +171,14 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes /// private IEnumerable PipesInDirection(PipeDirection pipeDir) { - if (!Owner.TryGetComponent(out SnapGridComponent? grid)) + if (!Owner.Transform.Anchored) yield break; - var entities = grid.GetInDir(pipeDir.ToDirection()); - - foreach (var entity in entities) + var grid = IoCManager.Resolve().GetGrid(Owner.Transform.GridID); + var position = Owner.Transform.Coordinates; + foreach (var entity in grid.GetInDir(position, pipeDir.ToDirection())) { - if (!entity.TryGetComponent(out var container)) + if (!Owner.EntityManager.ComponentManager.TryGetComponent(entity, out var container)) continue; foreach (var node in container.Nodes.Values) diff --git a/Content.Server/GameObjects/Components/PA/ParticleAcceleratorControlBoxComponent.cs b/Content.Server/GameObjects/Components/PA/ParticleAcceleratorControlBoxComponent.cs index 30c336f3f5..d0195877a8 100644 --- a/Content.Server/GameObjects/Components/PA/ParticleAcceleratorControlBoxComponent.cs +++ b/Content.Server/GameObjects/Components/PA/ParticleAcceleratorControlBoxComponent.cs @@ -13,8 +13,10 @@ using Content.Shared.GameObjects.EntitySystems.ActionBlocker; using Content.Shared.Interfaces.GameObjects.Components; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Log; +using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; @@ -36,6 +38,8 @@ namespace Content.Server.GameObjects.Components.PA [RegisterComponent] public class ParticleAcceleratorControlBoxComponent : ParticleAcceleratorPartComponent, IActivate, IWires { + [Dependency] private readonly IMapManager _mapManager = default!; + public override string Name => "ParticleAcceleratorControlBox"; [ViewVariables] @@ -378,11 +382,13 @@ namespace Content.Server.GameObjects.Components.PA _partEmitterRight = null; // Find fuel chamber first by scanning cardinals. - if (SnapGrid != null) + if (Owner.Transform.Anchored) { - foreach (var maybeFuel in SnapGrid.GetCardinalNeighborCells()) + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + foreach (var maybeFuel in grid.GetCardinalNeighborCells(coords)) { - if (maybeFuel.Owner.TryGetComponent(out _partFuelChamber)) + if (Owner.EntityManager.ComponentManager.TryGetComponent(maybeFuel, out _partFuelChamber)) { break; } @@ -452,9 +458,11 @@ namespace Content.Server.GameObjects.Components.PA private bool ScanPart(Vector2i offset, [NotNullWhen(true)] out T? part) where T : ParticleAcceleratorPartComponent { - foreach (var ent in SnapGrid!.GetOffset(offset)) + var grid = _mapManager.GetGrid(Owner.Transform.GridID); + var coords = Owner.Transform.Coordinates; + foreach (var ent in grid.GetOffset(coords, offset)) { - if (ent.TryGetComponent(out part) && !part.Deleted) + if (Owner.EntityManager.ComponentManager.TryGetComponent(ent, out part) && !part.Deleted) { return true; } diff --git a/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs b/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs index b74b9de74b..de6c9f56c8 100644 --- a/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs +++ b/Content.Server/GameObjects/Components/PA/ParticleAcceleratorPartComponent.cs @@ -1,6 +1,5 @@ #nullable enable using Robust.Shared.GameObjects; -using Robust.Shared.Log; using Robust.Shared.ViewVariables; namespace Content.Server.GameObjects.Components.PA @@ -8,14 +7,13 @@ namespace Content.Server.GameObjects.Components.PA public abstract class ParticleAcceleratorPartComponent : Component { [ViewVariables] public ParticleAcceleratorControlBoxComponent? Master; - [ViewVariables] protected SnapGridComponent? SnapGrid; public override void Initialize() { base.Initialize(); // FIXME: this has to be an entity system, full stop. - Owner.EnsureComponent(out SnapGrid); + Owner.Transform.Anchored = true; } public override void HandleMessage(ComponentMessage message, IComponent? component) diff --git a/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs b/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs index 8cab4a77d1..e240171357 100644 --- a/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs +++ b/Content.Server/GameObjects/Components/Power/AME/AMEPartComponent.cs @@ -40,8 +40,8 @@ namespace Content.Server.GameObjects.Components.Power.AME if (!_mapManager.TryGetGrid(args.ClickLocation.GetGridId(_serverEntityManager), out var mapGrid)) return false; // No AME in space. - var snapPos = mapGrid.SnapGridCellFor(args.ClickLocation, SnapGridOffset.Center); - if (mapGrid.GetSnapGridCell(snapPos, SnapGridOffset.Center).Any(sc => sc.Owner.HasComponent())) + var snapPos = mapGrid.TileIndicesFor(args.ClickLocation); + if (mapGrid.GetAnchoredEntities(snapPos).Any(sc => _serverEntityManager.ComponentManager.HasComponent(sc))) { Owner.PopupMessage(args.User, Loc.GetString("Shielding is already there!")); return true; diff --git a/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs b/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs index 33678d16f1..bfb72c9f66 100644 --- a/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs +++ b/Content.Server/GameObjects/Components/Power/WirePlacerComponent.cs @@ -1,4 +1,5 @@ #nullable enable +using System.Collections.Generic; using Content.Server.GameObjects.Components.Stack; using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Utility; @@ -38,13 +39,12 @@ namespace Content.Server.GameObjects.Components.Power return true; if(!_mapManager.TryGetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager), out var grid)) return true; - var snapPos = grid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center); - var snapCell = grid.GetSnapGridCell(snapPos, SnapGridOffset.Center); + var snapPos = grid.TileIndicesFor(eventArgs.ClickLocation); if(grid.GetTileRef(snapPos).Tile.IsEmpty) return true; - foreach (var snapComp in snapCell) + foreach (var anchored in grid.GetAnchoredEntities(snapPos)) { - if (snapComp.Owner.TryGetComponent(out var wire) && wire.WireType == _blockingWireType) + if (Owner.EntityManager.ComponentManager.TryGetComponent(anchored, out var wire) && wire.WireType == _blockingWireType) { return true; } diff --git a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs index b6f88e7436..b9ed00390f 100644 --- a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs @@ -62,7 +62,8 @@ namespace Content.Server.GameObjects.EntitySystems } // Required for airtight components. - EntityManager.EventBus.SubscribeEvent(EventSource.Local, this, RotateEvent); + SubscribeLocalEvent(RotateEvent); + SubscribeLocalEvent(HandleSnapGridMove); _cfg.OnValueChanged(CCVars.SpaceWind, OnSpaceWindChanged, true); _cfg.OnValueChanged(CCVars.MonstermosEqualization, OnMonstermosEqualizationChanged, true); @@ -72,6 +73,11 @@ namespace Content.Server.GameObjects.EntitySystems _cfg.OnValueChanged(CCVars.ExcitedGroupsSpaceIsAllConsuming, OnExcitedGroupsSpaceIsAllConsumingChanged, true); } + private static void HandleSnapGridMove(EntityUid uid, AirtightComponent component, SnapGridPositionChangedEvent args) + { + component.OnTransformMove(); + } + public bool SpaceWind { get; private set; } public bool MonstermosEqualization { get; private set; } public bool Superconduction { get; private set; } @@ -115,7 +121,8 @@ namespace Content.Server.GameObjects.EntitySystems _mapManager.MapCreated -= OnMapCreated; - EntityManager.EventBus.UnsubscribeEvent(EventSource.Local, this); + UnsubscribeLocalEvent(); + UnsubscribeLocalEvent(HandleSnapGridMove); } private void RotateEvent(RotateEvent ev) diff --git a/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs b/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs index 30d3b99d11..0718c5cfca 100644 --- a/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs @@ -3,34 +3,41 @@ using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Map; +using Robust.Shared.Maths; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] internal sealed class PuddleSystem : EntitySystem { + [Dependency] private readonly IMapManager _mapManager = default!; + public override void Initialize() { base.Initialize(); - var mapManager = IoCManager.Resolve(); - mapManager.TileChanged += HandleTileChanged; + _mapManager.TileChanged += HandleTileChanged; } public override void Shutdown() { base.Shutdown(); - var mapManager = IoCManager.Resolve(); - mapManager.TileChanged -= HandleTileChanged; + _mapManager.TileChanged -= HandleTileChanged; } + //TODO: Replace all this with an Unanchored event that deletes the puddle private void HandleTileChanged(object? sender, TileChangedEventArgs eventArgs) { // If this gets hammered you could probably queue up all the tile changes every tick but I doubt that would ever happen. - foreach (var (puddle, snapGrid) in ComponentManager.EntityQuery(true)) + foreach (var puddle in ComponentManager.EntityQuery(true)) { // If the tile becomes space then delete it (potentially change by design) + var puddleTransform = puddle.Owner.Transform; + if(!puddleTransform.Anchored) + continue; + + var grid = _mapManager.GetGrid(puddleTransform.GridID); if (eventArgs.NewTile.GridIndex == puddle.Owner.Transform.GridID && - snapGrid.Position == eventArgs.NewTile.GridIndices && + grid.TileIndicesFor(puddleTransform.Coordinates) == eventArgs.NewTile.GridIndices && eventArgs.NewTile.Tile.IsEmpty) { puddle.Owner.Delete(); diff --git a/Content.Server/GameObjects/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/GameObjects/EntitySystems/SpawnAfterInteractSystem.cs index 07821913a4..3404224cb9 100644 --- a/Content.Server/GameObjects/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/SpawnAfterInteractSystem.cs @@ -4,7 +4,6 @@ using Content.Server.GameObjects.Components.Stack; using Content.Server.GameObjects.EntitySystems.DoAfter; using Content.Server.Utility; using Content.Shared.Interfaces.GameObjects.Components; -using Content.Shared.Maps; using Content.Shared.Utility; using JetBrains.Annotations; using Robust.Shared.GameObjects; @@ -70,12 +69,10 @@ namespace Content.Server.GameObjects.EntitySystems if (component.RemoveOnInteract && component.Owner.TryGetComponent(out stack) && !stack.Use(1)) return; - EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid, SnapGridOffset.Center)); + EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid)); if (component.RemoveOnInteract && stack == null && !component.Owner.Deleted) component.Owner.Delete(); - - return; } } } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index d2d3063bfe..6fe91adcf7 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -156,9 +156,9 @@ namespace Content.Server.Physics.Controllers // If the coordinates have a FootstepModifier component // i.e. component that emit sound on footsteps emit that sound string? soundCollectionName = null; - foreach (var maybeFootstep in grid.GetSnapGridCell(tile.GridIndices, SnapGridOffset.Center)) + foreach (var maybeFootstep in grid.GetAnchoredEntities(tile.GridIndices)) { - if (maybeFootstep.Owner.TryGetComponent(out FootstepModifierComponent? footstep)) + if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep)) { soundCollectionName = footstep._soundCollectionName; break; diff --git a/Content.Server/Utility/SnapgridHelper.cs b/Content.Server/Utility/SnapgridHelper.cs index 54655944f0..4c1f630ce1 100644 --- a/Content.Server/Utility/SnapgridHelper.cs +++ b/Content.Server/Utility/SnapgridHelper.cs @@ -7,13 +7,12 @@ namespace Content.Server.Utility { public static class SnapgridHelper { - public static void SnapToGrid(this IEntity entity, SnapGridOffset offset = SnapGridOffset.Center, IEntityManager? entityManager = null, IMapManager? mapManager = null) + public static void SnapToGrid(this IEntity entity, IEntityManager? entityManager = null, IMapManager? mapManager = null) { - entity.Transform.Coordinates = entity.Transform.Coordinates.SnapToGrid(offset, entityManager, mapManager); + entity.Transform.Coordinates = entity.Transform.Coordinates.SnapToGrid(entityManager, mapManager); } - public static EntityCoordinates SnapToGrid(this EntityCoordinates coordinates, - SnapGridOffset offset = SnapGridOffset.Center, IEntityManager? entityManager = null, IMapManager? mapManager = null) + public static EntityCoordinates SnapToGrid(this EntityCoordinates coordinates, IEntityManager? entityManager = null, IMapManager? mapManager = null) { entityManager ??= IoCManager.Resolve(); mapManager ??= IoCManager.Resolve(); @@ -30,21 +29,20 @@ namespace Content.Server.Utility var localPos = coordinates.Position; - var x = (int)Math.Floor(localPos.X / tileSize) + tileSize / (offset == SnapGridOffset.Center ? 2f : 0f); - var y = (int)Math.Floor(localPos.Y / tileSize) + tileSize / (offset == SnapGridOffset.Center ? 2f : 0f); + var x = (int)Math.Floor(localPos.X / tileSize) + tileSize / 2f; + var y = (int)Math.Floor(localPos.Y / tileSize) + tileSize / 2f; return new EntityCoordinates(coordinates.EntityId, x, y); } - public static EntityCoordinates SnapToGrid(this EntityCoordinates coordinates, IMapGrid grid, - SnapGridOffset offset = SnapGridOffset.Center) + public static EntityCoordinates SnapToGrid(this EntityCoordinates coordinates, IMapGrid grid) { var tileSize = grid.TileSize; var localPos = coordinates.Position; - var x = (int)Math.Floor(localPos.X / tileSize) + tileSize / (offset == SnapGridOffset.Center ? 2f : 0f); - var y = (int)Math.Floor(localPos.Y / tileSize) + tileSize / (offset == SnapGridOffset.Center ? 2f : 0f); + var x = (int)Math.Floor(localPos.X / tileSize) + tileSize / 2f; + var y = (int)Math.Floor(localPos.Y / tileSize) + tileSize / 2f; return new EntityCoordinates(coordinates.EntityId, x, y); } diff --git a/Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs b/Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs index 0f60fbb50e..be25aeea2e 100644 --- a/Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SubFloorHideSystem.cs @@ -36,12 +36,11 @@ namespace Content.Shared.GameObjects.EntitySystems private void UpdateAll() { - foreach (var comp in EntityManager.ComponentManager.EntityQuery(true)) + foreach (var comp in ComponentManager.EntityQuery(true)) { - if (!_mapManager.TryGetGrid(comp.Owner.Transform.GridID, out var grid)) return; - - var snapPos = comp.Owner.GetComponent(); - UpdateTile(grid, snapPos.Position); + var transform = comp.Owner.Transform; + if (!_mapManager.TryGetGrid(transform.GridID, out var grid)) return; + UpdateTile(grid, grid.TileIndicesFor(transform.Coordinates)); } } @@ -119,22 +118,21 @@ namespace Content.Shared.GameObjects.EntitySystems { var tile = grid.GetTileRef(position); var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; - foreach (var snapGridComponent in grid.GetSnapGridCell(position, SnapGridOffset.Center)) + foreach (var anchored in grid.GetAnchoredEntities(position)) { - var entity = snapGridComponent.Owner; - if (!entity.TryGetComponent(out SubFloorHideComponent? subFloorComponent)) + if (!ComponentManager.TryGetComponent(anchored, out SubFloorHideComponent? subFloorComponent)) { continue; } // Show sprite - if (entity.TryGetComponent(out SharedSpriteComponent? spriteComponent)) + if (ComponentManager.TryGetComponent(anchored, out SharedSpriteComponent ? spriteComponent)) { 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)) + if (ComponentManager.TryGetComponent(anchored, out PhysicsComponent ? physicsComponent)) { physicsComponent.CanCollide = !subFloorComponent.Running; } diff --git a/Resources/Prototypes/Entities/Constructible/Doors/airlock_base.yml b/Resources/Prototypes/Entities/Constructible/Doors/airlock_base.yml index ecc22bc20c..c5461290ce 100644 --- a/Resources/Prototypes/Entities/Constructible/Doors/airlock_base.yml +++ b/Resources/Prototypes/Entities/Constructible/Doors/airlock_base.yml @@ -104,7 +104,6 @@ - type: Anchorable - type: Pullable - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible diff --git a/Resources/Prototypes/Entities/Constructible/Ground/catwalk.yml b/Resources/Prototypes/Entities/Constructible/Ground/catwalk.yml index 91184af423..13dc19c8f4 100644 --- a/Resources/Prototypes/Entities/Constructible/Ground/catwalk.yml +++ b/Resources/Prototypes/Entities/Constructible/Ground/catwalk.yml @@ -22,7 +22,6 @@ sprite: Constructible/Tiles/catwalk.rsi state: catwalk_preview - type: SnapGrid - offset: Center - type: IconSmooth key: catwalk base: catwalk_ diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml b/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml index 67ca24b4e9..6071b39208 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml @@ -8,7 +8,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Sprite netsync: false sprite: Constructible/Atmos/gascanisterport.rsi diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gascanisters.yml b/Resources/Prototypes/Entities/Constructible/Piping/gascanisters.yml index e26a09a671..9cdb40b525 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gascanisters.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gascanisters.yml @@ -7,7 +7,6 @@ components: - type: InteractionOutline - type: SnapGrid - offset: Center - type: Sprite - type: Damageable resistances: metallicResistances diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml b/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml index 2dd1daf7fa..72169c0f62 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml @@ -8,7 +8,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml b/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml index a67bf0261f..866a2b1ce2 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml @@ -22,7 +22,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: GasGenerator - type: PipeNetDevice diff --git a/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml b/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml index ce0c261902..b54397ab50 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml @@ -9,7 +9,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Damageable - type: Destructible thresholds: diff --git a/Resources/Prototypes/Entities/Constructible/Piping/pipes.yml b/Resources/Prototypes/Entities/Constructible/Piping/pipes.yml index 28e6e79347..5a8f4900e3 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/pipes.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/pipes.yml @@ -10,7 +10,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Damageable - type: Destructible thresholds: diff --git a/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml b/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml index 034174141e..1e66dc6370 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml @@ -8,7 +8,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible diff --git a/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml b/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml index 23547d4a13..6d0f2810ab 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml @@ -8,7 +8,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible diff --git a/Resources/Prototypes/Entities/Constructible/Piping/vents.yml b/Resources/Prototypes/Entities/Constructible/Piping/vents.yml index 25b36842e5..f626eb112d 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/vents.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/vents.yml @@ -8,7 +8,6 @@ - type: InteractionOutline - type: Physics - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/controller.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/controller.yml index 545177280a..34a85b5ad2 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/controller.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/controller.yml @@ -41,7 +41,6 @@ - !type:DoActsBehavior acts: ["Destruction"] - type: SnapGrid - offset: Center - type: Anchorable - type: Pullable - type: AMEController diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/shielding.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/shielding.yml index e43b7dfae3..c0bcc8e5e4 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/shielding.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/AME/shielding.yml @@ -37,7 +37,6 @@ - !type:DoActsBehavior acts: ["Destruction"] - type: SnapGrid - offset: Center - type: IconSmooth mode: CardinalFlags base: shield_ diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/PA/base.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/PA/base.yml index 1fee8ae412..fa139ca653 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/PA/base.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/PA/base.yml @@ -19,6 +19,5 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Pullable - type: Clickable diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/collector.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/collector.yml index fac3c7d61b..c1f99b06d9 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/collector.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/collector.yml @@ -24,7 +24,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/Singularity/collector.rsi layers: diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/containment.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/containment.yml index 0db38430b9..4488cbb3bf 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/containment.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/containment.yml @@ -24,7 +24,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/Singularity/containment.rsi state: icon @@ -66,7 +65,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/Singularity/containment_field.rsi state: field diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/emitter.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/emitter.yml index c8634d7ed6..1067d20264 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/emitter.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/emitter.yml @@ -24,7 +24,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/Singularity/emitter.rsi layers: diff --git a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/generator.yml b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/generator.yml index 5e22b4820c..187cf53c9d 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/generator.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Engines/Singularity/generator.yml @@ -23,6 +23,5 @@ mask: - MobImpassable - type: SnapGrid - offset: Center - type: Anchorable - type: Pullable diff --git a/Resources/Prototypes/Entities/Constructible/Power/Generation/generator.yml b/Resources/Prototypes/Entities/Constructible/Power/Generation/generator.yml index 85f0922d25..45091750d8 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Generation/generator.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Generation/generator.yml @@ -26,7 +26,6 @@ - VaultImpassable - SmallImpassable - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/power.rsi state: generator diff --git a/Resources/Prototypes/Entities/Constructible/Power/Generation/solar.yml b/Resources/Prototypes/Entities/Constructible/Power/Generation/solar.yml index c37be3e41f..9f852d0c9a 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Generation/solar.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Generation/solar.yml @@ -35,7 +35,6 @@ - type: SolarPanel supply: 1500 - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible @@ -78,7 +77,6 @@ sprite: Constructible/Power/solar_panel.rsi state: solar_assembly - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible @@ -123,7 +121,6 @@ sprite: Constructible/Power/solar_panel.rsi state: solar_tracker - type: SnapGrid - offset: Center - type: Damageable resistances: metallicResistances - type: Destructible diff --git a/Resources/Prototypes/Entities/Constructible/Power/Specific/debug_power.yml b/Resources/Prototypes/Entities/Constructible/Power/Specific/debug_power.yml index 244baac4b0..963521c356 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/Specific/debug_power.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/Specific/debug_power.yml @@ -19,7 +19,6 @@ bounds: "-0.5, -0.5, 0.5, 0.5" layer: [MobMask, Opaque] - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/power.rsi state: wiredmachine @@ -58,7 +57,6 @@ bounds: "-0.5, -0.5, 0.5, 0.5" layer: [MobMask, Opaque] - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/power.rsi state: provider @@ -88,7 +86,6 @@ bounds: "-0.5, -0.5, 0.5, 0.5" layer: [MobMask, Opaque] - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/power.rsi state: provider @@ -133,7 +130,6 @@ bounds: "-0.5, -0.5, 0.5, 0.5" layer: [MobMask, Opaque] - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/power.rsi state: wirelessmachine diff --git a/Resources/Prototypes/Entities/Constructible/Power/lathe.yml b/Resources/Prototypes/Entities/Constructible/Power/lathe.yml index dece3752fe..853125eb61 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/lathe.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/lathe.yml @@ -22,7 +22,6 @@ - Opaque - MobImpassable - type: SnapGrid - offset: Center - type: Lathe - type: MaterialStorage - type: Anchorable diff --git a/Resources/Prototypes/Entities/Constructible/Power/parts.yml b/Resources/Prototypes/Entities/Constructible/Power/parts.yml index f77824bfc4..98f6969595 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/parts.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/parts.yml @@ -25,7 +25,6 @@ - VaultImpassable - SmallImpassable - type: SnapGrid - offset: Center - type: Sprite netsync: false sprite: Constructible/Power/smes.rsi @@ -85,7 +84,6 @@ - VaultImpassable - SmallImpassable - type: SnapGrid - offset: Center - type: Sprite sprite: Constructible/Power/substation.rsi layers: @@ -139,7 +137,6 @@ bounds: "-0.25, -0.25, 0.25, 0.3" layer: [ Passable ] - type: SnapGrid - offset: Center - type: Sprite drawdepth: WallMountedItems netsync: false diff --git a/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml b/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml index 262729b4e2..99bfc821e7 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/seed_extractor.yml @@ -23,7 +23,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Anchorable - type: SeedExtractor - type: PowerReceiver diff --git a/Resources/Prototypes/Entities/Constructible/Power/wires.yml b/Resources/Prototypes/Entities/Constructible/Power/wires.yml index 8452181b80..41d8c088cd 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/wires.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/wires.yml @@ -14,7 +14,6 @@ - Underplating - type: InteractionOutline - type: SnapGrid - offset: Center - type: Sprite drawdepth: BelowFloor - type: IconSmooth @@ -166,7 +165,6 @@ mode: SnapgridCenter components: - type: SnapGrid - offset: Center - type: Sprite drawdepth: BelowFloor - type: IconSmooth diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Conveyor/conveyor.yml b/Resources/Prototypes/Entities/Constructible/Specific/Conveyor/conveyor.yml index 16f3244d5a..3fe0e117cf 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Conveyor/conveyor.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Conveyor/conveyor.yml @@ -20,7 +20,6 @@ - VaultImpassable - SmallImpassable - type: SnapGrid - offset: Center - type: Sprite netsync: false sprite: Constructible/Power/conveyor.rsi diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Cooking/microwave.yml b/Resources/Prototypes/Entities/Constructible/Specific/Cooking/microwave.yml index 66d1630218..6a22095168 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Cooking/microwave.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Cooking/microwave.yml @@ -6,7 +6,6 @@ mode: SnapgridCenter components: - type: SnapGrid - offset: Center - type: Microwave - type: Clickable - type: InteractionOutline diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Cooking/reagent_grinder.yml b/Resources/Prototypes/Entities/Constructible/Specific/Cooking/reagent_grinder.yml index 6ddb1f1e19..5d8fa6511a 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Cooking/reagent_grinder.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Cooking/reagent_grinder.yml @@ -7,7 +7,6 @@ mode: SnapgridCenter components: - type: SnapGrid - offset: Center - type: ReagentGrinder - type: UserInterface interfaces: diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml b/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml index 4b49fe4325..a542c67926 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Dispensers/reagent_dispenser_base.yml @@ -24,7 +24,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: ReagentDispenser - type: PowerReceiver - type: UserInterface diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Medical/cloning_machine.yml b/Resources/Prototypes/Entities/Constructible/Specific/Medical/cloning_machine.yml index 7fe6868252..c96ac62bc2 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Medical/cloning_machine.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Medical/cloning_machine.yml @@ -28,7 +28,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: CloningPod - type: Damageable resistances: metallicResistances diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Medical/medical_scanner.yml b/Resources/Prototypes/Entities/Constructible/Specific/Medical/medical_scanner.yml index cab60850f8..7c7d477780 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Medical/medical_scanner.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Medical/medical_scanner.yml @@ -27,7 +27,6 @@ - Impassable - VaultImpassable - type: SnapGrid - offset: Center - type: Anchorable - type: Pullable - type: MedicalScanner diff --git a/Resources/Prototypes/Entities/Constructible/Specific/Medical/morgue.yml b/Resources/Prototypes/Entities/Constructible/Specific/Medical/morgue.yml index 941ac6d1a6..af4fa47dae 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/Medical/morgue.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/Medical/morgue.yml @@ -48,7 +48,6 @@ light_mob: morgue_nosoul_light light_soul: morgue_soul_light - type: SnapGrid - offset: Center - type: entity id: MorgueTray @@ -115,7 +114,6 @@ light_contents: crema_contents_light light_burning: crema_active_light - type: SnapGrid - offset: Center - type: entity id: CrematoriumTray diff --git a/Resources/Prototypes/Entities/Constructible/Specific/disposal.yml b/Resources/Prototypes/Entities/Constructible/Specific/disposal.yml index a0cf7818c3..87c97b4e92 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/disposal.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/disposal.yml @@ -11,7 +11,6 @@ - type: Physics bodyType: Static - type: SnapGrid - offset: Center - type: Anchorable - type: Damageable resistances: metallicResistances @@ -399,7 +398,6 @@ - VaultImpassable - SmallImpassable - type: SnapGrid - offset: Center - type: Anchorable - type: Damageable resistances: metallicResistances diff --git a/Resources/Prototypes/Entities/Constructible/Specific/gravity_generator.yml b/Resources/Prototypes/Entities/Constructible/Specific/gravity_generator.yml index f22aa08a90..4708e06aee 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/gravity_generator.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/gravity_generator.yml @@ -14,7 +14,6 @@ shader: unshaded map: ["enum.GravityGeneratorVisualLayers.Core"] - type: SnapGrid - offset: Center - type: PowerReceiver powerLoad: 500 - type: Physics diff --git a/Resources/Prototypes/Entities/Constructible/Specific/hydroponics.yml b/Resources/Prototypes/Entities/Constructible/Specific/hydroponics.yml index e6fa7387bc..906b1bfe06 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/hydroponics.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/hydroponics.yml @@ -44,7 +44,6 @@ maxVol: 200 caps: Refillable - type: SnapGrid - offset: Center - type: Reactive reactions: - !type:AddToSolutionReaction diff --git a/Resources/Prototypes/Entities/Constructible/Specific/recycler.yml b/Resources/Prototypes/Entities/Constructible/Specific/recycler.yml index 83ce876c87..419981a1d1 100644 --- a/Resources/Prototypes/Entities/Constructible/Specific/recycler.yml +++ b/Resources/Prototypes/Entities/Constructible/Specific/recycler.yml @@ -19,7 +19,6 @@ - MobImpassable - VaultImpassable - type: SnapGrid - offset: Center - type: Sprite netsync: false sprite: Constructible/Power/recycling.rsi diff --git a/Resources/Prototypes/Entities/Constructible/base.yml b/Resources/Prototypes/Entities/Constructible/base.yml index d97ca3971b..854f535d34 100644 --- a/Resources/Prototypes/Entities/Constructible/base.yml +++ b/Resources/Prototypes/Entities/Constructible/base.yml @@ -5,7 +5,6 @@ mode: SnapgridCenter components: - type: SnapGrid - offset: Center - type: Clickable - type: Physics bodyType: Static diff --git a/Resources/Prototypes/Entities/Effects/chemistry_effects.yml b/Resources/Prototypes/Entities/Effects/chemistry_effects.yml index 71f75f2ad1..0776e99ed8 100644 --- a/Resources/Prototypes/Entities/Effects/chemistry_effects.yml +++ b/Resources/Prototypes/Entities/Effects/chemistry_effects.yml @@ -12,7 +12,6 @@ - type: SmokeVisualizer - type: Occluder - type: SnapGrid - offset: Center - type: SmokeSolutionAreaEffect - type: SolutionContainer maxVol: 600 @@ -38,7 +37,6 @@ animationTime: 0.6 animationState: foam-dissolve - type: SnapGrid - offset: Center - type: Physics fixtures: - shape: @@ -118,7 +116,6 @@ sizeX: 32 sizeY: 32 - type: SnapGrid - offset: Center - type: Airtight - type: Damageable resistances: metallicResistances diff --git a/Resources/Prototypes/Entities/Effects/puddle.yml b/Resources/Prototypes/Entities/Effects/puddle.yml index a161cd7aae..007a55daff 100644 --- a/Resources/Prototypes/Entities/Effects/puddle.yml +++ b/Resources/Prototypes/Entities/Effects/puddle.yml @@ -4,7 +4,6 @@ abstract: true components: - type: SnapGrid - offset: Center - type: Sprite drawdepth: FloorObjects - type: SolutionContainer diff --git a/Resources/Prototypes/Entities/Objects/Misc/bedsheets.yml b/Resources/Prototypes/Entities/Objects/Misc/bedsheets.yml index c00aa0dfa7..0902861684 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/bedsheets.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/bedsheets.yml @@ -17,7 +17,6 @@ Slots: - neck - type: SnapGrid - offset: Center - type: entity id: BedsheetBlack diff --git a/Resources/Prototypes/Entities/Objects/Misc/inflatable_wall.yml b/Resources/Prototypes/Entities/Objects/Misc/inflatable_wall.yml index bb25fbabd0..24d9ca9ab3 100644 --- a/Resources/Prototypes/Entities/Objects/Misc/inflatable_wall.yml +++ b/Resources/Prototypes/Entities/Objects/Misc/inflatable_wall.yml @@ -35,6 +35,5 @@ doAfter: 3 - type: Airtight - type: SnapGrid - offset: Center placement: mode: SnapgridCenter diff --git a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml index 5241d2d310..2226d60bbd 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Janitorial/spray.yml @@ -58,7 +58,6 @@ abstract: true components: - type: SnapGrid - offset: Center - type: SolutionContainer maxVol: 50 - type: Vapor diff --git a/RobustToolbox b/RobustToolbox index 197227dcf6..122acc5fd5 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 197227dcf64f374829a1a4c241fa6fdc0306a9b4 +Subproject commit 122acc5fd5cf30292ed1bc855f92b9c70430b9c7