SnapGridComponent Removal (#3884)
* Removed SnapGridOffset, there is only center now. * SnapGridComponent methods are now static. * Removed SnapGridComponent.OnPositionChanged. * Refactored static functions off SnapGridComponent to MapGrid. Refactored away usages of SnapGridComponent.Position. * Added Transform.Anchored for checking if an entity is a tile entity. More refactoring for static MapGrid functions. * Static snapgrid methods on MapGrid are no longer static. * Add setter to ITransformComponent.Anchored. Removed direct references to SnapGridComponent from content. * Grid functions now deal with EntityUids instead of SnapGridComponents. Began renaming public API functions from SnapGrid to Anchor. * Remove the SnapGridComponent 'Offset' field from all yaml files. This was removed in code previously, so the yaml linter was upset. * Update engine submodule to v0.4.46.
This commit is contained in:
@@ -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<IEntity> candidates)
|
||||
private (bool connected, bool lowWall) MatchingWall(IEnumerable<EntityUid> candidates)
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!entity.TryGetComponent(out IconSmoothComponent? other))
|
||||
if (!Owner.EntityManager.ComponentManager.TryGetComponent(entity, out IconSmoothComponent? other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user