]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Show other speso colours, add larger denominations (Frontier#1496) (#37030)
authorWhatstone <166147148+whatston3@users.noreply.github.com>
Tue, 29 Apr 2025 21:44:47 +0000 (17:44 -0400)
committerGitHub <noreply@github.com>
Tue, 29 Apr 2025 21:44:47 +0000 (14:44 -0700)
16 files changed:
Content.Client/Stack/StackSystem.cs
Content.Shared/Stacks/StackComponent.cs
Content.Shared/Stacks/StackThresholdComponent.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Misc/space_cash.yml
Resources/Textures/Objects/Economy/cash.rsi/cash.png
Resources/Textures/Objects/Economy/cash.rsi/cash_10.png
Resources/Textures/Objects/Economy/cash.rsi/cash_100.png
Resources/Textures/Objects/Economy/cash.rsi/cash_1000.png
Resources/Textures/Objects/Economy/cash.rsi/cash_10000.png [new file with mode: 0644]
Resources/Textures/Objects/Economy/cash.rsi/cash_100000.png [new file with mode: 0644]
Resources/Textures/Objects/Economy/cash.rsi/cash_1000000.png
Resources/Textures/Objects/Economy/cash.rsi/cash_25000.png [new file with mode: 0644]
Resources/Textures/Objects/Economy/cash.rsi/cash_500.png
Resources/Textures/Objects/Economy/cash.rsi/cash_5000.png [new file with mode: 0644]
Resources/Textures/Objects/Economy/cash.rsi/cash_50000.png [new file with mode: 0644]
Resources/Textures/Objects/Economy/cash.rsi/meta.json

index 7e681aeba3e357fa92d8f783f6ef6eec1f1b1718..17e502675cf9295ace264ba601f8f724e2ff6e64 100644 (file)
@@ -66,10 +66,60 @@ namespace Content.Client.Stack
             if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component))
                 hidden = false;
 
+            if (comp.LayerFunction != StackLayerFunction.None)
+                ApplyLayerFunction((uid, comp), ref actual, ref maxCount);
+
             if (comp.IsComposite)
                 _counterSystem.ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
             else
                 _counterSystem.ProcessOpaqueSprite(uid, comp.BaseLayer, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
         }
+
+        /// <summary>
+        /// Adjusts the actual and maxCount to change how stack amounts are displayed.
+        /// </summary>
+        /// <param name="ent">The entity considered.</param>
+        /// <param name="actual">The actual number of items in the stack. Altered depending on the function to run.</param>
+        /// <param name="maxCount">The maximum number of items in the stack. Altered depending on the function to run.</param>
+        /// <returns>Whether or not a function was applied.</returns>
+        private bool ApplyLayerFunction(Entity<StackComponent> ent, ref int actual, ref int maxCount)
+        {
+            switch (ent.Comp.LayerFunction)
+            {
+                case StackLayerFunction.Threshold:
+                    if (TryComp<StackLayerThresholdComponent>(ent, out var threshold))
+                    {
+                        ApplyThreshold(threshold, ref actual, ref maxCount);
+                        return true;
+                    }
+                    break;
+            }
+            // No function applied.
+            return false;
+        }
+
+        /// <summary>
+        /// Selects which layer a stack applies based on a list of thresholds.
+        /// Each threshold passed results in the next layer being selected.
+        /// </summary>
+        /// <param name="comp">The threshold parameters to apply.</param>
+        /// <param name="actual">The number of items in the stack. Will be set to the index of the layer to use.</param>
+        /// <param name="maxCount">The maximum possible number of items in the stack. Will be set to the number of selectable layers.</param>
+        private static void ApplyThreshold(StackLayerThresholdComponent comp, ref int actual, ref int maxCount)
+        {
+            // We must stop before we run out of thresholds or layers, whichever's smaller. 
+            maxCount = Math.Min(comp.Thresholds.Count + 1, maxCount);
+            var newActual = 0;
+            foreach (var threshold in comp.Thresholds)
+            {
+                //If our value exceeds threshold, the next layer should be displayed.
+                //Note: we must ensure actual <= MaxCount.
+                if (actual >= threshold && newActual < maxCount)
+                    newActual++;
+                else
+                    break;
+            }
+            actual = newActual;
+        }
     }
 }
index 7137f8c0c221c18ff86d1a42f0c8dd2993b9c84e..356b888606c117e199ba1a4d25bb5b950e70e3d8 100644 (file)
@@ -78,6 +78,13 @@ namespace Content.Shared.Stacks
         [DataField("layerStates")]
         [ViewVariables(VVAccess.ReadWrite)]
         public List<string> LayerStates = new();
+
+        /// <summary>
+        /// An optional function to convert the amounts used to adjust a stack's appearance.
+        /// Useful for different denominations of cash, for example.
+        /// </summary>
+        [DataField]
+        public StackLayerFunction LayerFunction = StackLayerFunction.None;
     }
 
     [Serializable, NetSerializable]
@@ -95,4 +102,19 @@ namespace Content.Shared.Stacks
             Lingering = lingering;
         }
     }
+
+    [Serializable, NetSerializable]
+    public enum StackLayerFunction : byte
+    {
+        // <summary>
+        // No operation performed.
+        // </summary>
+        None,
+
+        // <summary>
+        // Arbitrarily thresholds the stack amount for each layer.
+        // Expects entity to have StackLayerThresholdComponent.
+        // </summary>
+        Threshold
+    }
 }
diff --git a/Content.Shared/Stacks/StackThresholdComponent.cs b/Content.Shared/Stacks/StackThresholdComponent.cs
new file mode 100644 (file)
index 0000000..5d142b5
--- /dev/null
@@ -0,0 +1,19 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Stacks;
+
+/// <summary>
+/// Denotes an item as having thresholded stack visuals.
+/// StackComponent.LayerFunction should be set to Threshold to use this in practice.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class StackLayerThresholdComponent : Component
+{
+    /// <summary>
+    /// A list of thresholds to check against the number of things in the stack.
+    /// Each exceeded threshold will cause the next layer to be displayed.
+    /// Should be sorted in ascending order.
+    /// </summary>
+    [DataField(required: true)]
+    public List<int> Thresholds = new();
+}
index 57dfb400984fc6d320a41f8302c505ddf8f1767f..db08a70202a58bde83ee84993990b46565a94f21 100644 (file)
     - cash_100
     - cash_500
     - cash_1000
+    - cash_5000
+    - cash_10000
+    - cash_25000
+    - cash_50000
+    - cash_100000
     - cash_1000000
+    layerFunction: Threshold
+  - type: StackLayerThreshold
+    thresholds: [10, 100, 500, 1000, 5000, 10000, 25000, 50000, 100000, 1000000]
   - type: Sprite
     sprite: Objects/Economy/cash.rsi
     state: cash
   components:
   - type: Icon
     sprite: Objects/Economy/cash.rsi
-    state: cash_1000
+    state: cash_5000
   - type: Stack
     count: 5000
 
   components:
   - type: Icon
     sprite: Objects/Economy/cash.rsi
-    state: cash_1000
+    state: cash_10000
   - type: Stack
     count: 10000
 
   components:
   - type: Icon
     sprite: Objects/Economy/cash.rsi
-    state: cash_1000
+    state: cash_10000
   - type: Stack
     count: 20000
 
   components:
   - type: Icon
     sprite: Objects/Economy/cash.rsi
-    state: cash_1000
+    state: cash_25000
   - type: Stack
     count: 30000
 
index 42e7b863e685d9974b0f2cf88fe948c507cc45d9..7ce8d6fd7b6e2cf6e729971c81b4866e5951c0dd 100644 (file)
Binary files a/Resources/Textures/Objects/Economy/cash.rsi/cash.png and b/Resources/Textures/Objects/Economy/cash.rsi/cash.png differ
index 05c477501682b5b2bd84e241465690655a617e43..98b572646a21718c1a99f431317cd2831847d856 100644 (file)
Binary files a/Resources/Textures/Objects/Economy/cash.rsi/cash_10.png and b/Resources/Textures/Objects/Economy/cash.rsi/cash_10.png differ
index 5862df67911ce2da6e85c5123eeb62f753eb3812..bd1586a7b5a1f0d82f62af820369e9aa04ff5641 100644 (file)
Binary files a/Resources/Textures/Objects/Economy/cash.rsi/cash_100.png and b/Resources/Textures/Objects/Economy/cash.rsi/cash_100.png differ
index 6a5688cd866d413a9e40239c01388bd43c060164..6271c90e99b574eec91284b598c58f15ffbdecb9 100644 (file)
Binary files a/Resources/Textures/Objects/Economy/cash.rsi/cash_1000.png and b/Resources/Textures/Objects/Economy/cash.rsi/cash_1000.png differ
diff --git a/Resources/Textures/Objects/Economy/cash.rsi/cash_10000.png b/Resources/Textures/Objects/Economy/cash.rsi/cash_10000.png
new file mode 100644 (file)
index 0000000..8038bb5
Binary files /dev/null and b/Resources/Textures/Objects/Economy/cash.rsi/cash_10000.png differ
diff --git a/Resources/Textures/Objects/Economy/cash.rsi/cash_100000.png b/Resources/Textures/Objects/Economy/cash.rsi/cash_100000.png
new file mode 100644 (file)
index 0000000..26b4e80
Binary files /dev/null and b/Resources/Textures/Objects/Economy/cash.rsi/cash_100000.png differ
index 389f00ce1593c4b2949549e763bd4050733f6379..7077bf99f8937bd749549d9f750c47597e5f2804 100644 (file)
Binary files a/Resources/Textures/Objects/Economy/cash.rsi/cash_1000000.png and b/Resources/Textures/Objects/Economy/cash.rsi/cash_1000000.png differ
diff --git a/Resources/Textures/Objects/Economy/cash.rsi/cash_25000.png b/Resources/Textures/Objects/Economy/cash.rsi/cash_25000.png
new file mode 100644 (file)
index 0000000..b0f705a
Binary files /dev/null and b/Resources/Textures/Objects/Economy/cash.rsi/cash_25000.png differ
index 5d68d914bfe725f19216c45bc268dc6376d0946f..ff3644af85cbea78268a8165e6a1d57ca1154d31 100644 (file)
Binary files a/Resources/Textures/Objects/Economy/cash.rsi/cash_500.png and b/Resources/Textures/Objects/Economy/cash.rsi/cash_500.png differ
diff --git a/Resources/Textures/Objects/Economy/cash.rsi/cash_5000.png b/Resources/Textures/Objects/Economy/cash.rsi/cash_5000.png
new file mode 100644 (file)
index 0000000..ba5aeaa
Binary files /dev/null and b/Resources/Textures/Objects/Economy/cash.rsi/cash_5000.png differ
diff --git a/Resources/Textures/Objects/Economy/cash.rsi/cash_50000.png b/Resources/Textures/Objects/Economy/cash.rsi/cash_50000.png
new file mode 100644 (file)
index 0000000..160e07a
Binary files /dev/null and b/Resources/Textures/Objects/Economy/cash.rsi/cash_50000.png differ
index bd7b30e211e84d4af3f533c360f8beb53889f9f4..11f8b13b165cefdb1284f0bb242351095cb88eb8 100644 (file)
 {
-  "version": 1,
-  "size": {
-    "x": 32,
-    "y": 32
-  },
-  "license": "CC-BY-NC-SA-3.0",
-  "copyright": "Modified by EmoGarbage404 and taken from https://github.com/goonstation/goonstation at commit b951a2c12d967af1295a3e6d33a861e7e1f21299.",
-  "states": [
-    {
-      "name": "cash"
+    "version": 1,
+    "size": {
+        "x": 32,
+        "y": 32
     },
-    {
-      "name": "cash_10"
-    },
-    {
-      "name": "cash_100"
-    },
-    {
-      "name": "cash_500"
-    },
-    {
-      "name": "cash_1000"
-    },
-    {
-      "name": "cash_1000000",
-      "delays": [
-        [
-          0.2,
-          0.2,
-          0.2,
-          0.2,
-          0.2,
-          0.2,
-          0.2,
-          0.2,
-          0.2,
-          0.2
-        ]
-      ]
-    }
-  ]
+    "license": "CC-BY-NC-SA-3.0",
+    "copyright": "Modified by EmoGarbage404 and taken from https://github.com/goonstation/goonstation at commit b951a2c12d967af1295a3e6d33a861e7e1f21299. cash_5k/10k/25k/50k/1M modified by whatston3, cash_100000 modified by Unkn0wnGh0st333.",
+    "states": [
+        {
+            "name": "cash"
+        },
+        {
+            "name": "cash_10"
+        },
+        {
+            "name": "cash_100"
+        },
+        {
+            "name": "cash_500"
+        },
+        {
+            "name": "cash_1000"
+        },
+        {
+            "name": "cash_5000"
+        },
+        {
+            "name": "cash_10000",
+            "delays": [
+                [
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2
+                ]
+            ]
+        },
+        {
+            "name": "cash_25000",
+            "delays": [
+                [
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2
+                ]
+            ]
+        },
+        {
+            "name": "cash_50000",
+            "delays": [
+                [
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2
+                ]
+            ]
+        },
+        {
+            "name": "cash_100000",
+            "delays": [
+                [
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2
+                ]
+            ]
+        },
+        {
+            "name": "cash_1000000",
+            "delays": [
+                [
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2,
+                    0.2
+                ]
+            ]
+        }
+    ]
 }