2022-05-13 00:59:03 -07:00
|
|
|
|
using Content.Shared.Maps;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Shared.Construction.Conditions
|
2020-10-08 17:41:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
|
public sealed partial class EmptyOrWindowValidInTile : IConstructionCondition
|
2020-10-08 17:41:23 +02:00
|
|
|
|
{
|
2021-10-15 12:20:10 +02:00
|
|
|
|
[DataField("tileNotBlocked")]
|
2023-08-22 18:14:33 -07:00
|
|
|
|
private TileNotBlocked _tileNotBlocked = new();
|
2021-10-15 12:20:10 +02:00
|
|
|
|
|
2021-12-04 12:59:44 +01:00
|
|
|
|
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
|
2020-10-08 17:41:23 +02:00
|
|
|
|
{
|
2021-10-15 12:20:10 +02:00
|
|
|
|
var result = false;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
2022-12-15 17:29:46 +13:00
|
|
|
|
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Static))
|
2020-10-08 17:41:23 +02:00
|
|
|
|
{
|
2021-12-03 15:53:09 +01:00
|
|
|
|
if (IoCManager.Resolve<IEntityManager>().HasComponent<SharedCanBuildWindowOnTopComponent>(entity))
|
2021-10-15 12:20:10 +02:00
|
|
|
|
result = true;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-10-15 12:20:10 +02:00
|
|
|
|
if (!result)
|
|
|
|
|
|
result = _tileNotBlocked.Condition(user, location, direction);
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
2021-11-02 11:24:32 +01:00
|
|
|
|
|
2022-10-30 02:48:53 -04:00
|
|
|
|
public ConstructionGuideEntry GenerateGuideEntry()
|
2021-11-02 11:24:32 +01:00
|
|
|
|
{
|
2022-10-30 02:48:53 -04:00
|
|
|
|
return new ConstructionGuideEntry
|
2021-11-02 11:24:32 +01:00
|
|
|
|
{
|
|
|
|
|
|
Localization = "construction-guide-condition-empty-or-window-valid-in-tile"
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|