Skip to content

Commit d6c3ebd

Browse files
committed
Documenting lock
1 parent c5c981f commit d6c3ebd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Runtime/Locks/GameLock.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@
55

66
namespace 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--;

0 commit comments

Comments
 (0)