Replace obsolete Tile Access methods (#32508)
* Replace obsolete SetTile * Remove obsolete GetTileRef & GetAllTiles * Forgor * Apply suggested `GetMapOrInvalid`
This commit is contained in:
@@ -35,9 +35,9 @@ public sealed partial class TestPair
|
||||
mapData.GridCoords = new EntityCoordinates(mapData.Grid, 0, 0);
|
||||
var plating = tileDefinitionManager[tile];
|
||||
var platingTile = new Tile(plating.TileId);
|
||||
mapData.Grid.Comp.SetTile(mapData.GridCoords, platingTile);
|
||||
Server.System<SharedMapSystem>().SetTile(mapData.Grid.Owner, mapData.Grid.Comp, mapData.GridCoords, platingTile);
|
||||
mapData.MapCoords = new MapCoordinates(0, 0, mapData.MapId);
|
||||
mapData.Tile = mapData.Grid.Comp.GetAllTiles().First();
|
||||
mapData.Tile = Server.System<SharedMapSystem>().GetAllTiles(mapData.Grid.Owner, mapData.Grid.Comp).First();
|
||||
});
|
||||
|
||||
TestMap = mapData;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Content.Server.Decals
|
||||
[Dependency] private readonly IConfigurationManager _conf = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly MapSystem _mapSystem = default!;
|
||||
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
|
||||
|
||||
private readonly Dictionary<NetEntity, HashSet<Vector2i>> _dirtyChunks = new();
|
||||
private readonly Dictionary<ICommonSession, Dictionary<NetEntity, HashSet<Vector2i>>> _previousSentChunks = new();
|
||||
@@ -106,7 +106,7 @@ namespace Content.Server.Decals
|
||||
return;
|
||||
|
||||
// Transfer decals over to the new grid.
|
||||
var enumerator = Comp<MapGridComponent>(ev.Grid).GetAllTilesEnumerator();
|
||||
var enumerator = _mapSystem.GetAllTilesEnumerator(ev.Grid, Comp<MapGridComponent>(ev.Grid));
|
||||
|
||||
var oldChunkCollection = oldComp.ChunkCollection.ChunkCollection;
|
||||
var chunkCollection = newComp.ChunkCollection.ChunkCollection;
|
||||
|
||||
@@ -29,7 +29,7 @@ public sealed partial class ExplosionSystem
|
||||
Dictionary<Vector2i, NeighborFlag> edges = new();
|
||||
_gridEdges[ev.EntityUid] = edges;
|
||||
|
||||
foreach (var tileRef in grid.GetAllTiles())
|
||||
foreach (var tileRef in _map.GetAllTiles(ev.EntityUid, grid))
|
||||
{
|
||||
if (IsEdge(grid, tileRef.GridIndices, out var dir))
|
||||
edges.Add(tileRef.GridIndices, dir);
|
||||
|
||||
@@ -666,6 +666,7 @@ sealed class Explosion
|
||||
|
||||
private readonly IEntityManager _entMan;
|
||||
private readonly ExplosionSystem _system;
|
||||
private readonly SharedMapSystem _mapSystem;
|
||||
|
||||
public readonly EntityUid VisualEnt;
|
||||
|
||||
@@ -688,11 +689,13 @@ sealed class Explosion
|
||||
IEntityManager entMan,
|
||||
IMapManager mapMan,
|
||||
EntityUid visualEnt,
|
||||
EntityUid? cause)
|
||||
EntityUid? cause,
|
||||
SharedMapSystem mapSystem)
|
||||
{
|
||||
VisualEnt = visualEnt;
|
||||
Cause = cause;
|
||||
_system = system;
|
||||
_mapSystem = mapSystem;
|
||||
ExplosionType = explosionType;
|
||||
_tileSetIntensity = tileSetIntensity;
|
||||
Epicenter = epicenter;
|
||||
@@ -899,7 +902,7 @@ sealed class Explosion
|
||||
{
|
||||
if (list.Count > 0 && _entMan.EntityExists(grid.Owner))
|
||||
{
|
||||
grid.SetTiles(list);
|
||||
_mapSystem.SetTiles(grid.Owner, grid, list);
|
||||
}
|
||||
}
|
||||
_tileUpdateDict.Clear();
|
||||
|
||||
@@ -389,7 +389,8 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
|
||||
EntityManager,
|
||||
_mapManager,
|
||||
visualEnt,
|
||||
queued.Cause);
|
||||
queued.Cause,
|
||||
_map);
|
||||
}
|
||||
|
||||
private void CameraShake(float range, MapCoordinates epicenter, float totalIntensity)
|
||||
|
||||
@@ -25,6 +25,7 @@ public sealed class ImmovableRodSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
@@ -39,7 +40,7 @@ public sealed class ImmovableRodSystem : EntitySystem
|
||||
if (!TryComp<MapGridComponent>(trans.GridUid, out var grid))
|
||||
continue;
|
||||
|
||||
grid.SetTile(trans.Coordinates, Tile.Empty);
|
||||
_map.SetTile(trans.GridUid.Value, grid, trans.Coordinates, Tile.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -962,7 +962,7 @@ public sealed partial class BiomeSystem : SharedBiomeSystem
|
||||
}
|
||||
}
|
||||
|
||||
grid.SetTiles(tiles);
|
||||
_mapSystem.SetTiles(gridUid, grid, tiles);
|
||||
tiles.Clear();
|
||||
component.LoadedChunks.Remove(chunk);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
|
||||
[Dependency] private readonly SharedMindSystem _minds = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ExamineSystemShared _examine = default!;
|
||||
|
||||
@@ -73,8 +74,13 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
}
|
||||
|
||||
// TODO: FOV
|
||||
private void SendMessage(EntityUid source, IEnumerable<ICommonSession> viewers, EntityUid pointed, string selfMessage,
|
||||
string viewerMessage, string? viewerPointedAtMessage = null)
|
||||
private void SendMessage(
|
||||
EntityUid source,
|
||||
IEnumerable<ICommonSession> viewers,
|
||||
EntityUid pointed,
|
||||
string selfMessage,
|
||||
string viewerMessage,
|
||||
string? viewerPointedAtMessage = null)
|
||||
{
|
||||
var netSource = GetNetEntity(source);
|
||||
|
||||
@@ -226,8 +232,8 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
|
||||
if (_mapManager.TryFindGridAt(mapCoordsPointed, out var gridUid, out var grid))
|
||||
{
|
||||
position = $"EntId={gridUid} {grid.WorldToTile(mapCoordsPointed.Position)}";
|
||||
tileRef = grid.GetTileRef(grid.WorldToTile(mapCoordsPointed.Position));
|
||||
position = $"EntId={gridUid} {_map.WorldToTile(gridUid, grid, mapCoordsPointed.Position)}";
|
||||
tileRef = _map.GetTileRef(gridUid, grid, _map.WorldToTile(gridUid, grid, mapCoordsPointed.Position));
|
||||
}
|
||||
|
||||
var tileDef = _tileDefinitionManager[tileRef?.Tile.TypeId ?? 0];
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Content.Server.Power.EntitySystems;
|
||||
public sealed partial class CableSystem
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
private void InitializeCablePlacer()
|
||||
{
|
||||
@@ -26,11 +28,12 @@ public sealed partial class CableSystem
|
||||
if (component.CablePrototypeId == null)
|
||||
return;
|
||||
|
||||
if(!TryComp<MapGridComponent>(args.ClickLocation.GetGridUid(EntityManager), out var grid))
|
||||
if(!TryComp<MapGridComponent>(_transform.GetGrid(args.ClickLocation), out var grid))
|
||||
return;
|
||||
|
||||
var gridUid = _transform.GetGrid(args.ClickLocation)!.Value;
|
||||
var snapPos = grid.TileIndicesFor(args.ClickLocation);
|
||||
var tileDef = (ContentTileDefinition) _tileManager[grid.GetTileRef(snapPos).Tile.TypeId];
|
||||
var tileDef = (ContentTileDefinition) _tileManager[_map.GetTileRef(gridUid, grid,snapPos).Tile.TypeId];
|
||||
|
||||
if (!tileDef.IsSubFloor || !tileDef.Sturdy)
|
||||
return;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.DungeonGenerators;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
@@ -44,7 +42,7 @@ public sealed partial class DungeonSystem
|
||||
}
|
||||
|
||||
var position = new Vector2i(posX, posY);
|
||||
var dungeonUid = _mapManager.GetMapEntityId(mapId);
|
||||
var dungeonUid = _maps.GetMapOrInvalid(mapId);
|
||||
|
||||
if (!TryComp<MapGridComponent>(dungeonUid, out var dungeonGrid))
|
||||
{
|
||||
@@ -118,7 +116,7 @@ public sealed partial class DungeonSystem
|
||||
}
|
||||
|
||||
var mapId = new MapId(mapInt);
|
||||
var mapUid = _mapManager.GetMapEntityId(mapId);
|
||||
var mapUid = _maps.GetMapOrInvalid(mapId);
|
||||
|
||||
if (!_prototype.TryIndex<DungeonRoomPackPrototype>(args[1], out var pack))
|
||||
{
|
||||
@@ -156,7 +154,7 @@ public sealed partial class DungeonSystem
|
||||
}
|
||||
}
|
||||
|
||||
grid.SetTiles(tiles);
|
||||
_maps.SetTiles(mapUid, grid, tiles);
|
||||
shell.WriteLine(Loc.GetString("cmd-dungen_pack_vis"));
|
||||
}
|
||||
|
||||
@@ -174,7 +172,7 @@ public sealed partial class DungeonSystem
|
||||
}
|
||||
|
||||
var mapId = new MapId(mapInt);
|
||||
var mapUid = _mapManager.GetMapEntityId(mapId);
|
||||
var mapUid =_maps.GetMapOrInvalid(mapId);
|
||||
|
||||
if (!_prototype.TryIndex<DungeonPresetPrototype>(args[1], out var preset))
|
||||
{
|
||||
@@ -197,7 +195,7 @@ public sealed partial class DungeonSystem
|
||||
}
|
||||
}
|
||||
|
||||
grid.SetTiles(tiles);
|
||||
_maps.SetTiles(mapUid, grid, tiles);
|
||||
shell.WriteLine(Loc.GetString("cmd-dungen_pack_vis"));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _xformSystem = default!;
|
||||
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
#endregion Dependencies
|
||||
|
||||
@@ -254,7 +255,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
|
||||
|
||||
var ev = new TilesConsumedByEventHorizonEvent(tiles, gridId, grid, hungry, eventHorizon);
|
||||
RaiseLocalEvent(hungry, ref ev);
|
||||
grid.SetTiles(tiles);
|
||||
_mapSystem.SetTiles(gridId, grid, tiles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed class SubFloorHideSystem : SharedSubFloorHideSystem
|
||||
var xform = Transform(uid);
|
||||
|
||||
if (TryComp<MapGridComponent>(xform.GridUid, out var grid)
|
||||
&& HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates)))
|
||||
&& HasFloorCover(xform.GridUid.Value, grid, Map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates)))
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public sealed class BlobFloorPlanBuilderSystem : BaseWorldSystem
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinition = default!;
|
||||
[Dependency] private readonly TileSystem _tiles = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
@@ -25,10 +26,10 @@ public sealed class BlobFloorPlanBuilderSystem : BaseWorldSystem
|
||||
private void OnBlobFloorPlanBuilderStartup(EntityUid uid, BlobFloorPlanBuilderComponent component,
|
||||
ComponentStartup args)
|
||||
{
|
||||
PlaceFloorplanTiles(component, Comp<MapGridComponent>(uid));
|
||||
PlaceFloorplanTiles(uid, component, Comp<MapGridComponent>(uid));
|
||||
}
|
||||
|
||||
private void PlaceFloorplanTiles(BlobFloorPlanBuilderComponent comp, MapGridComponent grid)
|
||||
private void PlaceFloorplanTiles(EntityUid gridUid, BlobFloorPlanBuilderComponent comp, MapGridComponent grid)
|
||||
{
|
||||
// NO MORE THAN TWO ALLOCATIONS THANK YOU VERY MUCH.
|
||||
// TODO: Just put these on a field instead then?
|
||||
@@ -82,7 +83,7 @@ public sealed class BlobFloorPlanBuilderSystem : BaseWorldSystem
|
||||
}
|
||||
}
|
||||
|
||||
grid.SetTiles(taken.Select(x => (x.Key, x.Value)).ToList());
|
||||
_map.SetTiles(gridUid, grid, taken.Select(x => (x.Key, x.Value)).ToList());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ public sealed class SimpleFloorPlanPopulatorSystem : BaseWorldSystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinition = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize()
|
||||
@@ -25,7 +26,7 @@ public sealed class SimpleFloorPlanPopulatorSystem : BaseWorldSystem
|
||||
{
|
||||
var placeables = new List<string?>(4);
|
||||
var grid = Comp<MapGridComponent>(uid);
|
||||
var enumerator = grid.GetAllTilesEnumerator();
|
||||
var enumerator = _map.GetAllTilesEnumerator(uid, grid);
|
||||
while (enumerator.MoveNext(out var tile))
|
||||
{
|
||||
var coords = grid.GridTileToLocal(tile.Value.GridIndices);
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Content.Shared.Friction
|
||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||
[Dependency] private readonly SharedMoverController _mover = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
private EntityQuery<TileFrictionModifierComponent> _frictionQuery;
|
||||
private EntityQuery<TransformComponent> _xformQuery;
|
||||
@@ -185,7 +186,7 @@ namespace Content.Shared.Friction
|
||||
: DefaultFriction;
|
||||
}
|
||||
|
||||
var tile = grid.GetTileRef(xform.Coordinates);
|
||||
var tile = _map.GetTileRef(xform.GridUid.Value, grid, xform.Coordinates);
|
||||
|
||||
// If it's a map but on an empty tile then just assume it has gravity.
|
||||
if (tile.Tile.IsEmpty &&
|
||||
|
||||
@@ -35,6 +35,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambient = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
||||
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -86,7 +87,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
var tile = grid.GetTileRef(xform.Coordinates);
|
||||
var tile = _map.GetTileRef(xform.GridUid.Value, grid, xform.Coordinates);
|
||||
|
||||
// Handle maps being grids (we'll still emit the sound).
|
||||
if (xform.GridUid != xform.MapUid && tile.IsSpace(_tileDefMan))
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Content.Shared.SubFloor
|
||||
{
|
||||
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
||||
[Dependency] protected readonly SharedMapSystem Map = default!;
|
||||
[Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -92,7 +93,7 @@ namespace Content.Shared.SubFloor
|
||||
if (args.NewTile.Tile.IsEmpty)
|
||||
return; // Anything that was here will be unanchored anyways.
|
||||
|
||||
UpdateTile(Comp<MapGridComponent>(args.NewTile.GridUid), args.NewTile.GridIndices);
|
||||
UpdateTile(args.NewTile.GridUid, Comp<MapGridComponent>(args.NewTile.GridUid), args.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -104,25 +105,25 @@ namespace Content.Shared.SubFloor
|
||||
return;
|
||||
|
||||
if (xform.Anchored && TryComp<MapGridComponent>(xform.GridUid, out var grid))
|
||||
component.IsUnderCover = HasFloorCover(grid, grid.TileIndicesFor(xform.Coordinates));
|
||||
component.IsUnderCover = HasFloorCover(xform.GridUid.Value, grid, Map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates));
|
||||
else
|
||||
component.IsUnderCover = false;
|
||||
|
||||
UpdateAppearance(uid, component);
|
||||
}
|
||||
|
||||
public bool HasFloorCover(MapGridComponent grid, Vector2i position)
|
||||
public bool HasFloorCover(EntityUid gridUid, MapGridComponent grid, Vector2i position)
|
||||
{
|
||||
// TODO Redo this function. Currently wires on an asteroid are always "below the floor"
|
||||
var tileDef = (ContentTileDefinition) _tileDefinitionManager[grid.GetTileRef(position).Tile.TypeId];
|
||||
var tileDef = (ContentTileDefinition) _tileDefinitionManager[Map.GetTileRef(gridUid, grid, position).Tile.TypeId];
|
||||
return !tileDef.IsSubFloor;
|
||||
}
|
||||
|
||||
private void UpdateTile(MapGridComponent grid, Vector2i position)
|
||||
private void UpdateTile(EntityUid gridUid, MapGridComponent grid, Vector2i position)
|
||||
{
|
||||
var covered = HasFloorCover(grid, position);
|
||||
var covered = HasFloorCover(gridUid, grid, position);
|
||||
|
||||
foreach (var uid in grid.GetAnchoredEntities(position))
|
||||
foreach (var uid in Map.GetAnchoredEntities(gridUid, grid, position))
|
||||
{
|
||||
if (!TryComp(uid, out SubFloorHideComponent? hideComp))
|
||||
continue;
|
||||
|
||||
@@ -36,6 +36,7 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly TileSystem _tile = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
private static readonly Vector2 CheckRange = new(1f, 1f);
|
||||
|
||||
@@ -132,7 +133,7 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
var tile = mapGrid.GetTileRef(location);
|
||||
var tile = _map.GetTileRef(gridUid, mapGrid, location);
|
||||
var baseTurf = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
|
||||
|
||||
if (HasBaseTurf(currentTileDefinition, baseTurf.ID))
|
||||
@@ -176,7 +177,7 @@ public sealed class FloorTileSystem : EntitySystem
|
||||
|
||||
var random = new System.Random((int) _timing.CurTick.Value);
|
||||
var variant = _tile.PickVariant((ContentTileDefinition) _tileDefinitionManager[tileId], random);
|
||||
mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId, 0, variant));
|
||||
_map.SetTile(gridUid, mapGrid,location.Offset(new Vector2(offset, offset)), new Tile(tileId, 0, variant));
|
||||
|
||||
_audio.PlayPredicted(placeSound, location, user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user