优化+清理

This commit is contained in:
SepComet
2026-04-26 15:02:56 +08:00
parent 41ce6f5834
commit 1fae93ee41
30 changed files with 583 additions and 697 deletions
@@ -1,4 +1,5 @@
using DataTable;
using Definition.Enum;
using Event;
using GameFramework.DataTable;
using GameFramework.Event;
@@ -16,6 +17,8 @@ namespace Procedure
private const int DialogChapterDivisor = 1000;
private IDataTable<DRDialog> _dtDialog;
private bool _pendingSceneChange;
private int _pendingSceneId;
public override bool UseNativeDialog => false;
@@ -25,6 +28,8 @@ namespace Procedure
AIChatEntryRuntime.EnsureOpen();
GameEntry.Event.Subscribe(StoryChapterEndedEventArgs.EventId, OnStoryChapterEnded);
_pendingSceneChange = false;
_pendingSceneId = 0;
GameEntry.Dialog.Init(InitialChapterId);
GameEntry.Dialog.StartDialog(InitialDialogId);
@@ -36,6 +41,21 @@ namespace Procedure
base.OnLeave(procedureOwner, isShutdown);
}
protected override void OnUpdate(IFsm<IProcedureManager> procedureOwner, float elapseSeconds,
float realElapseSeconds)
{
base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
if (!_pendingSceneChange)
{
return;
}
_pendingSceneChange = false;
procedureOwner.SetData<VarInt32>("NextSceneId", _pendingSceneId);
ChangeState<ProcedureChangeScene>(procedureOwner);
}
private void OnStoryChapterEnded(object sender, GameEventArgs e)
{
if (!(e is StoryChapterEndedEventArgs args))
@@ -54,8 +74,12 @@ namespace Procedure
if (!TryResolveFirstDialogId(nextChapterId, out int nextDialogId))
{
Log.Info("ProcedureMain chapter switch stopped. No dialog found for chapter '{0}'.",
nextChapterId.ToString());
Log.Info(
"ProcedureMain chapter '{0}' ended and no next chapter found. Return to menu scene.",
currentChapterId.ToString());
CloseBgFormIfOpened();
_pendingSceneId = (int)SceneId.Menu;
_pendingSceneChange = true;
return;
}
@@ -123,5 +147,19 @@ namespace Procedure
{
return dialogId / DialogChapterDivisor;
}
private static void CloseBgFormIfOpened()
{
if (GameEntry.UI == null)
{
return;
}
UGuiForm bgForm = GameEntry.UI.GetUIForm(UIFormId.BgForm);
if (bgForm != null)
{
GameEntry.UI.CloseUIForm(bgForm.UIForm);
}
}
}
}
@@ -69,8 +69,7 @@ namespace Procedure
e.Subscribe(MenuSettingEventArgs.EventId, MenuSetting);
e.Subscribe(MenuExitEventArgs.EventId, MenuExit);
e.Subscribe(SettingSaveEventArgs.EventId, SettingSave);
_menuFormController = new MenuFormController();
_menuFormController.OpenUI(new MenuFormContext());