]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Allow storage to specify a default orientation for stored items. (#23594)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Sat, 6 Jan 2024 03:19:01 +0000 (22:19 -0500)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2024 03:19:01 +0000 (14:19 +1100)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Content.Shared/Storage/StorageComponent.cs
Resources/Prototypes/Entities/Clothing/Belt/base_clothingbelt.yml

index 9092bdc7416fd57e734ac765066d098628127cd8..17eb30ad50d4ff53e7d60892c5d300502a1e1967 100644 (file)
@@ -890,11 +890,32 @@ public abstract class SharedStorageSystem : EntitySystem
 
         var storageBounding = storageEnt.Comp.Grid.GetBoundingBox();
 
+        Angle startAngle;
+        if (storageEnt.Comp.DefaultStorageOrientation == null)
+        {
+            startAngle = Angle.FromDegrees(-itemEnt.Comp.StoredRotation);
+        }
+        else
+        {
+            if (storageBounding.Width < storageBounding.Height)
+            {
+                startAngle = storageEnt.Comp.DefaultStorageOrientation == StorageDefaultOrientation.Horizontal
+                    ? Angle.Zero
+                    : Angle.FromDegrees(90);
+            }
+            else
+            {
+                startAngle = storageEnt.Comp.DefaultStorageOrientation == StorageDefaultOrientation.Vertical
+                    ? Angle.Zero
+                    : Angle.FromDegrees(90);
+            }
+        }
+
         for (var y = storageBounding.Bottom; y <= storageBounding.Top; y++)
         {
             for (var x = storageBounding.Left; x <= storageBounding.Right; x++)
             {
-                for (var angle = Angle.FromDegrees(-itemEnt.Comp.StoredRotation); angle <= Angle.FromDegrees(360 - itemEnt.Comp.StoredRotation); angle += Math.PI / 2f)
+                for (var angle = startAngle; angle <= Angle.FromDegrees(360 - startAngle); angle += Math.PI / 2f)
                 {
                     var location = new ItemStorageLocation(angle, (x, y));
                     if (ItemFitsInGridLocation(itemEnt, storageEnt, location))
index e3287b20ad753f54583ff320f1078c6358d760d1..796c9cb5ffa87a2413815ea3941c8537ed6a86aa 100644 (file)
@@ -94,6 +94,14 @@ namespace Content.Shared.Storage
         [DataField("storageCloseSound")]
         public SoundSpecifier? StorageCloseSound;
 
+        /// <summary>
+        /// If not null, ensures that all inserted items are of the same orientation
+        /// Horizontal - items are stored laying down
+        /// Vertical - items are stored standing up
+        /// </summary>
+        [DataField, ViewVariables(VVAccess.ReadWrite)]
+        public StorageDefaultOrientation? DefaultStorageOrientation;
+
         [Serializable, NetSerializable]
         public enum StorageUiKey
         {
@@ -204,4 +212,11 @@ namespace Content.Shared.Storage
         StorageUsed,
         Capacity
     }
+
+    [Serializable, NetSerializable]
+    public enum StorageDefaultOrientation : byte
+    {
+        Horizontal,
+        Vertical
+    }
 }
index 614e739e058dc90ca6083729b1f97d6d07cd5841..2f904d3438cedd5218d03e26aefdae5fa61580f2 100644 (file)
@@ -23,6 +23,7 @@
   components:
   - type: Storage
     maxItemSize: Normal
+    defaultStorageOrientation: Vertical
     grid:
     - 0,0,7,1
   - type: Item