Prevent growth overflow, add .Between(min, max) extension methods to simplify time/temp checks

This commit is contained in:
2023-07-16 01:36:46 -05:00
parent 06957a26d9
commit 96267e251c
3 changed files with 38 additions and 9 deletions

View File

@@ -0,0 +1,21 @@
namespace HydroponicsExpanded.Utility {
public static class BetweenExtension {
public static bool Between(this float value, float min, float max, bool inclusive = false) {
if (inclusive)
return value >= min && value <= max;
return value > min && value < max;
}
public static bool Between(this double value, double min, double max, bool inclusive = false) {
if (inclusive)
return value >= min && value <= max;
return value > min && value < max;
}
public static bool Between(this int value, int min, int max, bool inclusive = false) {
if (inclusive)
return value >= min && value <= max;
return value > min && value < max;
}
}
}