同步
This commit is contained in:
@@ -16,6 +16,7 @@ namespace Ichni
|
||||
/// 游戏/谱面数据由 ProjectContainer 持有;
|
||||
/// 此处的属性均为转发属性,保持所有外部调用点零改动。
|
||||
/// </summary>
|
||||
[DefaultExecutionOrder(-100)]
|
||||
public class EditorManager : Singleton<EditorManager>
|
||||
{
|
||||
#region [单例别名] Singleton Alias
|
||||
@@ -37,13 +38,20 @@ namespace Ichni
|
||||
public BackgroundController backgroundController;
|
||||
public SimpleGridController gridController;
|
||||
public CameraManager cameraManager;
|
||||
public NoteManager noteManager;
|
||||
public TrackManager trackManager;
|
||||
public AnimationManager animationManager;
|
||||
public Canvas judgeHintCanvas;
|
||||
public Canvas inspectorCanvas;
|
||||
public Timeline timeline;
|
||||
public PanelDrawer panelDrawer;
|
||||
|
||||
/// <summary>集中式元素更新调度器,替代原先分散的帧更新逻辑</summary>
|
||||
[NonSerialized]
|
||||
public ElementUpdateScheduler updateScheduler;
|
||||
|
||||
/// <summary>
|
||||
/// NoteManager 转发属性。NoteManager 现为纯 C# 类,由 updateScheduler 内部持有。
|
||||
/// 保留此属性以兼容现有调用点。
|
||||
/// </summary>
|
||||
public NoteManager noteManager => updateScheduler?.NoteScheduler;
|
||||
#endregion
|
||||
|
||||
#region [编辑器首选项转发属性] Editor Preferences Forwarding Properties
|
||||
@@ -124,6 +132,14 @@ namespace Ichni
|
||||
// 不再直接依赖 EditorManager.instance.musicPlayer
|
||||
CoreServices.TimeProvider = musicPlayer;
|
||||
|
||||
// 初始化集中式更新调度器:
|
||||
// BeatmapContainer 在项目加载后才可用,使用 Func 延迟解析
|
||||
// NoteManager 在调度器内部创建,不再依赖外部 Singleton
|
||||
updateScheduler = new ElementUpdateScheduler(
|
||||
() => beatmapContainer
|
||||
);
|
||||
CoreServices.UpdateScheduler = updateScheduler;
|
||||
|
||||
if (!ES3.FileExists(Application.streamingAssetsPath + "/EditorSettings.es3"))
|
||||
{
|
||||
editorSettings = new EditorSettings(300, 3, 100, 100, 60);
|
||||
@@ -173,42 +189,14 @@ namespace Ichni
|
||||
|
||||
projectManager.autoSaveManager.UpdateAutoSave();
|
||||
|
||||
// 统一调度: Animation → Submodules → Track → Note
|
||||
float songTime = CoreServices.TimeProvider.SongTime;
|
||||
updateScheduler.TickEarly(songTime);
|
||||
}
|
||||
|
||||
animationManager.ManualTick(songTime);
|
||||
|
||||
// 手动执行原本属于 UniRx 的每帧调度,消灭不可控的时序错乱
|
||||
for (int i = 0; i < beatmapContainer.gameElementList.Count; i++)
|
||||
{
|
||||
var element = beatmapContainer.gameElementList[i];
|
||||
if (element == null) continue;
|
||||
|
||||
if (element is IHaveTimeDurationSubmodule timeHost && !(element is NoteBase))
|
||||
{
|
||||
timeHost.timeDurationSubmodule?.UpdateTimeDuration(songTime);
|
||||
}
|
||||
|
||||
if (element is IHaveDirtyMarkSubmodule dirtyHost)
|
||||
{
|
||||
dirtyHost.dirtyMarkSubmodule?.ExecuteDeferredRefresh();
|
||||
}
|
||||
|
||||
if (element.gameObject.activeSelf)
|
||||
{
|
||||
if (element is IHaveTransformSubmodule transformHost)
|
||||
{
|
||||
transformHost.UpdateTransform();
|
||||
}
|
||||
if (element is IHaveColorSubmodule colorHost)
|
||||
{
|
||||
colorHost.UpdateColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trackManager.ManualTick(songTime);
|
||||
noteManager.ManualTick(songTime);
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
updateScheduler.TickLate();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user