2021-11-02 11:24:32 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Content.Shared.Maps;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 12:23:18 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
using Robust.Shared.Maths;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
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]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class EmptyOrWindowValidInTile : IConstructionCondition
|
2020-10-08 17:41:23 +02:00
|
|
|
|
{
|
2021-10-15 12:20:10 +02:00
|
|
|
|
[DataField("tileNotBlocked")]
|
|
|
|
|
|
private readonly TileNotBlocked _tileNotBlocked = new();
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-08-29 14:23:11 +10:00
|
|
|
|
foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.IncludeAnchored))
|
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
|
|
|
|
|
|
|
|
|
|
public ConstructionGuideEntry? GenerateGuideEntry()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new ConstructionGuideEntry()
|
|
|
|
|
|
{
|
|
|
|
|
|
Localization = "construction-guide-condition-empty-or-window-valid-in-tile"
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|