mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Backwards compatible API additions to support removing GridId from content. (#2855)
This commit is contained in:
@@ -95,6 +95,7 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
// TODO: Cache this.
|
||||
public EntityUid? GridUid => _mapManager.TryGetGrid(_gridId, out var mapGrid) ? mapGrid.GridEntityId : null;
|
||||
public EntityUid GridEntityId => _mapManager.TryGetGrid(_gridId, out var mapGrid) ? mapGrid.GridEntityId : EntityUid.Invalid;
|
||||
|
||||
/// <summary>
|
||||
/// Disables or enables to ability to locally rotate the entity. When set it removes any local rotation.
|
||||
|
||||
@@ -225,6 +225,17 @@ namespace Robust.Shared.Map
|
||||
return !IsValid(entityManager) ? null : entityManager.GetComponent<TransformComponent>(EntityId).GridUid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Grid EntityUid these coordinates are on.
|
||||
/// If none of the ancestors are a grid, returns null instead.
|
||||
/// </summary>
|
||||
/// <param name="entityManager"></param>
|
||||
/// <returns>Grid EntityUid this entity is on or null</returns>
|
||||
public EntityUid GetGridEntityId(IEntityManager entityManager)
|
||||
{
|
||||
return !IsValid(entityManager) ? EntityUid.Invalid : entityManager.GetComponent<TransformComponent>(EntityId).GridEntityId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Map Id these coordinates are on.
|
||||
/// If the relative entity is not valid, returns <see cref="MapId.Nullspace"/> instead.
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace Robust.Shared.Map
|
||||
|
||||
IMapGrid CreateGrid(MapId currentMapId, GridId? gridId = null, ushort chunkSize = 16);
|
||||
IMapGrid GetGrid(GridId gridId);
|
||||
IMapGrid GetGrid(EntityUid gridId);
|
||||
bool TryGetGrid(GridId gridId, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
bool GridExists(GridId gridId);
|
||||
IEnumerable<IMapGrid> GetAllMapGrids(MapId mapId);
|
||||
|
||||
@@ -145,6 +145,13 @@ internal partial class MapManager
|
||||
return GetGridComp(euid).Grid;
|
||||
}
|
||||
|
||||
public IMapGrid GetGrid(EntityUid gridId)
|
||||
{
|
||||
DebugTools.Assert(gridId.IsValid());
|
||||
|
||||
return GetGridComp(gridId).Grid;
|
||||
}
|
||||
|
||||
public bool IsGrid(EntityUid uid)
|
||||
{
|
||||
return EntityManager.HasComponent<IMapGridComponent>(uid);
|
||||
|
||||
@@ -188,6 +188,17 @@ namespace Robust.Shared.Map
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsGridPaused(EntityUid gridId)
|
||||
{
|
||||
if (TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
return IsGridPaused(grid);
|
||||
}
|
||||
|
||||
Logger.ErrorS("map", $"Tried to check if unknown grid {gridId} was paused.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsMapInitialized(MapId mapId)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Robust.Shared.Timing
|
||||
@@ -27,6 +28,9 @@ namespace Robust.Shared.Timing
|
||||
|
||||
[Pure]
|
||||
bool IsGridPaused(GridId gridId);
|
||||
|
||||
[Pure]
|
||||
bool IsGridPaused(EntityUid gridId);
|
||||
|
||||
[Pure]
|
||||
bool IsMapInitialized(MapId mapId);
|
||||
|
||||
Reference in New Issue
Block a user