2020-12-16 18:18:27 +01:00
|
|
|
using Content.Shared.Maps;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
|
2023-06-15 05:25:29 +03:00
|
|
|
namespace Content.Shared.Construction.Conditions;
|
|
|
|
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
[DataDefinition]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class TileNotBlocked : IConstructionCondition
|
2020-12-16 18:18:27 +01:00
|
|
|
{
|
2023-06-15 05:25:29 +03:00
|
|
|
[DataField("filterMobs")] private bool _filterMobs = false;
|
|
|
|
|
[DataField("failIfSpace")] private bool _failIfSpace = true;
|
|
|
|
|
[DataField("failIfNotSturdy")] private bool _failIfNotSturdy = true;
|
|
|
|
|
|
|
|
|
|
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
|
2020-12-16 18:18:27 +01:00
|
|
|
{
|
2023-06-15 05:25:29 +03:00
|
|
|
var tileRef = location.GetTileRef();
|
2020-12-16 18:18:27 +01:00
|
|
|
|
2023-06-15 05:25:29 +03:00
|
|
|
if (tileRef == null)
|
2020-12-16 18:18:27 +01:00
|
|
|
{
|
2023-06-15 05:25:29 +03:00
|
|
|
return false;
|
|
|
|
|
}
|
2020-12-16 18:18:27 +01:00
|
|
|
|
2023-06-15 05:25:29 +03:00
|
|
|
if (tileRef.Value.IsSpace() && _failIfSpace)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
2020-12-16 18:18:27 +01:00
|
|
|
}
|
2021-11-02 11:24:32 +01:00
|
|
|
|
2023-06-15 05:25:29 +03:00
|
|
|
if (!tileRef.Value.GetContentTileDefinition().Sturdy && _failIfNotSturdy)
|
2021-11-02 11:24:32 +01:00
|
|
|
{
|
2023-06-15 05:25:29 +03:00
|
|
|
return false;
|
2021-11-02 11:24:32 +01:00
|
|
|
}
|
2023-06-15 05:25:29 +03:00
|
|
|
|
|
|
|
|
return !tileRef.Value.IsBlockedTurf(_filterMobs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ConstructionGuideEntry GenerateGuideEntry()
|
|
|
|
|
{
|
|
|
|
|
return new ConstructionGuideEntry
|
|
|
|
|
{
|
|
|
|
|
Localization = "construction-step-condition-tile-not-blocked",
|
|
|
|
|
};
|
2020-12-16 18:18:27 +01:00
|
|
|
}
|
|
|
|
|
}
|