-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd429b4
commit 2a20c43
Showing
20 changed files
with
295 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"profiles": { | ||
"WSL": { | ||
"commandName": "WSL2", | ||
"distributionName": "" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Content.Shared/_NF/Stacks/Components/StackLayerThresholdComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Content.Shared.Stacks.Components; | ||
|
||
[RegisterComponent] | ||
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 List<int>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Content.Shared.Stacks; | ||
|
||
public enum StackLayerFunction | ||
{ | ||
None, | ||
Threshold | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
Resources/Prototypes/_NF/Entities/Objects/Misc/space_cash.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- type: entity | ||
parent: SpaceCash | ||
id: SpaceCash15000 | ||
suffix: 15000 | ||
components: | ||
- type: Icon | ||
sprite: _NF/Objects/Economy/cash.rsi | ||
state: cash_10000 | ||
- type: Stack | ||
count: 15000 | ||
|
||
- type: entity | ||
parent: SpaceCash | ||
id: SpaceCash25000 | ||
suffix: 25000 | ||
components: | ||
- type: Icon | ||
sprite: _NF/Objects/Economy/cash.rsi | ||
state: cash_25000 | ||
- type: Stack | ||
count: 25000 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.