Remove default grids (content) (#2241)
* Default grids go poof * Address review * Update submodule * Fix DoAfterSystem for entities without grid. * Fix SubFloorHideSystem for entities without grid. * Fix ExplosionHelper for coordinates that aren't in a grid * Fix TurfHelpers' GetWorldTileBox crash in the case of invalid grid * Fix tile prying component crash when trying to pry space. * Spill fixes when passing coordinates without grids. * Are you static'in, son? * Change SaveLoadSaveTest grid Id hardcoded value It's still hardcoded, but at least now it's correct! * Only send debug AI thing if grid is not invalid * Update submodule. Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
committed by
GitHub
parent
78507ac9a2
commit
48841a274d
@@ -37,8 +37,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
foreach (var comp in EntityManager.ComponentManager.EntityQuery<SubFloorHideComponent>())
|
foreach (var comp in EntityManager.ComponentManager.EntityQuery<SubFloorHideComponent>())
|
||||||
{
|
{
|
||||||
var gridId = comp.Owner.Transform.GridID;
|
if (!_mapManager.TryGetGrid(comp.Owner.Transform.GridID, out var grid)) return;
|
||||||
var grid = _mapManager.GetGrid(gridId);
|
|
||||||
|
|
||||||
var snapPos = comp.Owner.GetComponent<SnapGridComponent>();
|
var snapPos = comp.Owner.GetComponent<SnapGridComponent>();
|
||||||
UpdateTile(grid, snapPos.Position);
|
UpdateTile(grid, snapPos.Position);
|
||||||
|
|||||||
@@ -209,11 +209,11 @@ namespace Content.Client.State
|
|||||||
var mousePosWorld = EyeManager.ScreenToMap(args.PointerLocation);
|
var mousePosWorld = EyeManager.ScreenToMap(args.PointerLocation);
|
||||||
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
||||||
|
|
||||||
if (!MapManager.TryFindGridAt(mousePosWorld, out var grid))
|
var coordinates = MapManager.TryFindGridAt(mousePosWorld, out var grid) ? grid.MapToGrid(mousePosWorld) :
|
||||||
grid = MapManager.GetDefaultGrid(mousePosWorld.MapId);
|
EntityCoordinates.FromMap(EntityManager, MapManager, mousePosWorld);
|
||||||
|
|
||||||
var message = new FullInputCmdMessage(Timing.CurTick, Timing.TickFraction, funcId, args.State,
|
var message = new FullInputCmdMessage(Timing.CurTick, Timing.TickFraction, funcId, args.State,
|
||||||
grid.MapToGrid(mousePosWorld), args.PointerLocation,
|
coordinates , args.PointerLocation,
|
||||||
entityToClick?.Uid ?? EntityUid.Invalid);
|
entityToClick?.Uid ?? EntityUid.Invalid);
|
||||||
|
|
||||||
// client side command handlers will always be sent the local player session.
|
// client side command handlers will always be sent the local player session.
|
||||||
|
|||||||
@@ -70,12 +70,14 @@ namespace Content.Client.UserInterface
|
|||||||
var func = args.Function;
|
var func = args.Function;
|
||||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(args.Function);
|
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(args.Function);
|
||||||
|
|
||||||
|
|
||||||
var mousePosWorld = _eyeManager.ScreenToMap(args.PointerLocation);
|
var mousePosWorld = _eyeManager.ScreenToMap(args.PointerLocation);
|
||||||
if (!_mapManager.TryFindGridAt(mousePosWorld, out var grid))
|
|
||||||
grid = _mapManager.GetDefaultGrid(mousePosWorld.MapId);
|
var coordinates = _mapManager.TryFindGridAt(mousePosWorld, out var grid) ? grid.MapToGrid(mousePosWorld) :
|
||||||
|
EntityCoordinates.FromMap(_entityManager, _mapManager, mousePosWorld);
|
||||||
|
|
||||||
var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId, BoundKeyState.Down,
|
var message = new FullInputCmdMessage(_gameTiming.CurTick, _gameTiming.TickFraction, funcId, BoundKeyState.Down,
|
||||||
grid.MapToGrid(mousePosWorld), args.PointerLocation, item.Uid);
|
coordinates, args.PointerLocation, item.Uid);
|
||||||
|
|
||||||
// client side command handlers will always be sent the local player session.
|
// client side command handlers will always be sent the local player session.
|
||||||
var session = _playerManager.LocalPlayer?.Session;
|
var session = _playerManager.LocalPlayer?.Session;
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ namespace Content.IntegrationTests.Tests
|
|||||||
var mapManager = server.ResolveDependency<IMapManager>();
|
var mapManager = server.ResolveDependency<IMapManager>();
|
||||||
server.Post(() =>
|
server.Post(() =>
|
||||||
{
|
{
|
||||||
mapLoader.SaveBlueprint(new GridId(2), "save load save 1.yml");
|
// TODO: Un-hardcode the grid Id for this test.
|
||||||
|
mapLoader.SaveBlueprint(new GridId(1), "save load save 1.yml");
|
||||||
var mapId = mapManager.CreateMap();
|
var mapId = mapManager.CreateMap();
|
||||||
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml");
|
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml");
|
||||||
mapLoader.SaveBlueprint(grid.Index, "save load save 2.yml");
|
mapLoader.SaveBlueprint(grid.Index, "save load save 2.yml");
|
||||||
|
|||||||
@@ -42,10 +42,7 @@ namespace Content.Server.Atmos
|
|||||||
[ViewVariables] private int _currentCycle;
|
[ViewVariables] private int _currentCycle;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private static GasTileOverlaySystem _gasTileOverlaySystem;
|
public float Temperature { get; private set; } = Atmospherics.T20C;
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
public float Temperature {get; private set; } = Atmospherics.T20C;
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private float _temperatureArchived = Atmospherics.T20C;
|
private float _temperatureArchived = Atmospherics.T20C;
|
||||||
@@ -1138,8 +1135,7 @@ namespace Content.Server.Atmos
|
|||||||
{
|
{
|
||||||
if (Air == null) return;
|
if (Air == null) return;
|
||||||
|
|
||||||
_gasTileOverlaySystem ??= EntitySystem.Get<GasTileOverlaySystem>();
|
_gridAtmosphereComponent.GasTileOverlaySystem.Invalidate(GridIndex, GridIndices);
|
||||||
_gasTileOverlaySystem.Invalidate(GridIndex, GridIndices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
@@ -75,42 +75,44 @@ namespace Content.Server.Explosions
|
|||||||
|
|
||||||
//Tile damage calculation mockup
|
//Tile damage calculation mockup
|
||||||
//TODO: make it into some sort of actual damage component or whatever the boys think is appropriate
|
//TODO: make it into some sort of actual damage component or whatever the boys think is appropriate
|
||||||
var mapGrid = mapManager.GetGrid(coords.GetGridId(entityManager));
|
if (mapManager.TryGetGrid(coords.GetGridId(entityManager), out var mapGrid))
|
||||||
var circle = new Circle(coords.Position, maxRange);
|
|
||||||
var tiles = mapGrid.GetTilesIntersecting(circle);
|
|
||||||
foreach (var tile in tiles)
|
|
||||||
{
|
{
|
||||||
var tileLoc = mapGrid.GridTileToLocal(tile.GridIndices);
|
var circle = new Circle(coords.Position, maxRange);
|
||||||
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
var tiles = mapGrid?.GetTilesIntersecting(circle);
|
||||||
var baseTurfs = tileDef.BaseTurfs;
|
foreach (var tile in tiles)
|
||||||
if (baseTurfs.Count == 0)
|
|
||||||
{
|
{
|
||||||
continue;
|
var tileLoc = mapGrid.GridTileToLocal(tile.GridIndices);
|
||||||
}
|
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
||||||
|
var baseTurfs = tileDef.BaseTurfs;
|
||||||
|
if (baseTurfs.Count == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tileLoc.TryDistance(entityManager, coords, out var distance))
|
if (!tileLoc.TryDistance(entityManager, coords, out var distance))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var zeroTile = new Tile(tileDefinitionManager[baseTurfs[0]].TileId);
|
var zeroTile = new Tile(tileDefinitionManager[baseTurfs[0]].TileId);
|
||||||
var previousTile = new Tile(tileDefinitionManager[baseTurfs[^1]].TileId);
|
var previousTile = new Tile(tileDefinitionManager[baseTurfs[^1]].TileId);
|
||||||
|
|
||||||
switch (distance)
|
switch (distance)
|
||||||
{
|
{
|
||||||
case var d when d < devastationRange:
|
case var d when d < devastationRange:
|
||||||
mapGrid.SetTile(tileLoc, zeroTile);
|
mapGrid.SetTile(tileLoc, zeroTile);
|
||||||
break;
|
break;
|
||||||
case var d when d < heavyImpactRange
|
case var d when d < heavyImpactRange
|
||||||
&& !previousTile.IsEmpty
|
&& !previousTile.IsEmpty
|
||||||
&& robustRandom.Prob(0.8f):
|
&& robustRandom.Prob(0.8f):
|
||||||
mapGrid.SetTile(tileLoc, previousTile);
|
mapGrid.SetTile(tileLoc, previousTile);
|
||||||
break;
|
break;
|
||||||
case var d when d < lightImpactRange
|
case var d when d < lightImpactRange
|
||||||
&& !previousTile.IsEmpty
|
&& !previousTile.IsEmpty
|
||||||
&& robustRandom.Prob(0.5f):
|
&& robustRandom.Prob(0.5f):
|
||||||
mapGrid.SetTile(tileLoc, previousTile);
|
mapGrid.SetTile(tileLoc, previousTile);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using Content.Server.Atmos;
|
|||||||
using Content.Server.GameObjects.Components.Atmos.Piping;
|
using Content.Server.GameObjects.Components.Atmos.Piping;
|
||||||
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Server.GameObjects.EntitySystems.Atmos;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Maps;
|
using Content.Shared.Maps;
|
||||||
using Robust.Server.GameObjects.EntitySystems.TileLookup;
|
using Robust.Server.GameObjects.EntitySystems.TileLookup;
|
||||||
@@ -39,6 +40,7 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
[Robust.Shared.IoC.Dependency] private IServerEntityManager _serverEntityManager = default!;
|
[Robust.Shared.IoC.Dependency] private IServerEntityManager _serverEntityManager = default!;
|
||||||
|
|
||||||
public GridTileLookupSystem GridTileLookupSystem { get; private set; } = default!;
|
public GridTileLookupSystem GridTileLookupSystem { get; private set; } = default!;
|
||||||
|
internal GasTileOverlaySystem GasTileOverlaySystem { get; private set; } = default!;
|
||||||
public AtmosphereSystem AtmosphereSystem { get; private set; } = default!;
|
public AtmosphereSystem AtmosphereSystem { get; private set; } = default!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -173,10 +175,11 @@ namespace Content.Server.GameObjects.Components.Atmos
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
RepopulateTiles();
|
|
||||||
|
|
||||||
GridTileLookupSystem = EntitySystem.Get<GridTileLookupSystem>();
|
GridTileLookupSystem = EntitySystem.Get<GridTileLookupSystem>();
|
||||||
|
GasTileOverlaySystem = EntitySystem.Get<GasTileOverlaySystem>();
|
||||||
AtmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
AtmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||||
|
|
||||||
|
RepopulateTiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnAdd()
|
public override void OnAdd()
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ namespace Content.Server.GameObjects.Components.Fluids
|
|||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
|
||||||
|
|
||||||
var gridId = coordinates.GetGridId(entityManager);
|
if (!mapManager.TryGetGrid(coordinates.GetGridId(entityManager), out var mapGrid))
|
||||||
var mapGrid = mapManager.GetGrid(gridId);
|
return null; // Let's not spill to space.
|
||||||
|
|
||||||
// If space return early, let that spill go out into the void
|
// If space return early, let that spill go out into the void
|
||||||
var tileRef = mapGrid.GetTileRef(coordinates);
|
var tileRef = mapGrid.GetTileRef(coordinates);
|
||||||
@@ -78,13 +78,11 @@ namespace Content.Server.GameObjects.Components.Fluids
|
|||||||
|
|
||||||
// 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 spillTileMapGrid = mapManager.GetGrid(gridId);
|
var spillGridCoords = mapGrid.GridTileToLocal(tileRef.GridIndices);
|
||||||
var spillTileRef = spillTileMapGrid.GetTileRef(coordinates).GridIndices;
|
|
||||||
var spillGridCoords = spillTileMapGrid.GridTileToLocal(spillTileRef);
|
|
||||||
|
|
||||||
var spilt = false;
|
var spilt = false;
|
||||||
|
|
||||||
foreach (var spillEntity in entityManager.GetEntitiesAt(spillTileMapGrid.ParentMapId, spillGridCoords.Position))
|
foreach (var spillEntity in entityManager.GetEntitiesAt(mapGrid.ParentMapId, spillGridCoords.Position))
|
||||||
{
|
{
|
||||||
if (!spillEntity.TryGetComponent(out PuddleComponent? puddleComponent))
|
if (!spillEntity.TryGetComponent(out PuddleComponent? puddleComponent))
|
||||||
{
|
{
|
||||||
@@ -167,7 +165,9 @@ namespace Content.Server.GameObjects.Components.Fluids
|
|||||||
|
|
||||||
// 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 spillTileMapGrid = mapManager.GetGrid(gridId);
|
if (!mapManager.TryGetGrid(gridId, out var spillTileMapGrid))
|
||||||
|
return null; // Let's not spill to invalid grids.
|
||||||
|
|
||||||
var spillGridCoords = spillTileMapGrid.GridTileToLocal(tileRef.GridIndices);
|
var spillGridCoords = spillTileMapGrid.GridTileToLocal(tileRef.GridIndices);
|
||||||
|
|
||||||
var spilt = false;
|
var spilt = false;
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
if (!Owner.TryGetComponent<ToolComponent>(out var tool) && _toolComponentNeeded)
|
if (!Owner.TryGetComponent<ToolComponent>(out var tool) && _toolComponentNeeded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mapGrid = _mapManager.GetGrid(clickLocation.GetGridId(Owner.EntityManager));
|
if (!_mapManager.TryGetGrid(clickLocation.GetGridId(Owner.EntityManager), out var mapGrid))
|
||||||
|
return;
|
||||||
|
|
||||||
var tile = mapGrid.GetTileRef(clickLocation);
|
var tile = mapGrid.GetTileRef(clickLocation);
|
||||||
|
|
||||||
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
|
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
|
|
||||||
private void SetPowerTransferRange(int newPowerTransferRange)
|
private void SetPowerTransferRange(int newPowerTransferRange)
|
||||||
{
|
{
|
||||||
foreach (var receiver in _linkedReceivers)
|
foreach (var receiver in _linkedReceivers.ToArray())
|
||||||
{
|
{
|
||||||
receiver.ClearProvider();
|
receiver.ClearProvider();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -621,7 +621,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
|||||||
/// <param name="chunk"></param>
|
/// <param name="chunk"></param>
|
||||||
private void GenerateRegions(PathfindingChunk chunk)
|
private void GenerateRegions(PathfindingChunk chunk)
|
||||||
{
|
{
|
||||||
// Grid deleted while update queued.
|
// Grid deleted while update queued, or invalid grid.
|
||||||
if (!_mapManager.TryGetGrid(chunk.GridId, out _))
|
if (!_mapManager.TryGetGrid(chunk.GridId, out _))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -688,7 +688,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
|||||||
private void SendDebugMessage(PlayerAttachSystemMessage message)
|
private void SendDebugMessage(PlayerAttachSystemMessage message)
|
||||||
{
|
{
|
||||||
var playerGrid = message.Entity.Transform.GridID;
|
var playerGrid = message.Entity.Transform.GridID;
|
||||||
SendRegionsDebugMessage(playerGrid);
|
if(playerGrid.IsValid())
|
||||||
|
SendRegionsDebugMessage(playerGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SendRegionsDebugMessage(GridId gridId)
|
private void SendRegionsDebugMessage(GridId gridId)
|
||||||
|
|||||||
@@ -6,24 +6,20 @@ using System.Threading.Tasks;
|
|||||||
using Content.Server.GameObjects.Components;
|
using Content.Server.GameObjects.Components;
|
||||||
using Content.Shared.GameObjects.Components.Damage;
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.Interfaces.Timing;
|
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems.DoAfter
|
namespace Content.Server.GameObjects.EntitySystems.DoAfter
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class DoAfterSystem : EntitySystem
|
public sealed class DoAfterSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPauseManager _pauseManager = default!;
|
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|
||||||
foreach (var comp in ComponentManager.EntityQuery<DoAfterComponent>())
|
foreach (var comp in ComponentManager.EntityQuery<DoAfterComponent>())
|
||||||
{
|
{
|
||||||
if (_pauseManager.IsGridPaused(comp.Owner.Transform.GridID)) continue;
|
if (comp.Owner.Paused) continue;
|
||||||
|
|
||||||
var cancelled = new List<DoAfter>(0);
|
var cancelled = new List<DoAfter>(0);
|
||||||
var finished = new List<DoAfter>(0);
|
var finished = new List<DoAfter>(0);
|
||||||
|
|||||||
@@ -187,21 +187,17 @@ namespace Content.Shared.Maps
|
|||||||
private static Box2 GetWorldTileBox(TileRef turf)
|
private static Box2 GetWorldTileBox(TileRef turf)
|
||||||
{
|
{
|
||||||
var map = IoCManager.Resolve<IMapManager>();
|
var map = IoCManager.Resolve<IMapManager>();
|
||||||
var tileGrid = map.GetGrid(turf.GridIndex);
|
|
||||||
|
|
||||||
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
|
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
|
||||||
var tileBox = Box2.UnitCentered.Scale(tileGrid.TileSize).Scale(0.9f);
|
var tileBox = Box2.UnitCentered.Scale(0.9f);
|
||||||
return tileBox.Translated(tileGrid.GridTileToWorldPos(turf.GridIndices));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
if (map.TryGetGrid(turf.GridIndex, out var tileGrid))
|
||||||
/// Creates a box the size of a tile.
|
{
|
||||||
/// </summary>
|
tileBox = tileBox.Scale(tileGrid.TileSize);
|
||||||
private static Box2 GetTileBox(this TileRef turf)
|
return tileBox.Translated(tileGrid.GridTileToWorldPos(turf.GridIndices));
|
||||||
{
|
}
|
||||||
var map = IoCManager.Resolve<IMapManager>();
|
|
||||||
var tileGrid = map.GetGrid(turf.GridIndex);
|
return tileBox;
|
||||||
return Box2.UnitCentered.Scale(tileGrid.TileSize);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule RobustToolbox updated: e3f2e36ad4...6a9cb790c0
Reference in New Issue
Block a user