feat: GameManager相关重构

This commit is contained in:
2026-07-17 14:24:02 +08:00
parent 2dcfeec938
commit 21d51945c3
47 changed files with 2064 additions and 1022 deletions
+3 -3
View File
@@ -76,9 +76,9 @@ namespace AibisDream
private CursorStateEnum CheckCursorState()
{
var gameState = GameManager.Instance.state;
var gameState = GameManager.Session;
if (!gameState.isInGame || gameState.isInPause)
if (gameState.Phase != GameSessionPhase.Playing || gameState.IsPaused)
{
// 非游戏中显示默认指针
return CursorStateEnum.Default;
@@ -88,7 +88,7 @@ namespace AibisDream
// 游戏中鼠标移至右上角Main Panel时显示默认指针
return CursorStateEnum.Default;
}
else if (gameState.isInDialog)
else if (gameState.IsDialogueActive)
{
// 处理对话中的指针
var dialogState = DialogController.Instance.GetDialogState();
@@ -25,7 +25,9 @@ namespace AibisDream
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.LineStart, AddDialogueLine);
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, AddDialogueLine);
EnumEventSystem.Global.Register(EventEnum.NextYarn, CleanDialogHistory);
EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, CleanDialogHistory);
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionEnded, CleanDialogHistory);
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionPaused, CloseCanvas);
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionResumed, OpenCanvas);
}
public override void OnSingletonDestroy()
@@ -33,7 +35,9 @@ namespace AibisDream
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.LineStart, AddDialogueLine);
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, AddDialogueLine);
EnumEventSystem.Global.UnRegister(EventEnum.NextYarn, CleanDialogHistory);
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameQuit, CleanDialogHistory);
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionEnded, CleanDialogHistory);
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionPaused, CloseCanvas);
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionResumed, OpenCanvas);
}
private void AddDialogueLine(LineInfo line)
+2 -2
View File
@@ -39,7 +39,7 @@ namespace AibisDream.UI
private void BackToMain()
{
UIManager.Instance.HidePanel<EndPanel>();
GameManager.Instance.QuitGame();
GameManager.Instance.TryReturnToMainMenu();
}
// private void OpenFeedbackLink()
@@ -52,4 +52,4 @@ namespace AibisDream.UI
// Application.OpenURL(ConstRef.BugSurveyURL);
// }
}
}
}
@@ -145,7 +145,7 @@ namespace AibisDream.UI
public void CloseToMainMenu()
{
Close(restoreAmb: false);
GameManager.Instance.QuitGame();
GameManager.Instance.TryReturnToMainMenu();
}
public void SetHeader(string title, string status = "")
@@ -165,12 +165,12 @@ namespace AibisDream.UI
private void PauseIfNeeded()
{
if (GameManager.Instance == null || !GameManager.Instance.state.isInGame || _pausedByPanel)
if (GameManager.Instance == null || !GameManager.Session.CanPause || _pausedByPanel)
{
return;
}
GameManager.Instance.PauseGame();
GameManager.Instance.TryPause();
TerminalUIAudio.NotifyPauseMenuAmbEnter();
_pausedByPanel = true;
}
@@ -182,7 +182,7 @@ namespace AibisDream.UI
return;
}
GameManager.Instance.ContinueGame();
GameManager.Instance.TryResume();
TerminalUIAudio.NotifyPauseMenuAmbExit(restoreAmb);
_pausedByPanel = false;
}
+1 -1
View File
@@ -259,7 +259,7 @@ namespace AibisDream.UI
public void CloseToMainMenu()
{
Close();
GameManager.Instance.QuitGame();
GameManager.Instance.TryReturnToMainMenu();
}
public void SetHeader(string title, string status = "")
@@ -166,11 +166,11 @@ namespace AibisDream.UI
var terminal = UIManager.Instance.GetPanel<TerminalPanel>();
if (terminal != null && terminal.IsOpen)
{
terminal.CloseThen(() => GameManager.Instance.StartWithSlot(SlotIndex.Auto));
terminal.CloseThen(() => GameManager.Instance.TryRestoreSlot(SlotIndex.Auto));
return;
}
GameManager.Instance.StartWithSlot(SlotIndex.Auto);
GameManager.Instance.TryRestoreSlot(SlotIndex.Auto);
}
private static void StartNewGame()
@@ -178,11 +178,11 @@ namespace AibisDream.UI
var terminal = UIManager.Instance.GetPanel<TerminalPanel>();
if (terminal != null && terminal.IsOpen)
{
terminal.CloseThen(() => GameManager.Instance.StartNewGame());
terminal.CloseThen(() => GameManager.Instance.TryStartNewGame());
return;
}
GameManager.Instance.StartNewGame();
GameManager.Instance.TryStartNewGame();
}
private void OpenChapter()
@@ -197,7 +197,7 @@ namespace AibisDream.UI
private static void QuitApp()
{
GameManager.Instance.QuitApp();
GameManager.Instance.QuitApplication();
}
}
}
+4 -4
View File
@@ -46,7 +46,7 @@ namespace AibisDream
return;
}
if (GameManager.Instance != null && GameManager.Instance.state.isInGame)
if (GameManager.Instance != null && GameManager.Session.CanPause)
{
GetPanel<InGameTerminalPanel>()?.Open(InGameTerminalPage.Setting);
}
@@ -85,9 +85,9 @@ namespace AibisDream
panel.Initialize();
}
EnumEventSystem.Global.Register(GameLoopEnum.AppStart, OnAppStart);
EnumEventSystem.Global.Register(GameLoopEnum.GameStart, OnGameStart);
EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, OnGameQuit);
EnumEventSystem.Global.Register(GameLifecycleEvent.ApplicationReady, OnAppStart);
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionStarted, OnGameStart);
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionEnded, OnGameQuit);
}
private void OnAppStart()