From 04b2dab4e9638227441b0b2230aa326ffb65f466 Mon Sep 17 00:00:00 2001
From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Fri, 19 May 2023 14:39:37 +0000
Subject: [PATCH] Revert no device stacking (#16608)
---
.../Atmos/UI/GasFilterBoundUserInterface.cs | 2 +
Content.Client/Atmos/UI/GasFilterWindow.xaml | 2 +-
.../Construction/ConstructionSystem.cs | 30 ++----------
.../Construction/AnchorableSystem.cs | 25 +---------
.../Conditions/NoUnstackableInTile.cs | 44 -----------------
.../Conditions/NoWindowsInTile.cs | 3 +-
.../conditions/no-unstackable-in-tile.ftl | 1 -
.../Structures/Piping/Atmospherics/binary.yml | 3 --
.../Piping/Atmospherics/trinary.yml | 11 -----
.../Recipes/Construction/utilities.yml | 47 +------------------
Resources/Prototypes/tags.yml | 3 --
11 files changed, 12 insertions(+), 159 deletions(-)
delete mode 100644 Content.Shared/Construction/Conditions/NoUnstackableInTile.cs
delete mode 100644 Resources/Locale/en-US/construction/conditions/no-unstackable-in-tile.ftl
diff --git a/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs b/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs
index 6c16881224..a0daf9c654 100644
--- a/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs
+++ b/Content.Client/Atmos/UI/GasFilterBoundUserInterface.cs
@@ -14,6 +14,7 @@ namespace Content.Client.Atmos.UI
{
private GasFilterWindow? _window;
+ private const float MaxTransferRate = Atmospherics.MaxTransferRate;
public GasFilterBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
@@ -48,6 +49,7 @@ namespace Content.Client.Atmos.UI
private void OnFilterTransferRatePressed(string value)
{
float rate = float.TryParse(value, out var parsed) ? parsed : 0f;
+ if (rate > MaxTransferRate) rate = MaxTransferRate;
SendMessage(new GasFilterChangeRateMessage(rate));
}
diff --git a/Content.Client/Atmos/UI/GasFilterWindow.xaml b/Content.Client/Atmos/UI/GasFilterWindow.xaml
index 6963a71d3d..30333b07bd 100644
--- a/Content.Client/Atmos/UI/GasFilterWindow.xaml
+++ b/Content.Client/Atmos/UI/GasFilterWindow.xaml
@@ -9,7 +9,7 @@
-
+
diff --git a/Content.Client/Construction/ConstructionSystem.cs b/Content.Client/Construction/ConstructionSystem.cs
index b91db740af..8a7e0be06d 100644
--- a/Content.Client/Construction/ConstructionSystem.cs
+++ b/Content.Client/Construction/ConstructionSystem.cs
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
-using Content.Client.Popups;
using Content.Shared.Construction;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Examine;
@@ -25,7 +24,6 @@ namespace Content.Client.Construction
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
- [Dependency] private readonly PopupSystem _popupSystem = default!;
private readonly Dictionary _ghosts = new();
private readonly Dictionary _guideCache = new();
@@ -190,8 +188,11 @@ namespace Content.Client.Construction
if (!_interactionSystem.InRangeUnobstructed(user, loc, 20f, predicate: predicate))
return false;
- if (!CheckConstructionConditions(prototype, loc, dir, user))
- return false;
+ foreach (var condition in prototype.Conditions)
+ {
+ if (!condition.Condition(user, loc, dir))
+ return false;
+ }
ghost = EntityManager.SpawnEntity("constructionghost", loc);
var comp = EntityManager.GetComponent(ghost.Value);
@@ -216,27 +217,6 @@ namespace Content.Client.Construction
return true;
}
- private bool CheckConstructionConditions(ConstructionPrototype prototype, EntityCoordinates loc, Direction dir,
- EntityUid user)
- {
- foreach (var condition in prototype.Conditions)
- {
- if (!condition.Condition(user, loc, dir))
- {
- var message = condition.GenerateGuideEntry()?.Localization;
- if (message != null)
- {
- // Show the reason to the user:
- _popupSystem.PopupCoordinates(Loc.GetString(message), loc);
- }
-
- return false;
- }
- }
-
- return true;
- }
-
///
/// Checks if any construction ghosts are present at the given position
///
diff --git a/Content.Server/Construction/AnchorableSystem.cs b/Content.Server/Construction/AnchorableSystem.cs
index 40b9749f45..a6583f9fc4 100644
--- a/Content.Server/Construction/AnchorableSystem.cs
+++ b/Content.Server/Construction/AnchorableSystem.cs
@@ -1,16 +1,13 @@
using Content.Server.Administration.Logs;
-using Content.Server.Construction.Components;
using Content.Server.Coordinates.Helpers;
using Content.Server.Popups;
using Content.Server.Pulling;
using Content.Shared.Construction.Components;
-using Content.Shared.Construction.Conditions;
using Content.Shared.Construction.EntitySystems;
using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
using Content.Shared.Pulling.Components;
-using Content.Shared.Tag;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Robust.Shared.Map;
@@ -27,7 +24,6 @@ namespace Content.Server.Construction
[Dependency] private readonly SharedToolSystem _tool = default!;
[Dependency] private readonly PullingSystem _pulling = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
- [Dependency] private readonly TagSystem _tagSystem = default!;
public override void Initialize()
{
@@ -89,26 +85,7 @@ namespace Content.Server.Construction
// TODO: Anchoring snaps rn anyway!
if (component.Snap)
{
- var coordinates = xform.Coordinates.SnapToGrid(EntityManager, _mapManager);
-
- if (_tagSystem.HasTag(uid, "Unstackable"))
- {
- // Need to enforce the unstackable rules on anchoring also.
- var condition = new NoUnstackableInTile();
- if (NoUnstackableInTile.AnyUnstackableTiles(coordinates, _tagSystem))
- {
- var message = condition.GenerateGuideEntry()?.Localization;
- if (message != null)
- {
- // Show the reason to the user:
- _popup.PopupEntity(Loc.GetString(message), uid, args.User);
- }
-
- return;
- }
- }
-
- _transform.SetCoordinates(uid, coordinates);
+ _transform.SetCoordinates(uid, xform.Coordinates.SnapToGrid(EntityManager, _mapManager));
}
RaiseLocalEvent(uid, new BeforeAnchoredEvent(args.User, used));
diff --git a/Content.Shared/Construction/Conditions/NoUnstackableInTile.cs b/Content.Shared/Construction/Conditions/NoUnstackableInTile.cs
deleted file mode 100644
index b51c985a37..0000000000
--- a/Content.Shared/Construction/Conditions/NoUnstackableInTile.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using Content.Shared.Maps;
-using Content.Shared.Tag;
-using JetBrains.Annotations;
-using Robust.Shared.Map;
-
-namespace Content.Shared.Construction.Conditions
-{
- [UsedImplicitly]
- [DataDefinition]
- public sealed class NoUnstackableInTile : IConstructionCondition
- {
- public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
- {
- var tagSystem = IoCManager.Resolve().GetEntitySystem();
-
- if (AnyUnstackableTiles(location, tagSystem))
- return false;
-
- return true;
- }
-
- public static bool AnyUnstackableTiles(EntityCoordinates location, TagSystem tagSystem)
- {
- var lookup = IoCManager.Resolve().GetEntitySystem();
-
- foreach (var entity in lookup.GetEntitiesIntersecting(location, LookupFlags.Approximate | LookupFlags.Static |
- LookupFlags.Sundries))
- {
- if (tagSystem.HasTag(entity, "Unstackable"))
- return true;
- }
-
- return false;
- }
-
- public ConstructionGuideEntry GenerateGuideEntry()
- {
- return new ConstructionGuideEntry
- {
- Localization = "construction-step-condition-no-unstackable-in-tile"
- };
- }
- }
-}
diff --git a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs
index 6b71c33ee3..4a409a998e 100644
--- a/Content.Shared/Construction/Conditions/NoWindowsInTile.cs
+++ b/Content.Shared/Construction/Conditions/NoWindowsInTile.cs
@@ -12,9 +12,8 @@ namespace Content.Shared.Construction.Conditions
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
{
var tagSystem = IoCManager.Resolve().GetEntitySystem();
- var lookup = IoCManager.Resolve().GetEntitySystem();
- foreach (var entity in lookup.GetEntitiesIntersecting(location, LookupFlags.Approximate | LookupFlags.Static))
+ foreach (var entity in location.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Static))
{
if (tagSystem.HasTag(entity, "Window"))
return false;
diff --git a/Resources/Locale/en-US/construction/conditions/no-unstackable-in-tile.ftl b/Resources/Locale/en-US/construction/conditions/no-unstackable-in-tile.ftl
deleted file mode 100644
index 37ce0de9e8..0000000000
--- a/Resources/Locale/en-US/construction/conditions/no-unstackable-in-tile.ftl
+++ /dev/null
@@ -1 +0,0 @@
-construction-step-condition-no-unstackable-in-tile = You cannot make a stack of similar devices.
diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml
index 82fe6e54c9..e1ef0251c5 100644
--- a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml
+++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/binary.yml
@@ -6,9 +6,6 @@
mode: SnapgridCenter
components:
- type: AtmosDevice
- - type: Tag
- tags:
- - Unstackable
- type: SubFloorHide
blockInteractions: false
blockAmbience: false
diff --git a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/trinary.yml b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/trinary.yml
index 0facc10f3a..adcb622636 100644
--- a/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/trinary.yml
+++ b/Resources/Prototypes/Entities/Structures/Piping/Atmospherics/trinary.yml
@@ -6,9 +6,6 @@
mode: SnapgridCenter
components:
- type: AtmosDevice
- - type: Tag
- tags:
- - Unstackable
- type: SubFloorHide
blockInteractions: false
blockAmbience: false
@@ -58,16 +55,11 @@
type: GasFilterBoundUserInterface
- type: GasFilter
enabled: false
- transferRate: 1000
- maxTransferRate: 1000
- type: Flippable
mirrorEntity: GasFilterFlipped
- type: Construction
graph: GasTrinary
node: filter
- conditions:
- - !type:TileNotBlocked
- - !type:NoUnstackableInTile
- type: AmbientSound
enabled: false
volume: -9
@@ -213,9 +205,6 @@
mode: SnapgridCenter
components:
- type: AtmosDevice
- - type: Tag
- tags:
- - Unstackable
- type: SubFloorHide
blockInteractions: false
blockAmbience: false
diff --git a/Resources/Prototypes/Recipes/Construction/utilities.yml b/Resources/Prototypes/Recipes/Construction/utilities.yml
index 4984ce08a5..f46dd2989d 100644
--- a/Resources/Prototypes/Recipes/Construction/utilities.yml
+++ b/Resources/Prototypes/Recipes/Construction/utilities.yml
@@ -516,7 +516,6 @@
state: pumpPressure
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
name: volumetric gas pump
@@ -538,7 +537,6 @@
state: pumpVolume
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
id: GasPassiveGate
@@ -560,7 +558,6 @@
state: pumpPassiveGate
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
id: GasValve
@@ -582,7 +579,6 @@
state: pumpManualValve
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
id: SignalControlledValve
@@ -604,7 +600,6 @@
state: pumpSignalValve
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
id: GasPort
@@ -626,7 +621,6 @@
state: gasCanisterPort
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
id: GasDualPortVentPump
@@ -684,24 +678,6 @@
mirror: GasFilter
conditions:
- !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
-
-- type: construction
- id: GasFilterFlipped
- name: gas filter [flipped]
- description: Very useful for filtering gases.
- graph: GasTrinary
- startNode: start
- targetNode: filter
- category: construction-category-utilities
- placementMode: SnapgridCenter
- canBuildInImpassable: false
- icon:
- sprite: Structures/Piping/Atmospherics/gasfilter.rsi
- state: gasFilterF
- conditions:
- - !type:TileNotBlocked {}
- - !type:NoUnstackableInTile
- type: construction
id: GasMixer
@@ -736,25 +712,7 @@
state: gasMixerF
mirror: GasMixer
conditions:
- - !type:TileNotBlocked
- - !type:NoUnstackableInTile
-
-- type: construction
- id: GasMixerFlipped
- name: gas mixer [flipped]
- description: Very useful for mixing gases.
- graph: GasTrinary
- startNode: start
- targetNode: mixer
- category: construction-category-utilities
- placementMode: SnapgridCenter
- canBuildInImpassable: false
- icon:
- sprite: Structures/Piping/Atmospherics/gasmixer.rsi
- state: gasMixerF
- conditions:
- - !type:TileNotBlocked
- - !type:NoUnstackableInTile
+ - !type:TileNotBlocked {}
- type: construction
id: PressureControlledValve
@@ -770,8 +728,7 @@
sprite: Structures/Piping/Atmospherics/pneumaticvalve.rsi
state: off
conditions:
- - !type:TileNotBlocked
- - !type:NoUnstackableInTile
+ - !type:TileNotBlocked {}
# INTERCOM
- type: construction
diff --git a/Resources/Prototypes/tags.yml b/Resources/Prototypes/tags.yml
index 35095fae48..d9720e1912 100644
--- a/Resources/Prototypes/tags.yml
+++ b/Resources/Prototypes/tags.yml
@@ -694,9 +694,6 @@
- type: Tag
id: TrashBag
-- type: Tag
- id: Unstackable # To prevent things like atmos devices (filters etc) being stacked on one tile. See NoUnstackableInTile
-
- type: Tag
id: VehicleKey