Show other speso colours, add larger denominations (Frontier#1496) (#37030)

This commit is contained in:
Whatstone
2025-04-29 17:44:47 -04:00
committed by GitHub
parent 87d097bb5d
commit afc55d6573
16 changed files with 236 additions and 44 deletions

View File

@@ -66,10 +66,60 @@ namespace Content.Client.Stack
if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component)) if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component))
hidden = false; hidden = false;
if (comp.LayerFunction != StackLayerFunction.None)
ApplyLayerFunction((uid, comp), ref actual, ref maxCount);
if (comp.IsComposite) if (comp.IsComposite)
_counterSystem.ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite); _counterSystem.ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
else else
_counterSystem.ProcessOpaqueSprite(uid, comp.BaseLayer, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite); _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;
}
} }
} }

View File

@@ -78,6 +78,13 @@ namespace Content.Shared.Stacks
[DataField("layerStates")] [DataField("layerStates")]
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public List<string> LayerStates = new(); 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] [Serializable, NetSerializable]
@@ -95,4 +102,19 @@ namespace Content.Shared.Stacks
Lingering = lingering; 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
}
} }

View File

@@ -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();
}

View File

@@ -25,7 +25,15 @@
- cash_100 - cash_100
- cash_500 - cash_500
- cash_1000 - cash_1000
- cash_5000
- cash_10000
- cash_25000
- cash_50000
- cash_100000
- cash_1000000 - cash_1000000
layerFunction: Threshold
- type: StackLayerThreshold
thresholds: [10, 100, 500, 1000, 5000, 10000, 25000, 50000, 100000, 1000000]
- type: Sprite - type: Sprite
sprite: Objects/Economy/cash.rsi sprite: Objects/Economy/cash.rsi
state: cash state: cash
@@ -121,7 +129,7 @@
components: components:
- type: Icon - type: Icon
sprite: Objects/Economy/cash.rsi sprite: Objects/Economy/cash.rsi
state: cash_1000 state: cash_5000
- type: Stack - type: Stack
count: 5000 count: 5000
@@ -132,7 +140,7 @@
components: components:
- type: Icon - type: Icon
sprite: Objects/Economy/cash.rsi sprite: Objects/Economy/cash.rsi
state: cash_1000 state: cash_10000
- type: Stack - type: Stack
count: 10000 count: 10000
@@ -143,7 +151,7 @@
components: components:
- type: Icon - type: Icon
sprite: Objects/Economy/cash.rsi sprite: Objects/Economy/cash.rsi
state: cash_1000 state: cash_10000
- type: Stack - type: Stack
count: 20000 count: 20000
@@ -154,7 +162,7 @@
components: components:
- type: Icon - type: Icon
sprite: Objects/Economy/cash.rsi sprite: Objects/Economy/cash.rsi
state: cash_1000 state: cash_25000
- type: Stack - type: Stack
count: 30000 count: 30000

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 375 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

View File

@@ -5,7 +5,7 @@
"y": 32 "y": 32
}, },
"license": "CC-BY-NC-SA-3.0", "license": "CC-BY-NC-SA-3.0",
"copyright": "Modified by EmoGarbage404 and taken from https://github.com/goonstation/goonstation at commit b951a2c12d967af1295a3e6d33a861e7e1f21299.", "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": [ "states": [
{ {
"name": "cash" "name": "cash"
@@ -22,6 +22,99 @@
{ {
"name": "cash_1000" "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", "name": "cash_1000000",
"delays": [ "delays": [