Frontier Port: Pretty Money (#2398)

* Frontier Port: Pretty Money

* Update Resources/Prototypes/Entities/Objects/Misc/space_cash.yml

Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com>
Signed-off-by: Unkn0wn_Gh0st <shadowstalkermll@gmail.com>

* Updated 100k texture

---------

Signed-off-by: Unkn0wn_Gh0st <shadowstalkermll@gmail.com>
Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com>
(cherry picked from commit da772611f8b2b02f21f801ccf255220602e850e5)
This commit is contained in:
Unkn0wn_Gh0st
2024-12-17 19:30:21 -06:00
committed by Spatison
parent 2cecfc8ffc
commit e05ee08c05
20 changed files with 291 additions and 28 deletions

View File

@@ -0,0 +1,56 @@
using Content.Shared.Stacks.Components;
using Content.Shared.Stacks;
namespace Content.Client.Stack
{
/// <summary>
/// Data used to determine which layers of a stack's sprite are visible.
/// </summary>
public struct StackLayerData
{
public int Actual;
public int MaxCount;
public bool Hidden;
}
public sealed partial class StackSystem : SharedStackSystem
{
// Modifies a given stack component to adjust the layers to display.
private bool ApplyLayerFunction(EntityUid uid, StackComponent comp, ref StackLayerData data)
{
switch (comp.LayerFunction)
{
case StackLayerFunction.Threshold:
if (TryComp<StackLayerThresholdComponent>(uid, out var threshold))
{
ApplyThreshold(threshold, ref data);
return true;
}
break;
}
// No function applied.
return false;
}
/// <summary>
/// Sets Actual to the number of thresholds that Actual exceeds from the beginning of the list.
/// Sets MaxCount to the total number of thresholds plus one (for values under thresholds).
/// </summary>
private static void ApplyThreshold(StackLayerThresholdComponent comp, ref StackLayerData data)
{
// We must stop before we run out of thresholds or layers, whichever's smaller.
data.MaxCount = Math.Min(comp.Thresholds.Count + 1, data.MaxCount);
int 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 (data.Actual >= threshold && newActual < data.MaxCount)
newActual++;
else
break;
}
data.Actual = newActual;
}
}
}