Clean up IPausable interafaces a little bit and start refactoring the pause-game flow in the minigame
This commit is contained in:
@@ -24,15 +24,6 @@ namespace UI
|
||||
[SerializeField] private GameObject pauseButton;
|
||||
[SerializeField] private CanvasGroup canvasGroup;
|
||||
|
||||
public event Action OnGamePaused;
|
||||
public event Action OnGameResumed;
|
||||
|
||||
private bool _isPaused = false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the game is currently paused
|
||||
/// </summary>
|
||||
public bool IsPaused => _isPaused;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -103,7 +94,7 @@ namespace UI
|
||||
/// </summary>
|
||||
public void ShowPauseMenu()
|
||||
{
|
||||
if (_isPaused) return;
|
||||
if (GameManager.Instance.IsPaused) return;
|
||||
if (UIPageController.Instance != null)
|
||||
{
|
||||
UIPageController.Instance.PushPage(this);
|
||||
@@ -130,7 +121,7 @@ namespace UI
|
||||
/// </summary>
|
||||
public void HidePauseMenu(bool resetInput = true)
|
||||
{
|
||||
if (!_isPaused)
|
||||
if (!GameManager.Instance.IsPaused)
|
||||
{
|
||||
// Ensure UI is hidden if somehow active without state
|
||||
if (pauseMenuPanel != null) pauseMenuPanel.SetActive(false);
|
||||
@@ -169,19 +160,17 @@ namespace UI
|
||||
|
||||
private void BeginPauseSideEffects()
|
||||
{
|
||||
_isPaused = true;
|
||||
if (pauseButton != null) pauseButton.SetActive(false);
|
||||
InputManager.Instance.SetInputMode(InputMode.UI);
|
||||
OnGamePaused?.Invoke();
|
||||
GameManager.Instance.RequestGamePause();
|
||||
Logging.Debug("[PauseMenu] Game Paused");
|
||||
}
|
||||
|
||||
private void EndPauseSideEffects(bool invokeEvent)
|
||||
{
|
||||
_isPaused = false;
|
||||
if (pauseButton != null) pauseButton.SetActive(true);
|
||||
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
|
||||
if (invokeEvent) OnGameResumed?.Invoke();
|
||||
GameManager.Instance.RequestGameResume();
|
||||
Logging.Debug("[PauseMenu] Game Resumed");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user