Revert "Update submodule (again)" (#7730)

This commit is contained in:
metalgearsloth
2022-04-24 02:26:00 +10:00
committed by GitHub
parent 7feea724fd
commit ecaad9c349
36 changed files with 151 additions and 292 deletions

View File

@@ -24,7 +24,7 @@ namespace Content.Client.IconSmoothing
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<IconSmoothComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<IconSmoothComponent, AnchorStateChangedEvent>(HandleAnchorChanged);
} }
public override void FrameUpdate(float frameTime) public override void FrameUpdate(float frameTime)
@@ -87,7 +87,7 @@ namespace Content.Client.IconSmoothing
} }
} }
private void OnAnchorChanged(EntityUid uid, IconSmoothComponent component, ref AnchorStateChangedEvent args) private void HandleAnchorChanged(EntityUid uid, IconSmoothComponent component, ref AnchorStateChangedEvent args)
{ {
UpdateSmoothing(uid, component); UpdateSmoothing(uid, component);
} }

View File

@@ -9,7 +9,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -250,8 +249,10 @@ namespace Content.IntegrationTests.Tests
var tileDefinition = tileDefinitionManager["underplating"]; var tileDefinition = tileDefinitionManager["underplating"];
var tile = new Tile(tileDefinition.TileId); var tile = new Tile(tileDefinition.TileId);
var coordinates = grid.ToCoordinates();
grid.SetTile(coordinates, tile);
grid.SetTile(Vector2i.Zero, tile);
mapManager.DoMapInitialize(mapId); mapManager.DoMapInitialize(mapId);
}); });

View File

@@ -18,6 +18,8 @@ namespace Content.IntegrationTests.Tests.Fluids;
[TestOf(typeof(FluidSpreaderSystem))] [TestOf(typeof(FluidSpreaderSystem))]
public sealed class FluidSpill : ContentIntegrationTest public sealed class FluidSpill : ContentIntegrationTest
{ {
private const string SpillMapsYml = "Maps/Test/floor3x3.yml";
private static PuddleComponent? GetPuddle(IEntityManager entityManager, IMapGrid mapGrid, Vector2i pos) private static PuddleComponent? GetPuddle(IEntityManager entityManager, IMapGrid mapGrid, Vector2i pos)
{ {
foreach (var uid in mapGrid.GetAnchoredEntities(pos)) foreach (var uid in mapGrid.GetAnchoredEntities(pos))
@@ -42,7 +44,7 @@ public sealed class FluidSpill : ContentIntegrationTest
}; };
private readonly Vector2i _origin = new(1, 1); private readonly Vector2i _origin = new(-1, -1);
[Test] [Test]
public async Task SpillEvenlyTest() public async Task SpillEvenlyTest()
@@ -52,30 +54,28 @@ public sealed class FluidSpill : ContentIntegrationTest
await server.WaitIdleAsync(); await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var mapLoader = server.ResolveDependency<IMapLoader>();
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>(); var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>();
var gameTiming = server.ResolveDependency<IGameTiming>(); var gameTiming = server.ResolveDependency<IGameTiming>();
MapId mapId; MapId mapId;
GridId gridId = default; GridId? gridid = null;
await server.WaitPost(() => await server.WaitPost(() =>
{ {
mapId = mapManager.CreateMap(); mapId = mapManager.CreateMap();
var grid = mapManager.CreateGrid(mapId); gridid = mapLoader.LoadBlueprint(mapId, SpillMapsYml).gridId;
gridId = grid.Index;
for (var x = 0; x < 3; x++)
{
for (var y = 0; y < 3; y++)
{
grid.SetTile(new Vector2i(x, y), new Tile(1));
}
}
}); });
if (gridid == null)
{
Assert.Fail($"Test blueprint {SpillMapsYml} not found.");
return;
}
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var grid = mapManager.GetGrid(gridId); var grid = mapManager.GetGrid(gridid.Value);
var solution = new Solution("Water", FixedPoint2.New(100)); var solution = new Solution("Water", FixedPoint2.New(100));
var tileRef = grid.GetTileRef(_origin); var tileRef = grid.GetTileRef(_origin);
var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear"); var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear");
@@ -88,7 +88,7 @@ public sealed class FluidSpill : ContentIntegrationTest
server.Assert(() => server.Assert(() =>
{ {
var grid = mapManager.GetGrid(gridId); var grid = mapManager.GetGrid(gridid.Value);
var puddle = GetPuddle(entityManager, grid, _origin); var puddle = GetPuddle(entityManager, grid, _origin);
Assert.That(puddle, Is.Not.Null); Assert.That(puddle, Is.Not.Null);
@@ -115,44 +115,47 @@ public sealed class FluidSpill : ContentIntegrationTest
await server.WaitIdleAsync(); await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var mapLoader = server.ResolveDependency<IMapLoader>();
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>(); var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>();
var gameTiming = server.ResolveDependency<IGameTiming>(); var gameTiming = server.ResolveDependency<IGameTiming>();
MapId mapId; MapId mapId;
GridId gridId = default; GridId? gridId = null;
await server.WaitPost(() => await server.WaitPost(() =>
{ {
mapId = mapManager.CreateMap(); mapId = mapManager.CreateMap();
var grid = mapManager.CreateGrid(mapId); gridId = mapLoader.LoadBlueprint(mapId, SpillMapsYml).gridId;
for (var x = 0; x < 3; x++)
{
for (var y = 0; y < 3; y++)
{
grid.SetTile(new Vector2i(x, y), new Tile(1));
}
}
gridId = grid.Index;
}); });
if (gridId == null)
{
Assert.Fail($"Test blueprint {SpillMapsYml} not found.");
return;
}
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var solution = new Solution("Water", FixedPoint2.New(20.01)); var solution = new Solution("Water", FixedPoint2.New(20.01));
var grid = mapManager.GetGrid(gridId); var grid = mapManager.GetGrid(gridId.Value);
var tileRef = grid.GetTileRef(_origin); var tileRef = grid.GetTileRef(_origin);
var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear"); var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear");
Assert.That(puddle, Is.Not.Null); Assert.That(puddle, Is.Not.Null);
}); });
if (gridId == null)
{
Assert.Fail($"Test blueprint {SpillMapsYml} not found.");
return;
}
var sTimeToWait = (int) Math.Ceiling(2f * gameTiming.TickRate); var sTimeToWait = (int) Math.Ceiling(2f * gameTiming.TickRate);
await server.WaitRunTicks(sTimeToWait); await server.WaitRunTicks(sTimeToWait);
server.Assert(() => server.Assert(() =>
{ {
var grid = mapManager.GetGrid(gridId); var grid = mapManager.GetGrid(gridId.Value);
var puddle = GetPuddle(entityManager, grid, _origin); var puddle = GetPuddle(entityManager, grid, _origin);
Assert.That(puddle, Is.Not.Null); Assert.That(puddle, Is.Not.Null);
Assert.That(puddle!.CurrentVolume, Is.EqualTo(FixedPoint2.New(20))); Assert.That(puddle!.CurrentVolume, Is.EqualTo(FixedPoint2.New(20)));

View File

@@ -22,7 +22,6 @@ namespace Content.Server.Atmos.EntitySystems
SubscribeLocalEvent<AirtightComponent, ComponentInit>(OnAirtightInit); SubscribeLocalEvent<AirtightComponent, ComponentInit>(OnAirtightInit);
SubscribeLocalEvent<AirtightComponent, ComponentShutdown>(OnAirtightShutdown); SubscribeLocalEvent<AirtightComponent, ComponentShutdown>(OnAirtightShutdown);
SubscribeLocalEvent<AirtightComponent, AnchorStateChangedEvent>(OnAirtightPositionChanged); SubscribeLocalEvent<AirtightComponent, AnchorStateChangedEvent>(OnAirtightPositionChanged);
SubscribeLocalEvent<AirtightComponent, ReAnchorEvent>(OnAirtightReAnchor);
SubscribeLocalEvent<AirtightComponent, RotateEvent>(OnAirtightRotated); SubscribeLocalEvent<AirtightComponent, RotateEvent>(OnAirtightRotated);
} }
@@ -58,7 +57,7 @@ namespace Content.Server.Atmos.EntitySystems
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args) private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
{ {
var xform = Transform(uid); var xform = EntityManager.GetComponent<TransformComponent>(uid);
var gridId = xform.GridID; var gridId = xform.GridID;
var coords = xform.Coordinates; var coords = xform.Coordinates;
@@ -71,16 +70,6 @@ namespace Content.Server.Atmos.EntitySystems
InvalidatePosition(gridId, tilePos); InvalidatePosition(gridId, tilePos);
} }
private void OnAirtightReAnchor(EntityUid uid, AirtightComponent airtight, ref ReAnchorEvent args)
{
foreach (var gridId in new[] { args.OldGrid, args.GridId })
{
// Update and invalidate new position.
airtight.LastPosition = (gridId, args.TilePos);
InvalidatePosition(gridId, args.TilePos);
}
}
private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, ref RotateEvent ev) private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, ref RotateEvent ev)
{ {
if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid) if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid)

View File

@@ -28,7 +28,6 @@ namespace Content.Server.Atmos.EntitySystems
private void InitializeGrid() private void InitializeGrid()
{ {
SubscribeLocalEvent<GridAtmosphereComponent, ComponentInit>(OnGridAtmosphereInit); SubscribeLocalEvent<GridAtmosphereComponent, ComponentInit>(OnGridAtmosphereInit);
SubscribeLocalEvent<GridAtmosphereComponent, GridSplitEvent>(OnGridSplit);
} }
private void OnGridAtmosphereInit(EntityUid uid, GridAtmosphereComponent gridAtmosphere, ComponentInit args) private void OnGridAtmosphereInit(EntityUid uid, GridAtmosphereComponent gridAtmosphere, ComponentInit args)
@@ -61,56 +60,6 @@ namespace Content.Server.Atmos.EntitySystems
GridRepopulateTiles(mapGrid.Grid, gridAtmosphere); GridRepopulateTiles(mapGrid.Grid, gridAtmosphere);
} }
private void OnGridSplit(EntityUid uid, GridAtmosphereComponent originalGridAtmos, ref GridSplitEvent args)
{
foreach (var newGrid in args.NewGrids)
{
// Make extra sure this is a valid grid.
if (!_mapManager.TryGetGrid(newGrid, out var mapGrid))
continue;
var entity = mapGrid.GridEntityId;
// If the new split grid has an atmosphere already somehow, use that. Otherwise, add a new one.
if (!TryComp(entity, out GridAtmosphereComponent? newGridAtmos))
newGridAtmos = AddComp<GridAtmosphereComponent>(entity);
// We assume the tiles on the new grid have the same coordinates as they did on the old grid...
var enumerator = mapGrid.GetAllTilesEnumerator();
while (enumerator.MoveNext(out var tile))
{
var indices = tile.Value.GridIndices;
// This split event happens *before* the spaced tiles have been invalidated, therefore we can still
// access their gas data. On the next atmos update tick, these tiles will be spaced. Poof!
if (!originalGridAtmos.Tiles.TryGetValue(indices, out var tileAtmosphere))
continue;
// The new grid atmosphere has been initialized, meaning it has all the needed TileAtmospheres...
if (!newGridAtmos.Tiles.TryGetValue(indices, out var newTileAtmosphere))
// Let's be honest, this is really not gonna happen, but just in case...!
continue;
// Copy a bunch of data over... Not great, maybe put this in TileAtmosphere?
newTileAtmosphere.Air = tileAtmosphere.Air?.Clone() ?? null;
newTileAtmosphere.Hotspot = tileAtmosphere.Hotspot;
newTileAtmosphere.HeatCapacity = tileAtmosphere.HeatCapacity;
newTileAtmosphere.Temperature = tileAtmosphere.Temperature;
newTileAtmosphere.PressureDifference = tileAtmosphere.PressureDifference;
newTileAtmosphere.PressureDirection = tileAtmosphere.PressureDirection;
// TODO ATMOS: Somehow force GasTileOverlaySystem to perform an update *right now, right here.*
// The reason why is that right now, gas will flicker until the next GasTileOverlay update.
// That looks bad, of course. We want to avoid that! Anyway that's a bit more complicated so out of scope.
// Invalidate the tile, it's redundant but redundancy is good! Also HashSet so really, no duplicates.
InvalidateTile(originalGridAtmos, indices);
InvalidateTile(newGridAtmos, indices);
}
}
}
#region Grid Is Simulated #region Grid Is Simulated
/// <summary> /// <summary>
@@ -268,9 +217,8 @@ namespace Content.Server.Atmos.EntitySystems
private AtmosDirection GetBlockedDirections(IMapGrid mapGrid, Vector2i indices) private AtmosDirection GetBlockedDirections(IMapGrid mapGrid, Vector2i indices)
{ {
var value = AtmosDirection.Invalid; var value = AtmosDirection.Invalid;
var enumerator = GetObstructingComponentsEnumerator(mapGrid, indices);
while (enumerator.MoveNext(out var airtightComponent)) foreach (var airtightComponent in GetObstructingComponents(mapGrid, indices))
{ {
if(airtightComponent.AirBlocked) if(airtightComponent.AirBlocked)
value |= airtightComponent.AirBlockedDirection; value |= airtightComponent.AirBlockedDirection;

View File

@@ -11,6 +11,7 @@ namespace Content.Server.Atmos.EntitySystems;
/// </summary> /// </summary>
public sealed class AutomaticAtmosSystem : EntitySystem public sealed class AutomaticAtmosSystem : EntitySystem
{ {
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
public override void Initialize() public override void Initialize()
@@ -19,6 +20,7 @@ public sealed class AutomaticAtmosSystem : EntitySystem
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged); SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
} }
private void OnTileChanged(TileChangedEvent ev) private void OnTileChanged(TileChangedEvent ev)
{ {
// Only if a atmos-holding tile has been added or removed. // Only if a atmos-holding tile has been added or removed.
@@ -26,18 +28,18 @@ public sealed class AutomaticAtmosSystem : EntitySystem
// TODO: Make tiledefmanager cache the IsSpace property, and turn this lookup-through-two-interfaces into // TODO: Make tiledefmanager cache the IsSpace property, and turn this lookup-through-two-interfaces into
// TODO: a simple array lookup, as tile IDs are likely contiguous, and there's at most 2^16 possibilities anyway. // TODO: a simple array lookup, as tile IDs are likely contiguous, and there's at most 2^16 possibilities anyway.
if (!((ev.OldTile.IsSpace(_tileDefinitionManager) && !ev.NewTile.IsSpace(_tileDefinitionManager)) || if (!((ev.OldTile.IsSpace(_tileDefinitionManager) && !ev.NewTile.IsSpace(_tileDefinitionManager)) ||
(!ev.OldTile.IsSpace(_tileDefinitionManager) && ev.NewTile.IsSpace(_tileDefinitionManager))) || (!ev.OldTile.IsSpace(_tileDefinitionManager) && ev.NewTile.IsSpace(_tileDefinitionManager))))
HasComp<IAtmosphereComponent>(ev.Entity))
return; return;
if (!TryComp<PhysicsComponent>(ev.Entity, out var physics)) var uid = _mapManager.GetGridEuid(ev.NewTile.GridIndex);
if (!TryComp<PhysicsComponent>(uid, out var physics))
return; return;
// We can't actually count how many tiles there are efficiently, so instead estimate with the mass. // We can't actually count how many tiles there are efficiently, so instead estimate with the mass.
if (physics.Mass / ShuttleSystem.TileMassMultiplier >= 7.0f) if (physics.Mass / ShuttleSystem.TileMassMultiplier >= 7.0f && !HasComp<IAtmosphereComponent>(uid))
{ {
AddComp<GridAtmosphereComponent>(ev.Entity); AddComp<GridAtmosphereComponent>(uid);
Logger.InfoS("atmos", $"Giving grid {ev.Entity} GridAtmosphereComponent."); Logger.InfoS("atmos", $"Giving grid {uid} GridAtmosphereComponent.");
} }
// It's not super important to remove it should the grid become too small again. // It's not super important to remove it should the grid become too small again.
// If explosions ever gain the ability to outright shatter grids, do rethink this. // If explosions ever gain the ability to outright shatter grids, do rethink this.

View File

@@ -18,7 +18,7 @@ namespace Content.Server.Atmos
/// </summary> /// </summary>
[Serializable] [Serializable]
[DataDefinition] [DataDefinition]
public sealed class GasMixture : IEquatable<GasMixture>, ISerializationHooks public sealed class GasMixture : IEquatable<GasMixture>, ICloneable, ISerializationHooks
{ {
public static GasMixture SpaceGas => new() {Volume = Atmospherics.CellVolume, Temperature = Atmospherics.TCMB, Immutable = true}; public static GasMixture SpaceGas => new() {Volume = Atmospherics.CellVolume, Temperature = Atmospherics.TCMB, Immutable = true};
@@ -296,7 +296,7 @@ namespace Content.Server.Atmos
return hashCode.ToHashCode(); return hashCode.ToHashCode();
} }
public GasMixture Clone() public object Clone()
{ {
var newMixture = new GasMixture() var newMixture = new GasMixture()
{ {

View File

@@ -26,7 +26,6 @@ namespace Content.Server.Atmos.Piping.EntitySystems
SubscribeLocalEvent<AtmosDeviceComponent, ComponentInit>(OnDeviceInitialize); SubscribeLocalEvent<AtmosDeviceComponent, ComponentInit>(OnDeviceInitialize);
SubscribeLocalEvent<AtmosDeviceComponent, ComponentShutdown>(OnDeviceShutdown); SubscribeLocalEvent<AtmosDeviceComponent, ComponentShutdown>(OnDeviceShutdown);
// Re-anchoring should be handled by the parent change.
SubscribeLocalEvent<AtmosDeviceComponent, EntParentChangedMessage>(OnDeviceParentChanged); SubscribeLocalEvent<AtmosDeviceComponent, EntParentChangedMessage>(OnDeviceParentChanged);
SubscribeLocalEvent<AtmosDeviceComponent, AnchorStateChangedEvent>(OnDeviceAnchorChanged); SubscribeLocalEvent<AtmosDeviceComponent, AnchorStateChangedEvent>(OnDeviceAnchorChanged);
} }
@@ -105,7 +104,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
if (!component.RequireAnchored) if (!component.RequireAnchored)
return; return;
if (args.Anchored) if(EntityManager.GetComponent<TransformComponent>(component.Owner).Anchored)
JoinAtmosphere(component); JoinAtmosphere(component);
else else
LeaveAtmosphere(component); LeaveAtmosphere(component);

View File

@@ -36,7 +36,6 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
SubscribeLocalEvent<GasMixerComponent, GasMixerChangeNodePercentageMessage>(OnChangeNodePercentageMessage); SubscribeLocalEvent<GasMixerComponent, GasMixerChangeNodePercentageMessage>(OnChangeNodePercentageMessage);
SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage); SubscribeLocalEvent<GasMixerComponent, GasMixerToggleStatusMessage>(OnToggleStatusMessage);
// Shouldn't need re-anchor event
SubscribeLocalEvent<GasMixerComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<GasMixerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
} }

View File

@@ -22,7 +22,6 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
base.Initialize(); base.Initialize();
SubscribeLocalEvent<GasPortableComponent, AnchorAttemptEvent>(OnPortableAnchorAttempt); SubscribeLocalEvent<GasPortableComponent, AnchorAttemptEvent>(OnPortableAnchorAttempt);
// Shouldn't need re-anchored event.
SubscribeLocalEvent<GasPortableComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<GasPortableComponent, AnchorStateChangedEvent>(OnAnchorChanged);
} }

View File

@@ -11,7 +11,6 @@ namespace Content.Server.Atmos
/// Internal Atmos class that stores data about the atmosphere in a grid. /// Internal Atmos class that stores data about the atmosphere in a grid.
/// You shouldn't use this directly, use <see cref="AtmosphereSystem"/> instead. /// You shouldn't use this directly, use <see cref="AtmosphereSystem"/> instead.
/// </summary> /// </summary>
[Friend(typeof(AtmosphereSystem))]
public sealed class TileAtmosphere : IGasMixtureHolder public sealed class TileAtmosphere : IGasMixtureHolder
{ {
[ViewVariables] [ViewVariables]

View File

@@ -24,8 +24,7 @@ namespace Content.Server.BarSign.Systems
private void UpdateBarSignVisuals(EntityUid owner, BarSignComponent component, PowerChangedEvent args) private void UpdateBarSignVisuals(EntityUid owner, BarSignComponent component, PowerChangedEvent args)
{ {
var lifestage = MetaData(owner).EntityLifeStage; if (component.LifeStage is < ComponentLifeStage.Initialized or > ComponentLifeStage.Running) return;
if (lifestage is < EntityLifeStage.Initialized or >= EntityLifeStage.Terminating) return;
if (!TryComp(owner, out SpriteComponent? sprite)) if (!TryComp(owner, out SpriteComponent? sprite))
{ {

View File

@@ -13,11 +13,9 @@ namespace Content.Server.Cargo;
public sealed partial class CargoSystem public sealed partial class CargoSystem
{ {
[Dependency] private readonly PaperSystem _paperSystem = default!; [Dependency] private readonly PaperSystem _paperSystem = default!;
private void InitializeTelepad() private void InitializeTelepad()
{ {
SubscribeLocalEvent<CargoTelepadComponent, PowerChangedEvent>(OnTelepadPowerChange); SubscribeLocalEvent<CargoTelepadComponent, PowerChangedEvent>(OnTelepadPowerChange);
// Shouldn't need re-anchored event
SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange); SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange);
} }

View File

@@ -15,7 +15,6 @@ namespace Content.Server.Decals
{ {
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefMan = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly Dictionary<GridId, HashSet<Vector2i>> _dirtyChunks = new(); private readonly Dictionary<GridId, HashSet<Vector2i>> _dirtyChunks = new();
@@ -38,7 +37,7 @@ namespace Content.Server.Decals
base.Initialize(); base.Initialize();
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged); MapManager.TileChanged += OnTileChanged;
SubscribeNetworkEvent<RequestDecalPlacementEvent>(OnDecalPlacementRequest); SubscribeNetworkEvent<RequestDecalPlacementEvent>(OnDecalPlacementRequest);
SubscribeNetworkEvent<RequestDecalRemovalEvent>(OnDecalRemovalRequest); SubscribeNetworkEvent<RequestDecalRemovalEvent>(OnDecalRemovalRequest);
@@ -49,22 +48,23 @@ namespace Content.Server.Decals
base.Shutdown(); base.Shutdown();
_playerManager.PlayerStatusChanged -= OnPlayerStatusChanged; _playerManager.PlayerStatusChanged -= OnPlayerStatusChanged;
MapManager.TileChanged -= OnTileChanged;
} }
private void OnTileChanged(TileChangedEvent args) private void OnTileChanged(object? sender, TileChangedEventArgs e)
{ {
if (!args.NewTile.IsSpace(_tileDefMan)) if (!e.NewTile.IsSpace())
return; return;
var chunkCollection = ChunkCollection(args.Entity); var chunkCollection = ChunkCollection(e.NewTile.GridIndex);
var indices = GetChunkIndices(args.NewTile.GridIndices); var indices = GetChunkIndices(e.NewTile.GridIndices);
var toDelete = new HashSet<uint>(); var toDelete = new HashSet<uint>();
if (chunkCollection.TryGetValue(indices, out var chunk)) if (chunkCollection.TryGetValue(indices, out var chunk))
{ {
foreach (var (uid, decal) in chunk) foreach (var (uid, decal) in chunk)
{ {
if (new Vector2((int) Math.Floor(decal.Coordinates.X), (int) Math.Floor(decal.Coordinates.Y)) == if (new Vector2((int) Math.Floor(decal.Coordinates.X), (int) Math.Floor(decal.Coordinates.Y)) ==
args.NewTile.GridIndices) e.NewTile.GridIndices)
{ {
toDelete.Add(uid); toDelete.Add(uid);
} }
@@ -75,10 +75,10 @@ namespace Content.Server.Decals
foreach (var uid in toDelete) foreach (var uid in toDelete)
{ {
RemoveDecalInternal(args.NewTile.GridIndex, uid); RemoveDecalInternal(e.NewTile.GridIndex, uid);
} }
DirtyChunk(args.NewTile.GridIndex, indices); DirtyChunk(e.NewTile.GridIndex, indices);
} }
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e) private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)

View File

@@ -46,7 +46,6 @@ namespace Content.Server.Disposal.Unit.EntitySystems
{ {
base.Initialize(); base.Initialize();
// Shouldn't need re-anchoring.
SubscribeLocalEvent<DisposalUnitComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<DisposalUnitComponent, AnchorStateChangedEvent>(OnAnchorChanged);
// TODO: Predict me when hands predicted // TODO: Predict me when hands predicted
SubscribeLocalEvent<DisposalUnitComponent, RelayMovementEntityEvent>(HandleMovement); SubscribeLocalEvent<DisposalUnitComponent, RelayMovementEntityEvent>(HandleMovement);

View File

@@ -225,11 +225,11 @@ public sealed partial class ExplosionSystem : EntitySystem
if (!ev.NewTile.Tile.IsEmpty && !ev.OldTile.IsEmpty) if (!ev.NewTile.Tile.IsEmpty && !ev.OldTile.IsEmpty)
return; return;
if (!_mapManager.TryGetGrid(ev.Entity, out var grid))
return;
var tileRef = ev.NewTile; var tileRef = ev.NewTile;
if (!_mapManager.TryGetGrid(tileRef.GridIndex, out var grid))
return;
if (!_gridEdges.TryGetValue(tileRef.GridIndex, out var edges)) if (!_gridEdges.TryGetValue(tileRef.GridIndex, out var edges))
{ {
edges = new(); edges = new();

View File

@@ -21,7 +21,6 @@ public sealed partial class TriggerSystem
SubscribeLocalEvent<TriggerOnProximityComponent, EndCollideEvent>(OnProximityEndCollide); SubscribeLocalEvent<TriggerOnProximityComponent, EndCollideEvent>(OnProximityEndCollide);
SubscribeLocalEvent<TriggerOnProximityComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<TriggerOnProximityComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<TriggerOnProximityComponent, ComponentShutdown>(OnProximityShutdown); SubscribeLocalEvent<TriggerOnProximityComponent, ComponentShutdown>(OnProximityShutdown);
// Shouldn't need re-anchoring.
SubscribeLocalEvent<TriggerOnProximityComponent, AnchorStateChangedEvent>(OnProximityAnchor); SubscribeLocalEvent<TriggerOnProximityComponent, AnchorStateChangedEvent>(OnProximityAnchor);
} }

View File

@@ -21,7 +21,6 @@ namespace Content.Server.Fluids.EntitySystems
{ {
base.Initialize(); base.Initialize();
// Shouldn't need re-anchoring.
SubscribeLocalEvent<PuddleComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<PuddleComponent, AnchorStateChangedEvent>(OnAnchorChanged);
SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined); SubscribeLocalEvent<PuddleComponent, ExaminedEvent>(HandlePuddleExamined);
SubscribeLocalEvent<PuddleComponent, SolutionChangedEvent>(OnUpdate); SubscribeLocalEvent<PuddleComponent, SolutionChangedEvent>(OnUpdate);

View File

@@ -184,7 +184,7 @@ public sealed class SpillableSystem : EntitySystem
// Get normalized co-ordinate for spill location and spill it in the centre // Get normalized co-ordinate for spill location and spill it in the centre
// TODO: Does SnapGrid or something else already do this? // TODO: Does SnapGrid or something else already do this?
var spillGridCoords = mapGrid.GridTileToLocal(tileRef.GridIndices); var spillGridCoords = mapGrid.GridTileToWorld(tileRef.GridIndices);
var startEntity = EntityUid.Invalid; var startEntity = EntityUid.Invalid;
PuddleComponent? puddleComponent = null; PuddleComponent? puddleComponent = null;

View File

@@ -22,7 +22,6 @@ namespace Content.Server.NodeContainer.EntitySystems
SubscribeLocalEvent<NodeContainerComponent, ComponentStartup>(OnStartupEvent); SubscribeLocalEvent<NodeContainerComponent, ComponentStartup>(OnStartupEvent);
SubscribeLocalEvent<NodeContainerComponent, ComponentShutdown>(OnShutdownEvent); SubscribeLocalEvent<NodeContainerComponent, ComponentShutdown>(OnShutdownEvent);
SubscribeLocalEvent<NodeContainerComponent, AnchorStateChangedEvent>(OnAnchorStateChanged); SubscribeLocalEvent<NodeContainerComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
SubscribeLocalEvent<NodeContainerComponent, ReAnchorEvent>(OnReAnchor);
SubscribeLocalEvent<NodeContainerComponent, RotateEvent>(OnRotateEvent); SubscribeLocalEvent<NodeContainerComponent, RotateEvent>(OnRotateEvent);
SubscribeLocalEvent<NodeContainerComponent, ExaminedEvent>(OnExamine); SubscribeLocalEvent<NodeContainerComponent, ExaminedEvent>(OnExamine);
} }
@@ -72,15 +71,6 @@ namespace Content.Server.NodeContainer.EntitySystems
} }
} }
private void OnReAnchor(EntityUid uid, NodeContainerComponent component, ref ReAnchorEvent args)
{
foreach (var node in component.Nodes.Values)
{
_nodeGroupSystem.QueueNodeRemove(node);
_nodeGroupSystem.QueueReflood(node);
}
}
private void OnRotateEvent(EntityUid uid, NodeContainerComponent container, ref RotateEvent ev) private void OnRotateEvent(EntityUid uid, NodeContainerComponent container, ref RotateEvent ev)
{ {
if (ev.NewRotation == ev.OldRotation) if (ev.NewRotation == ev.OldRotation)

View File

@@ -157,8 +157,8 @@ namespace Content.Server.NodeContainer.EntitySystems
var sw = Stopwatch.StartNew(); var sw = Stopwatch.StartNew();
var xformQuery = GetEntityQuery<TransformComponent>(); var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
var nodeQuery = GetEntityQuery<NodeContainerComponent>(); var nodeQuery = EntityManager.GetEntityQuery<NodeContainerComponent>();
foreach (var toRemove in _toRemove) foreach (var toRemove in _toRemove)
{ {

View File

@@ -55,7 +55,7 @@ namespace Content.Server.NodeContainer.NodeGroups
} }
} }
public enum NodeGroupID : byte public enum NodeGroupID
{ {
Default, Default,
HVPower, HVPower,

View File

@@ -34,7 +34,6 @@ namespace Content.Server.Nuke
// anchoring logic // anchoring logic
SubscribeLocalEvent<NukeComponent, AnchorAttemptEvent>(OnAnchorAttempt); SubscribeLocalEvent<NukeComponent, AnchorAttemptEvent>(OnAnchorAttempt);
SubscribeLocalEvent<NukeComponent, UnanchorAttemptEvent>(OnUnanchorAttempt); SubscribeLocalEvent<NukeComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
// Shouldn't need re-anchoring.
SubscribeLocalEvent<NukeComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<NukeComponent, AnchorStateChangedEvent>(OnAnchorChanged);
// ui events // ui events

View File

@@ -26,7 +26,6 @@ public sealed partial class CableSystem : EntitySystem
SubscribeLocalEvent<CableComponent, InteractUsingEvent>(OnInteractUsing); SubscribeLocalEvent<CableComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<CableComponent, CuttingFinishedEvent>(OnCableCut); SubscribeLocalEvent<CableComponent, CuttingFinishedEvent>(OnCableCut);
// Shouldn't need re-anchoring.
SubscribeLocalEvent<CableComponent, AnchorStateChangedEvent>(OnAnchorChanged); SubscribeLocalEvent<CableComponent, AnchorStateChangedEvent>(OnAnchorChanged);
} }

View File

@@ -25,10 +25,7 @@ namespace Content.Server.Power.EntitySystems
//Anchoring //Anchoring
SubscribeLocalEvent<ExtensionCableReceiverComponent, AnchorStateChangedEvent>(OnReceiverAnchorStateChanged); SubscribeLocalEvent<ExtensionCableReceiverComponent, AnchorStateChangedEvent>(OnReceiverAnchorStateChanged);
SubscribeLocalEvent<ExtensionCableReceiverComponent, ReAnchorEvent>(OnReceiverReAnchor);
SubscribeLocalEvent<ExtensionCableProviderComponent, AnchorStateChangedEvent>(OnProviderAnchorStateChanged); SubscribeLocalEvent<ExtensionCableProviderComponent, AnchorStateChangedEvent>(OnProviderAnchorStateChanged);
SubscribeLocalEvent<ExtensionCableProviderComponent, ReAnchorEvent>(OnProviderReAnchor);
} }
#region Provider #region Provider
@@ -44,7 +41,14 @@ namespace Content.Server.Power.EntitySystems
private void OnProviderStarted(EntityUid uid, ExtensionCableProviderComponent provider, ComponentStartup args) private void OnProviderStarted(EntityUid uid, ExtensionCableProviderComponent provider, ComponentStartup args)
{ {
Connect(uid, provider); foreach (var receiver in FindAvailableReceivers(uid, provider.TransferRange))
{
receiver.Provider?.LinkedReceivers.Remove(receiver);
receiver.Provider = provider;
provider.LinkedReceivers.Add(receiver);
RaiseLocalEvent(receiver.Owner, new ProviderConnectedEvent(provider), broadcast: false);
RaiseLocalEvent(uid, new ReceiverConnectedEvent(receiver), broadcast: false);
}
} }
private void OnProviderShutdown(EntityUid uid, ExtensionCableProviderComponent provider, ComponentShutdown args) private void OnProviderShutdown(EntityUid uid, ExtensionCableProviderComponent provider, ComponentShutdown args)
@@ -57,21 +61,17 @@ namespace Content.Server.Power.EntitySystems
if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return; if (MetaData(grid.GridEntityId).EntityLifeStage > EntityLifeStage.MapInitialized) return;
} }
Disconnect(uid, provider); provider.Connectable = false;
ResetReceivers(provider);
} }
private void OnProviderAnchorStateChanged(EntityUid uid, ExtensionCableProviderComponent provider, ref AnchorStateChangedEvent args) private void OnProviderAnchorStateChanged(EntityUid uid, ExtensionCableProviderComponent provider, ref AnchorStateChangedEvent args)
{ {
if (args.Anchored) if (args.Anchored)
Connect(uid, provider);
else
Disconnect(uid, provider);
}
private void Connect(EntityUid uid, ExtensionCableProviderComponent provider)
{ {
provider.Connectable = true; provider.Connectable = true;
// same as OnProviderStarted
foreach (var receiver in FindAvailableReceivers(uid, provider.TransferRange)) foreach (var receiver in FindAvailableReceivers(uid, provider.TransferRange))
{ {
receiver.Provider?.LinkedReceivers.Remove(receiver); receiver.Provider?.LinkedReceivers.Remove(receiver);
@@ -81,18 +81,12 @@ namespace Content.Server.Power.EntitySystems
RaiseLocalEvent(uid, new ReceiverConnectedEvent(receiver), broadcast: false); RaiseLocalEvent(uid, new ReceiverConnectedEvent(receiver), broadcast: false);
} }
} }
else
private void Disconnect(EntityUid uid, ExtensionCableProviderComponent provider)
{ {
// same as OnProviderShutdown // same as OnProviderShutdown
provider.Connectable = false; provider.Connectable = false;
ResetReceivers(provider); ResetReceivers(provider);
} }
private void OnProviderReAnchor(EntityUid uid, ExtensionCableProviderComponent component, ref ReAnchorEvent args)
{
Disconnect(uid, component);
Connect(uid, component);
} }
private void ResetReceivers(ExtensionCableProviderComponent provider) private void ResetReceivers(ExtensionCableProviderComponent provider)
@@ -185,28 +179,16 @@ namespace Content.Server.Power.EntitySystems
private void OnReceiverShutdown(EntityUid uid, ExtensionCableReceiverComponent receiver, ComponentShutdown args) private void OnReceiverShutdown(EntityUid uid, ExtensionCableReceiverComponent receiver, ComponentShutdown args)
{ {
Disconnect(uid, receiver); if (receiver.Provider == null) return;
receiver.Provider.LinkedReceivers.Remove(receiver);
RaiseLocalEvent(uid, new ProviderDisconnectedEvent(receiver.Provider), broadcast: false);
RaiseLocalEvent(receiver.Provider.Owner, new ReceiverDisconnectedEvent(receiver), broadcast: false);
} }
private void OnReceiverAnchorStateChanged(EntityUid uid, ExtensionCableReceiverComponent receiver, ref AnchorStateChangedEvent args) private void OnReceiverAnchorStateChanged(EntityUid uid, ExtensionCableReceiverComponent receiver, ref AnchorStateChangedEvent args)
{ {
if (args.Anchored) if (args.Anchored)
{
Connect(uid, receiver);
}
else
{
Disconnect(uid, receiver);
}
}
private void OnReceiverReAnchor(EntityUid uid, ExtensionCableReceiverComponent receiver, ref ReAnchorEvent args)
{
Disconnect(uid, receiver);
Connect(uid, receiver);
}
private void Connect(EntityUid uid, ExtensionCableReceiverComponent receiver)
{ {
receiver.Connectable = true; receiver.Connectable = true;
if (receiver.Provider == null) if (receiver.Provider == null)
@@ -214,8 +196,7 @@ namespace Content.Server.Power.EntitySystems
TryFindAndSetProvider(receiver); TryFindAndSetProvider(receiver);
} }
} }
else
private void Disconnect(EntityUid uid, ExtensionCableReceiverComponent receiver)
{ {
receiver.Connectable = false; receiver.Connectable = false;
RaiseLocalEvent(uid, new ProviderDisconnectedEvent(receiver.Provider), broadcast: false); RaiseLocalEvent(uid, new ProviderDisconnectedEvent(receiver.Provider), broadcast: false);
@@ -227,6 +208,7 @@ namespace Content.Server.Power.EntitySystems
receiver.Provider = null; receiver.Provider = null;
} }
}
private void TryFindAndSetProvider(ExtensionCableReceiverComponent receiver, TransformComponent? xform = null) private void TryFindAndSetProvider(ExtensionCableReceiverComponent receiver, TransformComponent? xform = null)
{ {

View File

@@ -13,21 +13,13 @@ namespace Content.Server.Power.NodeGroups
public override void LoadNodes(List<Node> groupNodes) public override void LoadNodes(List<Node> groupNodes)
{ {
base.LoadNodes(groupNodes); base.LoadNodes(groupNodes);
var entManager = IoCManager.Resolve<IEntityManager>();
foreach (var node in groupNodes) foreach (var node in groupNodes)
{ {
var newNetConnectorComponents = new List<IBaseNetConnectorComponent<TNetType>>(); var newNetConnectorComponents = IoCManager.Resolve<IEntityManager>().GetComponents<IBaseNetConnectorComponent<TNetType>>(node.Owner)
.Where(powerComp => (powerComp.NodeId == null || powerComp.NodeId == node.Name) &&
foreach (var comp in entManager.GetComponents<IBaseNetConnectorComponent<TNetType>>(node.Owner)) (NodeGroupID) powerComp.Voltage == node.NodeGroupID)
{ .ToList();
if ((comp.NodeId == null ||
comp.NodeId == node.Name) &&
(NodeGroupID) comp.Voltage == node.NodeGroupID)
{
newNetConnectorComponents.Add(comp);
}
}
foreach (var netConnector in newNetConnectorComponents) foreach (var netConnector in newNetConnectorComponents)
{ {

View File

@@ -38,7 +38,6 @@ namespace Content.Server.Shuttles.EntitySystems
SubscribeLocalEvent<DockingComponent, ComponentShutdown>(OnShutdown); SubscribeLocalEvent<DockingComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<DockingComponent, PowerChangedEvent>(OnPowerChange); SubscribeLocalEvent<DockingComponent, PowerChangedEvent>(OnPowerChange);
SubscribeLocalEvent<DockingComponent, AnchorStateChangedEvent>(OnAnchorChange); SubscribeLocalEvent<DockingComponent, AnchorStateChangedEvent>(OnAnchorChange);
SubscribeLocalEvent<DockingComponent, ReAnchorEvent>(OnDockingReAnchor);
SubscribeLocalEvent<DockingComponent, GetVerbsEvent<InteractionVerb>>(OnVerb); SubscribeLocalEvent<DockingComponent, GetVerbsEvent<InteractionVerb>>(OnVerb);
SubscribeLocalEvent<DockingComponent, BeforeDoorAutoCloseEvent>(OnAutoClose); SubscribeLocalEvent<DockingComponent, BeforeDoorAutoCloseEvent>(OnAutoClose);
@@ -257,16 +256,6 @@ namespace Content.Server.Shuttles.EntitySystems
} }
} }
private void OnDockingReAnchor(EntityUid uid, DockingComponent component, ref ReAnchorEvent args)
{
if (!component.Docked) return;
var other = Comp<DockingComponent>(component.DockedWith!.Value);
Undock(component);
Dock(component, other);
}
private void OnPowerChange(EntityUid uid, DockingComponent component, PowerChangedEvent args) private void OnPowerChange(EntityUid uid, DockingComponent component, PowerChangedEvent args)
{ {
// This is because power can change during startup for <Reasons> and undock // This is because power can change during startup for <Reasons> and undock

View File

@@ -1,17 +1,18 @@
using System.Collections.Generic;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics; using Robust.Shared.Physics;
namespace Content.Server.Shuttles.EntitySystems namespace Content.Server.Shuttles.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public sealed class ShuttleSystem : EntitySystem internal sealed class ShuttleSystem : EntitySystem
{ {
[Dependency] private readonly FixtureSystem _fixtures = default!; public const float TileMassMultiplier = 4f;
public const float TileMassMultiplier = 0.5f;
public float ShuttleMaxLinearSpeed; public float ShuttleMaxLinearSpeed;
@@ -73,15 +74,11 @@ namespace Content.Server.Shuttles.EntitySystems
// Look this is jank but it's a placeholder until we design it. // Look this is jank but it's a placeholder until we design it.
if (args.NewFixtures.Count == 0) return; if (args.NewFixtures.Count == 0) return;
var manager = Comp<FixturesComponent>(args.NewFixtures[0].Body.Owner);
foreach (var fixture in args.NewFixtures) foreach (var fixture in args.NewFixtures)
{ {
_fixtures.SetMass(fixture, fixture.Area * TileMassMultiplier, manager, false); fixture.Mass = fixture.Area * TileMassMultiplier;
_fixtures.SetRestitution(fixture, 0.1f, manager, false); fixture.Restitution = 0.1f;
} }
_fixtures.FixtureUpdate(manager, args.NewFixtures[0].Body);
} }
private void OnGridInit(GridInitializeEvent ev) private void OnGridInit(GridInitializeEvent ev)

View File

@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Content.Server.Audio; using Content.Server.Audio;
using Content.Server.Damage.Systems;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using Content.Shared.Damage; using Content.Shared.Damage;
@@ -11,7 +14,11 @@ using Content.Shared.Physics;
using Content.Shared.Temperature; using Content.Shared.Temperature;
using Content.Shared.Shuttles.Components; using Content.Shared.Shuttles.Components;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes; using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Dynamics; using Robust.Shared.Physics.Dynamics;
@@ -22,7 +29,6 @@ namespace Content.Server.Shuttles.EntitySystems
public sealed class ThrusterSystem : EntitySystem public sealed class ThrusterSystem : EntitySystem
{ {
[Robust.Shared.IoC.Dependency] private readonly IMapManager _mapManager = default!; [Robust.Shared.IoC.Dependency] private readonly IMapManager _mapManager = default!;
[Robust.Shared.IoC.Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
[Robust.Shared.IoC.Dependency] private readonly AmbientSoundSystem _ambient = default!; [Robust.Shared.IoC.Dependency] private readonly AmbientSoundSystem _ambient = default!;
[Robust.Shared.IoC.Dependency] private readonly FixtureSystem _fixtureSystem = default!; [Robust.Shared.IoC.Dependency] private readonly FixtureSystem _fixtureSystem = default!;
[Robust.Shared.IoC.Dependency] private readonly DamageableSystem _damageable = default!; [Robust.Shared.IoC.Dependency] private readonly DamageableSystem _damageable = default!;
@@ -46,7 +52,6 @@ namespace Content.Server.Shuttles.EntitySystems
SubscribeLocalEvent<ThrusterComponent, ComponentShutdown>(OnThrusterShutdown); SubscribeLocalEvent<ThrusterComponent, ComponentShutdown>(OnThrusterShutdown);
SubscribeLocalEvent<ThrusterComponent, PowerChangedEvent>(OnPowerChange); SubscribeLocalEvent<ThrusterComponent, PowerChangedEvent>(OnPowerChange);
SubscribeLocalEvent<ThrusterComponent, AnchorStateChangedEvent>(OnAnchorChange); SubscribeLocalEvent<ThrusterComponent, AnchorStateChangedEvent>(OnAnchorChange);
SubscribeLocalEvent<ThrusterComponent, ReAnchorEvent>(OnThrusterReAnchor);
SubscribeLocalEvent<ThrusterComponent, RotateEvent>(OnRotate); SubscribeLocalEvent<ThrusterComponent, RotateEvent>(OnRotate);
SubscribeLocalEvent<ThrusterComponent, IsHotEvent>(OnIsHotEvent); SubscribeLocalEvent<ThrusterComponent, IsHotEvent>(OnIsHotEvent);
SubscribeLocalEvent<ThrusterComponent, StartCollideEvent>(OnStartCollide); SubscribeLocalEvent<ThrusterComponent, StartCollideEvent>(OnStartCollide);
@@ -99,12 +104,9 @@ namespace Content.Server.Shuttles.EntitySystems
private void OnTileChange(object? sender, TileChangedEventArgs e) private void OnTileChange(object? sender, TileChangedEventArgs e)
{ {
// If the old tile was space but the new one isn't then disable all adjacent thrusters // If the old tile was space but the new one isn't then disable all adjacent thrusters
if (e.NewTile.IsSpace(_tileDefManager) || !e.OldTile.IsSpace(_tileDefManager)) return; if (e.NewTile.IsSpace() || !e.OldTile.IsSpace()) return;
var tilePos = e.NewTile.GridIndices; var tilePos = e.NewTile.GridIndices;
var grid = _mapManager.GetGrid(e.NewTile.GridIndex);
var xformQuery = GetEntityQuery<TransformComponent>();
var thrusterQuery = GetEntityQuery<ThrusterComponent>();
for (var x = -1; x <= 1; x++) for (var x = -1; x <= 1; x++)
{ {
@@ -113,19 +115,17 @@ namespace Content.Server.Shuttles.EntitySystems
if (x != 0 && y != 0) continue; if (x != 0 && y != 0) continue;
var checkPos = tilePos + new Vector2i(x, y); var checkPos = tilePos + new Vector2i(x, y);
var enumerator = grid.GetAnchoredEntitiesEnumerator(checkPos);
while (enumerator.MoveNext(out var ent)) foreach (var ent in _mapManager.GetGrid(e.NewTile.GridIndex).GetAnchoredEntities(checkPos))
{ {
if (!thrusterQuery.TryGetComponent(ent.Value, out var thruster) || !thruster.RequireSpace) continue; if (!EntityManager.TryGetComponent(ent, out ThrusterComponent? thruster) || !thruster.RequireSpace) continue;
// Work out if the thruster is facing this direction // Work out if the thruster is facing this direction
var xform = xformQuery.GetComponent(ent.Value); var direction = EntityManager.GetComponent<TransformComponent>(ent).LocalRotation.ToWorldVec();
var direction = xform.LocalRotation.ToWorldVec();
if (new Vector2i((int) direction.X, (int) direction.Y) != new Vector2i(x, y)) continue; if (new Vector2i((int) direction.X, (int) direction.Y) != new Vector2i(x, y)) continue;
DisableThruster(ent.Value, thruster, xform.GridID); DisableThruster(ent, thruster);
} }
} }
} }
@@ -195,14 +195,6 @@ namespace Content.Server.Shuttles.EntitySystems
} }
} }
private void OnThrusterReAnchor(EntityUid uid, ThrusterComponent component, ref ReAnchorEvent args)
{
DisableThruster(uid, component, args.OldGrid);
if (CanEnable(uid, component))
EnableThruster(uid, component);
}
private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args) private void OnThrusterInit(EntityUid uid, ThrusterComponent component, ComponentInit args)
{ {
_ambient.SetAmbience(uid, false); _ambient.SetAmbience(uid, false);
@@ -300,20 +292,14 @@ namespace Content.Server.Shuttles.EntitySystems
_ambient.SetAmbience(uid, true); _ambient.SetAmbience(uid, true);
} }
public void DisableThruster(EntityUid uid, ThrusterComponent component, TransformComponent? xform = null, Angle? angle = null)
{
if (!Resolve(uid, ref xform)) return;
DisableThruster(uid, component, xform.GridID, xform);
}
/// <summary> /// <summary>
/// Tries to disable the thruster. /// Tries to disable the thruster.
/// </summary> /// </summary>
public void DisableThruster(EntityUid uid, ThrusterComponent component, GridId gridId, TransformComponent? xform = null, Angle? angle = null) public void DisableThruster(EntityUid uid, ThrusterComponent component, TransformComponent? xform = null, Angle? angle = null)
{ {
if (!component.IsOn || if (!component.IsOn ||
!Resolve(uid, ref xform) || !Resolve(uid, ref xform) ||
!_mapManager.TryGetGrid(gridId, out var grid)) return; !_mapManager.TryGetGrid(xform.GridID, out var grid)) return;
component.IsOn = false; component.IsOn = false;
@@ -365,7 +351,7 @@ namespace Content.Server.Shuttles.EntitySystems
{ {
if (!component.Enabled) return false; if (!component.Enabled) return false;
var xform = Transform(uid); var xform = EntityManager.GetComponent<TransformComponent>(uid);
if (!xform.Anchored || if (!xform.Anchored ||
EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered) EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered)

View File

@@ -52,11 +52,8 @@ namespace Content.Shared.Decals
} }
} }
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(EntityUid gridEuid) => protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(GridId gridId) => EntityManager
Comp<DecalGridComponent>(gridEuid).ChunkCollection; .GetComponent<DecalGridComponent>(MapManager.GetGrid(gridId).GridEntityId).ChunkCollection;
protected DecalGridComponent.DecalGridChunkCollection DecalGridChunkCollection(GridId gridId) =>
Comp<DecalGridComponent>(MapManager.GetGridEuid(gridId)).ChunkCollection;
protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(EntityUid gridEuid) => DecalGridChunkCollection(gridEuid).ChunkCollection;
protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(GridId gridId) => DecalGridChunkCollection(gridId).ChunkCollection; protected Dictionary<Vector2i, Dictionary<uint, Decal>> ChunkCollection(GridId gridId) => DecalGridChunkCollection(gridId).ChunkCollection;
protected virtual void DirtyChunk(GridId id, Vector2i chunkIndices) {} protected virtual void DirtyChunk(GridId id, Vector2i chunkIndices) {}

View File

@@ -164,7 +164,7 @@ namespace Content.Shared.Maps
if (!GetWorldTileBox(turf, out var worldBox)) if (!GetWorldTileBox(turf, out var worldBox))
return Enumerable.Empty<EntityUid>(); return Enumerable.Empty<EntityUid>();
return lookupSystem.GetEntitiesIntersecting(turf.GridIndex, worldBox, flags); return lookupSystem.GetEntitiesIntersecting(turf.MapIndex, worldBox, flags);
} }
/// <summary> /// <summary>
@@ -193,18 +193,15 @@ namespace Content.Shared.Maps
/// </summary> /// </summary>
public static bool IsBlockedTurf(this TileRef turf, bool filterMobs) public static bool IsBlockedTurf(this TileRef turf, bool filterMobs)
{ {
// TODO: Deprecate this with entitylookup. var physics = EntitySystem.Get<SharedPhysicsSystem>();
var physics = EntitySystem.Get<EntityLookupSystem>();
if (!GetWorldTileBox(turf, out var worldBox)) if (!GetWorldTileBox(turf, out var worldBox))
return false; return false;
var entManager = IoCManager.Resolve<IEntityManager>(); var query = physics.GetCollidingEntities(turf.MapIndex, in worldBox);
var query = physics.GetEntitiesIntersecting(turf.GridIndex, worldBox);
foreach (var ent in query) foreach (var body in query)
{ {
var body = entManager.GetComponent<PhysicsComponent>(ent);
if (body.CanCollide && body.Hard && (body.CollisionLayer & (int) CollisionGroup.Impassable) != 0) if (body.CanCollide && body.Hard && (body.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
return true; return true;

View File

@@ -26,7 +26,6 @@ namespace Content.Shared.SubFloor
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged); SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
SubscribeLocalEvent<SubFloorHideComponent, ComponentStartup>(OnSubFloorStarted); SubscribeLocalEvent<SubFloorHideComponent, ComponentStartup>(OnSubFloorStarted);
SubscribeLocalEvent<SubFloorHideComponent, ComponentShutdown>(OnSubFloorTerminating); SubscribeLocalEvent<SubFloorHideComponent, ComponentShutdown>(OnSubFloorTerminating);
// Like 80% sure this doesn't need to handle re-anchoring.
SubscribeLocalEvent<SubFloorHideComponent, AnchorStateChangedEvent>(HandleAnchorChanged); SubscribeLocalEvent<SubFloorHideComponent, AnchorStateChangedEvent>(HandleAnchorChanged);
SubscribeLocalEvent<SubFloorHideComponent, GettingInteractedWithAttemptEvent>(OnInteractionAttempt); SubscribeLocalEvent<SubFloorHideComponent, GettingInteractedWithAttemptEvent>(OnInteractionAttempt);
} }

View File

@@ -40,7 +40,7 @@ public sealed class TrayScannerSystem : EntitySystem
return; return;
scanner.Enabled = enabled; scanner.Enabled = enabled;
Dirty(scanner); scanner.Dirty();
if (scanner.Enabled) if (scanner.Enabled)
_activeScanners.Add(uid); _activeScanners.Add(uid);

View File

@@ -28,7 +28,7 @@ namespace Content.Shared.Throwing
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<ThrownItemComponent, PhysicsSleepEvent>(OnSleep); SubscribeLocalEvent<ThrownItemComponent, PhysicsSleepMessage>(HandleSleep);
SubscribeLocalEvent<ThrownItemComponent, StartCollideEvent>(HandleCollision); SubscribeLocalEvent<ThrownItemComponent, StartCollideEvent>(HandleCollision);
SubscribeLocalEvent<ThrownItemComponent, PreventCollideEvent>(PreventCollision); SubscribeLocalEvent<ThrownItemComponent, PreventCollideEvent>(PreventCollision);
SubscribeLocalEvent<ThrownItemComponent, ThrownEvent>(ThrowItem); SubscribeLocalEvent<ThrownItemComponent, ThrownEvent>(ThrowItem);
@@ -87,7 +87,7 @@ namespace Content.Shared.Throwing
} }
} }
private void OnSleep(EntityUid uid, ThrownItemComponent thrownItem, ref PhysicsSleepEvent @event) private void HandleSleep(EntityUid uid, ThrownItemComponent thrownItem, PhysicsSleepMessage message)
{ {
StopThrow(uid, thrownItem); StopThrow(uid, thrownItem);
} }

View File

@@ -67,7 +67,6 @@
- showpos - showpos
- showray - showray
- showchunkbb - showchunkbb
- showgridnodes
- entfo - entfo
- sggcell - sggcell
- ldrsc - ldrsc