This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
forked from new-frontiers-14/frontier-station-14
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Showing
1,136 changed files
with
86,653 additions
and
16,710 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
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
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
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
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
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
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
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
Oops, something went wrong.