File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 55
66namespace Gameframe . ScriptableObjects . Locks
77{
8+
9+ /// <summary>
10+ /// GameLock maintains an internal count for the number of times it's been locked
11+ /// The Locked property will be true when the count is not equal to zero
12+ /// Events are generated on Lock and Unlock
13+ /// </summary>
814 [ CreateAssetMenu ( menuName = MenuNames . LockMenu + "Lock" ) ]
915 public class GameLock : ScriptableObject , INotifyPropertyChanged
1016 {
1117 [ NonSerialized ]
1218 private int lockCount = 0 ;
1319
1420 public bool Locked => lockCount != 0 ;
21+
22+ /// <summary>
23+ /// OnValueChanged is raised when the state of the lock changes
24+ /// A value of True means the lock count is non-zero.
25+ /// </summary>
1526 public event Action < bool > OnValueChanged ;
1627
1728 [ SerializeField ]
@@ -47,6 +58,9 @@ private void OnEnable()
4758 lockCount = 0 ;
4859 }
4960
61+ /// <summary>
62+ /// Increment the internal counter which enables the lock
63+ /// </summary>
5064 public void Lock ( )
5165 {
5266 lockCount ++ ;
@@ -56,6 +70,9 @@ public void Lock()
5670 }
5771 }
5872
73+ /// <summary>
74+ /// Decrement the internal counter which disables the lock if it hits zero
75+ /// </summary>
5976 public void Unlock ( )
6077 {
6178 lockCount -- ;
You can’t perform that action at this time.
0 commit comments