30 lines
626 B
C#
30 lines
626 B
C#
using Godot;
|
|
|
|
namespace Game.Godot;
|
|
|
|
public static class GamePause
|
|
{
|
|
private static SceneTree Tree => (SceneTree)Engine.GetMainLoop();
|
|
|
|
public static bool IsPaused => Tree.Paused;
|
|
|
|
public static void Pause() => Tree.Paused = true;
|
|
|
|
public static void Resume() => Tree.Paused = false;
|
|
|
|
public static void Toggle()
|
|
{
|
|
if (IsPaused)
|
|
{
|
|
Resume();
|
|
}
|
|
else
|
|
{
|
|
Pause();
|
|
}
|
|
}
|
|
|
|
public static void SetIgnoresPause(Node node, bool value) =>
|
|
node.ProcessMode = value ? Node.ProcessModeEnum.Always : Node.ProcessModeEnum.Inherit;
|
|
}
|