Class ByteExtensions
- Namespace
- FishMMO.Shared
- Assembly
- FishMMO-SharedUtility.dll
Provides deterministic byte utility methods for the FishMMO framework. All calculations use pure integer math to ensure cross-platform consistency.
public static class ByteExtensions
- Inheritance
-
ByteExtensions
- Inherited Members
Methods
Clamp(byte, byte, byte)
Returns the byte clamped to the specified inclusive minimum and maximum range.
public static byte Clamp(this byte number, byte minimum, byte maximum)
Parameters
numberbyteThe value to clamp.
minimumbyteThe lowest possible result.
maximumbyteThe highest possible result.
Returns
- byte
The clamped byte value.
DigitCount(byte)
Returns the total count of digits in the byte value using deterministic range checks.
public static int DigitCount(this byte number)
Parameters
numberbyteThe byte to check (0-255).
Returns
- int
The number of digits (e.g., 255 returns 3, 0 returns 1).
GetDigit(byte, int)
Returns the specific digit at the given index, where 0 is the least significant digit (ones place).
public static byte GetDigit(this byte number, int digitIndex)
Parameters
Returns
- byte
The single-digit value (0-9).
GetPercentOf(byte, int)
Calculates a percentage of a byte using integer math with standard rounding (0.5 rounds up). Useful for small-value modifiers like status effects.
public static byte GetPercentOf(this byte number, int percent)
Parameters
Returns
- byte
The rounded result clamped back to a byte.