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

Commit e6f06e5

Browse files
Made clamped variable min/max values references
1 parent 2a3a769 commit e6f06e5

14 files changed

Lines changed: 43 additions & 41 deletions

Assets/SO Architecture/Editor/Code Generation/SO_CodeGenerationWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class SO_CodeGenerationWindow : EditorWindow
2020
* 4
2121
* 5
2222
* 6
23-
* 7
23+
* 7 X X
2424
*/
2525

2626
private bool[,] _dependencyGraph = new bool[SO_CodeGenerator.TYPE_COUNT, SO_CodeGenerator.TYPE_COUNT]
@@ -31,7 +31,7 @@ public class SO_CodeGenerationWindow : EditorWindow
3131
{ false, false, false, false, false, false, false },
3232
{ false, false, false, false, false, false, false },
3333
{ false, false, false, false, false, false, false },
34-
{ false, false, false, false, false, false, false },
34+
{ false, false, false, true, false, true, false },
3535
};
3636

3737
private bool[] _states = new bool[SO_CodeGenerator.TYPE_COUNT];

Assets/SO Architecture/Editor/Code Generation/Templates/ClampedVariableTemplate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ using UnityEngine;
44
fileName = "$TYPE_NAME$ClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "$MENU_NAME$",
66
order = $ORDER$)]
7-
public class $TYPE_NAME$ClampedVariable : ClampedVariable<$TYPE$>
7+
public class $TYPE_NAME$ClampedVariable : ClampedVariable<$TYPE$, $TYPE_NAME$Variable, $TYPE_NAME$Reference>
88
{
99
}

Assets/SO Architecture/Editor/Inspectors/ClampedVariableEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using UnityEngine;
44
using UnityEditor;
55

6-
[CustomEditor(typeof(ClampedVariable<>), true)]
6+
[CustomEditor(typeof(ClampedVariable<,,>), true)]
77
public class ClampedVariableEditor : BaseVariableEditor
88
{
99
private SerializedProperty _minValueProperty;

Assets/SO Architecture/Variables/Clamped/ByteClampedVariable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
fileName = "ByteClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "byte",
66
order = SOArchitecture_Utility.ASSET_MENU_ORDER_CLAMPED_VARIABLES + 2)]
7-
public class ByteClampedVariable : ClampedVariable<byte>
7+
public class ByteClampedVariable : ClampedVariable<byte, ByteVariable, ByteReference>
88
{
99
protected override byte ClampValue(byte value)
1010
{
11-
return (byte)Mathf.Clamp(value, MinValue, MaxValue);
11+
return (byte)Mathf.Clamp(value, MinValue.Value, MaxValue.Value);
1212
}
1313
}

Assets/SO Architecture/Variables/Clamped/ClampedVariable.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
using System.Collections.Generic;
33
using UnityEngine;
44

5-
public abstract class ClampedVariable<T> : BaseVariable<T>
5+
public abstract class ClampedVariable<TType, TVariable, TReference> : BaseVariable<TType>
6+
where TVariable : BaseVariable<TType>
7+
where TReference : BaseReference<TType, TVariable>
68
{
7-
protected T MinValue { get { return _minClampedValue; } }
8-
protected T MaxValue { get { return _maxClampedValue; } }
9+
protected TReference MinValue { get { return _minClampedValue; } }
10+
protected TReference MaxValue { get { return _maxClampedValue; } }
911

1012
[SerializeField]
11-
private T _minClampedValue;
13+
private TReference _minClampedValue;
1214
[SerializeField]
13-
private T _maxClampedValue;
15+
private TReference _maxClampedValue;
1416

15-
protected abstract T ClampValue(T value);
17+
protected abstract TType ClampValue(TType value);
1618

17-
public override T SetValue(BaseVariable<T> value)
19+
public override TType SetValue(BaseVariable<TType> value)
1820
{
1921
return ClampValue(value.Value);
2022
}
21-
public override T SetValue(T value)
23+
public override TType SetValue(TType value)
2224
{
2325
return ClampValue(value);
2426
}

Assets/SO Architecture/Variables/Clamped/DoubleClampedVariable.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
fileName = "DoubleClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "double",
66
order = SOArchitecture_Utility.ASSET_MENU_ORDER_CLAMPED_VARIABLES + 3)]
7-
public class DoubleClampedVariable : ClampedVariable<double>
7+
public class DoubleClampedVariable : ClampedVariable<double, DoubleVariable, DoubleReference>
88
{
99
protected override double ClampValue(double value)
1010
{
11-
if (value < MinValue)
12-
return MinValue;
11+
if (value < MinValue.Value)
12+
return MinValue.Value;
1313

14-
if (value > MaxValue)
15-
return MaxValue;
14+
if (value > MaxValue.Value)
15+
return MaxValue.Value;
1616

1717
return value;
1818
}

Assets/SO Architecture/Variables/Clamped/FloatClampedVariable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
fileName = "FloatClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "float",
66
order = SOArchitecture_Utility.ASSET_MENU_ORDER_CLAMPED_VARIABLES + 0)]
7-
public class FloatClampedVariable : ClampedVariable<float>
7+
public class FloatClampedVariable : ClampedVariable<float, FloatVariable, FloatReference>
88
{
99
protected override float ClampValue(float value)
1010
{
11-
return Mathf.Clamp(value, MinValue, MaxValue);
11+
return Mathf.Clamp(value, MinValue.Value, MaxValue.Value);
1212
}
1313
}

Assets/SO Architecture/Variables/Clamped/IntClampedVariable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
fileName = "IntClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "int",
66
order = SOArchitecture_Utility.ASSET_MENU_ORDER_CLAMPED_VARIABLES + 1)]
7-
public class IntClampedVariable : ClampedVariable<int>
7+
public class IntClampedVariable : ClampedVariable<int, IntVariable, IntReference>
88
{
99
protected override int ClampValue(int value)
1010
{
11-
return Mathf.Clamp(value, MinValue, MaxValue);
11+
return Mathf.Clamp(value, MinValue.Value, MaxValue.Value);
1212
}
1313
}

Assets/SO Architecture/Variables/Clamped/LongClampedVariable.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
fileName = "LongClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "long",
66
order = SOArchitecture_Utility.ASSET_MENU_ORDER_CLAMPED_VARIABLES + 4)]
7-
public class LongClampedVariable : ClampedVariable<long>
7+
public class LongClampedVariable : ClampedVariable<long, LongVariable, LongReference>
88
{
99
protected override long ClampValue(long value)
1010
{
11-
if (value < MinValue)
12-
return MinValue;
11+
if (value < MinValue.Value)
12+
return MinValue.Value;
1313

14-
if (value > MaxValue)
15-
return MaxValue;
14+
if (value > MaxValue.Value)
15+
return MaxValue.Value;
1616

1717
return value;
1818
}

Assets/SO Architecture/Variables/Clamped/SByteClampedVariable.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
fileName = "SbyteClampedVariable.asset",
55
menuName = SOArchitecture_Utility.VARIABLE_CLAMPED_SUBMENU + "sbyte",
66
order = SOArchitecture_Utility.ASSET_MENU_ORDER_CLAMPED_VARIABLES + 6)]
7-
public class SbyteClampedVariable : ClampedVariable<sbyte>
7+
public class SbyteClampedVariable : ClampedVariable<sbyte, SByteVariable, SByteReference>
88
{
99
protected override sbyte ClampValue(sbyte value)
1010
{
11-
return (sbyte)Mathf.Clamp(value, MinValue, MaxValue);
11+
return (sbyte)Mathf.Clamp(value, MinValue.Value, MaxValue.Value);
1212
}
1313
}

0 commit comments

Comments
 (0)