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,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;
|
||||
|
||||
/// <summary>
|
||||
@@ -62,7 +64,6 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SnapGrid = Owner.GetComponent<SnapGridComponent>();
|
||||
Sprite = Owner.GetComponent<ISpriteComponent>();
|
||||
}
|
||||
|
||||
@@ -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<IEntity> candidates)
|
||||
protected bool MatchingEntity(IEnumerable<EntityUid> candidates)
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!entity.TryGetComponent(out IconSmoothComponent? other))
|
||||
if (!Owner.EntityManager.ComponentManager.TryGetComponent(entity, out IconSmoothComponent? other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<ISpriteComponent>();
|
||||
_snapGrid = Owner.GetComponent<SnapGridComponent>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<ISpriteComponent>();
|
||||
if (!component.Owner.TryGetComponent(out SnapGridComponent? snapGrid))
|
||||
if (!component.Owner.Transform.Anchored)
|
||||
return;
|
||||
|
||||
var lowWall = FindLowWall(snapGrid);
|
||||
var lowWall = FindLowWall(IoCManager.Resolve<IMapManager>(), 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;
|
||||
}
|
||||
|
||||
@@ -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<IEntity> _dirtyEntities = new();
|
||||
private readonly Queue<EntityUid> _dirtyEntities = new();
|
||||
|
||||
private int _generation;
|
||||
|
||||
@@ -27,13 +28,18 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<IconSmoothDirtyEvent>(HandleDirtyEvent);
|
||||
|
||||
SubscribeLocalEvent<IconSmoothComponent, SnapGridPositionChangedEvent>(HandleSnapGridMove);
|
||||
}
|
||||
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
|
||||
UnsubscribeLocalEvent<IconSmoothDirtyEvent>();
|
||||
|
||||
UnsubscribeLocalEvent<IconSmoothComponent, SnapGridPositionChangedEvent>(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<SnapGridComponent>();
|
||||
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<IEntity> candidates)
|
||||
private static void HandleSnapGridMove(EntityUid uid, IconSmoothComponent component, SnapGridPositionChangedEvent args)
|
||||
{
|
||||
component.SnapGridOnPositionChanged();
|
||||
}
|
||||
|
||||
private void AddValidEntities(IEnumerable<EntityUid> candidates)
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (entity.HasComponent<IconSmoothComponent>())
|
||||
if (ComponentManager.HasComponent<IconSmoothComponent>(entity))
|
||||
{
|
||||
_dirtyEntities.Enqueue(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddValidEntities(IEnumerable<IComponent> 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
|
||||
/// </summary>
|
||||
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; }
|
||||
}
|
||||
|
||||
@@ -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<WindowSmoothDirtyEvent>(HandleDirtyEvent);
|
||||
SubscribeLocalEvent<WindowComponent, SnapGridPositionChangedEvent>(HandleSnapGridMove);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -22,6 +23,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
base.Shutdown();
|
||||
|
||||
UnsubscribeLocalEvent<WindowSmoothDirtyEvent>();
|
||||
UnsubscribeLocalEvent<WindowComponent, SnapGridPositionChangedEvent>(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);
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Content.Server.Commands.GameTicking
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!childEntity.TryGetComponent(out SnapGridComponent? snapGrid))
|
||||
if (!childEntity.Transform.Anchored)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<AtmosphereSystem>();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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)
|
||||
|
||||
@@ -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<SnapGridComponent>(out var snapGrid)) return;
|
||||
var port = snapGrid.GetLocal()
|
||||
.Select(entity => entity.TryGetComponent<GasCanisterPortComponent>(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<GasCanisterPortComponent>(entity, out var port) ? port : null)
|
||||
.Where(port => port != null)
|
||||
.Where(port => !port!.ConnectedToCanister)
|
||||
.FirstOrDefault();
|
||||
|
||||
@@ -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<PipeNetDeviceComponent>();
|
||||
SetGasPort();
|
||||
if (Owner.TryGetComponent<SnapGridComponent>(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<GasCanisterComponent>(out var canister) && canister.Anchored && !canister.ConnectedToPort)
|
||||
if (Owner.EntityManager.ComponentManager.TryGetComponent<GasCanisterComponent>(entity, out var canister) && canister.Anchored && !canister.ConnectedToPort)
|
||||
{
|
||||
canister.TryConnectToPort();
|
||||
break;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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<SnapGridComponent>();
|
||||
var entry = snapGrid
|
||||
.GetLocal()
|
||||
.FirstOrDefault(entity => entity.HasComponent<DisposalEntryComponent>());
|
||||
var grid = _mapManager.GetGrid(Owner.Transform.GridID);
|
||||
var coords = Owner.Transform.Coordinates;
|
||||
var entry = grid.GetLocal(coords)
|
||||
.FirstOrDefault(entity => Owner.EntityManager.ComponentManager.HasComponent<DisposalEntryComponent>(entity));
|
||||
|
||||
if (entry == null)
|
||||
if (entry == default)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var entryComponent = entry.GetComponent<DisposalEntryComponent>();
|
||||
var entryComponent = Owner.EntityManager.ComponentManager.GetComponent<DisposalEntryComponent>(entry);
|
||||
var entities = _container.ContainedEntities.ToList();
|
||||
foreach (var entity in _container.ContainedEntities.ToList())
|
||||
{
|
||||
|
||||
@@ -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<SnapGridComponent>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<SnapGridComponent>();
|
||||
var entry = snapGrid
|
||||
.GetLocal()
|
||||
.FirstOrDefault(entity => entity.HasComponent<DisposalEntryComponent>());
|
||||
var grid = _mapManager.GetGrid(Owner.Transform.GridID);
|
||||
var coords = Owner.Transform.Coordinates;
|
||||
var entry = grid.GetLocal(coords)
|
||||
.FirstOrDefault(entity => Owner.EntityManager.ComponentManager.HasComponent<DisposalEntryComponent>(entity));
|
||||
|
||||
if (entry == null)
|
||||
if (entry == default)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var entryComponent = entry.GetComponent<DisposalEntryComponent>();
|
||||
var entryComponent = Owner.EntityManager.ComponentManager.GetComponent<DisposalEntryComponent>(entry);
|
||||
|
||||
if (Owner.Transform.Coordinates.TryGetTileAtmosphere(out var tileAtmos) &&
|
||||
tileAtmos.Air != null &&
|
||||
|
||||
@@ -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<SolutionContainerComponent>();
|
||||
_snapGrid = Owner.EnsureComponent<SnapGridComponent>();
|
||||
|
||||
// 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<PuddleComponent>();
|
||||
puddle = () => Owner.EntityManager.SpawnEntity(Owner.Prototype?.ID, mapGrid.DirectionToGrid(coords, direction)).GetComponent<PuddleComponent>();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<AMEShieldComponent>(out var shield)) { continue; }
|
||||
var nodeNeighbors = node.Owner
|
||||
.GetComponent<SnapGridComponent>()
|
||||
.GetCellsInSquareArea()
|
||||
.Select(sgc => sgc.Owner)
|
||||
.Where(entity => entity != node.Owner)
|
||||
var nodeOwner = node.Owner;
|
||||
if (!nodeOwner.TryGetComponent<AMEShieldComponent>(out var shield)) { continue; }
|
||||
|
||||
var grid = IoCManager.Resolve<IMapManager>().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<AMEShieldComponent>(out var adjshield) ? adjshield : null)
|
||||
.Where(adjshield => adjshield != null);
|
||||
|
||||
|
||||
@@ -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,13 +14,17 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
{
|
||||
protected override IEnumerable<Node> 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<IMapManager>().GetGrid(Owner.Transform.GridID);
|
||||
var coords = Owner.Transform.Coordinates;
|
||||
foreach (var cell in grid.GetCardinalNeighborCells(coords))
|
||||
{
|
||||
if (!entity.TryGetComponent<NodeContainerComponent>(out var container)) continue;
|
||||
foreach (var entity in grid.GetLocal(Owner.EntityManager.GetEntity(cell).Transform.Coordinates))
|
||||
{
|
||||
if (!Owner.EntityManager.GetEntity(entity).TryGetComponent<NodeContainerComponent>(out var container))
|
||||
continue;
|
||||
|
||||
foreach (var node in container.Nodes.Values)
|
||||
{
|
||||
@@ -33,3 +38,4 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
private IEnumerable<PipeNode> 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<IMapManager>().GetGrid(Owner.Transform.GridID);
|
||||
var position = Owner.Transform.Coordinates;
|
||||
foreach (var entity in grid.GetInDir(position, pipeDir.ToDirection()))
|
||||
{
|
||||
if (!entity.TryGetComponent<NodeContainerComponent>(out var container))
|
||||
if (!Owner.EntityManager.ComponentManager.TryGetComponent<NodeContainerComponent>(entity, out var container))
|
||||
continue;
|
||||
|
||||
foreach (var node in container.Nodes.Values)
|
||||
|
||||
@@ -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<T>(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;
|
||||
}
|
||||
|
||||
@@ -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<SnapGridComponent>(out SnapGrid);
|
||||
Owner.Transform.Anchored = true;
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
|
||||
@@ -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<AMEShieldComponent>()))
|
||||
var snapPos = mapGrid.TileIndicesFor(args.ClickLocation);
|
||||
if (mapGrid.GetAnchoredEntities(snapPos).Any(sc => _serverEntityManager.ComponentManager.HasComponent<AMEShieldComponent>(sc)))
|
||||
{
|
||||
Owner.PopupMessage(args.User, Loc.GetString("Shielding is already there!"));
|
||||
return true;
|
||||
|
||||
@@ -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<WireComponent>(out var wire) && wire.WireType == _blockingWireType)
|
||||
if (Owner.EntityManager.ComponentManager.TryGetComponent<WireComponent>(anchored, out var wire) && wire.WireType == _blockingWireType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
|
||||
// Required for airtight components.
|
||||
EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
|
||||
SubscribeLocalEvent<RotateEvent>(RotateEvent);
|
||||
SubscribeLocalEvent<AirtightComponent, SnapGridPositionChangedEvent>(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<RotateEvent>(EventSource.Local, this);
|
||||
UnsubscribeLocalEvent<RotateEvent>();
|
||||
UnsubscribeLocalEvent<AirtightComponent, SnapGridPositionChangedEvent>(HandleSnapGridMove);
|
||||
}
|
||||
|
||||
private void RotateEvent(RotateEvent ev)
|
||||
|
||||
@@ -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<IMapManager>();
|
||||
mapManager.TileChanged += HandleTileChanged;
|
||||
_mapManager.TileChanged += HandleTileChanged;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
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<PuddleComponent, SnapGridComponent>(true))
|
||||
foreach (var puddle in ComponentManager.EntityQuery<PuddleComponent>(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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<IEntityManager>();
|
||||
mapManager ??= IoCManager.Resolve<IMapManager>();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -36,12 +36,11 @@ namespace Content.Shared.GameObjects.EntitySystems
|
||||
|
||||
private void UpdateAll()
|
||||
{
|
||||
foreach (var comp in EntityManager.ComponentManager.EntityQuery<SubFloorHideComponent>(true))
|
||||
foreach (var comp in ComponentManager.EntityQuery<SubFloorHideComponent>(true))
|
||||
{
|
||||
if (!_mapManager.TryGetGrid(comp.Owner.Transform.GridID, out var grid)) return;
|
||||
|
||||
var snapPos = comp.Owner.GetComponent<SnapGridComponent>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,6 @@
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
- type: Destructible
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
sprite: Constructible/Tiles/catwalk.rsi
|
||||
state: catwalk_preview
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: IconSmooth
|
||||
key: catwalk
|
||||
base: catwalk_
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Constructible/Atmos/gascanisterport.rsi
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
components:
|
||||
- type: InteractionOutline
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
- type: Destructible
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: GasGenerator
|
||||
- type: PipeNetDevice
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
- type: Destructible
|
||||
thresholds:
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
- type: Destructible
|
||||
thresholds:
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
- type: Destructible
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
- type: Destructible
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
- type: InteractionOutline
|
||||
- type: Physics
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
- type: Destructible
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
- !type:DoActsBehavior
|
||||
acts: ["Destruction"]
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: AMEController
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
- !type:DoActsBehavior
|
||||
acts: ["Destruction"]
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: IconSmooth
|
||||
mode: CardinalFlags
|
||||
base: shield_
|
||||
|
||||
@@ -19,6 +19,5 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Pullable
|
||||
- type: Clickable
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
sprite: Constructible/Power/Singularity/collector.rsi
|
||||
layers:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
sprite: Constructible/Power/Singularity/emitter.rsi
|
||||
layers:
|
||||
|
||||
@@ -23,6 +23,5 @@
|
||||
mask:
|
||||
- MobImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
- VaultImpassable
|
||||
- SmallImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
sprite: Constructible/Power/power.rsi
|
||||
state: generator
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
- Opaque
|
||||
- MobImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Lathe
|
||||
- type: MaterialStorage
|
||||
- type: Anchorable
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Anchorable
|
||||
- type: SeedExtractor
|
||||
- type: PowerReceiver
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
- VaultImpassable
|
||||
- SmallImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Constructible/Power/conveyor.rsi
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
mode: SnapgridCenter
|
||||
components:
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Microwave
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
mode: SnapgridCenter
|
||||
components:
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: ReagentGrinder
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: ReagentDispenser
|
||||
- type: PowerReceiver
|
||||
- type: UserInterface
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: CloningPod
|
||||
- type: Damageable
|
||||
resistances: metallicResistances
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
- Impassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: MedicalScanner
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
shader: unshaded
|
||||
map: ["enum.GravityGeneratorVisualLayers.Core"]
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: PowerReceiver
|
||||
powerLoad: 500
|
||||
- type: Physics
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
maxVol: 200
|
||||
caps: Refillable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Reactive
|
||||
reactions:
|
||||
- !type:AddToSolutionReaction
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
- MobImpassable
|
||||
- VaultImpassable
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Constructible/Power/recycling.rsi
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
mode: SnapgridCenter
|
||||
components:
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Clickable
|
||||
- type: Physics
|
||||
bodyType: Static
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
abstract: true
|
||||
components:
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: Sprite
|
||||
drawdepth: FloorObjects
|
||||
- type: SolutionContainer
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
Slots:
|
||||
- neck
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
|
||||
- type: entity
|
||||
id: BedsheetBlack
|
||||
|
||||
@@ -35,6 +35,5 @@
|
||||
doAfter: 3
|
||||
- type: Airtight
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
placement:
|
||||
mode: SnapgridCenter
|
||||
|
||||
@@ -58,7 +58,6 @@
|
||||
abstract: true
|
||||
components:
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
- type: SolutionContainer
|
||||
maxVol: 50
|
||||
- type: Vapor
|
||||
|
||||
Submodule RobustToolbox updated: 197227dcf6...122acc5fd5
Reference in New Issue
Block a user