2022-02-17 15:40:03 +13:00
|
|
|
using System.Linq;
|
2024-06-05 16:23:23 -04:00
|
|
|
using Content.Shared.Construction.Components;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.Map;
|
2024-06-05 16:23:23 -04:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-02-17 15:40:03 +13:00
|
|
|
using static Content.Shared.Interaction.SharedInteractionSystem;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Construction
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public abstract class SharedConstructionSystem : EntitySystem
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2025-02-21 00:12:12 +11:00
|
|
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
2025-05-22 21:42:47 -04:00
|
|
|
[Dependency] private readonly SharedMapSystem _map = default!;
|
2024-06-05 16:23:23 -04:00
|
|
|
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
2025-02-07 03:49:22 -08:00
|
|
|
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
|
2022-02-17 15:40:03 +13:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get predicate for construction obstruction checks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Ignored? GetPredicate(bool canBuildInImpassable, MapCoordinates coords)
|
|
|
|
|
{
|
|
|
|
|
if (!canBuildInImpassable)
|
|
|
|
|
return null;
|
|
|
|
|
|
2025-05-22 21:42:47 -04:00
|
|
|
if (!_mapManager.TryFindGridAt(coords, out var gridUid, out var grid))
|
2022-02-17 15:40:03 +13:00
|
|
|
return null;
|
|
|
|
|
|
2025-05-22 21:42:47 -04:00
|
|
|
var ignored = _map.GetAnchoredEntities((gridUid, grid), coords).ToHashSet();
|
2022-02-17 15:40:03 +13:00
|
|
|
return e => ignored.Contains(e);
|
|
|
|
|
}
|
2024-06-05 16:23:23 -04:00
|
|
|
|
|
|
|
|
public string GetExamineName(GenericPartInfo info)
|
|
|
|
|
{
|
|
|
|
|
if (info.ExamineName is not null)
|
|
|
|
|
return Loc.GetString(info.ExamineName.Value);
|
|
|
|
|
|
|
|
|
|
return PrototypeManager.Index(info.DefaultPrototype).Name;
|
|
|
|
|
}
|
2018-08-02 08:29:55 +02:00
|
|
|
}
|
|
|
|
|
}
|