feat: GameManager相关重构
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.Kit;
|
||||
using AibisDream.SaveSystem;
|
||||
@@ -11,6 +12,8 @@ namespace AibisDream
|
||||
{
|
||||
public class DialogController : Singleton<DialogController>
|
||||
{
|
||||
public event Action<bool> DialogueActivityChanged;
|
||||
|
||||
private DialogueRunner _dialogueRunner;
|
||||
|
||||
public DialogueRunner DialogueRunner => _dialogueRunner;
|
||||
@@ -30,11 +33,13 @@ namespace AibisDream
|
||||
|
||||
_dialogueRunner.onDialogueStart.AddListener(() =>
|
||||
{
|
||||
DialogueActivityChanged?.Invoke(true);
|
||||
EnumEventSystem.Global.Send(InteractionEventEnum.DialogStart);
|
||||
});
|
||||
|
||||
_dialogueRunner.onDialogueComplete.AddListener(() =>
|
||||
{
|
||||
DialogueActivityChanged?.Invoke(false);
|
||||
EnumEventSystem.Global.Send(InteractionEventEnum.DialogEnd);
|
||||
ClearCurrentNodeContext();
|
||||
});
|
||||
@@ -47,8 +52,8 @@ namespace AibisDream
|
||||
{
|
||||
SingleCastEventSystem.Global.Register<DialogEventEnum, string>(DialogEventEnum.StartNode, StartDialogNode);
|
||||
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameStart, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.Register(GameLoopEnum.GameQuit, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionStarted, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.Register(GameLifecycleEvent.SessionEnded, ResetAdvanceMode);
|
||||
|
||||
EnumEventSystem.Global.Register(DialogEventEnum.OptionShow, OnOptionShow);
|
||||
EnumEventSystem.Global.Register<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, OnOptionSelected);
|
||||
@@ -58,8 +63,8 @@ namespace AibisDream
|
||||
{
|
||||
SingleCastEventSystem.Global.Unregister(DialogEventEnum.StartNode);
|
||||
|
||||
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameStart, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.UnRegister(GameLoopEnum.GameQuit, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionStarted, ResetAdvanceMode);
|
||||
EnumEventSystem.Global.UnRegister(GameLifecycleEvent.SessionEnded, ResetAdvanceMode);
|
||||
|
||||
EnumEventSystem.Global.UnRegister(DialogEventEnum.OptionShow, OnOptionShow);
|
||||
EnumEventSystem.Global.UnRegister<DialogEventEnum, LineInfo>(DialogEventEnum.OptionSelected, OnOptionSelected);
|
||||
@@ -94,10 +99,20 @@ namespace AibisDream
|
||||
|
||||
public void StopDialog()
|
||||
{
|
||||
_ = _dialogueRunner.Stop();
|
||||
StartCoroutine(StopDialogRoutine());
|
||||
}
|
||||
|
||||
public IEnumerator StopDialogRoutine()
|
||||
{
|
||||
if (_dialogueRunner != null && _dialogueRunner.IsDialogueRunning)
|
||||
{
|
||||
yield return _dialogueRunner.Stop();
|
||||
}
|
||||
|
||||
SavePointEvaluator.ResetForProject(null);
|
||||
YarnVariableStorage.Instance.Clear();
|
||||
DialogUIManager.Instance.HideDialog();
|
||||
DialogueActivityChanged?.Invoke(false);
|
||||
}
|
||||
|
||||
public void LoadDialog(YarnProject yarnProject)
|
||||
@@ -314,4 +329,4 @@ namespace AibisDream
|
||||
Auto,
|
||||
Quick
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user