mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
Replace obsolete Tile Access methods (#32508)
* Replace obsolete SetTile * Remove obsolete GetTileRef & GetAllTiles * Forgor * Apply suggested `GetMapOrInvalid` (cherry picked from commit 1b9d77a76078668ceb15acebf777fae05167ea83)
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -400,7 +400,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -974,7 +974,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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
@@ -89,7 +90,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))
|
||||
|
||||
@@ -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