Files
tbd-station-14/Content.Shared/Construction/SharedConstructionSystem.cs
Tayrtahn 3f9670f792 Cleanup remaining MapGridComponent.GetAnchoredEntities(MapCoordinates) uses (#37729)
Cleanup remaining MapGridComponent.GetAnchoredEntities uses
2025-05-22 21:42:47 -04:00

40 lines
1.4 KiB
C#

using System.Linq;
using Content.Shared.Construction.Components;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using static Content.Shared.Interaction.SharedInteractionSystem;
namespace Content.Shared.Construction
{
public abstract class SharedConstructionSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly SharedMapSystem _map = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
/// <summary>
/// Get predicate for construction obstruction checks.
/// </summary>
public Ignored? GetPredicate(bool canBuildInImpassable, MapCoordinates coords)
{
if (!canBuildInImpassable)
return null;
if (!_mapManager.TryFindGridAt(coords, out var gridUid, out var grid))
return null;
var ignored = _map.GetAnchoredEntities((gridUid, grid), coords).ToHashSet();
return e => ignored.Contains(e);
}
public string GetExamineName(GenericPartInfo info)
{
if (info.ExamineName is not null)
return Loc.GetString(info.ExamineName.Value);
return PrototypeManager.Index(info.DefaultPrototype).Name;
}
}
}