diff --git a/Content.Shared/Construction/ConstructionConditions/TileNotBlocked.cs b/Content.Shared/Construction/ConstructionConditions/TileNotBlocked.cs new file mode 100644 index 0000000000..6bc9dd084a --- /dev/null +++ b/Content.Shared/Construction/ConstructionConditions/TileNotBlocked.cs @@ -0,0 +1,32 @@ +using Content.Shared.Maps; +using JetBrains.Annotations; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Map; +using Robust.Shared.Maths; +using Robust.Shared.Serialization; + +namespace Content.Shared.Construction.ConstructionConditions +{ + [UsedImplicitly] + public class TileNotBlocked : IConstructionCondition + { + private bool _filterMobs = false; + private bool _failIfSpace = true; + + public void ExposeData(ObjectSerializer serializer) + { + serializer.DataField(ref _filterMobs, "filterMobs", false); + serializer.DataField(ref _failIfSpace, "failIfSpace", true); + } + + public bool Condition(IEntity user, EntityCoordinates location, Direction direction) + { + var tileRef = location.GetTileRef(); + + if (tileRef == null || tileRef.Value.IsSpace()) + return !_failIfSpace; + + return !tileRef.Value.IsBlockedTurf(_filterMobs); + } + } +} diff --git a/Content.Shared/Construction/ConstructionPrototype.cs b/Content.Shared/Construction/ConstructionPrototype.cs index 17d88a7f9e..ec78912b3f 100644 --- a/Content.Shared/Construction/ConstructionPrototype.cs +++ b/Content.Shared/Construction/ConstructionPrototype.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Utility; diff --git a/Resources/Prototypes/Entities/Constructible/Walls/girder.yml b/Resources/Prototypes/Entities/Constructible/Walls/girder.yml index 1ec2f250fc..71e537adee 100644 --- a/Resources/Prototypes/Entities/Constructible/Walls/girder.yml +++ b/Resources/Prototypes/Entities/Constructible/Walls/girder.yml @@ -6,6 +6,7 @@ - type: Clickable - type: InteractionOutline - type: Anchorable + snap: true - type: Construction graph: girder node: girder @@ -17,13 +18,9 @@ anchored: true shapes: - !type:PhysShapeAabb - mask: - - Impassable - - MobImpassable - - VaultImpassable - - SmallImpassable layer: - Opaque + - Impassable - MobImpassable - VaultImpassable - SmallImpassable diff --git a/Resources/Prototypes/Recipes/Construction/conveyor.yml b/Resources/Prototypes/Recipes/Construction/conveyor.yml index 0eae0c1a5c..30abd3ca51 100644 --- a/Resources/Prototypes/Recipes/Construction/conveyor.yml +++ b/Resources/Prototypes/Recipes/Construction/conveyor.yml @@ -12,6 +12,8 @@ icon: sprite: Constructible/Power/conveyor.rsi state: conveyor_stopped_cw + conditions: + - !type:TileNotBlocked {} - type: construction name: two-way lever @@ -26,3 +28,5 @@ icon: sprite: Constructible/Power/conveyor.rsi state: switch-off + conditions: + - !type:TileNotBlocked {} diff --git a/Resources/Prototypes/Recipes/Construction/structures.yml b/Resources/Prototypes/Recipes/Construction/structures.yml index f192be3132..720c48b34e 100644 --- a/Resources/Prototypes/Recipes/Construction/structures.yml +++ b/Resources/Prototypes/Recipes/Construction/structures.yml @@ -13,6 +13,8 @@ placementMode: SnapgridCenter canRotate: false canBuildInImpassable: false + conditions: + - !type:TileNotBlocked { } - type: construction name: wall @@ -29,6 +31,8 @@ placementMode: SnapgridCenter canRotate: false canBuildInImpassable: false + conditions: + - !type:TileNotBlocked {} - type: construction name: reinforced wall @@ -45,6 +49,8 @@ placementMode: SnapgridCenter canRotate: false canBuildInImpassable: false + conditions: + - !type:TileNotBlocked {} - type: construction name: low wall @@ -55,7 +61,8 @@ category: Structures description: A low wall used for mounting windows. conditions: - - !type:NoWindowsInTile { } + - !type:NoWindowsInTile {} + - !type:TileNotBlocked {} icon: sprite: Constructible/Structures/Walls/low_wall.rsi state: metal @@ -131,6 +138,8 @@ objectType: Structure placementMode: SnapgridCenter canBuildInImpassable: false + conditions: + - !type:TileNotBlocked {} - type: construction name: Table Frame @@ -146,6 +155,8 @@ objectType: Structure placementMode: SnapgridCenter canBuildInImpassable: false + conditions: + - !type:TileNotBlocked {} - type: construction name: Poker Table @@ -161,6 +172,8 @@ objectType: Structure placementMode: SnapgridCenter canBuildInImpassable: false + conditions: + - !type:TileNotBlocked {} - type: construction name: Catwalk @@ -171,6 +184,7 @@ category: Structures description: Just like a lattice. Except it looks better. conditions: + - !type:TileNotBlocked {} - !type:TileType targets: - lattice