Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit bcc1855

Browse files
Updated clamped variables documentation
1 parent 0e28a76 commit bcc1855

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Assets/SO Architecture/Documentation/Clamped-Variables.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Clamped Variables were created for two very simple reasons. We very often would
44
We obviously don't want the PlayerHealth to exceed the maximum allowed health, nor do we want it to dip below 0. We would have to ensure that every single piece of code that references this variable ensured to clamp it properly, or force them to assign it through a static function that did it for them. That's not very Unity-like. So instead I decided to make a variable that does this dynamically. Code that references such an object doesn't need to know which values to clamp it to, it can simply assign whatever value it pleases without worry.
55

66
## Script Reference
7-
Since we're clamping an unknown type, it is impossible for me to make an implementation that'll definitely work with everything. I could write a relatively safe implementation of Mathf.Clamp, but if you're using any known numerical value, I've already implemented a Clamped Variable type for you, so it seemed like a bad idea to make such an assumption.
7+
Clamped Variables inherit IClampedVariable<TType, TVariable, TReference> which contains the following members
88

9-
abstract TType ClampValue(TType value);
9+
TType ClampValue(TType value);
1010

1111
TReference MinValue { get; }
1212
TReference MaxValue { get; }

0 commit comments

Comments
 (0)