-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPauseHelper.cs
More file actions
65 lines (60 loc) · 1.22 KB
/
PauseHelper.cs
File metadata and controls
65 lines (60 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using UnityEngine;
namespace Uzu
{
/// <summary>
/// Allows generic pausing through bit flags.
/// By using flags, it allows us to have certain functionality
/// paused, while other functionality continues to update.
///
/// Example:
/// Uzu.PauseHelper pauseObject = new Uzu.PauseHelper();
///
/// // Define:
/// const int BACKGROUND_LAYER = 1 << 0;
///
/// // From GUI button:
/// pauseObject.Pause(BACKGROUND_LAYER);
///
/// // ...
///
/// // From background layer (Update()):
/// if (pauseObject.IsPaused(BACKGROUND_LAYER)) {
/// return;
/// }
///
/// </summary>
public class PauseHelper
{
/// <summary>
/// Pause the specified flag.
/// </summary>
public void Pause (int flag)
{
_flags |= flag;
}
/// <summary>
/// Unpause the specified flag.
/// </summary>
public void Unpause (int flag)
{
_flags &= ~flag;
}
/// <summary>
/// Unpause all flags.
/// </summary>
public void UnpauseAll ()
{
_flags = 0;
}
/// <summary>
/// Determines whether the specified flag is paused.
/// </summary>
public bool IsPaused (int flag)
{
return (_flags & flag) != 0;
}
#region Implementation.
private int _flags = 0;
#endregion
}
}